@milaboratories/pl-model-common 1.15.9 → 1.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/{base32-encode.d.ts → base32_encode.d.ts} +1 -1
  2. package/dist/{base32-encode.d.ts.map → base32_encode.d.ts.map} +1 -1
  3. package/dist/bmodel/block_config.d.ts +42 -0
  4. package/dist/bmodel/block_config.d.ts.map +1 -0
  5. package/dist/bmodel/code.d.ts +11 -0
  6. package/dist/bmodel/code.d.ts.map +1 -0
  7. package/dist/bmodel/container.d.ts +46 -0
  8. package/dist/bmodel/container.d.ts.map +1 -0
  9. package/dist/bmodel/index.d.ts +6 -0
  10. package/dist/bmodel/index.d.ts.map +1 -0
  11. package/dist/bmodel/normalization.d.ts +10 -0
  12. package/dist/bmodel/normalization.d.ts.map +1 -0
  13. package/dist/{block.d.ts → bmodel/types.d.ts} +1 -1
  14. package/dist/bmodel/types.d.ts.map +1 -0
  15. package/dist/drivers/pframe/table_calculate.d.ts +8 -2
  16. package/dist/drivers/pframe/table_calculate.d.ts.map +1 -1
  17. package/dist/flags/block_flags.d.ts +20 -0
  18. package/dist/flags/block_flags.d.ts.map +1 -0
  19. package/dist/flags/flag_utils.d.ts +56 -0
  20. package/dist/flags/flag_utils.d.ts.map +1 -0
  21. package/dist/flags/index.d.ts +4 -0
  22. package/dist/flags/index.d.ts.map +1 -0
  23. package/dist/flags/type_utils.d.ts +35 -0
  24. package/dist/flags/type_utils.d.ts.map +1 -0
  25. package/dist/index.d.ts +3 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +732 -577
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +3 -3
  32. package/src/bmodel/block_config.ts +69 -0
  33. package/src/bmodel/code.ts +12 -0
  34. package/src/bmodel/container.ts +58 -0
  35. package/src/bmodel/index.ts +5 -0
  36. package/src/bmodel/normalization.ts +111 -0
  37. package/src/drivers/pframe/table_calculate.ts +10 -1
  38. package/src/flags/block_flags.ts +43 -0
  39. package/src/flags/flag_utils.test.ts +162 -0
  40. package/src/flags/flag_utils.ts +104 -0
  41. package/src/flags/index.ts +3 -0
  42. package/src/flags/type_utils.ts +43 -0
  43. package/src/index.ts +3 -1
  44. package/src/plid.ts +1 -1
  45. package/dist/block.d.ts.map +0 -1
  46. /package/src/{base32-encode.ts → base32_encode.ts} +0 -0
  47. /package/src/{block.ts → bmodel/types.ts} +0 -0
