@synnaxlabs/x 0.25.0 → 0.26.7

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 (48) hide show
  1. package/.turbo/turbo-build.log +22 -20
  2. package/dist/binary.cjs +1 -3
  3. package/dist/binary.js +2 -98
  4. package/dist/{box-DC5oviHL.js → box-B5SaODGu.js} +1 -1
  5. package/dist/{box-BcFruCBW.cjs → box-C6r0YnKB.cjs} +1 -1
  6. package/dist/box.cjs +1 -1
  7. package/dist/box.js +1 -1
  8. package/dist/caseconv.cjs +1 -1
  9. package/dist/caseconv.js +1 -1
  10. package/dist/index-BGz7XJIe.cjs +1 -0
  11. package/dist/{index-CQk9JICS.js → index-C9i674Sf.js} +18 -18
  12. package/dist/index-CzjnpuXF.js +101 -0
  13. package/dist/index-tYmAULd8.cjs +3 -0
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.js +7 -7
  16. package/dist/{location-wMqTcQ0n.cjs → location-55G2uRZN.cjs} +1 -1
  17. package/dist/{location-D4yS2DfR.js → location-C6sCnzhU.js} +1 -1
  18. package/dist/location.cjs +1 -1
  19. package/dist/location.js +1 -1
  20. package/dist/{position-DvsYXRzE.js → position-BY9oBMZB.js} +2 -2
  21. package/dist/{position-DolPXOLe.cjs → position-BwmbckCe.cjs} +1 -1
  22. package/dist/position.cjs +1 -1
  23. package/dist/position.js +1 -1
  24. package/dist/{scale-6y6-BcVI.js → scale-BgCpxgAk.js} +2 -2
  25. package/dist/{scale-D_uVU2Fw.cjs → scale-COuYv97b.cjs} +1 -1
  26. package/dist/scale.cjs +1 -1
  27. package/dist/scale.js +1 -1
  28. package/dist/series-CNcMldp_.cjs +11 -0
  29. package/dist/{series-B3wKdjpi.js → series-CaeAWaDJ.js} +217 -216
  30. package/dist/spatial.cjs +1 -1
  31. package/dist/spatial.js +4 -4
  32. package/dist/src/binary/encoder.d.ts +11 -11
  33. package/dist/src/binary/encoder.d.ts.map +1 -1
  34. package/dist/src/caseconv/caseconv.d.ts +2 -2
  35. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  36. package/dist/src/telem/series.d.ts.map +1 -1
  37. package/dist/telem.cjs +1 -1
  38. package/dist/telem.js +1 -1
  39. package/package.json +3 -3
  40. package/src/binary/encoder.spec.ts +12 -12
  41. package/src/binary/encoder.ts +11 -11
  42. package/src/caseconv/caseconv.ts +9 -6
  43. package/src/telem/series.spec.ts +17 -3
  44. package/src/telem/series.ts +5 -4
  45. package/src/telem/telem.spec.ts +1 -1
  46. package/tsconfig.tsbuildinfo +1 -1
  47. package/dist/index-2SfxIaaU.cjs +0 -1
  48. package/dist/series-PoUlr-RX.cjs +0 -11
package/dist/scale.js CHANGED
@@ -1,4 +1,4 @@
1
- import { s as e } from "./scale-6y6-BcVI.js";
1
+ import { s as e } from "./scale-BgCpxgAk.js";
2
2
  export {
3
3
  e as scale
4
4
  };
