@synnaxlabs/x 0.32.0 → 0.33.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/.turbo/turbo-build.log +23 -23
- package/dist/binary.cjs +1 -1
- package/dist/binary.js +1 -1
- package/dist/bounds-CCueigU3.js +171 -0
- package/dist/bounds-Cudf5M4H.cjs +1 -0
- package/dist/bounds.cjs +1 -1
- package/dist/bounds.js +1 -1
- package/dist/box-CZVdKCOc.cjs +1 -0
- package/dist/box-hAkmDC3K.js +201 -0
- package/dist/box.cjs +1 -1
- package/dist/box.js +1 -1
- package/dist/caseconv.cjs +1 -1
- package/dist/caseconv.js +1 -1
- package/dist/index-By0n2R_b.cjs +1 -0
- package/dist/{index-DgaYJC35.cjs → index-DQZfhLnw.cjs} +1 -1
- package/dist/{index-Duv1uH08.js → index-q_1Jz5rY.js} +5 -5
- package/dist/{index-B5THJ1eb.js → index-zsix_qnl.js} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +163 -146
- package/dist/{location-DjcaXEps.js → location-B5rSnQP3.js} +1 -1
- package/dist/{location-gPB1RtfA.cjs → location-YGxhLPDy.cjs} +1 -1
- package/dist/location.cjs +1 -1
- package/dist/location.js +1 -1
- package/dist/{position-DkON65EZ.js → position-BZOTg74V.js} +2 -2
- package/dist/{position-C71OiHiw.cjs → position-CjNCcq8X.cjs} +1 -1
- package/dist/position.cjs +1 -1
- package/dist/position.js +1 -1
- package/dist/{scale-COPgp55a.cjs → scale-BvbW9p2C.cjs} +1 -1
- package/dist/{scale-qw6vRO4s.js → scale-C7_4I3pa.js} +3 -3
- package/dist/scale.cjs +1 -1
- package/dist/scale.js +1 -1
- package/dist/series-BId9slhU.cjs +11 -0
- package/dist/{series-B5eA90Ci.js → series-CZw97Bq2.js} +619 -456
- package/dist/spatial.cjs +1 -1
- package/dist/spatial.js +5 -5
- package/dist/src/caseconv/caseconv.d.ts.map +1 -1
- package/dist/src/deep/path.d.ts +1 -1
- package/dist/src/deep/path.d.ts.map +1 -1
- package/dist/src/math/math.d.ts +26 -6
- package/dist/src/math/math.d.ts.map +1 -1
- package/dist/src/math/math.spec.d.ts +2 -0
- package/dist/src/math/math.spec.d.ts.map +1 -0
- package/dist/src/record.d.ts +4 -0
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/spatial/bounds/bounds.d.ts +204 -2
- package/dist/src/spatial/bounds/bounds.d.ts.map +1 -1
- package/dist/src/spatial/box/box.d.ts +4 -4
- package/dist/src/spatial/box/box.d.ts.map +1 -1
- package/dist/src/strings/strings.d.ts +14 -0
- package/dist/src/strings/strings.d.ts.map +1 -1
- package/dist/src/telem/series.d.ts +35 -10
- package/dist/src/telem/series.d.ts.map +1 -1
- package/dist/src/telem/telem.d.ts +12 -10
- package/dist/src/telem/telem.d.ts.map +1 -1
- package/dist/telem.cjs +1 -1
- package/dist/telem.js +1 -1
- package/package.json +9 -9
- package/src/caseconv/caseconv.ts +1 -0
- package/src/deep/path.ts +1 -1
- package/src/math/math.spec.ts +149 -0
- package/src/math/math.ts +60 -9
- package/src/record.ts +5 -0
- package/src/spatial/bounds/bounds.spec.ts +135 -270
- package/src/spatial/bounds/bounds.ts +290 -25
- package/src/spatial/box/box.ts +9 -5
- package/src/strings/strings.spec.ts +33 -1
- package/src/strings/strings.ts +52 -0
- package/src/telem/series.spec.ts +235 -0
- package/src/telem/series.ts +271 -52
- package/src/telem/telem.spec.ts +22 -0
- package/src/telem/telem.ts +44 -20
- package/src/zodutil/zodutil.spec.ts +5 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/bounds-CpboA0q6.js +0 -127
- package/dist/bounds-ZZc1c-_Z.cjs +0 -1
- package/dist/box-BQID-0jO.cjs +0 -1
- package/dist/box-xRqO6NvI.js +0 -202
- package/dist/index-xk130iQA.cjs +0 -1
- package/dist/series-CJ65b1Uz.cjs +0 -11
package/dist/index.js
CHANGED
|
@@ -1,229 +1,246 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (e,
|
|
4
|
-
import { e as
|
|
5
|
-
import { a as
|
|
6
|
-
import { c as
|
|
7
|
-
import { c as
|
|
8
|
-
import { L as
|
|
9
|
-
import { c as
|
|
10
|
-
import { z as
|
|
11
|
-
import { debounce as ue, throttle as
|
|
1
|
+
var j = Object.defineProperty;
|
|
2
|
+
var T = (e, t, r) => t in e ? j(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var p = (e, t, r) => T(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { e as X } from "./index-zsix_qnl.js";
|
|
5
|
+
import { a as ee } from "./index-q_1Jz5rY.js";
|
|
6
|
+
import { c as te } from "./change-DLl6DccR.js";
|
|
7
|
+
import { c as ne, s as se } from "./scale-C7_4I3pa.js";
|
|
8
|
+
import { L as S, G as y, E as w, i as A, a as k, b as O } from "./index-B3BUDIdi.js";
|
|
9
|
+
import { c as ae, d as ce, p as le } from "./index-B3BUDIdi.js";
|
|
10
|
+
import { z as c } from "zod";
|
|
11
|
+
import { debounce as ue, throttle as me } from "./debounce.js";
|
|
12
12
|
import { deep as pe } from "./deep.js";
|
|
13
|
-
import { d as
|
|
14
|
-
import { isObject as
|
|
15
|
-
import { t as
|
|
16
|
-
import { b as Pe,
|
|
13
|
+
import { d as be, D as he, M as xe, R as Se, S as ye, e as ve, c as $e, b as Ee, T as Me, a as je, g as Te, h as we, i as Ae, f as ke, t as Oe } from "./series-CZw97Bq2.js";
|
|
14
|
+
import { isObject as _e } from "./identity.js";
|
|
15
|
+
import { t as Ne } from "./types-BpAJW2TM.js";
|
|
16
|
+
import { b as Pe, f as Ge } from "./bounds-CCueigU3.js";
|
|
17
17
|
import { observe as De } from "./observe.js";
|
|
18
|
-
import { getEntries as
|
|
19
|
-
import { e as
|
|
18
|
+
import { getEntries as Ie, unknownRecordZ as Ve } from "./record.js";
|
|
19
|
+
import { e as qe } from "./external-CO221aaF.js";
|
|
20
20
|
import { Search as He } from "./search.js";
|
|
21
|
-
import { b as Ue } from "./box-
|
|
22
|
-
import { d as
|
|
23
|
-
import { d as
|
|
24
|
-
import { l as
|
|
25
|
-
import { p as
|
|
26
|
-
import { s as
|
|
27
|
-
import { x as
|
|
28
|
-
import { nullToArr as
|
|
21
|
+
import { b as Ue } from "./box-hAkmDC3K.js";
|
|
22
|
+
import { d as Ke } from "./dimensions-D-1PnJVI.js";
|
|
23
|
+
import { d as Xe } from "./direction-CScbfCdT.js";
|
|
24
|
+
import { l as er } from "./location-B5rSnQP3.js";
|
|
25
|
+
import { p as tr } from "./position-BZOTg74V.js";
|
|
26
|
+
import { s as nr } from "./spatial-DozyssiN.js";
|
|
27
|
+
import { x as ir } from "./xy-CrgPnICw.js";
|
|
28
|
+
import { nullToArr as cr, toArray as lr } from "./toArray.js";
|
|
29
29
|
import { unique as ur } from "./unique.js";
|
|
30
|
-
import { URL as
|
|
31
|
-
import { RoutedWorker as
|
|
32
|
-
import { z as
|
|
33
|
-
const
|
|
30
|
+
import { URL as dr, buildQueryString as pr } from "./url.js";
|
|
31
|
+
import { RoutedWorker as br, TypedWorker as hr, createMockWorkers as xr } from "./worker.js";
|
|
32
|
+
import { z as yr } from "./zodutil-qNM8aVYC.js";
|
|
33
|
+
const l = class l extends Number {
|
|
34
34
|
};
|
|
35
|
-
p(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
p(l, "Absolute", 255), p(l, "Default", 1), p(l, "z", c.union([
|
|
36
|
+
c.instanceof(l),
|
|
37
|
+
c.number().int().min(0).max(255).transform((t) => new l(t)),
|
|
38
|
+
c.instanceof(Number).transform((t) => new l(t))
|
|
39
39
|
]));
|
|
40
|
-
let
|
|
41
|
-
const
|
|
42
|
-
name:
|
|
43
|
-
key:
|
|
44
|
-
}),
|
|
45
|
-
subject:
|
|
40
|
+
let h = l;
|
|
41
|
+
const E = c.object({
|
|
42
|
+
name: c.string(),
|
|
43
|
+
key: c.string()
|
|
44
|
+
}), L = (e) => c.object({
|
|
45
|
+
subject: E,
|
|
46
46
|
resource: e,
|
|
47
|
-
authority:
|
|
48
|
-
}),
|
|
47
|
+
authority: h.z
|
|
48
|
+
}), _ = (...e) => (t) => t.filter((r) => {
|
|
49
49
|
let n = !1;
|
|
50
50
|
return r.to != null && (n = e.includes(r.to.resource)), r.from != null && !n && (n = e.includes(r.from.resource)), n;
|
|
51
|
-
}),
|
|
51
|
+
}), W = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
52
52
|
__proto__: null,
|
|
53
|
-
Authority:
|
|
54
|
-
filterTransfersByChannelKey:
|
|
55
|
-
stateZ:
|
|
56
|
-
subjectZ:
|
|
57
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
53
|
+
Authority: h,
|
|
54
|
+
filterTransfersByChannelKey: _,
|
|
55
|
+
stateZ: L,
|
|
56
|
+
subjectZ: E
|
|
57
|
+
}, Symbol.toStringTag, { value: "Module" })), m = class m extends Error {
|
|
58
58
|
constructor() {
|
|
59
|
-
super(
|
|
59
|
+
super(m.MESSAGE);
|
|
60
60
|
}
|
|
61
61
|
/** Returns true if the error or message is a cancellation error" */
|
|
62
|
-
matches(
|
|
63
|
-
return typeof
|
|
62
|
+
matches(t) {
|
|
63
|
+
return typeof t == "string" ? t.includes(m.MESSAGE) : t instanceof m || t.message.includes(m.MESSAGE);
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
p(
|
|
67
|
-
let
|
|
68
|
-
const
|
|
66
|
+
p(m, "MESSAGE", "canceled");
|
|
67
|
+
let v = m;
|
|
68
|
+
const z = new v(), q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
69
69
|
__proto__: null,
|
|
70
|
-
CANCELED:
|
|
71
|
-
}, Symbol.toStringTag, { value: "Module" })), B = (e) => e ? -1 : 1,
|
|
70
|
+
CANCELED: z
|
|
71
|
+
}, Symbol.toStringTag, { value: "Module" })), B = (e) => e ? -1 : 1, $ = c.string().regex(/^\d+\.\d+\.\d+$/), g = (e, t, r = {}) => {
|
|
72
72
|
r.checkMajor ?? (r.checkMajor = !0), r.checkMinor ?? (r.checkMinor = !0), r.checkPatch ?? (r.checkPatch = !0);
|
|
73
|
-
const n =
|
|
73
|
+
const n = $.parse(e), i = $.parse(t), [f, u, d] = n.split(".").map(Number), [s, o, a] = i.split(".").map(Number);
|
|
74
74
|
if (r.checkMajor) {
|
|
75
|
-
if (
|
|
76
|
-
if (
|
|
75
|
+
if (f < s) return S;
|
|
76
|
+
if (f > s) return y;
|
|
77
77
|
}
|
|
78
78
|
if (r.checkMinor) {
|
|
79
|
-
if (
|
|
80
|
-
if (
|
|
79
|
+
if (u < o) return S;
|
|
80
|
+
if (u > o) return y;
|
|
81
81
|
}
|
|
82
82
|
if (r.checkPatch) {
|
|
83
|
-
if (
|
|
84
|
-
if (
|
|
83
|
+
if (d < a) return S;
|
|
84
|
+
if (d > a) return y;
|
|
85
85
|
}
|
|
86
|
-
return
|
|
87
|
-
}, N = (e,
|
|
86
|
+
return w;
|
|
87
|
+
}, N = (e, t, r = {}) => A(g(e, t, r)), M = (e, t, r = {}) => k(g(e, t, r)), R = (e, t, r = {}) => O(g(e, t, r)), P = ({
|
|
88
88
|
name: e,
|
|
89
|
-
migrate:
|
|
89
|
+
migrate: t
|
|
90
90
|
}) => (r) => {
|
|
91
91
|
try {
|
|
92
|
-
const n =
|
|
92
|
+
const n = t(r);
|
|
93
93
|
return console.log(`${e} migrated: ${r.version} -> ${n.version}`), n;
|
|
94
94
|
} catch (n) {
|
|
95
95
|
throw console.log(`${e} failed to migrate from ${r.version}`), console.error(n), n;
|
|
96
96
|
}
|
|
97
97
|
}, G = ({
|
|
98
98
|
name: e,
|
|
99
|
-
migrations:
|
|
99
|
+
migrations: t,
|
|
100
100
|
targetSchema: r,
|
|
101
101
|
defaultVersion: n,
|
|
102
|
-
def:
|
|
102
|
+
def: i
|
|
103
103
|
}) => {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
return (
|
|
107
|
-
if (
|
|
104
|
+
const f = Object.keys(t).sort(g).pop();
|
|
105
|
+
if (f == null)
|
|
106
|
+
return (o) => {
|
|
107
|
+
if (o.version == null && (o.version = n), o.version !== i.version)
|
|
108
108
|
return console.log(
|
|
109
|
-
`${e} version ${
|
|
109
|
+
`${e} version ${o.version} is newer than latest version of ${i.version}.
|
|
110
110
|
Returning default instead.
|
|
111
111
|
`
|
|
112
|
-
),
|
|
112
|
+
), i;
|
|
113
113
|
try {
|
|
114
|
-
return r != null ? r.parse(
|
|
115
|
-
} catch (
|
|
116
|
-
return console.log(`${e} failed to parse default. Exiting with default`), console.error(
|
|
114
|
+
return r != null ? r.parse(o) : o;
|
|
115
|
+
} catch (a) {
|
|
116
|
+
return console.log(`${e} failed to parse default. Exiting with default`), console.error(a), i;
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
-
const
|
|
120
|
-
let
|
|
121
|
-
const
|
|
119
|
+
const u = Object.keys(t).length;
|
|
120
|
+
let d = !1;
|
|
121
|
+
const s = (o) => {
|
|
122
122
|
try {
|
|
123
|
-
if (
|
|
124
|
-
return console.log(
|
|
125
|
-
const
|
|
126
|
-
return
|
|
127
|
-
} catch (
|
|
123
|
+
if (u === 0 || M(o.version, f))
|
|
124
|
+
return console.log(d ? `${e} ${o.version} now up to date` : `${e} version ${o.version} is up to date with target version ${i.version}`), o;
|
|
125
|
+
const a = o.version, b = t[a], x = b(o);
|
|
126
|
+
return d = !0, s(x);
|
|
127
|
+
} catch (a) {
|
|
128
128
|
return console.log(
|
|
129
|
-
`${e} failed to migrate from ${
|
|
130
|
-
), console.error(
|
|
129
|
+
`${e} failed to migrate from ${o.version} to ${f}`
|
|
130
|
+
), console.error(a), i;
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
return (
|
|
133
|
+
return (o) => {
|
|
134
134
|
try {
|
|
135
|
-
if (
|
|
135
|
+
if (o.version == null)
|
|
136
136
|
if (n != null)
|
|
137
137
|
console.log(
|
|
138
138
|
`${e} version is null. Setting version to default of ${n}`
|
|
139
|
-
),
|
|
139
|
+
), o.version = n;
|
|
140
140
|
else
|
|
141
141
|
return console.log(
|
|
142
142
|
`${e} version is null and no default version set. Exiting with default`
|
|
143
|
-
),
|
|
144
|
-
return
|
|
145
|
-
} catch (
|
|
146
|
-
return console.log(`${e} failed to parse final result. Exiting with default`), console.error(
|
|
143
|
+
), i;
|
|
144
|
+
return s(o);
|
|
145
|
+
} catch (a) {
|
|
146
|
+
return console.log(`${e} failed to parse final result. Exiting with default`), console.error(a), i;
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
}, H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
150
150
|
__proto__: null,
|
|
151
151
|
compareSemVer: g,
|
|
152
|
-
createMigration:
|
|
152
|
+
createMigration: P,
|
|
153
153
|
migrator: G,
|
|
154
|
-
semVerNewer:
|
|
155
|
-
semVerOlder:
|
|
156
|
-
semVerZ:
|
|
154
|
+
semVerNewer: M,
|
|
155
|
+
semVerOlder: R,
|
|
156
|
+
semVerZ: $,
|
|
157
157
|
versionsEqual: N
|
|
158
158
|
}, Symbol.toStringTag, { value: "Module" })), Q = (e) => {
|
|
159
159
|
if (e === void 0 || typeof e == "string" || typeof e == "number")
|
|
160
160
|
return e;
|
|
161
161
|
if (e.toString === void 0) throw new Error("invalid renderer");
|
|
162
162
|
return e.toString();
|
|
163
|
-
}, U = (e) => Array.isArray(e) ? [...e] : typeof e == "object" && e !== null ? { ...e } : e,
|
|
163
|
+
}, U = (e) => Array.isArray(e) ? [...e] : typeof e == "object" && e !== null ? { ...e } : e, C = (e, t = "") => {
|
|
164
164
|
const r = e.length;
|
|
165
|
-
return r === 0 ?
|
|
166
|
-
},
|
|
165
|
+
return r === 0 ? t : r === 1 ? e[0] : r === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")}, and ${e[r - 1]}`;
|
|
166
|
+
}, D = (e) => {
|
|
167
|
+
const t = e.split(" "), r = /* @__PURE__ */ new Set(), n = t.map((s) => s.charAt(0).toLowerCase()).join("");
|
|
168
|
+
r.add(n), r.add(n.replace(/(.)(.)/g, "$1_$2"));
|
|
169
|
+
const i = /\d+/g;
|
|
170
|
+
e.match(i) && t.forEach((s, o) => {
|
|
171
|
+
if (i.test(s)) {
|
|
172
|
+
const a = t.map((b, x) => x !== o ? b.charAt(0).toLowerCase() : b).join("");
|
|
173
|
+
r.add(a), r.add(a.replace(/(.)(.)/g, "$1_$2"));
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const u = t.map(
|
|
177
|
+
(s) => (s.length > 3 ? s.substring(0, 3) : s).toLowerCase()
|
|
178
|
+
);
|
|
179
|
+
return r.add(u.join("")), r.add(u.join("_")), Array.from(r).filter(
|
|
180
|
+
(s) => s.length >= 2 && s.length <= 12
|
|
181
|
+
);
|
|
182
|
+
}, J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
167
183
|
__proto__: null,
|
|
168
|
-
|
|
184
|
+
generateShortIdentifiers: D,
|
|
185
|
+
naturalLanguageJoin: C
|
|
169
186
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
170
187
|
export {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
188
|
+
be as DataType,
|
|
189
|
+
he as Density,
|
|
190
|
+
xe as MultiSeries,
|
|
174
191
|
Se as Rate,
|
|
175
|
-
|
|
192
|
+
br as RoutedWorker,
|
|
176
193
|
He as Search,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
194
|
+
ye as Series,
|
|
195
|
+
ve as Size,
|
|
196
|
+
$e as TimeRange,
|
|
197
|
+
Ee as TimeSpan,
|
|
198
|
+
Me as TimeStamp,
|
|
199
|
+
hr as TypedWorker,
|
|
200
|
+
dr as URL,
|
|
201
|
+
je as addSamples,
|
|
202
|
+
X as binary,
|
|
186
203
|
Pe as bounds,
|
|
187
204
|
Ue as box,
|
|
188
205
|
pr as buildQueryString,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
206
|
+
ee as caseconv,
|
|
207
|
+
te as change,
|
|
208
|
+
ne as clamp,
|
|
209
|
+
ae as compare,
|
|
210
|
+
W as control,
|
|
194
211
|
Te as convertDataType,
|
|
195
212
|
Q as convertRenderV,
|
|
196
|
-
|
|
213
|
+
xr as createMockWorkers,
|
|
197
214
|
ue as debounce,
|
|
198
215
|
pe as deep,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
216
|
+
Ke as dimensions,
|
|
217
|
+
Xe as direction,
|
|
218
|
+
q as errors,
|
|
219
|
+
Ie as getEntries,
|
|
220
|
+
we as id,
|
|
204
221
|
B as invert,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
222
|
+
Ae as isCrudeSeries,
|
|
223
|
+
_e as isObject,
|
|
224
|
+
ce as isStringer,
|
|
225
|
+
ke as isTelemValue,
|
|
226
|
+
Ne as kv,
|
|
227
|
+
er as location,
|
|
228
|
+
Ge as math,
|
|
212
229
|
H as migrate,
|
|
213
|
-
|
|
230
|
+
cr as nullToArr,
|
|
214
231
|
De as observe,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
232
|
+
tr as position,
|
|
233
|
+
le as primitiveIsZero,
|
|
234
|
+
qe as runtime,
|
|
235
|
+
se as scale,
|
|
219
236
|
U as shallowCopy,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
237
|
+
nr as spatial,
|
|
238
|
+
J as strings,
|
|
239
|
+
me as throttle,
|
|
240
|
+
lr as toArray,
|
|
241
|
+
Oe as typedArrayZ,
|
|
225
242
|
ur as unique,
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
243
|
+
Ve as unknownRecordZ,
|
|
244
|
+
ir as xy,
|
|
245
|
+
yr as zodutil
|
|
229
246
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z as O } from "zod";
|
|
2
|
-
import { c as m } from "./index-
|
|
2
|
+
import { c as m } from "./index-q_1Jz5rY.js";
|
|
3
3
|
import { e as f, f as x, y as a, g, D as C, C as z, X as L, Y as h, l as S, h as d } from "./base-DnZzEvvz.js";
|
|
4
4
|
const N = f, R = a, I = {
|
|
5
5
|
top: "bottom",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const u=require("zod"),I=require("./index-
|
|
1
|
+
"use strict";const u=require("zod"),I=require("./index-By0n2R_b.cjs"),c=require("./base-B48bPNx5.cjs"),R=c.xLocation,g=c.yLocation,h={top:"bottom",right:"left",bottom:"top",left:"right",center:"center"},d={top:"left",right:"top",bottom:"right",left:"bottom",center:"center"},m=c.crudeLocation,s=t=>t instanceof String?t:c.DIRECTIONS.includes(t)?t==="x"?"left":"top":t,_=t=>h[s(t)],A=t=>d[s(t)],i=t=>{const o=s(t);return o==="top"||o==="bottom"?"y":"x"},l=u.z.object({x:c.xLocation.or(c.centerLocation),y:c.yLocation.or(c.centerLocation)}),E=u.z.object({x:c.xLocation,y:c.yLocation}),O=Object.freeze({x:"left",y:"top"}),f=Object.freeze({x:"right",y:"top"}),x=Object.freeze({x:"left",y:"bottom"}),a=Object.freeze({x:"right",y:"bottom"}),T=Object.freeze({x:"center",y:"center"}),b=Object.freeze({x:"center",y:"top"}),L=Object.freeze({x:"center",y:"bottom"}),p=Object.freeze({x:"right",y:"center"}),C=Object.freeze({x:"left",y:"center"}),N=Object.freeze([C,p,b,L,O,f,x,a,T]),j=(t,o)=>t.x===o.x&&t.y===o.y,S=(t,o)=>{if(typeof o=="object"){let e=!0;return"x"in o&&(t.x===o.x||(e=!1)),"y"in o&&(t.y===o.y||(e=!1)),e}return t.x===o||t.y===o},z=t=>[t.x,t.y],y=t=>i(s(t))==="x",M=t=>i(s(t))==="y",P=t=>`${t.x}${I.capitalize(t.y)}`,X=(t,o)=>{let e,n;if(typeof t=="object"&&"x"in t?(e=t.x,n=t.y):(e=s(t),n=s(o??t)),i(e)===i(n)&&e!=="center"&&n!=="center")throw new Error(`[XYLocation] - encountered two locations with the same direction: ${e.toString()} - ${n.toString()}`);const r={...T};return e==="center"?y(n)?[r.x,r.y]=[n,e]:[r.x,r.y]=[e,n]:n==="center"?y(e)?[r.x,r.y]=[e,n]:[r.x,r.y]=[n,e]:y(e)?[r.x,r.y]=[e,n]:[r.x,r.y]=[n,e],r},Y=Object.freeze(Object.defineProperty({__proto__:null,BOTTOM_CENTER:L,BOTTOM_LEFT:x,BOTTOM_RIGHT:a,CENTER:T,CENTER_LOCATIONS:c.CENTER_LOCATIONS,LEFT_CENTER:C,RIGHT_CENTER:p,TOP_CENTER:b,TOP_LEFT:O,TOP_RIGHT:f,XY_LOCATIONS:N,X_LOCATIONS:c.X_LOCATIONS,Y_LOCATIONS:c.Y_LOCATIONS,construct:s,constructXY:X,corner:E,crude:m,direction:i,isX:y,isY:M,location:c.location,outer:c.outerLocation,rotate90:A,swap:_,x:R,xy:l,xyCouple:z,xyEquals:j,xyMatches:S,xyToString:P,y:g},Symbol.toStringTag,{value:"Module"}));exports.BOTTOM_LEFT=x;exports.BOTTOM_RIGHT=a;exports.CENTER=T;exports.TOP_LEFT=O;exports.TOP_RIGHT=f;exports.XY_LOCATIONS=N;exports.corner=E;exports.location=Y;exports.swap=_;exports.xy=l;exports.xyCouple=z;exports.xyEquals=j;exports.xyMatches=S;
|
package/dist/location.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./location-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./location-YGxhLPDy.cjs");exports.location=o.location;
|
package/dist/location.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as g, x as v, a as I, h as M, w as N, d as X, i as j } from "./box-
|
|
1
|
+
import { c as g, x as v, a as I, h as M, w as N, d as X, i as j } from "./box-hAkmDC3K.js";
|
|
2
2
|
import { c as w } from "./direction-CScbfCdT.js";
|
|
3
|
-
import { x as B, a as h, b as C, C as O, T as R, s as m, X as S } from "./location-
|
|
3
|
+
import { x as B, a as h, b as C, C as O, T as R, s as m, X as S } from "./location-B5rSnQP3.js";
|
|
4
4
|
import { l as Y } from "./base-DnZzEvvz.js";
|
|
5
5
|
const P = (t) => {
|
|
6
6
|
if (t == null) return { x: void 0, y: void 0 };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const n=require("./box-
|
|
1
|
+
"use strict";const n=require("./box-CZVdKCOc.cjs"),T=require("./direction-DZbN47uL.cjs"),r=require("./location-YGxhLPDy.cjs"),b=require("./base-B48bPNx5.cjs"),P=t=>{if(t==null)return{x:void 0,y:void 0};const s=r.xy.safeParse(t);if(s.success)return s.data;const e=b.location.safeParse(t);return e.success?T.construct(e.data)==="x"?{x:e.data,y:void 0}:{x:void 0,y:e.data}:t},N=({container:t,target:s,dialog:e,initial:u,prefer:a,alignments:l=["start"],disable:f=[]})=>{const i=P(u);let x=r.XY_LOCATIONS;if(a!=null){const o=a.map(c=>P(c));x=x.slice().sort((c,p)=>{const d=o.findIndex(g=>r.xyMatches(c,g)),h=o.findIndex(g=>r.xyMatches(p,g));return d>-1&&h>-1?d-h:d>-1?-1:h>-1?1:0})}const O=x.filter(o=>!r.xyEquals(o,r.CENTER)&&(i.x==null||o.x===i.x)&&(i.y==null||o.y===i.y)&&!f.some(c=>r.xyMatches(o,c))).map(o=>l==null?void 0:l.map(c=>[o,c])).flat(),A=n.construct(t),M=n.construct(s),_=n.construct(e);let E=-1/0;const y={location:r.CENTER,adjustedDialog:_};return O.forEach(([o,c])=>{const[p,d]=v({option:o,alignment:c,container:A,target:M,dialog:_});d>E&&(E=d,y.location=o,y.adjustedDialog=p)}),y},v=({option:t,alignment:s,container:e,target:u,dialog:a})=>{const l=L(t,s),f=n.xyLoc(u,t),i=n.constructWithAlternateRoot(f.x,f.y,n.width(a),n.height(a),l,r.TOP_LEFT),x=n.area(n.intersection(i,e));return[i,x]},I={start:"left",center:"center",end:"right"},j={start:"bottom",center:"center",end:"top"},L=(t,s)=>{const e={x:"center",y:"center"};if(t.y!=="center"){e.y=r.swap(t.y);const u=t.x==="left"?r.swap:a=>a;e.x=u(I[s])}else e.x=r.swap(t.x),e.y=j[s];return e},q=Object.freeze(Object.defineProperty({__proto__:null,dialog:N,getRoot:L,parseLocationOptions:P},Symbol.toStringTag,{value:"Module"}));exports.position=q;
|
package/dist/position.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./position-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./position-CjNCcq8X.cjs");exports.position=o.position;
|
package/dist/position.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var g=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var i=(n,t,e)=>g(n,typeof t!="symbol"?t+"":t,e);const R=require("zod"),x=require("./bounds-
|
|
1
|
+
"use strict";var v=Object.defineProperty;var g=(n,t,e)=>t in n?v(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var i=(n,t,e)=>g(n,typeof t!="symbol"?t+"":t,e);const R=require("zod"),x=require("./bounds-Cudf5M4H.cjs"),u=require("./box-CZVdKCOc.cjs"),T=require("./location-YGxhLPDy.cjs"),h=require("./xy-cP-FXJtR.cjs"),m=(n,t,e)=>t!==void 0&&n<t?t:e!==void 0&&n>e?e:n,q=R.z.object({offset:h.crudeZ,scale:h.crudeZ}),E=n=>(t,e,s,r)=>e==="dimension"?[t,s]:[t,r?s-n:s+n],I=n=>(t,e,s,r)=>[t,r?s/n:s*n],Y=n=>(t,e,s)=>{if(t===null)return[n,s];const{lower:r,upper:o}=t,{lower:p,upper:l}=n,f=o-r,w=l-p;if(e==="dimension")return[n,s*(w/f)];const B=(s-r)*(w/f)+p;return[n,B]},j=n=>(t,e,s)=>[n,s],z=()=>(n,t,e)=>{if(n===null)throw new Error("cannot invert without bounds");if(t==="dimension")return[n,e];const{lower:s,upper:r}=n;return[n,r-(e-s)]},D=n=>(t,e,s)=>{const{lower:r,upper:o}=n;return s=m(s,r,o),[t,s]},a=class a{constructor(){i(this,"ops",[]);i(this,"currBounds",null);i(this,"currType",null);i(this,"reversed",!1);this.ops=[]}static translate(t){return new a().translate(t)}static magnify(t){return new a().magnify(t)}static scale(t,e){return new a().scale(t,e)}translate(t){const e=this.new(),s=E(t);return s.type="translate",e.ops.push(s),e}magnify(t){const e=this.new(),s=I(t);return s.type="magnify",e.ops.push(s),e}scale(t,e){const s=x.construct(t,e),r=this.new(),o=Y(s);return o.type="scale",r.ops.push(o),r}clamp(t,e){const s=x.construct(t,e),r=this.new(),o=D(s);return o.type="clamp",r.ops.push(o),r}reBound(t,e){const s=x.construct(t,e),r=this.new(),o=j(s);return o.type="re-bound",r.ops.push(o),r}invert(){const t=z();t.type="invert";const e=this.new();return e.ops.push(t),e}pos(t){return this.exec("position",t)}dim(t){return this.exec("dimension",t)}new(){const t=new a;return t.ops=this.ops.slice(),t.reversed=this.reversed,t}exec(t,e){return this.currBounds=null,this.ops.reduce(([s,r],o)=>o(s,t,r,this.reversed),[null,e])[1]}reverse(){const t=this.new();t.ops.reverse();const e=[];return t.ops.forEach((s,r)=>{if(s.type==="scale"||e.some(([p,l])=>r>=p&&r<=l))return;const o=t.ops.findIndex((p,l)=>p.type==="scale"&&l>r);o!==-1&&e.push([r,o])}),e.forEach(([s,r])=>{const o=t.ops.slice(s,r);o.unshift(t.ops[r]),t.ops.splice(s,r-s+1,...o)}),t.reversed=!t.reversed,t}};i(a,"IDENTITY",new a);let y=a;const L=n=>({scale:{x:n.x.dim(1),y:n.y.dim(1)},offset:{x:n.x.pos(0),y:n.y.pos(0)}}),c=class c{constructor(t=new y,e=new y,s=null){i(this,"x");i(this,"y");i(this,"currRoot");this.x=t,this.y=e,this.currRoot=s}static translate(t,e){return new c().translate(t,e)}static translateX(t){return new c().translateX(t)}static translateY(t){return new c().translateY(t)}static clamp(t){return new c().clamp(t)}static magnify(t){return new c().magnify(t)}static scale(t){return new c().scale(t)}static reBound(t){return new c().reBound(t)}translate(t,e){const s=h.construct(t,e),r=this.copy();return r.x=this.x.translate(s.x),r.y=this.y.translate(s.y),r}translateX(t){const e=this.copy();return e.x=this.x.translate(t),e}translateY(t){const e=this.copy();return e.y=this.y.translate(t),e}magnify(t){const e=this.copy();return e.x=this.x.magnify(t.x),e.y=this.y.magnify(t.y),e}scale(t){const e=this.copy();if(u.isBox(t)){const s=this.currRoot;return e.currRoot=t.root,s!=null&&!T.xyEquals(s,t.root)&&(s.x!==t.root.x&&(e.x=e.x.invert()),s.y!==t.root.y&&(e.y=e.y.invert())),e.x=e.x.scale(u.xBounds(t)),e.y=e.y.scale(u.yBounds(t)),e}return e.x=e.x.scale(t.width),e.y=e.y.scale(t.height),e}reBound(t){const e=this.copy();return e.x=this.x.reBound(u.xBounds(t)),e.y=this.y.reBound(u.yBounds(t)),e}clamp(t){const e=this.copy();return e.x=this.x.clamp(u.xBounds(t)),e.y=this.y.clamp(u.yBounds(t)),e}copy(){const t=new c;return t.currRoot=this.currRoot,t.x=this.x,t.y=this.y,t}reverse(){const t=this.copy();return t.x=this.x.reverse(),t.y=this.y.reverse(),t}pos(t){return{x:this.x.pos(t.x),y:this.y.pos(t.y)}}box(t){return u.construct(this.pos(t.one),this.pos(t.two),0,0,this.currRoot??t.root)}};i(c,"IDENTITY",new c);let d=c;const M=Object.freeze(Object.defineProperty({__proto__:null,Scale:y,XY:d,crudeXYTransform:q,xyScaleToTransform:L},Symbol.toStringTag,{value:"Module"}));exports.clamp=m;exports.scale=M;
|
|
@@ -2,9 +2,9 @@ var g = Object.defineProperty;
|
|
|
2
2
|
var B = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
3
|
var i = (r, t, e) => B(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { z as R } from "zod";
|
|
5
|
-
import { c as l } from "./bounds-
|
|
6
|
-
import { e as T, f as x, y as h, c as E } from "./box-
|
|
7
|
-
import { b as I } from "./location-
|
|
5
|
+
import { c as l } from "./bounds-CCueigU3.js";
|
|
6
|
+
import { e as T, f as x, y as h, c as E } from "./box-hAkmDC3K.js";
|
|
7
|
+
import { b as I } from "./location-B5rSnQP3.js";
|
|
8
8
|
import { b as w, c as Y } from "./xy-CrgPnICw.js";
|
|
9
9
|
const j = (r, t, e) => t !== void 0 && r < t ? t : e !== void 0 && r > e ? e : r, z = R.object({ offset: w, scale: w }), D = (r) => (t, e, s, n) => e === "dimension" ? [t, s] : [
|
|
10
10
|
t,
|
package/dist/scale.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./scale-BvbW9p2C.cjs");exports.scale=e.scale;
|
package/dist/scale.js
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";var _=Object.defineProperty;var tt=(l,t,e)=>t in l?_(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var i=(l,t,e)=>tt(l,typeof t!="symbol"?t+"":t,e);const o=require("zod"),D=require("./index-DQZfhLnw.cjs"),et=require("./index-By0n2R_b.cjs"),nt=require("./index-h-QAL9T1.cjs"),w=require("./bounds-Cudf5M4H.cjs");require("./box-CZVdKCOc.cjs");require("./dimensions-zMcb9pMk.cjs");require("./base-B48bPNx5.cjs");require("./location-YGxhLPDy.cjs");require("./scale-BvbW9p2C.cjs");require("./xy-cP-FXJtR.cjs");const rt=require("./zodutil-BWvwKcpb.cjs");let it=(l,t=21)=>(e=t)=>{let n="",s=e;for(;s--;)n+=l[Math.random()*l.length|0];return n};const st="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",K=it(st,11),at=Object.freeze(Object.defineProperty({__proto__:null,id:K},Symbol.toStringTag,{value:"Module"})),ut=o.z.enum(["static","dynamic"]),H=(l,t)=>{const e=new m(t);if(![y.DAY,y.HOUR,y.MINUTE,y.SECOND,y.MILLISECOND,y.MICROSECOND,y.NANOSECOND].some(s=>s.equals(e)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=l.valueOf()%e.valueOf();return l instanceof m?new m(n):new y(n)},a=class a{constructor(t,e="UTC"){i(this,"value");i(this,"encodeValue",!0);if(t==null)this.value=a.now().valueOf();else if(t instanceof Date)this.value=BigInt(t.getTime())*a.MILLISECOND.valueOf();else if(typeof t=="string")this.value=a.parseDateTimeString(t,e).valueOf();else if(Array.isArray(t))this.value=a.parseDate(t);else{let n=BigInt(0);t instanceof Number&&(t=t.valueOf()),e==="local"&&(n=a.utcOffset.valueOf()),typeof t=="number"&&(isFinite(t)?t=Math.trunc(t):(isNaN(t)&&(t=0),t===1/0?t=a.MAX:t=a.MIN)),this.value=BigInt(t.valueOf())+n}}static parseDate([t=1970,e=1,n=1]){const s=new Date(t,e-1,n,0,0,0,0);return new a(BigInt(s.getTime())*a.MILLISECOND.valueOf()).truncate(a.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(t,e="UTC"){const[n,s,c]=t.split(":");let f="00",v="00";c!=null&&([f,v]=c.split("."));let O=a.hours(parseInt(n??"00",10)).add(a.minutes(parseInt(s??"00",10))).add(a.seconds(parseInt(f??"00",10))).add(a.milliseconds(parseInt(v??"00",10)));return e==="local"&&(O=O.add(a.utcOffset)),O.valueOf()}static parseDateTimeString(t,e="UTC"){if(!t.includes("/")&&!t.includes("-"))return a.parseTimeString(t,e);const n=new Date(t);return t.includes(":")||n.setUTCHours(0,0,0,0),new a(BigInt(n.getTime())*a.MILLISECOND.valueOf(),e).valueOf()}fString(t="ISO",e="UTC"){switch(t){case"ISODate":return this.toISOString(e).slice(0,10);case"ISOTime":return this.toISOString(e).slice(11,23);case"time":return this.timeString(!1,e);case"preciseTime":return this.timeString(!0,e);case"date":return this.dateString();case"preciseDate":return`${this.dateString()} ${this.timeString(!0,e)}`;case"dateTime":return`${this.dateString()} ${this.timeString(!1,e)}`;default:return this.toISOString(e)}}toISOString(t="UTC"){return t==="UTC"?this.date().toISOString():this.sub(a.utcOffset).date().toISOString()}timeString(t=!1,e="UTC"){const n=this.toISOString(e);return t?n.slice(11,23):n.slice(11,19)}dateString(){const t=this.date(),e=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${e} ${n}`}static get utcOffset(){return new y(BigInt(new Date().getTimezoneOffset())*a.MINUTE.valueOf())}static since(t){return new a().span(t)}date(){return new Date(this.milliseconds())}equals(t){return this.valueOf()===new a(t).valueOf()}span(t){return this.range(t).span}range(t){return new M(this,t).makeValid()}spanRange(t){return this.range(this.add(t)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(t){return this.valueOf()>new a(t).valueOf()}afterEq(t){return this.valueOf()>=new a(t).valueOf()}before(t){return this.valueOf()<new a(t).valueOf()}beforeEq(t){return this.valueOf()<=new a(t).valueOf()}add(t){return new a(this.valueOf()+BigInt(t.valueOf()))}sub(t){return new a(this.valueOf()-BigInt(t.valueOf()))}milliseconds(){return Number(this.valueOf())/Number(a.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(t){return H(this,t)}get isToday(){return this.truncate(y.DAY).equals(a.now().truncate(y.DAY))}truncate(t){return this.sub(this.remainder(t))}static now(){return new a(new Date)}static max(...t){let e=a.MIN;for(const n of t){const s=new a(n);s.after(e)&&(e=s)}return e}static min(...t){let e=a.MAX;for(const n of t){const s=new a(n);s.before(e)&&(e=s)}return e}static nanoseconds(t){return new a(t)}static microseconds(t){return a.nanoseconds(t*1e3)}static milliseconds(t){return a.microseconds(t*1e3)}static seconds(t){return a.milliseconds(t*1e3)}static minutes(t){return a.seconds(t*60)}static hours(t){return a.minutes(t*60)}static days(t){return a.hours(t*24)}};i(a,"NANOSECOND",a.nanoseconds(1)),i(a,"MICROSECOND",a.microseconds(1)),i(a,"MILLISECOND",a.milliseconds(1)),i(a,"SECOND",a.seconds(1)),i(a,"MINUTE",a.minutes(1)),i(a,"HOUR",a.hours(1)),i(a,"DAY",a.days(1)),i(a,"MAX",new a((1n<<63n)-1n)),i(a,"MIN",new a(0)),i(a,"ZERO",new a(0)),i(a,"z",o.z.union([o.z.object({value:o.z.bigint()}).transform(t=>new a(t.value)),o.z.string().transform(t=>new a(BigInt(t))),o.z.instanceof(Number).transform(t=>new a(t)),o.z.number().transform(t=>new a(t)),o.z.instanceof(a)]));let m=a;const u=class u{constructor(t){i(this,"value");i(this,"encodeValue",!0);typeof t=="number"&&(t=Math.trunc(t.valueOf())),this.value=BigInt(t.valueOf())}static fromSeconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.seconds(t):new u(t)}static fromMilliseconds(t){return t instanceof u?t:t instanceof L?t.period:t instanceof m?new u(t):["number","bigint"].includes(typeof t)?u.milliseconds(t):new u(t)}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(t){return this.valueOf()<new u(t).valueOf()}greaterThan(t){return this.valueOf()>new u(t).valueOf()}lessThanOrEqual(t){return this.valueOf()<=new u(t).valueOf()}greaterThanOrEqual(t){return this.valueOf()>=new u(t).valueOf()}remainder(t){return H(this,t)}truncate(t){return new u(BigInt(Math.trunc(Number(this.valueOf()/t.valueOf())))*t.valueOf())}toString(){const t=this.truncate(u.DAY),e=this.truncate(u.HOUR),n=this.truncate(u.MINUTE),s=this.truncate(u.SECOND),c=this.truncate(u.MILLISECOND),f=this.truncate(u.MICROSECOND),v=this.truncate(u.NANOSECOND),O=t,N=e.sub(t),A=n.sub(e),h=s.sub(n),R=c.sub(s),C=f.sub(c),Y=v.sub(f);let B="";return O.isZero||(B+=`${O.days}d `),N.isZero||(B+=`${N.hours}h `),A.isZero||(B+=`${A.minutes}m `),h.isZero||(B+=`${h.seconds}s `),R.isZero||(B+=`${R.milliseconds}ms `),C.isZero||(B+=`${C.microseconds}µs `),Y.isZero||(B+=`${Y.nanoseconds}ns`),B.trim()}get days(){return Number(this.valueOf())/Number(u.DAY.valueOf())}get hours(){return Number(this.valueOf())/Number(u.HOUR.valueOf())}get minutes(){return Number(this.valueOf())/Number(u.MINUTE.valueOf())}get seconds(){return Number(this.valueOf())/Number(u.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf())/Number(u.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf())/Number(u.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(t){return this.valueOf()===new u(t).valueOf()}add(t){return new u(this.valueOf()+new u(t).valueOf())}sub(t){return new u(this.valueOf()-new u(t).valueOf())}static nanoseconds(t=1){return new u(t)}static microseconds(t=1){return u.nanoseconds(w.mult(t,1e3))}static milliseconds(t=1){return u.microseconds(w.mult(t,1e3))}static seconds(t=1){return u.milliseconds(w.mult(t,1e3))}static minutes(t=1){return u.seconds(w.mult(t,60))}static hours(t){return u.minutes(w.mult(t,60))}static days(t){return u.hours(w.mult(t,24))}};i(u,"NANOSECOND",u.nanoseconds(1)),i(u,"MICROSECOND",u.microseconds(1)),i(u,"MILLISECOND",u.milliseconds(1)),i(u,"SECOND",u.seconds(1)),i(u,"MINUTE",u.minutes(1)),i(u,"HOUR",u.hours(1)),i(u,"DAY",u.days(1)),i(u,"MAX",new u((1n<<63n)-1n)),i(u,"MIN",new u(0)),i(u,"ZERO",new u(0)),i(u,"z",o.z.union([o.z.object({value:o.z.bigint()}).transform(t=>new u(t.value)),o.z.string().transform(t=>new u(BigInt(t))),o.z.instanceof(Number).transform(t=>new u(t)),o.z.number().transform(t=>new u(t)),o.z.instanceof(u)]));let y=u;const p=class p extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}toString(){return`${this.valueOf()} Hz`}equals(t){return this.valueOf()===new p(t).valueOf()}get period(){return y.seconds(1/this.valueOf())}sampleCount(t){return new y(t).seconds*this.valueOf()}byteCount(t,e){return this.sampleCount(t)*new I(e).valueOf()}span(t){return y.seconds(t/this.valueOf())}byteSpan(t,e){return this.span(t.valueOf()/e.valueOf())}static hz(t){return new p(t)}static khz(t){return p.hz(t*1e3)}};i(p,"z",o.z.union([o.z.number().transform(t=>new p(t)),o.z.instanceof(Number).transform(t=>new p(t)),o.z.instanceof(p)]));let L=p;const b=class b extends Number{constructor(t){t instanceof Number?super(t.valueOf()):super(t)}length(t){return t.valueOf()/this.valueOf()}size(t){return new U(t*this.valueOf())}};i(b,"UNKNOWN",new b(0)),i(b,"BIT128",new b(16)),i(b,"BIT64",new b(8)),i(b,"BIT32",new b(4)),i(b,"BIT16",new b(2)),i(b,"BIT8",new b(1)),i(b,"z",o.z.union([o.z.number().transform(t=>new b(t)),o.z.instanceof(Number).transform(t=>new b(t)),o.z.instanceof(b)]));let I=b;const S=class S{constructor(t,e){i(this,"start");i(this,"end");typeof t=="object"&&"start"in t?(this.start=new m(t.start),this.end=new m(t.end)):(this.start=new m(t),this.end=new m(e))}get span(){return new y(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}get numeric(){return{start:Number(this.start.valueOf()),end:Number(this.end.valueOf())}}swap(){return new S(this.end,this.start)}equals(t){return this.start.equals(t.start)&&this.end.equals(t.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(t,e=y.ZERO){t=t.makeValid();const n=this.makeValid();if(this.equals(t))return!0;if(t.end.equals(n.start)||n.end.equals(t.start))return!1;const s=m.max(n.start,t.start),c=m.min(n.end,t.end);return c.before(s)?!1:new y(c.sub(s)).greaterThanOrEqual(e)}roughlyEquals(t,e){let n=this.start.sub(t.start).valueOf(),s=this.end.sub(t.end).valueOf();return n<0&&(n=-n),s<0&&(s=-s),n<=e.valueOf()&&s<=e.valueOf()}contains(t){return t instanceof S?this.contains(t.start)&&this.contains(t.end):this.start.beforeEq(t)&&this.end.after(t)}boundBy(t){const e=new S(this.start,this.end);return t.start.after(this.start)&&(e.start=t.start),t.start.after(this.end)&&(e.end=t.start),t.end.before(this.end)&&(e.end=t.end),t.end.before(this.start)&&(e.start=t.end),e}};i(S,"MAX",new S(m.MIN,m.MAX)),i(S,"MIN",new S(m.MAX,m.MIN)),i(S,"ZERO",new S(m.ZERO,m.ZERO)),i(S,"z",o.z.union([o.z.object({start:m.z,end:m.z}).transform(t=>new S(t.start,t.end)),o.z.instanceof(S)]));let M=S;const r=class r extends String{constructor(t){if(t instanceof r||typeof t=="string"||typeof t.valueOf()=="string"){super(t.valueOf());return}else{const e=r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(t.constructor.name);if(e!=null){super(e.valueOf());return}}throw super(r.UNKNOWN.valueOf()),new Error(`unable to find data type for ${t.toString()}`)}get Array(){const t=r.ARRAY_CONSTRUCTORS.get(this.toString());if(t==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return t}equals(t){return this.valueOf()===t.valueOf()}matches(...t){return t.some(e=>this.equals(e))}toString(){return this.valueOf()}get isVariable(){return this.equals(r.JSON)||this.equals(r.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(r.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const t=r.DENSITIES.get(this.toString());if(t==null)throw new Error(`unable to find density for ${this.valueOf()}`);return t}canSafelyCastTo(t){return this.equals(t)?!0:this.isVariable&&!t.isVariable||!this.isVariable&&t.isVariable?!1:this.isFloat&&t.isInteger||this.isInteger&&t.isFloat?this.density.valueOf()<t.density.valueOf():this.isFloat&&t.isFloat||this.isInteger&&t.isInteger?this.density.valueOf()<=t.density.valueOf():!1}canCastTo(t){return this.isNumeric&&t.isNumeric?!0:this.equals(t)}checkArray(t){return t.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return r.BIG_INT_TYPES.some(t=>t.equals(this))}};i(r,"UNKNOWN",new r("unknown")),i(r,"FLOAT64",new r("float64")),i(r,"FLOAT32",new r("float32")),i(r,"INT64",new r("int64")),i(r,"INT32",new r("int32")),i(r,"INT16",new r("int16")),i(r,"INT8",new r("int8")),i(r,"UINT64",new r("uint64")),i(r,"UINT32",new r("uint32")),i(r,"UINT16",new r("uint16")),i(r,"UINT8",new r("uint8")),i(r,"BOOLEAN",r.UINT8),i(r,"TIMESTAMP",new r("timestamp")),i(r,"UUID",new r("uuid")),i(r,"STRING",new r("string")),i(r,"JSON",new r("json")),i(r,"ARRAY_CONSTRUCTORS",new Map([[r.UINT8.toString(),Uint8Array],[r.UINT16.toString(),Uint16Array],[r.UINT32.toString(),Uint32Array],[r.UINT64.toString(),BigUint64Array],[r.FLOAT32.toString(),Float32Array],[r.FLOAT64.toString(),Float64Array],[r.INT8.toString(),Int8Array],[r.INT16.toString(),Int16Array],[r.INT32.toString(),Int32Array],[r.INT64.toString(),BigInt64Array],[r.TIMESTAMP.toString(),BigInt64Array],[r.STRING.toString(),Uint8Array],[r.JSON.toString(),Uint8Array],[r.UUID.toString(),Uint8Array]])),i(r,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,r.UINT8],[Uint16Array.name,r.UINT16],[Uint32Array.name,r.UINT32],[BigUint64Array.name,r.UINT64],[Float32Array.name,r.FLOAT32],[Float64Array.name,r.FLOAT64],[Int8Array.name,r.INT8],[Int16Array.name,r.INT16],[Int32Array.name,r.INT32],[BigInt64Array.name,r.INT64]])),i(r,"DENSITIES",new Map([[r.UINT8.toString(),I.BIT8],[r.UINT16.toString(),I.BIT16],[r.UINT32.toString(),I.BIT32],[r.UINT64.toString(),I.BIT64],[r.FLOAT32.toString(),I.BIT32],[r.FLOAT64.toString(),I.BIT64],[r.INT8.toString(),I.BIT8],[r.INT16.toString(),I.BIT16],[r.INT32.toString(),I.BIT32],[r.INT64.toString(),I.BIT64],[r.TIMESTAMP.toString(),I.BIT64],[r.STRING.toString(),I.UNKNOWN],[r.JSON.toString(),I.UNKNOWN],[r.UUID.toString(),I.BIT128]])),i(r,"ALL",[r.UNKNOWN,r.FLOAT64,r.FLOAT32,r.INT64,r.INT32,r.INT16,r.INT8,r.UINT64,r.UINT32,r.UINT16,r.UINT8,r.TIMESTAMP,r.UUID,r.STRING,r.JSON]),i(r,"BIG_INT_TYPES",[r.INT64,r.UINT64,r.TIMESTAMP]),i(r,"z",o.z.union([o.z.string().transform(t=>new r(t)),o.z.instanceof(r)]));let g=r;const d=class d extends Number{constructor(t){super(t.valueOf())}largerThan(t){return this.valueOf()>t.valueOf()}smallerThan(t){return this.valueOf()<t.valueOf()}add(t){return d.bytes(this.valueOf()+t.valueOf())}sub(t){return d.bytes(this.valueOf()-t.valueOf())}truncate(t){return new d(Math.trunc(this.valueOf()/t.valueOf())*t.valueOf())}remainder(t){return d.bytes(this.valueOf()%t.valueOf())}get gigabytes(){return this.valueOf()/d.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/d.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/d.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/d.TERABYTE.valueOf()}toString(){const t=this.truncate(d.TERABYTE),e=this.truncate(d.GIGABYTE),n=this.truncate(d.MEGABYTE),s=this.truncate(d.KILOBYTE),c=this.truncate(d.BYTE),f=t,v=e.sub(t),O=n.sub(e),N=s.sub(n),A=c.sub(s);let h="";return f.isZero||(h+=`${f.terabytes}TB `),v.isZero||(h+=`${v.gigabytes}GB `),O.isZero||(h+=`${O.megabytes}MB `),N.isZero||(h+=`${N.kilobytes}KB `),(!A.isZero||h==="")&&(h+=`${A.valueOf()}B`),h.trim()}static bytes(t=1){return new d(t)}static kilobytes(t=1){return d.bytes(t.valueOf()*1e3)}static megabytes(t=1){return d.kilobytes(t.valueOf()*1e3)}static gigabytes(t=1){return d.megabytes(t.valueOf()*1e3)}static terabytes(t){return d.gigabytes(t.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};i(d,"BYTE",new d(1)),i(d,"KILOBYTE",d.kilobytes(1)),i(d,"MEGABYTE",d.megabytes(1)),i(d,"GIGABYTE",d.gigabytes(1)),i(d,"TERABYTE",d.terabytes(1)),i(d,"ZERO",new d(0)),i(d,"z",o.z.union([o.z.number().transform(t=>new d(t)),o.z.instanceof(d)]));let U=d;const ot=o.z.union([o.z.instanceof(Uint8Array),o.z.instanceof(Uint16Array),o.z.instanceof(Uint32Array),o.z.instanceof(BigUint64Array),o.z.instanceof(Float32Array),o.z.instanceof(Float64Array),o.z.instanceof(Int8Array),o.z.instanceof(Int16Array),o.z.instanceof(Int32Array),o.z.instanceof(BigInt64Array)]),F=l=>{const t=typeof l;return t==="string"||t==="number"||t==="boolean"||t==="bigint"||l instanceof m||l instanceof y||l instanceof Date},X=(l,t,e,n=0)=>l.usesBigInt&&!t.usesBigInt?Number(e)-Number(n):!l.usesBigInt&&t.usesBigInt?BigInt(e.valueOf())-BigInt(n.valueOf()):x(e,-n).valueOf(),Q=l=>l==null?!1:Array.isArray(l)||l instanceof ArrayBuffer||ArrayBuffer.isView(l)&&!(l instanceof DataView)||l instanceof z?!0:F(l),E=-1,$={[Symbol.iterator]:()=>$,next:()=>({done:!0,value:void 0})},lt=o.z.string().transform(l=>new Uint8Array(atob(l).split("").map(t=>t.charCodeAt(0))).buffer),ct=o.z.union([o.z.null(),o.z.undefined()]).transform(()=>new Uint8Array().buffer),P=10,T=class T{constructor(t){i(this,"key","");i(this,"isSynnaxSeries",!0);i(this,"dataType");i(this,"sampleOffset");i(this,"gl");i(this,"_data");i(this,"_timeRange");i(this,"alignment",0n);i(this,"_cachedMin");i(this,"_cachedMax");i(this,"writePos",E);i(this,"_refCount",0);i(this,"_cachedLength");i(this,"_cachedIndexes");Q(t)&&(t={data:t});const{dataType:e,timeRange:n,sampleOffset:s=0,glBufferUsage:c="static",alignment:f=0n,key:v=K()}=t,O=t.data??[];if(O instanceof T||typeof O=="object"&&"isSynnaxSeries"in O&&O.isSynnaxSeries===!0){const h=O;this.key=h.key,this.dataType=h.dataType,this.sampleOffset=h.sampleOffset,this.gl=h.gl,this._data=h._data,this._timeRange=h._timeRange,this.alignment=h.alignment,this._cachedMin=h._cachedMin,this._cachedMax=h._cachedMax,this.writePos=h.writePos,this._refCount=h._refCount,this._cachedLength=h._cachedLength;return}const N=F(O),A=Array.isArray(O);if(e!=null)this.dataType=new g(e);else{if(O instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(A||N){let h=O;if(!N){if(O.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");h=O[0]}if(typeof h=="string")this.dataType=g.STRING;else if(typeof h=="number")this.dataType=g.FLOAT64;else if(typeof h=="bigint")this.dataType=g.INT64;else if(typeof h=="boolean")this.dataType=g.BOOLEAN;else if(h instanceof m||h instanceof Date||h instanceof m)this.dataType=g.TIMESTAMP;else if(typeof h=="object")this.dataType=g.JSON;else throw new Error(`cannot infer data type of ${typeof h} when constructing a Series from a JS array`)}else this.dataType=new g(O)}if(!A&&!N)this._data=O;else{let h=N?[O]:O;const R=h[0];(R instanceof m||R instanceof Date||R instanceof y)&&(h=h.map(C=>new m(C).valueOf())),this.dataType.equals(g.STRING)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.join(`
|
|
2
|
+
`)+`
|
|
3
|
+
`)):this.dataType.equals(g.JSON)?(this._cachedLength=h.length,this._data=new TextEncoder().encode(h.map(C=>D.JSON_CODEC.encodeString(C)).join(`
|
|
4
|
+
`)+`
|
|
5
|
+
`)):this._data=new this.dataType.Array(h).buffer}this.key=v,this.alignment=f,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:c}}static alloc({capacity:t,dataType:e,...n}){if(t===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new g(e).Array(t),c=new T({data:s.buffer,dataType:e,...n});return c.writePos=0,c}static generateTimestamps(t,e,n){const s=n.spanRange(e.span(t)),c=new BigInt64Array(t);for(let f=0;f<t;f++)c[f]=BigInt(n.add(e.span(f)).valueOf());return new T({data:c,dataType:g.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(t,e){const n=new TextEncoder().encode(t.join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`);return new T({data:n,dataType:g.STRING,timeRange:e})}static fromJSON(t,e){const n=new TextEncoder().encode(t.map(s=>D.JSON_CODEC.encodeString(s)).join(`
|
|
8
|
+
`)+`
|
|
9
|
+
`);return new T({data:n,dataType:g.JSON,timeRange:e})}acquire(t){this._refCount++,t!=null&&this.updateGLBuffer(t)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(t){if(!t.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");return this.dataType.isVariable?this.writeVariable(t):this.writeFixed(t)}writeVariable(t){if(this.writePos===E)return 0;const e=this.byteCapacity.valueOf()-this.writePos,n=t.subBytes(0,e);return this.writeToUnderlyingData(n),this.writePos+=n.byteLength.valueOf(),this._cachedLength!=null&&(this._cachedLength+=n.length,this.calculateCachedLength()),n.length}writeFixed(t){if(this.writePos===E)return 0;const e=this.capacity-this.writePos,n=t.sub(0,e);return this.writeToUnderlyingData(n),this._cachedLength=void 0,this.maybeRecomputeMinMax(n),this.writePos+=n.length,n.length}writeToUnderlyingData(t){this.underlyingData.set(t.data,this.writePos)}get buffer(){return this._data instanceof ArrayBuffer||this._data instanceof SharedArrayBuffer?this._data:this._data.buffer}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===E?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.matches(g.STRING,g.UUID))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
10
|
+
`).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(g.UUID))throw new Error("cannot convert non-uuid series to uuids");const t=g.UUID.density.valueOf(),e=Array(this.length);for(let n=0;n<this.length;n++){const s=this.underlyingData.slice(n*t,(n+1)*t),c=Array.from(new Uint8Array(s),f=>f.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");e[n]=c}return e}parseJSON(t){if(!this.dataType.equals(g.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.underlyingData).split(`
|
|
11
|
+
`).slice(0,-1).map(e=>t.parse(D.JSON_CODEC.decodeString(e)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new U(this.underlyingData.byteLength)}get capacity(){return this.dataType.isVariable?this.byteCapacity.valueOf():this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===E?this.byteCapacity:this.dataType.isVariable?new U(this.writePos):this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===E?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let t=0;const e=[0];return this.data.forEach((n,s)=>{n===P&&(t++,e.push(s+1))}),this._cachedIndexes=e,this._cachedLength=t,t}convert(t,e=0){if(this.dataType.equals(t))return this;const n=new t.Array(this.length);for(let s=0;s<this.length;s++)n[s]=X(this.dataType,t,this.data[s],e);return new T({data:n.buffer,dataType:t,timeRange:this._timeRange,sampleOffset:e,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}else{const t=this.data;this._cachedMax=t.reduce((e,n)=>e>n?e:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),x(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(g.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}else{const t=this.data;this._cachedMin=t.reduce((e,n)=>e<n?e:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),x(this._cachedMin,this.sampleOffset))}get bounds(){return w.construct(Number(this.min),Number(this.max))}maybeRecomputeMinMax(t){if(this._cachedMin!=null){const e=t._cachedMin??t.calcRawMin();e<this._cachedMin&&(this._cachedMin=e)}if(this._cachedMax!=null){const e=t._cachedMax??t.calcRawMax();e>this._cachedMax&&(this._cachedMax=e)}}enrich(){this.max,this.min}get range(){return x(this.max,-this.min)}atAlignment(t,e){const n=Number(t-this.alignment);if(n<0||n>=this.length){if(e===!0)throw new Error(`[series] - no value at index ${n}`);return}return this.at(n,e)}at(t,e){if(this.dataType.isVariable)return this.atVariable(t,e??!1);t<0&&(t=this.length+t);const n=this.data[t];if(n==null){if(e===!0)throw new Error(`[series] - no value at index ${t}`);return}return x(n,this.sampleOffset)}atVariable(t,e){let n=0,s=0;if(this._cachedIndexes!=null)n=this._cachedIndexes[t],s=this._cachedIndexes[t+1]-1;else{t<0&&(t=this.length+t);for(let f=0;f<this.data.length;f++)if(this.data[f]===P){if(t===0){s=f;break}n=f+1,t--}if(s===0&&(s=this.data.length),n>=s||t>0){if(e)throw new Error(`[series] - no value at index ${t}`);return}}const c=this.data.slice(n,s);return this.dataType.equals(g.STRING)?new TextDecoder().decode(c):et.snakeToCamel(JSON.parse(new TextDecoder().decode(c)))}binarySearch(t){let e=0,n=this.length-1;const s=nt.newF(t);for(;e<=n;){const c=Math.floor((e+n)/2),f=s(this.at(c,!0),t);if(f===0)return c;f<0?e=c+1:n=c-1}return e}updateGLBuffer(t){if(this.gl.control=t,!this.dataType.equals(g.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:e,bufferUsage:n,prevBuffer:s}=this.gl;if(e==null&&(this.gl.buffer=t.createBuffer()),this.writePos!==s)if(t.bindBuffer(t.ARRAY_BUFFER,this.gl.buffer),this.writePos!==E){s===0&&t.bufferData(t.ARRAY_BUFFER,this.byteCapacity.valueOf(),t.STATIC_DRAW);const c=this.dataType.density.size(s).valueOf(),f=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);t.bufferSubData(t.ARRAY_BUFFER,c,f.buffer),this.gl.prevBuffer=this.writePos}else t.bufferData(t.ARRAY_BUFFER,this.underlyingData,n==="static"?t.STATIC_DRAW:t.DYNAMIC_DRAW),this.gl.prevBuffer=E}as(t){if(t==="string"){if(!this.dataType.equals(g.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(t==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(t==="bigint"){if(!this.dataType.equals(g.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${t}`)}get digest(){var t;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(t=this._timeRange)==null?void 0:t.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return w.construct(this.alignment,this.alignment+BigInt(this.length))}maybeGarbageCollectGLBuffer(t){this.gl.buffer!=null&&(t.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const t=new ht(this);return this.dataType.equals(g.JSON)?new ft(t):t}return new dt(this)}slice(t,e){return this.sliceSub(!1,t,e)}sub(t,e){return this.sliceSub(!0,t,e)}subIterator(t,e){return new V(this,t,e??this.length)}subAlignmentIterator(t,e){return new V(this,Number(t-this.alignment),Number(e-this.alignment))}subBytes(t,e){if(t>=0&&(e==null||e>=this.byteLength.valueOf()))return this;const n=this.data.subarray(t,e);return new T({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(t)})}sliceSub(t,e,n){if(e<=0&&(n==null||n>=this.length))return this;let s;return t?s=this.data.subarray(e,n):s=this.data.slice(e,n),new T({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+BigInt(e)})}reAlign(t){return new T({data:this.buffer,dataType:this.dataType,timeRange:M.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:t})}};i(T,"crudeZ",o.z.object({timeRange:M.z.optional(),dataType:g.z,alignment:rt.bigInt.optional(),data:o.z.union([lt,ct,o.z.instanceof(ArrayBuffer)]),glBufferUsage:ut.optional().default("static").optional()})),i(T,"z",T.crudeZ.transform(t=>new T(t)));let z=T;class V{constructor(t,e,n){i(this,"series");i(this,"end");i(this,"index");this.series=t;const s=w.construct(0,t.length);this.end=w.clamp(s,n),this.index=w.clamp(s,e)}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}class ht{constructor(t){i(this,"series");i(this,"index");i(this,"decoder");if(!t.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=t,this.index=0,this.decoder=new TextDecoder}next(){const t=this.index,e=this.series.data;for(;this.index<e.length&&e[this.index]!==P;)this.index++;const n=this.index;return t===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(t,n))})}[Symbol.iterator](){return this}}var Z,k;class ft{constructor(t){i(this,"wrapped");i(this,Z,"JSONSeriesIterator");this.wrapped=t}next(){const t=this.wrapped.next();return t.done===!0?{done:!0,value:void 0}:{done:!1,value:D.JSON_CODEC.decodeString(t.value)}}[(k=Symbol.iterator,Z=Symbol.toStringTag,k)](){return this}}var G,J;class dt{constructor(t){i(this,"series");i(this,"index");i(this,G,"SeriesIterator");this.series=t,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[(J=Symbol.iterator,G=Symbol.toStringTag,J)](){return this}}const x=(l,t)=>typeof l=="bigint"&&typeof t=="bigint"||typeof l=="number"&&typeof t=="number"?l+t:t===0?l:l===0?t:Number(l)+Number(t);class gt{constructor(t){i(this,"series");if(t.length!==0){const e=t[0].dataType;for(let n=1;n<t.length;n++)if(!t[n].dataType.equals(e))throw new Error("[multi-series] - series must have the same data type")}this.series=t}as(t){if(!new g(t).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${t.toString()}`);return this}get dataType(){return this.series.length===0?g.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?M.ZERO:new M(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}get alignment(){return this.series.length===0?0n:this.series[0].alignment}get alignmentBounds(){return this.series.length===0?w.construct(0n,0n):w.construct(this.series[0].alignmentBounds.lower,this.series[this.series.length-1].alignmentBounds.upper)}push(t){this.series.push(t)}get length(){return this.series.reduce((t,e)=>t+e.length,0)}atAlignment(t,e){if(this.series.length===0){if(e)throw new Error(`[series] - no value at alignment ${t}`);return}for(const n of this.series)if(w.contains(n.alignmentBounds,t))return n.atAlignment(t,e);if(e)throw new Error(`[series] - no value at alignment ${t}`)}at(t,e=!1){t<0&&(t=this.length+t);for(const n of this.series){if(t<n.length)return n.at(t,e);t-=n.length}if(e)throw new Error(`[series] - no value at index ${t}`)}subIterator(t,e){return new q(this,t,e??this.length)}subAlignmentIterator(t,e){if(t>=this.alignmentBounds.upper||e<=this.alignmentBounds.lower)return $;let n=0;for(let c=0;c<this.series.length;c++){const f=this.series[c];if(t<f.alignment)break;if(t>=f.alignmentBounds.upper)n+=f.length;else if(w.contains(f.alignmentBounds,t)){n+=Number(t-f.alignment);break}}let s=0;for(let c=0;c<this.series.length;c++){const f=this.series[c];if(e<f.alignment)break;if(e>=f.alignmentBounds.upper)s+=f.length;else if(w.contains(f.alignmentBounds,e)){s+=Number(e-f.alignment);break}}return new q(this,n,s)}subAlignmentSpanIterator(t,e){if(t>=this.alignmentBounds.upper)return $;let n=0;for(let s=0;s<this.series.length;s++){const c=this.series[s];if(t<c.alignment)break;if(t>=c.alignmentBounds.upper)n+=c.length;else if(w.contains(c.alignmentBounds,t)){n+=Number(t-c.alignment);break}}return new q(this,n,n+e)}get byteLength(){return new U(this.series.reduce((t,e)=>t+e.byteLength.valueOf(),0))}get data(){const t=new this.dataType.Array(this.length);let e=0;for(const n of this.series)t.set(n.data,e),e+=n.length;return new this.dataType.Array(t)}traverseAlignment(t,e){const n=this.series.map(s=>s.alignmentBounds);return w.traverse(n,t,e)}distance(t,e){const n=this.series.map(s=>s.alignmentBounds);return w.distance(n,t,e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new mt(this.series)}}var W,j;class mt{constructor(t){i(this,"series");i(this,"seriesIndex");i(this,"internal");i(this,W,"MultiSeriesIterator");this.series=t,this.seriesIndex=0,this.internal=t[0][Symbol.iterator]()}next(){const t=this.internal.next();return t.done===!1?t:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[(j=Symbol.iterator,W=Symbol.toStringTag,j)](){return this}}class q{constructor(t,e,n){i(this,"series");i(this,"index");i(this,"end");this.series=t,this.end=n,this.index=e}next(){return this.index>=this.end?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}exports.DataType=g;exports.Density=I;exports.MultiSeries=gt;exports.Rate=L;exports.Series=z;exports.Size=U;exports.TimeRange=M;exports.TimeSpan=y;exports.TimeStamp=m;exports.addSamples=x;exports.convertDataType=X;exports.id=at;exports.isCrudeSeries=Q;exports.isTelemValue=F;exports.typedArrayZ=ot;
|