@synnaxlabs/x 0.28.0 → 0.29.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 (46) hide show
  1. package/.turbo/turbo-build.log +23 -23
  2. package/dist/binary.cjs +1 -1
  3. package/dist/binary.js +1 -1
  4. package/dist/{box-C6r0YnKB.cjs → box-BQID-0jO.cjs} +1 -1
  5. package/dist/{box-B5SaODGu.js → box-xRqO6NvI.js} +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-CzjnpuXF.js → index-B5THJ1eb.js} +1 -1
  11. package/dist/{index-tYmAULd8.cjs → index-DgaYJC35.cjs} +1 -1
  12. package/dist/{index-C9i674Sf.js → index-Duv1uH08.js} +5 -5
  13. package/dist/index-xk130iQA.cjs +1 -0
  14. package/dist/index.cjs +2 -2
  15. package/dist/index.js +17 -15
  16. package/dist/{location-C6sCnzhU.js → location-DjcaXEps.js} +1 -1
  17. package/dist/{location-55G2uRZN.cjs → location-gPB1RtfA.cjs} +1 -1
  18. package/dist/location.cjs +1 -1
  19. package/dist/location.js +1 -1
  20. package/dist/{position-BwmbckCe.cjs → position-C71OiHiw.cjs} +1 -1
  21. package/dist/{position-BY9oBMZB.js → position-DkON65EZ.js} +2 -2
  22. package/dist/position.cjs +1 -1
  23. package/dist/position.js +1 -1
  24. package/dist/{scale-COuYv97b.cjs → scale-COPgp55a.cjs} +1 -1
  25. package/dist/{scale-BgCpxgAk.js → scale-qw6vRO4s.js} +2 -2
  26. package/dist/scale.cjs +1 -1
  27. package/dist/scale.js +1 -1
  28. package/dist/{series-DIZdmPCa.js → series-By2HWr-H.js} +5 -5
  29. package/dist/{series-DMsaUp_n.cjs → series-vJnPOt1M.cjs} +1 -1
  30. package/dist/spatial.cjs +1 -1
  31. package/dist/spatial.js +4 -4
  32. package/dist/src/caseconv/caseconv.d.ts.map +1 -1
  33. package/dist/src/index.d.ts +1 -0
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/zodutil/zodutil.d.ts +16 -1
  36. package/dist/src/zodutil/zodutil.d.ts.map +1 -1
  37. package/dist/telem.cjs +1 -1
  38. package/dist/telem.js +1 -1
  39. package/dist/zodutil.cjs +1 -1
  40. package/dist/zodutil.js +16 -12
  41. package/package.json +8 -8
  42. package/src/caseconv/caseconv.ts +4 -1
  43. package/src/index.ts +1 -0
  44. package/src/zodutil/zodutil.ts +27 -2
  45. package/tsconfig.tsbuildinfo +1 -1
  46. package/dist/index-BGz7XJIe.cjs +0 -1
