@platforma-sdk/model 1.25.0 → 1.27.6

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