@platforma-sdk/model 1.27.17 → 1.28.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/index.mjs CHANGED
@@ -1,66 +1,67 @@
1
- var _e = Object.defineProperty;
2
- var Ie = (t, e, n) => e in t ? _e(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var F = (t, e, n) => Ie(t, typeof e != "symbol" ? e + "" : e, n);
4
- import { isPColumn as M, mapPObjectData as ue, selectorsToPredicate as ce, AnchoredIdDeriver as te, isPlRef as Ce, resolveAnchors as Le, isPColumnSpec as N, getAxisId as L, entriesToDataInfo as Fe, mapValueInVOE as Te, ensurePColumn as Re, isDataInfo as me, extractAllColumns as ke, mapPTableDef as De, mapDataInfo as Oe, canonicalizeAxisId as Ee, matchAxisId as G } from "@milaboratories/pl-model-common";
1
+ var je = Object.defineProperty;
2
+ var Ke = (t, e, n) => e in t ? je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var L = (t, e, n) => Ke(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isPColumn as se, mapPObjectData as ge, isDataInfoEntries as xe, isDataInfo as me, dataInfoToEntries as Ve, resolveAnchors as $e, isPColumnSpec as Z, isPartitionedDataInfoEntries as Je, getAxisId as F, entriesToDataInfo as Ne, selectorsToPredicate as ce, canonicalizeAxisId as Ue, AnchoredIdDeriver as ye, isPlRef as Be, mapValueInVOE as Me, ensurePColumn as Ge, extractAllColumns as We, mapPTableDef as He, mapDataInfo as qe, matchAxisId as G } from "@milaboratories/pl-model-common";
5
5
  export * from "@milaboratories/pl-model-common";
6
- import { z as O } from "zod";
6
+ import { z as K } from "zod";
7
+ import Pe from "canonicalize";
7
8
  export * from "@milaboratories/pl-error-like";
8
- class je extends Error {
9
+ class ze extends Error {
9
10
  constructor(e, n) {
10
11
  super(`${e.length}${n ? "+" : ""} errors, first error: ` + e[0].message), this.errors = e, this.moreErrors = n;
11
12
  }
12
13
  }
13
- function Ve(t) {
14
- if (!t.ok) throw new je(t.errors, t.moreErrors);
14
+ function Ye(t) {
15
+ if (!t.ok) throw new ze(t.errors, t.moreErrors);
15
16
  return t.value;
16
17
  }
17
- function ht(t) {
18
+ function Rt(t) {
18
19
  return new Proxy(t, {
19
20
  get(e, n) {
20
- return Ve(e[n]);
21
+ return Ye(e[n]);
21
22
  }
22
23
  });
23
24
  }
24
- function b(t) {
25
- return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null ? Y(t) : t;
25
+ function S(t) {
26
+ return typeof t == "string" || typeof t == "number" || typeof t == "boolean" || t === null ? ee(t) : t;
26
27
  }
27
28
  function W(t) {
28
29
  return { type: "GetFromCtx", variable: t };
29
30
  }
30
- function gt(t) {
31
+ function Ot(t) {
31
32
  return {
32
33
  type: "Isolate",
33
34
  cfg: t
34
35
  };
35
36
  }
36
- const mt = W("$args"), yt = W("$it"), bt = W("$prod"), vt = W("$staging"), wt = W("$ui");
37
- function Y(t) {
37
+ const jt = W("$args"), Kt = W("$it"), Vt = W("$prod"), $t = W("$staging"), Jt = W("$ui");
38
+ function ee(t) {
38
39
  return { type: "Immediate", value: t };
39
40
  }
40
- function ye(t) {
41
+ function Ce(t) {
41
42
  const e = {};
42
- for (const [n, r] of Object.entries(t)) e[n] = b(r);
43
+ for (const [n, r] of Object.entries(t)) e[n] = S(r);
43
44
  return {
44
45
  type: "MakeObject",
45
46
  template: e
46
47
  };
47
48
  }
48
- function xt(...t) {
49
+ function Nt(...t) {
49
50
  const e = [];
50
- for (const n of t) e.push(b(n));
51
+ for (const n of t) e.push(S(n));
51
52
  return {
52
53
  type: "MakeArray",
53
54
  template: e
54
55
  };
55
56
  }
56
- function X(t, e) {
57
+ function te(t, e) {
57
58
  return {
58
59
  type: "GetJsonField",
59
- source: b(t),
60
- field: b(e)
60
+ source: S(t),
61
+ field: S(e)
61
62
  };
62
63
  }
63
- function At(t, e, n = "$it") {
64
+ function Ut(t, e, n = "$it") {
64
65
  return {
65
66
  type: "MapRecordValues",
66
67
  source: t,
@@ -68,7 +69,7 @@ function At(t, e, n = "$it") {
68
69
  itVar: n
69
70
  };
70
71
  }
71
- function St(t, e, n = "$it") {
72
+ function Bt(t, e, n = "$it") {
72
73
  return {
73
74
  type: "MapArrayValues",
74
75
  source: t,
@@ -76,54 +77,54 @@ function St(t, e, n = "$it") {
76
77
  itVar: n
77
78
  };
78
79
  }
79
- function Pt(t) {
80
+ function Mt(t) {
80
81
  return {
81
82
  type: "Flatten",
82
83
  source: t
83
84
  };
84
85
  }
85
- function _t(t) {
86
+ function Gt(t) {
86
87
  return {
87
88
  type: "IsEmpty",
88
89
  arg: t
89
90
  };
90
91
  }
91
- function It(t) {
92
+ function Wt(t) {
92
93
  return {
93
94
  type: "Not",
94
95
  operand: t
95
96
  };
96
97
  }
97
- function Ct(t, e) {
98
+ function Ht(t, e) {
98
99
  return {
99
100
  type: "And",
100
101
  operand1: t,
101
102
  operand2: e
102
103
  };
103
104
  }
104
- function Lt(t, e) {
105
+ function qt(t, e) {
105
106
  return {
106
107
  type: "Or",
107
108
  operand1: t,
108
109
  operand2: e
109
110
  };
110
111
  }
111
- function Ft(t, e) {
112
+ function zt(t, e) {
112
113
  return {
113
114
  type: "GetResourceField",
114
- source: b(t),
115
- field: b(e)
115
+ source: S(t),
116
+ field: S(e)
116
117
  };
117
118
  }
118
- function Tt() {
119
+ function Yt() {
119
120
  return function(t) {
120
121
  return {
121
122
  type: "GetResourceValueAsJson",
122
- source: b(t)
123
+ source: S(t)
123
124
  };
124
125
  };
125
126
  }
126
- function Rt(t, e, n = "$it") {
127
+ function Xt(t, e, n = "$it") {
127
128
  return {
128
129
  type: "MapResourceFields",
129
130
  source: t,
@@ -131,120 +132,120 @@ function Rt(t, e, n = "$it") {
131
132
  itVar: n
132
133
  };
133
134
  }
134
- function kt(t) {
135
+ function Qt(t) {
135
136
  return {
136
137
  type: "GetBlobContent",
137
- source: b(t)
138
+ source: S(t)
138
139
  };
139
140
  }
140
- function Dt(t) {
141
+ function Zt(t) {
141
142
  return {
142
143
  type: "GetBlobContentAsString",
143
- source: b(t)
144
+ source: S(t)
144
145
  };
145
146
  }
146
- function Ot() {
147
+ function en() {
147
148
  return function(t) {
148
149
  return {
149
150
  type: "GetBlobContentAsJson",
150
- source: b(t)
151
+ source: S(t)
151
152
  };
152
153
  };
153
154
  }
154
- function Et(t) {
155
+ function tn(t) {
155
156
  return {
156
157
  type: "GetDownloadedBlobContent",
157
- source: b(t)
158
+ source: S(t)
158
159
  };
159
160
  }
160
- function jt(t) {
161
+ function nn(t) {
161
162
  return {
162
163
  type: "GetOnDemandBlobContent",
163
- source: b(t)
164
+ source: S(t)
164
165
  };
165
166
  }
166
- function Vt(t, e) {
167
+ function rn(t, e) {
167
168
  return {
168
169
  type: "ExtractArchiveAndGetURL",
169
170
  format: e,
170
- source: b(t)
171
+ source: S(t)
171
172
  };
172
173
  }
173
- function Kt(t) {
174
+ function sn(t) {
174
175
  return {
175
176
  type: "GetImportProgress",
176
- source: b(t)
177
+ source: S(t)
177
178
  };
178
179
  }
179
- function Jt(t, e) {
180
+ function on(t, e) {
180
181
  return {
181
182
  type: "GetLastLogs",
182
- source: b(t),
183
+ source: S(t),
183
184
  lines: e
184
185
  };
185
186
  }
186
- function Nt(t, e) {
187
+ function an(t, e) {
187
188
  return {
188
189
  type: "GetProgressLog",
189
- source: b(t),
190
+ source: S(t),
190
191
  patternToSearch: e
191
192
  };
192
193
  }
193
- function $t(t, e) {
194
+ function ln(t, e) {
194
195
  return {
195
196
  type: "GetProgressLogWithInfo",
196
- source: b(t),
197
+ source: S(t),
197
198
  patternToSearch: e
198
199
  };
199
200
  }
200
- function Bt(t) {
201
+ function un(t) {
201
202
  return {
202
203
  type: "GetLogHandle",
203
- source: b(t)
204
+ source: S(t)
204
205
  };
205
206
  }
206
- function Ke() {
207
+ function Xe() {
207
208
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
208
209
  }
209
- function be(t) {
210
+ function _e(t) {
210
211
  if (t && typeof globalThis.getPlatforma == "function")
211
212
  return globalThis.getPlatforma(t);
212
213
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
213
214
  throw new Error("Can't get platforma instance.");
214
215
  }
215
- function Je() {
216
+ function Qe() {
216
217
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
217
218
  }
218
219
  function h() {
219
220
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
220
221
  throw new Error("Not in config rendering context");
221
222
  }
222
- function q(t, e) {
223
- const n = Je();
223
+ function X(t, e) {
224
+ const n = Qe();
224
225
  if (n === void 0) return !1;
225
226
  if (t in n.callbackRegistry) throw new Error(`Callback with key ${t} already registered.`);
226
227
  return n.callbackRegistry[t] = e, !0;
227
228
  }
228
- const ne = /* @__PURE__ */ new Map();
229
- function Ne(t, e) {
229
+ const ae = /* @__PURE__ */ new Map();
230
+ function Ze(t, e) {
230
231
  t in h().callbackRegistry || (h().callbackRegistry[t] = (n) => {
231
- for (const r of ne.get(t))
232
+ for (const r of ae.get(t))
232
233
  r(n);
233
- }, ne.set(t, [])), ne.get(t).push(e);
234
+ }, ae.set(t, [])), ae.get(t).push(e);
234
235
  }
235
- class S {
236
+ class _ {
236
237
  constructor(e, n = (r) => r) {
237
- F(this, "isResolved", !1);
238
- F(this, "resolvedValue");
239
- this.handle = e, this.postProcess = n, Ne(e, (r) => {
238
+ L(this, "isResolved", !1);
239
+ L(this, "resolvedValue");
240
+ this.handle = e, this.postProcess = n, Ze(e, (r) => {
240
241
  this.resolvedValue = n(r), this.isResolved = !0;
241
242
  });
242
243
  }
243
244
  map(e) {
244
- return new S(this.handle, (n) => e(this.postProcess(n)));
245
+ return new _(this.handle, (n) => e(this.postProcess(n)));
245
246
  }
246
247
  mapDefined(e) {
247
- return new S(this.handle, (n) => {
248
+ return new _(this.handle, (n) => {
248
249
  const r = this.postProcess(n);
249
250
  return r ? e(r) : void 0;
250
251
  });
@@ -253,7 +254,7 @@ class S {
253
254
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
254
255
  }
255
256
  }
256
- function ie(t, e) {
257
+ function pe(t, e) {
257
258
  return t === void 0 ? void 0 : e(t);
258
259
  }
259
260
  class I {
@@ -295,7 +296,7 @@ class I {
295
296
  ...this.resolvePath,
296
297
  ...n.map((i) => typeof i == "string" ? i : i.field)
297
298
  ];
298
- return ie(
299
+ return pe(
299
300
  h().resolveWithCommon(this.handle, e, ...n),
300
301
  (i) => new I(i, r)
301
302
  );
@@ -317,7 +318,7 @@ class I {
317
318
  }
318
319
  getError() {
319
320
  const e = [...this.resolvePath, "error"];
320
- return ie(
321
+ return pe(
321
322
  h().getError(this.handle),
322
323
  (n) => new I(n, e)
323
324
  );
@@ -359,7 +360,7 @@ class I {
359
360
  getPColumns(e = !1, n = "") {
360
361
  const r = this.parsePObjectCollection(e, n);
361
362
  return r === void 0 ? void 0 : Object.entries(r).map(([, s]) => {
362
- if (!M(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
363
+ if (!se(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
363
364
  return s;
364
365
  });
365
366
  }
@@ -377,18 +378,18 @@ class I {
377
378
  const i = {};
378
379
  for (const [s, o] of Object.entries(r)) {
379
380
  const a = [...this.resolvePath, s];
380
- i[s] = ue(o, (c) => new I(c, a));
381
+ i[s] = ge(o, (l) => new I(l, a));
381
382
  }
382
383
  return i;
383
384
  }
384
385
  getFileContentAsBase64() {
385
- return new S(h().getBlobContentAsBase64(this.handle));
386
+ return new _(h().getBlobContentAsBase64(this.handle));
386
387
  }
387
388
  getFileContentAsString() {
388
- return new S(h().getBlobContentAsString(this.handle));
389
+ return new _(h().getBlobContentAsString(this.handle));
389
390
  }
390
391
  getFileContentAsJson() {
391
- return new S(
392
+ return new _(
392
393
  h().getBlobContentAsString(this.handle)
393
394
  ).mapDefined((e) => JSON.parse(e));
394
395
  }
@@ -408,7 +409,7 @@ class I {
408
409
  * @returns downloaded file handle
409
410
  */
410
411
  getFileHandle() {
411
- return new S(h().getDownloadedBlobContentHandle(this.handle));
412
+ return new _(h().getDownloadedBlobContentHandle(this.handle));
412
413
  }
413
414
  /**
414
415
  * @deprecated use getFileHandle
@@ -420,7 +421,7 @@ class I {
420
421
  * @returns downloaded file handle
421
422
  */
422
423
  getRemoteFileHandle() {
423
- return new S(h().getOnDemandBlobContentHandle(this.handle));
424
+ return new _(h().getOnDemandBlobContentHandle(this.handle));
424
425
  }
425
426
  /**
426
427
  * @deprecated use getRemoteFileHandle
@@ -432,22 +433,22 @@ class I {
432
433
  * @returns the url to the extracted folder
433
434
  */
434
435
  extractArchiveAndGetURL(e) {
435
- return new S(h().extractArchiveAndGetURL(this.handle, e));
436
+ return new _(h().extractArchiveAndGetURL(this.handle, e));
436
437
  }
437
438
  getImportProgress() {
438
- return new S(h().getImportProgress(this.handle));
439
+ return new _(h().getImportProgress(this.handle));
439
440
  }
440
441
  getLastLogs(e) {
441
- return new S(h().getLastLogs(this.handle, e));
442
+ return new _(h().getLastLogs(this.handle, e));
442
443
  }
443
444
  getProgressLog(e) {
444
- return new S(h().getProgressLog(this.handle, e));
445
+ return new _(h().getProgressLog(this.handle, e));
445
446
  }
446
447
  getProgressLogWithInfo(e) {
447
- return new S(h().getProgressLogWithInfo(this.handle, e));
448
+ return new _(h().getProgressLogWithInfo(this.handle, e));
448
449
  }
449
450
  getLogHandle() {
450
- return new S(h().getLogHandle(this.handle));
451
+ return new _(h().getLogHandle(this.handle));
451
452
  }
452
453
  allFieldsResolved(e = "Input") {
453
454
  switch (e) {
@@ -470,195 +471,134 @@ class I {
470
471
  }, o = e;
471
472
  if (i && (r === "Input" && !this.getInputsLocked() || r === "Output" && !this.getOutputsLocked()))
472
473
  return;
473
- let c = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
474
- (l) => [l, this.resolve({ field: l, assertFieldType: r })]
474
+ let l = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
475
+ (c) => [c, this.resolve({ field: c, assertFieldType: r })]
475
476
  );
476
- return s && (c = c.filter((l) => l[1] !== void 0)), c.map(([l, m]) => o(l, m));
477
+ return s && (l = l.filter((c) => c[1] !== void 0)), l.map(([c, w]) => o(c, w));
477
478
  }
478
479
  }
479
- const ve = "staging", we = "main", $e = {
480
+ const Ie = "staging", Le = "main", et = {
480
481
  explicitColumnsSupport: !0,
481
482
  inlineColumnsSupport: !0,
482
483
  activeArgs: !0
483
484
  };
484
- function xe(t) {
485
+ function Te(t) {
485
486
  return typeof t == "object" && t !== null && "__awaited_futures__" in t;
486
487
  }
487
- function oe(t, e, n) {
488
+ function de(t, e, n) {
488
489
  if (e.has(n)) return;
489
490
  if (e.add(n), typeof n === "object")
490
- if (xe(n)) n.__awaited_futures__.forEach((i) => t.add(i));
491
+ if (Te(n)) n.__awaited_futures__.forEach((i) => t.add(i));
491
492
  else if (Array.isArray(n))
492
- for (const i of n) oe(t, e, i);
493
+ for (const i of n) de(t, e, i);
493
494
  else
494
495
  for (const [, i] of Object.entries(n))
495
- i !== n && oe(t, e, i);
496
+ i !== n && de(t, e, i);
496
497
  }
497
- function Be(t) {
498
+ function tt(t) {
498
499
  const e = /* @__PURE__ */ new Set();
499
- return oe(e, /* @__PURE__ */ new Set(), t), e;
500
+ return de(e, /* @__PURE__ */ new Set(), t), e;
500
501
  }
501
- const Ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
+ const cn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
502
503
  __proto__: null,
503
- GlobalCfgRenderCtxFeatureFlags: $e,
504
- MainAccessorName: we,
505
- StagingAccessorName: ve,
506
- getAllFutureAwaits: Be,
507
- isFutureAwait: xe
508
- }, Symbol.toStringTag, { value: "Module" }));
509
- function Ue(t, e) {
510
- const n = [...e].sort((s, o) => o[0] - s[0]);
511
- if (t.type === "JsonPartitioned" || t.type === "BinaryPartitioned") {
512
- const { partitionKeyLength: s } = t;
513
- for (const [o] of e)
514
- if (o >= s)
515
- throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`);
516
- } else if (t.type === "Json") {
517
- const { keyLength: s } = t;
518
- for (const [o] of e)
519
- if (o >= s)
520
- throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`);
521
- }
522
- const r = (s) => {
523
- for (const [o, a] of n)
524
- if (s[o] !== a)
525
- return !1;
526
- return !0;
527
- }, i = (s) => {
528
- const o = [...s];
529
- for (const [a] of n)
530
- o.splice(a, 1);
531
- return o;
532
- };
533
- switch (t.type) {
534
- case "Json": {
535
- const s = t.data.filter((o) => r(o.key)).map((o) => ({
536
- key: i(o.key),
537
- value: o.value
538
- }));
539
- return {
540
- type: "Json",
541
- keyLength: t.keyLength - e.length,
542
- data: s
543
- };
544
- }
545
- case "JsonPartitioned": {
546
- const s = t.parts.filter((o) => r(o.key)).map((o) => ({
547
- key: i(o.key),
548
- value: o.value
549
- }));
550
- return {
551
- type: "JsonPartitioned",
552
- partitionKeyLength: t.partitionKeyLength - e.length,
553
- parts: s
554
- };
555
- }
556
- case "BinaryPartitioned": {
557
- const s = t.parts.filter((o) => r(o.key)).map((o) => ({
558
- key: i(o.key),
559
- value: o.value
560
- }));
561
- return {
562
- type: "BinaryPartitioned",
563
- partitionKeyLength: t.partitionKeyLength - e.length,
564
- parts: s
565
- };
566
- }
567
- }
568
- }
569
- const Me = "pl7.app/label", Ge = "pl7.app/trace", We = O.object({
570
- type: O.string(),
571
- importance: O.number().optional(),
572
- id: O.string().optional(),
573
- label: O.string()
574
- }), He = O.array(We), qe = 1e-3, ze = "__LABEL__", pe = "__LABEL__@1";
575
- function de(t, e, n = {}) {
576
- const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = t.map((f) => {
577
- var R, k;
578
- const p = e(f);
579
- let d, y, g;
580
- "spec" in p && typeof p.spec == "object" ? (d = p.spec, y = p.prefixTrace, g = p.suffixTrace) : d = p;
581
- const v = (R = d.annotations) == null ? void 0 : R[Me], w = (k = d.annotations) == null ? void 0 : k[Ge], x = (w ? He.safeParse(JSON.parse(w)).data : void 0) ?? [], C = [
504
+ GlobalCfgRenderCtxFeatureFlags: et,
505
+ MainAccessorName: Le,
506
+ StagingAccessorName: Ie,
507
+ getAllFutureAwaits: tt,
508
+ isFutureAwait: Te
509
+ }, Symbol.toStringTag, { value: "Module" })), nt = "pl7.app/label", rt = "pl7.app/trace", it = K.object({
510
+ type: K.string(),
511
+ importance: K.number().optional(),
512
+ id: K.string().optional(),
513
+ label: K.string()
514
+ }), st = K.array(it), ot = 1e-3, at = "__LABEL__", ve = "__LABEL__@1";
515
+ function Fe(t, e, n = {}) {
516
+ const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = t.map((u) => {
517
+ var $, q;
518
+ const f = e(u);
519
+ let p, y, v;
520
+ "spec" in f && typeof f.spec == "object" ? (p = f.spec, y = f.prefixTrace, v = f.suffixTrace) : p = f;
521
+ const m = ($ = p.annotations) == null ? void 0 : $[nt], b = (q = p.annotations) == null ? void 0 : q[rt], g = (b ? st.safeParse(JSON.parse(b)).data : void 0) ?? [], A = [
582
522
  ...y ?? [],
583
- ...x,
584
- ...g ?? []
523
+ ...g,
524
+ ...v ?? []
585
525
  ];
586
- if (v) {
587
- const A = { label: v, type: ze, importance: -2 };
588
- n.addLabelAsSuffix ? C.push(A) : C.splice(0, 0, A);
526
+ if (m) {
527
+ const P = { label: m, type: at, importance: -2 };
528
+ n.addLabelAsSuffix ? A.push(P) : A.splice(0, 0, P);
589
529
  }
590
- const P = [], T = /* @__PURE__ */ new Map();
591
- for (let A = C.length - 1; A >= 0; --A) {
592
- const { type: j } = C[A], V = C[A].importance ?? 0, K = (T.get(j) ?? 0) + 1;
593
- T.set(j, K);
594
- const J = `${j}@${K}`;
595
- i.set(J, (i.get(J) ?? 0) + 1), r.set(
596
- J,
530
+ const x = [], k = /* @__PURE__ */ new Map();
531
+ for (let P = A.length - 1; P >= 0; --P) {
532
+ const { type: R } = A[P], z = A[P].importance ?? 0, J = (k.get(R) ?? 0) + 1;
533
+ k.set(R, J);
534
+ const E = `${R}@${J}`;
535
+ i.set(E, (i.get(E) ?? 0) + 1), r.set(
536
+ E,
597
537
  Math.max(
598
- r.get(J) ?? Number.NEGATIVE_INFINITY,
599
- V - (C.length - A) * qe
538
+ r.get(E) ?? Number.NEGATIVE_INFINITY,
539
+ z - (A.length - P) * ot
600
540
  )
601
- ), P.push({ ...C[A], fullType: J, occurenceIndex: K });
541
+ ), x.push({ ...A[P], fullType: E, occurenceIndex: J });
602
542
  }
603
- return P.reverse(), {
604
- value: f,
605
- spec: d,
606
- label: v,
607
- fullTrace: P
543
+ return x.reverse(), {
544
+ value: u,
545
+ spec: p,
546
+ label: m,
547
+ fullTrace: x
608
548
  };
609
- }), o = [], a = [], c = [...r];
610
- c.sort(([, f], [, p]) => p - f);
611
- for (const [f] of c)
612
- f.endsWith("@1") || i.get(f) === t.length ? o.push(f) : a.push(f);
613
- const l = (f) => s.map((p) => {
614
- const d = p.fullTrace.filter((g) => f.has(g.fullType)).map((g) => g.label), y = n.separator ?? " / ";
549
+ }), o = [], a = [], l = [...r];
550
+ l.sort(([, u], [, f]) => f - u);
551
+ for (const [u] of l)
552
+ u.endsWith("@1") || i.get(u) === t.length ? o.push(u) : a.push(u);
553
+ const c = (u) => s.map((f) => {
554
+ const p = f.fullTrace.filter((v) => u.has(v.fullType)).map((v) => v.label), y = n.separator ?? " / ";
615
555
  return {
616
- label: d.join(y),
617
- value: p.value
556
+ label: p.join(y),
557
+ value: f.value
618
558
  };
619
559
  });
620
560
  if (o.length === 0) {
621
561
  if (a.length !== 0) throw new Error("Assertion error.");
622
- return l(new Set(pe));
623
- }
624
- let m = 0, u = 0;
625
- for (; m < o.length; ) {
626
- const f = /* @__PURE__ */ new Set();
627
- n.includeNativeLabel && f.add(pe);
628
- for (let d = 0; d < m; ++d) f.add(o[d]);
629
- f.add(o[u]);
630
- const p = l(f);
631
- if (new Set(p.map((d) => d.label)).size === t.length) return p;
632
- u++, u == o.length && (m++, u = m);
633
- }
634
- return l(/* @__PURE__ */ new Set([...o, ...a]));
635
- }
636
- const H = "PColumnData/", Q = H + "ResourceMap", Z = H + "Partitioned/ResourceMap", $ = H + "JsonPartitioned", E = H + "BinaryPartitioned", Ae = H + "Partitioned/", ee = Ae + "JsonPartitioned", B = Ae + "BinaryPartitioned";
637
- function Se(t, e, n, r = [], i) {
562
+ return c(new Set(ve));
563
+ }
564
+ let w = 0, d = 0;
565
+ for (; w < o.length; ) {
566
+ const u = /* @__PURE__ */ new Set();
567
+ n.includeNativeLabel && u.add(ve);
568
+ for (let p = 0; p < w; ++p) u.add(o[p]);
569
+ u.add(o[d]);
570
+ const f = c(u);
571
+ if (new Set(f.map((p) => p.label)).size === t.length) return f;
572
+ d++, d == o.length && (w++, d = w);
573
+ }
574
+ return c(/* @__PURE__ */ new Set([...o, ...a]));
575
+ }
576
+ const H = "PColumnData/", ne = H + "ResourceMap", re = H + "Partitioned/ResourceMap", U = H + "JsonPartitioned", V = H + "BinaryPartitioned", Ee = H + "Partitioned/", ie = Ee + "JsonPartitioned", B = Ee + "BinaryPartitioned";
577
+ function De(t, e, n, r = [], i) {
638
578
  if (t === void 0) return !1;
639
579
  switch (t.resourceType.name) {
640
- case Q: {
580
+ case ne: {
641
581
  let s = t.getInputsLocked();
642
582
  for (const o of t.listInputFields()) {
643
- const a = t.resolve({ field: o, assertFieldType: "Input" }), c = [...r, ...JSON.parse(o)], l = a === void 0 ? void 0 : e(a);
644
- l === void 0 && (s = !1), (l !== void 0 || i) && n.push({ key: c, value: l });
583
+ const a = t.resolve({ field: o, assertFieldType: "Input" }), l = [...r, ...JSON.parse(o)], c = a === void 0 ? void 0 : e(a);
584
+ c === void 0 && (s = !1), (c !== void 0 || i) && n.push({ key: l, value: c });
645
585
  }
646
586
  return s;
647
587
  }
648
- case Z: {
588
+ case re: {
649
589
  let s = t.getInputsLocked();
650
590
  for (const o of t.listInputFields()) {
651
591
  const a = t.resolve({ field: o, assertFieldType: "Input" });
652
592
  if (a === void 0) s = !1;
653
593
  else {
654
- const c = [...r, ...JSON.parse(o)], l = Se(
594
+ const l = [...r, ...JSON.parse(o)], c = De(
655
595
  a,
656
596
  e,
657
597
  n,
658
- c,
598
+ l,
659
599
  i
660
600
  );
661
- s = s && l;
601
+ s = s && c;
662
602
  }
663
603
  }
664
604
  return s;
@@ -667,65 +607,87 @@ function Se(t, e, n, r = [], i) {
667
607
  throw new Error(`Unknown resource type: ${t.resourceType.name}`);
668
608
  }
669
609
  }
670
- function Mt(t, e, n = !1) {
610
+ function pn(t, e, n = !1) {
671
611
  const r = [];
672
- return { isComplete: Se(t, e, r, [], n), data: r };
612
+ return { isComplete: De(t, e, r, [], n), data: r };
673
613
  }
674
- const ae = (t) => {
614
+ const fe = (t) => {
675
615
  if (t.endsWith(".index"))
676
616
  return { baseKey: t.substring(0, t.length - 6), type: "index" };
677
617
  if (t.endsWith(".values"))
678
618
  return { baseKey: t.substring(0, t.length - 7), type: "values" };
679
619
  throw new Error(`key must ends on .index/.values for binary p-column, got: ${t}`);
680
620
  };
681
- function Ye(t) {
621
+ function lt(t) {
682
622
  if (!t) return;
683
623
  const e = t.resourceType.name, n = t.getDataAsJson(), r = [];
684
624
  let i = 0;
685
625
  switch (e) {
686
- case Q:
626
+ case ne:
687
627
  i = n.keyLength;
688
628
  break;
689
- case Z:
629
+ case re:
690
630
  i = n.partitionKeyLength + n.keyLength;
691
631
  break;
692
- case $:
693
- case E:
632
+ case U:
633
+ case V:
694
634
  i = n.partitionKeyLength;
695
635
  break;
696
636
  case B:
697
- case ee:
637
+ case ie:
698
638
  i = n.superPartitionKeyLength + n.partitionKeyLength;
699
639
  break;
700
640
  }
701
641
  switch (e) {
702
- case Q:
703
- case $:
704
- case E:
642
+ case ne:
643
+ case U:
644
+ case V:
705
645
  for (let s of t.listInputFields()) {
706
- e === E && (s = ae(s).baseKey);
646
+ e === V && (s = fe(s).baseKey);
707
647
  const o = [...JSON.parse(s)];
708
648
  r.push(o);
709
649
  }
710
650
  break;
711
- case Z:
651
+ case re:
712
652
  case B:
713
- case ee:
653
+ case ie:
714
654
  for (const s of t.listInputFields()) {
715
655
  const o = [...JSON.parse(s)], a = t.resolve({ field: s, assertFieldType: "Input" });
716
656
  if (a !== void 0)
717
- for (let c of a.listInputFields()) {
718
- e === B && (c = ae(c).baseKey);
719
- const l = [...o, ...JSON.parse(c)];
720
- r.push(l);
657
+ for (let l of a.listInputFields()) {
658
+ e === B && (l = fe(l).baseKey);
659
+ const c = [...o, ...JSON.parse(l)];
660
+ r.push(c);
721
661
  }
722
662
  }
723
663
  break;
724
664
  }
725
665
  return { data: r, keyLength: i };
726
666
  }
727
- function Xe(t) {
728
- const e = Ye(t);
667
+ function ut(t) {
668
+ if (t.type !== "JsonPartitioned" && t.type !== "BinaryPartitioned")
669
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${t.type}`);
670
+ const { parts: e, partitionKeyLength: n } = t, r = [];
671
+ for (let i = 0; i < n; ++i)
672
+ r.push(/* @__PURE__ */ new Set());
673
+ for (const i of e) {
674
+ const s = i.key;
675
+ if (s.length !== n)
676
+ throw new Error(
677
+ `Key length (${s.length}) does not match partition length (${n}) for key: ${JSON.stringify(
678
+ s
679
+ )}`
680
+ );
681
+ for (let o = 0; o < n; ++o)
682
+ r[o].add(s[o]);
683
+ }
684
+ return r.map((i) => Array.from(i.values()));
685
+ }
686
+ function ct(t) {
687
+ if (t === void 0) return;
688
+ if (xe(t))
689
+ return ut(t);
690
+ const e = lt(t);
729
691
  if (!e) return;
730
692
  const { data: n, keyLength: r } = e, i = [];
731
693
  for (let s = 0; s < r; ++s)
@@ -738,16 +700,16 @@ function Xe(t) {
738
700
  }
739
701
  return i.map((s) => Array.from(s.values()));
740
702
  }
741
- function le(t, e = []) {
742
- if (t === void 0) return;
703
+ function he(t, e = []) {
704
+ if (t === void 0 || !t.getIsReadyOrError()) return;
743
705
  const n = t.resourceType.name, r = t.getDataAsJson();
744
- if (e.length > 0 && (n === ee || n === B))
706
+ if (e.length > 0 && (n === ie || n === B))
745
707
  throw new Error(`Unexpected nested super-partitioned resource: ${n}`);
746
708
  switch (n) {
747
- case Q:
748
- case Z:
709
+ case ne:
710
+ case re:
749
711
  throw new Error(`Only data columns are supported, got: ${n}`);
750
- case $: {
712
+ case U: {
751
713
  if (typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
752
714
  throw new Error(`Missing partitionKeyLength in metadata for ${n}`);
753
715
  const i = [];
@@ -763,21 +725,21 @@ function le(t, e = []) {
763
725
  parts: i
764
726
  };
765
727
  }
766
- case E: {
728
+ case V: {
767
729
  if (typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
768
730
  throw new Error(`Missing partitionKeyLength in metadata for ${n}`);
769
731
  const i = [], s = /* @__PURE__ */ new Map();
770
732
  for (const o of t.listInputFields()) {
771
- const a = ae(o), c = t.resolve({ field: o, assertFieldType: "Input" });
772
- if (c === void 0) return;
773
- let l = s.get(a.baseKey);
774
- l || (l = {}, s.set(a.baseKey, l)), a.type === "index" ? l.index = c : l.values = c;
733
+ const a = fe(o), l = t.resolve({ field: o, assertFieldType: "Input" });
734
+ if (l === void 0) return;
735
+ let c = s.get(a.baseKey);
736
+ c || (c = {}, s.set(a.baseKey, c)), a.type === "index" ? c.index = l : c.values = l;
775
737
  }
776
738
  for (const [o, a] of s.entries()) {
777
739
  if (!a.index || !a.values) return;
778
- const c = [...e, ...JSON.parse(o)];
740
+ const l = [...e, ...JSON.parse(o)];
779
741
  i.push({
780
- key: c,
742
+ key: l,
781
743
  value: {
782
744
  index: a.index,
783
745
  values: a.values
@@ -790,20 +752,20 @@ function le(t, e = []) {
790
752
  parts: i
791
753
  };
792
754
  }
793
- case ee: {
755
+ case ie: {
794
756
  if (typeof (r == null ? void 0 : r.superPartitionKeyLength) != "number" || typeof (r == null ? void 0 : r.partitionKeyLength) != "number")
795
757
  throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${n}`);
796
758
  const i = r.superPartitionKeyLength + r.partitionKeyLength, s = [];
797
759
  for (const o of t.listInputFields()) {
798
760
  const a = t.resolve({ field: o, assertFieldType: "Input" });
799
761
  if (a === void 0) return;
800
- if (a.resourceType.name !== $)
801
- throw new Error(`Expected ${$} inside ${n}, but got ${a.resourceType.name}`);
802
- const c = le(a, JSON.parse(o));
803
- if (c === void 0) return;
804
- if (c.type !== "JsonPartitioned")
805
- throw new Error(`Unexpected inner result type for ${n}: ${c.type}`);
806
- s.push(...c.parts);
762
+ if (a.resourceType.name !== U)
763
+ throw new Error(`Expected ${U} inside ${n}, but got ${a.resourceType.name}`);
764
+ const l = he(a, JSON.parse(o));
765
+ if (l === void 0) return;
766
+ if (l.type !== "JsonPartitioned")
767
+ throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);
768
+ s.push(...l.parts);
807
769
  }
808
770
  return {
809
771
  type: "JsonPartitioned",
@@ -818,13 +780,13 @@ function le(t, e = []) {
818
780
  for (const o of t.listInputFields()) {
819
781
  const a = t.resolve({ field: o, assertFieldType: "Input" });
820
782
  if (a === void 0) return;
821
- if (a.resourceType.name !== E)
822
- throw new Error(`Expected ${E} inside ${n}, but got ${a.resourceType.name}`);
823
- const c = le(a, JSON.parse(o));
824
- if (c === void 0) return;
825
- if (c.type !== "BinaryPartitioned")
826
- throw new Error(`Unexpected inner result type for ${n}: ${c.type}`);
827
- s.push(...c.parts);
783
+ if (a.resourceType.name !== V)
784
+ throw new Error(`Expected ${V} inside ${n}, but got ${a.resourceType.name}`);
785
+ const l = he(a, JSON.parse(o));
786
+ if (l === void 0) return;
787
+ if (l.type !== "BinaryPartitioned")
788
+ throw new Error(`Unexpected inner result type for ${n}: ${l.type}`);
789
+ s.push(...l.parts);
828
790
  }
829
791
  return {
830
792
  type: "BinaryPartitioned",
@@ -836,32 +798,287 @@ function le(t, e = []) {
836
798
  throw new Error(`Unknown resource type: ${n}`);
837
799
  }
838
800
  }
839
- function re(t, e) {
840
- if (t === void 0) return e === void 0;
841
- if (e === void 0) return !0;
842
- for (const n in e)
843
- if (t[n] !== e[n]) return !1;
844
- return !0;
801
+ function pt(t) {
802
+ if (t !== void 0) {
803
+ if (xe(t)) return t;
804
+ if (me(t)) return Ve(t);
805
+ if (t instanceof I) return he(t);
806
+ throw new Error(`Unexpected input type: ${typeof t}`);
807
+ }
808
+ }
809
+ function dt(t, e) {
810
+ const n = [...e].sort((s, o) => o[0] - s[0]);
811
+ if (t.type === "JsonPartitioned" || t.type === "BinaryPartitioned") {
812
+ const { partitionKeyLength: s } = t;
813
+ for (const [o] of e)
814
+ if (o >= s)
815
+ throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`);
816
+ } else if (t.type === "Json") {
817
+ const { keyLength: s } = t;
818
+ for (const [o] of e)
819
+ if (o >= s)
820
+ throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`);
821
+ }
822
+ const r = (s) => {
823
+ for (const [o, a] of n)
824
+ if (s[o] !== a)
825
+ return !1;
826
+ return !0;
827
+ }, i = (s) => {
828
+ const o = [...s];
829
+ for (const [a] of n)
830
+ o.splice(a, 1);
831
+ return o;
832
+ };
833
+ switch (t.type) {
834
+ case "Json": {
835
+ const s = t.data.filter((o) => r(o.key)).map((o) => ({
836
+ key: i(o.key),
837
+ value: o.value
838
+ }));
839
+ return {
840
+ type: "Json",
841
+ keyLength: t.keyLength - e.length,
842
+ data: s
843
+ };
844
+ }
845
+ case "JsonPartitioned": {
846
+ const s = t.parts.filter((o) => r(o.key)).map((o) => ({
847
+ key: i(o.key),
848
+ value: o.value
849
+ }));
850
+ return {
851
+ type: "JsonPartitioned",
852
+ partitionKeyLength: t.partitionKeyLength - e.length,
853
+ parts: s
854
+ };
855
+ }
856
+ case "BinaryPartitioned": {
857
+ const s = t.parts.filter((o) => r(o.key)).map((o) => ({
858
+ key: i(o.key),
859
+ value: o.value
860
+ }));
861
+ return {
862
+ type: "BinaryPartitioned",
863
+ partitionKeyLength: t.partitionKeyLength - e.length,
864
+ parts: s
865
+ };
866
+ }
867
+ }
845
868
  }
846
- function fe(t) {
847
- return ue(t, (e) => e instanceof I ? e.handle : me(e) ? Oe(e, (n) => n.handle) : e);
869
+ class ft {
870
+ constructor(e) {
871
+ this.columns = e;
872
+ }
873
+ selectColumns(e) {
874
+ const n = typeof e == "function" ? e : ce(e);
875
+ return this.columns.filter((r) => n(r.spec));
876
+ }
848
877
  }
849
- function Qe(t) {
878
+ function ht(t) {
850
879
  if (t)
851
880
  return t.map((e) => ({
852
- type: `split:${Ee(e.axisId)}`,
881
+ type: `split:${Ue(e.axisId)}`,
853
882
  label: e.label,
854
883
  importance: 1e6
855
884
  // High importance for split filters in labels
856
885
  }));
857
886
  }
858
- function Ze(t) {
887
+ function gt(t) {
859
888
  if (t)
860
889
  return t.map((e) => [e.axisIdx, e.value]);
861
890
  }
862
- class et {
891
+ function mt(t, e) {
892
+ if (!e || e.length === 0) return t;
893
+ const n = [...e].sort((r, i) => r[0] - i[0]);
894
+ return Pe({ id: t, axisFilters: n });
895
+ }
896
+ function yt(t) {
897
+ if (!t || typeof t != "object") return !1;
898
+ const e = t, n = e.domain && typeof e.domain == "object" && Object.values(e.domain).some((i) => typeof i == "object" && i !== null && "anchor" in i), r = e.axes && Array.isArray(e.axes) && e.axes.some((i) => typeof i == "object" && i !== null && "anchor" in i);
899
+ return !!e.domainAnchor || n || r;
900
+ }
901
+ function vt(t) {
902
+ if (typeof t != "object" || !("axes" in t) || t.axes === void 0)
903
+ return [];
904
+ const e = t.axes.map((n, r) => typeof n == "object" && "split" in n && n.split === !0 ? r : -1).filter((n) => n !== -1);
905
+ if (e.length > 0 && t.partialAxesMatch !== void 0)
906
+ throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");
907
+ return e.sort((n, r) => n - r), e;
908
+ }
909
+ class be {
863
910
  constructor() {
864
- F(this, "ctx", h());
911
+ L(this, "defaultProviderStore", []);
912
+ L(this, "providers", [new ft(this.defaultProviderStore)]);
913
+ L(this, "axisLabelProviders", []);
914
+ }
915
+ addColumnProvider(e) {
916
+ return this.providers.push(e), this;
917
+ }
918
+ addAxisLabelProvider(e) {
919
+ return this.axisLabelProviders.push(e), this;
920
+ }
921
+ addColumns(e) {
922
+ return this.defaultProviderStore.push(...e), this;
923
+ }
924
+ addColumn(e) {
925
+ return this.defaultProviderStore.push(e), this;
926
+ }
927
+ /** Fetches labels for a given axis from the registered providers */
928
+ findLabels(e) {
929
+ for (const n of this.axisLabelProviders) {
930
+ const r = n.findLabels(e);
931
+ if (r) return r;
932
+ }
933
+ }
934
+ getUniversalEntries(e, n) {
935
+ const { anchorCtx: r, labelOps: i, dontWaitAllData: s = !1, overrideLabelAnnotation: o = !1 } = n ?? {}, a = {
936
+ ...o && (i == null ? void 0 : i.includeNativeLabel) !== !1 ? { includeNativeLabel: !0 } : {},
937
+ ...i ?? {}
938
+ }, l = typeof e == "function" ? [e] : Array.isArray(e) ? e : [e], c = [];
939
+ for (const u of l) {
940
+ const f = yt(u);
941
+ let p;
942
+ if (f) {
943
+ if (!r)
944
+ throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");
945
+ p = $e(r.anchors, u);
946
+ } else
947
+ p = u;
948
+ const y = /* @__PURE__ */ new Set(), v = [];
949
+ for (const g of this.providers) {
950
+ const A = g.selectColumns(p);
951
+ for (const x of A) {
952
+ if (y.has(x.id)) throw new Error(`Duplicate column id ${x.id} in provider ${g.constructor.name}`);
953
+ y.add(x.id), v.push(x);
954
+ }
955
+ }
956
+ if (v.length === 0) continue;
957
+ const m = vt(u), b = m.length > 0;
958
+ for (const g of v) {
959
+ if (!Z(g.spec)) continue;
960
+ const A = g.spec;
961
+ if (b) {
962
+ const x = pt(g.data);
963
+ if (!x) {
964
+ if (s) continue;
965
+ return;
966
+ }
967
+ if (!Je(x))
968
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${x.type} for column ${g.id}`);
969
+ const k = ct(x), $ = m[m.length - 1];
970
+ if ($ >= x.partitionKeyLength)
971
+ throw new Error(`Not enough partition keys (${x.partitionKeyLength}) for requested split axes (max index ${$}) in column ${A.name}`);
972
+ const q = m.map((C) => this.findLabels(F(A.axesSpec[C]))), P = [], R = (C, N) => {
973
+ if (N >= m.length) {
974
+ P.push([...C]);
975
+ return;
976
+ }
977
+ const D = m[N];
978
+ if (D >= k.length)
979
+ throw new Error(`Axis index ${D} out of bounds for unique keys array (length ${k.length}) during split key generation for column ${g.id}`);
980
+ const O = k[D];
981
+ if (!O || O.length === 0) {
982
+ P.length = 0;
983
+ return;
984
+ }
985
+ for (const Y of O)
986
+ C.push(Y), R(C, N + 1), C.pop();
987
+ };
988
+ if (R([], 0), P.length === 0)
989
+ continue;
990
+ const z = [...A.axesSpec], J = m.map((C) => C);
991
+ for (let C = m.length - 1; C >= 0; C--)
992
+ z.splice(m[C], 1);
993
+ const E = { ...A, axesSpec: z };
994
+ for (const C of P) {
995
+ const N = C.map((D, O) => {
996
+ const Y = J[O], Re = F(A.axesSpec[Y]), oe = q[O], Oe = (oe == null ? void 0 : oe[D]) ?? String(D);
997
+ return { axisIdx: Y, axisId: Re, value: D, label: Oe };
998
+ });
999
+ c.push({
1000
+ type: "split",
1001
+ originalColumn: g,
1002
+ spec: A,
1003
+ adjustedSpec: E,
1004
+ dataEntries: x,
1005
+ axisFilters: N
1006
+ });
1007
+ }
1008
+ } else
1009
+ c.push({
1010
+ type: "direct",
1011
+ originalColumn: g,
1012
+ spec: A,
1013
+ adjustedSpec: A
1014
+ });
1015
+ }
1016
+ }
1017
+ if (c.length === 0) return [];
1018
+ const w = Fe(
1019
+ c,
1020
+ (u) => ({
1021
+ spec: u.spec,
1022
+ suffixTrace: u.type === "split" ? ht(u.axisFilters) : void 0
1023
+ }),
1024
+ a
1025
+ ), d = [];
1026
+ for (const { value: u, label: f } of w) {
1027
+ const { originalColumn: p, spec: y } = u, v = u.type === "split" ? u.axisFilters : void 0, m = gt(v);
1028
+ let b;
1029
+ r ? b = r.deriveS(y, m) : b = mt(p.id, m);
1030
+ let g = { ...u.adjustedSpec };
1031
+ o && (g = {
1032
+ ...g,
1033
+ annotations: {
1034
+ ...g.annotations ?? {},
1035
+ "pl7.app/label": f
1036
+ }
1037
+ }), d.push({
1038
+ id: b,
1039
+ spec: g,
1040
+ data: () => u.type === "split" ? Ne(dt(u.dataEntries, m)) : u.originalColumn.data,
1041
+ label: f
1042
+ });
1043
+ }
1044
+ return d;
1045
+ }
1046
+ getColumns(e, n) {
1047
+ const r = this.getUniversalEntries(e, {
1048
+ overrideLabelAnnotation: !0,
1049
+ // default for getColumns
1050
+ ...n ?? {}
1051
+ });
1052
+ if (!r) return;
1053
+ const i = [];
1054
+ for (const s of r) {
1055
+ const o = s.data();
1056
+ if (!o) {
1057
+ if (n != null && n.dontWaitAllData) continue;
1058
+ return;
1059
+ }
1060
+ i.push({
1061
+ id: s.id,
1062
+ spec: s.spec,
1063
+ data: o
1064
+ });
1065
+ }
1066
+ return i;
1067
+ }
1068
+ }
1069
+ function le(t, e) {
1070
+ if (t === void 0) return e === void 0;
1071
+ if (e === void 0) return !0;
1072
+ for (const n in e)
1073
+ if (t[n] !== e[n]) return !1;
1074
+ return !0;
1075
+ }
1076
+ function we(t) {
1077
+ return ge(t, (e) => e instanceof I ? e.handle : me(e) ? qe(e, (n) => n.handle) : e);
1078
+ }
1079
+ class bt {
1080
+ constructor() {
1081
+ L(this, "ctx", h());
865
1082
  }
866
1083
  /**
867
1084
  * @deprecated use getOptions()
@@ -871,7 +1088,7 @@ class et {
871
1088
  }
872
1089
  getOptions(e, n) {
873
1090
  const r = typeof e == "function" ? e : ce(e), i = this.getSpecs().entries.filter((s) => r(s.obj));
874
- return typeof n == "object" || typeof n > "u" ? de(i, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: o }) => ({
1091
+ return typeof n == "object" || typeof n > "u" ? Fe(i, (s) => s.obj, n ?? {}).map(({ value: { ref: s }, label: o }) => ({
875
1092
  ref: s,
876
1093
  label: o
877
1094
  })) : i.map((s) => ({
@@ -879,93 +1096,18 @@ class et {
879
1096
  label: n(s.obj, s.ref)
880
1097
  }));
881
1098
  }
882
- /**
883
- * Internal implementation that generates UniversalPColumnEntry objects from the provided
884
- * anchors and selectors.
885
- */
886
- getUniversalPColumnEntries(e, n, r) {
887
- const i = {};
888
- if (!(e instanceof te))
889
- for (const [l, m] of Object.entries(e))
890
- if (Ce(m)) {
891
- const u = this.getPColumnSpecByRef(m);
892
- if (!u)
893
- return;
894
- i[l] = u;
895
- } else
896
- i[l] = m;
897
- const s = typeof n == "function" ? [n] : Array.isArray(n) ? n : [n], o = e instanceof te ? e : new te(i), a = [];
898
- for (const l of s) {
899
- const m = typeof l == "function" ? l : ce(Le(i, l)), u = this.getSpecs().entries.filter(({ obj: p }) => N(p) ? m(p) : !1);
900
- if (u.length === 0)
901
- continue;
902
- const f = typeof l == "object" && "axes" in l && l.axes !== void 0 && l.partialAxesMatch === void 0 ? l.axes.map((p, d) => "split" in p && p.split === !0 ? d : -1).filter((p) => p !== -1) : [];
903
- if (f.sort((p, d) => p - d), f.length > 0) {
904
- const p = f[f.length - 1];
905
- for (const { ref: d, obj: y } of u) {
906
- if (!N(y)) throw new Error(`Assertion failed: expected PColumnSpec, got ${y.kind}`);
907
- const g = this.getDataByRef(d);
908
- if (!g) {
909
- if (r != null && r.dontWaitAllData) continue;
910
- return;
911
- }
912
- if (!M(g)) throw new Error(`Assertion failed: expected PColumn, got ${g.spec.kind}`);
913
- const v = Xe(g.data);
914
- if (!v) {
915
- if (r != null && r.dontWaitAllData) continue;
916
- return;
917
- }
918
- if (p >= v.length)
919
- throw new Error(`Not enough partition keys for the requested split axes in column ${y.name}`);
920
- const w = f.map((P) => this.findLabels(L(y.axesSpec[P]))), x = [], C = (P, T) => {
921
- if (T >= f.length) {
922
- x.push([...P]);
923
- return;
924
- }
925
- const R = f[T], k = v[R];
926
- for (const A of k)
927
- P.push(A), C(P, T + 1), P.pop();
928
- };
929
- C([], 0);
930
- for (const P of x) {
931
- const T = P.map((R, k) => {
932
- const A = f[k], j = L(y.axesSpec[A]), V = w[k], K = (V == null ? void 0 : V[R]) ?? String(R);
933
- return { axisIdx: A, axisId: j, value: R, label: K };
934
- });
935
- a.push({
936
- obj: y,
937
- ref: d,
938
- axisFilters: T
939
- });
940
- }
941
- }
1099
+ resolveAnchorCtx(e) {
1100
+ if (e instanceof ye) return e;
1101
+ const n = {};
1102
+ for (const [r, i] of Object.entries(e))
1103
+ if (Be(i)) {
1104
+ const s = this.getPColumnSpecByRef(i);
1105
+ if (!s)
1106
+ return;
1107
+ n[r] = s;
942
1108
  } else
943
- for (const { ref: p, obj: d } of u)
944
- N(d) && a.push({
945
- obj: d,
946
- ref: p
947
- // No splitFilters needed here
948
- });
949
- }
950
- return a.length === 0 ? [] : de(
951
- a,
952
- (l) => ({
953
- spec: l.obj,
954
- suffixTrace: Qe(l.axisFilters)
955
- // Use helper function
956
- }),
957
- (r == null ? void 0 : r.labelOps) ?? {}
958
- ).map((l) => ({
959
- id: o.deriveS(
960
- l.value.obj,
961
- Ze(l.value.axisFilters)
962
- // Use helper function
963
- ),
964
- obj: l.value.obj,
965
- ref: l.value.ref,
966
- axisFilters: l.value.axisFilters,
967
- label: l.label
968
- }));
1109
+ n[r] = i;
1110
+ return new ye(n);
969
1111
  }
970
1112
  /**
971
1113
  * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
@@ -976,55 +1118,12 @@ class et {
976
1118
  * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
977
1119
  */
978
1120
  getAnchoredPColumns(e, n, r) {
979
- const i = {
980
- ...r,
981
- labelOps: {
982
- includeNativeLabel: !0,
983
- ...(r == null ? void 0 : r.labelOps) || {}
984
- }
985
- }, s = this.getUniversalPColumnEntries(
986
- e,
987
- n,
988
- i
989
- );
990
- if (!s || s.length === 0) return;
991
- const o = [];
992
- for (const a of s) {
993
- const c = this.getPColumnByRef(a.ref);
994
- if (!c) return;
995
- const l = le(c.data);
996
- if (!l) return;
997
- let m = l, u = { ...c.spec };
998
- if (a.axisFilters && a.axisFilters.length > 0) {
999
- const p = a.axisFilters.map((g) => [
1000
- g.axisIdx,
1001
- g.value
1002
- ]);
1003
- m = Ue(l, p);
1004
- const d = [...a.axisFilters].map((g) => g.axisIdx).sort((g, v) => v - g), y = [...u.axesSpec];
1005
- for (const g of d)
1006
- y.splice(g, 1);
1007
- u = { ...u, axesSpec: y };
1008
- }
1009
- const f = Fe(m);
1010
- u.annotations ? u = {
1011
- ...u,
1012
- annotations: {
1013
- ...u.annotations,
1014
- "pl7.app/label": a.label
1015
- }
1016
- } : u = {
1017
- ...u,
1018
- annotations: {
1019
- "pl7.app/label": a.label
1020
- }
1021
- }, o.push({
1022
- id: a.id,
1023
- spec: u,
1024
- data: f
1121
+ const i = this.resolveAnchorCtx(e);
1122
+ if (i)
1123
+ return new be().addColumnProvider(this).addAxisLabelProvider(this).getColumns(n, {
1124
+ ...r,
1125
+ anchorCtx: i
1025
1126
  });
1026
- }
1027
- return o;
1028
1127
  }
1029
1128
  /**
1030
1129
  * Calculates anchored identifier options for columns matching a given predicate and returns their
@@ -1056,11 +1155,16 @@ class et {
1056
1155
  * or undefined if any PlRef resolution fails.
1057
1156
  */
1058
1157
  getCanonicalOptions(e, n, r) {
1059
- const i = this.getUniversalPColumnEntries(e, n, r);
1060
- if (i)
1061
- return i.map((s) => ({
1062
- value: s.id,
1063
- label: s.label
1158
+ const i = this.resolveAnchorCtx(e);
1159
+ if (!i) return;
1160
+ const s = new be().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(n, {
1161
+ ...r,
1162
+ anchorCtx: i
1163
+ });
1164
+ if (s)
1165
+ return s.map((o) => ({
1166
+ value: o.id,
1167
+ label: o.label
1064
1168
  }));
1065
1169
  }
1066
1170
  /**
@@ -1096,7 +1200,7 @@ class et {
1096
1200
  ref: n.ref,
1097
1201
  obj: {
1098
1202
  ...n.obj,
1099
- data: Te(
1203
+ data: Me(
1100
1204
  n.obj.data,
1101
1205
  (r) => new I(r, [n.ref.blockId, n.ref.name])
1102
1206
  )
@@ -1125,7 +1229,7 @@ class et {
1125
1229
  )) == null ? void 0 : r.obj;
1126
1230
  const n = this.ctx.getDataFromResultPoolByRef(e.blockId, e.name);
1127
1231
  if (n)
1128
- return ue(
1232
+ return ge(
1129
1233
  n,
1130
1234
  (i) => new I(i, [e.blockId, e.name])
1131
1235
  );
@@ -1138,7 +1242,7 @@ class et {
1138
1242
  getPColumnByRef(e) {
1139
1243
  const n = this.getDataByRef(e);
1140
1244
  if (n)
1141
- return Re(n);
1245
+ return Ge(n);
1142
1246
  }
1143
1247
  /**
1144
1248
  * Returns spec associated with the ref ensuring that it is a p-column spec.
@@ -1148,7 +1252,7 @@ class et {
1148
1252
  getPColumnSpecByRef(e) {
1149
1253
  const n = this.getSpecByRef(e);
1150
1254
  if (n) {
1151
- if (!N(n)) throw new Error(`not a PColumn spec (kind = ${n.kind})`);
1255
+ if (!Z(n)) throw new Error(`not a PColumn spec (kind = ${n.kind})`);
1152
1256
  return n;
1153
1257
  }
1154
1258
  }
@@ -1167,13 +1271,13 @@ class et {
1167
1271
  findDataWithCompatibleSpec(e) {
1168
1272
  const n = [];
1169
1273
  e: for (const r of this.getData().entries) {
1170
- if (!N(r.obj.spec))
1274
+ if (!Z(r.obj.spec))
1171
1275
  continue;
1172
1276
  const i = r.obj.spec;
1173
- if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && re(e.domain, i.domain)) {
1277
+ if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && le(e.domain, i.domain)) {
1174
1278
  for (let s = 0; s < e.axesSpec.length; ++s) {
1175
1279
  const o = e.axesSpec[s], a = i.axesSpec[s];
1176
- if (o.name !== a.name || o.type !== a.type || !re(o.domain, a.domain))
1280
+ if (o.name !== a.name || o.type !== a.type || !le(o.domain, a.domain))
1177
1281
  continue e;
1178
1282
  }
1179
1283
  n.push(r.obj);
@@ -1188,9 +1292,9 @@ class et {
1188
1292
  findLabels(e) {
1189
1293
  const n = this.getData();
1190
1294
  for (const r of n.entries) {
1191
- if (!M(r.obj)) continue;
1295
+ if (!se(r.obj)) continue;
1192
1296
  const i = r.obj.spec;
1193
- if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && re(e.domain, i.axesSpec[0].domain)) {
1297
+ if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && le(e.domain, i.axesSpec[0].domain)) {
1194
1298
  if (r.obj.data.resourceType.name !== "PColumnData/Json")
1195
1299
  throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);
1196
1300
  return Object.fromEntries(
@@ -1201,6 +1305,29 @@ class et {
1201
1305
  }
1202
1306
  }
1203
1307
  }
1308
+ /**
1309
+ * Selects columns based on the provided selectors, returning PColumn objects
1310
+ * with lazily loaded data.
1311
+ *
1312
+ * @param selectors - A predicate function, a single selector, or an array of selectors.
1313
+ * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
1314
+ */
1315
+ selectColumns(e) {
1316
+ const n = typeof e == "function" ? e : ce(e);
1317
+ return this.getSpecs().entries.filter(({ obj: i }) => Z(i) ? n(i) : !1).map(({ ref: i, obj: s }) => {
1318
+ const o = s;
1319
+ let a = null;
1320
+ const l = this;
1321
+ return {
1322
+ id: Pe(i),
1323
+ spec: o,
1324
+ get data() {
1325
+ var c;
1326
+ return a !== null || (a = (c = l.getPColumnByRef(i)) == null ? void 0 : c.data), a;
1327
+ }
1328
+ };
1329
+ });
1330
+ }
1204
1331
  /**
1205
1332
  * Find labels data for a given axis id of a p-column.
1206
1333
  * @returns a map of axis value => label
@@ -1214,14 +1341,14 @@ class et {
1214
1341
  }));
1215
1342
  }
1216
1343
  }
1217
- class z {
1344
+ class Q {
1218
1345
  constructor() {
1219
- F(this, "ctx");
1220
- F(this, "args");
1221
- F(this, "uiState");
1346
+ L(this, "ctx");
1347
+ L(this, "args");
1348
+ L(this, "uiState");
1222
1349
  // lazy rendering because this feature is rarely used
1223
- F(this, "_activeArgsCache");
1224
- F(this, "resultPool", new et());
1350
+ L(this, "_activeArgsCache");
1351
+ L(this, "resultPool", new bt());
1225
1352
  this.ctx = h(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : {};
1226
1353
  }
1227
1354
  /**
@@ -1238,16 +1365,16 @@ class z {
1238
1365
  // return this.ctx.featureFlags;
1239
1366
  // }
1240
1367
  getNamedAccessor(e) {
1241
- return ie(
1368
+ return pe(
1242
1369
  this.ctx.getAccessorHandleByName(e),
1243
1370
  (n) => new I(n, [e])
1244
1371
  );
1245
1372
  }
1246
1373
  get prerun() {
1247
- return this.getNamedAccessor(ve);
1374
+ return this.getNamedAccessor(Ie);
1248
1375
  }
1249
1376
  get outputs() {
1250
- return this.getNamedAccessor(we);
1377
+ return this.getNamedAccessor(Le);
1251
1378
  }
1252
1379
  /**
1253
1380
  * Find labels data for a given axis id. It will search for a label column and return its data as a map.
@@ -1262,9 +1389,10 @@ class z {
1262
1389
  const n = e.some((s) => !(s.data instanceof I) || me(s.data)), r = ((i = this.ctx.featureFlags) == null ? void 0 : i.inlineColumnsSupport) === !0;
1263
1390
  if (n && !r) throw Error("Inline or explicit columns not supported");
1264
1391
  }
1392
+ // TODO remove all non-PColumn fields
1265
1393
  createPFrame(e) {
1266
1394
  return this.verifyInlineAndExplicitColumnsSupport(e), this.ctx.createPFrame(
1267
- e.map((n) => fe(n))
1395
+ e.map((n) => we(n))
1268
1396
  );
1269
1397
  }
1270
1398
  createPTable(e) {
@@ -1276,8 +1404,8 @@ class z {
1276
1404
  },
1277
1405
  filters: e.filters ?? [],
1278
1406
  sorting: e.sorting ?? []
1279
- } : n = e, this.verifyInlineAndExplicitColumnsSupport(ke(n.src)), this.ctx.createPTable(
1280
- De(n, (r) => fe(r))
1407
+ } : n = e, this.verifyInlineAndExplicitColumnsSupport(We(n.src)), this.ctx.createPTable(
1408
+ He(n, (r) => we(r))
1281
1409
  );
1282
1410
  }
1283
1411
  /** @deprecated scheduled for removal from SDK */
@@ -1289,19 +1417,19 @@ class z {
1289
1417
  return this.ctx.getCurrentUnstableMarker();
1290
1418
  }
1291
1419
  }
1292
- const U = "1.27.17";
1293
- function tt(t) {
1420
+ const M = "1.28.0";
1421
+ function wt(t) {
1294
1422
  return t.__renderLambda === !0;
1295
1423
  }
1296
- function se(t) {
1424
+ function ue(t) {
1297
1425
  if (t !== void 0)
1298
- return tt(t) ? t.handle : t;
1426
+ return wt(t) ? t.handle : t;
1299
1427
  }
1300
- function D(t) {
1428
+ function j(t) {
1301
1429
  if (t !== void 0)
1302
1430
  return typeof t == "string" ? { __renderLambda: !0, handle: t, retentive: !1 } : t;
1303
1431
  }
1304
- function Gt(t) {
1432
+ function dn(t) {
1305
1433
  if (t.v3 !== void 0) {
1306
1434
  const {
1307
1435
  initialArgs: e,
@@ -1311,8 +1439,8 @@ function Gt(t) {
1311
1439
  renderingMode: s,
1312
1440
  sdkVersion: o,
1313
1441
  sections: a,
1314
- title: c
1315
- } = t.v3, { code: l } = t;
1442
+ title: l
1443
+ } = t.v3, { code: c } = t;
1316
1444
  return {
1317
1445
  initialArgs: e,
1318
1446
  initialUiState: n,
@@ -1321,42 +1449,42 @@ function Gt(t) {
1321
1449
  renderingMode: s,
1322
1450
  sdkVersion: o,
1323
1451
  sections: a,
1324
- title: c,
1325
- code: l
1452
+ title: l,
1453
+ code: c
1326
1454
  };
1327
1455
  } else if (t.inputsValid !== void 0) {
1328
- const { sdkVersion: e, renderingMode: n, outputs: r, inputsValid: i, sections: s, initialArgs: o, code: a } = t, c = Object.keys(t);
1456
+ const { sdkVersion: e, renderingMode: n, outputs: r, inputsValid: i, sections: s, initialArgs: o, code: a } = t, l = Object.keys(t);
1329
1457
  if (e === void 0 || n === void 0 || r === void 0 || i === void 0 || s === void 0 || o === void 0)
1330
1458
  throw new Error(
1331
- `Malformed config v2. SDK version ${e}; Fields = ${c.join(", ")}`
1459
+ `Malformed config v2. SDK version ${e}; Fields = ${l.join(", ")}`
1332
1460
  );
1333
1461
  return {
1334
1462
  sdkVersion: e,
1335
1463
  renderingMode: n,
1336
1464
  initialArgs: o,
1337
1465
  outputs: Object.fromEntries(
1338
- Object.entries(r).map(([l, m]) => [l, D(m)])
1466
+ Object.entries(r).map(([c, w]) => [c, j(w)])
1339
1467
  ),
1340
- inputsValid: D(i),
1341
- sections: D(s),
1468
+ inputsValid: j(i),
1469
+ sections: j(s),
1342
1470
  initialUiState: void 0,
1343
1471
  code: a
1344
1472
  };
1345
1473
  } else if (t.renderingMode !== void 0) {
1346
- const { sdkVersion: e, canRun: n, renderingMode: r, outputs: i, sections: s, initialArgs: o, code: a } = t, c = Object.keys(t);
1474
+ const { sdkVersion: e, canRun: n, renderingMode: r, outputs: i, sections: s, initialArgs: o, code: a } = t, l = Object.keys(t);
1347
1475
  if (r === void 0 || i === void 0 || n === void 0 || s === void 0 || o === void 0)
1348
1476
  throw new Error(
1349
- `Malformed config v1. SDK version ${e}; Fields = ${c.join(", ")}`
1477
+ `Malformed config v1. SDK version ${e}; Fields = ${l.join(", ")}`
1350
1478
  );
1351
1479
  return {
1352
1480
  sdkVersion: e ?? "unknown",
1353
1481
  renderingMode: r,
1354
1482
  initialArgs: o,
1355
1483
  outputs: Object.fromEntries(
1356
- Object.entries(i).map(([l, m]) => [l, D(m)])
1484
+ Object.entries(i).map(([c, w]) => [c, j(w)])
1357
1485
  ),
1358
- inputsValid: D(n),
1359
- sections: D(s),
1486
+ inputsValid: j(n),
1487
+ sections: j(s),
1360
1488
  initialUiState: void 0,
1361
1489
  code: a
1362
1490
  };
@@ -1367,25 +1495,25 @@ function Gt(t) {
1367
1495
  );
1368
1496
  }
1369
1497
  }
1370
- class _ {
1498
+ class T {
1371
1499
  constructor(e, n, r, i, s, o, a) {
1372
1500
  this._renderingMode = e, this._initialArgs = n, this._initialUiState = r, this._outputs = i, this._inputsValid = s, this._sections = o, this._title = a;
1373
1501
  }
1374
1502
  static create(e = "Heavy") {
1375
- return new _(
1503
+ return new T(
1376
1504
  e,
1377
1505
  void 0,
1378
1506
  {},
1379
1507
  {},
1380
- Y(!0),
1381
- Y([]),
1508
+ ee(!0),
1509
+ ee([]),
1382
1510
  void 0
1383
1511
  );
1384
1512
  }
1385
1513
  output(e, n, r = {}) {
1386
1514
  if (typeof n == "function") {
1387
1515
  const i = `output#${e}`;
1388
- return q(i, () => n(new z())), new _(
1516
+ return X(i, () => n(new Q())), new T(
1389
1517
  this._renderingMode,
1390
1518
  this._initialArgs,
1391
1519
  this._initialUiState,
@@ -1402,7 +1530,7 @@ class _ {
1402
1530
  this._title
1403
1531
  );
1404
1532
  } else
1405
- return new _(
1533
+ return new T(
1406
1534
  this._renderingMode,
1407
1535
  this._initialArgs,
1408
1536
  this._initialUiState,
@@ -1420,7 +1548,7 @@ class _ {
1420
1548
  return this.output(e, n, { retentive: !0 });
1421
1549
  }
1422
1550
  argsValid(e) {
1423
- return typeof e == "function" ? (q("inputsValid", () => e(new z())), new _(
1551
+ return typeof e == "function" ? (X("inputsValid", () => e(new Q())), new T(
1424
1552
  this._renderingMode,
1425
1553
  this._initialArgs,
1426
1554
  this._initialUiState,
@@ -1431,7 +1559,7 @@ class _ {
1431
1559
  },
1432
1560
  this._sections,
1433
1561
  this._title
1434
- )) : new _(
1562
+ )) : new T(
1435
1563
  this._renderingMode,
1436
1564
  this._initialArgs,
1437
1565
  this._initialUiState,
@@ -1442,7 +1570,7 @@ class _ {
1442
1570
  );
1443
1571
  }
1444
1572
  sections(e) {
1445
- return Array.isArray(e) ? this.sections(Y(e)) : typeof e == "function" ? (q("sections", () => e(new z())), new _(
1573
+ return Array.isArray(e) ? this.sections(ee(e)) : typeof e == "function" ? (X("sections", () => e(new Q())), new T(
1446
1574
  this._renderingMode,
1447
1575
  this._initialArgs,
1448
1576
  this._initialUiState,
@@ -1450,7 +1578,7 @@ class _ {
1450
1578
  this._inputsValid,
1451
1579
  { __renderLambda: !0, handle: "sections" },
1452
1580
  this._title
1453
- )) : new _(
1581
+ )) : new T(
1454
1582
  this._renderingMode,
1455
1583
  this._initialArgs,
1456
1584
  this._initialUiState,
@@ -1462,7 +1590,7 @@ class _ {
1462
1590
  }
1463
1591
  /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
1464
1592
  title(e) {
1465
- return q("title", () => e(new z())), new _(
1593
+ return X("title", () => e(new Q())), new T(
1466
1594
  this._renderingMode,
1467
1595
  this._initialArgs,
1468
1596
  this._initialUiState,
@@ -1477,7 +1605,7 @@ class _ {
1477
1605
  * @deprecated use {@link withArgs}
1478
1606
  * */
1479
1607
  initialArgs(e) {
1480
- return new _(
1608
+ return new T(
1481
1609
  this._renderingMode,
1482
1610
  e,
1483
1611
  this._initialUiState,
@@ -1489,7 +1617,7 @@ class _ {
1489
1617
  }
1490
1618
  /** Sets initial args for the block, this value must be specified. */
1491
1619
  withArgs(e) {
1492
- return new _(
1620
+ return new T(
1493
1621
  this._renderingMode,
1494
1622
  e,
1495
1623
  this._initialUiState,
@@ -1501,7 +1629,7 @@ class _ {
1501
1629
  }
1502
1630
  /** Defines type and sets initial value for block UiState. */
1503
1631
  withUiState(e) {
1504
- return new _(
1632
+ return new T(
1505
1633
  this._renderingMode,
1506
1634
  this._initialArgs,
1507
1635
  e,
@@ -1518,7 +1646,7 @@ class _ {
1518
1646
  if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
1519
1647
  const e = {
1520
1648
  v3: {
1521
- sdkVersion: U,
1649
+ sdkVersion: M,
1522
1650
  renderingMode: this._renderingMode,
1523
1651
  initialArgs: this._initialArgs,
1524
1652
  initialUiState: this._initialUiState,
@@ -1528,75 +1656,75 @@ class _ {
1528
1656
  outputs: this._outputs
1529
1657
  },
1530
1658
  // fields below are added to allow previous desktop versions read generated configs
1531
- sdkVersion: U,
1659
+ sdkVersion: M,
1532
1660
  renderingMode: this._renderingMode,
1533
1661
  initialArgs: this._initialArgs,
1534
- inputsValid: se(this._inputsValid),
1535
- sections: se(this._sections),
1662
+ inputsValid: ue(this._inputsValid),
1663
+ sections: ue(this._sections),
1536
1664
  outputs: Object.fromEntries(
1537
- Object.entries(this._outputs).map(([n, r]) => [n, se(r)])
1665
+ Object.entries(this._outputs).map(([n, r]) => [n, ue(r)])
1538
1666
  )
1539
1667
  };
1540
- return Ke() ? be({ sdkVersion: U }) : { config: e };
1668
+ return Xe() ? _e({ sdkVersion: M }) : { config: e };
1541
1669
  }
1542
1670
  }
1543
- function Wt(t, e, n, r) {
1544
- var l, m;
1671
+ function fn(t, e, n, r) {
1672
+ var c, w;
1545
1673
  Array.isArray(r) && (r = { filters: r });
1546
- const i = t.resultPool.getData().entries.map((u) => u.obj).filter(M).filter((u) => u.spec.name === "pl7.app/label" && u.spec.axesSpec.length === 1), s = (u, f) => {
1547
- let p = u.toString();
1548
- if (f)
1549
- for (const d in f)
1550
- p += d, p += f[d];
1551
- return p;
1674
+ const i = t.resultPool.getData().entries.map((d) => d.obj).filter(se).filter((d) => d.spec.name === "pl7.app/label" && d.spec.axesSpec.length === 1), s = (d, u) => {
1675
+ let f = d.toString();
1676
+ if (u)
1677
+ for (const p in u)
1678
+ f += p, f += u[p];
1679
+ return f;
1552
1680
  }, o = /* @__PURE__ */ new Map();
1553
- for (const u of e)
1554
- for (const f of u.spec.axesSpec) {
1555
- const p = L(f);
1556
- for (const d of i) {
1557
- const y = d.spec.axesSpec[0], g = L(d.spec.axesSpec[0]);
1558
- if (G(p, g)) {
1559
- const v = Object.keys(p.domain ?? {}).length, w = Object.keys(g.domain ?? {}).length;
1560
- if (v > w) {
1561
- const x = s(d.id, p.domain);
1562
- o.set(x, {
1563
- id: x,
1681
+ for (const d of e)
1682
+ for (const u of d.spec.axesSpec) {
1683
+ const f = F(u);
1684
+ for (const p of i) {
1685
+ const y = p.spec.axesSpec[0], v = F(p.spec.axesSpec[0]);
1686
+ if (G(f, v)) {
1687
+ const m = Object.keys(f.domain ?? {}).length, b = Object.keys(v.domain ?? {}).length;
1688
+ if (m > b) {
1689
+ const g = s(p.id, f.domain);
1690
+ o.set(g, {
1691
+ id: g,
1564
1692
  spec: {
1565
- ...d.spec,
1566
- axesSpec: [{ ...p, annotations: y.annotations }]
1693
+ ...p.spec,
1694
+ axesSpec: [{ ...f, annotations: y.annotations }]
1567
1695
  },
1568
- data: d.data
1696
+ data: p.data
1569
1697
  });
1570
1698
  } else
1571
- o.set(s(d.id), d);
1699
+ o.set(s(p.id), p);
1572
1700
  }
1573
1701
  }
1574
1702
  }
1575
1703
  if ([...e, ...o.values()].some(
1576
- (u) => u.data instanceof I && !u.data.getIsReadyOrError()
1704
+ (d) => d.data instanceof I && !d.data.getIsReadyOrError()
1577
1705
  ))
1578
1706
  return;
1579
1707
  let a = e;
1580
- const c = [];
1708
+ const l = [];
1581
1709
  if (r != null && r.coreColumnPredicate) {
1582
1710
  a = [];
1583
- for (const u of e)
1584
- r.coreColumnPredicate(u.spec) ? a.push(u) : c.push(u);
1711
+ for (const d of e)
1712
+ r.coreColumnPredicate(d.spec) ? a.push(d) : l.push(d);
1585
1713
  }
1586
- return c.push(...o.values()), t.createPTable({
1714
+ return l.push(...o.values()), t.createPTable({
1587
1715
  src: {
1588
1716
  type: "outer",
1589
1717
  primary: {
1590
1718
  type: (r == null ? void 0 : r.coreJoinType) ?? "full",
1591
- entries: a.map((u) => ({ type: "column", column: u }))
1719
+ entries: a.map((d) => ({ type: "column", column: d }))
1592
1720
  },
1593
- secondary: c.map((u) => ({ type: "column", column: u }))
1721
+ secondary: l.map((d) => ({ type: "column", column: d }))
1594
1722
  },
1595
- filters: [...(r == null ? void 0 : r.filters) ?? [], ...((l = n == null ? void 0 : n.pTableParams) == null ? void 0 : l.filters) ?? []],
1596
- sorting: ((m = n == null ? void 0 : n.pTableParams) == null ? void 0 : m.sorting) ?? []
1723
+ filters: [...(r == null ? void 0 : r.filters) ?? [], ...((c = n == null ? void 0 : n.pTableParams) == null ? void 0 : c.filters) ?? []],
1724
+ sorting: ((w = n == null ? void 0 : n.pTableParams) == null ? void 0 : w.sorting) ?? []
1597
1725
  });
1598
1726
  }
1599
- function Ht(t, e, n) {
1727
+ function hn(t, e, n) {
1600
1728
  const r = t.resultPool.findLabels(e);
1601
1729
  return {
1602
1730
  axis: e,
@@ -1607,7 +1735,7 @@ function Ht(t, e, n) {
1607
1735
  defaultValue: n[0]
1608
1736
  };
1609
1737
  }
1610
- const nt = (t, e) => {
1738
+ const At = (t, e) => {
1611
1739
  let n = t.toString();
1612
1740
  return e == null || e.forEach((r) => {
1613
1741
  if (r)
@@ -1615,7 +1743,7 @@ const nt = (t, e) => {
1615
1743
  n += i, n += s;
1616
1744
  }), n;
1617
1745
  };
1618
- function rt(t) {
1746
+ function St(t) {
1619
1747
  if (!t.length)
1620
1748
  return [];
1621
1749
  let e = [[]];
@@ -1626,87 +1754,87 @@ function rt(t) {
1626
1754
  }), e = r;
1627
1755
  }), e;
1628
1756
  }
1629
- function st(t, e) {
1630
- const n = t.spec.axesSpec.map(L);
1631
- return e.spec.axesSpec.map(L).every((i) => n.some((s) => G(s, i) && G(i, s)));
1757
+ function xt(t, e) {
1758
+ const n = t.spec.axesSpec.map(F);
1759
+ return e.spec.axesSpec.map(F).every((i) => n.some((s) => G(s, i) && G(i, s)));
1632
1760
  }
1633
- function Pe(t, e) {
1634
- const n = t.spec.axesSpec.map(L);
1635
- return e.spec.axesSpec.map(L).every((i) => n.some((s) => G(s, i)));
1761
+ function ke(t, e) {
1762
+ const n = t.spec.axesSpec.map(F);
1763
+ return e.spec.axesSpec.map(F).every((i) => n.some((s) => G(s, i)));
1636
1764
  }
1637
- const it = "pl7.app/graph/isVirtual", he = "pl7.app/label";
1638
- function ge(t, e) {
1639
- const n = t.spec.axesSpec.map(L), r = e.spec.axesSpec.map(L);
1640
- if (st(t, e))
1765
+ const Pt = "pl7.app/graph/isVirtual", Ae = "pl7.app/label";
1766
+ function Se(t, e) {
1767
+ const n = t.spec.axesSpec.map(F), r = e.spec.axesSpec.map(F);
1768
+ if (xt(t, e))
1641
1769
  return [];
1642
- if (!Pe(t, e))
1770
+ if (!ke(t, e))
1643
1771
  return [];
1644
- const o = r.map((u) => n.filter((f) => G(f, u))), a = rt(o), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), m = a.map((u) => {
1645
- const f = /* @__PURE__ */ new Set();
1646
- return u.map((p, d) => {
1647
- const y = e.spec.axesSpec[d].domain, g = p.domain;
1648
- return Object.entries(g ?? {}).forEach(([v, w]) => {
1649
- if ((y == null ? void 0 : y[v]) === void 0) {
1650
- const x = JSON.stringify([v, w]);
1651
- f.add(x), c.add(x);
1772
+ const o = r.map((d) => n.filter((u) => G(u, d))), a = St(o), l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), w = a.map((d) => {
1773
+ const u = /* @__PURE__ */ new Set();
1774
+ return d.map((f, p) => {
1775
+ const y = e.spec.axesSpec[p].domain, v = f.domain;
1776
+ return Object.entries(v ?? {}).forEach(([m, b]) => {
1777
+ if ((y == null ? void 0 : y[m]) === void 0) {
1778
+ const g = JSON.stringify([m, b]);
1779
+ u.add(g), l.add(g);
1652
1780
  }
1653
1781
  }), {
1654
- ...p,
1655
- annotations: e.spec.axesSpec[d].annotations
1782
+ ...f,
1783
+ annotations: e.spec.axesSpec[p].annotations
1656
1784
  };
1657
- }), f;
1785
+ }), u;
1658
1786
  });
1659
- return [...c].forEach((u) => {
1660
- m.some((f) => !f.has(u)) && l.add(u);
1661
- }), a.map((u, f) => {
1662
- var v;
1663
- const p = nt(e.id, u.map((w) => w.domain)), d = ((v = e.spec.annotations) == null ? void 0 : v[he]) ?? "", y = [...m[f]].filter((w) => l.has(w)).sort().map((w) => {
1664
- var x;
1665
- return (x = JSON.parse(w)) == null ? void 0 : x[1];
1666
- }).join(" / "), g = {
1787
+ return [...l].forEach((d) => {
1788
+ w.some((u) => !u.has(d)) && c.add(d);
1789
+ }), a.map((d, u) => {
1790
+ var m;
1791
+ const f = At(e.id, d.map((b) => b.domain)), p = ((m = e.spec.annotations) == null ? void 0 : m[Ae]) ?? "", y = [...w[u]].filter((b) => c.has(b)).sort().map((b) => {
1792
+ var g;
1793
+ return (g = JSON.parse(b)) == null ? void 0 : g[1];
1794
+ }).join(" / "), v = {
1667
1795
  ...e.spec.annotations,
1668
- [it]: "true"
1796
+ [Pt]: "true"
1669
1797
  };
1670
- return (d || y) && (g[he] = d && y ? d + " / " + y : d + y), {
1671
- id: p,
1798
+ return (p || y) && (v[Ae] = p && y ? p + " / " + y : p + y), {
1799
+ id: f,
1672
1800
  spec: {
1673
1801
  ...e.spec,
1674
- axesSpec: u.map((w, x) => ({
1675
- ...w,
1676
- annotations: e.spec.axesSpec[x].annotations
1802
+ axesSpec: d.map((b, g) => ({
1803
+ ...b,
1804
+ annotations: e.spec.axesSpec[g].annotations
1677
1805
  })),
1678
- annotations: g
1806
+ annotations: v
1679
1807
  },
1680
1808
  data: e.data
1681
1809
  };
1682
1810
  });
1683
1811
  }
1684
- function ot(t) {
1812
+ function Ct(t) {
1685
1813
  const e = [];
1686
1814
  for (let n = 0; n < t.length; n++)
1687
1815
  for (let r = n + 1; r < t.length; r++) {
1688
1816
  const i = t[n], s = t[r];
1689
1817
  e.push(
1690
- ...ge(i, s),
1691
- ...ge(s, i)
1818
+ ...Se(i, s),
1819
+ ...Se(s, i)
1692
1820
  );
1693
1821
  }
1694
1822
  return e;
1695
1823
  }
1696
- function at(t, e) {
1824
+ function _t(t, e) {
1697
1825
  const n = [...t];
1698
1826
  for (const r of e)
1699
1827
  for (const i of t) {
1700
1828
  if (i.id === r.id)
1701
1829
  break;
1702
- if (Pe(i, r)) {
1830
+ if (ke(i, r)) {
1703
1831
  n.push(r);
1704
1832
  break;
1705
1833
  }
1706
1834
  }
1707
1835
  return n;
1708
1836
  }
1709
- const lt = [
1837
+ const It = [
1710
1838
  "Int",
1711
1839
  "Long",
1712
1840
  "Float",
@@ -1714,15 +1842,15 @@ const lt = [
1714
1842
  "String",
1715
1843
  "Bytes"
1716
1844
  ];
1717
- function qt(t, e) {
1845
+ function gn(t, e) {
1718
1846
  if (e === void 0) return;
1719
- const n = t.resultPool.getData().entries.map((s) => s.obj).filter(M).filter((s) => lt.includes(s.spec.valueType)), r = at(e, n), i = [...r, ...ot(r)];
1847
+ const n = t.resultPool.getData().entries.map((s) => s.obj).filter(se).filter((s) => It.includes(s.spec.valueType)), r = _t(e, n), i = [...r, ...Ct(r)];
1720
1848
  if (!i.some(
1721
1849
  (s) => s.data instanceof I && !s.data.getIsReadyOrError()
1722
1850
  ))
1723
1851
  return t.createPFrame(i);
1724
1852
  }
1725
- class zt {
1853
+ class mn {
1726
1854
  constructor(e) {
1727
1855
  this.handle = e;
1728
1856
  }
@@ -1742,111 +1870,113 @@ class zt {
1742
1870
  return await platforma.pFrameDriver.getUniqueValues(this.handle, e);
1743
1871
  }
1744
1872
  }
1745
- function ut(t) {
1746
- return ye({
1873
+ function Lt(t) {
1874
+ return Ce({
1747
1875
  __isRef: !0,
1748
- blockId: X(t, "blockId"),
1749
- name: X(t, "name")
1876
+ blockId: te(t, "blockId"),
1877
+ name: te(t, "name")
1750
1878
  });
1751
1879
  }
1752
- function Yt(t) {
1753
- return ye({
1754
- ref: ut(X(t, "ref")),
1755
- label: X(t, "label")
1880
+ function yn(t) {
1881
+ return Ce({
1882
+ ref: Lt(te(t, "ref")),
1883
+ label: te(t, "label")
1756
1884
  });
1757
1885
  }
1758
- const Xt = {
1759
- sdkVersion: U
1886
+ const vn = {
1887
+ sdkVersion: M
1760
1888
  };
1761
- function ct() {
1762
- return be({ sdkVersion: U });
1889
+ function Tt() {
1890
+ return _e({ sdkVersion: M });
1763
1891
  }
1764
- function Qt(t) {
1892
+ function bn(t) {
1765
1893
  try {
1766
- return ct();
1894
+ return Tt();
1767
1895
  } catch {
1768
1896
  return t;
1769
1897
  }
1770
1898
  }
1771
- function Zt(t) {
1899
+ function wn(t) {
1772
1900
  if (typeof globalThis.getEnvironmentValue == "function")
1773
1901
  return globalThis.getEnvironmentValue(t);
1774
1902
  }
1775
1903
  export {
1776
- mt as Args,
1777
- _ as BlockModel,
1778
- Xt as CurrentSdkInfo,
1779
- S as FutureRef,
1780
- it as IS_VIRTUAL_COLUMN,
1781
- yt as It,
1782
- Ut as JsRenderInternal,
1783
- he as LABEL_ANNOTATION,
1784
- bt as MainOutputs,
1785
- je as OutputError,
1786
- Me as PAnnotationLabel,
1787
- Ge as PAnnotationTrace,
1788
- zt as PFrameImpl,
1789
- E as RT_BINARY_PARTITIONED,
1904
+ jt as Args,
1905
+ T as BlockModel,
1906
+ vn as CurrentSdkInfo,
1907
+ _ as FutureRef,
1908
+ Pt as IS_VIRTUAL_COLUMN,
1909
+ Kt as It,
1910
+ cn as JsRenderInternal,
1911
+ Ae as LABEL_ANNOTATION,
1912
+ Vt as MainOutputs,
1913
+ ze as OutputError,
1914
+ nt as PAnnotationLabel,
1915
+ rt as PAnnotationTrace,
1916
+ be as PColumnCollection,
1917
+ mn as PFrameImpl,
1918
+ V as RT_BINARY_PARTITIONED,
1790
1919
  B as RT_BINARY_SUPER_PARTITIONED,
1791
- $ as RT_JSON_PARTITIONED,
1792
- ee as RT_JSON_SUPER_PARTITIONED,
1793
- Q as RT_RESOURCE_MAP,
1794
- Z as RT_RESOURCE_MAP_PARTITIONED,
1795
- z as RenderCtx,
1796
- et as ResultPool,
1797
- vt as StagingOutputs,
1798
- He as Trace,
1799
- We as TraceEntry,
1920
+ U as RT_JSON_PARTITIONED,
1921
+ ie as RT_JSON_SUPER_PARTITIONED,
1922
+ ne as RT_RESOURCE_MAP,
1923
+ re as RT_RESOURCE_MAP_PARTITIONED,
1924
+ Q as RenderCtx,
1925
+ bt as ResultPool,
1926
+ $t as StagingOutputs,
1927
+ st as Trace,
1928
+ it as TraceEntry,
1800
1929
  I as TreeNodeAccessor,
1801
- wt as UiState,
1802
- Ct as and,
1803
- qt as createPFrameForGraphs,
1804
- Wt as createPlDataTable,
1805
- Ht as createPlDataTableSheet,
1806
- de as deriveLabels,
1807
- se as downgradeCfgOrLambda,
1808
- at as enrichColumnsWithCompatible,
1809
- Vt as extractArchiveAndGetURL,
1810
- Gt as extractConfig,
1811
- Ue as filterDataInfoEntries,
1812
- Pt as flatten,
1813
- Yt as fromPlOption,
1814
- ut as fromPlRef,
1815
- ot as getAdditionalColumns,
1816
- kt as getBlobContent,
1817
- Ot as getBlobContentAsJson,
1818
- Dt as getBlobContentAsString,
1819
- Et as getDownloadedBlobContent,
1820
- Zt as getEnvironmentValue,
1930
+ Jt as UiState,
1931
+ Ht as and,
1932
+ pt as convertOrParsePColumnData,
1933
+ gn as createPFrameForGraphs,
1934
+ fn as createPlDataTable,
1935
+ hn as createPlDataTableSheet,
1936
+ Fe as deriveLabels,
1937
+ ue as downgradeCfgOrLambda,
1938
+ _t as enrichColumnsWithCompatible,
1939
+ rn as extractArchiveAndGetURL,
1940
+ dn as extractConfig,
1941
+ dt as filterDataInfoEntries,
1942
+ Mt as flatten,
1943
+ yn as fromPlOption,
1944
+ Lt as fromPlRef,
1945
+ Ct as getAdditionalColumns,
1946
+ Qt as getBlobContent,
1947
+ en as getBlobContentAsJson,
1948
+ Zt as getBlobContentAsString,
1949
+ tn as getDownloadedBlobContent,
1950
+ wn as getEnvironmentValue,
1821
1951
  W as getFromCfg,
1822
- Y as getImmediate,
1823
- Kt as getImportProgress,
1824
- X as getJsonField,
1825
- Jt as getLastLogs,
1826
- Bt as getLogHandle,
1827
- jt as getOnDemandBlobContent,
1828
- Ye as getPartitionKeysList,
1829
- Qt as getPlatformaOrDefault,
1830
- Nt as getProgressLog,
1831
- $t as getProgressLogWithInfo,
1832
- ct as getRawPlatformaInstance,
1833
- Ft as getResourceField,
1834
- Tt as getResourceValueAsJson,
1835
- Xe as getUniquePartitionKeys,
1836
- ie as ifDef,
1837
- tt as isConfigLambda,
1838
- _t as isEmpty,
1839
- gt as isolate,
1840
- xt as makeArray,
1841
- ye as makeObject,
1842
- St as mapArrayValues,
1843
- At as mapRecordValues,
1844
- Rt as mapResourceFields,
1845
- It as not,
1846
- Lt as or,
1847
- le as parsePColumnData,
1848
- Mt as parseResourceMap,
1849
- Ve as readOutput,
1850
- ht as wrapOutputs
1952
+ ee as getImmediate,
1953
+ sn as getImportProgress,
1954
+ te as getJsonField,
1955
+ on as getLastLogs,
1956
+ un as getLogHandle,
1957
+ nn as getOnDemandBlobContent,
1958
+ lt as getPartitionKeysList,
1959
+ bn as getPlatformaOrDefault,
1960
+ an as getProgressLog,
1961
+ ln as getProgressLogWithInfo,
1962
+ Tt as getRawPlatformaInstance,
1963
+ zt as getResourceField,
1964
+ Yt as getResourceValueAsJson,
1965
+ ct as getUniquePartitionKeys,
1966
+ pe as ifDef,
1967
+ wt as isConfigLambda,
1968
+ Gt as isEmpty,
1969
+ Ot as isolate,
1970
+ Nt as makeArray,
1971
+ Ce as makeObject,
1972
+ Bt as mapArrayValues,
1973
+ Ut as mapRecordValues,
1974
+ Xt as mapResourceFields,
1975
+ Wt as not,
1976
+ qt as or,
1977
+ he as parsePColumnData,
1978
+ pn as parseResourceMap,
1979
+ Ye as readOutput,
1980
+ Rt as wrapOutputs
1851
1981
  };
1852
1982
  //# sourceMappingURL=index.mjs.map