@@ -1,4 +1,4 @@
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-DYgqYo6X.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(![m.DAY,m.HOUR,m.MINUTE,m.SECOND,m.MILLISECOND,m.MICROSECOND,m.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 m(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,d]=t.split(":");let g="00",S="00";d!=null&&([g,S]=d.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(S??"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 m(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(m.DAY).equals(i.now().truncate(m.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),d=this.truncate(a.MILLISECOND),g=this.truncate(a.MICROSECOND),S=this.truncate(a.NANOSECOND),O=t,N=e.sub(t),p=r.sub(e),o=u.sub(r),B=d.sub(u),U=g.sub(d),q=S.sub(g);let A="";return O.isZero||(A+=`${O.days}d `),N.isZero||(A+=`${N.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 m=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 m.seconds(1/this.valueOf())}sampleCount(t){return new m(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return m.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 w=class w 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(w,"UNKNOWN",new w(0)),s(w,"BIT128",new w(16)),s(w,"BIT64",new w(8)),s(w,"BIT32",new w(4)),s(w,"BIT16",new w(2)),s(w,"BIT8",new w(1)),s(w,"z",c.z.union([c.z.number().transform(t=>new w(t)),c.z.instanceof(Number).transform(t=>new w(t)),c.z.instanceof(w)]));let I=w;const b=class b{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 m(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 b(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=m.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),d=y.min(r.end,t.end);return d.before(u)?!1:new m(d.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 b?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new b(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(b,"MAX",new b(y.MIN,y.MAX)),s(b,"MIN",new b(y.MAX,y.MIN)),s(b,"ZERO",new b(y.ZERO,y.ZERO)),s(b,"z",c.z.union([c.z.object({start:y.z,end:y.z}).transform(t=>new b(t.start,t.end)),c.z.instanceof(b)]));let M=b;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()}matches(...t){return t.some(e=>this.equals(e))}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 h=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),d=this.truncate(l.BYTE),g=t,S=e.sub(t),O=r.sub(e),N=u.sub(r),p=d.sub(u);let o="";return g.isZero||(o+=`${g.terabytes}TB `),S.isZero||(o+=`${S.gigabytes}GB `),O.isZero||(o+=`${O.megabytes}MB `),N.isZero||(o+=`${N.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 m||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 T?!0:D(f),E=-1;class T{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:d="static",alignment:g=0n,key:S=Z()}=t,{data:O}=t;if(O instanceof T||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 N=D(O),p=Array.isArray(O);if(e!=null)this.dataType=new h(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||N){let o=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.");o=O[0]}if(typeof o=="string")this.dataType=h.STRING;else if(typeof o=="number")this.dataType=h.FLOAT64;else if(typeof o=="bigint")this.dataType=h.INT64;else if(typeof o=="boolean")this.dataType=h.BOOLEAN;else if(o instanceof y||o instanceof Date||o instanceof y)this.dataType=h.TIMESTAMP;else if(typeof o=="object")this.dataType=h.JSON;else throw new Error(`cannot infer data type of ${typeof o} when constructing a Series from a JS array`)}else this.dataType=new h(O)}if(!p&&!N)this._data=O;else{let o=N?[O]:O;const B=o[0];(B instanceof y||B instanceof Date||B instanceof m)&&(o=o.map(U=>new y(U).valueOf())),this.dataType.equals(h.STRING)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.join(`
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-DgaYJC35.cjs"),H=require("./index-xk130iQA.cjs"),X=require("./index-DYgqYo6X.cjs"),z=require("./bounds-ZZc1c-_Z.cjs");require("./box-BQID-0jO.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-gPB1RtfA.cjs");require("./scale-COPgp55a.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(![m.DAY,m.HOUR,m.MINUTE,m.SECOND,m.MILLISECOND,m.MICROSECOND,m.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 m(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,d]=t.split(":");let g="00",S="00";d!=null&&([g,S]=d.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(S??"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 m(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(m.DAY).equals(i.now().truncate(m.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),d=this.truncate(a.MILLISECOND),g=this.truncate(a.MICROSECOND),S=this.truncate(a.NANOSECOND),O=t,N=e.sub(t),p=r.sub(e),o=u.sub(r),B=d.sub(u),U=g.sub(d),q=S.sub(g);let A="";return O.isZero||(A+=`${O.days}d `),N.isZero||(A+=`${N.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 m=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 m.seconds(1/this.valueOf())}sampleCount(t){return new m(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return m.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 w=class w 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(w,"UNKNOWN",new w(0)),s(w,"BIT128",new w(16)),s(w,"BIT64",new w(8)),s(w,"BIT32",new w(4)),s(w,"BIT16",new w(2)),s(w,"BIT8",new w(1)),s(w,"z",c.z.union([c.z.number().transform(t=>new w(t)),c.z.instanceof(Number).transform(t=>new w(t)),c.z.instanceof(w)]));let I=w;const b=class b{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 m(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 b(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=m.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),d=y.min(r.end,t.end);return d.before(u)?!1:new m(d.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 b?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new b(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(b,"MAX",new b(y.MIN,y.MAX)),s(b,"MIN",new b(y.MAX,y.MIN)),s(b,"ZERO",new b(y.ZERO,y.ZERO)),s(b,"z",c.z.union([c.z.object({start:y.z,end:y.z}).transform(t=>new b(t.start,t.end)),c.z.instanceof(b)]));let M=b;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()}matches(...t){return t.some(e=>this.equals(e))}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 h=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),d=this.truncate(l.BYTE),g=t,S=e.sub(t),O=r.sub(e),N=u.sub(r),p=d.sub(u);let o="";return g.isZero||(o+=`${g.terabytes}TB `),S.isZero||(o+=`${S.gigabytes}GB `),O.isZero||(o+=`${O.megabytes}MB `),N.isZero||(o+=`${N.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 m||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 T?!0:D(f),E=-1;class T{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:d="static",alignment:g=0n,key:S=Z()}=t,{data:O}=t;if(O instanceof T||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 N=D(O),p=Array.isArray(O);if(e!=null)this.dataType=new h(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||N){let o=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.");o=O[0]}if(typeof o=="string")this.dataType=h.STRING;else if(typeof o=="number")this.dataType=h.FLOAT64;else if(typeof o=="bigint")this.dataType=h.INT64;else if(typeof o=="boolean")this.dataType=h.BOOLEAN;else if(o instanceof y||o instanceof Date||o instanceof y)this.dataType=h.TIMESTAMP;else if(typeof o=="object")this.dataType=h.JSON;else throw new Error(`cannot infer data type of ${typeof o} when constructing a Series from a JS array`)}else this.dataType=new h(O)}if(!p&&!N)this._data=O;else{let o=N?[O]:O;const B=o[0];(B instanceof y||B instanceof Date||B instanceof m)&&(o=o.map(U=>new y(U).valueOf())),this.dataType.equals(h.STRING)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.join(`
2
2
  `)+`
3
3
  `)):this.dataType.equals(h.JSON)?(this._cachedLength=o.length,this._data=new TextEncoder().encode(o.map(U=>L.JSON_CODEC.encodeString(U)).join(`
4
4
  `)+`
package/dist/spatial.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./bounds-ZZc1c-_Z.cjs"),i=require("./box-C6r0YnKB.cjs"),e=require("./dimensions-zMcb9pMk.cjs"),n=require("./direction-DZbN47uL.cjs"),s=require("./location-55G2uRZN.cjs"),t=require("./position-BwmbckCe.cjs"),r=require("./scale-COuYv97b.cjs"),c=require("./spatial-BOhaO8xN.cjs"),u=require("./xy-cP-FXJtR.cjs");exports.bounds=o.bounds;exports.box=i.box;exports.dimensions=e.dimensions;exports.direction=n.direction;exports.location=s.location;exports.position=t.position;exports.scale=r.scale;exports.spatial=c.spatial;exports.xy=u.xy;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./bounds-ZZc1c-_Z.cjs"),i=require("./box-BQID-0jO.cjs"),e=require("./dimensions-zMcb9pMk.cjs"),n=require("./direction-DZbN47uL.cjs"),s=require("./location-gPB1RtfA.cjs"),t=require("./position-C71OiHiw.cjs"),r=require("./scale-COPgp55a.cjs"),c=require("./spatial-BOhaO8xN.cjs"),u=require("./xy-cP-FXJtR.cjs");exports.bounds=o.bounds;exports.box=i.box;exports.dimensions=e.dimensions;exports.direction=n.direction;exports.location=s.location;exports.position=t.position;exports.scale=r.scale;exports.spatial=c.spatial;exports.xy=u.xy;
package/dist/spatial.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { b as s } from "./bounds-CpboA0q6.js";
2
- import { b as t } from "./box-B5SaODGu.js";
2
+ import { b as t } from "./box-xRqO6NvI.js";
3
3
  import { d as p } from "./dimensions-D-1PnJVI.js";
4
4
  import { d as m } from "./direction-CScbfCdT.js";
5
- import { l as i } from "./location-C6sCnzhU.js";
6
- import { p as d } from "./position-BY9oBMZB.js";
7
- import { s as l } from "./scale-BgCpxgAk.js";
5
+ import { l as i } from "./location-DjcaXEps.js";
6
+ import { p as d } from "./position-DkON65EZ.js";
7
+ import { s as l } from "./scale-qw6vRO4s.js";
8
8
  import { s as u } from "./spatial-DozyssiN.js";
9
9
  import { x as g } from "./xy-CrgPnICw.js";
10
10
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"caseconv.d.ts","sourceRoot":"","sources":["../../../src/caseconv/caseconv.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAnDpB,CAAC,OAAO,CAAC,QAAQ,OAAO,KAAK,CAmD0B,CAAC;AAQ7D,eAAO,MAAM,YAAY,GA3DpB,CAAC,OAAO,CAAC,QAAQ,OAAO,KAAK,CA2D0B,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAA6C,CAAC;AAEvF;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,GAAG,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAI5B,CAAC;AAEF,eAAO,MAAM,eAAe,SAAS,OAAO,KAAoB,OAO/D,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,OAA4C,CAAC;AAEtF,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,OACsB,CAAC;AAEhE,eAAO,MAAM,aAAa,QAAS,GAAG,UAAU,GAAG,EAAE,KAAG,OACL,CAAC"}
1
+ {"version":3,"file":"caseconv.d.ts","sourceRoot":"","sources":["../../../src/caseconv/caseconv.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,GAnDpB,CAAC,OAAO,CAAC,QAAQ,OAAO,KAAK,CAmD0B,CAAC;AAQ7D,eAAO,MAAM,YAAY,GA3DpB,CAAC,OAAO,CAAC,QAAQ,OAAO,KAAK,CA2D0B,CAAC;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAGxC,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,GAAG,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,OAI5B,CAAC;AAEF,eAAO,MAAM,eAAe,SAAS,OAAO,KAAoB,OAO/D,CAAC;AAEF,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,OAA4C,CAAC;AAEtF,eAAO,MAAM,aAAa,QAAS,GAAG,KAAG,OACsB,CAAC;AAEhE,eAAO,MAAM,aAAa,QAAS,GAAG,UAAU,GAAG,EAAE,KAAG,OACL,CAAC"}
@@ -30,4 +30,5 @@ export * from './transform';
30
30
  export * from './unique';
31
31
  export * from './url';
32
32
  export * from './worker';
33
+ export * from './zodutil';
33
34
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AASA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,MAAM,CAAC;AACrB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC"}
@@ -1,5 +1,20 @@
1
- import { z } from 'zod';
1
+ import { z, ZodSchema } from 'zod';
2
2
  import { deep } from '../deep';
3
3
  export declare const getFieldSchemaPath: (path: string) => string;
4
4
  export declare const getFieldSchema: deep.TypedGet<z.ZodTypeAny, z.ZodTypeAny>;
5
+ /**
6
+ * Creates a transformer function that validates and transforms input values based on
7
+ * provided schemas. The first schema to successfully validate the input value is used
8
+ * in the transformation. If no schema is found that validates the input, the
9
+ * transformer function returns null.
10
+ *
11
+ * @template Input - The type of the input value.
12
+ * @template Output - The type of the output value.
13
+ * @param transform - The function to transform the input value to the output value.
14
+ * @param schemas - An array of Zod schemas to validate the input value against.
15
+ * @returns A function that takes an unknown value, validates it against the schemas,
16
+ * and uses the first valid schema to transform the input type. If no schema can
17
+ * validate the input, the function returns null.
18
+ */
19
+ export declare const transformer: <Input, Output>(transform: (input: Input) => Output, schemas: ZodSchema<Input>[]) => ((value: unknown) => Output | null);
5
20
  //# sourceMappingURL=zodutil.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"zodutil.d.ts","sourceRoot":"","sources":["../../../src/zodutil/zodutil.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,eAAO,MAAM,kBAAkB,SAAU,MAAM,KAAG,MAQ9C,CAAC;AAYL,eAAO,MAAM,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CASG,CAAC"}
1
+ {"version":3,"file":"zodutil.d.ts","sourceRoot":"","sources":["../../../src/zodutil/zodutil.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,CAAC,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,eAAO,MAAM,kBAAkB,SAAU,MAAM,KAAG,MAQ9C,CAAC;AAYL,eAAO,MAAM,cAAc,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CASG,CAAC;AAEzE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GACrB,KAAK,EAAE,MAAM,aACD,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,WAC1B,SAAS,CAAC,KAAK,CAAC,EAAE,KAC1B,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,CAKpC,CAAC"}
package/dist/telem.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./series-DMsaUp_n.cjs");exports.DataType=e.DataType;exports.Density=e.Density;exports.MultiSeries=e.MultiSeries;exports.Rate=e.Rate;exports.Series=e.Series;exports.Size=e.Size;exports.TimeRange=e.TimeRange;exports.TimeSpan=e.TimeSpan;exports.TimeStamp=e.TimeStamp;exports.addSamples=e.addSamples;exports.convertDataType=e.convertDataType;exports.isCrudeSeries=e.isCrudeSeries;exports.isTelemValue=e.isTelemValue;exports.typedArrayZ=e.typedArrayZ;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./series-vJnPOt1M.cjs");exports.DataType=e.DataType;exports.Density=e.Density;exports.MultiSeries=e.MultiSeries;exports.Rate=e.Rate;exports.Series=e.Series;exports.Size=e.Size;exports.TimeRange=e.TimeRange;exports.TimeSpan=e.TimeSpan;exports.TimeStamp=e.TimeStamp;exports.addSamples=e.addSamples;exports.convertDataType=e.convertDataType;exports.isCrudeSeries=e.isCrudeSeries;exports.isTelemValue=e.isTelemValue;exports.typedArrayZ=e.typedArrayZ;
package/dist/telem.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as s, D as i, M as t, R as r, S, e as m, c as p, b as T, T as d, a as y, g as l, i as n, f as D, t as o } from "./series-DIZdmPCa.js";
1
+ import { d as s, D as i, M as t, R as r, S, e as m, c as p, b as T, T as d, a as y, g as l, i as n, f as D, t as o } from "./series-By2HWr-H.js";
2
2
  export {
3
3
  s as DataType,
4
4
  i as Density,
package/dist/zodutil.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./path-577Fmn5N.cjs"),c=e=>o.transformPath(e,(t,r,n)=>{const u=r===n.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(n[r+1]));return i&&(t="element"),u||l?t:[t,"shape"]}),s=(e,t)=>{if(e==null)return null;const r=e[t];return r==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:r},a=(e,t,r)=>o.get(s(e,"shape"),c(t),{...r,getter:s}),p=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:a,getFieldSchemaPath:c},Symbol.toStringTag,{value:"Module"}));exports.zodutil=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./path-577Fmn5N.cjs"),u=e=>o.transformPath(e,(t,r,n)=>{const s=r===n.length-1,i=!isNaN(parseInt(t)),l=!isNaN(parseInt(n[r+1]));return i&&(t="element"),s||l?t:[t,"shape"]}),c=(e,t)=>{if(e==null)return null;const r=e[t];return r==null&&typeof e=="object"&&"sourceType"in e?e.sourceType()[t]:r},a=(e,t,r)=>o.get(c(e,"shape"),u(t),{...r,getter:c}),f=(e,t)=>r=>{const n=t.find(s=>s.safeParse(r).success);return n==null?null:e(n.parse(r))},m=Object.freeze(Object.defineProperty({__proto__:null,getFieldSchema:a,getFieldSchemaPath:u,transformer:f},Symbol.toStringTag,{value:"Module"}));exports.zodutil=m;
package/dist/zodutil.js CHANGED
@@ -1,20 +1,24 @@
1
- import { t as l, g as a } from "./path-B-1-i3qC.js";
2
- const o = (e) => l(e, (t, r, n) => {
3
- const c = r === n.length - 1, u = !isNaN(parseInt(t)), i = !isNaN(parseInt(n[r + 1]));
4
- return u && (t = "element"), c || i ? t : [t, "shape"];
5
- }), s = (e, t) => {
1
+ import { t as i, g as l } from "./path-B-1-i3qC.js";
2
+ const o = (e) => i(e, (t, r, n) => {
3
+ const s = r === n.length - 1, u = !isNaN(parseInt(t)), a = !isNaN(parseInt(n[r + 1]));
4
+ return u && (t = "element"), s || a ? t : [t, "shape"];
5
+ }), c = (e, t) => {
6
6
  if (e == null) return null;
7
7
  const r = e[t];
8
8
  return r == null && typeof e == "object" && "sourceType" in e ? e.sourceType()[t] : r;
9
- }, p = (e, t, r) => a(
10
- s(e, "shape"),
9
+ }, f = (e, t, r) => l(
10
+ c(e, "shape"),
11
11
  o(t),
12
- { ...r, getter: s }
13
- ), m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12
+ { ...r, getter: c }
13
+ ), m = (e, t) => (r) => {
14
+ const n = t.find((s) => s.safeParse(r).success);
15
+ return n == null ? null : e(n.parse(r));
16
+ }, g = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14
17
  __proto__: null,
15
- getFieldSchema: p,
16
- getFieldSchemaPath: o
18
+ getFieldSchema: f,
19
+ getFieldSchemaPath: o,
20
+ transformer: m
17
21
  }, Symbol.toStringTag, { value: "Module" }));
18
22
  export {
19
- m as zodutil
23
+ g as zodutil
20
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/x",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "type": "module",
5
5
  "description": "Common Utilities for Synnax Labs",
6
6
  "repository": "https://github.com/synnaxlabs/synnax/tree/main/x/go",
@@ -18,14 +18,14 @@
18
18
  "zod": "3.23.8"
19
19
  },
20
20
  "devDependencies": {
21
- "@types/node": "^20.14.9",
22
- "@vitest/coverage-v8": "^1.6.0",
23
- "typescript": "^5.5.3",
24
- "vite": "5.3.3",
25
- "vitest": "^1.6.0",
26
- "@synnaxlabs/tsconfig": "0.0.2",
21
+ "@types/node": "^22.5.4",
22
+ "@vitest/coverage-v8": "^2.1.0",
23
+ "typescript": "^5.6.2",
24
+ "vite": "5.4.4",
25
+ "vitest": "^2.1.0",
27
26
  "@synnaxlabs/vite-plugin": "0.0.1",
28
- "eslint-config-synnaxlabs": "0.0.1"
27
+ "eslint-config-synnaxlabs": "0.0.1",
28
+ "@synnaxlabs/tsconfig": "0.0.2"
29
29
  },
30
30
  "main": "./dist/index.cjs",
31
31
  "module": "./dist/index.js",
@@ -89,7 +89,10 @@ export const camelToSnake = createConverter(camelToSnakeStr);
89
89
  * @param str - The string to capitalize.
90
90
  * @returns The string with the first character capitalized.
91
91
  */
92
- export const capitalize = (str: string): string => str[0].toUpperCase() + str.slice(1);
92
+ export const capitalize = (str: string): string => {
93
+ if (str.length === 0) return str;
94
+ return str[0].toUpperCase() + str.slice(1);
95
+ };
93
96
 
94
97
  /**
95
98
  * Options parameter for convert function
package/src/index.ts CHANGED
@@ -39,3 +39,4 @@ export * from "@/transform";
39
39
  export * from "@/unique";
40
40
  export * from "@/url";
41
41
  export * from "@/worker";
42
+ export * from "@/zodutil";
@@ -7,10 +7,10 @@
7
7
  // License, use of this software will be governed by the Apache License, Version 2.0,
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
- import { z } from "zod";
10
+ import { type z, type ZodSchema } from "zod";
11
11
 
12
12
  import { deep } from "@/deep";
13
- import { UnknownRecord } from "@/record";
13
+ import { type UnknownRecord } from "@/record";
14
14
 
15
15
  export const getFieldSchemaPath = (path: string): string =>
16
16
  deep.transformPath(path, (part, index, parts) => {
@@ -42,3 +42,28 @@ export const getFieldSchema: deep.TypedGet<z.ZodTypeAny, z.ZodTypeAny> = ((
42
42
  getFieldSchemaPath(path),
43
43
  { ...options, getter: sourceTypeGetter } as deep.GetOptions<boolean | undefined>,
44
44
  ) as z.ZodTypeAny | null) as deep.TypedGet<z.ZodTypeAny, z.ZodTypeAny>;
45
+
46
+ /**
47
+ * Creates a transformer function that validates and transforms input values based on
48
+ * provided schemas. The first schema to successfully validate the input value is used
49
+ * in the transformation. If no schema is found that validates the input, the
50
+ * transformer function returns null.
51
+ *
52
+ * @template Input - The type of the input value.
53
+ * @template Output - The type of the output value.
54
+ * @param transform - The function to transform the input value to the output value.
55
+ * @param schemas - An array of Zod schemas to validate the input value against.
56
+ * @returns A function that takes an unknown value, validates it against the schemas,
57
+ * and uses the first valid schema to transform the input type. If no schema can
58
+ * validate the input, the function returns null.
59
+ */
60
+ export const transformer =
61
+ <Input, Output>(
62
+ transform: (input: Input) => Output,
63
+ schemas: ZodSchema<Input>[],
64
+ ): ((value: unknown) => Output | null) =>
65
+ (value) => {
66
+ const matchingSchema = schemas.find((schema) => schema.safeParse(value).success);
67
+ if (matchingSchema == null) return null;
68
+ return transform(matchingSchema.parse(value));
69
+ };