@synnaxlabs/freighter 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/freighter.cjs +8 -8
- package/dist/freighter.js +150 -144
- package/dist/unary.d.ts +1 -1
- package/dist/unary.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/unary.ts +3 -3
package/dist/freighter.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";var dt=Object.defineProperty;var ft=(r,e,t)=>e in r?dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var y=(r,e,t)=>ft(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("zod"),gt=r=>{const e=r.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Ve=r=>{const e=(t,n=pe)=>{if(typeof t=="string")return r(t);if(Array.isArray(t))return t.map(c=>e(c,n));if(!he(t))return t;n=mt(n);const s={},a=t;return Object.keys(a).forEach(c=>{let d=a[c];const f=r(c);n.recursive&&(he(d)?Ae(d,n.keepTypesOnRecursion)||(d=e(d,n)):n.recursiveInArray&&Ee(d)&&(d=[...d].map(p=>{let m=p;return he(p)?Ae(m,n.keepTypesOnRecursion)||(m=e(p,n)):Ee(p)&&(m=e({key:p},n).key),m}))),s[f]=d}),s};return e},Ze=Ve(gt),pt=r=>r.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),yt=Ve(pt),pe={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},mt=(r=pe)=>(r.recursive==null?r=pe:r.recursiveInArray??(r.recursiveInArray=!1),r),Ee=r=>r!=null&&Array.isArray(r),he=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Ae=(r,e)=>(e||[]).some(t=>r instanceof t),He=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var wt=Object.defineProperty,bt=(r,e,t)=>e in r?wt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Q=(r,e,t)=>bt(r,typeof e!="symbol"?e+"":e,t);let
|
|
1
|
+
"use strict";var dt=Object.defineProperty;var ft=(r,e,t)=>e in r?dt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var y=(r,e,t)=>ft(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("zod"),gt=r=>{const e=r.replace(/_[a-z]/g,t=>t[1].toUpperCase());return e.length>1&&e[0]===e[0].toUpperCase()&&e[1]===e[1].toUpperCase()||e.length===0?e:e[0].toLowerCase()+e.slice(1)},Ve=r=>{const e=(t,n=pe)=>{if(typeof t=="string")return r(t);if(Array.isArray(t))return t.map(c=>e(c,n));if(!he(t))return t;n=mt(n);const s={},a=t;return Object.keys(a).forEach(c=>{let d=a[c];const f=r(c);n.recursive&&(he(d)?Ae(d,n.keepTypesOnRecursion)||(d=e(d,n)):n.recursiveInArray&&Ee(d)&&(d=[...d].map(p=>{let m=p;return he(p)?Ae(m,n.keepTypesOnRecursion)||(m=e(p,n)):Ee(p)&&(m=e({key:p},n).key),m}))),s[f]=d}),s};return e},Ze=Ve(gt),pt=r=>r.replace(/([a-z0-9])([A-Z])/g,(e,t,n)=>`${t}_${n.toLowerCase()}`),yt=Ve(pt),pe={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},mt=(r=pe)=>(r.recursive==null?r=pe:r.recursiveInArray??(r.recursiveInArray=!1),r),Ee=r=>r!=null&&Array.isArray(r),he=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Ae=(r,e)=>(e||[]).some(t=>r instanceof t),He=r=>r!=null&&typeof r=="object"&&!Array.isArray(r);var wt=Object.defineProperty,bt=(r,e,t)=>e in r?wt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Q=(r,e,t)=>bt(r,typeof e!="symbol"?e+"":e,t);let Ot=class{constructor(){Q(this,"contentType","application/json"),Q(this,"decoder"),Q(this,"encoder"),this.decoder=new TextDecoder,this.encoder=new TextEncoder}encode(e){return this.encoder.encode(this.encodeString(e)).buffer}decode(e,t){return this.decodeString(this.decoder.decode(e),t)}decodeString(e,t){const n=JSON.parse(e),s=Ze(n);return t!=null?t.parse(s):s}encodeString(e){const t=yt(e);return JSON.stringify(t,(n,s)=>ArrayBuffer.isView(s)?Array.from(s):He(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s)}static registerCustomType(){}},Tt=class{constructor(){Q(this,"contentType","text/csv")}encode(e){const t=this.encodeString(e);return new TextEncoder().encode(t).buffer}decode(e,t){const n=new TextDecoder().decode(e);return this.decodeString(n,t)}encodeString(e){if(!Array.isArray(e)||e.length===0||!He(e[0]))throw new Error("Payload must be an array of objects");const t=Object.keys(e[0]),n=[t.join(",")];return e.forEach(s=>{const a=t.map(c=>JSON.stringify(s[c]??""));n.push(a.join(","))}),n.join(`
|
|
2
2
|
`)}decodeString(e,t){const[n,...s]=e.trim().split(`
|
|
3
|
-
`).map(d=>d.trim());if(n.length===0)return t!=null?t.parse({}):{};const a=n.split(",").map(d=>d.trim()),c={};return a.forEach(d=>{c[d]=[]}),s.forEach(d=>{const f=d.split(",").map(p=>p.trim());a.forEach((p,m)=>{const l=this.parseValue(f[m]);l!=null&&c[p].push(l)})}),t!=null?t.parse(c):c}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},vt=class{constructor(){Q(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const n=new TextDecoder().decode(e);return t!=null?t.parse(n):n}};const te=new Tt;new Ot;new vt;const ue=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const Je=i.z.object({width:i.z.number(),height:i.z.number()}),St=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),It=["width","height"];i.z.enum(It);const Nt=["start","center","end"],Et=["signedWidth","signedHeight"];i.z.enum(Et);const ie=i.z.object({x:i.z.number(),y:i.z.number()}),At=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),xt=["x","y"],Xe=i.z.enum(xt),Ke=["top","right","bottom","left"];i.z.enum(Ke);const zt=["left","right"],Qe=i.z.enum(zt),Mt=["top","bottom"],_e=i.z.enum(Mt),et=["center"],xe=i.z.enum(et),$t=[...Ke,...et],tt=i.z.enum($t);i.z.enum(Nt);const Bt=["first","last"];i.z.enum(Bt);const Rt=i.z.object({lower:i.z.number(),upper:i.z.number()}),Ut=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([Rt,ue]);i.z.union([Ut,ue]);i.z.union([Xe,tt]);i.z.union([Xe,tt,i.z.instanceof(String)]);const Ct=r=>typeof r=="bigint"||r instanceof BigInt,j=(r,e)=>Ct(r)?r.valueOf()*BigInt(e.valueOf()):r.valueOf()*Number(e.valueOf()),k=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return ze(r);return ze(t)},ze=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r,Me=(r,e)=>{const t=k(r);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e};i.z.object({x:Qe.or(xe),y:_e.or(xe)});const Dt=i.z.object({x:Qe,y:_e}),Pt=Object.freeze({x:"left",y:"top"}),Lt=(r,e)=>r.x===e.x&&r.y===e.y,$e=i.z.union([i.z.number(),ie,ue,Je,St,At]),Yt=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Be=Object.freeze({x:0,y:0}),ee=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:ee,left:ee,width:ee,height:ee});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:ie,two:ie,root:Dt});const ve=(r,e,t=0,n=0,s)=>{const a={one:{...Be},two:{...Be},root:s??Pt};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},de=r=>{const e=ve(r);return{lower:e.one.x,upper:e.two.x}},fe=r=>{const e=ve(r);return{lower:e.one.y,upper:e.two.y}},kt=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r;var jt=Object.defineProperty,Ft=(r,e,t)=>e in r?jt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e,t)=>Ft(r,typeof e!="symbol"?e+"":e,t);const qt=(r,e,t)=>e!==void 0&&r<e?e:t!==void 0&&r>t?t:r;i.z.object({offset:$e,scale:$e});i.z.object({offset:i.z.number(),scale:i.z.number()});const Gt=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Wt=r=>(e,t,n,s)=>[e,s?n/r:n*r],Vt=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:c,upper:d}=r,f=a-s,p=d-c;if(t==="dimension")return[r,n*(p/f)];const m=(n-s)*(p/f)+c;return[r,m]},Zt=r=>(e,t,n)=>[r,n],Ht=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},Jt=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=qt(n,s,a),[e,n]},ye=class V{constructor(){C(this,"ops",[]),C(this,"currBounds",null),C(this,"currType",null),C(this,"reversed",!1),this.ops=[]}static translate(e){return new V().translate(e)}static magnify(e){return new V().magnify(e)}static scale(e,t){return new V().scale(e,t)}translate(e){const t=this.new(),n=Gt(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Wt(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=k(e,t),s=this.new(),a=Vt(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=k(e,t),s=this.new(),a=Jt(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=k(e,t),s=this.new(),a=Zt(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Ht();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new V;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([c,d])=>s>=c&&s<=d))return;const a=e.ops.findIndex((c,d)=>c.type==="scale"&&d>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};C(ye,"IDENTITY",new ye);let Re=ye;const Ue=class U{constructor(e=new Re,t=new Re,n=null){C(this,"x"),C(this,"y"),C(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new U().translate(e,t)}static translateX(e){return new U().translateX(e)}static translateY(e){return new U().translateY(e)}static clamp(e){return new U().clamp(e)}static magnify(e){return new U().magnify(e)}static scale(e){return new U().scale(e)}static reBound(e){return new U().reBound(e)}translate(e,t){const n=Yt(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(kt(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Lt(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(de(e)),t.y=t.y.scale(fe(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(de(e)),t.y=this.y.reBound(fe(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(de(e)),t.y=this.y.clamp(fe(e)),t}copy(){const e=new U;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ve(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};C(Ue,"IDENTITY",new Ue);const Xt=r=>r!=null&&typeof r=="object"&&"toString"in r,Kt=(r,e=!1)=>{const t=Xt(r)?"stringer":typeof r;let n;switch(t){case"string":n=(s,a)=>s.localeCompare(a);break;case"stringer":n=(s,a)=>s.toString().localeCompare(a.toString());break;case"number":n=(s,a)=>Number(s)-Number(a);break;case"bigint":n=(s,a)=>BigInt(s)-BigInt(a)>0n?1:-1;break;case"boolean":n=(s,a)=>Number(s)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Qt(n):n},Qt=r=>(e,t)=>r(t,e),_t=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([Je,_t,ie,ue]);const er=i.z.bigint().or(i.z.string().transform(BigInt));var tr=Object.defineProperty,rr=(r,e,t)=>e in r?tr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e,t)=>rr(r,typeof e!="symbol"?e+"":e,t);let nr=(r,e=21)=>(t=e)=>{let n="",s=t;for(;s--;)n+=r[Math.random()*r.length|0];return n};const sr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ir=nr(sr,11),ar=i.z.enum(["static","dynamic"]),rt=(r,e)=>{const t=new v(e);if(![O.DAY,O.HOUR,O.MINUTE,O.SECOND,O.MILLISECOND,O.MICROSECOND,O.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof v?new v(n):new O(n)},w=class h{constructor(e,t="UTC"){if(u(this,"value"),u(this,"encodeValue",!0),e==null)this.value=h.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*h.MILLISECOND.valueOf();else if(typeof e=="string")this.value=h.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=h.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=h.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=h.MAX:e=h.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new h(BigInt(s.getTime())*h.MILLISECOND.valueOf()).truncate(h.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let c="00",d="00";a!=null&&([c,d]=a.split("."));let f=h.hours(parseInt(n??"00")).add(h.minutes(parseInt(s??"00"))).add(h.seconds(parseInt(c??"00"))).add(h.milliseconds(parseInt(d??"00")));return t==="local"&&(f=f.add(h.utcOffset)),f.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return h.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new h(BigInt(n.getTime())*h.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(h.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new O(BigInt(new Date().getTimezoneOffset())*h.MINUTE.valueOf())}static since(e){return new h().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new h(e).valueOf()}span(e){return this.range(e).span}range(e){return new Se(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new h(e).valueOf()}afterEq(e){return this.valueOf()>=new h(e).valueOf()}before(e){return this.valueOf()<new h(e).valueOf()}beforeEq(e){return this.valueOf()<=new h(e).valueOf()}add(e){return new h(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new h(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(O.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(O.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(O.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(O.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(h.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new h(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new h(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new h(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new h(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new h(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new h(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new h(t)}toString(){return this.date().toISOString()}remainder(e){return rt(this,e)}get isToday(){return this.truncate(O.DAY).equals(h.now().truncate(O.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new h(new Date)}static max(...e){let t=h.MIN;for(const n of e){const s=new h(n);s.after(t)&&(t=s)}return t}static min(...e){let t=h.MAX;for(const n of e){const s=new h(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new h(e)}static microseconds(e){return h.nanoseconds(e*1e3)}static milliseconds(e){return h.microseconds(e*1e3)}static seconds(e){return h.milliseconds(e*1e3)}static minutes(e){return h.seconds(e*60)}static hours(e){return h.minutes(e*60)}static days(e){return h.hours(e*24)}};u(w,"NANOSECOND",w.nanoseconds(1)),u(w,"MICROSECOND",w.microseconds(1)),u(w,"MILLISECOND",w.milliseconds(1)),u(w,"SECOND",w.seconds(1)),u(w,"MINUTE",w.minutes(1)),u(w,"HOUR",w.hours(1)),u(w,"DAY",w.days(1)),u(w,"MAX",new w((1n<<63n)-1n)),u(w,"MIN",new w(0)),u(w,"ZERO",new w(0)),u(w,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new w(r.value)),i.z.string().transform(r=>new w(BigInt(r))),i.z.instanceof(Number).transform(r=>new w(r)),i.z.number().transform(r=>new w(r)),i.z.instanceof(w)]));let v=w;const b=class g{constructor(e){u(this,"value"),u(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof g?e:e instanceof Ce?e.period:e instanceof v?new g(e):["number","bigint"].includes(typeof e)?g.seconds(e):new g(e)}static fromMilliseconds(e){return e instanceof g?e:e instanceof Ce?e.period:e instanceof v?new g(e):["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return rt(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(g.DAY),t=this.truncate(g.HOUR),n=this.truncate(g.MINUTE),s=this.truncate(g.SECOND),a=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),d=this.truncate(g.NANOSECOND),f=e,p=t.sub(e),m=n.sub(t),l=s.sub(n),E=a.sub(s),B=c.sub(a),R=d.sub(c);let x="";return f.isZero||(x+=`${f.days}d `),p.isZero||(x+=`${p.hours}h `),m.isZero||(x+=`${m.minutes}m `),l.isZero||(x+=`${l.seconds}s `),E.isZero||(x+=`${E.milliseconds}ms `),B.isZero||(x+=`${B.microseconds}µs `),R.isZero||(x+=`${R.nanoseconds}ns`),x.trim()}mult(e){return new g(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static microseconds(e=1){return g.nanoseconds(j(e,1e3))}static milliseconds(e=1){return g.microseconds(j(e,1e3))}static seconds(e=1){return g.milliseconds(j(e,1e3))}static minutes(e=1){return g.seconds(j(e,60))}static hours(e){return g.minutes(j(e,60))}static days(e){return g.hours(j(e,24))}};u(b,"NANOSECOND",b.nanoseconds(1)),u(b,"MICROSECOND",b.microseconds(1)),u(b,"MILLISECOND",b.milliseconds(1)),u(b,"SECOND",b.seconds(1)),u(b,"MINUTE",b.minutes(1)),u(b,"HOUR",b.hours(1)),u(b,"DAY",b.days(1)),u(b,"MAX",new b((1n<<63n)-1n)),u(b,"MIN",new b(0)),u(b,"ZERO",new b(0)),u(b,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new b(r.value)),i.z.string().transform(r=>new b(BigInt(r))),i.z.instanceof(Number).transform(r=>new b(r)),i.z.number().transform(r=>new b(r)),i.z.instanceof(b)]));let O=b;const Z=class re extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new re(e).valueOf()}get period(){return O.seconds(1/this.valueOf())}sampleCount(e){return new O(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new A(t).valueOf()}span(e){return O.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new re(e)}static khz(e){return re.hz(e*1e3)}};u(Z,"z",i.z.union([i.z.number().transform(r=>new Z(r)),i.z.instanceof(Number).transform(r=>new Z(r)),i.z.instanceof(Z)]));let Ce=Z;const I=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new me(e*this.valueOf())}};u(I,"UNKNOWN",new I(0)),u(I,"BIT128",new I(16)),u(I,"BIT64",new I(8)),u(I,"BIT32",new I(4)),u(I,"BIT16",new I(2)),u(I,"BIT8",new I(1)),u(I,"z",i.z.union([i.z.number().transform(r=>new I(r)),i.z.instanceof(Number).transform(r=>new I(r)),i.z.instanceof(I)]));let A=I;const z=class ne{constructor(e,t){u(this,"start"),u(this,"end"),typeof e=="object"&&"start"in e?(this.start=new v(e.start),this.end=new v(e.end)):(this.start=new v(e),this.end=new v(t))}get span(){return new O(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 ne(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=O.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=v.max(n.start,e.start),a=v.min(n.end,e.end);return a.before(s)?!1:new O(a.sub(s)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=t.valueOf()&&s<=t.valueOf()}contains(e){return e instanceof ne?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new ne(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};u(z,"MAX",new z(v.MIN,v.MAX)),u(z,"MIN",new z(v.MAX,v.MIN)),u(z,"ZERO",new z(v.ZERO,v.ZERO)),u(z,"z",i.z.union([i.z.object({start:v.z,end:v.z}).transform(r=>new z(r.start,r.end)),i.z.instanceof(z)]));let Se=z;const o=class M extends String{constructor(e){if(e instanceof M||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=M.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(M.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=M.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(M.JSON)||this.equals(M.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(M.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=M.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return M.BIG_INT_TYPES.some(e=>e.equals(this))}};u(o,"UNKNOWN",new o("unknown")),u(o,"FLOAT64",new o("float64")),u(o,"FLOAT32",new o("float32")),u(o,"INT64",new o("int64")),u(o,"INT32",new o("int32")),u(o,"INT16",new o("int16")),u(o,"INT8",new o("int8")),u(o,"UINT64",new o("uint64")),u(o,"UINT32",new o("uint32")),u(o,"UINT16",new o("uint16")),u(o,"UINT8",new o("uint8")),u(o,"BOOLEAN",o.UINT8),u(o,"TIMESTAMP",new o("timestamp")),u(o,"UUID",new o("uuid")),u(o,"STRING",new o("string")),u(o,"JSON",new o("json")),u(o,"ARRAY_CONSTRUCTORS",new Map([[o.UINT8.toString(),Uint8Array],[o.UINT16.toString(),Uint16Array],[o.UINT32.toString(),Uint32Array],[o.UINT64.toString(),BigUint64Array],[o.FLOAT32.toString(),Float32Array],[o.FLOAT64.toString(),Float64Array],[o.INT8.toString(),Int8Array],[o.INT16.toString(),Int16Array],[o.INT32.toString(),Int32Array],[o.INT64.toString(),BigInt64Array],[o.TIMESTAMP.toString(),BigInt64Array],[o.STRING.toString(),Uint8Array],[o.JSON.toString(),Uint8Array],[o.UUID.toString(),Uint8Array]])),u(o,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,o.UINT8],[Uint16Array.name,o.UINT16],[Uint32Array.name,o.UINT32],[BigUint64Array.name,o.UINT64],[Float32Array.name,o.FLOAT32],[Float64Array.name,o.FLOAT64],[Int8Array.name,o.INT8],[Int16Array.name,o.INT16],[Int32Array.name,o.INT32],[BigInt64Array.name,o.INT64]])),u(o,"DENSITIES",new Map([[o.UINT8.toString(),A.BIT8],[o.UINT16.toString(),A.BIT16],[o.UINT32.toString(),A.BIT32],[o.UINT64.toString(),A.BIT64],[o.FLOAT32.toString(),A.BIT32],[o.FLOAT64.toString(),A.BIT64],[o.INT8.toString(),A.BIT8],[o.INT16.toString(),A.BIT16],[o.INT32.toString(),A.BIT32],[o.INT64.toString(),A.BIT64],[o.TIMESTAMP.toString(),A.BIT64],[o.STRING.toString(),A.UNKNOWN],[o.JSON.toString(),A.UNKNOWN],[o.UUID.toString(),A.BIT128]])),u(o,"ALL",[o.UNKNOWN,o.FLOAT64,o.FLOAT32,o.INT64,o.INT32,o.INT16,o.INT8,o.UINT64,o.UINT32,o.UINT16,o.UINT8,o.TIMESTAMP,o.UUID,o.STRING,o.JSON]),u(o,"BIG_INT_TYPES",[o.INT64,o.UINT64,o.TIMESTAMP]),u(o,"z",i.z.union([i.z.string().transform(r=>new o(r)),i.z.instanceof(o)]));let T=o;const N=class S extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return S.bytes(this.valueOf()+e.valueOf())}sub(e){return S.bytes(this.valueOf()-e.valueOf())}truncate(e){return new S(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return S.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/S.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/S.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/S.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/S.TERABYTE.valueOf()}toString(){const e=this.truncate(S.TERABYTE),t=this.truncate(S.GIGABYTE),n=this.truncate(S.MEGABYTE),s=this.truncate(S.KILOBYTE),a=this.truncate(S.BYTE),c=e,d=t.sub(e),f=n.sub(t),p=s.sub(n),m=a.sub(s);let l="";return c.isZero||(l+=`${c.terabytes}TB `),d.isZero||(l+=`${d.gigabytes}GB `),f.isZero||(l+=`${f.megabytes}MB `),p.isZero||(l+=`${p.kilobytes}KB `),(!m.isZero||l==="")&&(l+=`${m.valueOf()}B`),l.trim()}static bytes(e=1){return new S(e)}static kilobytes(e=1){return S.bytes(e.valueOf()*1e3)}static megabytes(e=1){return S.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return S.megabytes(e.valueOf()*1e3)}static terabytes(e){return S.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};u(N,"BYTE",new N(1)),u(N,"KILOBYTE",N.kilobytes(1)),u(N,"MEGABYTE",N.megabytes(1)),u(N,"GIGABYTE",N.gigabytes(1)),u(N,"TERABYTE",N.terabytes(1)),u(N,"ZERO",new N(0)),u(N,"z",i.z.union([i.z.number().transform(r=>new N(r)),i.z.instanceof(N)]));let me=N;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const nt=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof v||r instanceof O||r instanceof Date},or=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):J(t,-n).valueOf(),ur=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof hr?!0:nt(r),Y=-1,cr=i.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer),lr=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),we=10,H=class ${constructor(e){u(this,"key",""),u(this,"isSynnaxSeries",!0),u(this,"dataType"),u(this,"sampleOffset"),u(this,"gl"),u(this,"_data"),u(this,"_timeRange"),u(this,"alignment",0n),u(this,"_cachedMin"),u(this,"_cachedMax"),u(this,"writePos",Y),u(this,"_refCount",0),u(this,"_cachedLength"),u(this,"_cachedIndexes"),ur(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:c=0n,key:d=ir()}=e,f=e.data??[];if(f instanceof $||typeof f=="object"&&"isSynnaxSeries"in f&&f.isSynnaxSeries===!0){const l=f;this.key=l.key,this.dataType=l.dataType,this.sampleOffset=l.sampleOffset,this.gl=l.gl,this._data=l._data,this._timeRange=l._timeRange,this.alignment=l.alignment,this._cachedMin=l._cachedMin,this._cachedMax=l._cachedMax,this.writePos=l.writePos,this._refCount=l._refCount,this._cachedLength=l._cachedLength;return}const p=nt(f),m=Array.isArray(f);if(t!=null)this.dataType=new T(t);else{if(f instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||p){let l=f;if(!p){if(f.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");l=f[0]}if(typeof l=="string")this.dataType=T.STRING;else if(typeof l=="number")this.dataType=T.FLOAT64;else if(typeof l=="bigint")this.dataType=T.INT64;else if(typeof l=="boolean")this.dataType=T.BOOLEAN;else if(l instanceof v||l instanceof Date||l instanceof v)this.dataType=T.TIMESTAMP;else if(typeof l=="object")this.dataType=T.JSON;else throw new Error(`cannot infer data type of ${typeof l} when constructing a Series from a JS array`)}else this.dataType=new T(f)}if(!m&&!p)this._data=f;else{let l=p?[f]:f;const E=l[0];(E instanceof v||E instanceof Date||E instanceof O)&&(l=l.map(B=>new v(B).valueOf())),this.dataType.equals(T.STRING)?(this._cachedLength=l.length,this._data=new TextEncoder().encode(`${l.join(`
|
|
3
|
+
`).map(d=>d.trim());if(n.length===0)return t!=null?t.parse({}):{};const a=n.split(",").map(d=>d.trim()),c={};return a.forEach(d=>{c[d]=[]}),s.forEach(d=>{const f=d.split(",").map(p=>p.trim());a.forEach((p,m)=>{const l=this.parseValue(f[m]);l!=null&&c[p].push(l)})}),t!=null?t.parse(c):c}parseValue(e){if(e==null||e.length===0)return null;const t=Number(e);return isNaN(t)?e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e:t}static registerCustomType(){}},vt=class{constructor(){Q(this,"contentType","text/plain")}encode(e){return new TextEncoder().encode(e).buffer}decode(e,t){const n=new TextDecoder().decode(e);return t!=null?t.parse(n):n}};const te=new Ot;new Tt;new vt;const St=r=>r!=null&&typeof r=="object"&&"toString"in r,It=(r,e=!1)=>{const t=St(r)?"stringer":typeof r;let n;switch(t){case"string":n=(s,a)=>s.localeCompare(a);break;case"stringer":n=(s,a)=>s.toString().localeCompare(a.toString());break;case"number":n=(s,a)=>Number(s)-Number(a);break;case"bigint":n=(s,a)=>BigInt(s)-BigInt(a)>0n?1:-1;break;case"boolean":n=(s,a)=>Number(s)-Number(a);break;case"undefined":n=()=>0;break;default:return console.warn(`sortFunc: unknown type ${t}`),()=>-1}return e?Nt(n):n},Nt=r=>(e,t)=>r(t,e),ue=i.z.tuple([i.z.number(),i.z.number()]);i.z.tuple([i.z.bigint(),i.z.bigint()]);const Je=i.z.object({width:i.z.number(),height:i.z.number()}),Et=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()}),At=["width","height"];i.z.enum(At);const xt=["start","center","end"],zt=["signedWidth","signedHeight"];i.z.enum(zt);const ie=i.z.object({x:i.z.number(),y:i.z.number()}),Mt=i.z.object({clientX:i.z.number(),clientY:i.z.number()}),$t=["x","y"],Xe=i.z.enum($t),Ke=["top","right","bottom","left"];i.z.enum(Ke);const Bt=["left","right"],Qe=i.z.enum(Bt),Rt=["top","bottom"],_e=i.z.enum(Rt),et=["center"],xe=i.z.enum(et),Ut=[...Ke,...et],tt=i.z.enum(Ut);i.z.enum(xt);const Ct=["first","last"];i.z.enum(Ct);const Dt=i.z.object({lower:i.z.number(),upper:i.z.number()}),Pt=i.z.object({lower:i.z.bigint(),upper:i.z.bigint()});i.z.union([Dt,ue]);i.z.union([Pt,ue]);i.z.union([Xe,tt]);i.z.union([Xe,tt,i.z.instanceof(String)]);const Lt=r=>typeof r=="bigint"||r instanceof BigInt,j=(r,e)=>Lt(r)?r.valueOf()*BigInt(e.valueOf()):r.valueOf()*Number(e.valueOf()),Y=(r,e)=>{const t={};if(typeof r=="number"||typeof r=="bigint")e!=null?(t.lower=r,t.upper=e):(t.lower=typeof r=="bigint"?0n:0,t.upper=r);else if(Array.isArray(r)){if(r.length!==2)throw new Error("bounds: expected array of length 2");[t.lower,t.upper]=r}else return ze(r);return ze(t)},ze=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r,Me=(r,e)=>{const t=Y(r);return e<t.lower?t.lower:e>=t.upper?t.upper-(typeof t.upper=="number"?1:1n):e};i.z.object({x:Qe.or(xe),y:_e.or(xe)});const kt=i.z.object({x:Qe,y:_e}),Yt=Object.freeze({x:"left",y:"top"}),jt=(r,e)=>r.x===e.x&&r.y===e.y,$e=i.z.union([i.z.number(),ie,ue,Je,Et,Mt]),Ft=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Be=Object.freeze({x:0,y:0}),ee=i.z.union([i.z.number(),i.z.string()]);i.z.object({top:ee,left:ee,width:ee,height:ee});i.z.object({left:i.z.number(),top:i.z.number(),right:i.z.number(),bottom:i.z.number()});i.z.object({one:ie,two:ie,root:kt});const ve=(r,e,t=0,n=0,s)=>{const a={one:{...Be},two:{...Be},root:s??Yt};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},de=r=>{const e=ve(r);return{lower:e.one.x,upper:e.two.x}},fe=r=>{const e=ve(r);return{lower:e.one.y,upper:e.two.y}},qt=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Gt=i.z.object({signedWidth:i.z.number(),signedHeight:i.z.number()});i.z.union([Je,Gt,ie,ue]);var Wt=Object.defineProperty,Vt=(r,e,t)=>e in r?Wt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,C=(r,e,t)=>Vt(r,typeof e!="symbol"?e+"":e,t);const Zt=(r,e,t)=>e!==void 0&&r<e?e:t!==void 0&&r>t?t:r;i.z.object({offset:$e,scale:$e});i.z.object({offset:i.z.number(),scale:i.z.number()});const Ht=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Jt=r=>(e,t,n,s)=>[e,s?n/r:n*r],Xt=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:c,upper:d}=r,f=a-s,p=d-c;if(t==="dimension")return[r,n*(p/f)];const m=(n-s)*(p/f)+c;return[r,m]},Kt=r=>(e,t,n)=>[r,n],Qt=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},_t=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Zt(n,s,a),[e,n]},ye=class V{constructor(){C(this,"ops",[]),C(this,"currBounds",null),C(this,"currType",null),C(this,"reversed",!1),this.ops=[]}static translate(e){return new V().translate(e)}static magnify(e){return new V().magnify(e)}static scale(e,t){return new V().scale(e,t)}translate(e){const t=this.new(),n=Ht(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Jt(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Y(e,t),s=this.new(),a=Xt(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=Y(e,t),s=this.new(),a=_t(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=Y(e,t),s=this.new(),a=Kt(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Qt();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new V;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([c,d])=>s>=c&&s<=d))return;const a=e.ops.findIndex((c,d)=>c.type==="scale"&&d>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}get transform(){return{scale:this.dim(1),offset:this.pos(0)}}};C(ye,"IDENTITY",new ye);let Re=ye;const Ue=class U{constructor(e=new Re,t=new Re,n=null){C(this,"x"),C(this,"y"),C(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new U().translate(e,t)}static translateX(e){return new U().translateX(e)}static translateY(e){return new U().translateY(e)}static clamp(e){return new U().clamp(e)}static magnify(e){return new U().magnify(e)}static scale(e){return new U().scale(e)}static reBound(e){return new U().reBound(e)}translate(e,t){const n=Ft(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(qt(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!jt(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(de(e)),t.y=t.y.scale(fe(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(de(e)),t.y=this.y.reBound(fe(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(de(e)),t.y=this.y.clamp(fe(e)),t}copy(){const e=new U;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}dim(e){return{x:this.x.dim(e.x),y:this.y.dim(e.y)}}box(e){return ve(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}get transform(){return{scale:this.dim({x:1,y:1}),offset:this.pos({x:0,y:0})}}};C(Ue,"IDENTITY",new Ue);const er=i.z.bigint().or(i.z.string().transform(BigInt));var tr=Object.defineProperty,rr=(r,e,t)=>e in r?tr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,u=(r,e,t)=>rr(r,typeof e!="symbol"?e+"":e,t);let nr=(r,e=21)=>(t=e)=>{let n="",s=t|0;for(;s--;)n+=r[Math.random()*r.length|0];return n};const sr="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",ir=nr(sr,11),ar=i.z.enum(["static","dynamic"]),rt=(r,e)=>{const t=new v(e);if(![T.DAY,T.HOUR,T.MINUTE,T.SECOND,T.MILLISECOND,T.MICROSECOND,T.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof v?new v(n):new T(n)},w=class h{constructor(e,t="UTC"){if(u(this,"value"),u(this,"encodeValue",!0),e==null)this.value=h.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*h.MILLISECOND.valueOf();else if(typeof e=="string")this.value=h.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=h.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=h.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=h.MAX:e=h.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new h(BigInt(s.getTime())*h.MILLISECOND.valueOf()).truncate(h.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let c="00",d="00";a!=null&&([c,d]=a.split("."));let f=h.hours(parseInt(n??"00")).add(h.minutes(parseInt(s??"00"))).add(h.seconds(parseInt(c??"00"))).add(h.milliseconds(parseInt(d??"00")));return t==="local"&&(f=f.add(h.utcOffset)),f.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return h.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new h(BigInt(n.getTime())*h.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(h.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(){const e=this.date(),t=e.toLocaleString("default",{month:"short"}),n=e.toLocaleString("default",{day:"numeric"});return`${t} ${n}`}static get utcOffset(){return new T(BigInt(new Date().getTimezoneOffset())*h.MINUTE.valueOf())}static since(e){return new h().span(e)}date(){return new Date(this.milliseconds)}equals(e){return this.valueOf()===new h(e).valueOf()}span(e){return this.range(e).span}range(e){return new Se(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new h(e).valueOf()}afterEq(e){return this.valueOf()>=new h(e).valueOf()}before(e){return this.valueOf()<new h(e).valueOf()}beforeEq(e){return this.valueOf()<=new h(e).valueOf()}add(e){return new h(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new h(this.valueOf()-BigInt(e.valueOf()))}get hours(){return Number(this.valueOf())/Number(T.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(T.MINUTE.valueOf())}get days(){return Number(this.valueOf())/Number(T.DAY.valueOf())}get seconds(){return Number(this.valueOf())/Number(T.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(h.MILLISECOND.valueOf())}get year(){return this.date().getFullYear()}setYear(e){const t=this.date();return t.setFullYear(e),new h(t)}get month(){return this.date().getMonth()}setMonth(e){const t=this.date();return t.setMonth(e),new h(t)}get day(){return this.date().getDate()}setDay(e){const t=this.date();return t.setDate(e),new h(t)}get hour(){return this.date().getHours()}setHour(e){const t=this.date();return t.setHours(e),new h(t)}get minute(){return this.date().getMinutes()}setMinute(e){const t=this.date();return t.setMinutes(e),new h(t)}get second(){return this.date().getSeconds()}setSecond(e){const t=this.date();return t.setSeconds(e),new h(t)}get millisecond(){return this.date().getMilliseconds()}setMillisecond(e){const t=this.date();return t.setMilliseconds(e),new h(t)}toString(){return this.date().toISOString()}remainder(e){return rt(this,e)}get isToday(){return this.truncate(T.DAY).equals(h.now().truncate(T.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new h(new Date)}static max(...e){let t=h.MIN;for(const n of e){const s=new h(n);s.after(t)&&(t=s)}return t}static min(...e){let t=h.MAX;for(const n of e){const s=new h(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new h(e)}static microseconds(e){return h.nanoseconds(e*1e3)}static milliseconds(e){return h.microseconds(e*1e3)}static seconds(e){return h.milliseconds(e*1e3)}static minutes(e){return h.seconds(e*60)}static hours(e){return h.minutes(e*60)}static days(e){return h.hours(e*24)}};u(w,"NANOSECOND",w.nanoseconds(1)),u(w,"MICROSECOND",w.microseconds(1)),u(w,"MILLISECOND",w.milliseconds(1)),u(w,"SECOND",w.seconds(1)),u(w,"MINUTE",w.minutes(1)),u(w,"HOUR",w.hours(1)),u(w,"DAY",w.days(1)),u(w,"MAX",new w((1n<<63n)-1n)),u(w,"MIN",new w(0)),u(w,"ZERO",new w(0)),u(w,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new w(r.value)),i.z.string().transform(r=>new w(BigInt(r))),i.z.instanceof(Number).transform(r=>new w(r)),i.z.number().transform(r=>new w(r)),i.z.instanceof(w)]));let v=w;const b=class g{constructor(e){u(this,"value"),u(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}static fromSeconds(e){return e instanceof g?e:e instanceof Ce?e.period:e instanceof v?new g(e):["number","bigint"].includes(typeof e)?g.seconds(e):new g(e)}static fromMilliseconds(e){return e instanceof g?e:e instanceof Ce?e.period:e instanceof v?new g(e):["number","bigint"].includes(typeof e)?g.milliseconds(e):new g(e)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new g(e).valueOf()}greaterThan(e){return this.valueOf()>new g(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new g(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new g(e).valueOf()}remainder(e){return rt(this,e)}truncate(e){return new g(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(g.DAY),t=this.truncate(g.HOUR),n=this.truncate(g.MINUTE),s=this.truncate(g.SECOND),a=this.truncate(g.MILLISECOND),c=this.truncate(g.MICROSECOND),d=this.truncate(g.NANOSECOND),f=e,p=t.sub(e),m=n.sub(t),l=s.sub(n),E=a.sub(s),B=c.sub(a),R=d.sub(c);let x="";return f.isZero||(x+=`${f.days}d `),p.isZero||(x+=`${p.hours}h `),m.isZero||(x+=`${m.minutes}m `),l.isZero||(x+=`${l.seconds}s `),E.isZero||(x+=`${E.milliseconds}ms `),B.isZero||(x+=`${B.microseconds}µs `),R.isZero||(x+=`${R.nanoseconds}ns`),x.trim()}mult(e){return new g(this.valueOf()*BigInt(e))}get days(){return Number(this.valueOf())/Number(g.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(g.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(g.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(g.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(g.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(g.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new g(e).valueOf()}add(e){return new g(this.valueOf()+new g(e).valueOf())}sub(e){return new g(this.valueOf()-new g(e).valueOf())}static nanoseconds(e=1){return new g(e)}static microseconds(e=1){return g.nanoseconds(j(e,1e3))}static milliseconds(e=1){return g.microseconds(j(e,1e3))}static seconds(e=1){return g.milliseconds(j(e,1e3))}static minutes(e=1){return g.seconds(j(e,60))}static hours(e){return g.minutes(j(e,60))}static days(e){return g.hours(j(e,24))}};u(b,"NANOSECOND",b.nanoseconds(1)),u(b,"MICROSECOND",b.microseconds(1)),u(b,"MILLISECOND",b.milliseconds(1)),u(b,"SECOND",b.seconds(1)),u(b,"MINUTE",b.minutes(1)),u(b,"HOUR",b.hours(1)),u(b,"DAY",b.days(1)),u(b,"MAX",new b((1n<<63n)-1n)),u(b,"MIN",new b(0)),u(b,"ZERO",new b(0)),u(b,"z",i.z.union([i.z.object({value:i.z.bigint()}).transform(r=>new b(r.value)),i.z.string().transform(r=>new b(BigInt(r))),i.z.instanceof(Number).transform(r=>new b(r)),i.z.number().transform(r=>new b(r)),i.z.instanceof(b)]));let T=b;const Z=class re extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new re(e).valueOf()}get period(){return T.seconds(1/this.valueOf())}sampleCount(e){return new T(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new A(t).valueOf()}span(e){return T.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new re(e)}static khz(e){return re.hz(e*1e3)}};u(Z,"z",i.z.union([i.z.number().transform(r=>new Z(r)),i.z.instanceof(Number).transform(r=>new Z(r)),i.z.instanceof(Z)]));let Ce=Z;const I=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new me(e*this.valueOf())}};u(I,"UNKNOWN",new I(0)),u(I,"BIT128",new I(16)),u(I,"BIT64",new I(8)),u(I,"BIT32",new I(4)),u(I,"BIT16",new I(2)),u(I,"BIT8",new I(1)),u(I,"z",i.z.union([i.z.number().transform(r=>new I(r)),i.z.instanceof(Number).transform(r=>new I(r)),i.z.instanceof(I)]));let A=I;const z=class ne{constructor(e,t){u(this,"start"),u(this,"end"),typeof e=="object"&&"start"in e?(this.start=new v(e.start),this.end=new v(e.end)):(this.start=new v(e),this.end=new v(t))}get span(){return new T(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 ne(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e,t=T.ZERO){e=e.makeValid();const n=this.makeValid();if(this.equals(e))return!0;if(e.end.equals(n.start)||n.end.equals(e.start))return!1;const s=v.max(n.start,e.start),a=v.min(n.end,e.end);return a.before(s)?!1:new T(a.sub(s)).greaterThanOrEqual(t)}roughlyEquals(e,t){let n=this.start.sub(e.start).valueOf(),s=this.end.sub(e.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=t.valueOf()&&s<=t.valueOf()}contains(e){return e instanceof ne?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new ne(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};u(z,"MAX",new z(v.MIN,v.MAX)),u(z,"MIN",new z(v.MAX,v.MIN)),u(z,"ZERO",new z(v.ZERO,v.ZERO)),u(z,"z",i.z.union([i.z.object({start:v.z,end:v.z}).transform(r=>new z(r.start,r.end)),i.z.instanceof(z)]));let Se=z;const o=class M extends String{constructor(e){if(e instanceof M||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}const t=M.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}throw super(M.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=M.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}matches(...e){return e.some(t=>this.equals(t))}toString(){return this.valueOf()}get isVariable(){return this.equals(M.JSON)||this.equals(M.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(M.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=M.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}canSafelyCastTo(e){return this.equals(e)?!0:this.isVariable&&!e.isVariable||!this.isVariable&&e.isVariable?!1:this.isFloat&&e.isInteger||this.isInteger&&e.isFloat?this.density.valueOf()<e.density.valueOf():this.isFloat&&e.isFloat||this.isInteger&&e.isInteger?this.density.valueOf()<=e.density.valueOf():!1}canCastTo(e){return this.isNumeric&&e.isNumeric?!0:this.equals(e)}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return M.BIG_INT_TYPES.some(e=>e.equals(this))}};u(o,"UNKNOWN",new o("unknown")),u(o,"FLOAT64",new o("float64")),u(o,"FLOAT32",new o("float32")),u(o,"INT64",new o("int64")),u(o,"INT32",new o("int32")),u(o,"INT16",new o("int16")),u(o,"INT8",new o("int8")),u(o,"UINT64",new o("uint64")),u(o,"UINT32",new o("uint32")),u(o,"UINT16",new o("uint16")),u(o,"UINT8",new o("uint8")),u(o,"BOOLEAN",o.UINT8),u(o,"TIMESTAMP",new o("timestamp")),u(o,"UUID",new o("uuid")),u(o,"STRING",new o("string")),u(o,"JSON",new o("json")),u(o,"ARRAY_CONSTRUCTORS",new Map([[o.UINT8.toString(),Uint8Array],[o.UINT16.toString(),Uint16Array],[o.UINT32.toString(),Uint32Array],[o.UINT64.toString(),BigUint64Array],[o.FLOAT32.toString(),Float32Array],[o.FLOAT64.toString(),Float64Array],[o.INT8.toString(),Int8Array],[o.INT16.toString(),Int16Array],[o.INT32.toString(),Int32Array],[o.INT64.toString(),BigInt64Array],[o.TIMESTAMP.toString(),BigInt64Array],[o.STRING.toString(),Uint8Array],[o.JSON.toString(),Uint8Array],[o.UUID.toString(),Uint8Array]])),u(o,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,o.UINT8],[Uint16Array.name,o.UINT16],[Uint32Array.name,o.UINT32],[BigUint64Array.name,o.UINT64],[Float32Array.name,o.FLOAT32],[Float64Array.name,o.FLOAT64],[Int8Array.name,o.INT8],[Int16Array.name,o.INT16],[Int32Array.name,o.INT32],[BigInt64Array.name,o.INT64]])),u(o,"DENSITIES",new Map([[o.UINT8.toString(),A.BIT8],[o.UINT16.toString(),A.BIT16],[o.UINT32.toString(),A.BIT32],[o.UINT64.toString(),A.BIT64],[o.FLOAT32.toString(),A.BIT32],[o.FLOAT64.toString(),A.BIT64],[o.INT8.toString(),A.BIT8],[o.INT16.toString(),A.BIT16],[o.INT32.toString(),A.BIT32],[o.INT64.toString(),A.BIT64],[o.TIMESTAMP.toString(),A.BIT64],[o.STRING.toString(),A.UNKNOWN],[o.JSON.toString(),A.UNKNOWN],[o.UUID.toString(),A.BIT128]])),u(o,"ALL",[o.UNKNOWN,o.FLOAT64,o.FLOAT32,o.INT64,o.INT32,o.INT16,o.INT8,o.UINT64,o.UINT32,o.UINT16,o.UINT8,o.TIMESTAMP,o.UUID,o.STRING,o.JSON]),u(o,"BIG_INT_TYPES",[o.INT64,o.UINT64,o.TIMESTAMP]),u(o,"z",i.z.union([i.z.string().transform(r=>new o(r)),i.z.instanceof(o)]));let O=o;const N=class S extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return S.bytes(this.valueOf()+e.valueOf())}sub(e){return S.bytes(this.valueOf()-e.valueOf())}truncate(e){return new S(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return S.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/S.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/S.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/S.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/S.TERABYTE.valueOf()}toString(){const e=this.truncate(S.TERABYTE),t=this.truncate(S.GIGABYTE),n=this.truncate(S.MEGABYTE),s=this.truncate(S.KILOBYTE),a=this.truncate(S.BYTE),c=e,d=t.sub(e),f=n.sub(t),p=s.sub(n),m=a.sub(s);let l="";return c.isZero||(l+=`${c.terabytes}TB `),d.isZero||(l+=`${d.gigabytes}GB `),f.isZero||(l+=`${f.megabytes}MB `),p.isZero||(l+=`${p.kilobytes}KB `),(!m.isZero||l==="")&&(l+=`${m.valueOf()}B`),l.trim()}static bytes(e=1){return new S(e)}static kilobytes(e=1){return S.bytes(e.valueOf()*1e3)}static megabytes(e=1){return S.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return S.megabytes(e.valueOf()*1e3)}static terabytes(e){return S.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};u(N,"BYTE",new N(1)),u(N,"KILOBYTE",N.kilobytes(1)),u(N,"MEGABYTE",N.megabytes(1)),u(N,"GIGABYTE",N.gigabytes(1)),u(N,"TERABYTE",N.terabytes(1)),u(N,"ZERO",new N(0)),u(N,"z",i.z.union([i.z.number().transform(r=>new N(r)),i.z.instanceof(N)]));let me=N;i.z.union([i.z.instanceof(Uint8Array),i.z.instanceof(Uint16Array),i.z.instanceof(Uint32Array),i.z.instanceof(BigUint64Array),i.z.instanceof(Float32Array),i.z.instanceof(Float64Array),i.z.instanceof(Int8Array),i.z.instanceof(Int16Array),i.z.instanceof(Int32Array),i.z.instanceof(BigInt64Array)]);const nt=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof v||r instanceof T||r instanceof Date},or=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t.valueOf())-BigInt(n.valueOf()):J(t,-n).valueOf(),ur=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof hr?!0:nt(r),k=-1,cr=i.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer),lr=i.z.union([i.z.null(),i.z.undefined()]).transform(()=>new Uint8Array().buffer),we=10,H=class ${constructor(e){u(this,"key",""),u(this,"isSynnaxSeries",!0),u(this,"dataType"),u(this,"sampleOffset"),u(this,"gl"),u(this,"_data"),u(this,"_timeRange"),u(this,"alignment",0n),u(this,"_cachedMin"),u(this,"_cachedMax"),u(this,"writePos",k),u(this,"_refCount",0),u(this,"_cachedLength"),u(this,"_cachedIndexes"),ur(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:c=0n,key:d=ir()}=e,f=e.data??[];if(f instanceof $||typeof f=="object"&&"isSynnaxSeries"in f&&f.isSynnaxSeries===!0){const l=f;this.key=l.key,this.dataType=l.dataType,this.sampleOffset=l.sampleOffset,this.gl=l.gl,this._data=l._data,this._timeRange=l._timeRange,this.alignment=l.alignment,this._cachedMin=l._cachedMin,this._cachedMax=l._cachedMax,this.writePos=l.writePos,this._refCount=l._refCount,this._cachedLength=l._cachedLength;return}const p=nt(f),m=Array.isArray(f);if(t!=null)this.dataType=new O(t);else{if(f instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||p){let l=f;if(!p){if(f.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");l=f[0]}if(typeof l=="string")this.dataType=O.STRING;else if(typeof l=="number")this.dataType=O.FLOAT64;else if(typeof l=="bigint")this.dataType=O.INT64;else if(typeof l=="boolean")this.dataType=O.BOOLEAN;else if(l instanceof v||l instanceof Date||l instanceof v)this.dataType=O.TIMESTAMP;else if(typeof l=="object")this.dataType=O.JSON;else throw new Error(`cannot infer data type of ${typeof l} when constructing a Series from a JS array`)}else this.dataType=new O(f)}if(!m&&!p)this._data=f;else{let l=p?[f]:f;const E=l[0];(E instanceof v||E instanceof Date||E instanceof T)&&(l=l.map(B=>new v(B).valueOf())),this.dataType.equals(O.STRING)?(this._cachedLength=l.length,this._data=new TextEncoder().encode(`${l.join(`
|
|
4
4
|
`)}
|
|
5
|
-
`).buffer):this.dataType.equals(
|
|
5
|
+
`).buffer):this.dataType.equals(O.JSON)?(this._cachedLength=l.length,this._data=new TextEncoder().encode(`${l.map(B=>te.encodeString(B)).join(`
|
|
6
6
|
`)}
|
|
7
|
-
`).buffer):this._data=new this.dataType.Array(l).buffer}this.key=d,this.alignment=c,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new
|
|
7
|
+
`).buffer):this._data=new this.dataType.Array(l).buffer}this.key=d,this.alignment=c,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new O(t).Array(e),a=new $({data:s.buffer,dataType:t,...n});return a.writePos=0,a}static generateTimestamps(e,t,n){const s=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let c=0;c<e;c++)a[c]=BigInt(n.add(t.span(c)).valueOf());return new $({data:a,dataType:O.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(`${e.join(`
|
|
8
8
|
`)}
|
|
9
|
-
`);return new $({data:n,dataType:
|
|
9
|
+
`);return new $({data:n,dataType:O.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(`${e.map(s=>te.encodeString(s)).join(`
|
|
10
10
|
`)}
|
|
11
|
-
`);return new $({data:n,dataType:
|
|
12
|
-
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(
|
|
13
|
-
`).slice(0,-1).map(t=>e.parse(te.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new me(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Y?this.byteCapacity:this.dataType.isVariable?new me(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Y?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((n,s)=>{n===we&&(e++,t.push(s+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=or(this.dataType,e,this.data[s],t);return new $({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(T.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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()),J(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(T.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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()),J(this._cachedMin,this.sampleOffset))}get bounds(){return k(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return J(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return J(n,this.sampleOffset)}atVariable(e,t){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let c=0;c<this.data.length;c++)if(this.data[c]===we){if(e===0){s=c;break}n=c+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,s);return this.dataType.equals(T.STRING)?new TextDecoder().decode(a):Ze(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const s=Kt(e);for(;t<=n;){const a=Math.floor((t+n)/2),c=s(this.at(a,!0),e);if(c===0)return a;c<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(T.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Y){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(s).valueOf(),c=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,c.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Y}as(e){if(e==="string"){if(!this.dataType.equals(T.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(T.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:je(this.alignmentBounds.lower),upper:je(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return k(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new dr(this);return this.dataType.equals(T.JSON)?new fr(e):e}return new gr(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new De(this,e,t??this.length)}subAlignmentIterator(e,t){return new De(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new $({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(t,n):s=this.data.slice(t,n),new $({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new $({data:this.buffer,dataType:this.dataType,timeRange:Se.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};u(H,"crudeZ",i.z.object({timeRange:Se.z.optional(),dataType:T.z,alignment:er.optional(),data:i.z.union([cr,lr,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:ar.optional().default("static").optional()})),u(H,"z",H.crudeZ.transform(r=>new H(r)));let hr=H;class De{constructor(e,t,n){u(this,"series"),u(this,"end"),u(this,"index"),this.series=e;const s=k(0,e.length);this.end=Me(s,n),this.index=Me(s,t)}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 dr{constructor(e){if(u(this,"series"),u(this,"index"),u(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==we;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Pe,Le;class fr{constructor(e){u(this,"wrapped"),u(this,Pe,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:te.decodeString(e.value)}}[(Le=Symbol.iterator,Pe=Symbol.toStringTag,Le)](){return this}}var Ye,ke;class gr{constructor(e){u(this,"series"),u(this,"index"),u(this,Ye,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(ke=Symbol.iterator,Ye=Symbol.toStringTag,ke)](){return this}}const J=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e),je=r=>{const e=r>>32n,t=r&0xffffffffn;return{domain:e,sample:t}};i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const st=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",pr=st(),it=["MacOS","Windows","Linux","Docker"],yr=i.z.enum(it);let ge;const mr=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},wr=(r={})=>{const{force:e,default:t}=r;return e??ge??(ge=mr(),ge??t)},at=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:it,RUNTIME:pr,detect:st,getOS:wr,osZ:yr},Symbol.toStringTag,{value:"Module"}));var br=Object.defineProperty,Tr=(r,e,t)=>e in r?br(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,X=(r,e,t)=>Tr(r,typeof e!="symbol"?e+"":e,t);const Or=(...r)=>r.map(ot).join(""),ot=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),vr=r=>r.endsWith("/")?r.slice(0,-1):r,Sr=(r,e="")=>r===null?"":`?${Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&")}`,be=class Te{constructor({host:e,port:t,protocol:n="",pathPrefix:s=""}){X(this,"protocol"),X(this,"host"),X(this,"port"),X(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=ot(s)}replace(e){return new Te({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Te({...this,pathPrefix:Or(this.path,e)})}toString(){return vr(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};X(be,"UNKNOWN",new be({host:"unknown",port:0}));let Ir=be;var Nr=Object.defineProperty,Er=(r,e,t)=>e in r?Nr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,se=(r,e,t)=>Er(r,typeof e!="symbol"?e+"":e,t);const F=class extends Number{};se(F,"Absolute",255),se(F,"Default",1),se(F,"z",i.z.union([i.z.instanceof(F),i.z.number().int().min(0).max(255).transform(r=>new F(r)),i.z.instanceof(Number).transform(r=>new F(r))]));i.z.object({name:i.z.string(),key:i.z.string()});const ut=class K extends Error{constructor(){super(K.MESSAGE)}matches(e){return typeof e=="string"?e.includes(K.MESSAGE):e instanceof K||e.message.includes(K.MESSAGE)}};se(ut,"MESSAGE","canceled");let Ar=ut;new Ar;i.z.string().regex(/^\d+\.\d+\.\d+$/);const xr=async r=>await new Promise(e=>setTimeout(e,O.fromMilliseconds(r).milliseconds)),zr=i.z.object({interval:O.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),Mr=(r={})=>{const e=r.sleepFn||xr,t=r.maxRetries??5,n=r.scale??1;let s=0,a=new O(r.interval??O.milliseconds(1));return async()=>s>=t?!1:(await e(a),a=a.mult(n),s++,!0)},$r=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:zr,create:Mr},Symbol.toStringTag,{value:"Module"})),ce=r=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(r):e instanceof Error?e.message.includes(r):typeof e!="string"?!1:e.includes(r);class _ extends Error{constructor(){super(...arguments);y(this,"discriminator","FreighterError");y(this,"type","")}}const Br=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Fe="unknown",qe="nil",Rr="freighter",Ie=i.z.object({type:i.z.string(),data:i.z.string()});class Ur{constructor(){y(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:qe,data:""};if(Br(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Fe,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===qe)return null;if(e.type===Fe)return new Ge(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Ge(e.data)}}const Ne=new Ur,ct=({encode:r,decode:e})=>Ne.register({encode:r,decode:e}),Cr=r=>Ne.encode(r),ae=r=>Ne.decode(r);class Ge extends _{constructor(){super(...arguments);y(this,"type","unknown")}}const le="freighter.",q=class q extends _{constructor(){super("EOF");y(this,"type",q.TYPE)}};y(q,"TYPE",`${le}eof`),y(q,"matches",ce(q.TYPE));let D=q;const G=class G extends _{constructor(){super("StreamClosed");y(this,"type",G.TYPE)}};y(G,"TYPE",`${le}stream_closed`),y(G,"matches",ce(G.TYPE));let P=G;const W=class W extends _{constructor(t={}){const{message:n="Unreachable",url:s=Ir.UNKNOWN}=t;super(n);y(this,"type",W.TYPE);y(this,"url");this.url=s}};y(W,"TYPE",`${le}unreachable`),y(W,"matches",ce(W.TYPE));let L=W;const Dr=r=>{if(!r.type.startsWith(Rr))return null;if(D.matches(r))return{type:D.TYPE,data:"EOF"};if(P.matches(r))return{type:P.TYPE,data:"StreamClosed"};if(L.matches(r))return{type:L.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},Pr=r=>{if(!r.type.startsWith(le))return null;switch(r.type){case D.TYPE:return new D;case P.TYPE:return new P;case L.TYPE:return new L;default:throw new Error(`Unknown error type: ${r.data}`)}};ct({encode:Dr,decode:Pr});class lt{constructor(){y(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const c=this.middleware[n];return n++,await c(a,s)};return await s(e)}}const ht="Content-Type",We=r=>{if(at.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class Lr extends lt{constructor(t,n,s=!1){super();y(this,"endpoint");y(this,"encoder");y(this,"fetch");return this.endpoint=t.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=We(this.endpoint.protocol),new Proxy(this,{get:(a,c,d)=>c==="endpoint"?this.endpoint:Reflect.get(a,c,d)})}get headers(){return{[ht]:this.encoder.contentType}}async send(t,n,s,a){n=s==null?void 0:s.parse(n);let c=null;const d=this.endpoint.child(t),f={};f.method="POST",f.body=this.encoder.encode(n??{});const[,p]=await this.executeMiddleware({target:d.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async m=>{const l={...m,params:{}};f.headers={...this.headers,...m.params};let E;try{E=await We(m.protocol)(m.target,f)}catch(R){let x=R;return x.message==="Load failed"&&(x=new L({url:d})),[l,x]}const B=await E.arrayBuffer();if(E!=null&&E.ok)return a!=null&&(c=this.encoder.decode(B,a)),[l,null];try{if(E.status!==400)return[l,new Error(E.statusText)];const R=this.encoder.decode(B,Ie),x=ae(R);return[l,x]}catch(R){return[l,new Error(`[freighter] - failed to decode error: ${E.statusText}: ${R.message}`)]}});return[c,p]}}const Yr=(r,e)=>{class t{constructor(s){y(this,"wrapped");this.wrapped=s}use(...s){this.wrapped.use(...s)}async send(s,a,c,d){const f=$r.create(e);do{const[p,m]=await this.wrapped.send(s,a,c,d);if(m==null||!L.matches(m))return[p,m];if(!await f())return[p,m]}while(!0)}}return new t(r)},kr=async(r,e,t,n,s)=>{const[a,c]=await r.send(e,t,n,s);if(c!=null)throw c;return a},jr=()=>at.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Fr=i.z.object({type:i.z.union([i.z.literal("data"),i.z.literal("close"),i.z.literal("open")]),payload:i.z.unknown().optional(),error:i.z.optional(Ie)});class qr{constructor(e,t,n,s){y(this,"encoder");y(this,"reqSchema");y(this,"resSchema");y(this,"ws");y(this,"serverClosed");y(this,"sendClosed");y(this,"receiveDataQueue",[]);y(this,"receiveCallbacksQueue",[]);this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return ae(e.error)}return null}send(e){if(this.serverClosed!=null)return new D;if(this.sendClosed)throw new P;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=ae(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,Fr)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:Hr(e)?D.TYPE:P.TYPE,data:""}})}}const Gr="freighterctx",Wr=1e3,Vr=1001,Zr=[Wr,Vr],Hr=r=>Zr.includes(r.code),oe=class oe extends lt{constructor(t,n,s=!1){super();y(this,"baseUrl");y(this,"encoder");this.baseUrl=t.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(t,n,s){const a=jr();let c;const[,d]=await this.executeMiddleware({target:t,protocol:"websocket",params:{},role:"client"},async f=>{const p=a(this.buildURL(t,f)),m={...f,params:{}};p.binaryType=oe.MESSAGE_TYPE;const l=await this.wrapSocket(p,n,s);return l instanceof Error?[m,l]:(c=l,[m,null])});if(d!=null)throw d;return c}buildURL(t,n){const s=Sr({[ht]:this.encoder.contentType,...n.params},Gr);return this.baseUrl.child(t).toString()+s}async wrapSocket(t,n,s){return await new Promise(a=>{t.onopen=()=>{const c=new qr(t,this.encoder,n,s);c.receiveOpenAck().then(d=>{d!=null?a(d):a(c)}).catch(d=>a(d))},t.onerror=c=>{const d=c;a(new Error(d.message))}})}};y(oe,"MESSAGE_TYPE","arraybuffer");let Oe=oe;exports.BaseTypedError=_;exports.EOF=D;exports.HTTPClient=Lr;exports.StreamClosed=P;exports.Unreachable=L;exports.WebSocketClient=Oe;exports.decodeError=ae;exports.encodeError=Cr;exports.errorMatcher=ce;exports.errorZ=Ie;exports.registerError=ct;exports.sendRequired=kr;exports.unaryWithBreaker=Yr;
|
|
11
|
+
`);return new $({data:n,dataType:O.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(e):this.writeFixed(e)}writeVariable(e){if(this.writePos===k)return 0;const t=this.byteCapacity.valueOf()-this.writePos,n=e.subBytes(0,t);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(e){if(this.writePos===k)return 0;const t=this.capacity-this.writePos,n=e.sub(0,t);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(e){this.underlyingData.set(e.data,this.writePos)}get buffer(){return typeof this._data=="object"&&"buffer"in this._data?this._data.buffer:this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===k?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(O.STRING,O.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
12
|
+
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(O.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=O.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const s=this.underlyingData.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(s.buffer),c=>c.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(O.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
13
|
+
`).slice(0,-1).map(t=>e.parse(te.decodeString(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new me(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===k?this.byteCapacity:this.dataType.isVariable?new me(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===k?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;const t=[0];return this.data.forEach((n,s)=>{n===we&&(e++,t.push(s+1))}),this._cachedIndexes=t,this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=or(this.dataType,e,this.data[s],t);return new $({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(O.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t: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()),J(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(O.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t: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()),J(this._cachedMin,this.sampleOffset))}get bounds(){return Y(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return J(this.max,-this.min)}atAlignment(e,t){const n=Number(e-this.alignment);if(n<0||n>=this.length){if(t===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,t)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return J(n,this.sampleOffset)}atVariable(e,t){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[e],s=this._cachedIndexes[e+1]-1;else{e<0&&(e=this.length+e);for(let c=0;c<this.data.length;c++)if(this.data[c]===we){if(e===0){s=c;break}n=c+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}}const a=this.data.slice(n,s);return this.dataType.equals(O.STRING)?new TextDecoder().decode(a):Ze(JSON.parse(new TextDecoder().decode(a)))}binarySearch(e){let t=0,n=this.length-1;const s=It(e);for(;t<=n;){const a=Math.floor((t+n)/2),c=s(this.at(a,!0),e);if(c===0)return a;c<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(O.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==k){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(s).valueOf(),c=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,c.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=k}as(e){if(e==="string"){if(!this.dataType.equals(O.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(O.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:{lower:je(this.alignmentBounds.lower),upper:je(this.alignmentBounds.upper)},timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Y(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new dr(this);return this.dataType.equals(O.JSON)?new fr(e):e}return new gr(this)}slice(e,t){return this.sliceSub(!1,e,t)}sub(e,t){return this.sliceSub(!0,e,t)}subIterator(e,t){return new De(this,e,t??this.length)}subAlignmentIterator(e,t){return new De(this,Number(e-this.alignment),Number(t-this.alignment))}subBytes(e,t){if(e>=0&&(t==null||t>=this.byteLength.valueOf()))return this;const n=this.data.subarray(e,t);return new $({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}sliceSub(e,t,n){if(t<=0&&(n==null||n>=this.length))return this;let s;return e?s=this.data.subarray(t,n):s=this.data.slice(t,n),new $({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}reAlign(e){return new $({data:this.buffer,dataType:this.dataType,timeRange:Se.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};u(H,"crudeZ",i.z.object({timeRange:Se.z.optional(),dataType:O.z,alignment:er.optional(),data:i.z.union([cr,lr,i.z.instanceof(ArrayBuffer),i.z.instanceof(Uint8Array)]),glBufferUsage:ar.optional().default("static").optional()})),u(H,"z",H.crudeZ.transform(r=>new H(r)));let hr=H;class De{constructor(e,t,n){u(this,"series"),u(this,"end"),u(this,"index"),this.series=e;const s=Y(0,e.length);this.end=Me(s,n),this.index=Me(s,t)}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 dr{constructor(e){if(u(this,"series"),u(this,"index"),u(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==we;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Pe,Le;class fr{constructor(e){u(this,"wrapped"),u(this,Pe,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:te.decodeString(e.value)}}[(Le=Symbol.iterator,Pe=Symbol.toStringTag,Le)](){return this}}var ke,Ye;class gr{constructor(e){u(this,"series"),u(this,"index"),u(this,ke,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(Ye=Symbol.iterator,ke=Symbol.toStringTag,Ye)](){return this}}const J=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e),je=r=>{const e=r>>32n,t=r&0xffffffffn;return{domain:e,sample:t}};i.z.object({key:i.z.string(),value:i.z.string()});i.z.record(i.z.union([i.z.number(),i.z.string(),i.z.symbol()]),i.z.unknown());const st=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",pr=st(),it=["MacOS","Windows","Linux","Docker"],yr=["macos","windows","linux","docker"],mr={macos:"MacOS",windows:"Windows",linux:"Linux",docker:"Docker"},wr=i.z.enum(it).or(i.z.enum(yr).transform(r=>mr[r]));let ge;const br=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Or=(r={})=>{const{force:e,default:t}=r;return e??ge??(ge=br(),ge??t)},at=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:it,RUNTIME:pr,detect:st,getOS:Or,osZ:wr},Symbol.toStringTag,{value:"Module"}));var Tr=Object.defineProperty,vr=(r,e,t)=>e in r?Tr(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,X=(r,e,t)=>vr(r,typeof e!="symbol"?e+"":e,t);const Sr=(...r)=>r.map(ot).join(""),ot=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Ir=r=>r.endsWith("/")?r.slice(0,-1):r,Nr=(r,e="")=>r===null?"":`?${Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&")}`,be=class Oe{constructor({host:e,port:t,protocol:n="",pathPrefix:s=""}){X(this,"protocol"),X(this,"host"),X(this,"port"),X(this,"path"),this.protocol=n,this.host=e,this.port=t,this.path=ot(s)}replace(e){return new Oe({host:e.host??this.host,port:e.port??this.port,protocol:e.protocol??this.protocol,pathPrefix:e.pathPrefix??this.path})}child(e){return new Oe({...this,pathPrefix:Sr(this.path,e)})}toString(){return Ir(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}};X(be,"UNKNOWN",new be({host:"unknown",port:0}));let Er=be;var Ar=Object.defineProperty,xr=(r,e,t)=>e in r?Ar(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,se=(r,e,t)=>xr(r,typeof e!="symbol"?e+"":e,t);const zr=async r=>await new Promise(e=>setTimeout(e,T.fromMilliseconds(r).milliseconds)),Mr=i.z.object({interval:T.z.optional(),maxRetries:i.z.number().optional(),scale:i.z.number().optional()}),$r=(r={})=>{const e=r.sleepFn||zr,t=r.maxRetries??5,n=r.scale??1;let s=0,a=new T(r.interval??T.milliseconds(1));return async()=>s>=t?!1:(await e(a),a=a.mult(n),s++,!0)},Br=Object.freeze(Object.defineProperty({__proto__:null,breakerConfig:Mr,create:$r},Symbol.toStringTag,{value:"Module"})),F=class extends Number{};se(F,"Absolute",255),se(F,"Default",1),se(F,"z",i.z.union([i.z.instanceof(F),i.z.number().int().min(0).max(255).transform(r=>new F(r)),i.z.instanceof(Number).transform(r=>new F(r))]));i.z.object({name:i.z.string(),key:i.z.string()});const ut=class K extends Error{constructor(){super(K.MESSAGE)}matches(e){return typeof e=="string"?e.includes(K.MESSAGE):e instanceof K||e.message.includes(K.MESSAGE)}};se(ut,"MESSAGE","canceled");let Rr=ut;new Rr;i.z.string().regex(/^\d+\.\d+\.\d+$/);const ce=r=>e=>e!=null&&typeof e=="object"&&"type"in e&&typeof e.type=="string"?e.type.includes(r):e instanceof Error?e.message.includes(r):typeof e!="string"?!1:e.includes(r);class _ extends Error{constructor(){super(...arguments);y(this,"discriminator","FreighterError");y(this,"type","")}}const Ur=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Fe="unknown",qe="nil",Cr="freighter",Ie=i.z.object({type:i.z.string(),data:i.z.string()});class Dr{constructor(){y(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:qe,data:""};if(Ur(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Fe,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===qe)return null;if(e.type===Fe)return new Ge(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Ge(e.data)}}const Ne=new Dr,ct=({encode:r,decode:e})=>Ne.register({encode:r,decode:e}),Pr=r=>Ne.encode(r),ae=r=>Ne.decode(r);class Ge extends _{constructor(){super(...arguments);y(this,"type","unknown")}}const le="freighter.",q=class q extends _{constructor(){super("EOF");y(this,"type",q.TYPE)}};y(q,"TYPE",`${le}eof`),y(q,"matches",ce(q.TYPE));let D=q;const G=class G extends _{constructor(){super("StreamClosed");y(this,"type",G.TYPE)}};y(G,"TYPE",`${le}stream_closed`),y(G,"matches",ce(G.TYPE));let P=G;const W=class W extends _{constructor(t={}){const{message:n="Unreachable",url:s=Er.UNKNOWN}=t;super(n);y(this,"type",W.TYPE);y(this,"url");this.url=s}};y(W,"TYPE",`${le}unreachable`),y(W,"matches",ce(W.TYPE));let L=W;const Lr=r=>{if(!r.type.startsWith(Cr))return null;if(D.matches(r))return{type:D.TYPE,data:"EOF"};if(P.matches(r))return{type:P.TYPE,data:"StreamClosed"};if(L.matches(r))return{type:L.TYPE,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},kr=r=>{if(!r.type.startsWith(le))return null;switch(r.type){case D.TYPE:return new D;case P.TYPE:return new P;case L.TYPE:return new L;default:throw new Error(`Unknown error type: ${r.data}`)}};ct({encode:Lr,decode:kr});class lt{constructor(){y(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const c=this.middleware[n];return n++,await c(a,s)};return await s(e)}}const ht="Content-Type",We=r=>{if(at.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class Yr extends lt{constructor(t,n,s=!1){super();y(this,"endpoint");y(this,"encoder");y(this,"fetch");return this.endpoint=t.replace({protocol:s?"https":"http"}),this.encoder=n,this.fetch=We(this.endpoint.protocol),new Proxy(this,{get:(a,c,d)=>c==="endpoint"?this.endpoint:Reflect.get(a,c,d)})}get headers(){return{[ht]:this.encoder.contentType}}async send(t,n,s,a){n=s==null?void 0:s.parse(n);let c=null;const d=this.endpoint.child(t),f={};f.method="POST",f.body=this.encoder.encode(n??{});const[,p]=await this.executeMiddleware({target:d.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async m=>{const l={...m,params:{}};f.headers={...this.headers,...m.params};let E;try{E=await We(m.protocol)(m.target,f)}catch(R){let x=R;return x.message==="Load failed"&&(x=new L({url:d})),[l,x]}const B=await E.arrayBuffer();if(E!=null&&E.ok)return a!=null&&(c=this.encoder.decode(B,a)),[l,null];try{if(E.status!==400)return[l,new Error(E.statusText)];const R=this.encoder.decode(B,Ie),x=ae(R);return[l,x]}catch(R){return[l,new Error(`[freighter] - failed to decode error: ${E.statusText}: ${R.message}`)]}});return[c,p]}}const jr=(r,e)=>{class t{constructor(s){y(this,"wrapped");this.wrapped=s}use(...s){this.wrapped.use(...s)}async send(s,a,c,d){const f=Br.create(e);do{const[p,m]=await this.wrapped.send(s,a,c,d);if(m==null||!L.matches(m))return[p,m];if(!await f())return[p,m]}while(!0)}}return new t(r)},Fr=async(r,e,t,n,s)=>{const[a,c]=await r.send(e,t,n,s);if(c!=null)throw c;return a},qr=()=>at.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Gr=i.z.object({type:i.z.union([i.z.literal("data"),i.z.literal("close"),i.z.literal("open")]),payload:i.z.unknown().optional(),error:i.z.optional(Ie)});class Wr{constructor(e,t,n,s){y(this,"encoder");y(this,"reqSchema");y(this,"resSchema");y(this,"ws");y(this,"serverClosed");y(this,"sendClosed");y(this,"receiveDataQueue",[]);y(this,"receiveCallbacksQueue",[]);this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}async receiveOpenAck(){const e=await this.receiveMsg();if(e.type!=="open"){if(e.error==null)throw new Error("Message error must be defined");return ae(e.error)}return null}send(e){if(this.serverClosed!=null)return new D;if(this.sendClosed)throw new P;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=ae(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){const e=this.receiveDataQueue.shift();return e??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}addMessage(e){const t=this.receiveCallbacksQueue.shift();t!=null?t.resolve(e):this.receiveDataQueue.push(e)}listenForMessages(){this.ws.onmessage=e=>this.addMessage(this.encoder.decode(e.data,Gr)),this.ws.onclose=e=>this.addMessage({type:"close",error:{type:Xr(e)?D.TYPE:P.TYPE,data:""}})}}const Vr="freighterctx",Zr=1e3,Hr=1001,Jr=[Zr,Hr],Xr=r=>Jr.includes(r.code),oe=class oe extends lt{constructor(t,n,s=!1){super();y(this,"baseUrl");y(this,"encoder");this.baseUrl=t.replace({protocol:s?"wss":"ws"}),this.encoder=n}async stream(t,n,s){const a=qr();let c;const[,d]=await this.executeMiddleware({target:t,protocol:"websocket",params:{},role:"client"},async f=>{const p=a(this.buildURL(t,f)),m={...f,params:{}};p.binaryType=oe.MESSAGE_TYPE;const l=await this.wrapSocket(p,n,s);return l instanceof Error?[m,l]:(c=l,[m,null])});if(d!=null)throw d;return c}buildURL(t,n){const s=Nr({[ht]:this.encoder.contentType,...n.params},Vr);return this.baseUrl.child(t).toString()+s}async wrapSocket(t,n,s){return await new Promise(a=>{t.onopen=()=>{const c=new Wr(t,this.encoder,n,s);c.receiveOpenAck().then(d=>{d!=null?a(d):a(c)}).catch(d=>a(d))},t.onerror=c=>{const d=c;a(new Error(d.message))}})}};y(oe,"MESSAGE_TYPE","arraybuffer");let Te=oe;exports.BaseTypedError=_;exports.EOF=D;exports.HTTPClient=Yr;exports.StreamClosed=P;exports.Unreachable=L;exports.WebSocketClient=Te;exports.decodeError=ae;exports.encodeError=Pr;exports.errorMatcher=ce;exports.errorZ=Ie;exports.registerError=ct;exports.sendRequired=Fr;exports.unaryWithBreaker=jr;
|
package/dist/freighter.js
CHANGED
|
@@ -5,7 +5,7 @@ import { z as i } from "zod";
|
|
|
5
5
|
const dt = (r) => {
|
|
6
6
|
const e = r.replace(/_[a-z]/g, (t) => t[1].toUpperCase());
|
|
7
7
|
return e.length > 1 && e[0] === e[0].toUpperCase() && e[1] === e[1].toUpperCase() || e.length === 0 ? e : e[0].toLowerCase() + e.slice(1);
|
|
8
|
-
},
|
|
8
|
+
}, ze = (r) => {
|
|
9
9
|
const e = (t, n = de) => {
|
|
10
10
|
if (typeof t == "string") return r(t);
|
|
11
11
|
if (Array.isArray(t)) return t.map((c) => e(c, n));
|
|
@@ -22,11 +22,11 @@ const dt = (r) => {
|
|
|
22
22
|
}), s;
|
|
23
23
|
};
|
|
24
24
|
return e;
|
|
25
|
-
},
|
|
25
|
+
}, Ve = ze(dt), gt = (r) => (
|
|
26
26
|
// Don't convert the first character and don't convert a character that is after a
|
|
27
27
|
// non-alphanumeric character
|
|
28
28
|
r.replace(/([a-z0-9])([A-Z])/g, (e, t, n) => `${t}_${n.toLowerCase()}`)
|
|
29
|
-
), pt =
|
|
29
|
+
), pt = ze(gt), de = {
|
|
30
30
|
recursive: !0,
|
|
31
31
|
recursiveInArray: !0,
|
|
32
32
|
keepTypesOnRecursion: [Number, String, Uint8Array]
|
|
@@ -43,7 +43,7 @@ let bt = class {
|
|
|
43
43
|
return this.decodeString(this.decoder.decode(e), t);
|
|
44
44
|
}
|
|
45
45
|
decodeString(e, t) {
|
|
46
|
-
const n = JSON.parse(e), s =
|
|
46
|
+
const n = JSON.parse(e), s = Ve(n);
|
|
47
47
|
return t != null ? t.parse(s) : s;
|
|
48
48
|
}
|
|
49
49
|
encodeString(e) {
|
|
@@ -112,27 +112,53 @@ let bt = class {
|
|
|
112
112
|
const ee = new bt();
|
|
113
113
|
new Ot();
|
|
114
114
|
new Tt();
|
|
115
|
-
const
|
|
115
|
+
const vt = (r) => r != null && typeof r == "object" && "toString" in r, St = (r, e = !1) => {
|
|
116
|
+
const t = vt(r) ? "stringer" : typeof r;
|
|
117
|
+
let n;
|
|
118
|
+
switch (t) {
|
|
119
|
+
case "string":
|
|
120
|
+
n = (s, a) => s.localeCompare(a);
|
|
121
|
+
break;
|
|
122
|
+
case "stringer":
|
|
123
|
+
n = (s, a) => s.toString().localeCompare(a.toString());
|
|
124
|
+
break;
|
|
125
|
+
case "number":
|
|
126
|
+
n = (s, a) => Number(s) - Number(a);
|
|
127
|
+
break;
|
|
128
|
+
case "bigint":
|
|
129
|
+
n = (s, a) => BigInt(s) - BigInt(a) > 0n ? 1 : -1;
|
|
130
|
+
break;
|
|
131
|
+
case "boolean":
|
|
132
|
+
n = (s, a) => Number(s) - Number(a);
|
|
133
|
+
break;
|
|
134
|
+
case "undefined":
|
|
135
|
+
n = () => 0;
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
139
|
+
}
|
|
140
|
+
return e ? It(n) : n;
|
|
141
|
+
}, It = (r) => (e, t) => r(t, e), ae = i.tuple([i.number(), i.number()]);
|
|
116
142
|
i.tuple([i.bigint(), i.bigint()]);
|
|
117
|
-
const Je = i.object({ width: i.number(), height: i.number() }),
|
|
143
|
+
const Je = i.object({ width: i.number(), height: i.number() }), Nt = i.object({
|
|
118
144
|
signedWidth: i.number(),
|
|
119
145
|
signedHeight: i.number()
|
|
120
|
-
}),
|
|
121
|
-
i.enum(
|
|
122
|
-
const
|
|
123
|
-
i.enum(
|
|
124
|
-
const se = i.object({ x: i.number(), y: i.number() }),
|
|
146
|
+
}), Et = ["width", "height"];
|
|
147
|
+
i.enum(Et);
|
|
148
|
+
const At = ["start", "center", "end"], xt = ["signedWidth", "signedHeight"];
|
|
149
|
+
i.enum(xt);
|
|
150
|
+
const se = i.object({ x: i.number(), y: i.number() }), Mt = i.object({ clientX: i.number(), clientY: i.number() }), $t = ["x", "y"], He = i.enum($t), Xe = ["top", "right", "bottom", "left"];
|
|
125
151
|
i.enum(Xe);
|
|
126
|
-
const
|
|
127
|
-
i.enum(
|
|
128
|
-
const
|
|
129
|
-
i.enum(
|
|
130
|
-
const
|
|
131
|
-
i.union([
|
|
132
|
-
i.union([
|
|
152
|
+
const Bt = ["left", "right"], Ke = i.enum(Bt), Rt = ["top", "bottom"], Qe = i.enum(Rt), _e = ["center"], Ee = i.enum(_e), Ut = [...Xe, ..._e], et = i.enum(Ut);
|
|
153
|
+
i.enum(At);
|
|
154
|
+
const Ct = ["first", "last"];
|
|
155
|
+
i.enum(Ct);
|
|
156
|
+
const Dt = i.object({ lower: i.number(), upper: i.number() }), Pt = i.object({ lower: i.bigint(), upper: i.bigint() });
|
|
157
|
+
i.union([Dt, ae]);
|
|
158
|
+
i.union([Pt, ae]);
|
|
133
159
|
i.union([He, et]);
|
|
134
160
|
i.union([He, et, i.instanceof(String)]);
|
|
135
|
-
const
|
|
161
|
+
const Lt = (r) => typeof r == "bigint" || r instanceof BigInt, F = (r, e) => Lt(r) ? r.valueOf() * BigInt(e.valueOf()) : r.valueOf() * Number(e.valueOf()), j = (r, e) => {
|
|
136
162
|
const t = {};
|
|
137
163
|
if (typeof r == "number" || typeof r == "bigint")
|
|
138
164
|
e != null ? (t.lower = r, t.upper = e) : (t.lower = typeof r == "bigint" ? 0n : 0, t.upper = r);
|
|
@@ -149,14 +175,14 @@ i.object({
|
|
|
149
175
|
x: Ke.or(Ee),
|
|
150
176
|
y: Qe.or(Ee)
|
|
151
177
|
});
|
|
152
|
-
const
|
|
178
|
+
const Yt = i.object({ x: Ke, y: Qe }), kt = Object.freeze({ x: "left", y: "top" }), jt = (r, e) => r.x === e.x && r.y === e.y, Me = i.union([
|
|
153
179
|
i.number(),
|
|
154
180
|
se,
|
|
155
181
|
ae,
|
|
156
182
|
Je,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
]),
|
|
183
|
+
Nt,
|
|
184
|
+
Mt
|
|
185
|
+
]), Ft = (r, e) => {
|
|
160
186
|
if (typeof r == "string") {
|
|
161
187
|
if (e === void 0) throw new Error("The y coordinate must be given.");
|
|
162
188
|
return r === "x" ? { x: e, y: 0 } : { x: 0, y: e };
|
|
@@ -178,13 +204,13 @@ i.object({
|
|
|
178
204
|
i.object({
|
|
179
205
|
one: se,
|
|
180
206
|
two: se,
|
|
181
|
-
root:
|
|
207
|
+
root: Yt
|
|
182
208
|
});
|
|
183
209
|
const Oe = (r, e, t = 0, n = 0, s) => {
|
|
184
210
|
const a = {
|
|
185
211
|
one: { ...$e },
|
|
186
212
|
two: { ...$e },
|
|
187
|
-
root: s ??
|
|
213
|
+
root: s ?? kt
|
|
188
214
|
};
|
|
189
215
|
if (typeof r == "number") {
|
|
190
216
|
if (typeof e != "number")
|
|
@@ -204,32 +230,33 @@ const Oe = (r, e, t = 0, n = 0, s) => {
|
|
|
204
230
|
}, he = (r) => {
|
|
205
231
|
const e = Oe(r);
|
|
206
232
|
return { lower: e.one.y, upper: e.two.y };
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
|
|
233
|
+
}, Gt = (r) => typeof r != "object" || r == null ? !1 : "one" in r && "two" in r && "root" in r, qt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
|
|
234
|
+
i.union([Je, qt, se, ae]);
|
|
235
|
+
var Wt = Object.defineProperty, zt = (r, e, t) => e in r ? Wt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, D = (r, e, t) => zt(r, typeof e != "symbol" ? e + "" : e, t);
|
|
236
|
+
const Vt = (r, e, t) => e !== void 0 && r < e ? e : t !== void 0 && r > t ? t : r;
|
|
210
237
|
i.object({ offset: Me, scale: Me });
|
|
211
238
|
i.object({ offset: i.number(), scale: i.number() });
|
|
212
|
-
const
|
|
239
|
+
const Zt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
213
240
|
e,
|
|
214
241
|
s ? n - r : n + r
|
|
215
|
-
],
|
|
242
|
+
], Jt = (r) => (e, t, n, s) => [
|
|
216
243
|
e,
|
|
217
244
|
s ? n / r : n * r
|
|
218
|
-
],
|
|
245
|
+
], Ht = (r) => (e, t, n) => {
|
|
219
246
|
if (e === null) return [r, n];
|
|
220
247
|
const { lower: s, upper: a } = e, { lower: c, upper: f } = r, d = a - s, p = f - c;
|
|
221
248
|
if (t === "dimension") return [r, n * (p / d)];
|
|
222
249
|
const m = (n - s) * (p / d) + c;
|
|
223
250
|
return [r, m];
|
|
224
|
-
},
|
|
251
|
+
}, Xt = (r) => (e, t, n) => [r, n], Kt = () => (r, e, t) => {
|
|
225
252
|
if (r === null) throw new Error("cannot invert without bounds");
|
|
226
253
|
if (e === "dimension") return [r, t];
|
|
227
254
|
const { lower: n, upper: s } = r;
|
|
228
255
|
return [r, s - (t - n)];
|
|
229
|
-
},
|
|
256
|
+
}, Qt = (r) => (e, t, n) => {
|
|
230
257
|
const { lower: s, upper: a } = r;
|
|
231
|
-
return n =
|
|
232
|
-
}, ge = class
|
|
258
|
+
return n = Vt(n, s, a), [e, n];
|
|
259
|
+
}, ge = class V {
|
|
233
260
|
constructor() {
|
|
234
261
|
D(this, "ops", []), D(this, "currBounds", null), D(this, "currType", null), D(this, "reversed", !1), this.ops = [];
|
|
235
262
|
}
|
|
@@ -239,7 +266,7 @@ const qt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
239
266
|
* @param value - The amount to translate by.
|
|
240
267
|
*/
|
|
241
268
|
static translate(e) {
|
|
242
|
-
return new
|
|
269
|
+
return new V().translate(e);
|
|
243
270
|
}
|
|
244
271
|
/**
|
|
245
272
|
* @returns a new scale with a magnification as its first operation. Any number provided
|
|
@@ -247,10 +274,10 @@ const qt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
247
274
|
* @param value - The amount to translate by.
|
|
248
275
|
*/
|
|
249
276
|
static magnify(e) {
|
|
250
|
-
return new
|
|
277
|
+
return new V().magnify(e);
|
|
251
278
|
}
|
|
252
279
|
static scale(e, t) {
|
|
253
|
-
return new
|
|
280
|
+
return new V().scale(e, t);
|
|
254
281
|
}
|
|
255
282
|
/**
|
|
256
283
|
* @returns a copy of the scale with a translation as its next operation. Any
|
|
@@ -259,7 +286,7 @@ const qt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
259
286
|
* @param value - The amount to translate by.
|
|
260
287
|
*/
|
|
261
288
|
translate(e) {
|
|
262
|
-
const t = this.new(), n =
|
|
289
|
+
const t = this.new(), n = Zt(e);
|
|
263
290
|
return n.type = "translate", t.ops.push(n), t;
|
|
264
291
|
}
|
|
265
292
|
/**
|
|
@@ -269,23 +296,23 @@ const qt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
269
296
|
* @param value - The amount to magnify by.
|
|
270
297
|
*/
|
|
271
298
|
magnify(e) {
|
|
272
|
-
const t = this.new(), n =
|
|
299
|
+
const t = this.new(), n = Jt(e);
|
|
273
300
|
return n.type = "magnify", t.ops.push(n), t;
|
|
274
301
|
}
|
|
275
302
|
scale(e, t) {
|
|
276
|
-
const n = j(e, t), s = this.new(), a =
|
|
303
|
+
const n = j(e, t), s = this.new(), a = Ht(n);
|
|
277
304
|
return a.type = "scale", s.ops.push(a), s;
|
|
278
305
|
}
|
|
279
306
|
clamp(e, t) {
|
|
280
|
-
const n = j(e, t), s = this.new(), a =
|
|
307
|
+
const n = j(e, t), s = this.new(), a = Qt(n);
|
|
281
308
|
return a.type = "clamp", s.ops.push(a), s;
|
|
282
309
|
}
|
|
283
310
|
reBound(e, t) {
|
|
284
|
-
const n = j(e, t), s = this.new(), a =
|
|
311
|
+
const n = j(e, t), s = this.new(), a = Xt(n);
|
|
285
312
|
return a.type = "re-bound", s.ops.push(a), s;
|
|
286
313
|
}
|
|
287
314
|
invert() {
|
|
288
|
-
const e =
|
|
315
|
+
const e = Kt();
|
|
289
316
|
e.type = "invert";
|
|
290
317
|
const t = this.new();
|
|
291
318
|
return t.ops.push(e), t;
|
|
@@ -297,7 +324,7 @@ const qt = (r) => (e, t, n, s) => t === "dimension" ? [e, n] : [
|
|
|
297
324
|
return this.exec("dimension", e);
|
|
298
325
|
}
|
|
299
326
|
new() {
|
|
300
|
-
const e = new
|
|
327
|
+
const e = new V();
|
|
301
328
|
return e.ops = this.ops.slice(), e.reversed = this.reversed, e;
|
|
302
329
|
}
|
|
303
330
|
exec(e, t) {
|
|
@@ -352,7 +379,7 @@ const Re = class C {
|
|
|
352
379
|
return new C().reBound(e);
|
|
353
380
|
}
|
|
354
381
|
translate(e, t) {
|
|
355
|
-
const n =
|
|
382
|
+
const n = Ft(e, t), s = this.copy();
|
|
356
383
|
return s.x = this.x.translate(n.x), s.y = this.y.translate(n.y), s;
|
|
357
384
|
}
|
|
358
385
|
translateX(e) {
|
|
@@ -369,9 +396,9 @@ const Re = class C {
|
|
|
369
396
|
}
|
|
370
397
|
scale(e) {
|
|
371
398
|
const t = this.copy();
|
|
372
|
-
if (
|
|
399
|
+
if (Gt(e)) {
|
|
373
400
|
const n = this.currRoot;
|
|
374
|
-
return t.currRoot = e.root, n != null && !
|
|
401
|
+
return t.currRoot = e.root, n != null && !jt(n, e.root) && (n.x !== e.root.x && (t.x = t.x.invert()), n.y !== e.root.y && (t.y = t.y.invert())), t.x = t.x.scale(le(e)), t.y = t.y.scale(he(e)), t;
|
|
375
402
|
}
|
|
376
403
|
return t.x = t.x.scale(e.width), t.y = t.y.scale(e.height), t;
|
|
377
404
|
}
|
|
@@ -414,38 +441,10 @@ const Re = class C {
|
|
|
414
441
|
}
|
|
415
442
|
};
|
|
416
443
|
D(Re, "IDENTITY", new Re());
|
|
417
|
-
const Ht = (r) => r != null && typeof r == "object" && "toString" in r, Xt = (r, e = !1) => {
|
|
418
|
-
const t = Ht(r) ? "stringer" : typeof r;
|
|
419
|
-
let n;
|
|
420
|
-
switch (t) {
|
|
421
|
-
case "string":
|
|
422
|
-
n = (s, a) => s.localeCompare(a);
|
|
423
|
-
break;
|
|
424
|
-
case "stringer":
|
|
425
|
-
n = (s, a) => s.toString().localeCompare(a.toString());
|
|
426
|
-
break;
|
|
427
|
-
case "number":
|
|
428
|
-
n = (s, a) => Number(s) - Number(a);
|
|
429
|
-
break;
|
|
430
|
-
case "bigint":
|
|
431
|
-
n = (s, a) => BigInt(s) - BigInt(a) > 0n ? 1 : -1;
|
|
432
|
-
break;
|
|
433
|
-
case "boolean":
|
|
434
|
-
n = (s, a) => Number(s) - Number(a);
|
|
435
|
-
break;
|
|
436
|
-
case "undefined":
|
|
437
|
-
n = () => 0;
|
|
438
|
-
break;
|
|
439
|
-
default:
|
|
440
|
-
return console.warn(`sortFunc: unknown type ${t}`), () => -1;
|
|
441
|
-
}
|
|
442
|
-
return e ? Kt(n) : n;
|
|
443
|
-
}, Kt = (r) => (e, t) => r(t, e), Qt = i.object({ signedWidth: i.number(), signedHeight: i.number() });
|
|
444
|
-
i.union([Je, Qt, se, ae]);
|
|
445
444
|
const _t = i.bigint().or(i.string().transform(BigInt));
|
|
446
445
|
var er = Object.defineProperty, tr = (r, e, t) => e in r ? er(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e, t) => tr(r, typeof e != "symbol" ? e + "" : e, t);
|
|
447
446
|
let rr = (r, e = 21) => (t = e) => {
|
|
448
|
-
let n = "", s = t;
|
|
447
|
+
let n = "", s = t | 0;
|
|
449
448
|
for (; s--; )
|
|
450
449
|
n += r[Math.random() * r.length | 0];
|
|
451
450
|
return n;
|
|
@@ -1845,7 +1844,7 @@ const rt = (r) => {
|
|
|
1845
1844
|
}
|
|
1846
1845
|
}
|
|
1847
1846
|
const a = this.data.slice(n, s);
|
|
1848
|
-
return this.dataType.equals(O.STRING) ? new TextDecoder().decode(a) :
|
|
1847
|
+
return this.dataType.equals(O.STRING) ? new TextDecoder().decode(a) : Ve(
|
|
1849
1848
|
JSON.parse(new TextDecoder().decode(a))
|
|
1850
1849
|
);
|
|
1851
1850
|
}
|
|
@@ -1856,7 +1855,7 @@ const rt = (r) => {
|
|
|
1856
1855
|
*/
|
|
1857
1856
|
binarySearch(e) {
|
|
1858
1857
|
let t = 0, n = this.length - 1;
|
|
1859
|
-
const s =
|
|
1858
|
+
const s = St(e);
|
|
1860
1859
|
for (; t <= n; ) {
|
|
1861
1860
|
const a = Math.floor((t + n) / 2), c = s(this.at(a, !0), e);
|
|
1862
1861
|
if (c === 0) return a;
|
|
@@ -2082,27 +2081,34 @@ i.record(
|
|
|
2082
2081
|
i.union([i.number(), i.string(), i.symbol()]),
|
|
2083
2082
|
i.unknown()
|
|
2084
2083
|
);
|
|
2085
|
-
const nt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", gr = nt(), st = ["MacOS", "Windows", "Linux", "Docker"], pr =
|
|
2084
|
+
const nt = () => typeof process < "u" && process.versions != null && process.versions.node != null ? "node" : typeof window > "u" || window.document === void 0 ? "webworker" : "browser", gr = nt(), st = ["MacOS", "Windows", "Linux", "Docker"], pr = ["macos", "windows", "linux", "docker"], yr = {
|
|
2085
|
+
macos: "MacOS",
|
|
2086
|
+
windows: "Windows",
|
|
2087
|
+
linux: "Linux",
|
|
2088
|
+
docker: "Docker"
|
|
2089
|
+
}, mr = i.enum(st).or(
|
|
2090
|
+
i.enum(pr).transform((r) => yr[r])
|
|
2091
|
+
);
|
|
2086
2092
|
let fe;
|
|
2087
|
-
const
|
|
2093
|
+
const wr = () => {
|
|
2088
2094
|
if (typeof window > "u") return;
|
|
2089
2095
|
const r = window.navigator.userAgent.toLowerCase();
|
|
2090
2096
|
if (r.includes("mac")) return "MacOS";
|
|
2091
2097
|
if (r.includes("win")) return "Windows";
|
|
2092
2098
|
if (r.includes("linux")) return "Linux";
|
|
2093
|
-
},
|
|
2099
|
+
}, br = (r = {}) => {
|
|
2094
2100
|
const { force: e, default: t } = r;
|
|
2095
|
-
return e ?? fe ?? (fe =
|
|
2101
|
+
return e ?? fe ?? (fe = wr(), fe ?? t);
|
|
2096
2102
|
}, it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2097
2103
|
__proto__: null,
|
|
2098
2104
|
OPERATING_SYSTEMS: st,
|
|
2099
2105
|
RUNTIME: gr,
|
|
2100
2106
|
detect: nt,
|
|
2101
|
-
getOS:
|
|
2102
|
-
osZ:
|
|
2107
|
+
getOS: br,
|
|
2108
|
+
osZ: mr
|
|
2103
2109
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
2104
|
-
var
|
|
2105
|
-
const
|
|
2110
|
+
var Or = Object.defineProperty, Tr = (r, e, t) => e in r ? Or(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, X = (r, e, t) => Tr(r, typeof e != "symbol" ? e + "" : e, t);
|
|
2111
|
+
const vr = (...r) => r.map(at).join(""), at = (r) => (r.endsWith("/") || (r += "/"), r.startsWith("/") && (r = r.slice(1)), r), Sr = (r) => r.endsWith("/") ? r.slice(0, -1) : r, Ir = (r, e = "") => r === null ? "" : `?${Object.entries(r).filter(([, t]) => t == null ? !1 : Array.isArray(t) ? t.length > 0 : !0).map(([t, n]) => `${e}${t}=${n}`).join("&")}`, me = class we {
|
|
2106
2112
|
/**
|
|
2107
2113
|
* @param host - The hostname or IP address of the server.
|
|
2108
2114
|
* @param port - The port number of the server.
|
|
@@ -2133,20 +2139,34 @@ const Or = (...r) => r.map(at).join(""), at = (r) => (r.endsWith("/") || (r += "
|
|
|
2133
2139
|
child(e) {
|
|
2134
2140
|
return new we({
|
|
2135
2141
|
...this,
|
|
2136
|
-
pathPrefix:
|
|
2142
|
+
pathPrefix: vr(this.path, e)
|
|
2137
2143
|
});
|
|
2138
2144
|
}
|
|
2139
2145
|
/** @returns a string representation of the url */
|
|
2140
2146
|
toString() {
|
|
2141
|
-
return
|
|
2147
|
+
return Sr(
|
|
2142
2148
|
`${this.protocol}://${this.host}:${this.port}/${this.path}`
|
|
2143
2149
|
);
|
|
2144
2150
|
}
|
|
2145
2151
|
};
|
|
2146
2152
|
X(me, "UNKNOWN", new me({ host: "unknown", port: 0 }));
|
|
2147
|
-
let
|
|
2148
|
-
var
|
|
2149
|
-
const
|
|
2153
|
+
let Nr = me;
|
|
2154
|
+
var Er = Object.defineProperty, Ar = (r, e, t) => e in r ? Er(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ne = (r, e, t) => Ar(r, typeof e != "symbol" ? e + "" : e, t);
|
|
2155
|
+
const xr = async (r) => await new Promise(
|
|
2156
|
+
(e) => setTimeout(e, T.fromMilliseconds(r).milliseconds)
|
|
2157
|
+
), Mr = i.object({
|
|
2158
|
+
interval: T.z.optional(),
|
|
2159
|
+
maxRetries: i.number().optional(),
|
|
2160
|
+
scale: i.number().optional()
|
|
2161
|
+
}), $r = (r = {}) => {
|
|
2162
|
+
const e = r.sleepFn || xr, t = r.maxRetries ?? 5, n = r.scale ?? 1;
|
|
2163
|
+
let s = 0, a = new T(r.interval ?? T.milliseconds(1));
|
|
2164
|
+
return async () => s >= t ? !1 : (await e(a), a = a.mult(n), s++, !0);
|
|
2165
|
+
}, Br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2166
|
+
__proto__: null,
|
|
2167
|
+
breakerConfig: Mr,
|
|
2168
|
+
create: $r
|
|
2169
|
+
}, Symbol.toStringTag, { value: "Module" })), G = class extends Number {
|
|
2150
2170
|
};
|
|
2151
2171
|
ne(G, "Absolute", 255), ne(G, "Default", 1), ne(G, "z", i.union([
|
|
2152
2172
|
i.instanceof(G),
|
|
@@ -2167,24 +2187,10 @@ const ot = class K extends Error {
|
|
|
2167
2187
|
}
|
|
2168
2188
|
};
|
|
2169
2189
|
ne(ot, "MESSAGE", "canceled");
|
|
2170
|
-
let
|
|
2171
|
-
new
|
|
2190
|
+
let Rr = ot;
|
|
2191
|
+
new Rr();
|
|
2172
2192
|
i.string().regex(/^\d+\.\d+\.\d+$/);
|
|
2173
|
-
const
|
|
2174
|
-
(e) => setTimeout(e, T.fromMilliseconds(r).milliseconds)
|
|
2175
|
-
), xr = i.object({
|
|
2176
|
-
interval: T.z.optional(),
|
|
2177
|
-
maxRetries: i.number().optional(),
|
|
2178
|
-
scale: i.number().optional()
|
|
2179
|
-
}), Mr = (r = {}) => {
|
|
2180
|
-
const e = r.sleepFn || Ar, t = r.maxRetries ?? 5, n = r.scale ?? 1;
|
|
2181
|
-
let s = 0, a = new T(r.interval ?? T.milliseconds(1));
|
|
2182
|
-
return async () => s >= t ? !1 : (await e(a), a = a.mult(n), s++, !0);
|
|
2183
|
-
}, $r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2184
|
-
__proto__: null,
|
|
2185
|
-
breakerConfig: xr,
|
|
2186
|
-
create: Mr
|
|
2187
|
-
}, Symbol.toStringTag, { value: "Module" })), ve = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
|
|
2193
|
+
const ve = (r) => (e) => e != null && typeof e == "object" && "type" in e && typeof e.type == "string" ? e.type.includes(r) : e instanceof Error ? e.message.includes(r) : typeof e != "string" ? !1 : e.includes(r);
|
|
2188
2194
|
class oe extends Error {
|
|
2189
2195
|
constructor() {
|
|
2190
2196
|
super(...arguments);
|
|
@@ -2192,7 +2198,7 @@ class oe extends Error {
|
|
|
2192
2198
|
y(this, "type", "");
|
|
2193
2199
|
}
|
|
2194
2200
|
}
|
|
2195
|
-
const
|
|
2201
|
+
const Ur = (r) => {
|
|
2196
2202
|
if (r == null || typeof r != "object") return !1;
|
|
2197
2203
|
const e = r;
|
|
2198
2204
|
if (e.discriminator !== "FreighterError") return !1;
|
|
@@ -2201,8 +2207,8 @@ const Br = (r) => {
|
|
|
2201
2207
|
`Freighter error is missing its type property: ${JSON.stringify(e)}`
|
|
2202
2208
|
);
|
|
2203
2209
|
return !0;
|
|
2204
|
-
}, je = "unknown", Fe = "nil",
|
|
2205
|
-
class
|
|
2210
|
+
}, je = "unknown", Fe = "nil", Cr = "freighter", ut = i.object({ type: i.string(), data: i.string() });
|
|
2211
|
+
class Dr {
|
|
2206
2212
|
constructor() {
|
|
2207
2213
|
y(this, "providers", []);
|
|
2208
2214
|
}
|
|
@@ -2211,7 +2217,7 @@ class Ur {
|
|
|
2211
2217
|
}
|
|
2212
2218
|
encode(e) {
|
|
2213
2219
|
if (e == null) return { type: Fe, data: "" };
|
|
2214
|
-
if (
|
|
2220
|
+
if (Ur(e))
|
|
2215
2221
|
for (const t of this.providers) {
|
|
2216
2222
|
const n = t.encode(e);
|
|
2217
2223
|
if (n != null) return n;
|
|
@@ -2228,10 +2234,10 @@ class Ur {
|
|
|
2228
2234
|
return new Ge(e.data);
|
|
2229
2235
|
}
|
|
2230
2236
|
}
|
|
2231
|
-
const Se = new
|
|
2237
|
+
const Se = new Dr(), Pr = ({
|
|
2232
2238
|
encode: r,
|
|
2233
2239
|
decode: e
|
|
2234
|
-
}) => Se.register({ encode: r, decode: e }),
|
|
2240
|
+
}) => Se.register({ encode: r, decode: e }), en = (r) => Se.encode(r), be = (r) => Se.decode(r);
|
|
2235
2241
|
class Ge extends oe {
|
|
2236
2242
|
constructor() {
|
|
2237
2243
|
super(...arguments);
|
|
@@ -2254,26 +2260,26 @@ const W = class W extends oe {
|
|
|
2254
2260
|
};
|
|
2255
2261
|
y(W, "TYPE", `${ue}stream_closed`), y(W, "matches", ve(W.TYPE));
|
|
2256
2262
|
let Y = W;
|
|
2257
|
-
const
|
|
2263
|
+
const z = class z extends oe {
|
|
2258
2264
|
constructor(t = {}) {
|
|
2259
|
-
const { message: n = "Unreachable", url: s =
|
|
2265
|
+
const { message: n = "Unreachable", url: s = Nr.UNKNOWN } = t;
|
|
2260
2266
|
super(n);
|
|
2261
|
-
y(this, "type",
|
|
2267
|
+
y(this, "type", z.TYPE);
|
|
2262
2268
|
y(this, "url");
|
|
2263
2269
|
this.url = s;
|
|
2264
2270
|
}
|
|
2265
2271
|
};
|
|
2266
|
-
y(
|
|
2267
|
-
let k =
|
|
2268
|
-
const
|
|
2269
|
-
if (!r.type.startsWith(
|
|
2272
|
+
y(z, "TYPE", `${ue}unreachable`), y(z, "matches", ve(z.TYPE));
|
|
2273
|
+
let k = z;
|
|
2274
|
+
const Lr = (r) => {
|
|
2275
|
+
if (!r.type.startsWith(Cr)) return null;
|
|
2270
2276
|
if (L.matches(r)) return { type: L.TYPE, data: "EOF" };
|
|
2271
2277
|
if (Y.matches(r))
|
|
2272
2278
|
return { type: Y.TYPE, data: "StreamClosed" };
|
|
2273
2279
|
if (k.matches(r))
|
|
2274
2280
|
return { type: k.TYPE, data: "Unreachable" };
|
|
2275
2281
|
throw new Error(`Unknown error type: ${r.type}: ${r.message}`);
|
|
2276
|
-
},
|
|
2282
|
+
}, Yr = (r) => {
|
|
2277
2283
|
if (!r.type.startsWith(ue)) return null;
|
|
2278
2284
|
switch (r.type) {
|
|
2279
2285
|
case L.TYPE:
|
|
@@ -2286,9 +2292,9 @@ const Dr = (r) => {
|
|
|
2286
2292
|
throw new Error(`Unknown error type: ${r.data}`);
|
|
2287
2293
|
}
|
|
2288
2294
|
};
|
|
2289
|
-
|
|
2290
|
-
encode:
|
|
2291
|
-
decode:
|
|
2295
|
+
Pr({
|
|
2296
|
+
encode: Lr,
|
|
2297
|
+
decode: Yr
|
|
2292
2298
|
});
|
|
2293
2299
|
class ct {
|
|
2294
2300
|
constructor() {
|
|
@@ -2324,7 +2330,7 @@ const lt = "Content-Type", qe = (r) => {
|
|
|
2324
2330
|
const t = require("https"), n = new t.Agent({ rejectUnauthorized: !1 });
|
|
2325
2331
|
return async (s, a) => await e(s, { ...a, agent: n });
|
|
2326
2332
|
};
|
|
2327
|
-
class
|
|
2333
|
+
class tn extends ct {
|
|
2328
2334
|
constructor(t, n, s = !1) {
|
|
2329
2335
|
super();
|
|
2330
2336
|
y(this, "endpoint");
|
|
@@ -2384,7 +2390,7 @@ class _r extends ct {
|
|
|
2384
2390
|
return [c, p];
|
|
2385
2391
|
}
|
|
2386
2392
|
}
|
|
2387
|
-
const
|
|
2393
|
+
const rn = (r, e) => {
|
|
2388
2394
|
class t {
|
|
2389
2395
|
constructor(s) {
|
|
2390
2396
|
y(this, "wrapped");
|
|
@@ -2394,7 +2400,7 @@ const en = (r, e) => {
|
|
|
2394
2400
|
this.wrapped.use(...s);
|
|
2395
2401
|
}
|
|
2396
2402
|
async send(s, a, c, f) {
|
|
2397
|
-
const d =
|
|
2403
|
+
const d = Br.create(e);
|
|
2398
2404
|
do {
|
|
2399
2405
|
const [p, m] = await this.wrapped.send(s, a, c, f);
|
|
2400
2406
|
if (m == null || !k.matches(m)) return [p, m];
|
|
@@ -2403,16 +2409,16 @@ const en = (r, e) => {
|
|
|
2403
2409
|
}
|
|
2404
2410
|
}
|
|
2405
2411
|
return new t(r);
|
|
2406
|
-
},
|
|
2412
|
+
}, nn = async (r, e, t, n, s) => {
|
|
2407
2413
|
const [a, c] = await r.send(e, t, n, s);
|
|
2408
2414
|
if (c != null) throw c;
|
|
2409
2415
|
return a;
|
|
2410
|
-
},
|
|
2416
|
+
}, kr = () => it.RUNTIME !== "node" ? (r) => new WebSocket(r) : (r) => new (require("ws")).WebSocket(r, { rejectUnauthorized: !1 }), jr = i.object({
|
|
2411
2417
|
type: i.union([i.literal("data"), i.literal("close"), i.literal("open")]),
|
|
2412
2418
|
payload: i.unknown().optional(),
|
|
2413
2419
|
error: i.optional(ut)
|
|
2414
2420
|
});
|
|
2415
|
-
class
|
|
2421
|
+
class Fr {
|
|
2416
2422
|
constructor(e, t, n, s) {
|
|
2417
2423
|
y(this, "encoder");
|
|
2418
2424
|
y(this, "reqSchema");
|
|
@@ -2473,13 +2479,13 @@ class kr {
|
|
|
2473
2479
|
t != null ? t.resolve(e) : this.receiveDataQueue.push(e);
|
|
2474
2480
|
}
|
|
2475
2481
|
listenForMessages() {
|
|
2476
|
-
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data,
|
|
2482
|
+
this.ws.onmessage = (e) => this.addMessage(this.encoder.decode(e.data, jr)), this.ws.onclose = (e) => this.addMessage({
|
|
2477
2483
|
type: "close",
|
|
2478
|
-
error: { type:
|
|
2484
|
+
error: { type: Vr(e) ? L.TYPE : Y.TYPE, data: "" }
|
|
2479
2485
|
});
|
|
2480
2486
|
}
|
|
2481
2487
|
}
|
|
2482
|
-
const
|
|
2488
|
+
const Gr = "freighterctx", qr = 1e3, Wr = 1001, zr = [qr, Wr], Vr = (r) => zr.includes(r.code), ie = class ie extends ct {
|
|
2483
2489
|
/**
|
|
2484
2490
|
* @param encoder - The encoder to use for encoding messages and decoding
|
|
2485
2491
|
* responses.
|
|
@@ -2493,7 +2499,7 @@ const jr = "freighterctx", Fr = 1e3, Gr = 1001, qr = [Fr, Gr], Wr = (r) => qr.in
|
|
|
2493
2499
|
}
|
|
2494
2500
|
/** Implements the StreamClient interface. */
|
|
2495
2501
|
async stream(t, n, s) {
|
|
2496
|
-
const a =
|
|
2502
|
+
const a = kr();
|
|
2497
2503
|
let c;
|
|
2498
2504
|
const [, f] = await this.executeMiddleware(
|
|
2499
2505
|
{ target: t, protocol: "websocket", params: {}, role: "client" },
|
|
@@ -2508,19 +2514,19 @@ const jr = "freighterctx", Fr = 1e3, Gr = 1001, qr = [Fr, Gr], Wr = (r) => qr.in
|
|
|
2508
2514
|
return c;
|
|
2509
2515
|
}
|
|
2510
2516
|
buildURL(t, n) {
|
|
2511
|
-
const s =
|
|
2517
|
+
const s = Ir(
|
|
2512
2518
|
{
|
|
2513
2519
|
[lt]: this.encoder.contentType,
|
|
2514
2520
|
...n.params
|
|
2515
2521
|
},
|
|
2516
|
-
|
|
2522
|
+
Gr
|
|
2517
2523
|
);
|
|
2518
2524
|
return this.baseUrl.child(t).toString() + s;
|
|
2519
2525
|
}
|
|
2520
2526
|
async wrapSocket(t, n, s) {
|
|
2521
2527
|
return await new Promise((a) => {
|
|
2522
2528
|
t.onopen = () => {
|
|
2523
|
-
const c = new
|
|
2529
|
+
const c = new Fr(t, this.encoder, n, s);
|
|
2524
2530
|
c.receiveOpenAck().then((f) => {
|
|
2525
2531
|
f != null ? a(f) : a(c);
|
|
2526
2532
|
}).catch((f) => a(f));
|
|
@@ -2536,15 +2542,15 @@ let We = ie;
|
|
|
2536
2542
|
export {
|
|
2537
2543
|
oe as BaseTypedError,
|
|
2538
2544
|
L as EOF,
|
|
2539
|
-
|
|
2545
|
+
tn as HTTPClient,
|
|
2540
2546
|
Y as StreamClosed,
|
|
2541
2547
|
k as Unreachable,
|
|
2542
2548
|
We as WebSocketClient,
|
|
2543
2549
|
be as decodeError,
|
|
2544
|
-
|
|
2550
|
+
en as encodeError,
|
|
2545
2551
|
ve as errorMatcher,
|
|
2546
2552
|
ut as errorZ,
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2553
|
+
Pr as registerError,
|
|
2554
|
+
nn as sendRequired,
|
|
2555
|
+
rn as unaryWithBreaker
|
|
2550
2556
|
};
|
package/dist/unary.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { breaker } from '@synnaxlabs/x';
|
|
1
2
|
import { z } from 'zod';
|
|
2
3
|
import { Transport } from './transport';
|
|
3
|
-
import { breaker } from '@synnaxlabs/x';
|
|
4
4
|
/**
|
|
5
5
|
* An interface for an entity that implements a simple request-response
|
|
6
6
|
* transport between two entities.
|
package/dist/unary.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../src/unary.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"unary.d.ts","sourceRoot":"","sources":["../src/unary.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC5C;;;;;OAKG;IACH,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC,UAAU,GAAG,EAAE,EAC1D,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAC/B,SAAS,EAAE,EAAE,EACb,SAAS,EAAE,EAAE,KACV,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;CACpD;AAED,eAAO,MAAM,gBAAgB,SACrB,WAAW,OACZ,OAAO,CAAC,MAAM,KAClB,WA2BF,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,EAAE,SAAS,CAAC,CAAC,UAAU,EACvB,EAAE,SAAS,CAAC,CAAC,UAAU,eAEf,WAAW,UACX,MAAM,OACT,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,aACpB,EAAE,aACF,EAAE,KACZ,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAItB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synnaxlabs/freighter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "a modular transport abstraction",
|
|
6
6
|
"repository": "https://github.com/synnaxlabs/synnax/tree/main/freighter/ts",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"node-fetch": "^2.7.0",
|
|
18
18
|
"ws": "^8.18.0",
|
|
19
19
|
"zod": "^3.24.1",
|
|
20
|
-
"@synnaxlabs/alamos": "0.
|
|
21
|
-
"@synnaxlabs/x": "0.
|
|
20
|
+
"@synnaxlabs/alamos": "0.37.0",
|
|
21
|
+
"@synnaxlabs/x": "0.37.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@types/node": "^22.
|
|
24
|
+
"@types/node": "^22.10.2",
|
|
25
25
|
"@vitest/coverage-v8": "^2.1.8",
|
|
26
|
-
"eslint": "^9.
|
|
27
|
-
"typescript": "^5.
|
|
26
|
+
"eslint": "^9.17.0",
|
|
27
|
+
"typescript": "^5.7.2",
|
|
28
28
|
"vite": "^6.0.3",
|
|
29
29
|
"vitest": "^2.1.8",
|
|
30
30
|
"@synnaxlabs/tsconfig": "0.0.2",
|
package/src/unary.ts
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
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 { breaker } from "@synnaxlabs/x";
|
|
10
11
|
import { type z } from "zod";
|
|
11
12
|
|
|
12
|
-
import { type Transport } from "@/transport";
|
|
13
|
-
import { breaker } from "@synnaxlabs/x";
|
|
14
|
-
import { Middleware } from "@/middleware";
|
|
15
13
|
import { Unreachable } from "@/errors";
|
|
14
|
+
import { type Middleware } from "@/middleware";
|
|
15
|
+
import { type Transport } from "@/transport";
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* An interface for an entity that implements a simple request-response
|