@@ -0,0 +1,11 @@
1
+ "use strict";var K=Object.defineProperty;var j=(f,t,e)=>t in f?K(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e;var s=(f,t,e)=>j(f,typeof t!="symbol"?t+"":t,e);const L=require("./index-tYmAULd8.cjs"),H=require("./index-BGz7XJIe.cjs"),X=require("./index-CvHP07Bs.cjs"),z=require("./bounds-ZZc1c-_Z.cjs");require("./box-C6r0YnKB.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-55G2uRZN.cjs");require("./scale-COuYv97b.cjs");require("./xy-cP-FXJtR.cjs");const c=require("zod");let Q=(f,t=21)=>(e=t)=>{let r="",u=e;for(;u--;)r+=f[Math.random()*f.length|0];return r};const _="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Z=Q(_,11),tt=Object.freeze(Object.defineProperty({__proto__:null,id:Z},Symbol.toStringTag,{value:"Module"})),k=(f,t)=>{const e=new y(t);if(![w.DAY,w.HOUR,w.MINUTE,w.SECOND,w.MILLISECOND,w.MICROSECOND,w.NANOSECOND].some(u=>u.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const r=f.valueOf()%e.valueOf();return f instanceof y?new y(r):new w(r)},i=class i{constructor(t,e="UTC"){s(this,"value");s(this,"encodeValue",!0);if(t==null)this.value=i.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*i.MILLISECOND.valueOf();else if(typeof t=="string")this.value=i.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=i.parseDate(t);else{let r=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(r=i.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=i.MAX:t=i.MIN)),this.value=BigInt(t.valueOf())+r}}static parseDate([t=1970,e=1,r=1]){const u=new Date(t,e-1,r,0,0,0,0);return new i(BigInt(u.getTime())*i.MILLISECOND.valueOf()).truncate(i.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[r,u,h]=t.split(":");let g="00",N="00";h!=null&&([g,N]=h.split("."));let O=i.hours(parseInt(r??"00",10)).add(i.minutes(parseInt(u??"00",10))).add(i.seconds(parseInt(g??"00",10))).add(i.milliseconds(parseInt(N??"00",10)));return e==="local"&&(O=O.add(i.utcOffset)),O.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return i.parseTimeString(t,e);const r=new Date(t);return t.includes(":")||r.setUTCHours(0,0,0,0),new i(BigInt(r.getTime())*i.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(i.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const r=this.toISOString(e);return t?r.slice(11,23):r.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),r=t.toLocaleString("default",{day:"numeric"});return`${e} ${r}`}static get utcOffset(){return new w(BigInt(new Date().getTimezoneOffset())*i.MINUTE.valueOf())}static since(t){return new i().span(t)}date(){return new Date(this.milliseconds())}equals(t){return this.valueOf()===new i(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 i(t).valueOf()}afterEq(t){return this.valueOf()>=new i(t).valueOf()}before(t){return this.valueOf()<new i(t).valueOf()}beforeEq(t){return this.valueOf()<=new i(t).valueOf()}add(t){return new i(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new i(this.valueOf()-BigInt(t.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(i.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(t){return k(this,t)}get isToday(){return this.truncate(w.DAY).equals(i.now().truncate(w.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new i(new Date)}static max(...t){let e=i.MIN;for(const r of t){const u=new i(r);u.after(e)&&(e=u)}return e}static min(...t){let e=i.MAX;for(const r of t){const u=new i(r);u.before(e)&&(e=u)}return e}static nanoseconds(t){return new i(t)}static microseconds(t){return i.nanoseconds(t*1e3)}static milliseconds(t){return i.microseconds(t*1e3)}static seconds(t){return i.milliseconds(t*1e3)}static minutes(t){return i.seconds(t*60)}static hours(t){return i.minutes(t*60)}static days(t){return i.hours(t*24)}};s(i,"NANOSECOND",i.nanoseconds(1)),s(i,"MICROSECOND",i.microseconds(1)),s(i,"MILLISECOND",i.milliseconds(1)),s(i,"SECOND",i.seconds(1)),s(i,"MINUTE",i.minutes(1)),s(i,"HOUR",i.hours(1)),s(i,"DAY",i.days(1)),s(i,"MAX",new i((1n<<63n)-1n)),s(i,"MIN",new i(0)),s(i,"ZERO",new i(0)),s(i,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new i(t.value)),c.z.string().transform(t=>new i(BigInt(t))),c.z.instanceof(Number).transform(t=>new i(t)),c.z.number().transform(t=>new i(t)),c.z.instanceof(i)]));let y=i;const a=class a{constructor(t){s(this,"value");s(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new a(t).valueOf()}greaterThan(t){return this.valueOf()>new a(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new a(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new a(t).valueOf()}remainder(t){return k(this,t)}truncate(t){return new a(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(a.DAY),e=this.truncate(a.HOUR),r=this.truncate(a.MINUTE),u=this.truncate(a.SECOND),h=this.truncate(a.MILLISECOND),g=this.truncate(a.MICROSECOND),N=this.truncate(a.NANOSECOND),O=t,S=e.sub(t),p=r.sub(e),o=u.sub(r),B=h.sub(u),U=g.sub(h),q=N.sub(g);let A="";return O.isZero||(A+=`${O.days}d `),S.isZero||(A+=`${S.hours}h `),p.isZero||(A+=`${p.minutes}m `),o.isZero||(A+=`${o.seconds}s `),B.isZero||(A+=`${B.milliseconds}ms `),U.isZero||(A+=`${U.microseconds}µs `),q.isZero||(A+=`${q.nanoseconds}ns`),A.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(t){return this.valueOf()===new a(t).valueOf()}add(t){return new a(this.valueOf()+new a(t).valueOf())}sub(t){return new a(this.valueOf()-new a(t).valueOf())}static nanoseconds(t=1){return new a(t)}static microseconds(t=1){return a.nanoseconds(t*1e3)}static milliseconds(t=1){return a.microseconds(t*1e3)}static seconds(t=1){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t.valueOf()*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};s(a,"NANOSECOND",a.nanoseconds(1)),s(a,"MICROSECOND",a.microseconds(1)),s(a,"MILLISECOND",a.milliseconds(1)),s(a,"SECOND",a.seconds(1)),s(a,"MINUTE",a.minutes(1)),s(a,"HOUR",a.hours(1)),s(a,"DAY",a.days(1)),s(a,"MAX",new a((1n<<63n)-1n)),s(a,"MIN",new a(0)),s(a,"ZERO",new a(0)),s(a,"z",c.z.union([c.z.object({value:c.z.bigint()}).transform(t=>new a(t.value)),c.z.string().transform(t=>new a(BigInt(t))),c.z.instanceof(Number).transform(t=>new a(t)),c.z.number().transform(t=>new a(t)),c.z.instanceof(a)]));let w=a;const v=class v extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new v(t).valueOf()}get period(){return w.seconds(1/this.valueOf())}sampleCount(t){return new w(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return w.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new v(t)}static khz(t){return v.hz(t*1e3)}};s(v,"z",c.z.union([c.z.number().transform(t=>new v(t)),c.z.instanceof(Number).transform(t=>new v(t)),c.z.instanceof(v)]));let x=v;const m=class m extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new C(t*this.valueOf())}};s(m,"UNKNOWN",new m(0)),s(m,"BIT128",new m(16)),s(m,"BIT64",new m(8)),s(m,"BIT32",new m(4)),s(m,"BIT16",new m(2)),s(m,"BIT8",new m(1)),s(m,"z",c.z.union([c.z.number().transform(t=>new m(t)),c.z.instanceof(Number).transform(t=>new m(t)),c.z.instanceof(m)]));let I=m;const T=class T{constructor(t,e){s(this,"start");s(this,"end");typeof t=="object"&&"start"in t?(this.start=new y(t.start),this.end=new y(t.end)):(this.start=new y(t),this.end=new y(e))}get span(){return new w(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new T(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=w.ZERO){t=t.makeValid();const r=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(r.start)||r.end.equals(t.start))return!1;const u=y.max(r.start,t.start),h=y.min(r.end,t.end);return h.before(u)?!1:new w(h.sub(u)).greaterThanOrEqual(e)}roughlyEquals(t,e){let r=this.start.sub(t.start).valueOf(),u=this.end.sub(t.end).valueOf();return r<0&&(r=-r),u<0&&(u=-u),r<=e.valueOf()&&u<=e.valueOf()}contains(t){return t instanceof T?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new T(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}};s(T,"MAX",new T(y.MIN,y.MAX)),s(T,"MIN",new T(y.MAX,y.MIN)),s(T,"ZERO",new T(y.ZERO,y.ZERO)),s(T,"z",c.z.union([c.z.object({start:y.z,end:y.z}).transform(t=>new T(t.start,t.end)),c.z.instanceof(T)]));let M=T;const n=class n extends String{constructor(t){if(t instanceof n||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}else{const e=n.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}}throw super(n.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=n.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()}toString(){return this.valueOf()}get isVariable(){return this.equals(n.JSON)||this.equals(n.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(n.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=n.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 n.BIG_INT_TYPES.some(t=>t.equals(this))}};s(n,"UNKNOWN",new n("unknown")),s(n,"FLOAT64",new n("float64")),s(n,"FLOAT32",new n("float32")),s(n,"INT64",new n("int64")),s(n,"INT32",new n("int32")),s(n,"INT16",new n("int16")),s(n,"INT8",new n("int8")),s(n,"UINT64",new n("uint64")),s(n,"UINT32",new n("uint32")),s(n,"UINT16",new n("uint16")),s(n,"UINT8",new n("uint8")),s(n,"BOOLEAN",n.UINT8),s(n,"TIMESTAMP",new n("timestamp")),s(n,"UUID",new n("uuid")),s(n,"STRING",new n("string")),s(n,"JSON",new n("json")),s(n,"ARRAY_CONSTRUCTORS",new Map([[n.UINT8.toString(),Uint8Array],[n.UINT16.toString(),Uint16Array],[n.UINT32.toString(),Uint32Array],[n.UINT64.toString(),BigUint64Array],[n.FLOAT32.toString(),Float32Array],[n.FLOAT64.toString(),Float64Array],[n.INT8.toString(),Int8Array],[n.INT16.toString(),Int16Array],[n.INT32.toString(),Int32Array],[n.INT64.toString(),BigInt64Array],[n.TIMESTAMP.toString(),BigInt64Array],[n.STRING.toString(),Uint8Array],[n.JSON.toString(),Uint8Array],[n.UUID.toString(),Uint8Array]])),s(n,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,n.UINT8],[Uint16Array.name,n.UINT16],[Uint32Array.name,n.UINT32],[BigUint64Array.name,n.UINT64],[Float32Array.name,n.FLOAT32],[Float64Array.name,n.FLOAT64],[Int8Array.name,n.INT8],[Int16Array.name,n.INT16],[Int32Array.name,n.INT32],[BigInt64Array.name,n.INT64]])),s(n,"DENSITIES",new Map([[n.UINT8.toString(),I.BIT8],[n.UINT16.toString(),I.BIT16],[n.UINT32.toString(),I.BIT32],[n.UINT64.toString(),I.BIT64],[n.FLOAT32.toString(),I.BIT32],[n.FLOAT64.toString(),I.BIT64],[n.INT8.toString(),I.BIT8],[n.INT16.toString(),I.BIT16],[n.INT32.toString(),I.BIT32],[n.INT64.toString(),I.BIT64],[n.TIMESTAMP.toString(),I.BIT64],[n.STRING.toString(),I.UNKNOWN],[n.JSON.toString(),I.UNKNOWN],[n.UUID.toString(),I.BIT128]])),s(n,"ALL",[n.UNKNOWN,n.FLOAT64,n.FLOAT32,n.INT64,n.INT32,n.INT16,n.INT8,n.UINT64,n.UINT32,n.UINT16,n.UINT8,n.TIMESTAMP,n.UUID,n.STRING,n.JSON]),s(n,"BIG_INT_TYPES",[n.INT64,n.UINT64,n.TIMESTAMP]),s(n,"z",c.z.union([c.z.string().transform(t=>new n(t)),c.z.instanceof(n)]));let d=n;const l=class l extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return l.bytes(this.valueOf()+t.valueOf())}sub(t){return l.bytes(this.valueOf()-t.valueOf())}truncate(t){return new l(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return l.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/l.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/l.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/l.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/l.TERABYTE.valueOf()}toString(){const t=this.truncate(l.TERABYTE),e=this.truncate(l.GIGABYTE),r=this.truncate(l.MEGABYTE),u=this.truncate(l.KILOBYTE),h=this.truncate(l.BYTE),g=t,N=e.sub(t),O=r.sub(e),S=u.sub(r),p=h.sub(u);let o="";return g.isZero||(o+=`${g.terabytes}TB `),N.isZero||(o+=`${N.gigabytes}GB `),O.isZero||(o+=`${O.megabytes}MB `),S.isZero||(o+=`${S.kilobytes}KB `),(!p.isZero||o==="")&&(o+=`${p.valueOf()}B`),o.trim()}static bytes(t=1){return new l(t)}static kilobytes(t=1){return l.bytes(t.valueOf()*1e3)}static megabytes(t=1){return l.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return l.megabytes(t.valueOf()*1e3)}static terabytes(t){return l.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};s(l,"BYTE",new l(1)),s(l,"KILOBYTE",l.kilobytes(1)),s(l,"MEGABYTE",l.megabytes(1)),s(l,"GIGABYTE",l.gigabytes(1)),s(l,"TERABYTE",l.terabytes(1)),s(l,"ZERO",new l(0)),s(l,"z",c.z.union([c.z.number().transform(t=>new l(t)),c.z.instanceof(l)]));let C=l;const et=c.z.union([c.z.instanceof(Uint8Array),c.z.instanceof(Uint16Array),c.z.instanceof(Uint32Array),c.z.instanceof(BigUint64Array),c.z.instanceof(Float32Array),c.z.instanceof(Float64Array),c.z.instanceof(Int8Array),c.z.instanceof(Int16Array),c.z.instanceof(Int32Array),c.z.instanceof(BigInt64Array)]),D=f=>{const t=typeof f;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||f instanceof y||f instanceof w||f instanceof Date},J=(f,t,e,r=0)=>f.usesBigInt&&!t.usesBigInt?Number(e)-Number(r):!f.usesBigInt&&t.usesBigInt?BigInt(e)-BigInt(r):R(e,-r),W=f=>f==null?!1:Array.isArray(f)||f instanceof ArrayBuffer||ArrayBuffer.isView(f)&&!(f instanceof DataView)||f instanceof b?!0:D(f),E=-1;class b{constructor(t){s(this,"key","");s(this,"isSynnaxSeries",!0);s(this,"dataType");s(this,"sampleOffset");s(this,"gl");s(this,"_data");s(this,"_timeRange");s(this,"alignment",0n);s(this,"_cachedMin");s(this,"_cachedMax");s(this,"writePos",E);s(this,"_refCount",0);s(this,"_cachedLength");W(t)&&(t={data:t});const{dataType:e,timeRange:r,sampleOffset:u=0,glBufferUsage:h="static",alignment:g=0n,key:N=Z()}=t,{data:O}=t;if(O instanceof b||typeof O=="object"&&"isSynnaxSeries"in O&&O.isSynnaxSeries===!0){const o=O;this.key=o.key,this.dataType=o.dataType,this.sampleOffset=o.sampleOffset,this.gl=o.gl,this._data=o._data,this._timeRange=o._timeRange,this.alignment=o.alignment,this._cachedMin=o._cachedMin,this._cachedMax=o._cachedMax,this.writePos=o.writePos,this._refCount=o._refCount,this._cachedLength=o._cachedLength;return}const S=D(O),p=Array.isArray(O);if(e!=null)this.dataType=new d(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(p||S){let o=O;if(!S){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.");o=O[0]}if(typeof o=="string")this.dataType=d.STRING;else if(typeof o=="number")this.dataType=d.FLOAT64;else if(typeof o=="bigint")this.dataType=d.INT64;else if(typeof o=="boolean")this.dataType=d.BOOLEAN;else if(o instanceof y||o instanceof Date||o instanceof y)this.dataType=d.TIMESTAMP;else if(typeof o=="object")this.dataType=d.JSON;else throw new Error(`cannot infer data type of ${typeof o} when constructing a Series from a JS array`)}else this.dataType=new d(O)}if(!p&&!S)this._data=O;else{let o=S?[O]:O;const B=o[0];(B instanceof y||B instanceof Date||B instanceof w)&&(o=o.map(U=>new y(U).valueOf())),this.dataType.equals(d.STRING)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.join(`
2
+ `)+`
3
+ `)):this.dataType.equals(d.JSON)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.map(U=>L.JSON_CODEC.encodeString(U)).join(`
4
+ `)+`
5
+ `)):this._data=new this.dataType.Array(o).buffer}this.key=N,this.alignment=g,this.sampleOffset=u??0,this._timeRange=r,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:h}}static alloc({capacity:t,dataType:e,...r}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const u=new new d(e).Array(t),h=new b({data:u.buffer,dataType:e,...r});return h.writePos=0,h}static generateTimestamps(t,e,r){const u=r.spanRange(e.span(t)),h=new BigInt64Array(t);for(let g=0;g<t;g++)h[g]=BigInt(r.add(e.span(g)).valueOf());return new b({data:h,dataType:d.TIMESTAMP,timeRange:u})}get refCount(){return this._refCount}static fromStrings(t,e){const r=new TextEncoder().encode(t.join(`
6
+ `)+`
7
+ `);return new b({data:r,dataType:d.STRING,timeRange:e})}static fromJSON(t,e){const r=new TextEncoder().encode(t.map(u=>L.JSON_CODEC.encodeString(u)).join(`
8
+ `)+`
9
+ `);return new b({data:r,dataType:d.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");if(this.writePos===E)return 0;const e=this.capacity-this.writePos,r=e<t.length?t.slice(0,e):t;return this.underlyingData.set(r.data,this.writePos),this.maybeRecomputeMinMax(r),this._cachedLength=void 0,this.writePos+=r.length,r.length}get buffer(){return this._data}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.equals(d.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
10
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(d.UUID))throw new Error("cannot convert non-uuid series to uuids");const t=d.UUID.density.valueOf(),e=Array(this.length);for(let r=0;r<this.length;r++){const u=this.buffer.slice(r*t,(r+1)*t),h=Array.from(new Uint8Array(u),g=>g.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");e[r]=h}return e}parseJSON(t){if(!this.dataType.equals(d.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
11
+ `).slice(0,-1).map(e=>t.parse(L.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 C(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity: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;return this.data.forEach(e=>{e===10&&t++}),this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const r=new t.Array(this.length);for(let u=0;u<this.length;u++)r[u]=J(this.dataType,t,this.data[u],e);return new b({data:r.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(d.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMax=t.reduce((e,r)=>e>r?e:r)}else{const t=this.data;this._cachedMax=t.reduce((e,r)=>e>r?e: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==null&&(this._cachedMax=this.calcRawMax()),R(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(d.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMin=t.reduce((e,r)=>e<r?e:r)}else{const t=this.data;this._cachedMin=t.reduce((e,r)=>e<r?e: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==null&&(this._cachedMin=this.calcRawMin()),R(this._cachedMin,this.sampleOffset))}get bounds(){return z.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 R(this.max,-this.min)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const r=this.data[t];if(r==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return R(r,this.sampleOffset)}atVariable(t,e){t<0&&(t=this.length+t);let r=0,u=0;for(let g=0;g<this.data.length;g++)if(this.data[g]===10){if(t===0){u=g;break}r=g+1,t--}if(u===0&&(u=this.data.length),r>=u||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}const h=this.data.slice(r,u);return this.dataType.equals(d.STRING)?new TextDecoder().decode(h):H.snakeToCamel(JSON.parse(new TextDecoder().decode(h)))}binarySearch(t){let e=0,r=this.length-1;const u=X.newF(t);for(;e<=r;){const h=Math.floor((e+r)/2),g=u(this.at(h,!0),t);if(g===0)return h;g<0?e=h+1:r=h-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(d.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:e,bufferUsage:r,prevBuffer:u}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==u)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==E){u===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const h=this.dataType.density.size(u).valueOf(),g=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,h,g.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.buffer,r==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=E}as(t){if(t==="string"){if(!this.dataType.equals(d.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(d.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 z.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 rt(this);return this.dataType.equals(d.JSON)?new nt(t):t}return new st(this)}slice(t,e){if(t<=0&&(e==null||e>=this.length))return this;const r=this.data.slice(t,e);return new b({data:r,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(t){return new b({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}}class rt{constructor(t){s(this,"series");s(this,"index");s(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]!==10;)this.index++;const r=this.index;return t===r?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,r))})}[Symbol.iterator](){return this}}var $,F;class nt{constructor(t){s(this,"wrapped");s(this,$,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:L.JSON_CODEC.decodeString(t.value)}}[(F=Symbol.iterator,$=Symbol.toStringTag,F)](){return this}}var P,Y;class st{constructor(t){s(this,"series");s(this,"index");s(this,P,"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)}}[(Y=Symbol.iterator,P=Symbol.toStringTag,Y)](){return this}}const R=(f,t)=>typeof f=="bigint"&&typeof t=="bigint"||typeof f=="number"&&typeof t=="number"?f+t:t===0?f:f===0?t:Number(f)+Number(t);class it{constructor(t){s(this,"series");if(t.length!==0){const e=t[0].dataType;for(let r=1;r<t.length;r++)if(!t[r].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){if(!new d(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?d.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)}push(t){this.series.push(t)}get length(){return this.series.reduce((t,e)=>t+e.length,0)}at(t,e=!1){t<0&&(t=this.length+t);for(const r of this.series){if(t<r.length)return r.at(t,e);t-=r.length}if(e)throw new Error(`[series] - no value at index ${t}`)}get byteLength(){return new C(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 r of this.series)t.set(r.data,e),e+=r.length;return new this.dataType.Array(t)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new at(this.series)}}var G,V;class at{constructor(t){s(this,"series");s(this,"seriesIndex");s(this,"internal");s(this,G,"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())}[(V=Symbol.iterator,G=Symbol.toStringTag,V)](){return this}}exports.DataType=d;exports.Density=I;exports.MultiSeries=it;exports.Rate=x;exports.Series=b;exports.Size=C;exports.TimeRange=M;exports.TimeSpan=w;exports.TimeStamp=y;exports.addSamples=R;exports.convertDataType=J;exports.id=tt;exports.isCrudeSeries=W;exports.isTelemValue=D;exports.typedArrayZ=et;