@rotorjs/jpl 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js ADDED
@@ -0,0 +1,3644 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {
3
+ let r = {};
4
+ for (var i in e) t(r, i, {
5
+ get: e[i],
6
+ enumerable: !0
7
+ });
8
+ return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ }, c = (e, i, o, s) => {
10
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
11
+ get: ((e) => i[e]).bind(null, d),
12
+ enumerable: !(s = n(i, d)) || s.enumerable
13
+ });
14
+ return e;
15
+ }, l = (n, r, a) => (a = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule ? t(a, "default", {
16
+ value: n,
17
+ enumerable: !0
18
+ }) : a, n));
19
+ //#endregion
20
+ //#region node_modules/@jplorg/jpl/src/createSingleton.js
21
+ function u(e) {
22
+ let t;
23
+ return () => (t ??= e(), t);
24
+ }
25
+ //#endregion
26
+ //#region node_modules/@jplorg/jpl/src/applyDefaults.js
27
+ function d(e, t, ...n) {
28
+ let r = (e, t, n) => {
29
+ if (Array.isArray(e)) return e;
30
+ if (typeof e == "object") {
31
+ if (e === null || Array.isArray(t) || typeof t != "object" || !t) return e;
32
+ let i = { ...e }, a = n.some((e) => e.length === 0);
33
+ return Object.keys({
34
+ ...e,
35
+ ...t
36
+ }).forEach((e) => {
37
+ a ? Object.hasOwn(i, e) || (i[e] = t[e]) : i[e] = r(i[e], t[e], n.filter((t) => t[0] === e).map((e) => e.slice(1))), i[e] === void 0 && delete i[e];
38
+ }), i;
39
+ }
40
+ return e === void 0 ? t : e;
41
+ };
42
+ return r(e, t, n.map((e) => typeof e == "string" ? e.split(".") : e));
43
+ }
44
+ //#endregion
45
+ //#region node_modules/@jplorg/jpl/src/library/apply.js
46
+ function f(e, t) {
47
+ let n = e, r = !0;
48
+ return t.forEach((e) => {
49
+ let [t, i] = e;
50
+ if (e.length === 1) {
51
+ if (!Object.hasOwn(n, t)) return;
52
+ if (r) {
53
+ let e;
54
+ ({[t]: e, ...n} = n), r = !1;
55
+ } else delete n[t];
56
+ return;
57
+ }
58
+ Object.hasOwn(n, t) && n[t] === i || (r ? (n = {
59
+ ...n,
60
+ [t]: i
61
+ }, r = !1) : n[t] = i);
62
+ }), n;
63
+ }
64
+ function p(e, t, n = null) {
65
+ let r = e, i = !0;
66
+ return t.forEach((e) => {
67
+ let [t, a] = e, o = t >= 0 ? t : r.length + t;
68
+ if (!(o >= 0 && o < r.length && r[o] === a)) {
69
+ if (t >= 0) {
70
+ let e = o + 1 - r.length;
71
+ e > 0 && (r = [...r, ...Array(e).fill(n)], i = !1);
72
+ } else {
73
+ let e = -o;
74
+ e > 0 && (r = [...Array(e).fill(n), ...r], i = !1, o = 0);
75
+ }
76
+ i &&= (r = [...r], !1), r[o] = a;
77
+ }
78
+ }), r;
79
+ }
80
+ function m(e, t) {
81
+ let n = t.length, r = 1, i = t.map((e) => {
82
+ let t = e.length;
83
+ return r *= t, [
84
+ t,
85
+ 0,
86
+ e
87
+ ];
88
+ });
89
+ if (r === 0) return [];
90
+ let a = e, o = e.length;
91
+ o !== n && (a = o > n ? a.slice(0, n) : [...a, ...Array(n - o)]);
92
+ let s = Array(r), c = 0;
93
+ for (;;) {
94
+ let e = a, t = !0;
95
+ if (i.forEach(([, n, r], i) => {
96
+ let a = r[n];
97
+ e[i] !== a && (t &&= (e = [...e], !1), e[i] = a);
98
+ }), s[c] = e, c += 1, c >= r) break;
99
+ for (let e = n - 1; e >= 0; --e) {
100
+ let t = i[e], [n, r] = t, a = r + 1;
101
+ if (a < n) {
102
+ t[1] = a;
103
+ break;
104
+ }
105
+ t[1] = 0;
106
+ }
107
+ }
108
+ return s;
109
+ }
110
+ var h = "1.0", g = class extends Error {
111
+ static is(e) {
112
+ return e instanceof this;
113
+ }
114
+ constructor(e, t = "JPLError") {
115
+ super(e), this.name = t;
116
+ }
117
+ }, _ = class extends g {
118
+ constructor(e, t = "JPLExecutionError") {
119
+ super(e, t), this.value = typeof e == "string" && e ? e : null;
120
+ }
121
+ };
122
+ //#endregion
123
+ //#region node_modules/@jplorg/jpl/src/library/errors/adaptErrors.js
124
+ function ee(e) {
125
+ try {
126
+ return e();
127
+ } catch (e) {
128
+ throw v(e);
129
+ }
130
+ }
131
+ async function te(e) {
132
+ try {
133
+ return await e();
134
+ } catch (e) {
135
+ throw v(e);
136
+ }
137
+ }
138
+ function v(e) {
139
+ return g.is(e) ? e : new _(e.message);
140
+ }
141
+ //#endregion
142
+ //#region node_modules/@jplorg/jpl/src/library/errors/enclosure.js
143
+ var y = class extends g {
144
+ constructor(e) {
145
+ super(e, "JPLErrorEnclosure"), this.inner = e;
146
+ }
147
+ }, b = class extends g {
148
+ constructor(e) {
149
+ super(e, "JPLFatalError");
150
+ }
151
+ }, x = class {
152
+ static is(e) {
153
+ return e instanceof this;
154
+ }
155
+ constructor(e) {
156
+ this._v = ne(e);
157
+ }
158
+ get value() {
159
+ return this._v;
160
+ }
161
+ get json() {
162
+ return this._v;
163
+ }
164
+ async alter(e) {
165
+ return S(await e(this.value));
166
+ }
167
+ toJSON() {
168
+ try {
169
+ return this.json;
170
+ } catch (e) {
171
+ throw v(e);
172
+ }
173
+ }
174
+ };
175
+ function ne(e) {
176
+ return x.is(e) ? e.value : S(e);
177
+ }
178
+ function S(e) {
179
+ return O(e, void 0, oe);
180
+ }
181
+ function C(e) {
182
+ return x.is(e) ? ee(() => e.value) : e;
183
+ }
184
+ var re = [
185
+ "null",
186
+ "function",
187
+ "boolean",
188
+ "number",
189
+ "string",
190
+ "array",
191
+ "object"
192
+ ];
193
+ function ie(e) {
194
+ let t = C(e);
195
+ if (t === null) return "null";
196
+ if (Array.isArray(t)) return "array";
197
+ let n = typeof t;
198
+ switch (n) {
199
+ case "function":
200
+ case "boolean":
201
+ case "number":
202
+ case "string":
203
+ case "object": return n;
204
+ default: throw new b(`invalid type ${n} (${e})`);
205
+ }
206
+ }
207
+ function w(e, t) {
208
+ if (x.is(e)) throw new b(E("unexpected type: JPLTypes (%*<100v) are not allowed here", e));
209
+ let n = ie(e);
210
+ if (n !== t) throw new b(E("unexpected type: %s (%*<100v) cannot be used as %s", n, e, t));
211
+ return e;
212
+ }
213
+ function T(e, t, n) {
214
+ let r = n ? O(e, (e, t) => typeof C(t) == "function" ? "<function>" : t) : O(e);
215
+ return t && typeof r == "string" ? r : JSON.stringify(r);
216
+ }
217
+ function E(e, ...t) {
218
+ let n = 0;
219
+ return D(e).replace(/%([*\-<]+)?([1-9][0-9]*)?(.)/g, (e, r, i, a) => {
220
+ switch (a) {
221
+ case "%": return "%";
222
+ default:
223
+ }
224
+ let o = t[n] ?? null;
225
+ n += 1;
226
+ let s;
227
+ switch (a) {
228
+ case "s":
229
+ s = D(o);
230
+ break;
231
+ case "v":
232
+ s = ae(o);
233
+ break;
234
+ default: throw new b(`format ${e} has unknown verb ${a}`);
235
+ }
236
+ let c = !0, l = !1, u = !1;
237
+ [...r ?? []].forEach((t) => {
238
+ switch (t) {
239
+ case "*":
240
+ c = !1;
241
+ break;
242
+ case "-":
243
+ l = !0;
244
+ break;
245
+ case "<":
246
+ u = !0;
247
+ break;
248
+ default: throw new b(`format ${e} has unknown flag ${t}`);
249
+ }
250
+ });
251
+ let d = +(i ?? 0);
252
+ if (d > 0) {
253
+ let e = [...s].length;
254
+ if (c && e < d) {
255
+ let t = " ".repeat(d - e);
256
+ s = l ? `${s}${t}` : `${t}${s}`;
257
+ } else u && e > d && (s = `${s.substring(0, d - 1)}…`);
258
+ }
259
+ return s;
260
+ });
261
+ }
262
+ function D(e) {
263
+ return T(e, !0, !0);
264
+ }
265
+ function ae(e) {
266
+ return T(e, !1, !0);
267
+ }
268
+ function O(e, t, n = ce) {
269
+ let r = (e, i) => {
270
+ let a = i;
271
+ return t && (a = t(e ?? "", a)), n(e, a, r);
272
+ };
273
+ return r(null, e);
274
+ }
275
+ function oe(e, t, n) {
276
+ return x.is(t) || typeof t == "function" ? t : k(e, t, n);
277
+ }
278
+ function se(e, t, n) {
279
+ let r = t;
280
+ return x.is(r) && (r = r.toJSON()), typeof r == "function" ? r : k(e, r, n);
281
+ }
282
+ function ce(e, t, n) {
283
+ let r = t;
284
+ return x.is(r) && (r = r.toJSON()), k(e, r, n);
285
+ }
286
+ function le(e, t, n) {
287
+ let r = t;
288
+ return typeof r?.toJSON == "function" && (r = r.toJSON()), k(e, r, n);
289
+ }
290
+ function k(e, t, n) {
291
+ let r = e == null, i = typeof t;
292
+ switch (i) {
293
+ case "string":
294
+ case "boolean": return t;
295
+ case "number": return Number.isFinite(t) ? t : null;
296
+ case "undefined":
297
+ case "function": return r ? null : void 0;
298
+ case "object": return t === null ? null : Array.isArray(t) ? p(t, Array.from(Array(t.length), (e, r) => [r, n(`${r}`, t[r]) ?? null])) : f(t, Object.entries(t).map(([e, t]) => {
299
+ let r = n(e, t);
300
+ return r === void 0 ? [e] : [e, r];
301
+ }));
302
+ default: throw new b(`unexpected ${i}`);
303
+ }
304
+ }
305
+ //#endregion
306
+ //#region node_modules/@jplorg/jpl/src/library/errors/runtime.js
307
+ function A(e, t) {
308
+ return t.length > 0 ? E(e, ...t) : D(e);
309
+ }
310
+ var j = class extends _ {
311
+ constructor(e, ...t) {
312
+ let n = A(e, t);
313
+ super(n, "JPLRuntimeError"), this.value = t.length > 0 ? n : S(e);
314
+ }
315
+ }, M = class extends j {
316
+ constructor(e, ...t) {
317
+ super(`TypeError - ${A(e, t)}`);
318
+ }
319
+ }, ue = class extends j {
320
+ constructor(e, ...t) {
321
+ super(`ReferenceError - ${A(e, t)}`);
322
+ }
323
+ }, de = class extends j {
324
+ constructor(e, ...t) {
325
+ super(`ZeroDivisionError - ${A(e, t)}`);
326
+ }
327
+ }, fe = class extends j {
328
+ constructor(e, ...t) {
329
+ super(`TypeConversionError - ${A(e, t)}`);
330
+ }
331
+ }, pe = class extends g {
332
+ constructor(e, t = "", n = 0) {
333
+ super(e, "JPLSyntaxError"), this.src = t, this.at = n;
334
+ }
335
+ }, me = class e {
336
+ constructor(e) {
337
+ this._parent = e, this._exited = !1, this._subscriptions = {}, this._nextSubscriptionKey = 0;
338
+ }
339
+ get parent() {
340
+ return this._parent;
341
+ }
342
+ get exited() {
343
+ return this._exited ||= this.parent?.exited ?? !1, this._exited;
344
+ }
345
+ checkHealth() {
346
+ if (this.exited) throw new b("execution aborted");
347
+ }
348
+ exit = () => {
349
+ this.exited || (this._exited = !0, Object.values(this._subscriptions).forEach((e) => {
350
+ e();
351
+ }), this._subscriptions = {});
352
+ };
353
+ subscribe = (e) => {
354
+ if (this.exited) return setTimeout(e), () => {};
355
+ let t = this._nextSubscriptionKey;
356
+ this._nextSubscriptionKey += 1, this._subscriptions[t] = e;
357
+ let n = (this.parent?.subscribe ?? (() => () => {}))(e);
358
+ return () => {
359
+ delete this._subscriptions[t], n();
360
+ };
361
+ };
362
+ next = () => new e(this);
363
+ }, he = class e {
364
+ constructor(e = {}) {
365
+ this._state = {
366
+ signal: e.signal ?? new me(),
367
+ vars: e.vars ?? {}
368
+ };
369
+ }
370
+ get signal() {
371
+ return this._state.signal;
372
+ }
373
+ get vars() {
374
+ return this._state.vars;
375
+ }
376
+ next(t) {
377
+ return new e({
378
+ signal: t.signal ?? this.signal,
379
+ vars: f(this.vars, Object.entries(t.vars ?? {}))
380
+ });
381
+ }
382
+ };
383
+ //#endregion
384
+ //#region node_modules/@jplorg/jpl/src/library/functions.js
385
+ function ge(e, t, n, r, ...i) {
386
+ let { argNames: a, pipe: o, scope: s } = this;
387
+ return e.executeInstructions(o, [r], s.next({
388
+ signal: t,
389
+ vars: Object.fromEntries(a.map((e, t) => [e, i[t] ?? null]))
390
+ }), n);
391
+ }
392
+ function _e(e, t, n) {
393
+ return ge.bind({
394
+ argNames: e,
395
+ pipe: t,
396
+ scope: n
397
+ });
398
+ }
399
+ function ve(e, t, n) {
400
+ return _e(e, t, new he(n));
401
+ }
402
+ function ye(e) {
403
+ return async (t, n, r, i, ...a) => {
404
+ let o = await e(t, i, ...a);
405
+ return t.muxAll([o], r);
406
+ };
407
+ }
408
+ //#endregion
409
+ //#region node_modules/@jplorg/jpl/src/library/mux.js
410
+ function be(e, t) {
411
+ let n = e.length;
412
+ if (n === 1) {
413
+ e[0].forEach((e) => t(e));
414
+ return;
415
+ }
416
+ let r = 1, i = e.map((e) => {
417
+ let t = e?.length ?? 0;
418
+ return r *= t, [
419
+ t,
420
+ 0,
421
+ e
422
+ ];
423
+ });
424
+ if (r === 0) return;
425
+ let a = e.map(([e]) => e), o = 0;
426
+ for (; t(...a), o += 1, !(o >= r);) for (let e = n - 1; e >= 0; --e) {
427
+ let t = i[e], [n, r, o] = t, s = r + 1;
428
+ if (s < n) {
429
+ t[1] = s, a[e] = o[s];
430
+ break;
431
+ }
432
+ t[1] = 0, [a[e]] = o;
433
+ }
434
+ }
435
+ function N(e, t) {
436
+ let n = e.length;
437
+ if (n === 1) return e[0].map((e) => t(e));
438
+ let r = 1, i = e.map((e) => {
439
+ let t = e?.length ?? 0;
440
+ return r *= t, [
441
+ t,
442
+ 0,
443
+ e
444
+ ];
445
+ });
446
+ if (r === 0) return [];
447
+ let a = Array(r), o = e.map(([e]) => e), s = 0;
448
+ for (; a[s] = t(...o), s += 1, !(s >= r);) for (let e = n - 1; e >= 0; --e) {
449
+ let t = i[e], [n, r, a] = t, s = r + 1;
450
+ if (s < n) {
451
+ t[1] = s, o[e] = a[s];
452
+ break;
453
+ }
454
+ t[1] = 0, [o[e]] = a;
455
+ }
456
+ return a;
457
+ }
458
+ function P(e, t) {
459
+ return Promise.all(N(e, t));
460
+ }
461
+ async function xe(e, t) {
462
+ return Se(await P(e, t));
463
+ }
464
+ function Se(e) {
465
+ return e.length === 0 ? e : e.length === 1 ? e[0] : e.flat(1);
466
+ }
467
+ //#endregion
468
+ //#region node_modules/@jplorg/jpl/src/library/index.js
469
+ var Ce = /* @__PURE__ */ s({
470
+ DEFINITION_VERSION: () => h,
471
+ DEFINITION_VERSION_MAJOR: () => 1,
472
+ DEFINITION_VERSION_MINOR: () => 0,
473
+ JPLError: () => g,
474
+ JPLErrorEnclosure: () => y,
475
+ JPLExecutionError: () => _,
476
+ JPLFatalError: () => b,
477
+ JPLReferenceError: () => ue,
478
+ JPLRuntimeError: () => j,
479
+ JPLRuntimeScope: () => he,
480
+ JPLSyntaxError: () => pe,
481
+ JPLType: () => x,
482
+ JPLTypeConversionError: () => fe,
483
+ JPLTypeError: () => M,
484
+ JPLZeroDivisionError: () => de,
485
+ OPA_FIELD: () => "$.$",
486
+ OPA_FUNCTION: () => "$()",
487
+ OPA_ITER: () => "$[]",
488
+ OPA_SLICE: () => "[:]",
489
+ OPC_EQUAL: () => "==",
490
+ OPC_GREATER: () => ">",
491
+ OPC_GREATEREQUAL: () => ">=",
492
+ OPC_LESS: () => "<",
493
+ OPC_LESSEQUAL: () => "<=",
494
+ OPC_UNEQUAL: () => "!=",
495
+ OPM_ADDITION: () => "+",
496
+ OPM_DIVISION: () => "/",
497
+ OPM_MULTIPLICATION: () => "*",
498
+ OPM_REMAINDER: () => "%",
499
+ OPM_SUBTRACTION: () => "-",
500
+ OPU_ADDITION: () => "+=",
501
+ OPU_DIVISION: () => "/=",
502
+ OPU_MULTIPLICATION: () => "*=",
503
+ OPU_NULL_COALESCENCE: () => "?=",
504
+ OPU_REMAINDER: () => "%=",
505
+ OPU_SET: () => "=",
506
+ OPU_SUBTRACTION: () => "-=",
507
+ OPU_UPDATE: () => "|=",
508
+ OP_ACCESS: () => "$.",
509
+ OP_AND: () => "and",
510
+ OP_ARRAY_CONSTRUCTOR: () => "[]",
511
+ OP_ASSIGNMENT: () => "$=",
512
+ OP_CALCULATION: () => "clc",
513
+ OP_COMPARISON: () => "cmp",
514
+ OP_CONSTANT: () => "cnt",
515
+ OP_CONSTANT_FALSE: () => "fls",
516
+ OP_CONSTANT_NULL: () => "nul",
517
+ OP_CONSTANT_TRUE: () => "tru",
518
+ OP_FUNCTION_DEFINITION: () => "fun",
519
+ OP_IF: () => "if",
520
+ OP_INTERPOLATED_STRING: () => "\"$\"",
521
+ OP_NEGATION: () => "neg",
522
+ OP_NOT: () => "not",
523
+ OP_NULL_COALESCENCE: () => "??",
524
+ OP_NUMBER: () => "nbr",
525
+ OP_OBJECT_CONSTRUCTOR: () => "{}",
526
+ OP_OR: () => "or",
527
+ OP_OUTPUT_CONCAT: () => ",",
528
+ OP_STRING: () => "\"\"",
529
+ OP_TRY: () => "try",
530
+ OP_VARIABLE: () => "var",
531
+ OP_VARIABLE_DEFINITION: () => "va=",
532
+ OP_VOID: () => "vod",
533
+ adaptError: () => v,
534
+ adaptErrors: () => ee,
535
+ adaptErrorsAsync: () => te,
536
+ applyArray: () => p,
537
+ applyCombinations: () => m,
538
+ applyObject: () => f,
539
+ assertType: () => w,
540
+ displayValue: () => D,
541
+ jplJSONStripper: () => ce,
542
+ jplStripper: () => se,
543
+ jplTypedStripper: () => oe,
544
+ jsonStripper: () => le,
545
+ mux: () => be,
546
+ muxAll: () => xe,
547
+ muxAsync: () => P,
548
+ muxOne: () => N,
549
+ nativeFunction: () => ye,
550
+ normalize: () => S,
551
+ orphanFunction: () => ve,
552
+ rawStripper: () => k,
553
+ scopedFunction: () => _e,
554
+ strictDisplayValue: () => ae,
555
+ stringify: () => T,
556
+ strip: () => O,
557
+ template: () => E,
558
+ typeOf: () => ie,
559
+ typeOrder: () => re,
560
+ unwrap: () => C
561
+ }), we = { vars: {} };
562
+ function F(e = {}, t = {}) {
563
+ return d(e, t, "vars");
564
+ }
565
+ var Te = class {
566
+ constructor(e, t) {
567
+ this._options = F(t?.runtime, we), this._program = e;
568
+ }
569
+ get options() {
570
+ return this._options;
571
+ }
572
+ get program() {
573
+ return this._program;
574
+ }
575
+ createScope = (e) => new he(e);
576
+ execute = async (e) => {
577
+ let t = this.createScope({ vars: Object.fromEntries(this.muxOne([Object.entries(this.options.vars)], ([e, t]) => [e, this.normalizeValue(t)])) });
578
+ try {
579
+ return await this.executeInstructions(this.program.definition.instructions ?? [], e, t, this.options.adjustResult);
580
+ } finally {
581
+ t.signal.exit();
582
+ }
583
+ };
584
+ executeInstructions = (e, t, n, r = (e) => [e]) => {
585
+ let i = async (t, n, a) => {
586
+ if (await void 0, a.signal.checkHealth(), t >= e.length) return r(n, a);
587
+ let { op: o, params: s } = e[t], c = this.program.ops[o];
588
+ if (!c) throw new b(`invalid OP '${o}'`);
589
+ return c.op(this, n, s ?? {}, a, (e, n) => i(t + 1, e, n));
590
+ };
591
+ return this.muxAll([t], (e) => i(0, e, n));
592
+ };
593
+ op(e, t, n, r, i = (e) => [e]) {
594
+ let a = this.program.ops[e];
595
+ if (!a) throw new b(`invalid OP '${e}'`);
596
+ let o = a.map(this, t);
597
+ return this.muxAll([n], (e) => a.op(this, e, o ?? {}, r, i));
598
+ }
599
+ normalizeValue = S;
600
+ normalizeValues = (e = [], t = "values") => {
601
+ if (!Array.isArray(e)) throw new b(`expected ${t} to be an array`);
602
+ return this.normalizeValue(e);
603
+ };
604
+ unwrapValue = C;
605
+ unwrapValues = (e = [], t = "values") => {
606
+ if (!Array.isArray(e)) throw new b(`expected ${t} to be an array`);
607
+ return this.muxOne([e], (e) => this.unwrapValue(e));
608
+ };
609
+ stripValue = (e) => O(e, (e, t) => this.unwrapValue(t));
610
+ stripValues = (e = [], t = "values") => {
611
+ if (!Array.isArray(e)) throw new b(`expected ${t} to be an array`);
612
+ return this.muxOne([e], (e) => this.stripValue(e));
613
+ };
614
+ alterValue = async (e, t) => x.is(e) ? te(() => e.alter(t)) : this.normalizeValue(await t(e));
615
+ type = ie;
616
+ assertType = w;
617
+ truthy = (e) => {
618
+ let t = this.unwrapValue(e);
619
+ return t !== null && t !== !1;
620
+ };
621
+ compare = Ee.bind(this);
622
+ compareStrings = (e, t) => {
623
+ let n = this.type(e);
624
+ if (n !== "string") throw new b(`unexpected type ${n}`);
625
+ let r = this.type(t);
626
+ if (r !== "string") throw new b(`unexpected type ${r}`);
627
+ return I(this.unwrapValue(e), this.unwrapValue(t));
628
+ };
629
+ compareArrays = (e, t) => {
630
+ let n = this.type(e);
631
+ if (n !== "array") throw new b(`unexpected type ${n}`);
632
+ let r = this.type(t);
633
+ if (r !== "array") throw new b(`unexpected type ${r}`);
634
+ return De.call(this, this.unwrapValue(e), this.unwrapValue(t));
635
+ };
636
+ compareObjects = (e, t) => {
637
+ let n = this.type(e);
638
+ if (n !== "object") throw new b(`unexpected type ${n}`);
639
+ let r = this.type(t);
640
+ if (r !== "object") throw new b(`unexpected type ${r}`);
641
+ return Oe.call(this, this.unwrapValue(e), this.unwrapValue(t));
642
+ };
643
+ equals = (e, t) => this.compare(e, t) === 0;
644
+ merge = async (e, t) => (await void 0, this.type(e) !== "object" || this.type(t) !== "object" ? t : this.alterValue(e, async (e) => f(e, await Promise.all(Object.entries(this.unwrapValue(t)).map(async ([t, n]) => [t, await this.merge(e[t] ?? null, n)])))));
645
+ stringifyJSON = (e, t) => T(e, t);
646
+ stripJSON = (e) => O(e);
647
+ mux = be;
648
+ muxOne = N;
649
+ muxAsync = P;
650
+ muxAll = xe;
651
+ };
652
+ function Ee(e, t) {
653
+ let n = this.type(e), r = this.type(t);
654
+ if (n !== r) return re.indexOf(n) - re.indexOf(r);
655
+ let i = this.unwrapValue(e), a = this.unwrapValue(t);
656
+ switch (n) {
657
+ case "null":
658
+ case "function": return 0;
659
+ case "boolean":
660
+ case "number": return i - +a;
661
+ case "string": return I(i, a);
662
+ case "array": return De.call(this, i, a);
663
+ case "object": return Oe.call(this, i, a);
664
+ default: throw new b(`unexpected type ${n}`);
665
+ }
666
+ }
667
+ function I(e, t) {
668
+ let n = Math.min(e.length, t.length), r = 0;
669
+ for (let i of e) {
670
+ if (r >= n) break;
671
+ let i = e.codePointAt(r), a = i - t.codePointAt(r);
672
+ if (a !== 0) return a;
673
+ r += 1, i > 65535 && (r += 1);
674
+ }
675
+ return e.length - t.length;
676
+ }
677
+ function De(e, t) {
678
+ let n = Math.min(e.length, t.length);
679
+ for (let r = 0; r < n; r += 1) {
680
+ let n = Ee.call(this, e[r], t[r]);
681
+ if (n !== 0) return n;
682
+ }
683
+ return e.length - t.length;
684
+ }
685
+ function Oe(e, t) {
686
+ let n = Object.keys(e).sort(I), r = Object.keys(t).sort(I), i = De.call(this, n, r);
687
+ if (i !== 0) return i;
688
+ for (let r of n) if (i = Ee.call(this, e[r], t[r]), i !== 0) return i;
689
+ return 0;
690
+ }
691
+ //#endregion
692
+ //#region node_modules/@jplorg/jpl/src/program/ops/utils.js
693
+ function L(e) {
694
+ return [{
695
+ op: "cnt",
696
+ params: { value: e ?? null }
697
+ }];
698
+ }
699
+ function R(e) {
700
+ return [{
701
+ op: "$.",
702
+ params: {
703
+ pipe: L(w(e, "function")),
704
+ selectors: [{
705
+ op: "$()",
706
+ params: {
707
+ args: [],
708
+ bound: !1,
709
+ optional: !1
710
+ }
711
+ }]
712
+ }
713
+ }];
714
+ }
715
+ //#endregion
716
+ //#region node_modules/@jplorg/jpl/src/program/ops/opAccess/opaField.js
717
+ var ke = {
718
+ op(e, t, n, r, i, a) {
719
+ let o = e.unwrapValue(n), s = e.type(o);
720
+ return e.executeInstructions(r.pipe ?? [], [t], i, (t) => {
721
+ let n = e.unwrapValue(t), i = e.type(n);
722
+ switch (s) {
723
+ case "null":
724
+ if (["string", "number"].includes(i)) return a(null);
725
+ break;
726
+ case "object":
727
+ if (i === "string") return a(o[n] ?? null);
728
+ break;
729
+ case "array":
730
+ if (i === "number") {
731
+ let e = Math.trunc(n);
732
+ return a(o[e >= 0 ? e : o.length + e] ?? null);
733
+ }
734
+ break;
735
+ case "string":
736
+ if (i === "number") {
737
+ let e = Math.trunc(n), t = [...o];
738
+ return a(t[e >= 0 ? e : t.length + e] ?? null);
739
+ }
740
+ break;
741
+ default:
742
+ }
743
+ if (r.optional) return [];
744
+ throw new M("cannot access field of %s (%*<100v) with %s (%*<100v)", s, o, i, n);
745
+ });
746
+ },
747
+ map(e, t) {
748
+ return {
749
+ pipe: R(t.pipe),
750
+ optional: e.assertType(t.optional, "boolean")
751
+ };
752
+ }
753
+ }, Ae = {
754
+ async op(e, t, n, r, i, a) {
755
+ let o = e.unwrapValue(n), s = e.type(o);
756
+ switch (s) {
757
+ case "function": {
758
+ let n = await e.muxAsync([r.args ?? []], (n) => e.executeInstructions(n ?? [], [t], i));
759
+ return e.muxAll(n, async (...n) => {
760
+ try {
761
+ let s = async (e) => {
762
+ try {
763
+ return await a(e);
764
+ } catch (e) {
765
+ throw new y(e);
766
+ }
767
+ };
768
+ return r.bound ? await o(e, i.signal, s, n[0] ?? null, ...n.slice(1)) : await o(e, i.signal, s, t, ...n);
769
+ } catch (e) {
770
+ throw y.is(e) ? e.inner : v(e);
771
+ }
772
+ });
773
+ }
774
+ default:
775
+ }
776
+ if (r.optional) return [];
777
+ throw new M("cannot execute %s (%*<100v)", s, o);
778
+ },
779
+ map(e, t) {
780
+ return {
781
+ args: e.muxOne([t.args], (e) => R(e)),
782
+ bound: e.assertType(t.bound, "boolean"),
783
+ optional: e.assertType(t.optional, "boolean")
784
+ };
785
+ }
786
+ }, je = {
787
+ op(e, t, n, r, i, a) {
788
+ let o = e.unwrapValue(n), s = e.type(o);
789
+ switch (s) {
790
+ case "null": return [];
791
+ case "object": return e.muxAll([Object.values(o)], a);
792
+ case "array": return e.muxAll([o], a);
793
+ case "string": return e.muxAll([[...o]], a);
794
+ default:
795
+ }
796
+ if (r.optional) return [];
797
+ throw new M("cannot iterate over %s (%*<100v)", s, o);
798
+ },
799
+ map(e, t) {
800
+ return { optional: e.assertType(t.optional, "boolean") };
801
+ }
802
+ }, Me = {
803
+ async op(e, t, n, r, i, a) {
804
+ let o = e.unwrapValue(n), s = e.type(o), [c, l] = await Promise.all([e.executeInstructions(r.from ?? [], [t], i), e.executeInstructions(r.to ?? [], [t], i)]);
805
+ return e.muxAll([e.unwrapValues(c), e.unwrapValues(l)], (t, n) => {
806
+ let i = e.type(t), c = e.type(n);
807
+ switch (s) {
808
+ case "null": return a(null);
809
+ case "array":
810
+ if (["number", "null"].includes(i) && ["number", "null"].includes(c)) return a(o.slice(Math.trunc(t ?? 0), Math.trunc(n ?? o.length)));
811
+ break;
812
+ case "string":
813
+ if (["number", "null"].includes(i) && ["number", "null"].includes(c)) {
814
+ let e = [...o];
815
+ return a(e.slice(Math.trunc(t ?? 0), Math.trunc(n ?? e.length)).join(""));
816
+ }
817
+ break;
818
+ default:
819
+ }
820
+ if (r.optional) return [];
821
+ throw new M("cannot slice %s (%*<100v) with %s (%*<100v) and %s (%*<100v)", s, o, i, t, c, n);
822
+ });
823
+ },
824
+ map(e, t) {
825
+ return {
826
+ from: R(t.from),
827
+ to: R(t.to),
828
+ optional: e.assertType(t.optional, "boolean")
829
+ };
830
+ }
831
+ }, Ne = {
832
+ op(e, t, n, r, i) {
833
+ let a = async (o, s) => {
834
+ if (await void 0, r.signal.checkHealth(), o >= (n.selectors?.length ?? 0)) return i(s, r);
835
+ let { op: c, params: l } = n.selectors[o], u = Pe[c];
836
+ if (!u) throw new b(`invalid OPA '${c}'`);
837
+ return u.op(e, t, s, l ?? {}, r, (e) => a(o + 1, e));
838
+ };
839
+ return e.executeInstructions(n.pipe ?? [], [t], r, (e) => a(0, e));
840
+ },
841
+ map(e, t) {
842
+ return {
843
+ pipe: R(t.pipe),
844
+ selectors: e.muxOne([t.selectors], ({ op: t, params: n }) => {
845
+ let r = Pe[t];
846
+ if (!r) throw new b(`invalid OPA '${t}'`);
847
+ return {
848
+ op: e.assertType(t, "string"),
849
+ params: r.map(e, n)
850
+ };
851
+ })
852
+ };
853
+ }
854
+ }, Pe = {
855
+ "$.$": ke,
856
+ "$()": Ae,
857
+ "$[]": je,
858
+ "[:]": Me
859
+ }, Fe = {
860
+ op(e, t, n, r, i) {
861
+ let a = async (o) => {
862
+ if (await void 0, r.signal.checkHealth(), o >= (n.pipes?.length ?? 0)) return i(!0, r);
863
+ let s = n.pipes[o];
864
+ return e.executeInstructions(s ?? [], [t], r, (t) => e.truthy(t) ? a(o + 1) : i(!1, r));
865
+ };
866
+ return a(0);
867
+ },
868
+ map(e, t) {
869
+ return { pipes: e.muxOne([t.pipes], (e) => R(e)) };
870
+ }
871
+ }, Ie = {
872
+ async op(e, t, n, r, i) {
873
+ return i(await e.executeInstructions(n.pipe ?? [], [t], r), r);
874
+ },
875
+ map(e, t) {
876
+ return { pipe: R(t.pipe) };
877
+ }
878
+ }, Le = {
879
+ async op(e, t, n, r, i, a) {
880
+ let o, s = e.unwrapValue(n), c = e.type(n);
881
+ switch (c) {
882
+ case "null":
883
+ case "object":
884
+ case "array":
885
+ o = s;
886
+ break;
887
+ case "string":
888
+ o = [...s];
889
+ break;
890
+ default:
891
+ if (r.optional) return [void 0];
892
+ throw new M("cannot access fields of %s (%*<100v) (assignment)", c, s);
893
+ }
894
+ let l = await e.executeInstructions(r.pipe ?? [], [t], i, (e) => [e]), u = async (t, n) => {
895
+ if (await void 0, i.signal.checkHealth(), t >= l.length) return [n];
896
+ let o = c === "string" ? c : e.type(n), s = e.unwrapValue(l[t]), d = e.type(s);
897
+ switch (o) {
898
+ case "null":
899
+ switch (d) {
900
+ case "string": return e.muxAll([await a(null)], (e) => e === void 0 ? u(t + 1, n) : u(t + 1, { [s]: e }));
901
+ case "number": {
902
+ let r = Math.trunc(s);
903
+ return e.muxAll([await a(null)], (e) => e === void 0 ? u(t + 1, n) : u(t + 1, p([], [[r, e]])));
904
+ }
905
+ default:
906
+ }
907
+ break;
908
+ case "object":
909
+ if (d === "string") {
910
+ let r = n[s];
911
+ return e.muxAll([await a(r ?? null)], (e) => e === void 0 ? u(t + 1, n) : u(t + 1, f(n, [[s, e]])));
912
+ }
913
+ break;
914
+ case "array":
915
+ if (d === "number") {
916
+ let r = Math.trunc(s), i = n[r >= 0 ? r : n.length + r];
917
+ return e.muxAll([await a(i ?? null)], (e) => e === void 0 ? u(t + 1, n) : u(t + 1, p(n, [[r, e]])));
918
+ }
919
+ break;
920
+ case "string":
921
+ if (d === "number") {
922
+ let r = Math.trunc(s), i = n[r >= 0 ? r : n.length + r];
923
+ return e.muxAll([await a(i ?? null)], (i) => {
924
+ if (i === void 0) return u(t + 1, n);
925
+ let a = e.unwrapValue(i), o = e.type(a);
926
+ switch (o) {
927
+ case "null":
928
+ case "string": return u(t + 1, p(n, [[r, i ?? " "]], " "));
929
+ default:
930
+ }
931
+ throw new M("cannot assign %s (%*<100v) to string (%*<100v)", o, a, n.join(""));
932
+ });
933
+ }
934
+ break;
935
+ default:
936
+ }
937
+ if (r.optional) return u(t + 1, n);
938
+ throw new M("cannot access field of %s (%*<100v) with %s (%*<100v) (assignment)", o, o === "string" ? n.join("") : n, d, s);
939
+ };
940
+ return e.muxAsync([await u(0, o)], (t) => {
941
+ if (o === t) return n;
942
+ switch (c === "string" ? c : e.type(t)) {
943
+ case "null": return;
944
+ case "object":
945
+ case "array": return e.alterValue(n, () => t);
946
+ case "string": return e.alterValue(n, () => t.join(""));
947
+ default:
948
+ }
949
+ });
950
+ },
951
+ map(e, t) {
952
+ return {
953
+ pipe: R(t.pipe),
954
+ optional: e.assertType(t.optional, "boolean")
955
+ };
956
+ }
957
+ }, Re = {
958
+ async op(e, t, n, r, i, a) {
959
+ let o = e.unwrapValue(n), s = e.type(o);
960
+ switch (s) {
961
+ case "null": return [void 0];
962
+ case "object": {
963
+ let t = Object.entries(o), r = await e.muxAsync([t], async (t) => e.muxAsync([await a(t[1] ?? null)], (e) => e === void 0 ? t : [t[0], e]));
964
+ return e.muxAsync([m(t, r)], (r) => t === r ? n : e.alterValue(n, () => Object.fromEntries(r)));
965
+ }
966
+ case "array": {
967
+ let t = o, r = await e.muxAsync([t], async (t) => e.muxAsync([await a(t ?? null)], (e) => e === void 0 ? t : e));
968
+ return e.muxAsync([m(t, r)], (r) => t === r ? n : e.alterValue(n, () => r));
969
+ }
970
+ case "string": {
971
+ let t = [...o], r = await e.muxAsync([t], async (t) => e.muxAsync([await a(t)], (n) => {
972
+ if (n === void 0) return t;
973
+ let r = e.unwrapValue(n), i = e.type(r);
974
+ switch (i) {
975
+ case "null":
976
+ case "string": return r ?? " ";
977
+ default:
978
+ }
979
+ throw new M("cannot assign %s (%*<100v) to string (%*<100v)", i, r, o);
980
+ }));
981
+ return e.muxAsync([m(t, r)], (r) => t === r ? n : e.alterValue(n, () => r.join("")));
982
+ }
983
+ default:
984
+ }
985
+ if (r.optional) return [void 0];
986
+ throw new M("cannot iterate over %s (%*<100v) (assignment)", s, o);
987
+ },
988
+ map(e, t) {
989
+ return { optional: e.assertType(t.optional, "boolean") };
990
+ }
991
+ };
992
+ //#endregion
993
+ //#region node_modules/@jplorg/jpl/src/program/ops/opAssignment/opaAssignSlice.js
994
+ function ze(e, t) {
995
+ return e.length === t.length ? e.every((e, n) => e === t[n]) : !1;
996
+ }
997
+ var Be = {
998
+ async op(e, t, n, r, i, a) {
999
+ let [o, s] = await Promise.all([e.executeInstructions(r.from ?? [], [t], i), e.executeInstructions(r.to ?? [], [t], i)]), c = e.muxOne([e.unwrapValues(o), e.unwrapValues(s)], (e, t) => [e, t]), l = async (t, n) => {
1000
+ if (await void 0, i.signal.checkHealth(), t >= c.length) return [n];
1001
+ let o = e.unwrapValue(n), s = e.type(n), [u, d] = c[t], f = e.type(u), p = e.type(d);
1002
+ switch (s) {
1003
+ case "null": return l(t + 1, n);
1004
+ case "array":
1005
+ if (["number", "null"].includes(f) && ["number", "null"].includes(p)) return e.muxAll([await a(o.slice(Math.trunc(u ?? 0), Math.trunc(d ?? o.length)))], async (r) => r === void 0 ? l(t + 1, n) : l(t + 1, await e.alterValue(n, (t) => {
1006
+ let n = e.unwrapValue(r), i = e.type(n);
1007
+ switch (i) {
1008
+ case "null":
1009
+ case "array": {
1010
+ let e = Math.trunc(u ?? 0), r = Math.trunc(d ?? t.length);
1011
+ if (e = e >= 0 ? Math.min(t.length, e) : Math.max(0, t.length + e), r = Math.max(e, r >= 0 ? Math.min(t.length, r) : Math.max(0, t.length + r)), ze(t.slice(e, r), n ?? [])) return t;
1012
+ let i = [...t];
1013
+ return i.splice(e, r - e, ...n ?? []), i;
1014
+ }
1015
+ default:
1016
+ }
1017
+ throw new M("cannot assign %s (%*<100v) to slice of %s (%*<100v)", i, n, s, t);
1018
+ })));
1019
+ break;
1020
+ case "string":
1021
+ if (["number", "null"].includes(f) && ["number", "null"].includes(p)) {
1022
+ let r = [...o];
1023
+ return e.muxAll([await a(r.slice(Math.trunc(u ?? 0), Math.trunc(d ?? r.length)).join(""))], async (r) => r === void 0 ? l(t + 1, n) : l(t + 1, await e.alterValue(n, (t) => {
1024
+ let n = e.unwrapValue(r), i = e.type(n);
1025
+ switch (i) {
1026
+ case "null":
1027
+ case "string": {
1028
+ let e = [...t], r = Math.trunc(u ?? 0), i = Math.trunc(d ?? e.length);
1029
+ return r = r >= 0 ? Math.min(e.length, r) : Math.max(0, e.length + r), i = Math.max(r, i >= 0 ? Math.min(e.length, i) : Math.max(0, e.length + i)), ze(e.slice(r, i), n ?? []) ? t : (e.splice(r, i - r, ...n ?? []), e.join(""));
1030
+ }
1031
+ default:
1032
+ }
1033
+ throw new M("cannot assign %s (%*<100v) to slice of %s (%*<100v)", i, n, s, t);
1034
+ })));
1035
+ }
1036
+ break;
1037
+ default:
1038
+ }
1039
+ if (r.optional) return l(t + 1, n);
1040
+ throw new M("cannot slice %s (%*<100v) with %s (%*<100v) and %s (%*<100v) (assignment)", s, o, f, u, p, d);
1041
+ };
1042
+ return e.muxOne([await l(0, n)], (t) => e.type(t) === "null" ? void 0 : t);
1043
+ },
1044
+ map(e, t) {
1045
+ return {
1046
+ from: R(t.from),
1047
+ to: R(t.to),
1048
+ optional: e.assertType(t.optional, "boolean")
1049
+ };
1050
+ }
1051
+ }, Ve = {
1052
+ op(e, t, n, r, i, a) {
1053
+ return e.executeInstructions([{
1054
+ op: "clc",
1055
+ params: {
1056
+ pipe: L(n),
1057
+ operations: [{
1058
+ op: "+",
1059
+ params: { by: r.pipe ?? [] }
1060
+ }]
1061
+ }
1062
+ }], [t], i, a);
1063
+ },
1064
+ map(e, t) {
1065
+ return { pipe: R(t.pipe) };
1066
+ }
1067
+ }, He = {
1068
+ op(e, t, n, r, i, a) {
1069
+ return e.executeInstructions([{
1070
+ op: "clc",
1071
+ params: {
1072
+ pipe: L(n),
1073
+ operations: [{
1074
+ op: "/",
1075
+ params: { by: r.pipe ?? [] }
1076
+ }]
1077
+ }
1078
+ }], [t], i, a);
1079
+ },
1080
+ map(e, t) {
1081
+ return { pipe: R(t.pipe) };
1082
+ }
1083
+ }, Ue = {
1084
+ op(e, t, n, r, i, a) {
1085
+ return e.executeInstructions([{
1086
+ op: "clc",
1087
+ params: {
1088
+ pipe: L(n),
1089
+ operations: [{
1090
+ op: "*",
1091
+ params: { by: r.pipe ?? [] }
1092
+ }]
1093
+ }
1094
+ }], [t], i, a);
1095
+ },
1096
+ map(e, t) {
1097
+ return { pipe: R(t.pipe) };
1098
+ }
1099
+ }, We = {
1100
+ op(e, t, n, r, i, a) {
1101
+ return e.executeInstructions([{
1102
+ op: "??",
1103
+ params: { pipes: [L(n), r.pipe ?? []] }
1104
+ }], [t], i, a);
1105
+ },
1106
+ map(e, t) {
1107
+ return { pipe: R(t.pipe) };
1108
+ }
1109
+ }, Ge = {
1110
+ op(e, t, n, r, i, a) {
1111
+ return e.executeInstructions([{
1112
+ op: "clc",
1113
+ params: {
1114
+ pipe: L(n),
1115
+ operations: [{
1116
+ op: "%",
1117
+ params: { by: r.pipe ?? [] }
1118
+ }]
1119
+ }
1120
+ }], [t], i, a);
1121
+ },
1122
+ map(e, t) {
1123
+ return { pipe: R(t.pipe) };
1124
+ }
1125
+ }, Ke = {
1126
+ op(e, t, n, r, i, a) {
1127
+ return e.executeInstructions(r.pipe ?? [], [t], i, a);
1128
+ },
1129
+ map(e, t) {
1130
+ return { pipe: R(t.pipe) };
1131
+ }
1132
+ }, qe = {
1133
+ op(e, t, n, r, i, a) {
1134
+ return e.executeInstructions([{
1135
+ op: "clc",
1136
+ params: {
1137
+ pipe: L(n),
1138
+ operations: [{
1139
+ op: "-",
1140
+ params: { by: r.pipe ?? [] }
1141
+ }]
1142
+ }
1143
+ }], [t], i, a);
1144
+ },
1145
+ map(e, t) {
1146
+ return { pipe: R(t.pipe) };
1147
+ }
1148
+ }, Je = {
1149
+ op(e, t, n, r, i, a) {
1150
+ return e.executeInstructions(r.pipe ?? [], [n], i, a);
1151
+ },
1152
+ map(e, t) {
1153
+ return { pipe: R(t.pipe) };
1154
+ }
1155
+ }, Ye = {
1156
+ op(e, t, n, r, i) {
1157
+ let a = async (i, o) => {
1158
+ if (await void 0, r.signal.checkHealth(), i >= (n.selectors?.length ?? 0)) {
1159
+ let { op: i, params: a } = n.assignment ?? {}, s = Ze[i];
1160
+ if (!s) throw new b(`invalid OPU '${i}'`);
1161
+ return s.op(e, t, o, a ?? {}, r, (e) => [e]);
1162
+ }
1163
+ let { op: s, params: c } = n.selectors[i], l = Xe[s];
1164
+ if (!l) throw new b(`invalid OPA '${s}' (assignment)`);
1165
+ return l.op(e, t, o, c ?? {}, r, (e) => a(i + 1, e));
1166
+ };
1167
+ return e.executeInstructions(n.pipe ?? [], [t], r, async (t) => e.muxAll([await a(0, t)], (e) => i(e === void 0 ? t : e, r)));
1168
+ },
1169
+ map(e, t) {
1170
+ return {
1171
+ pipe: R(t.pipe),
1172
+ selectors: e.muxOne([t.selectors], ({ op: t, params: n }) => {
1173
+ let r = Xe[t];
1174
+ if (!r) throw new b(`invalid OPA '${t}' (assignment)`);
1175
+ return {
1176
+ op: e.assertType(t, "string"),
1177
+ params: r.map(e, n)
1178
+ };
1179
+ }),
1180
+ assignment: (({ op: t, params: n }) => {
1181
+ let r = Ze[t];
1182
+ if (!r) throw new b(`invalid OPU '${t}'`);
1183
+ return {
1184
+ op: e.assertType(t, "string"),
1185
+ params: r.map(e, n)
1186
+ };
1187
+ })(t.assignment)
1188
+ };
1189
+ }
1190
+ }, Xe = {
1191
+ "$.$": Le,
1192
+ "$[]": Re,
1193
+ "[:]": Be
1194
+ }, Ze = {
1195
+ "+=": Ve,
1196
+ "/=": He,
1197
+ "*=": Ue,
1198
+ "?=": We,
1199
+ "%=": Ge,
1200
+ "=": Ke,
1201
+ "-=": qe,
1202
+ "|=": Je
1203
+ }, Qe = {
1204
+ op(e, t, n, r, i, a) {
1205
+ return e.executeInstructions(r.by ?? [], [t], i, async (t) => a(await e.alterValue(n, (n) => {
1206
+ let r = e.unwrapValue(t), i = e.type(n), a = e.type(r);
1207
+ if (i === "null" || a === "null") return i === "null" ? a === "null" ? null : r : n;
1208
+ switch (i) {
1209
+ case "number":
1210
+ if (a === "number") return n + r;
1211
+ break;
1212
+ case "array":
1213
+ if (a === "array") return r.length === 0 ? n : n.length === 0 ? r : [...n, ...r];
1214
+ break;
1215
+ case "string":
1216
+ if (a === "string") return n + r;
1217
+ break;
1218
+ case "object":
1219
+ if (a === "object") return f(n, Object.entries(r));
1220
+ break;
1221
+ default:
1222
+ }
1223
+ throw new M("%s (%*<100v) and %s (%*<100v) cannot be added together", i, n, a, r);
1224
+ })));
1225
+ },
1226
+ map(e, t) {
1227
+ return { by: R(t.by) };
1228
+ }
1229
+ }, $e = {
1230
+ op(e, t, n, r, i, a) {
1231
+ return e.executeInstructions(r.by ?? [], [t], i, async (t) => a(await e.alterValue(n, (n) => {
1232
+ let r = e.unwrapValue(t), i = e.type(n), a = e.type(r);
1233
+ switch (i) {
1234
+ case "number":
1235
+ if (a === "number") {
1236
+ if (r === 0) throw new de("%s (%*<100v) cannot be divided by zero", i, n);
1237
+ return n / r;
1238
+ }
1239
+ break;
1240
+ case "string":
1241
+ if (a === "string") return r === "" ? [...n] : n.split(r);
1242
+ break;
1243
+ default:
1244
+ }
1245
+ throw new M("%s (%*<100v) cannot be divided by %s (%*<100v)", i, n, a, r);
1246
+ })));
1247
+ },
1248
+ map(e, t) {
1249
+ return { by: R(t.by) };
1250
+ }
1251
+ }, et = {
1252
+ op(e, t, n, r, i, a) {
1253
+ return e.executeInstructions(r.by ?? [], [t], i, async (t) => a(await e.alterValue(n, (n) => {
1254
+ let r = e.unwrapValue(t), i = e.type(n), a = e.type(r);
1255
+ switch (i) {
1256
+ case "number":
1257
+ if (a === "number") return n * r;
1258
+ break;
1259
+ case "string":
1260
+ if (a === "number") return r < 1 ? null : n.repeat(r);
1261
+ break;
1262
+ case "object":
1263
+ if (a === "object") return e.merge(n, r);
1264
+ break;
1265
+ default:
1266
+ }
1267
+ throw new M("%s (%*<100v) and %s (%*<100v) cannot be multiplied together", i, n, a, r);
1268
+ })));
1269
+ },
1270
+ map(e, t) {
1271
+ return { by: R(t.by) };
1272
+ }
1273
+ }, tt = {
1274
+ op(e, t, n, r, i, a) {
1275
+ return e.executeInstructions(r.by ?? [], [t], i, async (t) => a(await e.alterValue(n, (n) => {
1276
+ let r = e.unwrapValue(t), i = e.type(n), a = e.type(r);
1277
+ switch (i) {
1278
+ case "number":
1279
+ if (a === "number") {
1280
+ if (r === 0) throw new de("%s (%*<100v) cannot be divided by zero (remainder)", i, n);
1281
+ return n % r;
1282
+ }
1283
+ break;
1284
+ default:
1285
+ }
1286
+ throw new M("%s (%*<100v) cannot be divided by %s (%*<100v) (remainder)", i, n, a, r);
1287
+ })));
1288
+ },
1289
+ map(e, t) {
1290
+ return { by: R(t.by) };
1291
+ }
1292
+ }, nt = {
1293
+ op(e, t, n, r, i, a) {
1294
+ return e.executeInstructions(r.by ?? [], [t], i, async (t) => a(await e.alterValue(n, (n) => {
1295
+ let r = e.unwrapValue(t), i = e.type(n), a = e.type(r);
1296
+ switch (i) {
1297
+ case "number":
1298
+ if (a === "number") return n - r;
1299
+ break;
1300
+ case "array":
1301
+ if (a === "array") {
1302
+ if (n.length === 0 || r.length === 0) return n;
1303
+ let t = n.filter((t) => !r.some((n) => e.equals(t, n)));
1304
+ return n.length === t.length ? n : t;
1305
+ }
1306
+ break;
1307
+ case "string":
1308
+ if (a === "string") return n.replaceAll(r, "");
1309
+ break;
1310
+ case "object":
1311
+ switch (a) {
1312
+ case "array": return r.length === 0 ? n : f(n, Object.entries(n).filter(([, t]) => r.some((n) => e.equals(t, n))).map(([e]) => [e]));
1313
+ case "string": return f(n, [[r]]);
1314
+ default:
1315
+ }
1316
+ break;
1317
+ default:
1318
+ }
1319
+ throw new M("%s (%*<100v) and %s (%*<100v) cannot be subtracted", i, n, a, r);
1320
+ })));
1321
+ },
1322
+ map(e, t) {
1323
+ return { by: R(t.by) };
1324
+ }
1325
+ }, rt = {
1326
+ op(e, t, n, r, i) {
1327
+ let a = async (o, s) => {
1328
+ if (await void 0, r.signal.checkHealth(), o >= (n.operations?.length ?? 0)) return i(s, r);
1329
+ let { op: c, params: l } = n.operations[o], u = it[c];
1330
+ if (!u) throw new b(`invalid OPM '${c}'`);
1331
+ return u.op(e, t, s, l ?? {}, r, (e) => a(o + 1, e));
1332
+ };
1333
+ return e.executeInstructions(n.pipe ?? [], [t], r, (e) => a(0, e));
1334
+ },
1335
+ map(e, t) {
1336
+ return {
1337
+ pipe: R(t.pipe),
1338
+ operations: e.muxOne([t.operations], ({ op: t, params: n }) => {
1339
+ let r = it[t];
1340
+ if (!r) throw new b(`invalid OPM '${t}'`);
1341
+ return {
1342
+ op: e.assertType(t, "string"),
1343
+ params: r.map(e, n)
1344
+ };
1345
+ })
1346
+ };
1347
+ }
1348
+ }, it = {
1349
+ "+": Qe,
1350
+ "/": $e,
1351
+ "*": et,
1352
+ "%": tt,
1353
+ "-": nt
1354
+ }, at = {
1355
+ op(e, t, n, r, i, a) {
1356
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(e.equals(n, t)));
1357
+ },
1358
+ map(e, t) {
1359
+ return { by: R(t.by) };
1360
+ }
1361
+ }, ot = {
1362
+ op(e, t, n, r, i, a) {
1363
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(e.compare(n, t) > 0));
1364
+ },
1365
+ map(e, t) {
1366
+ return { by: R(t.by) };
1367
+ }
1368
+ }, st = {
1369
+ op(e, t, n, r, i, a) {
1370
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(e.compare(n, t) >= 0));
1371
+ },
1372
+ map(e, t) {
1373
+ return { by: R(t.by) };
1374
+ }
1375
+ }, ct = {
1376
+ op(e, t, n, r, i, a) {
1377
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(e.compare(n, t) < 0));
1378
+ },
1379
+ map(e, t) {
1380
+ return { by: R(t.by) };
1381
+ }
1382
+ }, lt = {
1383
+ op(e, t, n, r, i, a) {
1384
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(e.compare(n, t) <= 0));
1385
+ },
1386
+ map(e, t) {
1387
+ return { by: R(t.by) };
1388
+ }
1389
+ }, ut = {
1390
+ op(e, t, n, r, i, a) {
1391
+ return e.executeInstructions(r.by ?? [], [t], i, (t) => a(!e.equals(n, t)));
1392
+ },
1393
+ map(e, t) {
1394
+ return { by: R(t.by) };
1395
+ }
1396
+ }, dt = {
1397
+ op(e, t, n, r, i) {
1398
+ let a = async (o, s) => {
1399
+ if (await void 0, r.signal.checkHealth(), o >= (n.comparisons?.length ?? 0)) return i(s, r);
1400
+ let { op: c, params: l } = n.comparisons[o], u = ft[c];
1401
+ if (!u) throw new b(`invalid OPC '${c}'`);
1402
+ return u.op(e, t, s, l ?? {}, r, (e) => a(o + 1, e));
1403
+ };
1404
+ return e.executeInstructions(n.pipe ?? [], [t], r, (e) => a(0, e));
1405
+ },
1406
+ map(e, t) {
1407
+ return {
1408
+ pipe: R(t.pipe),
1409
+ comparisons: e.muxOne([t.comparisons], ({ op: t, params: n }) => {
1410
+ let r = ft[t];
1411
+ if (!r) throw new b(`invalid OPC '${t}'`);
1412
+ return {
1413
+ op: e.assertType(t, "string"),
1414
+ params: r.map(e, n)
1415
+ };
1416
+ })
1417
+ };
1418
+ }
1419
+ }, ft = {
1420
+ "==": at,
1421
+ ">": ot,
1422
+ ">=": st,
1423
+ "<": ct,
1424
+ "<=": lt,
1425
+ "!=": ut
1426
+ }, pt = {
1427
+ "$.": Ne,
1428
+ and: Fe,
1429
+ "[]": Ie,
1430
+ "$=": Ye,
1431
+ clc: rt,
1432
+ cmp: dt,
1433
+ cnt: {
1434
+ op(e, t, n, r, i) {
1435
+ return i(n.value ?? null, r);
1436
+ },
1437
+ map(e, t) {
1438
+ return { value: e.normalizeValue(t.value) };
1439
+ }
1440
+ },
1441
+ fls: {
1442
+ op(e, t, n, r, i) {
1443
+ return i(!1, r);
1444
+ },
1445
+ map() {
1446
+ return {};
1447
+ }
1448
+ },
1449
+ nul: {
1450
+ op(e, t, n, r, i) {
1451
+ return i(null, r);
1452
+ },
1453
+ map() {
1454
+ return {};
1455
+ }
1456
+ },
1457
+ tru: {
1458
+ op(e, t, n, r, i) {
1459
+ return i(!0, r);
1460
+ },
1461
+ map() {
1462
+ return {};
1463
+ }
1464
+ },
1465
+ fun: {
1466
+ op(e, t, n, r, i) {
1467
+ return i(_e(n.argNames ?? [], n.pipe ?? [], r), r);
1468
+ },
1469
+ map(e, t) {
1470
+ return {
1471
+ argNames: e.muxOne([t.argNames], (t) => e.assertType(t, "string")),
1472
+ pipe: R(t.pipe)
1473
+ };
1474
+ }
1475
+ },
1476
+ if: {
1477
+ op(e, t, n, r, i) {
1478
+ let a = async (o) => {
1479
+ if (await void 0, r.signal.checkHealth(), o >= (n.ifs?.length ?? 0)) return e.executeInstructions(n.else ?? [], [t], r, (e) => i(e, r));
1480
+ let s = n.ifs[o];
1481
+ return e.executeInstructions(s.if ?? [], [t], r, (n) => e.truthy(n) ? e.executeInstructions(s.then ?? [], [t], r, (e) => i(e, r)) : a(o + 1));
1482
+ };
1483
+ return a(0);
1484
+ },
1485
+ map(e, t) {
1486
+ return {
1487
+ ifs: e.muxOne([t.ifs], (e) => ({
1488
+ if: R(e.if),
1489
+ then: R(e.then)
1490
+ })),
1491
+ else: R(t.else)
1492
+ };
1493
+ }
1494
+ },
1495
+ "\"$\"": {
1496
+ async op(e, t, n, r, i) {
1497
+ let a = await e.muxAsync([n.interpolations ?? []], (n) => e.executeInstructions(n.pipe ?? [], [t], r, (t) => [(n.before ?? "") + e.stringifyJSON(t, !0)]));
1498
+ return e.muxAll(a, (...e) => i(e.join("") + (n.after ?? ""), r));
1499
+ },
1500
+ map(e, t) {
1501
+ return {
1502
+ interpolations: e.muxOne([t.interpolations], (t) => ({
1503
+ before: e.assertType(t.before, "string"),
1504
+ pipe: R(t.pipe)
1505
+ })),
1506
+ after: e.assertType(t.after, "string")
1507
+ };
1508
+ }
1509
+ },
1510
+ neg: {
1511
+ async op(e, t, n, r, i) {
1512
+ return i(await e.alterValue(t, (t) => {
1513
+ let n = e.type(t);
1514
+ switch (n) {
1515
+ case "number": return -t;
1516
+ default:
1517
+ }
1518
+ throw new M("%s (%*<100v) cannot be negated", n, t);
1519
+ }), r);
1520
+ },
1521
+ map() {
1522
+ return {};
1523
+ }
1524
+ },
1525
+ not: {
1526
+ op(e, t, n, r, i) {
1527
+ return i(!e.truthy(t), r);
1528
+ },
1529
+ map() {
1530
+ return {};
1531
+ }
1532
+ },
1533
+ "??": {
1534
+ op(e, t, n, r, i) {
1535
+ let a = async (o) => {
1536
+ if (await void 0, r.signal.checkHealth(), o >= (n.pipes?.length ?? 0)) return i(null, r);
1537
+ let s = n.pipes[o];
1538
+ return e.executeInstructions(s ?? [], [t], r, (t) => {
1539
+ switch (e.type(t)) {
1540
+ case "null": return a(o + 1);
1541
+ default: return i(t, r);
1542
+ }
1543
+ });
1544
+ };
1545
+ return a(0);
1546
+ },
1547
+ map(e, t) {
1548
+ return { pipes: e.muxOne([t.pipes], (e) => R(e)) };
1549
+ }
1550
+ },
1551
+ nbr: {
1552
+ op(e, t, n, r, i) {
1553
+ return i(n.number ?? 0, r);
1554
+ },
1555
+ map(e, t) {
1556
+ return { number: e.assertType(t.number, "number") };
1557
+ }
1558
+ },
1559
+ "{}": {
1560
+ async op(e, t, n, r, i) {
1561
+ let a = await e.muxAsync([n.fields ?? []], async (n) => {
1562
+ let [i, a] = await Promise.all([e.executeInstructions(n.key ?? [], [t], r), e.executeInstructions(n.value ?? [], [t], r)]);
1563
+ return e.muxAll([e.unwrapValues(i), a], (t, r) => {
1564
+ let i = e.type(t);
1565
+ switch (i) {
1566
+ case "string": return [[t, r]];
1567
+ default:
1568
+ }
1569
+ if (n.optional) return [];
1570
+ throw new M("cannot use %s (%*<100v) as object key", i, t);
1571
+ });
1572
+ });
1573
+ return e.muxAll(a, (...e) => i(Object.fromEntries(e), r));
1574
+ },
1575
+ map(e, t) {
1576
+ return { fields: e.muxOne([t.fields], (t) => ({
1577
+ key: R(t.key),
1578
+ value: R(t.value),
1579
+ optional: e.assertType(t.optional, "boolean")
1580
+ })) };
1581
+ }
1582
+ },
1583
+ or: {
1584
+ op(e, t, n, r, i) {
1585
+ let a = async (o) => {
1586
+ if (await void 0, r.signal.checkHealth(), o >= (n.pipes?.length ?? 0)) return i(!1, r);
1587
+ let s = n.pipes[o];
1588
+ return e.executeInstructions(s ?? [], [t], r, (t) => e.truthy(t) ? i(!0, r) : a(o + 1));
1589
+ };
1590
+ return a(0);
1591
+ },
1592
+ map(e, t) {
1593
+ return { pipes: e.muxOne([t.pipes], (e) => R(e)) };
1594
+ }
1595
+ },
1596
+ ",": {
1597
+ op(e, t, n, r, i) {
1598
+ return e.muxAll([n.pipes ?? []], (n) => e.executeInstructions(n ?? [], [t], r, (e) => i(e, r)));
1599
+ },
1600
+ map(e, t) {
1601
+ return { pipes: e.muxOne([t.pipes], (e) => R(e)) };
1602
+ }
1603
+ },
1604
+ "\"\"": {
1605
+ op(e, t, n, r, i) {
1606
+ return i(n.string ?? "", r);
1607
+ },
1608
+ map(e, t) {
1609
+ return { string: e.assertType(t.string, "string") };
1610
+ }
1611
+ },
1612
+ try: {
1613
+ async op(e, t, n, r, i) {
1614
+ let a = r.next({ signal: r.signal.next() });
1615
+ try {
1616
+ return await e.executeInstructions(n.try ?? [], [t], a, async (e) => {
1617
+ try {
1618
+ return await i(e, r);
1619
+ } catch (e) {
1620
+ throw new y(e);
1621
+ }
1622
+ });
1623
+ } catch (t) {
1624
+ if (y.is(t)) throw t.inner;
1625
+ if (!_.is(t)) throw t;
1626
+ return a.signal.exit(), e.executeInstructions(n.catch ?? [], [t.value], r, (e) => i(e, r));
1627
+ }
1628
+ },
1629
+ map(e, t) {
1630
+ return {
1631
+ try: R(t.try),
1632
+ catch: R(t.catch)
1633
+ };
1634
+ }
1635
+ },
1636
+ var: {
1637
+ op(e, t, n, r, i) {
1638
+ if (!Object.hasOwn(r.vars, n.name ?? "")) throw new ue("%s is not defined", n.name ?? "");
1639
+ return i(r.vars[n.name ?? ""], r);
1640
+ },
1641
+ map(e, t) {
1642
+ return { name: e.assertType(t.name, "string") };
1643
+ }
1644
+ },
1645
+ "va=": {
1646
+ op(e, t, n, r, i) {
1647
+ return e.executeInstructions(n.pipe ?? [], [t], r, (e) => i(t, r.next({ vars: { [n.name ?? ""]: e } })));
1648
+ },
1649
+ map(e, t) {
1650
+ return {
1651
+ name: e.assertType(t.name, "string"),
1652
+ pipe: R(t.pipe)
1653
+ };
1654
+ }
1655
+ },
1656
+ vod: {
1657
+ op() {
1658
+ return [];
1659
+ },
1660
+ map() {
1661
+ return {};
1662
+ }
1663
+ }
1664
+ }, mt = {};
1665
+ function ht(e = {}, t = {}) {
1666
+ return d(e, t);
1667
+ }
1668
+ function gt(e) {
1669
+ let t = e?.version, [, n, r] = typeof t == "string" ? /^(\d+)\.(\d+)?$/g.exec(t) ?? [] : [];
1670
+ if (!n || !r || !Array.isArray(e.instructions)) throw new b("invalid program definition");
1671
+ if (+n != 1 || +r > 0) throw new b(`unsupported program definition v${n}.${r} - this version of JPL only supports v1 (up to v${h})`);
1672
+ }
1673
+ var _t = class e {
1674
+ constructor(e, t) {
1675
+ gt(e), this._options = ht(t?.program, mt), this._runtimeOptions = t?.runtime, this._definition = e, this._ops = pt;
1676
+ }
1677
+ get options() {
1678
+ return this._options;
1679
+ }
1680
+ get definition() {
1681
+ return this._definition;
1682
+ }
1683
+ get ops() {
1684
+ return this._ops;
1685
+ }
1686
+ run = async (e, t) => {
1687
+ let n = new Te(this, { runtime: F(t?.runtime, this._runtimeOptions) }), r = n.normalizeValues(e, "program inputs"), i = await n.execute(r);
1688
+ return n.stripJSON(i);
1689
+ };
1690
+ prepend = (t) => (gt(t), new e({
1691
+ version: h,
1692
+ instructions: [...t.instructions, ...this.definition.instructions]
1693
+ }, {
1694
+ program: this._options,
1695
+ runtime: this._runtimeOptions
1696
+ }));
1697
+ append = (t) => (gt(t), new e({
1698
+ version: h,
1699
+ instructions: [...this.definition.instructions, ...t.instructions]
1700
+ }, {
1701
+ program: this._options,
1702
+ runtime: this._runtimeOptions
1703
+ }));
1704
+ }, vt = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", yt = "0123456789", bt = `${vt}_$`, xt = `${bt}${yt}`, St = xt, Ct = " \xA0\r\n ", wt = `${yt}abcdefABCDEF`;
1705
+ function z(e, t, n) {
1706
+ let r = t, i = !1;
1707
+ for (;;) {
1708
+ let t = B(e, r, n, { phrase: "#" });
1709
+ if (t.is) {
1710
+ for ({i: r} = t;;) {
1711
+ let t = H(e, r, n, { set: "\r\n" });
1712
+ if (t.is) {
1713
+ ({i: r} = t);
1714
+ break;
1715
+ }
1716
+ let i = W(e, r, n);
1717
+ if (i.is) {
1718
+ ({i: r} = i);
1719
+ break;
1720
+ }
1721
+ r += 1;
1722
+ }
1723
+ i = !0;
1724
+ continue;
1725
+ }
1726
+ if (t = B(e, r, n, { phrase: "/*" }), t.is) {
1727
+ for ({i: r} = t;;) {
1728
+ if (t = B(e, r, n, { phrase: "*/" }), t.is) {
1729
+ ({i: r} = t);
1730
+ break;
1731
+ }
1732
+ let i = W(e, r, n);
1733
+ if (i.is) return {i: r} = i, G(e, r, n, {
1734
+ operator: "comment",
1735
+ message: "incomplete comment"
1736
+ });
1737
+ r += 1;
1738
+ }
1739
+ i = !0;
1740
+ continue;
1741
+ }
1742
+ let a = H(e, r, n, { set: Ct });
1743
+ if ({i: r} = a, !a.is) break;
1744
+ i = !0;
1745
+ }
1746
+ return {
1747
+ i: r,
1748
+ is: i
1749
+ };
1750
+ }
1751
+ function B(e, t, n, { phrase: r, notBeforeSet: i, spaceBefore: a, spaceAfter: o }) {
1752
+ let s = t;
1753
+ if (a && t > 0 && !H(e, s - 1, n, {
1754
+ set: St,
1755
+ exclusive: !0
1756
+ }).is) return {
1757
+ i: s,
1758
+ is: !1
1759
+ };
1760
+ for (let t = 0; t < r.length; t += 1, s += 1) {
1761
+ let i = W(e, s, n);
1762
+ if (i.is || e[s] !== r[t]) return {
1763
+ i: i.i,
1764
+ is: !1
1765
+ };
1766
+ }
1767
+ return !W(e, s, n).is && (i && H(e, s, n, { set: i }).is || o && !H(e, s, n, {
1768
+ set: St,
1769
+ exclusive: !0
1770
+ }).is) ? {
1771
+ i: s,
1772
+ is: !1
1773
+ } : {
1774
+ i: s,
1775
+ is: !0
1776
+ };
1777
+ }
1778
+ function V(e, t, n, { phrase: r, notBeforeSet: i, spaceBefore: a, spaceAfter: o }) {
1779
+ let s = t, c = B(e, s, n, {
1780
+ phrase: r,
1781
+ notBeforeSet: i,
1782
+ spaceBefore: a,
1783
+ spaceAfter: o
1784
+ });
1785
+ return c.is ? ({i: s} = c, {i: s} = z(e, s, n), {
1786
+ i: s,
1787
+ is: !0
1788
+ }) : {
1789
+ i: c.i,
1790
+ is: !1
1791
+ };
1792
+ }
1793
+ function Tt(e, t, n) {
1794
+ return H(e, t, n, { set: wt });
1795
+ }
1796
+ function H(e, t, n, { set: r, exclusive: i }) {
1797
+ let a = W(e, t, n);
1798
+ if (a.is) return {
1799
+ i: a.i,
1800
+ is: !1
1801
+ };
1802
+ let o = e[t];
1803
+ return r.includes(o) === !i ? {
1804
+ i: t + 1,
1805
+ is: !0,
1806
+ value: o
1807
+ } : {
1808
+ i: t,
1809
+ is: !1,
1810
+ value: ""
1811
+ };
1812
+ }
1813
+ function Et(e, t, n) {
1814
+ let r = t, i = !1, a = "";
1815
+ for (;;) {
1816
+ let t = H(e, r, n, { set: i ? xt : bt });
1817
+ if ({i: r} = t, !t.is) break;
1818
+ i = !0, a += t.value;
1819
+ }
1820
+ return i && ({i: r} = z(e, r, n)), {
1821
+ i: r,
1822
+ is: i,
1823
+ value: a
1824
+ };
1825
+ }
1826
+ function U(e, t, n) {
1827
+ let r = Et(e, t, n);
1828
+ if (!r.is) return r;
1829
+ switch (r.value) {
1830
+ case "and":
1831
+ case "catch":
1832
+ case "func":
1833
+ case "elif":
1834
+ case "else":
1835
+ case "end":
1836
+ case "false":
1837
+ case "if":
1838
+ case "not":
1839
+ case "null":
1840
+ case "or":
1841
+ case "then":
1842
+ case "true":
1843
+ case "try": return {
1844
+ i: t,
1845
+ is: !1,
1846
+ value: r.value,
1847
+ reserved: !0
1848
+ };
1849
+ default: return r;
1850
+ }
1851
+ }
1852
+ function W(e, t) {
1853
+ return t >= e.length ? {
1854
+ i: e.length,
1855
+ is: !0
1856
+ } : {
1857
+ i: t,
1858
+ is: !1
1859
+ };
1860
+ }
1861
+ function Dt(e, t) {
1862
+ let n = e.substring(0, t).split(/\r?\n|\r/), r = n[n.length - 1];
1863
+ return {
1864
+ i: t,
1865
+ line: n.length - 1,
1866
+ column: r.length
1867
+ };
1868
+ }
1869
+ function Ot(e, t, n, { area: r = 25 } = {}) {
1870
+ let i = Math.max(Math.min(t, e.length - 1 - r), r) - r, a = Math.min(i + r + 1 + r, e.length), o = e.substring(i, a).replaceAll(/\r?\n|\r/g, "⏎").replaceAll(" ", "→"), s = " > ";
1871
+ i > 0 && (s += "…");
1872
+ let c = "";
1873
+ return a < e.length && (c = "…"), {
1874
+ i: t,
1875
+ value: `${s}${o}${c}\n${" ".repeat(s.length + (t - i))}^ here`
1876
+ };
1877
+ }
1878
+ function G(e, t, n, { operator: r, message: i } = {}) {
1879
+ let a;
1880
+ if (W(e, t, n).is) a = "unexpected EOT";
1881
+ else {
1882
+ let { line: r, column: i } = Dt(e, t, n);
1883
+ a = `unexpected token '${e[t]}' at line ${r + 1}, column ${i + 1}`;
1884
+ }
1885
+ throw r && (a += ` while parsing ${r}`), i && (a += `: ${i}`), a += `\n${Ot(e, t, n).value}`, new pe(a, e, t);
1886
+ }
1887
+ function kt(e, t, n, { operator: r, message: i } = {}) {
1888
+ let a = "error";
1889
+ throw r && (a += ` while parsing ${r}`), i && (a += `: ${i}`), a += `\n${Ot(e, t, n).value}`, new pe(a, e, t);
1890
+ }
1891
+ //#endregion
1892
+ //#region node_modules/@jplorg/jpl/src/interpreter/parse.js
1893
+ async function At(e, t, n) {
1894
+ let r = t, i = await jt(e, r, n);
1895
+ return {i: r} = i, W(e, r, n).is ? i : G(e, r, n, {
1896
+ operator: "program",
1897
+ message: "expected EOT"
1898
+ });
1899
+ }
1900
+ function jt(e, t, n) {
1901
+ let r = t;
1902
+ return {i: r} = z(e, r, n), K(e, r, n);
1903
+ }
1904
+ function Mt(e, t, n) {
1905
+ let r = t, i = V(e, r, n, { phrase: "(" });
1906
+ if ({i: r} = i, !i.is) return G(e, r, n, {
1907
+ operator: "function definition",
1908
+ message: "expected '('"
1909
+ });
1910
+ let a = [];
1911
+ if (i = V(e, r, n, { phrase: ")" }), i.is) ({i: r} = i);
1912
+ else for (;;) {
1913
+ let t = U(e, r, n);
1914
+ if (!t.is) return G(e, r, n, {
1915
+ operator: "function definition",
1916
+ message: "expected argument name"
1917
+ });
1918
+ let o;
1919
+ if ({i: r, value: o} = t, a.push(o), i = V(e, r, n, { phrase: ")" }), i.is) {
1920
+ ({i: r} = i);
1921
+ break;
1922
+ }
1923
+ if (i = V(e, r, n, { phrase: "," }), {i: r} = i, !i.is) return G(e, r, n, {
1924
+ operator: "function definition",
1925
+ message: "expected ',' or ')'"
1926
+ });
1927
+ }
1928
+ return i = V(e, r, n, { phrase: ":" }), {i: r} = i, i.is ? {
1929
+ i: r,
1930
+ argNames: a
1931
+ } : G(e, r, n, {
1932
+ operator: "function definition",
1933
+ message: "expected ':'"
1934
+ });
1935
+ }
1936
+ async function Nt(e, t, n, { identity: r } = {}) {
1937
+ let i = t, a = [], o = !0;
1938
+ for (;;) {
1939
+ let t = V(e, i, n, { phrase: "." });
1940
+ if (!(r && a.length === 0) && t.is) {
1941
+ ({i: i} = t);
1942
+ let r = U(e, i, n);
1943
+ if (!r.is) return G(e, i, n, {
1944
+ operator: "field access operator",
1945
+ message: "expected field name"
1946
+ });
1947
+ let o;
1948
+ ({i: i, value: o} = r);
1949
+ let s;
1950
+ t = V(e, i, n, {
1951
+ phrase: "?",
1952
+ notBeforeSet: "?="
1953
+ }), t.is && ({i: i, is: s} = t), a.push({
1954
+ op: "$.$",
1955
+ params: {
1956
+ pipe: [{
1957
+ op: "\"\"",
1958
+ params: { string: o }
1959
+ }],
1960
+ optional: s
1961
+ }
1962
+ });
1963
+ continue;
1964
+ }
1965
+ if (t = V(e, i, n, { phrase: "[" }), t.is) {
1966
+ if ({i: i} = t, t = V(e, i, n, { phrase: "]" }), t.is) {
1967
+ ({i: i} = t);
1968
+ let r;
1969
+ t = V(e, i, n, {
1970
+ phrase: "?",
1971
+ notBeforeSet: "?="
1972
+ }), t.is && ({i: i, is: r} = t), a.push({
1973
+ op: "$[]",
1974
+ params: { optional: r }
1975
+ });
1976
+ continue;
1977
+ }
1978
+ if (t = V(e, i, n, { phrase: ":" }), t.is) {
1979
+ if ({i: i} = t, t = V(e, i, n, { phrase: "]" }), t.is) {
1980
+ ({i: i} = t);
1981
+ let r;
1982
+ t = V(e, i, n, {
1983
+ phrase: "?",
1984
+ notBeforeSet: "?="
1985
+ }), t.is && ({i: i, is: r} = t), a.push({
1986
+ op: "[:]",
1987
+ params: {
1988
+ from: [{ op: "nul" }],
1989
+ to: [{ op: "nul" }],
1990
+ optional: r
1991
+ }
1992
+ });
1993
+ continue;
1994
+ }
1995
+ let r;
1996
+ if ({i: i, ops: r} = await K(e, i, n), t = V(e, i, n, { phrase: "]" }), {i: i} = t, !t.is) return G(e, i, n, {
1997
+ operator: "array slice operator",
1998
+ message: "expected ']'"
1999
+ });
2000
+ let o;
2001
+ t = V(e, i, n, {
2002
+ phrase: "?",
2003
+ notBeforeSet: "?="
2004
+ }), t.is && ({i: i, is: o} = t), a.push({
2005
+ op: "[:]",
2006
+ params: {
2007
+ from: [{ op: "nul" }],
2008
+ to: r,
2009
+ optional: o
2010
+ }
2011
+ });
2012
+ continue;
2013
+ }
2014
+ let r;
2015
+ if ({i: i, ops: r} = await K(e, i, n), t = V(e, i, n, { phrase: "]" }), t.is) {
2016
+ ({i: i} = t);
2017
+ let o;
2018
+ t = V(e, i, n, {
2019
+ phrase: "?",
2020
+ notBeforeSet: "?="
2021
+ }), t.is && ({i: i, is: o} = t), a.push({
2022
+ op: "$.$",
2023
+ params: {
2024
+ pipe: r,
2025
+ optional: o
2026
+ }
2027
+ });
2028
+ continue;
2029
+ }
2030
+ if (t = V(e, i, n, { phrase: ":" }), !t.is) return G(e, i, n, {
2031
+ operator: "variable access operator",
2032
+ message: "expected ':' or ']'"
2033
+ });
2034
+ if ({i: i} = t, t = V(e, i, n, { phrase: "]" }), t.is) {
2035
+ ({i: i} = t);
2036
+ let o;
2037
+ t = V(e, i, n, {
2038
+ phrase: "?",
2039
+ notBeforeSet: "?="
2040
+ }), t.is && ({i: i, is: o} = t), a.push({
2041
+ op: "[:]",
2042
+ params: {
2043
+ from: r,
2044
+ to: [{ op: "nul" }],
2045
+ optional: o
2046
+ }
2047
+ });
2048
+ continue;
2049
+ }
2050
+ let o;
2051
+ if ({i: i, ops: o} = await K(e, i, n), t = V(e, i, n, { phrase: "]" }), {i: i} = t, !t.is) return G(e, i, n, {
2052
+ operator: "array slice operator",
2053
+ message: "expected ']'"
2054
+ });
2055
+ let s;
2056
+ t = V(e, i, n, {
2057
+ phrase: "?",
2058
+ notBeforeSet: "?="
2059
+ }), t.is && ({i: i, is: s} = t), a.push({
2060
+ op: "[:]",
2061
+ params: {
2062
+ from: r,
2063
+ to: o,
2064
+ optional: s
2065
+ }
2066
+ });
2067
+ continue;
2068
+ }
2069
+ let s;
2070
+ if (t = V(e, i, n, { phrase: "->" }), t.is && ({i: i, is: s} = t), t = V(e, i, n, { phrase: "(" }), !t.is && s) return G(e, i, n, {
2071
+ operator: "bound function call",
2072
+ message: "expected '('"
2073
+ });
2074
+ if (t.is) {
2075
+ ({i: i} = t);
2076
+ let r = [];
2077
+ if (t = V(e, i, n, { phrase: ")" }), t.is) ({i: i} = t);
2078
+ else for (;;) {
2079
+ let a;
2080
+ if ({i: i, ops: a} = await q(e, i, n), r.push(a), t = V(e, i, n, { phrase: ")" }), t.is) {
2081
+ ({i: i} = t);
2082
+ break;
2083
+ }
2084
+ if (t = V(e, i, n, { phrase: "," }), {i: i} = t, !t.is) return G(e, i, n, {
2085
+ operator: "function call",
2086
+ message: "expected ',' or ')'"
2087
+ });
2088
+ }
2089
+ let c;
2090
+ t = V(e, i, n, {
2091
+ phrase: "?",
2092
+ notBeforeSet: "?="
2093
+ }), t.is && ({i: i, is: c} = t), a.push({
2094
+ op: "$()",
2095
+ params: {
2096
+ args: r,
2097
+ bound: s,
2098
+ optional: c
2099
+ }
2100
+ }), o = !1;
2101
+ continue;
2102
+ }
2103
+ break;
2104
+ }
2105
+ return {
2106
+ i,
2107
+ is: a.length > 0,
2108
+ selectors: a,
2109
+ canAssign: o
2110
+ };
2111
+ }
2112
+ async function Pt(e, t, n) {
2113
+ let r = t, i = V(e, r, n, {
2114
+ phrase: "=",
2115
+ notBeforeSet: "="
2116
+ });
2117
+ if (i.is) {
2118
+ ({i: r} = i);
2119
+ let t;
2120
+ return {i: r, ops: t} = await J(e, r, n), {
2121
+ i: r,
2122
+ is: !0,
2123
+ assignment: {
2124
+ op: "=",
2125
+ params: { pipe: t }
2126
+ }
2127
+ };
2128
+ }
2129
+ if (i = V(e, r, n, { phrase: "|=" }), i.is) {
2130
+ ({i: r} = i);
2131
+ let t;
2132
+ return {i: r, ops: t} = await J(e, r, n), {
2133
+ i: r,
2134
+ is: !0,
2135
+ assignment: {
2136
+ op: "|=",
2137
+ params: { pipe: t }
2138
+ }
2139
+ };
2140
+ }
2141
+ if (i = V(e, r, n, { phrase: "+=" }), i.is) {
2142
+ ({i: r} = i);
2143
+ let t;
2144
+ return {i: r, ops: t} = await J(e, r, n), {
2145
+ i: r,
2146
+ is: !0,
2147
+ assignment: {
2148
+ op: "+=",
2149
+ params: { pipe: t }
2150
+ }
2151
+ };
2152
+ }
2153
+ if (i = V(e, r, n, { phrase: "-=" }), i.is) {
2154
+ ({i: r} = i);
2155
+ let t;
2156
+ return {i: r, ops: t} = await J(e, r, n), {
2157
+ i: r,
2158
+ is: !0,
2159
+ assignment: {
2160
+ op: "-=",
2161
+ params: { pipe: t }
2162
+ }
2163
+ };
2164
+ }
2165
+ if (i = V(e, r, n, { phrase: "*=" }), i.is) {
2166
+ ({i: r} = i);
2167
+ let t;
2168
+ return {i: r, ops: t} = await J(e, r, n), {
2169
+ i: r,
2170
+ is: !0,
2171
+ assignment: {
2172
+ op: "*=",
2173
+ params: { pipe: t }
2174
+ }
2175
+ };
2176
+ }
2177
+ if (i = V(e, r, n, { phrase: "/=" }), i.is) {
2178
+ ({i: r} = i);
2179
+ let t;
2180
+ return {i: r, ops: t} = await J(e, r, n), {
2181
+ i: r,
2182
+ is: !0,
2183
+ assignment: {
2184
+ op: "/=",
2185
+ params: { pipe: t }
2186
+ }
2187
+ };
2188
+ }
2189
+ if (i = V(e, r, n, { phrase: "%=" }), i.is) {
2190
+ ({i: r} = i);
2191
+ let t;
2192
+ return {i: r, ops: t} = await J(e, r, n), {
2193
+ i: r,
2194
+ is: !0,
2195
+ assignment: {
2196
+ op: "%=",
2197
+ params: { pipe: t }
2198
+ }
2199
+ };
2200
+ }
2201
+ if (i = V(e, r, n, { phrase: "?=" }), i.is) {
2202
+ ({i: r} = i);
2203
+ let t;
2204
+ return {i: r, ops: t} = await J(e, r, n), {
2205
+ i: r,
2206
+ is: !0,
2207
+ assignment: {
2208
+ op: "?=",
2209
+ params: { pipe: t }
2210
+ }
2211
+ };
2212
+ }
2213
+ return {
2214
+ i: r,
2215
+ is: !1
2216
+ };
2217
+ }
2218
+ function Ft(e, t, n) {
2219
+ let r = t, i = !1, a = "";
2220
+ for (;;) {
2221
+ let t = H(e, r, n, { set: "0123456789" });
2222
+ if (!t.is) break;
2223
+ ({i: r} = t), i = !0, a += t.value;
2224
+ }
2225
+ if (!i) return {
2226
+ i: r,
2227
+ is: !1
2228
+ };
2229
+ let o = B(e, r, n, { phrase: "." });
2230
+ if (o.is) for ({i: r} = o, a += ".";;) {
2231
+ let t = H(e, r, n, { set: "0123456789" });
2232
+ if (!t.is) break;
2233
+ ({i: r} = t), a += t.value;
2234
+ }
2235
+ let s = H(e, r, n, { set: "eE" });
2236
+ if (s.is) {
2237
+ ({i: r} = s), a += s.value, s = H(e, r, n, { set: "+-" }), s.is && ({i: r} = s, a += s.value);
2238
+ let t;
2239
+ for (; s = H(e, r, n, { set: "0123456789" }), s.is;) ({i: r} = s), t = !0, a += s.value;
2240
+ if (!t) return G(e, r, n, {
2241
+ operator: "number",
2242
+ message: "expected digit"
2243
+ });
2244
+ }
2245
+ let c = +a;
2246
+ return Number.isFinite(c) ? ({i: r} = z(e, r, n), {
2247
+ i: r,
2248
+ is: !0,
2249
+ ops: [{
2250
+ op: "nbr",
2251
+ params: { number: c }
2252
+ }]
2253
+ }) : kt(e, r, n, {
2254
+ operator: "number",
2255
+ message: `invalid number ${c}`
2256
+ });
2257
+ }
2258
+ async function It(e, t, n) {
2259
+ let r = t, i = "", a = H(e, r, n, { set: "\"'`" });
2260
+ if (!a.is) return {
2261
+ i: r,
2262
+ is: !1
2263
+ };
2264
+ let o;
2265
+ ({i: r, value: o} = a);
2266
+ let s = o === "`", c = [];
2267
+ for (;;) {
2268
+ let t = B(e, r, n, { phrase: o });
2269
+ if (t.is) {
2270
+ ({i: r} = t);
2271
+ break;
2272
+ }
2273
+ let a = W(e, r, n);
2274
+ if (a.is) return {i: r} = a, G(e, r, n, {
2275
+ operator: "string",
2276
+ message: "incomplete string literal"
2277
+ });
2278
+ if (t = B(e, r, n, { phrase: "\\" }), t.is) {
2279
+ if ({i: r} = t, t = V(e, r, n, { phrase: "(" }), t.is) {
2280
+ ({i: r} = t);
2281
+ let a;
2282
+ if ({i: r, ops: a} = await K(e, r, n), t = B(e, r, n, { phrase: ")" }), {i: r} = t, !t.is) return G(e, r, n, {
2283
+ operator: "string interpolation",
2284
+ message: "expected ')'"
2285
+ });
2286
+ c.push({
2287
+ before: i,
2288
+ pipe: a
2289
+ }), i = "";
2290
+ continue;
2291
+ }
2292
+ if (s) switch (e[r]) {
2293
+ case "\n":
2294
+ r += 1;
2295
+ continue;
2296
+ case "\r":
2297
+ r += 1, !W(e, r, n).is && e[r] === "\n" && (r += 1);
2298
+ continue;
2299
+ default:
2300
+ }
2301
+ switch (e[r]) {
2302
+ case "\"":
2303
+ i += "\"", r += 1;
2304
+ continue;
2305
+ case "'":
2306
+ i += "'", r += 1;
2307
+ continue;
2308
+ case "`":
2309
+ i += "`", r += 1;
2310
+ continue;
2311
+ case "\\":
2312
+ i += "\\", r += 1;
2313
+ continue;
2314
+ case "/":
2315
+ i += "/", r += 1;
2316
+ continue;
2317
+ case "b":
2318
+ i += "\b", r += 1;
2319
+ continue;
2320
+ case "f":
2321
+ i += "\f", r += 1;
2322
+ continue;
2323
+ case "n":
2324
+ i += "\n", r += 1;
2325
+ continue;
2326
+ case "r":
2327
+ i += "\r", r += 1;
2328
+ continue;
2329
+ case "t":
2330
+ i += " ", r += 1;
2331
+ continue;
2332
+ case "u": {
2333
+ r += 1;
2334
+ let a = "";
2335
+ for (let i = 0; i < 4; i += 1) {
2336
+ if (t = Tt(e, r, n), {i: r} = t, !t.is) return G(e, r, n, {
2337
+ operator: "string",
2338
+ message: "incomplete unicode escape sequence: expected hex digit"
2339
+ });
2340
+ a += t.value;
2341
+ }
2342
+ i += String.fromCodePoint(parseInt(a, 16));
2343
+ continue;
2344
+ }
2345
+ default: return G(e, r, n, {
2346
+ operator: "string",
2347
+ message: "invalid escape sequence"
2348
+ });
2349
+ }
2350
+ }
2351
+ if (s) switch (e[r]) {
2352
+ case "\n":
2353
+ case "\r":
2354
+ case " ":
2355
+ i += e[r], r += 1;
2356
+ continue;
2357
+ default:
2358
+ }
2359
+ if (e.charCodeAt(r) < 32) return G(e, r, n, { operator: "string" });
2360
+ i += e[r], r += 1;
2361
+ }
2362
+ return {i: r} = z(e, r, n), c.length === 0 ? {
2363
+ i: r,
2364
+ is: !0,
2365
+ ops: [{
2366
+ op: "\"\"",
2367
+ params: { string: i }
2368
+ }]
2369
+ } : {
2370
+ i: r,
2371
+ is: !0,
2372
+ ops: [{
2373
+ op: "\"$\"",
2374
+ params: {
2375
+ interpolations: c,
2376
+ after: i
2377
+ }
2378
+ }]
2379
+ };
2380
+ }
2381
+ async function K(e, t, n) {
2382
+ await void 0;
2383
+ let r = t, i = [];
2384
+ for (;;) {
2385
+ let t;
2386
+ ({i: r, ops: t} = await Lt(e, r, n)), i.push(...t);
2387
+ let a = V(e, r, n, {
2388
+ phrase: "|",
2389
+ notBeforeSet: "="
2390
+ });
2391
+ if (!a.is) break;
2392
+ ({i: r} = a);
2393
+ }
2394
+ return {
2395
+ i: r,
2396
+ ops: i
2397
+ };
2398
+ }
2399
+ async function q(e, t, n) {
2400
+ await void 0;
2401
+ let r = t, i = [];
2402
+ for (;;) {
2403
+ let t;
2404
+ ({i: r, ops: t} = await Rt(e, r, n)), i.push(...t);
2405
+ let a = V(e, r, n, {
2406
+ phrase: "|",
2407
+ notBeforeSet: "="
2408
+ });
2409
+ if (!a.is) break;
2410
+ ({i: r} = a);
2411
+ }
2412
+ return {
2413
+ i: r,
2414
+ ops: i
2415
+ };
2416
+ }
2417
+ async function J(e, t, n) {
2418
+ return await void 0, Rt(e, t, n);
2419
+ }
2420
+ async function Lt(e, t, n) {
2421
+ let r = t, i = [];
2422
+ for (;;) {
2423
+ let t;
2424
+ ({i: r, ops: t} = await Rt(e, r, n)), i.push(t);
2425
+ let a = V(e, r, n, { phrase: "," });
2426
+ if (!a.is) break;
2427
+ ({i: r} = a);
2428
+ }
2429
+ return i.length === 1 ? {
2430
+ i: r,
2431
+ ops: i[0]
2432
+ } : {
2433
+ i: r,
2434
+ ops: [{
2435
+ op: ",",
2436
+ params: { pipes: i }
2437
+ }]
2438
+ };
2439
+ }
2440
+ async function Rt(e, t, n) {
2441
+ let r = t, i = V(e, r, n, {
2442
+ phrase: "try",
2443
+ spaceAfter: !0
2444
+ });
2445
+ if (!i.is) return zt(e, r, n);
2446
+ ({i: r} = i);
2447
+ let a;
2448
+ ({i: r, ops: a} = await zt(e, r, n));
2449
+ let o;
2450
+ return i = V(e, r, n, {
2451
+ spaceBefore: !0,
2452
+ phrase: "catch",
2453
+ spaceAfter: !0
2454
+ }), i.is ? ({i: r} = i, {i: r, ops: o} = await zt(e, r, n)) : o = [{ op: "vod" }], {
2455
+ i: r,
2456
+ ops: [{
2457
+ op: "try",
2458
+ params: {
2459
+ try: a,
2460
+ catch: o
2461
+ }
2462
+ }]
2463
+ };
2464
+ }
2465
+ async function zt(e, t, n) {
2466
+ let r = t, i = [];
2467
+ for (;;) {
2468
+ let t;
2469
+ ({i: r, ops: t} = await Bt(e, r, n)), i.push(t);
2470
+ let a = V(e, r, n, {
2471
+ spaceBefore: !0,
2472
+ phrase: "or",
2473
+ spaceAfter: !0
2474
+ });
2475
+ if (!a.is) break;
2476
+ ({i: r} = a);
2477
+ }
2478
+ return i.length === 1 ? {
2479
+ i: r,
2480
+ ops: i[0]
2481
+ } : {
2482
+ i: r,
2483
+ ops: [{
2484
+ op: "or",
2485
+ params: { pipes: i }
2486
+ }]
2487
+ };
2488
+ }
2489
+ async function Bt(e, t, n) {
2490
+ let r = t, i = [];
2491
+ for (;;) {
2492
+ let t;
2493
+ ({i: r, ops: t} = await Vt(e, r, n)), i.push(t);
2494
+ let a = V(e, r, n, {
2495
+ spaceBefore: !0,
2496
+ phrase: "and",
2497
+ spaceAfter: !0
2498
+ });
2499
+ if (!a.is) break;
2500
+ ({i: r} = a);
2501
+ }
2502
+ return i.length === 1 ? {
2503
+ i: r,
2504
+ ops: i[0]
2505
+ } : {
2506
+ i: r,
2507
+ ops: [{
2508
+ op: "and",
2509
+ params: { pipes: i }
2510
+ }]
2511
+ };
2512
+ }
2513
+ async function Vt(e, t, n) {
2514
+ let r = t, i;
2515
+ ({i: r, ops: i} = await Ht(e, r, n));
2516
+ let a = [];
2517
+ for (;;) {
2518
+ let t = V(e, r, n, { phrase: "==" });
2519
+ if (t.is) {
2520
+ ({i: r} = t);
2521
+ let i;
2522
+ ({i: r, ops: i} = await Ht(e, r, n)), a.push({
2523
+ op: "==",
2524
+ params: { by: i }
2525
+ });
2526
+ continue;
2527
+ }
2528
+ if (t = V(e, r, n, { phrase: "!=" }), t.is) {
2529
+ ({i: r} = t);
2530
+ let i;
2531
+ ({i: r, ops: i} = await Ht(e, r, n)), a.push({
2532
+ op: "!=",
2533
+ params: { by: i }
2534
+ });
2535
+ continue;
2536
+ }
2537
+ break;
2538
+ }
2539
+ return a.length === 0 ? {
2540
+ i: r,
2541
+ ops: i
2542
+ } : {
2543
+ i: r,
2544
+ ops: [{
2545
+ op: "cmp",
2546
+ params: {
2547
+ pipe: i,
2548
+ comparisons: a
2549
+ }
2550
+ }]
2551
+ };
2552
+ }
2553
+ async function Ht(e, t, n) {
2554
+ let r = t, i;
2555
+ ({i: r, ops: i} = await Y(e, r, n));
2556
+ let a = [];
2557
+ for (;;) {
2558
+ let t = V(e, r, n, { phrase: "<=" });
2559
+ if (t.is) {
2560
+ ({i: r} = t);
2561
+ let i;
2562
+ ({i: r, ops: i} = await Y(e, r, n)), a.push({
2563
+ op: "<=",
2564
+ params: { by: i }
2565
+ });
2566
+ continue;
2567
+ }
2568
+ if (t = V(e, r, n, { phrase: "<" }), t.is) {
2569
+ ({i: r} = t);
2570
+ let i;
2571
+ ({i: r, ops: i} = await Y(e, r, n)), a.push({
2572
+ op: "<",
2573
+ params: { by: i }
2574
+ });
2575
+ continue;
2576
+ }
2577
+ if (t = V(e, r, n, { phrase: ">=" }), t.is) {
2578
+ ({i: r} = t);
2579
+ let i;
2580
+ ({i: r, ops: i} = await Y(e, r, n)), a.push({
2581
+ op: ">=",
2582
+ params: { by: i }
2583
+ });
2584
+ continue;
2585
+ }
2586
+ if (t = V(e, r, n, { phrase: ">" }), t.is) {
2587
+ ({i: r} = t);
2588
+ let i;
2589
+ ({i: r, ops: i} = await Y(e, r, n)), a.push({
2590
+ op: ">",
2591
+ params: { by: i }
2592
+ });
2593
+ continue;
2594
+ }
2595
+ break;
2596
+ }
2597
+ return a.length === 0 ? {
2598
+ i: r,
2599
+ ops: i
2600
+ } : {
2601
+ i: r,
2602
+ ops: [{
2603
+ op: "cmp",
2604
+ params: {
2605
+ pipe: i,
2606
+ comparisons: a
2607
+ }
2608
+ }]
2609
+ };
2610
+ }
2611
+ async function Y(e, t, n) {
2612
+ let r = t, i = V(e, r, n, {
2613
+ phrase: "not",
2614
+ spaceAfter: !0
2615
+ });
2616
+ if (!i.is) return Ut(e, r, n);
2617
+ ({i: r} = i);
2618
+ let a;
2619
+ return {i: r, ops: a} = await Ut(e, r, n), {
2620
+ i: r,
2621
+ ops: [...a, { op: "not" }]
2622
+ };
2623
+ }
2624
+ async function Ut(e, t, n) {
2625
+ let r = t, i = await Wt(e, r, n);
2626
+ ({i: r} = i);
2627
+ let a = V(e, r, n, {
2628
+ phrase: "?",
2629
+ notBeforeSet: "?="
2630
+ });
2631
+ return a.is ? ({i: r} = a, {
2632
+ i: r,
2633
+ ops: [{
2634
+ op: "try",
2635
+ params: {
2636
+ try: i.ops,
2637
+ catch: [{ op: "vod" }]
2638
+ }
2639
+ }]
2640
+ }) : i;
2641
+ }
2642
+ async function Wt(e, t, n) {
2643
+ let r = t, i;
2644
+ ({i: r, ops: i} = await X(e, r, n));
2645
+ let a = [];
2646
+ for (;;) {
2647
+ let t = V(e, r, n, {
2648
+ phrase: "+",
2649
+ notBeforeSet: "="
2650
+ });
2651
+ if (t.is) {
2652
+ ({i: r} = t);
2653
+ let i;
2654
+ ({i: r, ops: i} = await X(e, r, n)), a.push({
2655
+ op: "+",
2656
+ params: { by: i }
2657
+ });
2658
+ continue;
2659
+ }
2660
+ if (t = V(e, r, n, {
2661
+ phrase: "-",
2662
+ notBeforeSet: "=>"
2663
+ }), t.is) {
2664
+ ({i: r} = t);
2665
+ let i;
2666
+ ({i: r, ops: i} = await X(e, r, n)), a.push({
2667
+ op: "-",
2668
+ params: { by: i }
2669
+ });
2670
+ continue;
2671
+ }
2672
+ break;
2673
+ }
2674
+ return a.length === 0 ? {
2675
+ i: r,
2676
+ ops: i
2677
+ } : {
2678
+ i: r,
2679
+ ops: [{
2680
+ op: "clc",
2681
+ params: {
2682
+ pipe: i,
2683
+ operations: a
2684
+ }
2685
+ }]
2686
+ };
2687
+ }
2688
+ async function X(e, t, n) {
2689
+ let r = t, i;
2690
+ ({i: r, ops: i} = await Z(e, r, n));
2691
+ let a = [];
2692
+ for (;;) {
2693
+ let t = V(e, r, n, {
2694
+ phrase: "*",
2695
+ notBeforeSet: "="
2696
+ });
2697
+ if (t.is) {
2698
+ ({i: r} = t);
2699
+ let i;
2700
+ ({i: r, ops: i} = await Z(e, r, n)), a.push({
2701
+ op: "*",
2702
+ params: { by: i }
2703
+ });
2704
+ continue;
2705
+ }
2706
+ if (t = V(e, r, n, {
2707
+ phrase: "/",
2708
+ notBeforeSet: "="
2709
+ }), t.is) {
2710
+ ({i: r} = t);
2711
+ let i;
2712
+ ({i: r, ops: i} = await Z(e, r, n)), a.push({
2713
+ op: "/",
2714
+ params: { by: i }
2715
+ });
2716
+ continue;
2717
+ }
2718
+ if (t = V(e, r, n, {
2719
+ phrase: "%",
2720
+ notBeforeSet: "="
2721
+ }), t.is) {
2722
+ ({i: r} = t);
2723
+ let i;
2724
+ ({i: r, ops: i} = await Z(e, r, n)), a.push({
2725
+ op: "%",
2726
+ params: { by: i }
2727
+ });
2728
+ continue;
2729
+ }
2730
+ break;
2731
+ }
2732
+ return a.length === 0 ? {
2733
+ i: r,
2734
+ ops: i
2735
+ } : {
2736
+ i: r,
2737
+ ops: [{
2738
+ op: "clc",
2739
+ params: {
2740
+ pipe: i,
2741
+ operations: a
2742
+ }
2743
+ }]
2744
+ };
2745
+ }
2746
+ async function Z(e, t, n) {
2747
+ let r = t, i = [];
2748
+ for (;;) {
2749
+ let t;
2750
+ ({i: r, ops: t} = await Gt(e, r, n)), i.push(t);
2751
+ let a = V(e, r, n, { phrase: "??" });
2752
+ if (!a.is) break;
2753
+ ({i: r} = a);
2754
+ }
2755
+ return i.length === 1 ? {
2756
+ i: r,
2757
+ ops: i[0]
2758
+ } : {
2759
+ i: r,
2760
+ ops: [{
2761
+ op: "??",
2762
+ params: { pipes: i }
2763
+ }]
2764
+ };
2765
+ }
2766
+ async function Gt(e, t, n) {
2767
+ let r = t, i = V(e, r, n, {
2768
+ phrase: "-",
2769
+ notBeforeSet: "=>"
2770
+ });
2771
+ if (!i.is) return Kt(e, r, n);
2772
+ ({i: r} = i);
2773
+ let a;
2774
+ return {i: r, ops: a} = await Kt(e, r, n), {
2775
+ i: r,
2776
+ ops: [...a, { op: "neg" }]
2777
+ };
2778
+ }
2779
+ async function Kt(e, t, n) {
2780
+ let r = t, i = V(e, r, n, {
2781
+ phrase: "if",
2782
+ spaceAfter: !0
2783
+ });
2784
+ if (!i.is) return qt(e, r, n);
2785
+ ({i: r} = i);
2786
+ let a = [];
2787
+ for (;;) {
2788
+ let t;
2789
+ if ({i: r, ops: t} = await K(e, r, n), i = V(e, r, n, {
2790
+ spaceBefore: !0,
2791
+ phrase: "then",
2792
+ spaceAfter: !0
2793
+ }), {i: r} = i, !i.is) return G(e, r, n, {
2794
+ operator: "if statement",
2795
+ message: "expected 'then'"
2796
+ });
2797
+ let o;
2798
+ if ({i: r, ops: o} = await K(e, r, n), a.push({
2799
+ if: t,
2800
+ then: o
2801
+ }), i = V(e, r, n, {
2802
+ spaceBefore: !0,
2803
+ phrase: "elif",
2804
+ spaceAfter: !0
2805
+ }), !i.is) break;
2806
+ ({i: r} = i);
2807
+ }
2808
+ let o;
2809
+ return i = V(e, r, n, {
2810
+ spaceBefore: !0,
2811
+ phrase: "else",
2812
+ spaceAfter: !0
2813
+ }), i.is ? ({i: r} = i, {i: r, ops: o} = await K(e, r, n)) : o = [], i = V(e, r, n, {
2814
+ spaceBefore: !0,
2815
+ phrase: "end"
2816
+ }), {i: r} = i, i.is ? {
2817
+ i: r,
2818
+ ops: [{
2819
+ op: "if",
2820
+ params: {
2821
+ ifs: a,
2822
+ else: o
2823
+ }
2824
+ }]
2825
+ } : G(e, r, n, {
2826
+ operator: "if statement",
2827
+ message: "expected 'end'"
2828
+ });
2829
+ }
2830
+ function qt(e, t, n) {
2831
+ let r = t, i = V(e, r, n, {
2832
+ phrase: "true",
2833
+ spaceAfter: !0
2834
+ });
2835
+ return i.is ? ({i: r} = i, {
2836
+ i: r,
2837
+ ops: [{ op: "tru" }]
2838
+ }) : (i = V(e, r, n, {
2839
+ phrase: "false",
2840
+ spaceAfter: !0
2841
+ }), i.is ? ({i: r} = i, {
2842
+ i: r,
2843
+ ops: [{ op: "fls" }]
2844
+ }) : (i = V(e, r, n, {
2845
+ phrase: "null",
2846
+ spaceAfter: !0
2847
+ }), i.is ? ({i: r} = i, {
2848
+ i: r,
2849
+ ops: [{ op: "nul" }]
2850
+ }) : Jt(e, r, n)));
2851
+ }
2852
+ async function Jt(e, t, n) {
2853
+ let r = t, i = await Ft(e, r, n);
2854
+ return i.is ? ({i: r} = i, {
2855
+ i: r,
2856
+ ops: i.ops
2857
+ }) : Yt(e, r, n);
2858
+ }
2859
+ async function Yt(e, t, n) {
2860
+ let r = t, i = V(e, r, n, {
2861
+ phrase: "func",
2862
+ spaceAfter: !0
2863
+ });
2864
+ if (!i.is) return Xt(e, r, n);
2865
+ ({i: r} = i);
2866
+ let a = U(e, r, n);
2867
+ if (!a.is) return Xt(e, t, n);
2868
+ let o;
2869
+ ({i: r, value: o} = a);
2870
+ let s;
2871
+ ({i: r, argNames: s} = await Mt(e, r, n));
2872
+ let c;
2873
+ return {i: r, ops: c} = await J(e, r, n), {
2874
+ i: r,
2875
+ ops: [{
2876
+ op: "va=",
2877
+ params: {
2878
+ name: o,
2879
+ pipe: [{
2880
+ op: "fun",
2881
+ params: {
2882
+ argNames: s,
2883
+ pipe: c
2884
+ }
2885
+ }]
2886
+ }
2887
+ }]
2888
+ };
2889
+ }
2890
+ async function Xt(e, t, n) {
2891
+ let r = t, i = V(e, r, n, {
2892
+ phrase: "func",
2893
+ spaceAfter: !0
2894
+ });
2895
+ if (!i.is) return Zt(e, r, n);
2896
+ ({i: r} = i);
2897
+ let a;
2898
+ ({i: r, argNames: a} = await Mt(e, r, n));
2899
+ let o;
2900
+ return {i: r, ops: o} = await J(e, r, n), {
2901
+ i: r,
2902
+ ops: [{
2903
+ op: "fun",
2904
+ params: {
2905
+ argNames: a,
2906
+ pipe: o
2907
+ }
2908
+ }]
2909
+ };
2910
+ }
2911
+ async function Zt(e, t, n) {
2912
+ let r = t, i = U(e, r, n);
2913
+ if (!i.is) return Qt(e, r, n);
2914
+ let a;
2915
+ ({i: r, value: a} = i);
2916
+ let o, s, c = await Nt(e, r, n);
2917
+ if (c.is ? {i: r, selectors: o, canAssign: s} = c : (o = [], s = !0), !s) {
2918
+ let e = [{
2919
+ op: "var",
2920
+ params: { name: a }
2921
+ }];
2922
+ return o.length === 0 ? {
2923
+ i: r,
2924
+ ops: e
2925
+ } : {
2926
+ i: r,
2927
+ ops: [{
2928
+ op: "$.",
2929
+ params: {
2930
+ pipe: e,
2931
+ selectors: o
2932
+ }
2933
+ }]
2934
+ };
2935
+ }
2936
+ let l = await Pt(e, r, n);
2937
+ if (!l.is) {
2938
+ let e = [{
2939
+ op: "var",
2940
+ params: { name: a }
2941
+ }];
2942
+ return o.length === 0 ? {
2943
+ i: r,
2944
+ ops: e
2945
+ } : {
2946
+ i: r,
2947
+ ops: [{
2948
+ op: "$.",
2949
+ params: {
2950
+ pipe: e,
2951
+ selectors: o
2952
+ }
2953
+ }]
2954
+ };
2955
+ }
2956
+ let u;
2957
+ return {i: r, assignment: u} = l, o.length === 0 && u.op === "=" ? {
2958
+ i: r,
2959
+ ops: [{
2960
+ op: "va=",
2961
+ params: {
2962
+ name: a,
2963
+ pipe: u.params.pipe
2964
+ }
2965
+ }]
2966
+ } : {
2967
+ i: r,
2968
+ ops: [{
2969
+ op: "va=",
2970
+ params: {
2971
+ name: a,
2972
+ pipe: [{
2973
+ op: "$=",
2974
+ params: {
2975
+ pipe: [{
2976
+ op: "var",
2977
+ params: { name: a }
2978
+ }],
2979
+ selectors: o,
2980
+ assignment: u
2981
+ }
2982
+ }]
2983
+ }
2984
+ }]
2985
+ };
2986
+ }
2987
+ async function Qt(e, t, n) {
2988
+ let r = t, i = [], a, o = V(e, r, n, { phrase: "." });
2989
+ if (!o.is) ({i: r, ops: a} = await $t(e, r, n));
2990
+ else {
2991
+ ({i: r} = o), a = [];
2992
+ let t = U(e, r, n);
2993
+ if (t.is) {
2994
+ let a;
2995
+ ({i: r, value: a} = t);
2996
+ let s;
2997
+ o = V(e, r, n, {
2998
+ phrase: "?",
2999
+ notBeforeSet: "?="
3000
+ }), o.is && ({i: r, is: s} = o), i.push({
3001
+ op: "$.$",
3002
+ params: {
3003
+ pipe: [{
3004
+ op: "\"\"",
3005
+ params: { string: a }
3006
+ }],
3007
+ optional: s
3008
+ }
3009
+ });
3010
+ }
3011
+ }
3012
+ let s = await Nt(e, r, n, { identity: a.length === 0 && i.length === 0 }), c;
3013
+ if (s.is ? ({i: r, canAssign: c} = s, i.push(...s.selectors)) : c = i.length > 0, i.length === 0) return {
3014
+ i: r,
3015
+ ops: a
3016
+ };
3017
+ if (!c) return {
3018
+ i: r,
3019
+ ops: [{
3020
+ op: "$.",
3021
+ params: {
3022
+ pipe: a,
3023
+ selectors: i
3024
+ }
3025
+ }]
3026
+ };
3027
+ let l = await Pt(e, r, n);
3028
+ if (!l.is) return {
3029
+ i: r,
3030
+ ops: [{
3031
+ op: "$.",
3032
+ params: {
3033
+ pipe: a,
3034
+ selectors: i
3035
+ }
3036
+ }]
3037
+ };
3038
+ let u;
3039
+ return {i: r, assignment: u} = l, {
3040
+ i: r,
3041
+ ops: [{
3042
+ op: "$=",
3043
+ params: {
3044
+ pipe: a,
3045
+ selectors: i,
3046
+ assignment: u
3047
+ }
3048
+ }]
3049
+ };
3050
+ }
3051
+ async function $t(e, t, n) {
3052
+ let r = t, i = V(e, r, n, { phrase: "{" });
3053
+ if (!i.is) return en(e, r, n);
3054
+ ({i: r} = i);
3055
+ let a = [];
3056
+ if (i = V(e, r, n, { phrase: "}" }), i.is) ({i: r} = i);
3057
+ else for (;;) {
3058
+ if (i = V(e, r, n, { phrase: "(" }), i.is) {
3059
+ ({i: r} = i);
3060
+ let t;
3061
+ if ({i: r, ops: t} = await K(e, r, n), i = V(e, r, n, { phrase: ")" }), {i: r} = i, !i.is) return G(e, r, n, {
3062
+ operator: "object",
3063
+ message: "expected ')'"
3064
+ });
3065
+ let o;
3066
+ if ({i: r, is: o} = V(e, r, n, { phrase: "?" }), i = V(e, r, n, { phrase: ":" }), {i: r} = i, !i.is) return G(e, r, n, {
3067
+ operator: "object",
3068
+ message: "expected ':'"
3069
+ });
3070
+ let s;
3071
+ if ({i: r, ops: s} = await q(e, r, n), a.push({
3072
+ key: t,
3073
+ value: s,
3074
+ optional: o
3075
+ }), i = V(e, r, n, { phrase: "}" }), i.is) {
3076
+ ({i: r} = i);
3077
+ break;
3078
+ }
3079
+ if (i = V(e, r, n, { phrase: "," }), {i: r} = i, !i.is) return G(e, r, n, {
3080
+ operator: "object",
3081
+ message: "expected ',' or '}'"
3082
+ });
3083
+ continue;
3084
+ }
3085
+ let t = await It(e, r, n);
3086
+ if (t.is) {
3087
+ let o;
3088
+ if ({i: r, ops: o} = t, i = V(e, r, n, { phrase: ":" }), {i: r} = i, !i.is) return G(e, r, n, {
3089
+ operator: "object",
3090
+ message: "expected ':'"
3091
+ });
3092
+ let s;
3093
+ if ({i: r, ops: s} = await q(e, r, n), a.push({
3094
+ key: o,
3095
+ value: s,
3096
+ optional: !1
3097
+ }), i = V(e, r, n, { phrase: "}" }), i.is) {
3098
+ ({i: r} = i);
3099
+ break;
3100
+ }
3101
+ if (i = V(e, r, n, { phrase: "," }), {i: r} = i, !i.is) return G(e, r, n, {
3102
+ operator: "object",
3103
+ message: "expected ',' or '}'"
3104
+ });
3105
+ continue;
3106
+ }
3107
+ let o = U(e, r, n);
3108
+ if (o.is) {
3109
+ let t;
3110
+ ({i: r, value: t} = o);
3111
+ let s;
3112
+ if (i = V(e, r, n, { phrase: ":" }), i.is) ({i: r} = i), {i: r, ops: s} = await q(e, r, n);
3113
+ else {
3114
+ let i;
3115
+ ({i: r, is: i} = V(e, r, n, { phrase: "?" })), s = i ? [{
3116
+ op: "try",
3117
+ params: {
3118
+ try: [{
3119
+ op: "var",
3120
+ params: { name: t }
3121
+ }],
3122
+ catch: [{ op: "vod" }]
3123
+ }
3124
+ }] : [{
3125
+ op: "var",
3126
+ params: { name: t }
3127
+ }];
3128
+ }
3129
+ if (a.push({
3130
+ key: [{
3131
+ op: "\"\"",
3132
+ params: { string: t }
3133
+ }],
3134
+ value: s,
3135
+ optional: !1
3136
+ }), i = V(e, r, n, { phrase: "}" }), i.is) {
3137
+ ({i: r} = i);
3138
+ break;
3139
+ }
3140
+ if (i = V(e, r, n, { phrase: "," }), {i: r} = i, !i.is) return G(e, r, n, {
3141
+ operator: "object",
3142
+ message: "expected ',' or '}'"
3143
+ });
3144
+ continue;
3145
+ }
3146
+ return G(e, r, n, {
3147
+ operator: "object",
3148
+ message: "expected field declaration"
3149
+ });
3150
+ }
3151
+ return {
3152
+ i: r,
3153
+ ops: [{
3154
+ op: "{}",
3155
+ params: { fields: a }
3156
+ }]
3157
+ };
3158
+ }
3159
+ async function en(e, t, n) {
3160
+ let r = t, i = V(e, r, n, { phrase: "[" });
3161
+ if ({i: r} = i, !i.is) return tn(e, r, n);
3162
+ let a;
3163
+ if (i = V(e, r, n, { phrase: "]" }), i.is) ({i: r} = i), a = [{ op: "vod" }];
3164
+ else if ({i: r, ops: a} = await K(e, r, n), i = V(e, r, n, { phrase: "]" }), {i: r} = i, !i.is) return G(e, r, n, {
3165
+ operator: "array",
3166
+ message: "expected ']'"
3167
+ });
3168
+ return {
3169
+ i: r,
3170
+ ops: [{
3171
+ op: "[]",
3172
+ params: { pipe: a }
3173
+ }]
3174
+ };
3175
+ }
3176
+ async function tn(e, t, n) {
3177
+ let r = t, i = await It(e, r, n);
3178
+ return i.is ? ({i: r} = i, {
3179
+ i: r,
3180
+ ops: i.ops
3181
+ }) : nn(e, r, n);
3182
+ }
3183
+ async function nn(e, t, n) {
3184
+ let r = t, i = V(e, r, n, { phrase: "(" });
3185
+ if ({i: r} = i, !i.is) return G(e, r, n);
3186
+ let a;
3187
+ return {i: r, ops: a} = await K(e, r, n), i = V(e, r, n, { phrase: ")" }), {i: r} = i, i.is ? {
3188
+ i: r,
3189
+ ops: a
3190
+ } : G(e, r, n, {
3191
+ operator: "group",
3192
+ message: "expected ')'"
3193
+ });
3194
+ }
3195
+ //#endregion
3196
+ //#region node_modules/@jplorg/jpl/src/interpreter/index.js
3197
+ var rn = {};
3198
+ function an(e = {}, t = {}) {
3199
+ return d(e, t);
3200
+ }
3201
+ var on = class {
3202
+ constructor(e) {
3203
+ this._options = an(e?.interpreter, rn), this._programOptions = e?.program, this._runtimeOptions = e?.runtime;
3204
+ }
3205
+ get options() {
3206
+ return this._options;
3207
+ }
3208
+ parse = async (e, t) => new _t({
3209
+ version: h,
3210
+ instructions: await this.parseInstructions(e)
3211
+ }, {
3212
+ program: ht(t?.program, this._programOptions),
3213
+ runtime: F(t?.runtime, this._runtimeOptions)
3214
+ });
3215
+ parseInstructions = async (e) => {
3216
+ let { ops: t } = await At(e, 0, { interpreter: this });
3217
+ return t;
3218
+ };
3219
+ }, sn = new on(), cn = /* @__PURE__ */ s({ sortEntries: () => ln }), ln = ye(async (e, t) => [await e.alterValue(t, (t) => [...t].sort((t, n) => e.compareArrays(e.unwrapValue(t)[0], e.unwrapValue(n)[0])))]);
3220
+ //#endregion
3221
+ //#region node_modules/@jplorg/jpl/src/builtins/funcContains.js
3222
+ function un(e, t, n, r, i) {
3223
+ let a = e.unwrapValue(r), o = e.type(a), s = e.unwrapValue(i ?? null), c = e.type(s);
3224
+ switch (o) {
3225
+ case "array": return n(a.some((t) => e.equals(t, s)));
3226
+ case "string":
3227
+ if (c === "string") return n(a.includes(s));
3228
+ break;
3229
+ case "object": return n(Object.values(a).some((t) => e.equals(t, s)));
3230
+ default:
3231
+ }
3232
+ throw new M("%s (%*<100v) cannot contain %s (%*<100v)", o, a, c, s);
3233
+ }
3234
+ //#endregion
3235
+ //#region node_modules/@jplorg/jpl/src/builtins/funcEndsWith.js
3236
+ function dn(e, t, n, r, i) {
3237
+ let a = e.unwrapValue(r), o = e.type(a), s = e.unwrapValue(i ?? null), c = e.type(s);
3238
+ switch (o) {
3239
+ case "string":
3240
+ if (c === "string") return n(a.endsWith(s));
3241
+ break;
3242
+ default:
3243
+ }
3244
+ throw new M("%s (%*<100v) cannot end with %s (%*<100v)", o, a, c, s);
3245
+ }
3246
+ //#endregion
3247
+ //#region node_modules/@jplorg/jpl/src/builtins/funcError.js
3248
+ function fn(e, t, n, r) {
3249
+ throw new j(r);
3250
+ }
3251
+ //#endregion
3252
+ //#region node_modules/@jplorg/jpl/src/builtins/funcFromJSON.js
3253
+ function pn(e, t, n, r) {
3254
+ let i = e.unwrapValue(r), a = e.type(i);
3255
+ switch (a) {
3256
+ case "string": {
3257
+ let e;
3258
+ try {
3259
+ e = JSON.parse(i);
3260
+ } catch (e) {
3261
+ throw new j(e.message);
3262
+ }
3263
+ return n(e);
3264
+ }
3265
+ default:
3266
+ }
3267
+ throw new M("%s (%*<100v) cannot be parsed as JSON", a, i);
3268
+ }
3269
+ //#endregion
3270
+ //#region node_modules/@jplorg/jpl/src/builtins/funcHas.js
3271
+ function mn(e, t, n, r, i) {
3272
+ let a = e.unwrapValue(r), o = e.type(a), s = e.unwrapValue(i ?? null), c = e.type(s);
3273
+ switch (o) {
3274
+ case "array":
3275
+ if (c === "number") return n(s >= 0 && s < a.length);
3276
+ break;
3277
+ case "object":
3278
+ if (c === "string") return n(Object.hasOwn(a, s));
3279
+ break;
3280
+ default:
3281
+ }
3282
+ throw new M("%s (%*<100v) cannot have %s (%*<100v) as key", o, a, c, s);
3283
+ }
3284
+ //#endregion
3285
+ //#region node_modules/@jplorg/jpl/src/builtins/funcIn.js
3286
+ function hn(e, t, n, r, i) {
3287
+ let a = e.unwrapValue(r), o = e.type(a), s = e.unwrapValue(i ?? null), c = e.type(s);
3288
+ switch (c) {
3289
+ case "array":
3290
+ if (o === "number") return n(a >= 0 && a < s.length);
3291
+ break;
3292
+ case "object":
3293
+ if (o === "string") return n(Object.hasOwn(s, a));
3294
+ break;
3295
+ default:
3296
+ }
3297
+ throw new M("%s (%*<100v) cannot have %s (%*<100v) as key", c, s, o, a);
3298
+ }
3299
+ //#endregion
3300
+ //#region node_modules/@jplorg/jpl/src/builtins/funcKeys.js
3301
+ function gn(e, t, n, r) {
3302
+ let i = e.unwrapValue(r), a = e.type(i);
3303
+ switch (a) {
3304
+ case "array": return n(i.map((e, t) => t));
3305
+ case "object": return n(Object.keys(i));
3306
+ default:
3307
+ }
3308
+ throw new M("%s (%*<100v) has no keys", a, i);
3309
+ }
3310
+ //#endregion
3311
+ //#region node_modules/@jplorg/jpl/src/builtins/funcLength.js
3312
+ function _n(e, t, n, r) {
3313
+ let i = e.unwrapValue(r), a = e.type(i);
3314
+ switch (a) {
3315
+ case "null": return n(0);
3316
+ case "array": return n(i.length);
3317
+ case "string": return n([...i].length);
3318
+ case "object": return n(Object.keys(i).length);
3319
+ default:
3320
+ }
3321
+ throw new M("%s (%*<100v) has no length", a, i);
3322
+ }
3323
+ //#endregion
3324
+ //#region node_modules/@jplorg/jpl/src/builtins/funcNow.js
3325
+ function vn(e, t, n) {
3326
+ return n(Date.now());
3327
+ }
3328
+ //#endregion
3329
+ //#region node_modules/@jplorg/jpl/src/builtins/funcStartsWith.js
3330
+ function yn(e, t, n, r, i) {
3331
+ let a = e.unwrapValue(r), o = e.type(a), s = e.unwrapValue(i ?? null), c = e.type(s);
3332
+ switch (o) {
3333
+ case "string":
3334
+ if (c === "string") return n(a.startsWith(s));
3335
+ break;
3336
+ default:
3337
+ }
3338
+ throw new M("%s (%*<100v) cannot start with %s (%*<100v)", o, a, c, s);
3339
+ }
3340
+ //#endregion
3341
+ //#region node_modules/@jplorg/jpl/src/builtins/funcToJSON.js
3342
+ function bn(e, t, n, r) {
3343
+ return n(e.stringifyJSON(r, !1));
3344
+ }
3345
+ //#endregion
3346
+ //#region node_modules/@jplorg/jpl/src/builtins/funcToLowerCase.js
3347
+ async function xn(e, t, n, r) {
3348
+ let i = e.type(r);
3349
+ switch (i) {
3350
+ case "string": return n(await e.alterValue(r, (e) => e.toLowerCase()));
3351
+ default:
3352
+ }
3353
+ throw new M("%s (%*<100v) cannot be converted to lower case", i, e.unwrapValue(r));
3354
+ }
3355
+ //#endregion
3356
+ //#region node_modules/@jplorg/jpl/src/builtins/funcToNumber.js
3357
+ function Sn(e, t, n, r) {
3358
+ let i = e.unwrapValue(r), a = e.type(i);
3359
+ switch (a) {
3360
+ case "number": return n(i);
3361
+ case "string": {
3362
+ let t = e.normalizeValue(+i);
3363
+ if (i === "" || e.type(t) !== "number") throw new fe("%s (%*<100v) does not contain a valid number", a, i);
3364
+ return n(t);
3365
+ }
3366
+ default:
3367
+ }
3368
+ throw new M("%s (%*<100v) cannot be parsed as a number", a, i);
3369
+ }
3370
+ //#endregion
3371
+ //#region node_modules/@jplorg/jpl/src/builtins/funcToString.js
3372
+ function Cn(e, t, n, r) {
3373
+ return n(e.stringifyJSON(r, !0));
3374
+ }
3375
+ //#endregion
3376
+ //#region node_modules/@jplorg/jpl/src/builtins/funcToUpperCase.js
3377
+ async function wn(e, t, n, r) {
3378
+ let i = e.type(r);
3379
+ switch (i) {
3380
+ case "string": return n(await e.alterValue(r, (e) => e.toUpperCase()));
3381
+ default:
3382
+ }
3383
+ throw new M("%s (%*<100v) cannot be converted to upper case", i, e.unwrapValue(r));
3384
+ }
3385
+ //#endregion
3386
+ //#region node_modules/@jplorg/jpl/src/builtins/funcTrim.js
3387
+ async function Tn(e, t, n, r) {
3388
+ let i = e.type(r);
3389
+ switch (i) {
3390
+ case "string": return n(await e.alterValue(r, (e) => e.trim()));
3391
+ default:
3392
+ }
3393
+ throw new M("%s (%*<100v) cannot be trimmed", i, e.unwrapValue(r));
3394
+ }
3395
+ //#endregion
3396
+ //#region node_modules/@jplorg/jpl/src/builtins/funcTrimEnd.js
3397
+ async function En(e, t, n, r) {
3398
+ let i = e.type(r);
3399
+ switch (i) {
3400
+ case "string": return n(await e.alterValue(r, (e) => e.trimEnd()));
3401
+ default:
3402
+ }
3403
+ throw new M("%s (%*<100v) cannot be trimmed", i, e.unwrapValue(r));
3404
+ }
3405
+ //#endregion
3406
+ //#region node_modules/@jplorg/jpl/src/builtins/funcTrimStart.js
3407
+ async function Dn(e, t, n, r) {
3408
+ let i = e.type(r);
3409
+ switch (i) {
3410
+ case "string": return n(await e.alterValue(r, (e) => e.trimStart()));
3411
+ default:
3412
+ }
3413
+ throw new M("%s (%*<100v) cannot be trimmed", i, e.unwrapValue(r));
3414
+ }
3415
+ //#endregion
3416
+ //#region node_modules/@jplorg/jpl/src/builtins/funcType.js
3417
+ function On(e, t, n, r) {
3418
+ return n(e.type(r));
3419
+ }
3420
+ //#endregion
3421
+ //#region node_modules/@jplorg/jpl/src/builtins/funcVoid.js
3422
+ function kn() {
3423
+ return [];
3424
+ }
3425
+ //#endregion
3426
+ //#region node_modules/@jplorg/jpl/src/builtins/math.js
3427
+ function An(e, t) {
3428
+ let n = e.type(t), r = e.unwrapValue(t);
3429
+ if (n !== "number") throw new M("%s (%*<100v) cannot be used for mathematical operations", n, r);
3430
+ return r;
3431
+ }
3432
+ function Q(e) {
3433
+ return async function(t, n, r, i, ...a) {
3434
+ let o = t.type(i);
3435
+ if (o !== "number") throw new M("%s (%*<100v) cannot be used for mathematical operations", o, t.unwrapValue(i));
3436
+ return r(await t.alterValue(i, (n) => e(t, n, ...a)));
3437
+ };
3438
+ }
3439
+ var jn = Q((e, t, n) => t ** An(e, n ?? null)), Mn = Q((e, t) => Math.sqrt(t)), Nn = Q((e, t) => Math.exp(t)), Pn = Q((e, t) => Math.log(t)), Fn = Q((e, t) => Math.log10(t)), In = Q((e, t) => Math.sin(t)), Ln = Q((e, t) => Math.cos(t)), Rn = Q((e, t) => Math.tan(t)), zn = Q((e, t) => Math.asin(t)), Bn = Q((e, t) => Math.acos(t)), Vn = Q((e, t) => Math.atan(t)), Hn = Q((e, t) => Math.ceil(t)), Un = Q((e, t) => Math.floor(t)), Wn = Q((e, t) => Math.round(t)), Gn = Q((e, t) => Math.trunc(t)), Kn = Q((e, t) => Math.abs(t)), qn = /* @__PURE__ */ s({
3440
+ abs: () => Kn,
3441
+ acos: () => Bn,
3442
+ asin: () => zn,
3443
+ atan: () => Vn,
3444
+ ceil: () => Hn,
3445
+ contains: () => un,
3446
+ cos: () => Ln,
3447
+ endsWith: () => dn,
3448
+ error: () => fn,
3449
+ exp: () => Nn,
3450
+ floor: () => Un,
3451
+ fromJSON: () => pn,
3452
+ has: () => mn,
3453
+ in: () => hn,
3454
+ keys: () => gn,
3455
+ length: () => _n,
3456
+ log: () => Pn,
3457
+ log10: () => Fn,
3458
+ now: () => vn,
3459
+ pow: () => jn,
3460
+ round: () => Wn,
3461
+ sin: () => In,
3462
+ sqrt: () => Mn,
3463
+ startsWith: () => yn,
3464
+ tan: () => Rn,
3465
+ toJSON: () => bn,
3466
+ toLowerCase: () => xn,
3467
+ toNumber: () => Sn,
3468
+ toString: () => Cn,
3469
+ toUpperCase: () => wn,
3470
+ trim: () => Tn,
3471
+ trimEnd: () => En,
3472
+ trimStart: () => Dn,
3473
+ trunc: () => Gn,
3474
+ type: () => On,
3475
+ void: () => kn
3476
+ }), Jn = "\n# There are additional builtins that are implemented directly in the corresponding languages.\n# Also the functions in the \"internals\" namespace are not exposed to the public and are only to be used by the builtins below.\n\nfunc map(f): ([.[] | f()])\n| func mapValues(f): (.[] |= f())\n| func select(f): (if f() then . else void() end)\n| func reduce(f, s): (\n l = length()\n | func i(i, n, c): (if n < l then i(i, n + 1, f->(.[n], c, n)) else c end)\n | i(i, 0, s)\n)\n| func while(cond, f): (\n func i(i): (if cond() then ., i->(f(), i) else void() end)\n | i(i)\n)\n| func until(cond, f): (\n func i(i): (if cond() then . else i->(f(), i) end)\n | i(i)\n)\n| func range(from, to, step): (\n t = type->(from) | if t != \"number\" then error->(\"cannot use \\(t) as a number\") end\n | t = type->(to) | if t != \"number\" then error->(\"cannot use \\(t) as a number\") end\n | s = (step | if . != 0 and . != null then abs() else 1 end)\n | while->(\n from,\n if from <= to then func (): (. < to) else func (): (. > to) end,\n if from <= to then func (): (. + s) else func (): (. - s) end\n )\n)\n\n\n# type selectors:\n| func isArray(): (type() == \"array\")\n| func arrays(): (select(isArray))\n| func isObject(): (type() == \"object\")\n| func objects(): (select(isObject))\n| func isIterable(): (contains->([\"array\", \"object\"], type()))\n| func iterables(): (select(isIterable))\n| func isScalar(): (not contains->([\"array\", \"object\"], type()))\n| func scalars(): (select(isScalar))\n| func isBoolean(): (type() == \"boolean\")\n| func booleans(): (select(isBoolean))\n| func isNumber(): (type() == \"number\")\n| func numbers(): (select(isNumber))\n| func isString(): (type() == \"string\")\n| func strings(): (select(isString))\n| func isNull(): (type() == \"null\")\n| func nulls(): (select(isNull))\n| func isFunction(): (type() == \"function\")\n| func functions(): (select(isFunction))\n| func isNullLike(): (contains->([\"null\", \"function\"], type()))\n| func nullLikes(): (select(isNullLike))\n| func isValue(): (not contains->([\"null\", \"function\"], type()))\n| func values(): (select(isValue))\n| func isContent(): (isValue() and not contains->([[], {}, \"\"], .))\n| func contents(): (select(isContent))\n\n\n| func toEntries(): (o = . | keys() | map(func (): ({ key: ., value: o[.] })))\n| func fromEntries(): (\n reduce(\n func (s): (s + { (.key ?? .Key ?? .name ?? .Name): if has(\"value\") then .value else .Value end }),\n {}\n )\n)\n| func withEntries(f): (toEntries() | map(f) | fromEntries())\n\n| func add(): (reduce(func (sum): (sum + .)))\n| func join(sep): (\n reduce(\n func (sum): (\n if sum == null then \"\" else sum + sep end\n + (. | toString())\n )\n ) ?? \"\"\n)\n| func sortBy(f): ([.[] | [[f()], .]] | internals.sortEntries() | [.[][1]])\n| func sort(): (sortBy(func (): (.)))\n| func groupBy(f): (\n key = 0 | value = 1\n | [.[] | [[f()], [.]]] | internals.sortEntries()\n | if . == []\n then .\n else\n reduce->(\n .[1:],\n func (sum): (if sum[-1][key] == .[key] then (sum)[-1][value] += .[value] else sum + [.] end),\n .[:1]\n )\n | [.[][value]]\n end\n)\n| func group(): (groupBy(func (): (.)))\n| func uniqueBy(f): (groupBy(f) | map(func (): (.[0])))\n| func unique(): (group() | map(func (): (.[0])))\n| func recurseBy(f, cond): (\n c = cond ?? func (): (. != null)\n | func r(r): (., (f() | select(c) | r(r)))\n | r(r)\n)\n| func recurse(cond): (recurseBy(func (): ((arrays(), objects()) | .[]), cond))\n| func reverse(): ([.[length() - 1 - range(0, length())]])\n| func minBy(f): (\n key = 0 | value = 1\n | [.[] | [[f()], .]]\n | reduce->(.[1:], func (sum): (if .[key] < sum[key] then . else sum end), .[0])\n | .[value]\n)\n| func min(): (reduce->(.[1:], func (sum): (if . < sum then . else sum end), .[0]))\n| func maxBy(f): (\n key = 0 | value = 1\n | [.[] | [[f()], .]]\n | reduce->(.[1:], func (sum): (if .[key] > sum[key] then . else sum end), .[0])\n | .[value]\n)\n| func max(): (reduce->(.[1:], func (sum): (if . > sum then . else sum end), .[0]))\n| func first(f): ([f()][0])\n| func nth(which, f): (\n [f()]\n | .[if which | type() == \"number\" then which else length() | which() end]\n)\n| func last(f): ([f()][-1])\n| func isEmpty(f): (first(func (): ((f() | false), true)))\n| func allBy(f, cond): (isEmpty(func (): (f() | cond() and void())))\n| func all(cond): (allBy(func (): (.[]), cond))\n| func anyBy(f, cond): (not isEmpty(func (): (f() | cond() or void())))\n| func any(cond): (anyBy(func (): (.[]), cond))\n\n| func getPath(path): (\n fields = (path | if type() == 'string' then . / '.' end)\n | reduce->(fields, func (sum): sum[if type->(sum) == 'array' then toNumber() else toString() end], .)\n)\n| func updatePath(path, update): (\n fields = (path | if type() == 'string' then (. / '.')[] |= (v = . | try toNumber() catch v) end)\n | reduce->(\n reverse->(fields),\n func (sum): (\n field = .\n | func (): (\n if type() == 'array'\n then (\n input = .\n | try toNumber->(field) catch toString->(field)\n | if type() == 'number'\n then input[.] |= sum()\n else {}[.] |= sum()\n end\n ) elif type() == 'object'\n then (\n .[toString->(field)] |= sum()\n ) elif type->(field) == 'number'\n then (\n [][field] |= sum()\n ) else (\n {}[toString->(field)] |= sum()\n )\n end\n )\n ),\n update\n )->(.)\n)\n| func setPath(path, value): (\n updatePath(path, func (): value)\n)\n", Yn = u(async () => {
3477
+ await void 0;
3478
+ let e = { ...qn };
3479
+ return await (await sn.parse(Jn, { runtime: {
3480
+ vars: {
3481
+ internals: cn,
3482
+ ...qn
3483
+ },
3484
+ adjustResult: (t, n) => {
3485
+ let { internals: r, ...i } = n.vars;
3486
+ return e = f(e, Object.entries(i)), [];
3487
+ }
3488
+ } })).run([null]), e;
3489
+ }), Xn = u(async () => ({
3490
+ interpreter: {},
3491
+ program: {},
3492
+ runtime: { vars: { ...await Yn() } }
3493
+ })), Zn = async (e, t) => {
3494
+ let n = await Xn();
3495
+ return new on({
3496
+ interpreter: an(t?.interpreter, n.interpreter),
3497
+ program: ht(t?.program, n.program),
3498
+ runtime: F(t?.runtime, n.runtime)
3499
+ }).parse(e);
3500
+ };
3501
+ ({ ...Ce });
3502
+ //#endregion
3503
+ //#region node_modules/@rotorjs/dashboards/dist/main.js
3504
+ var Qn = [];
3505
+ for (let e = 0; e < 256; ++e) Qn.push((e + 256).toString(16).slice(1));
3506
+ var $n = class {
3507
+ #e;
3508
+ #t;
3509
+ #n;
3510
+ #r = {};
3511
+ #i = !1;
3512
+ #a;
3513
+ #o = new AbortController();
3514
+ constructor(e, t, n, r) {
3515
+ this.#e = e, this.#t = Promise.resolve(t), this.#n = n, this.#a = r?.debounce;
3516
+ let i = this.signal;
3517
+ this.#e.addEventListener("interest", (e) => {
3518
+ Object.hasOwn(this.#r, e.interest) && this.update();
3519
+ }, { signal: i }), this.#n(t);
3520
+ }
3521
+ get engine() {
3522
+ return this.#e;
3523
+ }
3524
+ get signal() {
3525
+ return AbortSignal.any([this.#o.signal, this.engine.signal]);
3526
+ }
3527
+ addInterest(e) {
3528
+ this.#r[e] = !0;
3529
+ }
3530
+ removeInterest(e) {
3531
+ delete this.#r[e];
3532
+ }
3533
+ getInterests() {
3534
+ return Object.keys(this.#r);
3535
+ }
3536
+ clearInterests() {
3537
+ this.#r = {};
3538
+ }
3539
+ update() {
3540
+ this.#i || (this.#i = !0, this.#t = this.#t.then(async (e) => {
3541
+ if (await new Promise((e) => {
3542
+ setTimeout(e, this.#a);
3543
+ }), this.#i = !1, this.signal.aborted) return e;
3544
+ let t;
3545
+ try {
3546
+ t = await this.reduce(e);
3547
+ } catch (n) {
3548
+ t = this.recover(e, n);
3549
+ }
3550
+ return this.signal.aborted ? e : (t !== e && this.#n(t), t);
3551
+ }));
3552
+ }
3553
+ stop() {
3554
+ this.#o.abort();
3555
+ }
3556
+ }, $ = [];
3557
+ for (let e = 0; e < 256; ++e) $.push((e + 256).toString(16).slice(1));
3558
+ function er(e, t = 0) {
3559
+ return ($[e[t + 0]] + $[e[t + 1]] + $[e[t + 2]] + $[e[t + 3]] + "-" + $[e[t + 4]] + $[e[t + 5]] + "-" + $[e[t + 6]] + $[e[t + 7]] + "-" + $[e[t + 8]] + $[e[t + 9]] + "-" + $[e[t + 10]] + $[e[t + 11]] + $[e[t + 12]] + $[e[t + 13]] + $[e[t + 14]] + $[e[t + 15]]).toLowerCase();
3560
+ }
3561
+ var tr = new Uint8Array(16);
3562
+ function nr() {
3563
+ return crypto.getRandomValues(tr);
3564
+ }
3565
+ var rr = {};
3566
+ function ir(e, t, n) {
3567
+ let r;
3568
+ if (e) r = or(e.random ?? e.rng?.() ?? nr(), e.msecs, e.seq, t, n);
3569
+ else {
3570
+ let e = Date.now(), i = nr();
3571
+ ar(rr, e, i), r = or(i, rr.msecs, rr.seq, t, n);
3572
+ }
3573
+ return t ?? er(r);
3574
+ }
3575
+ function ar(e, t, n) {
3576
+ return e.msecs ??= -Infinity, e.seq ??= 0, t > e.msecs ? (e.seq = n[6] << 23 | n[7] << 16 | n[8] << 8 | n[9], e.msecs = t) : (e.seq = e.seq + 1 | 0, e.seq === 0 && e.msecs++), e;
3577
+ }
3578
+ function or(e, t, n, r, i = 0) {
3579
+ if (e.length < 16) throw Error("Random bytes length must be >= 16");
3580
+ if (!r) r = new Uint8Array(16), i = 0;
3581
+ else if (i < 0 || i + 16 > r.length) throw RangeError(`UUID byte range ${i}:${i + 15} is out of buffer bounds`);
3582
+ return t ??= Date.now(), n ??= e[6] * 127 << 24 | e[7] << 16 | e[8] << 8 | e[9], r[i++] = t / 1099511627776 & 255, r[i++] = t / 4294967296 & 255, r[i++] = t / 16777216 & 255, r[i++] = t / 65536 & 255, r[i++] = t / 256 & 255, r[i++] = t & 255, r[i++] = 112 | n >>> 28 & 15, r[i++] = n >>> 20 & 255, r[i++] = 128 | n >>> 14 & 63, r[i++] = n >>> 6 & 255, r[i++] = n << 2 & 255 | e[10] & 3, r[i++] = e[11], r[i++] = e[12], r[i++] = e[13], r[i++] = e[14], r[i++] = e[15], r;
3583
+ }
3584
+ var sr = class extends $n {
3585
+ recover(e, t) {
3586
+ return [{
3587
+ type: "error",
3588
+ id: ir(),
3589
+ error: t
3590
+ }];
3591
+ }
3592
+ }, cr = /* @__PURE__ */ l((/* @__PURE__ */ o(((e, t) => {
3593
+ t.exports = function e(t, n) {
3594
+ if (t === n) return !0;
3595
+ if (t && n && typeof t == "object" && typeof n == "object") {
3596
+ if (t.constructor !== n.constructor) return !1;
3597
+ var r, i, a;
3598
+ if (Array.isArray(t)) {
3599
+ if (r = t.length, r != n.length) return !1;
3600
+ for (i = r; i-- !== 0;) if (!e(t[i], n[i])) return !1;
3601
+ return !0;
3602
+ }
3603
+ if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
3604
+ if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
3605
+ if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
3606
+ if (a = Object.keys(t), r = a.length, r !== Object.keys(n).length) return !1;
3607
+ for (i = r; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(n, a[i])) return !1;
3608
+ for (i = r; i-- !== 0;) {
3609
+ var o = a[i];
3610
+ if (!e(t[o], n[o])) return !1;
3611
+ }
3612
+ return !0;
3613
+ }
3614
+ return t !== t && n !== n;
3615
+ };
3616
+ })))(), 1), lr = class extends sr {
3617
+ #e;
3618
+ #t;
3619
+ #n;
3620
+ #r;
3621
+ constructor(e, t, n, r) {
3622
+ super(e, r?.initialState ?? [], n), this.#e = t, this.#n = r?.vars ?? {}, this.#r = r?.compare ?? cr.default, this.update();
3623
+ }
3624
+ async getProgram() {
3625
+ if (this.#t) throw this.#t;
3626
+ if (typeof this.#e == "string") try {
3627
+ this.#e = await Zn(this.#e);
3628
+ } catch (e) {
3629
+ throw this.#t = e, e;
3630
+ }
3631
+ return this.#e;
3632
+ }
3633
+ async reduce(e) {
3634
+ let t = await this.getProgram(), n = Object.fromEntries(Object.entries(this.#n).map(([e, t]) => [e, typeof t == "function" ? t(this) : t])), r = await t.run([null], { runtime: { vars: n } });
3635
+ return this.#r(e, r) ? e : r;
3636
+ }
3637
+ };
3638
+ //#endregion
3639
+ //#region lib/createJPLDashboardReducer.ts
3640
+ function ur(e) {
3641
+ return (t, n, r) => new lr(t, n.src ?? "", r, e);
3642
+ }
3643
+ //#endregion
3644
+ export { lr as JPLDashboardReducer, ur as createJPLDashboardReducer };