package/dist/index.mjs CHANGED
@@ -1,319 +1,401 @@
1
- var B = Object.defineProperty;
2
- var j = (n, e, t) => e in n ? B(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var l = (n, e, t) => j(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { z as d } from "zod";
5
- import y from "canonicalize";
6
- const wn = d.object({
1
+ var D = Object.defineProperty;
2
+ var L = (e, n, t) => n in e ? D(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var l = (e, n, t) => L(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { z as p } from "zod";
5
+ import h from "canonicalize";
6
+ function ke(e) {
7
+ if (e.code !== void 0)
8
+ return {
9
+ code: e.code,
10
+ sdkVersion: e.sdkVersion,
11
+ featureFlags: e.featureFlags
12
+ };
13
+ }
14
+ function m(e) {
15
+ if (e !== void 0)
16
+ return typeof e == "string" ? { __renderLambda: !0, handle: e, retentive: !1 } : e;
17
+ }
18
+ function xe(e) {
19
+ if (e.v3 !== void 0) {
20
+ const {
21
+ initialArgs: n,
22
+ initialUiState: t,
23
+ inputsValid: r,
24
+ outputs: o,
25
+ renderingMode: i,
26
+ sdkVersion: a,
27
+ featureFlags: s,
28
+ sections: u,
29
+ title: c,
30
+ enrichmentTargets: f
31
+ } = e.v3, { code: R } = e;
32
+ return {
33
+ initialArgs: n,
34
+ initialUiState: t,
35
+ inputsValid: r,
36
+ outputs: o,
37
+ renderingMode: i,
38
+ sdkVersion: a,
39
+ featureFlags: s,
40
+ sections: u,
41
+ title: c,
42
+ code: R,
43
+ enrichmentTargets: f
44
+ };
45
+ } else if (e.inputsValid !== void 0) {
46
+ const { sdkVersion: n, renderingMode: t, outputs: r, inputsValid: o, sections: i, initialArgs: a, code: s } = e, u = Object.keys(e);
47
+ if (n === void 0 || t === void 0 || r === void 0 || o === void 0 || i === void 0 || a === void 0)
48
+ throw new Error(
49
+ `Malformed config v2. SDK version ${n}; Fields = ${u.join(", ")}`
50
+ );
51
+ return {
52
+ sdkVersion: n,
53
+ renderingMode: t,
54
+ initialArgs: a,
55
+ outputs: Object.fromEntries(
56
+ Object.entries(r).map(([c, f]) => [c, m(f)])
57
+ ),
58
+ inputsValid: m(o),
59
+ sections: m(i),
60
+ initialUiState: void 0,
61
+ code: s
62
+ };
63
+ } else if (e.renderingMode !== void 0) {
64
+ const { sdkVersion: n, canRun: t, renderingMode: r, outputs: o, sections: i, initialArgs: a, code: s } = e, u = Object.keys(e);
65
+ if (r === void 0 || o === void 0 || t === void 0 || i === void 0 || a === void 0)
66
+ throw new Error(
67
+ `Malformed config v1. SDK version ${n}; Fields = ${u.join(", ")}`
68
+ );
69
+ return {
70
+ sdkVersion: n ?? "unknown",
71
+ renderingMode: r,
72
+ initialArgs: a,
73
+ outputs: Object.fromEntries(
74
+ Object.entries(o).map(([c, f]) => [c, m(f)])
75
+ ),
76
+ inputsValid: m(t),
77
+ sections: m(i),
78
+ initialUiState: void 0,
79
+ code: s
80
+ };
81
+ } else {
82
+ const { sdkVersion: n } = e, t = Object.keys(e);
83
+ throw new Error(
84
+ `Config format not supported: SDK = ${n}; Fields = ${t.join(", ")}`
85
+ );
86
+ }
87
+ }
88
+ const Pe = p.object({
7
89
  /** Included left border. */
8
- from: d.number(),
90
+ from: p.number(),
9
91
  /** Excluded right border. */
10
- to: d.number()
92
+ to: p.number()
11
93
  });
12
- function An(n, e) {
13
- if (!(n == null || e == null))
14
- return { from: n, to: e };
15
- }
16
- function xn(n, e) {
17
- if (n.from < 0 || n.to < 0 || n.from >= n.to)
18
- throw new Error(`${e}: invalid bytes range: ${n}`);
19
- }
20
- function Pn(n) {
21
- return n !== void 0 && n.startsWith("log+live://log/");
22
- }
23
- function w(n) {
24
- throw new Error("Unexpected object: " + n);
25
- }
26
- const S = "upload://upload/", C = "index://index/";
27
- function v(n) {
28
- return n.startsWith(S);
29
- }
30
- function F(n) {
31
- return n.startsWith(C);
32
- }
33
- function R(n) {
34
- if (F(n)) {
35
- const e = n.slice(C.length);
36
- return JSON.parse(decodeURIComponent(e)).path;
37
- } else if (v(n)) {
38
- const e = n.slice(S.length);
39
- return JSON.parse(decodeURIComponent(e)).localPath;
94
+ function Ee(e, n) {
95
+ if (!(e == null || n == null))
96
+ return { from: e, to: n };
97
+ }
98
+ function Se(e, n) {
99
+ if (e.from < 0 || e.to < 0 || e.from >= e.to)
100
+ throw new Error(`${n}: invalid bytes range: ${e}`);
101
+ }
102
+ function ve(e) {
103
+ return e !== void 0 && e.startsWith("log+live://log/");
104
+ }
105
+ function A(e) {
106
+ throw new Error("Unexpected object: " + e);
107
+ }
108
+ const N = "upload://upload/", O = "index://index/";
109
+ function B(e) {
110
+ return e.startsWith(N);
111
+ }
112
+ function U(e) {
113
+ return e.startsWith(O);
114
+ }
115
+ function K(e) {
116
+ if (U(e)) {
117
+ const n = e.slice(O.length);
118
+ return JSON.parse(decodeURIComponent(n)).path;
119
+ } else if (B(e)) {
120
+ const n = e.slice(N.length);
121
+ return JSON.parse(decodeURIComponent(n)).localPath;
40
122
  }
41
- w(n);
123
+ A(e);
42
124
  }
43
- function U(n) {
44
- return n.replace(/^.*[\\/]/, "");
125
+ function M(e) {
126
+ return e.replace(/^.*[\\/]/, "");
45
127
  }
46
- function kn(n) {
47
- return U(R(n));
128
+ function Ne(e) {
129
+ return M(K(e));
48
130
  }
49
- function En(n) {
50
- if (!n || typeof n != "object")
131
+ function Oe(e) {
132
+ if (!e || typeof e != "object")
51
133
  return !1;
52
- const e = n;
53
- if (!("type" in e))
134
+ const n = e;
135
+ if (!("type" in n))
54
136
  return !1;
55
- switch (e.type) {
137
+ switch (n.type) {
56
138
  case "Json":
57
- return typeof e.keyLength == "number" && e.data !== void 0 && typeof e.data == "object";
139
+ return typeof n.keyLength == "number" && n.data !== void 0 && typeof n.data == "object";
58
140
  case "JsonPartitioned":
59
- return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
141
+ return typeof n.partitionKeyLength == "number" && n.parts !== void 0 && typeof n.parts == "object";
60
142
  case "BinaryPartitioned":
61
- return typeof e.partitionKeyLength == "number" && e.parts !== void 0 && typeof e.parts == "object";
143
+ return typeof n.partitionKeyLength == "number" && n.parts !== void 0 && typeof n.parts == "object";
62
144
  default:
63
145
  return !1;
64
146
  }
65
147
  }
66
- function Nn(n, e) {
67
- if (n !== void 0)
68
- switch (n.type) {
148
+ function Ce(e, n) {
149
+ if (e !== void 0)
150
+ switch (e.type) {
69
151
  case "Json":
70
- return n;
152
+ return e;
71
153
  case "JsonPartitioned": {
72
154
  const t = {};
73
- for (const [r, o] of Object.entries(n.parts))
74
- t[r] = e(o);
155
+ for (const [r, o] of Object.entries(e.parts))
156
+ t[r] = n(o);
75
157
  return {
76
- ...n,
158
+ ...e,
77
159
  parts: t
78
160
  };
79
161
  }
80
162
  case "BinaryPartitioned": {
81
163
  const t = {};
82
- for (const [r, o] of Object.entries(n.parts))
164
+ for (const [r, o] of Object.entries(e.parts))
83
165
  t[r] = {
84
- index: e(o.index),
85
- values: e(o.values)
166
+ index: n(o.index),
167
+ values: n(o.values)
86
168
  };
87
169
  return {
88
- ...n,
170
+ ...e,
89
171
  parts: t
90
172
  };
91
173
  }
92
174
  }
93
175
  }
94
- function K(n) {
95
- if (!n || typeof n != "object")
176
+ function _(e) {
177
+ if (!e || typeof e != "object")
96
178
  return !1;
97
- const e = n;
98
- if (!("type" in e))
179
+ const n = e;
180
+ if (!("type" in n))
99
181
  return !1;
100
- switch (e.type) {
182
+ switch (n.type) {
101
183
  case "Json":
102
- return typeof e.keyLength == "number" && Array.isArray(e.data);
184
+ return typeof n.keyLength == "number" && Array.isArray(n.data);
103
185
  case "JsonPartitioned":
104
- return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
186
+ return typeof n.partitionKeyLength == "number" && Array.isArray(n.parts);
105
187
  case "BinaryPartitioned":
106
- return typeof e.partitionKeyLength == "number" && Array.isArray(e.parts);
188
+ return typeof n.partitionKeyLength == "number" && Array.isArray(n.parts);
107
189
  default:
108
190
  return !1;
109
191
  }
110
192
  }
111
- function Sn(n) {
112
- return K(n) ? n.type === "JsonPartitioned" || n.type === "BinaryPartitioned" : !1;
193
+ function $e(e) {
194
+ return _(e) ? e.type === "JsonPartitioned" || e.type === "BinaryPartitioned" : !1;
113
195
  }
114
- function Cn(n) {
115
- switch (n.type) {
196
+ function Ve(e) {
197
+ switch (e.type) {
116
198
  case "Json": {
117
- const e = Object.entries(n.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
199
+ const n = Object.entries(e.data).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
118
200
  return {
119
201
  type: "Json",
120
- keyLength: n.keyLength,
121
- data: e
202
+ keyLength: e.keyLength,
203
+ data: n
122
204
  };
123
205
  }
124
206
  case "JsonPartitioned": {
125
- const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
207
+ const n = Object.entries(e.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
126
208
  return {
127
209
  type: "JsonPartitioned",
128
- partitionKeyLength: n.partitionKeyLength,
129
- parts: e
210
+ partitionKeyLength: e.partitionKeyLength,
211
+ parts: n
130
212
  };
131
213
  }
132
214
  case "BinaryPartitioned": {
133
- const e = Object.entries(n.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
215
+ const n = Object.entries(e.parts).map(([t, r]) => ({ key: JSON.parse(t), value: r }));
134
216
  return {
135
217
  type: "BinaryPartitioned",
136
- partitionKeyLength: n.partitionKeyLength,
137
- parts: e
218
+ partitionKeyLength: e.partitionKeyLength,
219
+ parts: n
138
220
  };
139
221
  }
140
222
  }
141
223
  }
142
- function Jn(n) {
143
- switch (n.type) {
224
+ function Ie(e) {
225
+ switch (e.type) {
144
226
  case "Json": {
145
- const e = {};
146
- for (const t of n.data)
147
- e[JSON.stringify(t.key)] = t.value;
227
+ const n = {};
228
+ for (const t of e.data)
229
+ n[JSON.stringify(t.key)] = t.value;
148
230
  return {
149
231
  type: "Json",
150
- keyLength: n.keyLength,
151
- data: e
232
+ keyLength: e.keyLength,
233
+ data: n
152
234
  };
153
235
  }
154
236
  case "JsonPartitioned": {
155
- const e = {};
156
- for (const t of n.parts)
157
- e[JSON.stringify(t.key)] = t.value;
237
+ const n = {};
238
+ for (const t of e.parts)
239
+ n[JSON.stringify(t.key)] = t.value;
158
240
  return {
159
241
  type: "JsonPartitioned",
160
- partitionKeyLength: n.partitionKeyLength,
161
- parts: e
242
+ partitionKeyLength: e.partitionKeyLength,
243
+ parts: n
162
244
  };
163
245
  }
164
246
  case "BinaryPartitioned": {
165
- const e = {};
166
- for (const t of n.parts)
167
- e[JSON.stringify(t.key)] = t.value;
247
+ const n = {};
248
+ for (const t of e.parts)
249
+ n[JSON.stringify(t.key)] = t.value;
168
250
  return {
169
251
  type: "BinaryPartitioned",
170
- partitionKeyLength: n.partitionKeyLength,
171
- parts: e
252
+ partitionKeyLength: e.partitionKeyLength,
253
+ parts: n
172
254
  };
173
255
  }
174
256
  }
175
257
  }
176
- function On(n, e) {
177
- if (n !== void 0)
178
- switch (n.type) {
258
+ function je(e, n) {
259
+ if (e !== void 0)
260
+ switch (e.type) {
179
261
  case "Json":
180
- return n;
262
+ return e;
181
263
  case "JsonPartitioned": {
182
- const t = n.parts.map((r) => ({
264
+ const t = e.parts.map((r) => ({
183
265
  key: r.key,
184
- value: e(r.value)
266
+ value: n(r.value)
185
267
  }));
186
268
  return {
187
- ...n,
269
+ ...e,
188
270
  parts: t
189
271
  };
190
272
  }
191
273
  case "BinaryPartitioned": {
192
- const t = n.parts.map((r) => ({
274
+ const t = e.parts.map((r) => ({
193
275
  key: r.key,
194
276
  value: {
195
- index: e(r.value.index),
196
- values: e(r.value.values)
277
+ index: n(r.value.index),
278
+ values: n(r.value.values)
197
279
  }
198
280
  }));
199
281
  return {
200
- ...n,
282
+ ...e,
201
283
  parts: t
202
284
  };
203
285
  }
204
286
  }
205
287
  }
206
- const _ = -2147483648, x = -9007199254740991n, $n = NaN, In = NaN, M = null, T = null;
207
- function g(n, e) {
208
- switch (e) {
288
+ const q = -2147483648, x = -9007199254740991n, Fe = NaN, Je = NaN, T = null, z = null;
289
+ function b(e, n) {
290
+ switch (n) {
209
291
  case "Int":
210
- return n === _;
292
+ return e === q;
211
293
  case "Long":
212
- return n === Number(x) || n === x;
294
+ return e === Number(x) || e === x;
213
295
  case "Float":
214
- return Number.isNaN(n);
296
+ return Number.isNaN(e);
215
297
  case "Double":
216
- return Number.isNaN(n);
298
+ return Number.isNaN(e);
217
299
  case "String":
218
- return n === M;
300
+ return e === T;
219
301
  case "Bytes":
220
- return n === T;
302
+ return e === z;
221
303
  default:
222
- throw Error(`unsupported data type: ${e}`);
304
+ throw Error(`unsupported data type: ${n}`);
223
305
  }
224
306
  }
225
- function Vn(n) {
226
- if (!z(n)) throw new Error(`Expected not-NA PValue, got ${n}`);
227
- return n;
307
+ function Re(e) {
308
+ if (!H(e)) throw new Error(`Expected not-NA PValue, got ${e}`);
309
+ return e;
228
310
  }
229
- function z(n, e) {
230
- if (!e)
231
- return typeof n == "string" || typeof n == "number" && isFinite(n) || typeof n == "bigint";
232
- if (g(n, e)) return !1;
233
- switch (e) {
311
+ function H(e, n) {
312
+ if (!n)
313
+ return typeof e == "string" || typeof e == "number" && isFinite(e) || typeof e == "bigint";
314
+ if (b(e, n)) return !1;
315
+ switch (n) {
234
316
  case "Int":
235
- return typeof n == "number";
317
+ return typeof e == "number";
236
318
  case "Long":
237
- return typeof n == "number" || typeof n == "bigint";
319
+ return typeof e == "number" || typeof e == "bigint";
238
320
  case "Float":
239
- return typeof n == "number";
321
+ return typeof e == "number";
240
322
  case "Double":
241
- return typeof n == "number";
323
+ return typeof e == "number";
242
324
  case "String":
243
- return typeof n == "string";
325
+ return typeof e == "string";
244
326
  case "Bytes":
245
327
  throw Error("Bytes not yet supported");
246
328
  default:
247
- throw Error(`unsupported data type: ${e}`);
329
+ throw Error(`unsupported data type: ${n}`);
248
330
  }
249
331
  }
250
- function H(n, e) {
251
- if (!e)
252
- return n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint";
253
- if (g(n, e)) return !0;
254
- switch (e) {
332
+ function W(e, n) {
333
+ if (!n)
334
+ return e === null || typeof e == "string" || typeof e == "number" || typeof e == "bigint";
335
+ if (b(e, n)) return !0;
336
+ switch (n) {
255
337
  case "Int":
256
- return typeof n == "number";
338
+ return typeof e == "number";
257
339
  case "Long":
258
- return typeof n == "number" || typeof n == "bigint";
340
+ return typeof e == "number" || typeof e == "bigint";
259
341
  case "Float":
260
- return typeof n == "number";
342
+ return typeof e == "number";
261
343
  case "Double":
262
- return typeof n == "number";
344
+ return typeof e == "number";
263
345
  case "String":
264
- return typeof n == "string";
346
+ return typeof e == "string";
265
347
  case "Bytes":
266
348
  throw Error("Bytes not yet supported");
267
349
  default:
268
- throw Error(`unsupported data type: ${e}`);
350
+ throw Error(`unsupported data type: ${n}`);
269
351
  }
270
352
  }
271
- function Dn(n) {
272
- if (n === null || typeof n == "string" || typeof n == "number") return n;
273
- if (typeof n == "bigint") return { bigint: n.toString() };
274
- throw new Error(`Type ${typeof n} (value ${n}) not yet supported.`);
353
+ function De(e) {
354
+ if (e === null || typeof e == "string" || typeof e == "number") return e;
355
+ if (typeof e == "bigint") return { bigint: e.toString() };
356
+ throw new Error(`Type ${typeof e} (value ${e}) not yet supported.`);
275
357
  }
276
- function q(n, e) {
277
- if (n === null || typeof n == "string" || typeof n == "number" || typeof n == "bigint") {
278
- if (e && !g(n, e) && !H(n, e))
279
- throw new Error(`Unexpected value type, got ${typeof n}, expected ${e}`);
280
- return n;
358
+ function G(e, n) {
359
+ if (e === null || typeof e == "string" || typeof e == "number" || typeof e == "bigint") {
360
+ if (n && !b(e, n) && !W(e, n))
361
+ throw new Error(`Unexpected value type, got ${typeof e}, expected ${n}`);
362
+ return e;
281
363
  }
282
- if (typeof n == "object" && n !== null && "bigint" in n && typeof n.bigint == "string") {
283
- if (e && e !== "Long")
284
- throw new Error(`Unexpected value type, got serialized bigint, expected ${e}`);
285
- return BigInt(n.bigint);
364
+ if (typeof e == "object" && e !== null && "bigint" in e && typeof e.bigint == "string") {
365
+ if (n && n !== "Long")
366
+ throw new Error(`Unexpected value type, got serialized bigint, expected ${n}`);
367
+ return BigInt(e.bigint);
286
368
  }
287
- throw new Error(`Unsupported type ${typeof n} (value ${n}).`);
369
+ throw new Error(`Unsupported type ${typeof e} (value ${e}).`);
288
370
  }
289
- function Ln(n) {
290
- if (n = W(n), n === null) throw new Error("Value is null");
291
- return n;
371
+ function Le(e) {
372
+ if (e = X(e), e === null) throw new Error("Value is null");
373
+ return e;
292
374
  }
293
- function W(n) {
294
- if (n = q(n), n === null) return null;
295
- if (typeof n == "string") return n;
296
- if (typeof n == "number") {
297
- if (!isFinite(n)) throw new Error(`Value is not finite (${n})`);
298
- return n;
375
+ function X(e) {
376
+ if (e = G(e), e === null) return null;
377
+ if (typeof e == "string") return e;
378
+ if (typeof e == "number") {
379
+ if (!isFinite(e)) throw new Error(`Value is not finite (${e})`);
380
+ return e;
299
381
  }
300
- if (typeof n == "bigint")
301
- return Number(n);
302
- throw new Error(`Unexpected value type: ${typeof n}`);
303
- }
304
- function X(n, e) {
305
- const t = Math.floor(e / 8), r = 1 << 7 - e % 8;
306
- return (n[t] & r) > 0;
307
- }
308
- const G = { type: "absent" }, Q = null;
309
- function Bn(n) {
310
- return typeof n == "object" && n !== null && n.type === "absent";
311
- }
312
- function jn(n, e, t = {}) {
313
- if (X(n.absent, e))
314
- return t.absent === void 0 ? G : t.absent;
315
- const r = n.data[e], o = n.type;
316
- if (g(r, o)) return t.na === void 0 ? Q : t.na;
382
+ if (typeof e == "bigint")
383
+ return Number(e);
384
+ throw new Error(`Unexpected value type: ${typeof e}`);
385
+ }
386
+ function Q(e, n) {
387
+ const t = Math.floor(n / 8), r = 1 << 7 - n % 8;
388
+ return (e[t] & r) > 0;
389
+ }
390
+ const Y = { type: "absent" }, Z = null;
391
+ function Be(e) {
392
+ return typeof e == "object" && e !== null && e.type === "absent";
393
+ }
394
+ function Ue(e, n, t = {}) {
395
+ if (Q(e.absent, n))
396
+ return t.absent === void 0 ? Y : t.absent;
397
+ const r = e.data[n], o = e.type;
398
+ if (b(r, o)) return t.na === void 0 ? Z : t.na;
317
399
  switch (o) {
318
400
  case "Int":
319
401
  return r;
@@ -331,109 +413,109 @@ function jn(n, e, t = {}) {
331
413
  throw Error(`unsupported data type: ${o}`);
332
414
  }
333
415
  }
334
- function vn(n) {
416
+ function Ke(e) {
335
417
  return {
336
- kind: n.kind,
337
- valueType: n.valueType,
338
- name: n.name,
339
- domain: n.domain,
340
- parentAxes: n.parentAxes,
341
- axesId: J(n.axesSpec)
418
+ kind: e.kind,
419
+ valueType: e.valueType,
420
+ name: e.name,
421
+ domain: e.domain,
422
+ parentAxes: e.parentAxes,
423
+ axesId: C(e.axesSpec)
342
424
  };
343
425
  }
344
- function Fn(n) {
426
+ function Me(e) {
345
427
  return {
346
- columnId: n.id,
347
- spec: n.spec
428
+ columnId: e.id,
429
+ spec: e.spec
348
430
  };
349
431
  }
350
- function p(n) {
351
- const { type: e, name: t, domain: r } = n, o = { type: e, name: t };
432
+ function y(e) {
433
+ const { type: n, name: t, domain: r } = e, o = { type: n, name: t };
352
434
  return r && Object.entries(r).length > 0 && Object.assign(o, { domain: r }), o;
353
435
  }
354
- function J(n) {
355
- return n.map(p);
436
+ function C(e) {
437
+ return e.map(y);
356
438
  }
357
- function Rn(n) {
358
- return y(p(n));
439
+ function _e(e) {
440
+ return h(y(e));
359
441
  }
360
- function Y(n, e) {
361
- if (n === void 0) return e === void 0;
362
- if (e === void 0) return !0;
363
- for (const t in e)
364
- if (n[t] !== e[t]) return !1;
442
+ function ee(e, n) {
443
+ if (e === void 0) return n === void 0;
444
+ if (n === void 0) return !0;
445
+ for (const t in n)
446
+ if (e[t] !== n[t]) return !1;
365
447
  return !0;
366
448
  }
367
- function Z(n, e) {
368
- return n.name === e.name && Y(n.domain, e.domain);
449
+ function ne(e, n) {
450
+ return e.name === n.name && ee(e.domain, n.domain);
369
451
  }
370
- function Un(n, e) {
371
- return { ...n, src: h(n.src, e) };
452
+ function qe(e, n) {
453
+ return { ...e, src: g(e.src, n) };
372
454
  }
373
- function h(n, e) {
374
- switch (n.type) {
455
+ function g(e, n) {
456
+ switch (e.type) {
375
457
  case "column":
376
458
  return {
377
459
  type: "column",
378
- column: e(n.column)
460
+ column: n(e.column)
379
461
  };
380
462
  case "slicedColumn":
381
463
  return {
382
464
  type: "slicedColumn",
383
- column: e(n.column),
384
- newId: n.newId,
385
- axisFilters: n.axisFilters
465
+ column: n(e.column),
466
+ newId: e.newId,
467
+ axisFilters: e.axisFilters
386
468
  };
387
469
  case "inlineColumn":
388
- return n;
470
+ return e;
389
471
  case "inner":
390
472
  case "full":
391
473
  return {
392
- type: n.type,
393
- entries: n.entries.map((t) => h(t, e))
474
+ type: e.type,
475
+ entries: e.entries.map((t) => g(t, n))
394
476
  };
395
477
  case "outer":
396
478
  return {
397
479
  type: "outer",
398
- primary: h(n.primary, e),
399
- secondary: n.secondary.map((t) => h(t, e))
480
+ primary: g(e.primary, n),
481
+ secondary: e.secondary.map((t) => g(t, n))
400
482
  };
401
483
  default:
402
- w(n);
484
+ A(e);
403
485
  }
404
486
  }
405
- function Kn(n) {
406
- switch (n.type) {
487
+ function Te(e) {
488
+ switch (e.type) {
407
489
  case "axis":
408
490
  return {
409
491
  type: "axis",
410
- id: n.id
492
+ id: e.id
411
493
  };
412
494
  case "column":
413
495
  return {
414
496
  type: "column",
415
- id: n.id
497
+ id: e.id
416
498
  };
417
499
  }
418
500
  }
419
- function nn(n) {
420
- return y(n);
501
+ function te(e) {
502
+ return h(e);
421
503
  }
422
- function _n(n) {
423
- return JSON.parse(n);
504
+ function ze(e) {
505
+ return JSON.parse(e);
424
506
  }
425
- function P(n) {
426
- return y(p(n));
507
+ function P(e) {
508
+ return h(y(e));
427
509
  }
428
- function k(n, e) {
429
- return JSON.stringify([n, e]);
510
+ function E(e, n) {
511
+ return JSON.stringify([e, n]);
430
512
  }
431
- class Mn {
513
+ class He {
432
514
  /**
433
515
  * Creates a new anchor context from a set of anchor column specifications
434
516
  * @param anchors Record of anchor column specifications indexed by anchor ID
435
517
  */
436
- constructor(e) {
518
+ constructor(n) {
437
519
  l(this, "domains", /* @__PURE__ */ new Map());
438
520
  l(this, "axes", /* @__PURE__ */ new Map());
439
521
  /**
@@ -445,19 +527,19 @@ class Mn {
445
527
  * Maps domain packs to anchors
446
528
  */
447
529
  l(this, "domainPackToAnchor", /* @__PURE__ */ new Map());
448
- this.anchors = e;
449
- const t = Object.entries(e);
530
+ this.anchors = n;
531
+ const t = Object.entries(n);
450
532
  t.sort((r, o) => r[0].localeCompare(o[0]));
451
533
  for (const [r, o] of t) {
452
- for (let s = 0; s < o.axesSpec.length; s++) {
453
- const a = o.axesSpec[s], i = P(a);
454
- this.axes.set(i, { anchor: r, idx: s });
534
+ for (let i = 0; i < o.axesSpec.length; i++) {
535
+ const a = o.axesSpec[i], s = P(a);
536
+ this.axes.set(s, { anchor: r, idx: i });
455
537
  }
456
538
  if (o.domain !== void 0) {
457
- const s = Object.entries(o.domain);
458
- s.sort((a, i) => a[0].localeCompare(i[0])), this.domainPackToAnchor.set(JSON.stringify(s), r), this.domainPacks.push(s.map(([a]) => a));
459
- for (const [a, i] of s) {
460
- const u = k(a, i);
539
+ const i = Object.entries(o.domain);
540
+ i.sort((a, s) => a[0].localeCompare(s[0])), this.domainPackToAnchor.set(JSON.stringify(i), r), this.domainPacks.push(i.map(([a]) => a));
541
+ for (const [a, s] of i) {
542
+ const u = E(a, s);
461
543
  this.domains.set(u, r);
462
544
  }
463
545
  }
@@ -466,57 +548,57 @@ class Mn {
466
548
  /**
467
549
  * Implementation of derive method
468
550
  */
469
- derive(e, t) {
551
+ derive(n, t) {
470
552
  const r = {
471
- name: e.name,
553
+ name: n.name,
472
554
  axes: []
473
555
  };
474
556
  let o;
475
- if (e.domain !== void 0)
476
- n:
557
+ if (n.domain !== void 0)
558
+ e:
477
559
  for (const a of this.domainPacks) {
478
- const i = [];
560
+ const s = [];
479
561
  for (const c of a) {
480
- const m = e.domain[c];
481
- if (m !== void 0)
482
- i.push([c, m]);
562
+ const f = n.domain[c];
563
+ if (f !== void 0)
564
+ s.push([c, f]);
483
565
  else
484
- break n;
566
+ break e;
485
567
  }
486
- const u = this.domainPackToAnchor.get(JSON.stringify(i));
568
+ const u = this.domainPackToAnchor.get(JSON.stringify(s));
487
569
  if (u !== void 0) {
488
570
  r.domainAnchor = u, o = new Set(a);
489
571
  break;
490
572
  }
491
573
  }
492
- for (const [a, i] of Object.entries(e.domain ?? {})) {
574
+ for (const [a, s] of Object.entries(n.domain ?? {})) {
493
575
  if (o !== void 0 && o.has(a))
494
576
  continue;
495
- const u = k(a, i), c = this.domains.get(u);
496
- r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : i;
577
+ const u = E(a, s), c = this.domains.get(u);
578
+ r.domain ?? (r.domain = {}), r.domain[a] = c ? { anchor: c } : s;
497
579
  }
498
- if (r.axes = e.axesSpec.map((a) => {
499
- const i = P(a), u = this.axes.get(i);
500
- return u === void 0 ? p(a) : u;
580
+ if (r.axes = n.axesSpec.map((a) => {
581
+ const s = P(a), u = this.axes.get(s);
582
+ return u === void 0 ? y(a) : u;
501
583
  }), !t || t.length === 0)
502
584
  return r;
503
- const s = [];
585
+ const i = [];
504
586
  for (const a of t) {
505
- const [i, u] = a;
506
- if (typeof i == "number") {
507
- if (i < 0 || i >= e.axesSpec.length)
508
- throw new Error(`Axis index ${i} is out of bounds (0-${e.axesSpec.length - 1})`);
509
- s.push([i, u]);
587
+ const [s, u] = a;
588
+ if (typeof s == "number") {
589
+ if (s < 0 || s >= n.axesSpec.length)
590
+ throw new Error(`Axis index ${s} is out of bounds (0-${n.axesSpec.length - 1})`);
591
+ i.push([s, u]);
510
592
  } else {
511
- const c = e.axesSpec.findIndex((m) => m.name === i);
593
+ const c = n.axesSpec.findIndex((f) => f.name === s);
512
594
  if (c === -1)
513
- throw new Error(`Axis with name "${i}" not found in the column specification`);
514
- s.push([c, u]);
595
+ throw new Error(`Axis with name "${s}" not found in the column specification`);
596
+ i.push([c, u]);
515
597
  }
516
598
  }
517
- return s.sort((a, i) => a[0] - i[0]), {
599
+ return i.sort((a, s) => a[0] - s[0]), {
518
600
  source: r,
519
- axisFilters: s
601
+ axisFilters: i
520
602
  };
521
603
  }
522
604
  /**
@@ -525,58 +607,58 @@ class Mn {
525
607
  * @param axisFilters Optional axis filters to apply to the column
526
608
  * @returns A canonicalized string representation of the anchored column identifier
527
609
  */
528
- deriveS(e, t) {
529
- return nn(this.derive(e, t));
610
+ deriveS(n, t) {
611
+ return te(this.derive(n, t));
530
612
  }
531
613
  }
532
- function Tn(n, e, t) {
533
- const r = { ...e }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
614
+ function We(e, n, t) {
615
+ const r = { ...n }, o = (t == null ? void 0 : t.ignoreMissingDomains) ?? !1;
534
616
  if (r.domainAnchor !== void 0) {
535
- const s = n[r.domainAnchor];
536
- if (!s)
617
+ const i = e[r.domainAnchor];
618
+ if (!i)
537
619
  throw new Error(`Anchor "${r.domainAnchor}" not found`);
538
- const a = s.domain || {};
620
+ const a = i.domain || {};
539
621
  r.domain = { ...a, ...r.domain }, delete r.domainAnchor;
540
622
  }
541
623
  if (r.domain) {
542
- const s = {};
543
- for (const [a, i] of Object.entries(r.domain))
544
- if (typeof i == "string")
545
- s[a] = i;
624
+ const i = {};
625
+ for (const [a, s] of Object.entries(r.domain))
626
+ if (typeof s == "string")
627
+ i[a] = s;
546
628
  else {
547
- const u = n[i.anchor];
629
+ const u = e[s.anchor];
548
630
  if (!u)
549
- throw new Error(`Anchor "${i.anchor}" not found for domain key "${a}"`);
631
+ throw new Error(`Anchor "${s.anchor}" not found for domain key "${a}"`);
550
632
  if (!u.domain || u.domain[a] === void 0) {
551
633
  if (!o)
552
- throw new Error(`Domain key "${a}" not found in anchor "${i.anchor}"`);
634
+ throw new Error(`Domain key "${a}" not found in anchor "${s.anchor}"`);
553
635
  continue;
554
636
  }
555
- s[a] = u.domain[a];
637
+ i[a] = u.domain[a];
556
638
  }
557
- r.domain = s;
639
+ r.domain = i;
558
640
  }
559
- return r.axes && (r.axes = r.axes.map((s) => en(n, s))), r;
641
+ return r.axes && (r.axes = r.axes.map((i) => re(e, i))), r;
560
642
  }
561
- function en(n, e) {
562
- if (!tn(e))
563
- return e;
564
- const t = e.anchor, r = n[t];
643
+ function re(e, n) {
644
+ if (!oe(n))
645
+ return n;
646
+ const t = n.anchor, r = e[t];
565
647
  if (!r)
566
648
  throw new Error(`Anchor "${t}" not found for axis reference`);
567
- if ("idx" in e) {
568
- if (e.idx < 0 || e.idx >= r.axesSpec.length)
569
- throw new Error(`Axis index ${e.idx} out of bounds for anchor "${t}"`);
570
- return r.axesSpec[e.idx];
571
- } else if ("name" in e) {
572
- const o = r.axesSpec.filter((s) => s.name === e.name);
649
+ if ("idx" in n) {
650
+ if (n.idx < 0 || n.idx >= r.axesSpec.length)
651
+ throw new Error(`Axis index ${n.idx} out of bounds for anchor "${t}"`);
652
+ return r.axesSpec[n.idx];
653
+ } else if ("name" in n) {
654
+ const o = r.axesSpec.filter((i) => i.name === n.name);
573
655
  if (o.length > 1)
574
- throw new Error(`Multiple axes with name "${e.name}" found in anchor "${t}"`);
656
+ throw new Error(`Multiple axes with name "${n.name}" found in anchor "${t}"`);
575
657
  if (o.length === 0)
576
- throw new Error(`Axis with name "${e.name}" not found in anchor "${t}"`);
658
+ throw new Error(`Axis with name "${n.name}" not found in anchor "${t}"`);
577
659
  return o[0];
578
- } else if ("id" in e) {
579
- const o = r.axesSpec.filter((s) => Z(e.id, p(s)));
660
+ } else if ("id" in n) {
661
+ const o = r.axesSpec.filter((i) => ne(n.id, y(i)));
580
662
  if (o.length > 1)
581
663
  throw new Error(`Multiple matching axes found for matcher in anchor "${t}"`);
582
664
  if (o.length === 0)
@@ -585,42 +667,42 @@ function en(n, e) {
585
667
  }
586
668
  throw new Error("Unsupported axis reference type");
587
669
  }
588
- function tn(n) {
589
- return typeof n == "object" && "anchor" in n;
670
+ function oe(e) {
671
+ return typeof e == "object" && "anchor" in e;
590
672
  }
591
- function zn(n) {
592
- return typeof n == "object" && n !== null && "source" in n && "axisFilters" in n;
673
+ function Ge(e) {
674
+ return typeof e == "object" && e !== null && "source" in e && "axisFilters" in e;
593
675
  }
594
- function f(n) {
595
- return n.kind === "PColumn";
676
+ function d(e) {
677
+ return e.kind === "PColumn";
596
678
  }
597
- function rn(n) {
598
- return f(n.spec);
679
+ function ie(e) {
680
+ return d(e.spec);
599
681
  }
600
- function Hn(n) {
601
- return f(n.obj);
682
+ function Xe(e) {
683
+ return d(e.obj);
602
684
  }
603
- function qn(n) {
604
- return f(n.obj.spec);
685
+ function Qe(e) {
686
+ return d(e.obj.spec);
605
687
  }
606
- function Wn(n) {
607
- if (!rn(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
608
- return n;
688
+ function Ye(e) {
689
+ if (!ie(e)) throw new Error(`not a PColumn (kind = ${e.spec.kind})`);
690
+ return e;
609
691
  }
610
- function Xn(n, e) {
611
- return n === void 0 ? void 0 : {
612
- ...n,
613
- data: e(n.data)
692
+ function Ze(e, n) {
693
+ return e === void 0 ? void 0 : {
694
+ ...e,
695
+ data: n(e.data)
614
696
  };
615
697
  }
616
- function Gn(n) {
617
- const e = /* @__PURE__ */ new Map(), t = (r) => {
698
+ function en(e) {
699
+ const n = /* @__PURE__ */ new Map(), t = (r) => {
618
700
  switch (r.type) {
619
701
  case "column":
620
- e.set(r.column.id, r.column);
702
+ n.set(r.column.id, r.column);
621
703
  return;
622
704
  case "slicedColumn":
623
- e.set(r.column.id, r.column);
705
+ n.set(r.column.id, r.column);
624
706
  return;
625
707
  case "inlineColumn":
626
708
  return;
@@ -633,390 +715,463 @@ function Gn(n) {
633
715
  for (const o of r.secondary) t(o);
634
716
  return;
635
717
  default:
636
- w(r);
718
+ A(r);
637
719
  }
638
720
  };
639
- return t(n), [...e.values()];
721
+ return t(e), [...n.values()];
640
722
  }
641
- function on(n) {
642
- throw new Error("Unexpected object: " + n);
723
+ function se(e) {
724
+ throw new Error("Unexpected object: " + e);
643
725
  }
644
- function b(n, e) {
645
- switch (n.type) {
726
+ function w(e, n) {
727
+ switch (e.type) {
646
728
  case "and":
647
- for (const t of n.operands)
648
- if (!b(t, e)) return !1;
729
+ for (const t of e.operands)
730
+ if (!w(t, n)) return !1;
649
731
  return !0;
650
732
  case "or":
651
- for (const t of n.operands)
652
- if (b(t, e)) return !0;
733
+ for (const t of e.operands)
734
+ if (w(t, n)) return !0;
653
735
  return !1;
654
736
  case "not":
655
- return !b(n.operand, e);
737
+ return !w(e.operand, n);
656
738
  case "name":
657
- return f(e) && e.name === n.name;
739
+ return d(n) && n.name === e.name;
658
740
  case "name_pattern":
659
- return f(e) && !!e.name.match(n.pattern);
741
+ return d(n) && !!n.name.match(e.pattern);
660
742
  case "annotation":
661
- return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] === n.value;
743
+ return d(n) && n.annotations !== void 0 && n.annotations[e.annotation] === e.value;
662
744
  case "annotation_pattern":
663
- return f(e) && e.annotations !== void 0 && e.annotations[n.annotation] !== void 0 && !!e.annotations[n.annotation].match(n.pattern);
745
+ return d(n) && n.annotations !== void 0 && n.annotations[e.annotation] !== void 0 && !!n.annotations[e.annotation].match(e.pattern);
664
746
  case "has_axes":
665
- return f(e) && n.axes.every(
666
- (t) => e.axesSpec.some(
747
+ return d(n) && e.axes.every(
748
+ (t) => n.axesSpec.some(
667
749
  (r) => (t.type === void 0 || t.type === r.type) && (t.name === void 0 || t.name === r.name) && (t.domain === void 0 || Object.keys(t.domain).length === 0 || r.domain !== void 0 && Object.entries(t.domain).every(
668
- ([o, s]) => r.domain[o] === s
750
+ ([o, i]) => r.domain[o] === i
669
751
  ))
670
752
  )
671
753
  );
672
754
  default:
673
- on(n);
755
+ se(e);
674
756
  }
675
757
  }
676
- function E(n, e) {
677
- if (n.name !== void 0 && n.name !== e.name)
758
+ function S(e, n) {
759
+ if (e.name !== void 0 && e.name !== n.name)
678
760
  return !1;
679
- if (n.type !== void 0) {
680
- if (Array.isArray(n.type)) {
681
- if (!n.type.includes(e.type))
761
+ if (e.type !== void 0) {
762
+ if (Array.isArray(e.type)) {
763
+ if (!e.type.includes(n.type))
682
764
  return !1;
683
- } else if (n.type !== e.type)
765
+ } else if (e.type !== n.type)
684
766
  return !1;
685
767
  }
686
- if (n.domain !== void 0) {
687
- const t = e.domain || {};
688
- for (const [r, o] of Object.entries(n.domain))
768
+ if (e.domain !== void 0) {
769
+ const t = n.domain || {};
770
+ for (const [r, o] of Object.entries(e.domain))
689
771
  if (t[r] !== o)
690
772
  return !1;
691
773
  }
692
774
  return !0;
693
775
  }
694
- function N(n, e) {
695
- if (e.name !== void 0 && n.name !== e.name || e.namePattern !== void 0 && !new RegExp(e.namePattern).test(n.name))
776
+ function v(e, n) {
777
+ if (n.name !== void 0 && e.name !== n.name || n.namePattern !== void 0 && !new RegExp(n.namePattern).test(e.name))
696
778
  return !1;
697
- if (e.type !== void 0) {
698
- if (Array.isArray(e.type)) {
699
- if (!e.type.includes(n.valueType))
779
+ if (n.type !== void 0) {
780
+ if (Array.isArray(n.type)) {
781
+ if (!n.type.includes(e.valueType))
700
782
  return !1;
701
- } else if (e.type !== n.valueType)
783
+ } else if (n.type !== e.valueType)
702
784
  return !1;
703
785
  }
704
- if (e.domain !== void 0) {
705
- const t = n.domain || {};
706
- for (const [r, o] of Object.entries(e.domain))
786
+ if (n.domain !== void 0) {
787
+ const t = e.domain || {};
788
+ for (const [r, o] of Object.entries(n.domain))
707
789
  if (t[r] !== o)
708
790
  return !1;
709
791
  }
710
- if (e.axes !== void 0) {
711
- const t = n.axesSpec.map(p);
712
- if (e.partialAxesMatch) {
713
- for (const r of e.axes)
714
- if (!t.some((o) => E(r, o)))
792
+ if (n.axes !== void 0) {
793
+ const t = e.axesSpec.map(y);
794
+ if (n.partialAxesMatch) {
795
+ for (const r of n.axes)
796
+ if (!t.some((o) => S(r, o)))
715
797
  return !1;
716
798
  } else {
717
- if (t.length !== e.axes.length)
799
+ if (t.length !== n.axes.length)
718
800
  return !1;
719
- for (let r = 0; r < e.axes.length; r++)
720
- if (!E(e.axes[r], t[r]))
801
+ for (let r = 0; r < n.axes.length; r++)
802
+ if (!S(n.axes[r], t[r]))
721
803
  return !1;
722
804
  }
723
805
  }
724
- if (e.annotations !== void 0) {
725
- const t = n.annotations || {};
726
- for (const [r, o] of Object.entries(e.annotations))
806
+ if (n.annotations !== void 0) {
807
+ const t = e.annotations || {};
808
+ for (const [r, o] of Object.entries(n.annotations))
727
809
  if (t[r] !== o)
728
810
  return !1;
729
811
  }
730
- if (e.annotationPatterns !== void 0) {
731
- const t = n.annotations || {};
732
- for (const [r, o] of Object.entries(e.annotationPatterns)) {
733
- const s = t[r];
734
- if (s === void 0 || !new RegExp(o).test(s))
812
+ if (n.annotationPatterns !== void 0) {
813
+ const t = e.annotations || {};
814
+ for (const [r, o] of Object.entries(n.annotationPatterns)) {
815
+ const i = t[r];
816
+ if (i === void 0 || !new RegExp(o).test(i))
735
817
  return !1;
736
818
  }
737
819
  }
738
820
  return !0;
739
821
  }
740
- function Qn(n) {
741
- return Array.isArray(n) ? (e) => n.some((t) => f(e) && N(e, t)) : (e) => f(e) && N(e, n);
822
+ function nn(e) {
823
+ return Array.isArray(e) ? (n) => e.some((t) => d(n) && v(n, t)) : (n) => d(n) && v(n, e);
742
824
  }
743
- function Yn(n) {
744
- const e = {
745
- kind: n.kind,
746
- name: n.name
825
+ function tn(e) {
826
+ const n = {
827
+ kind: e.kind,
828
+ name: e.name
747
829
  };
748
- return n.domain !== void 0 && (e.domain = n.domain), f(n) && (e.axesSpec = J(n.axesSpec)), y(e);
830
+ return e.domain !== void 0 && (n.domain = e.domain), d(e) && (n.axesSpec = C(e.axesSpec)), h(n);
749
831
  }
750
- const Zn = { href: "/" }, ne = d.object({
751
- __isRef: d.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
752
- blockId: d.string().describe("Upstream block id"),
753
- name: d.string().describe("Name of the output provided to the upstream block's output context"),
754
- requireEnrichments: d.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
832
+ const rn = { href: "/" }, on = p.object({
833
+ __isRef: p.literal(!0).describe("Crucial marker for the block dependency tree reconstruction"),
834
+ blockId: p.string().describe("Upstream block id"),
835
+ name: p.string().describe("Name of the output provided to the upstream block's output context"),
836
+ requireEnrichments: p.literal(!0).optional().describe("True if current block that stores this reference in its args, may need enrichments for the references value originating from the blocks in between current and referenced block")
755
837
  }).describe(
756
838
  "Universal reference type, allowing to set block connections. It is crucial that {@link __isRef} is present and equal to true, internal logic relies on this marker to build block dependency trees."
757
839
  ).readonly();
758
- function ee(n) {
759
- return typeof n == "object" && n !== null && "__isRef" in n && n.__isRef === !0 && "blockId" in n && "name" in n;
840
+ function sn(e) {
841
+ return typeof e == "object" && e !== null && "__isRef" in e && e.__isRef === !0 && "blockId" in e && "name" in e;
760
842
  }
761
- function te(n, e, t = !1) {
843
+ function an(e, n, t = !1) {
762
844
  return t ? {
763
845
  __isRef: !0,
764
- blockId: n,
765
- name: e,
846
+ blockId: e,
847
+ name: n,
766
848
  requireEnrichments: !0
767
849
  } : {
768
850
  __isRef: !0,
769
- blockId: n,
770
- name: e
851
+ blockId: e,
852
+ name: n
771
853
  };
772
854
  }
773
- function re(n, e = !0) {
774
- if (e)
855
+ function un(e, n = !0) {
856
+ if (n)
775
857
  return {
776
- ...n,
858
+ ...e,
777
859
  requireEnrichments: !0
778
860
  };
779
861
  {
780
- const { requireEnrichments: t, ...r } = n;
862
+ const { requireEnrichments: t, ...r } = e;
781
863
  return r;
782
864
  }
783
865
  }
784
- function oe(n, e, t = !1) {
785
- return n.blockId === e.blockId && n.name === e.name && (t || n.requireEnrichments === e.requireEnrichments);
866
+ function cn(e, n, t = !1) {
867
+ return e.blockId === n.blockId && e.name === n.name && (t || e.requireEnrichments === n.requireEnrichments);
786
868
  }
787
- function ie(n, e) {
788
- return n.ok ? { ok: !0, value: e(n.value) } : n;
869
+ function fn(e, n) {
870
+ return e.ok ? { ok: !0, value: n(e.value) } : e;
789
871
  }
790
- function sn(n) {
791
- if (n instanceof Int8Array || n instanceof Uint8Array || n instanceof Uint8ClampedArray)
792
- return new DataView(n.buffer, n.byteOffset, n.byteLength);
793
- if (n instanceof ArrayBuffer) return new DataView(n);
872
+ function ae(e) {
873
+ if (e instanceof Int8Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray)
874
+ return new DataView(e.buffer, e.byteOffset, e.byteLength);
875
+ if (e instanceof ArrayBuffer) return new DataView(e);
794
876
  throw new TypeError(
795
877
  "Expected `data` to be an ArrayBuffer, Buffer, Int8Array, Uint8Array or Uint8ClampedArray"
796
878
  );
797
879
  }
798
- const an = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", un = "0123456789ABCDEFGHIJKLMNOPQRSTUV", cn = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
799
- function O(n, e, t) {
880
+ const ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ce = "0123456789ABCDEFGHIJKLMNOPQRSTUV", fe = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
881
+ function $(e, n, t) {
800
882
  t = t || {};
801
883
  let r, o;
802
- switch (e) {
884
+ switch (n) {
803
885
  case "RFC3548":
804
886
  case "RFC4648":
805
- r = an, o = !0;
887
+ r = ue, o = !0;
806
888
  break;
807
889
  case "RFC4648-HEX":
808
- r = un, o = !0;
890
+ r = ce, o = !0;
809
891
  break;
810
892
  case "Crockford":
811
- r = cn, o = !1;
893
+ r = fe, o = !1;
812
894
  break;
813
895
  default:
814
- throw new Error("Unknown base32 variant: " + String(e));
815
- }
816
- const s = t.padding !== void 0 ? t.padding : o, a = sn(n);
817
- let i = 0, u = 0, c = "";
818
- for (let m = 0; m < a.byteLength; m++)
819
- for (u = u << 8 | a.getUint8(m), i += 8; i >= 5; )
820
- c += r[u >>> i - 5 & 31], i -= 5;
821
- if (i > 0 && (c += r[u << 5 - i & 31]), s)
896
+ throw new Error("Unknown base32 variant: " + String(n));
897
+ }
898
+ const i = t.padding !== void 0 ? t.padding : o, a = ae(e);
899
+ let s = 0, u = 0, c = "";
900
+ for (let f = 0; f < a.byteLength; f++)
901
+ for (u = u << 8 | a.getUint8(f), s += 8; s >= 5; )
902
+ c += r[u >>> s - 5 & 31], s -= 5;
903
+ if (s > 0 && (c += r[u << 5 - s & 31]), i)
822
904
  for (; c.length % 8 !== 0; )
823
905
  c += "=";
824
906
  return c;
825
907
  }
826
- const $ = 15, fn = 24, I = d.string().length(fn).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
827
- function se() {
828
- const n = new Uint8Array($);
829
- return crypto.getRandomValues(n), I.parse(O(n, "RFC4648"));
908
+ const V = 15, de = 24, I = p.string().length(de).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
909
+ function dn() {
910
+ const e = new Uint8Array(V);
911
+ return crypto.getRandomValues(e), I.parse($(e, "RFC4648"));
830
912
  }
831
- function dn(n) {
832
- if (n.length !== $) throw new Error(`Wrong number of bytes: ${n.length}`);
833
- return I.parse(O(n, "RFC4648"));
913
+ function le(e) {
914
+ if (e.length !== V) throw new Error(`Wrong number of bytes: ${e.length}`);
915
+ return I.parse($(e, "RFC4648"));
834
916
  }
835
- async function ae(n) {
836
- const e = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", e.encode(n));
837
- return dn(new Uint8Array(t.slice(0, 15)));
917
+ async function ln(e) {
918
+ const n = new TextEncoder(), t = await crypto.subtle.digest("SHA-256", n.encode(e));
919
+ return le(new Uint8Array(t.slice(0, 15)));
838
920
  }
839
- function ue(n) {
840
- return JSON.stringify(n);
921
+ function pn(e) {
922
+ return JSON.stringify(e);
841
923
  }
842
- function ce(n) {
843
- return y(n);
924
+ function mn(e) {
925
+ return h(e);
844
926
  }
845
- function fe(n) {
846
- return JSON.parse(n);
927
+ function yn(e) {
928
+ return JSON.parse(e);
847
929
  }
848
- class de extends Error {
930
+ class hn extends Error {
849
931
  constructor() {
850
932
  super(...arguments);
851
933
  l(this, "name", "AbortError");
852
934
  }
853
935
  }
854
- class me extends Error {
936
+ class gn extends Error {
855
937
  constructor() {
856
938
  super(...arguments);
857
939
  l(this, "name", "UiError");
858
940
  }
859
941
  }
860
- function le(n) {
861
- return n instanceof Error && n.name === "AbortError";
942
+ function bn(e) {
943
+ return e instanceof Error && e.name === "AbortError";
862
944
  }
863
- function mn(n) {
864
- return n instanceof Error ? n.name === "AbortError" || mn(n.cause) : !1;
945
+ function pe(e) {
946
+ return e instanceof Error ? e.name === "AbortError" || pe(e.cause) : !1;
865
947
  }
866
- function pe(n) {
867
- return n instanceof Error && n.name === "AggregateError";
948
+ function wn(e) {
949
+ return e instanceof Error && e.name === "AggregateError";
868
950
  }
869
- function ln(n) {
870
- if (typeof n == "string")
871
- return `String value was thrown: ${n}`;
872
- if (n && typeof n == "object")
951
+ function me(e) {
952
+ if (typeof e == "string")
953
+ return `String value was thrown: ${e}`;
954
+ if (e && typeof e == "object")
873
955
  try {
874
- return `Plain object was thrown: ${JSON.stringify(n)}`;
875
- } catch (e) {
876
- return `Non-serializable object was thrown (JSON.stringify failed: ${e instanceof Error ? e.message : String(e)}): ${String(n)}`;
956
+ return `Plain object was thrown: ${JSON.stringify(e)}`;
957
+ } catch (n) {
958
+ return `Non-serializable object was thrown (JSON.stringify failed: ${n instanceof Error ? n.message : String(n)}): ${String(e)}`;
877
959
  }
878
- return `Non-Error value (${typeof n}) was thrown: ${n}`;
960
+ return `Non-Error value (${typeof e}) was thrown: ${e}`;
879
961
  }
880
- function A(n) {
881
- return n instanceof Error ? n : new Error(ln(n));
962
+ function k(e) {
963
+ return e instanceof Error ? e : new Error(me(e));
882
964
  }
883
- function V(n) {
884
- const e = n.cause ? V(n.cause) : void 0, t = new Error(n.message, e !== void 0 ? { cause: e } : void 0);
885
- return t.name = n.name || "Error", t.stack = n.stack, t;
965
+ function j(e) {
966
+ const n = e.cause ? j(e.cause) : void 0, t = new Error(e.message, n !== void 0 ? { cause: n } : void 0);
967
+ return t.name = e.name || "Error", t.stack = e.stack, t;
886
968
  }
887
- function D(n) {
888
- const e = A(n), t = e.cause ? D(e.cause) : void 0;
969
+ function F(e) {
970
+ const n = k(e), t = n.cause ? F(n.cause) : void 0;
889
971
  return {
890
- name: e.name,
891
- message: e.message,
892
- stack: e.stack,
893
- ...e.cause !== void 0 && { cause: t }
972
+ name: n.name,
973
+ message: n.message,
974
+ stack: n.stack,
975
+ ...n.cause !== void 0 && { cause: t }
894
976
  };
895
977
  }
896
- function ye(n) {
897
- if (n.error)
898
- throw n.error;
899
- return n.value;
978
+ function An(e) {
979
+ if (e.error)
980
+ throw e.error;
981
+ return e.value;
900
982
  }
901
- function L(n) {
902
- return n.error ? { error: D(n.error) } : { value: n.value };
983
+ function J(e) {
984
+ return e.error ? { error: F(e.error) } : { value: e.value };
903
985
  }
904
- function he(n) {
905
- return n.error ? { error: V(n.error) } : { value: n.value };
986
+ function kn(e) {
987
+ return e.error ? { error: j(e.error) } : { value: e.value };
906
988
  }
907
- function pn(n) {
989
+ function ye(e) {
908
990
  try {
909
- return { value: n() };
910
- } catch (e) {
911
- return { error: A(e) };
991
+ return { value: e() };
992
+ } catch (n) {
993
+ return { error: k(n) };
912
994
  }
913
995
  }
914
- async function yn(n) {
996
+ async function he(e) {
915
997
  try {
916
- return { value: await n() };
917
- } catch (e) {
918
- return { error: A(e) };
998
+ return { value: await e() };
999
+ } catch (n) {
1000
+ return { error: k(n) };
919
1001
  }
920
1002
  }
921
- function ge(n) {
922
- const e = pn(n);
923
- return L(e);
1003
+ function xn(e) {
1004
+ const n = ye(e);
1005
+ return J(n);
1006
+ }
1007
+ async function Pn(e) {
1008
+ const n = await he(e);
1009
+ return J(n);
1010
+ }
1011
+ const En = ["supportsLazyState"], Sn = ["requiresUIAPIVersion", "requiresModelAPIVersion"];
1012
+ function vn(e, n, t = !0) {
1013
+ return e === void 0 ? !1 : e[n] === t;
924
1014
  }
925
- async function be(n) {
926
- const e = await yn(n);
927
- return L(e);
1015
+ function Nn(e) {
1016
+ return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("requires") && t === !0).map(([n]) => n));
1017
+ }
1018
+ function On(e) {
1019
+ return e === void 0 ? /* @__PURE__ */ new Set() : new Set(Object.entries(e).filter(([n, t]) => n.startsWith("supports") && t === !0).map(([n]) => n));
1020
+ }
1021
+ class ge extends Error {
1022
+ constructor(t) {
1023
+ super(`Some of the block requirements are not supported by the runtime: ${Array.from(t.entries()).map(([r, o]) => `${r}: ${o}`).join(", ")}`);
1024
+ l(this, "name", "IncompatibleFlagsError");
1025
+ this.incompatibleFlags = t;
1026
+ }
1027
+ }
1028
+ class Cn {
1029
+ constructor() {
1030
+ l(this, "supportedRequirements", /* @__PURE__ */ new Map());
1031
+ }
1032
+ /**
1033
+ * Adds a supported requirement to the runtime capabilities.
1034
+ * @param requirement - The requirement.
1035
+ * @param value - The value of the requirement. If not provided, defaults to true.
1036
+ */
1037
+ addSupportedRequirement(n, t = !0) {
1038
+ return this.supportedRequirements.has(n) || this.supportedRequirements.set(n, /* @__PURE__ */ new Set()), this.supportedRequirements.get(n).add(t), this;
1039
+ }
1040
+ /**
1041
+ * Returns a map of incompatible flags. If the block flags are compatible, returns undefined.
1042
+ * @param blockFlags - The block flags.
1043
+ * @returns A map of incompatible flags, or undefined if the block flags are compatible.
1044
+ */
1045
+ getIncompatibleFlags(n) {
1046
+ if (n === void 0) return;
1047
+ const t = /* @__PURE__ */ new Map();
1048
+ for (const [r, o] of Object.entries(n))
1049
+ if (r.startsWith("requires")) {
1050
+ if (o === void 0) continue;
1051
+ const i = this.supportedRequirements.get(r);
1052
+ (i === void 0 || !i.has(o)) && t.set(r, o);
1053
+ }
1054
+ return t.size === 0 ? void 0 : t;
1055
+ }
1056
+ /**
1057
+ * Checks if the block flags are compatible with the runtime capabilities.
1058
+ * @param blockFlags - The block flags.
1059
+ * @returns True if the block flags are compatible, false otherwise.
1060
+ */
1061
+ checkCompatibility(n) {
1062
+ return this.getIncompatibleFlags(n) === void 0;
1063
+ }
1064
+ /**
1065
+ * Throws an error if the block flags are incompatible with the runtime capabilities.
1066
+ * @param blockFlags - The block flags.
1067
+ * @throws IncompatibleFlagsError if the block flags are incompatible with the runtime capabilities.
1068
+ */
1069
+ throwIfIncompatible(n) {
1070
+ const t = this.getIncompatibleFlags(n);
1071
+ if (t !== void 0)
1072
+ throw new ge(t);
1073
+ }
928
1074
  }
929
1075
  export {
930
- de as AbortError,
931
- Mn as AnchoredIdDeriver,
932
- Zn as DefaultNavigationState,
933
- G as PTableAbsent,
934
- Q as PTableNA,
935
- T as PValueBytesNA,
936
- In as PValueDoubleNA,
937
- $n as PValueFloatNA,
938
- _ as PValueIntNA,
1076
+ hn as AbortError,
1077
+ Sn as AllRequiresFeatureFlags,
1078
+ En as AllSupportsFeatureFlags,
1079
+ He as AnchoredIdDeriver,
1080
+ rn as DefaultNavigationState,
1081
+ ge as IncompatibleFlagsError,
1082
+ Y as PTableAbsent,
1083
+ Z as PTableNA,
1084
+ z as PValueBytesNA,
1085
+ Je as PValueDoubleNA,
1086
+ Fe as PValueFloatNA,
1087
+ q as PValueIntNA,
939
1088
  x as PValueLongNA,
940
- M as PValueStringNA,
1089
+ T as PValueStringNA,
941
1090
  I as PlId,
942
- $ as PlIdBytes,
943
- fn as PlIdLength,
944
- ne as PlRef,
945
- wn as RangeBytes,
946
- me as UiError,
947
- Rn as canonicalizeAxisId,
948
- ce as canonicalizeJson,
949
- te as createPlRef,
950
- Cn as dataInfoToEntries,
951
- Yn as deriveNativeId,
952
- V as deserializeError,
953
- he as deserializeResult,
954
- ae as digestPlId,
955
- A as ensureError,
956
- Vn as ensureNotNAPValue,
957
- Wn as ensurePColumn,
958
- Jn as entriesToDataInfo,
959
- b as executePSpecPredicate,
960
- Gn as extractAllColumns,
961
- J as getAxesId,
962
- p as getAxisId,
963
- Fn as getColumnIdAndSpec,
964
- kn as getFileNameFromHandle,
965
- R as getFilePathFromHandle,
966
- vn as getPColumnSpecId,
967
- Kn as getPTableColumnId,
968
- mn as hasAbortError,
969
- le as isAbortError,
970
- pe as isAggregateError,
971
- En as isDataInfo,
972
- K as isDataInfoEntries,
973
- zn as isFilteredPColumn,
974
- F as isImportFileHandleIndex,
975
- v as isImportFileHandleUpload,
976
- Pn as isLiveLog,
977
- z as isNotNAPValue,
978
- rn as isPColumn,
979
- qn as isPColumnResult,
980
- f as isPColumnSpec,
981
- Hn as isPColumnSpecResult,
982
- Bn as isPTableAbsent,
983
- H as isPValue,
984
- Sn as isPartitionedDataInfoEntries,
985
- ee as isPlRef,
986
- X as isValueAbsent,
987
- g as isValueNA,
988
- Nn as mapDataInfo,
989
- On as mapDataInfoEntries,
990
- h as mapJoinEntry,
991
- Xn as mapPObjectData,
992
- Un as mapPTableDef,
993
- ie as mapValueInVOE,
994
- E as matchAxis,
995
- Z as matchAxisId,
996
- N as matchPColumn,
997
- An as newRangeBytesOpt,
998
- jn as pTableValue,
999
- Ln as pValueToStringOrNumber,
1000
- W as pValueToStringOrNumberOrNull,
1001
- _n as parseColumnId,
1002
- fe as parseJson,
1003
- dn as plId,
1004
- oe as plRefsEqual,
1005
- Tn as resolveAnchors,
1006
- q as safeConvertToPValue,
1007
- Qn as selectorsToPredicate,
1008
- D as serializeError,
1009
- L as serializeResult,
1010
- nn as stringifyColumnId,
1011
- ue as stringifyJson,
1012
- Dn as toJsonSafePValue,
1013
- se as uniquePlId,
1014
- ye as unwrapResult,
1015
- xn as validateRangeBytes,
1016
- re as withEnrichments,
1017
- ge as wrapAndSerialize,
1018
- be as wrapAndSerializeAsync,
1019
- yn as wrapAsyncCallback,
1020
- pn as wrapCallback
1091
+ V as PlIdBytes,
1092
+ de as PlIdLength,
1093
+ on as PlRef,
1094
+ Pe as RangeBytes,
1095
+ Cn as RuntimeCapabilities,
1096
+ gn as UiError,
1097
+ _e as canonicalizeAxisId,
1098
+ mn as canonicalizeJson,
1099
+ vn as checkBlockFlag,
1100
+ an as createPlRef,
1101
+ Ve as dataInfoToEntries,
1102
+ tn as deriveNativeId,
1103
+ j as deserializeError,
1104
+ kn as deserializeResult,
1105
+ ln as digestPlId,
1106
+ k as ensureError,
1107
+ Re as ensureNotNAPValue,
1108
+ Ye as ensurePColumn,
1109
+ Ie as entriesToDataInfo,
1110
+ w as executePSpecPredicate,
1111
+ en as extractAllColumns,
1112
+ Nn as extractAllRequirements,
1113
+ On as extractAllSupports,
1114
+ ke as extractCodeWithInfo,
1115
+ xe as extractConfigGeneric,
1116
+ C as getAxesId,
1117
+ y as getAxisId,
1118
+ Me as getColumnIdAndSpec,
1119
+ Ne as getFileNameFromHandle,
1120
+ K as getFilePathFromHandle,
1121
+ Ke as getPColumnSpecId,
1122
+ Te as getPTableColumnId,
1123
+ pe as hasAbortError,
1124
+ bn as isAbortError,
1125
+ wn as isAggregateError,
1126
+ Oe as isDataInfo,
1127
+ _ as isDataInfoEntries,
1128
+ Ge as isFilteredPColumn,
1129
+ U as isImportFileHandleIndex,
1130
+ B as isImportFileHandleUpload,
1131
+ ve as isLiveLog,
1132
+ H as isNotNAPValue,
1133
+ ie as isPColumn,
1134
+ Qe as isPColumnResult,
1135
+ d as isPColumnSpec,
1136
+ Xe as isPColumnSpecResult,
1137
+ Be as isPTableAbsent,
1138
+ W as isPValue,
1139
+ $e as isPartitionedDataInfoEntries,
1140
+ sn as isPlRef,
1141
+ Q as isValueAbsent,
1142
+ b as isValueNA,
1143
+ Ce as mapDataInfo,
1144
+ je as mapDataInfoEntries,
1145
+ g as mapJoinEntry,
1146
+ Ze as mapPObjectData,
1147
+ qe as mapPTableDef,
1148
+ fn as mapValueInVOE,
1149
+ S as matchAxis,
1150
+ ne as matchAxisId,
1151
+ v as matchPColumn,
1152
+ Ee as newRangeBytesOpt,
1153
+ Ue as pTableValue,
1154
+ Le as pValueToStringOrNumber,
1155
+ X as pValueToStringOrNumberOrNull,
1156
+ ze as parseColumnId,
1157
+ yn as parseJson,
1158
+ le as plId,
1159
+ cn as plRefsEqual,
1160
+ We as resolveAnchors,
1161
+ G as safeConvertToPValue,
1162
+ nn as selectorsToPredicate,
1163
+ F as serializeError,
1164
+ J as serializeResult,
1165
+ te as stringifyColumnId,
1166
+ pn as stringifyJson,
1167
+ De as toJsonSafePValue,
1168
+ dn as uniquePlId,
1169
+ An as unwrapResult,
1170
+ Se as validateRangeBytes,
1171
+ un as withEnrichments,
1172
+ xn as wrapAndSerialize,
1173
+ Pn as wrapAndSerializeAsync,
1174
+ he as wrapAsyncCallback,
1175
+ ye as wrapCallback
1021
1176
  };
1022
1177
  //# sourceMappingURL=index.mjs.map