@milaboratories/uikit 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,34 +1,1516 @@
1
- import { PlIdLength as m, getFileNameFromHandle as f, getFilePathFromHandle as p, isImportFileHandleIndex as g, isImportFileHandleUpload as d } from "../../../lib/model/common/dist/index.js";
2
- import r from "../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.js";
3
- import { BasePlErrorLike as u, ErrorLike as b, PlErrorLike as h, StandardErrorLike as P } from "../../../lib/model/pl-error-like/dist/index.js";
4
- function o(t) {
5
- if (t && typeof globalThis.getPlatforma == "function")
6
- return globalThis.getPlatforma(t);
1
+ import { isDataInfo as ae, extractAllColumns as Le, mapPTableDef as Ee, selectorsToPredicate as W, withEnrichments as ce, AnchoredIdDeriver as he, isPlRef as Te, mapValueInVOE as Fe, mapPObjectData as le, ensurePColumn as ke, isPColumnSpec as G, isPColumn as ve, resolveAnchors as de, deriveNativeId as Oe, isPartitionedDataInfoEntries as Re, getAxisId as pe, entriesToDataInfo as De, isDataInfoEntries as be, dataInfoToEntries as Ke, canonicalizeAxisId as $e, mapDataInfo as Ne } from "../../../lib/model/common/dist/index.js";
2
+ import { PlIdLength as vt, getAxesId as bt, getFileNameFromHandle as _t, getFilePathFromHandle as wt, isImportFileHandleIndex as Pt, isImportFileHandleUpload as xt, mapJoinEntry as At, matchAxis as It, matchAxisId as St, matchPColumn as Ct, stringifyColumnId as Lt } from "../../../lib/model/common/dist/index.js";
3
+ import _e from "../../../_virtual/canonicalize.js";
4
+ import $ from "../../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.js";
5
+ import { BasePlErrorLike as Tt, ErrorLike as Ft, PlErrorLike as kt, StandardErrorLike as Ot } from "../../../lib/model/pl-error-like/dist/index.js";
6
+ var je = Object.defineProperty, Be = (r, e, t) => e in r ? je(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, I = (r, e, t) => Be(r, typeof e != "symbol" ? e + "" : e, t);
7
+ function Q(r) {
8
+ return { type: "Immediate", value: r };
9
+ }
10
+ function Je() {
11
+ return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
12
+ }
13
+ function we(r) {
14
+ if (r && typeof globalThis.getPlatforma == "function")
15
+ return globalThis.getPlatforma(r);
7
16
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
8
17
  throw new Error("Can't get platforma instance.");
9
18
  }
10
- const e = r.object({
11
- type: r.string(),
12
- importance: r.number().optional(),
13
- id: r.string().optional(),
14
- label: r.string()
19
+ function Ue() {
20
+ if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
21
+ }
22
+ function c() {
23
+ if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
24
+ throw new Error("Not in config rendering context");
25
+ }
26
+ function U(r, e) {
27
+ const t = Ue();
28
+ if (t === void 0) return !1;
29
+ if (r in t.callbackRegistry) throw new Error(`Callback with key ${r} already registered.`);
30
+ return t.callbackRegistry[r] = e, !0;
31
+ }
32
+ const X = /* @__PURE__ */ new Map();
33
+ function Ve(r, e) {
34
+ r in c().callbackRegistry || (c().callbackRegistry[r] = (t) => {
35
+ for (const n of X.get(r))
36
+ n(t);
37
+ }, X.set(r, [])), X.get(r).push(e);
38
+ }
39
+ class w {
40
+ constructor(e, t = (n) => n) {
41
+ I(this, "isResolved", !1), I(this, "resolvedValue"), this.handle = e, this.postProcess = t, Ve(e, (n) => {
42
+ this.resolvedValue = t(n), this.isResolved = !0;
43
+ });
44
+ }
45
+ map(e) {
46
+ return new w(this.handle, (t) => e(this.postProcess(t)));
47
+ }
48
+ mapDefined(e) {
49
+ return new w(this.handle, (t) => {
50
+ const n = this.postProcess(t);
51
+ return n ? e(n) : void 0;
52
+ });
53
+ }
54
+ toJSON() {
55
+ return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
56
+ }
57
+ }
58
+ function ne(r, e) {
59
+ return r === void 0 ? void 0 : e(r);
60
+ }
61
+ class S {
62
+ constructor(e, t) {
63
+ this.handle = e, this.resolvePath = t;
64
+ }
65
+ resolve(...e) {
66
+ const t = e.map(
67
+ (n) => ({
68
+ assertFieldType: "Input",
69
+ ...typeof n == "string" ? { field: n } : n
70
+ })
71
+ );
72
+ return this.resolveWithCommon({}, ...t);
73
+ }
74
+ resolveOutput(...e) {
75
+ const t = e.map(
76
+ (n) => ({
77
+ assertFieldType: "Output",
78
+ ...typeof n == "string" ? { field: n } : n
79
+ })
80
+ );
81
+ return this.resolveWithCommon({}, ...t);
82
+ }
83
+ resolveInput(...e) {
84
+ const t = e.map(
85
+ (n) => ({
86
+ assertFieldType: "Input",
87
+ ...typeof n == "string" ? { field: n } : n
88
+ })
89
+ );
90
+ return this.resolveWithCommon({}, ...t);
91
+ }
92
+ resolveAny(...e) {
93
+ return this.resolveWithCommon({}, ...e);
94
+ }
95
+ resolveWithCommon(e, ...t) {
96
+ const n = [
97
+ ...this.resolvePath,
98
+ ...t.map((i) => typeof i == "string" ? i : i.field)
99
+ ];
100
+ return ne(
101
+ c().resolveWithCommon(this.handle, e, ...t),
102
+ (i) => new S(i, n)
103
+ );
104
+ }
105
+ get resourceType() {
106
+ return c().getResourceType(this.handle);
107
+ }
108
+ getInputsLocked() {
109
+ return c().getInputsLocked(this.handle);
110
+ }
111
+ getOutputsLocked() {
112
+ return c().getOutputsLocked(this.handle);
113
+ }
114
+ getIsReadyOrError() {
115
+ return c().getIsReadyOrError(this.handle);
116
+ }
117
+ getIsFinal() {
118
+ return c().getIsFinal(this.handle);
119
+ }
120
+ getError() {
121
+ const e = [...this.resolvePath, "error"];
122
+ return ne(
123
+ c().getError(this.handle),
124
+ (t) => new S(t, e)
125
+ );
126
+ }
127
+ listInputFields() {
128
+ return c().listInputFields(this.handle);
129
+ }
130
+ listOutputFields() {
131
+ return c().listOutputFields(this.handle);
132
+ }
133
+ listDynamicFields() {
134
+ return c().listDynamicFields(this.handle);
135
+ }
136
+ getKeyValueBase64(e) {
137
+ return c().getKeyValueBase64(this.handle, e);
138
+ }
139
+ getKeyValueAsString(e) {
140
+ return c().getKeyValueAsString(this.handle, e);
141
+ }
142
+ getKeyValueAsJson(e) {
143
+ const t = this.getKeyValueAsString(e);
144
+ if (t == null) throw new Error("Resource has no content.");
145
+ return JSON.parse(t);
146
+ }
147
+ getDataBase64() {
148
+ return c().getDataBase64(this.handle);
149
+ }
150
+ getDataAsString() {
151
+ return c().getDataAsString(this.handle);
152
+ }
153
+ getDataAsJson() {
154
+ const e = this.getDataAsString();
155
+ if (e == null) throw new Error("Resource has no content.");
156
+ return JSON.parse(e);
157
+ }
158
+ /**
159
+ *
160
+ */
161
+ getPColumns(e = !1, t = "") {
162
+ const n = this.parsePObjectCollection(e, t);
163
+ return n === void 0 ? void 0 : Object.entries(n).map(([, i]) => {
164
+ if (!ve(i)) throw new Error(`not a PColumn (kind = ${i.spec.kind})`);
165
+ return i;
166
+ });
167
+ }
168
+ /**
169
+ *
170
+ */
171
+ parsePObjectCollection(e = !1, t = "") {
172
+ const n = c().parsePObjectCollection(
173
+ this.handle,
174
+ e,
175
+ t,
176
+ ...this.resolvePath
177
+ );
178
+ if (n === void 0) return;
179
+ const i = {};
180
+ for (const [s, o] of Object.entries(n)) {
181
+ const a = [...this.resolvePath, s];
182
+ i[s] = le(o, (l) => new S(l, a));
183
+ }
184
+ return i;
185
+ }
186
+ getFileContentAsBase64(e) {
187
+ return new w(c().getBlobContentAsBase64(this.handle, e));
188
+ }
189
+ getFileContentAsString(e) {
190
+ return new w(c().getBlobContentAsString(this.handle, e));
191
+ }
192
+ getFileContentAsJson(e) {
193
+ return new w(
194
+ c().getBlobContentAsString(this.handle, e)
195
+ ).mapDefined((t) => JSON.parse(t));
196
+ }
197
+ /**
198
+ * @deprecated use getFileContentAsBase64
199
+ */
200
+ getBlobContentAsBase64() {
201
+ return this.getFileContentAsBase64();
202
+ }
203
+ /**
204
+ * @deprecated use getFileContentAsString
205
+ */
206
+ getBlobContentAsString() {
207
+ return this.getFileContentAsString();
208
+ }
209
+ /**
210
+ * @returns downloaded file handle
211
+ */
212
+ getFileHandle() {
213
+ return new w(c().getDownloadedBlobContentHandle(this.handle));
214
+ }
215
+ /**
216
+ * @deprecated use getFileHandle
217
+ */
218
+ getDownloadedBlobHandle() {
219
+ return this.getFileHandle();
220
+ }
221
+ /**
222
+ * @returns downloaded file handle
223
+ */
224
+ getRemoteFileHandle() {
225
+ return new w(c().getOnDemandBlobContentHandle(this.handle));
226
+ }
227
+ /**
228
+ * @deprecated use getRemoteFileHandle
229
+ */
230
+ getOnDemandBlobHandle() {
231
+ return this.getRemoteFileHandle();
232
+ }
233
+ /**
234
+ * @returns the url to the extracted folder
235
+ */
236
+ extractArchiveAndGetURL(e) {
237
+ return new w(c().extractArchiveAndGetURL(this.handle, e));
238
+ }
239
+ getImportProgress() {
240
+ return new w(c().getImportProgress(this.handle));
241
+ }
242
+ getLastLogs(e) {
243
+ return new w(c().getLastLogs(this.handle, e));
244
+ }
245
+ getProgressLog(e) {
246
+ return new w(c().getProgressLog(this.handle, e));
247
+ }
248
+ getProgressLogWithInfo(e) {
249
+ return new w(c().getProgressLogWithInfo(this.handle, e));
250
+ }
251
+ getLogHandle() {
252
+ return new w(c().getLogHandle(this.handle));
253
+ }
254
+ allFieldsResolved(e = "Input") {
255
+ switch (e) {
256
+ case "Input":
257
+ return this.getInputsLocked() && this.listInputFields().every(
258
+ (t) => this.resolve({ field: t, assertFieldType: "Input" }) !== void 0
259
+ );
260
+ case "Output":
261
+ return this.getOutputsLocked() && this.listOutputFields().every(
262
+ (t) => this.resolve({ field: t, assertFieldType: "Output" }) !== void 0
263
+ );
264
+ }
265
+ }
266
+ mapFields(e, t) {
267
+ const { fieldType: n, requireLocked: i, skipUnresolved: s } = {
268
+ fieldType: "Input",
269
+ requireLocked: !0,
270
+ skipUnresolved: !1,
271
+ ...t
272
+ }, o = e;
273
+ if (i && (n === "Input" && !this.getInputsLocked() || n === "Output" && !this.getOutputsLocked()))
274
+ return;
275
+ let a = (n === "Input" ? this.listInputFields() : n === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
276
+ (l) => [l, this.resolve({ field: l, assertFieldType: n })]
277
+ );
278
+ return s && (a = a.filter((l) => l[1] !== void 0)), a.map(([l, y]) => o(l, y));
279
+ }
280
+ }
281
+ const Me = "staging", We = "main", He = "pl7.app/label", qe = "pl7.app/trace", ze = $.object({
282
+ type: $.string(),
283
+ importance: $.number().optional(),
284
+ id: $.string().optional(),
285
+ label: $.string()
286
+ }), Ge = $.array(ze), Ye = 1e-3, Ze = "__LABEL__", fe = "__LABEL__@1";
287
+ function Pe(r, e, t = {}) {
288
+ const n = /* @__PURE__ */ new Map(), i = t.forceTraceElements !== void 0 && t.forceTraceElements.length > 0 ? new Set(t.forceTraceElements) : void 0, s = /* @__PURE__ */ new Map(), o = r.map((f) => {
289
+ var P, u;
290
+ const h = e(f);
291
+ let v, C, L;
292
+ "spec" in h && typeof h.spec == "object" ? (v = h.spec, C = h.prefixTrace, L = h.suffixTrace) : v = h;
293
+ const d = (P = v.annotations) == null ? void 0 : P[He], x = (u = v.annotations) == null ? void 0 : u[qe], p = (x ? Ge.safeParse(JSON.parse(x)).data : void 0) ?? [], g = [
294
+ ...C ?? [],
295
+ ...p,
296
+ ...L ?? []
297
+ ];
298
+ if (d !== void 0) {
299
+ const A = { label: d, type: Ze, importance: -2 };
300
+ t.addLabelAsSuffix ? g.push(A) : g.splice(0, 0, A);
301
+ }
302
+ const m = [], T = /* @__PURE__ */ new Map();
303
+ for (let A = g.length - 1; A >= 0; --A) {
304
+ const { type: B } = g[A], O = g[A].importance ?? 0, D = (T.get(B) ?? 0) + 1;
305
+ T.set(B, D);
306
+ const k = `${B}@${D}`;
307
+ s.set(k, (s.get(k) ?? 0) + 1), n.set(
308
+ k,
309
+ Math.max(
310
+ n.get(k) ?? Number.NEGATIVE_INFINITY,
311
+ O - (g.length - A) * Ye
312
+ )
313
+ ), m.push({ ...g[A], fullType: k, occurrenceIndex: D });
314
+ }
315
+ return m.reverse(), {
316
+ value: f,
317
+ spec: v,
318
+ label: d,
319
+ fullTrace: m
320
+ };
321
+ }), a = [], l = [], y = [...n];
322
+ y.sort(([, f], [, P]) => P - f);
323
+ for (const [f] of y)
324
+ f.endsWith("@1") || s.get(f) === r.length ? a.push(f) : l.push(f);
325
+ const j = (f, P = !1) => {
326
+ const u = [];
327
+ for (let h = 0; h < o.length; h++) {
328
+ const v = o[h], C = v.fullTrace.filter((x) => f.has(x.fullType) || i && i.has(x.type));
329
+ if (C.length === 0)
330
+ if (P)
331
+ u.push({
332
+ label: "Unlabeled",
333
+ value: v.value
334
+ });
335
+ else return;
336
+ const L = C.map((x) => x.label), d = t.separator ?? " / ";
337
+ u.push({
338
+ label: L.join(d),
339
+ value: v.value
340
+ });
341
+ }
342
+ return u;
343
+ };
344
+ if (a.length === 0) {
345
+ if (l.length !== 0) throw new Error("Non-empty secondary types list while main types list is empty.");
346
+ return j(new Set(fe), !0);
347
+ }
348
+ let E = 0, F = -1;
349
+ for (; E < a.length; ) {
350
+ const f = /* @__PURE__ */ new Set();
351
+ t.includeNativeLabel && f.add(fe);
352
+ for (let u = 0; u < E; ++u) f.add(a[u]);
353
+ F >= 0 && f.add(a[F]);
354
+ const P = j(f);
355
+ if (P !== void 0 && new Set(P.map((u) => u.label)).size === r.length) return P;
356
+ F++, F >= a.length && (E++, F = E);
357
+ }
358
+ return j(/* @__PURE__ */ new Set([...a, ...l]), !0);
359
+ }
360
+ const H = "PColumnData/", re = H + "ResourceMap", ie = H + "Partitioned/ResourceMap", V = H + "JsonPartitioned", N = H + "BinaryPartitioned", xe = H + "Partitioned/", Z = xe + "JsonPartitioned", M = xe + "BinaryPartitioned", se = (r) => {
361
+ if (r.endsWith(".index"))
362
+ return { baseKey: r.substring(0, r.length - 6), type: "index" };
363
+ if (r.endsWith(".values"))
364
+ return { baseKey: r.substring(0, r.length - 7), type: "values" };
365
+ throw new Error(`key must ends on .index/.values for binary p-column, got: ${r}`);
366
+ };
367
+ function Qe(r) {
368
+ if (!r) return;
369
+ const e = r.resourceType.name, t = r.getDataAsJson(), n = [];
370
+ let i = 0;
371
+ switch (e) {
372
+ case re:
373
+ i = t.keyLength;
374
+ break;
375
+ case ie:
376
+ i = t.partitionKeyLength + t.keyLength;
377
+ break;
378
+ case V:
379
+ case N:
380
+ i = t.partitionKeyLength;
381
+ break;
382
+ case M:
383
+ case Z:
384
+ i = t.superPartitionKeyLength + t.partitionKeyLength;
385
+ break;
386
+ }
387
+ switch (e) {
388
+ case re:
389
+ case V:
390
+ case N:
391
+ for (let s of r.listInputFields()) {
392
+ e === N && (s = se(s).baseKey);
393
+ const o = [...JSON.parse(s)];
394
+ n.push(o);
395
+ }
396
+ break;
397
+ case ie:
398
+ case M:
399
+ case Z:
400
+ for (const s of r.listInputFields()) {
401
+ const o = [...JSON.parse(s)], a = r.resolve({ field: s, assertFieldType: "Input" });
402
+ if (a !== void 0)
403
+ for (let l of a.listInputFields()) {
404
+ e === M && (l = se(l).baseKey);
405
+ const y = [...o, ...JSON.parse(l)];
406
+ n.push(y);
407
+ }
408
+ }
409
+ break;
410
+ }
411
+ return { data: n, keyLength: i };
412
+ }
413
+ function Xe(r) {
414
+ if (r.type !== "JsonPartitioned" && r.type !== "BinaryPartitioned")
415
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, got ${r.type}`);
416
+ const { parts: e, partitionKeyLength: t } = r, n = [];
417
+ for (let i = 0; i < t; ++i)
418
+ n.push(/* @__PURE__ */ new Set());
419
+ for (const i of e) {
420
+ const s = i.key;
421
+ if (s.length !== t)
422
+ throw new Error(
423
+ `Key length (${s.length}) does not match partition length (${t}) for key: ${JSON.stringify(
424
+ s
425
+ )}`
426
+ );
427
+ for (let o = 0; o < t; ++o)
428
+ n[o].add(s[o]);
429
+ }
430
+ return n.map((i) => Array.from(i.values()));
431
+ }
432
+ function et(r) {
433
+ if (r === void 0) return;
434
+ if (be(r))
435
+ return Xe(r);
436
+ const e = Qe(r);
437
+ if (!e) return;
438
+ const { data: t, keyLength: n } = e, i = [];
439
+ for (let s = 0; s < n; ++s)
440
+ i.push(/* @__PURE__ */ new Set());
441
+ for (const s of t) {
442
+ if (s.length !== n)
443
+ throw new Error("key length does not match partition length");
444
+ for (let o = 0; o < n; ++o)
445
+ i[o].add(s[o]);
446
+ }
447
+ return i.map((s) => Array.from(s.values()));
448
+ }
449
+ function oe(r, e = []) {
450
+ if (r === void 0 || !r.getIsReadyOrError()) return;
451
+ const t = r.resourceType.name, n = r.getDataAsJson();
452
+ if (e.length > 0 && (t === Z || t === M))
453
+ throw new Error(`Unexpected nested super-partitioned resource: ${t}`);
454
+ switch (t) {
455
+ case re:
456
+ case ie:
457
+ throw new Error(`Only data columns are supported, got: ${t}`);
458
+ case V: {
459
+ if (typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
460
+ throw new Error(`Missing partitionKeyLength in metadata for ${t}`);
461
+ const i = [];
462
+ for (const s of r.listInputFields()) {
463
+ const o = r.resolve({ field: s, assertFieldType: "Input" });
464
+ if (o === void 0) return;
465
+ const a = [...e, ...JSON.parse(s)];
466
+ i.push({ key: a, value: o });
467
+ }
468
+ return {
469
+ type: "JsonPartitioned",
470
+ partitionKeyLength: n.partitionKeyLength,
471
+ parts: i
472
+ };
473
+ }
474
+ case N: {
475
+ if (typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
476
+ throw new Error(`Missing partitionKeyLength in metadata for ${t}`);
477
+ const i = [], s = /* @__PURE__ */ new Map();
478
+ for (const o of r.listInputFields()) {
479
+ const a = se(o), l = r.resolve({ field: o, assertFieldType: "Input" });
480
+ if (l === void 0) return;
481
+ let y = s.get(a.baseKey);
482
+ y || (y = {}, s.set(a.baseKey, y)), a.type === "index" ? y.index = l : y.values = l;
483
+ }
484
+ for (const [o, a] of s.entries()) {
485
+ if (!a.index || !a.values) return;
486
+ const l = [...e, ...JSON.parse(o)];
487
+ i.push({
488
+ key: l,
489
+ value: {
490
+ index: a.index,
491
+ values: a.values
492
+ }
493
+ });
494
+ }
495
+ return {
496
+ type: "BinaryPartitioned",
497
+ partitionKeyLength: n.partitionKeyLength,
498
+ parts: i
499
+ };
500
+ }
501
+ case Z: {
502
+ if (typeof (n == null ? void 0 : n.superPartitionKeyLength) != "number" || typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
503
+ throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${t}`);
504
+ const i = n.superPartitionKeyLength + n.partitionKeyLength, s = [];
505
+ for (const o of r.listInputFields()) {
506
+ const a = r.resolve({ field: o, assertFieldType: "Input" });
507
+ if (a === void 0) return;
508
+ if (a.resourceType.name !== V)
509
+ throw new Error(`Expected ${V} inside ${t}, but got ${a.resourceType.name}`);
510
+ const l = oe(a, JSON.parse(o));
511
+ if (l === void 0) return;
512
+ if (l.type !== "JsonPartitioned")
513
+ throw new Error(`Unexpected inner result type for ${t}: ${l.type}`);
514
+ s.push(...l.parts);
515
+ }
516
+ return {
517
+ type: "JsonPartitioned",
518
+ partitionKeyLength: i,
519
+ parts: s
520
+ };
521
+ }
522
+ case M: {
523
+ if (typeof (n == null ? void 0 : n.superPartitionKeyLength) != "number" || typeof (n == null ? void 0 : n.partitionKeyLength) != "number")
524
+ throw new Error(`Missing superPartitionKeyLength or partitionKeyLength in metadata for ${t}`);
525
+ const i = n.superPartitionKeyLength + n.partitionKeyLength, s = [];
526
+ for (const o of r.listInputFields()) {
527
+ const a = r.resolve({ field: o, assertFieldType: "Input" });
528
+ if (a === void 0) return;
529
+ if (a.resourceType.name !== N)
530
+ throw new Error(`Expected ${N} inside ${t}, but got ${a.resourceType.name}`);
531
+ const l = oe(a, JSON.parse(o));
532
+ if (l === void 0) return;
533
+ if (l.type !== "BinaryPartitioned")
534
+ throw new Error(`Unexpected inner result type for ${t}: ${l.type}`);
535
+ s.push(...l.parts);
536
+ }
537
+ return {
538
+ type: "BinaryPartitioned",
539
+ partitionKeyLength: i,
540
+ parts: s
541
+ };
542
+ }
543
+ default:
544
+ throw new Error(`Unknown resource type: ${t}`);
545
+ }
546
+ }
547
+ function tt(r) {
548
+ if (r !== void 0) {
549
+ if (be(r)) return r;
550
+ if (ae(r)) return Ke(r);
551
+ if (r instanceof S) return oe(r);
552
+ throw new Error(`Unexpected input type: ${typeof r}`);
553
+ }
554
+ }
555
+ function nt(r, e) {
556
+ const t = [...e].sort((s, o) => o[0] - s[0]);
557
+ if (r.type === "JsonPartitioned" || r.type === "BinaryPartitioned") {
558
+ const { partitionKeyLength: s } = r;
559
+ for (const [o] of e)
560
+ if (o >= s)
561
+ throw new Error(`Can't filter on non-partitioned axis ${o}. Must be >= ${s}`);
562
+ } else if (r.type === "Json") {
563
+ const { keyLength: s } = r;
564
+ for (const [o] of e)
565
+ if (o >= s)
566
+ throw new Error(`Can't filter on non-data axis ${o}. Must be >= ${s}`);
567
+ }
568
+ const n = (s) => {
569
+ for (const [o, a] of t)
570
+ if (s[o] !== a)
571
+ return !1;
572
+ return !0;
573
+ }, i = (s) => {
574
+ const o = [...s];
575
+ for (const [a] of t)
576
+ o.splice(a, 1);
577
+ return o;
578
+ };
579
+ switch (r.type) {
580
+ case "Json": {
581
+ const s = r.data.filter((o) => n(o.key)).map((o) => ({
582
+ key: i(o.key),
583
+ value: o.value
584
+ }));
585
+ return {
586
+ type: "Json",
587
+ keyLength: r.keyLength - e.length,
588
+ data: s
589
+ };
590
+ }
591
+ case "JsonPartitioned": {
592
+ const s = r.parts.filter((o) => n(o.key)).map((o) => ({
593
+ key: i(o.key),
594
+ value: o.value
595
+ }));
596
+ return {
597
+ type: "JsonPartitioned",
598
+ partitionKeyLength: r.partitionKeyLength - e.length,
599
+ parts: s
600
+ };
601
+ }
602
+ case "BinaryPartitioned": {
603
+ const s = r.parts.filter((o) => n(o.key)).map((o) => ({
604
+ key: i(o.key),
605
+ value: o.value
606
+ }));
607
+ return {
608
+ type: "BinaryPartitioned",
609
+ partitionKeyLength: r.partitionKeyLength - e.length,
610
+ parts: s
611
+ };
612
+ }
613
+ }
614
+ }
615
+ function rt(r) {
616
+ if (!Array.isArray(r)) return !1;
617
+ if (r.length === 0) return !0;
618
+ const e = r[0];
619
+ return typeof e == "object" && e !== null && "key" in e && "val" in e;
620
+ }
621
+ class it {
622
+ constructor(e) {
623
+ this.columns = e;
624
+ }
625
+ selectColumns(e) {
626
+ const t = typeof e == "function" ? e : W(e);
627
+ return this.columns.filter((n) => t(n.spec));
628
+ }
629
+ }
630
+ function st(r) {
631
+ if (r)
632
+ return r.map((e) => ({
633
+ type: `split:${$e(e.axisId)}`,
634
+ label: e.label,
635
+ importance: 1e6
636
+ // High importance for split filters in labels
637
+ }));
638
+ }
639
+ function ot(r) {
640
+ if (r)
641
+ return r.map((e) => [e.axisIdx, e.value]);
642
+ }
643
+ function at(r, e) {
644
+ if (!e || e.length === 0) return r;
645
+ const t = [...e].sort((n, i) => n[0] - i[0]);
646
+ return _e({ id: r, axisFilters: t });
647
+ }
648
+ function ge(r) {
649
+ if (!r || typeof r != "object") return !1;
650
+ const e = r, t = e.domain && typeof e.domain == "object" && Object.values(e.domain).some((i) => typeof i == "object" && i !== null && "anchor" in i), n = e.axes && Array.isArray(e.axes) && e.axes.some((i) => typeof i == "object" && i !== null && "anchor" in i);
651
+ return !!e.domainAnchor || t || n;
652
+ }
653
+ function lt(r) {
654
+ if (typeof r != "object" || !("axes" in r) || r.axes === void 0)
655
+ return [];
656
+ const e = r.axes.map((t, n) => typeof t == "object" && "split" in t && t.split === !0 ? n : -1).filter((t) => t !== -1);
657
+ if (e.length > 0 && r.partialAxesMatch !== void 0)
658
+ throw new Error("Axis splitting is not supported when `partialAxesMatch` is defined.");
659
+ return e.sort((t, n) => t - n), e;
660
+ }
661
+ class me {
662
+ constructor() {
663
+ I(this, "defaultProviderStore", []), I(this, "providers", [new it(this.defaultProviderStore)]), I(this, "axisLabelProviders", []);
664
+ }
665
+ addColumnProvider(e) {
666
+ return this.providers.push(e), this;
667
+ }
668
+ addAxisLabelProvider(e) {
669
+ return this.axisLabelProviders.push(e), this;
670
+ }
671
+ addColumns(e) {
672
+ return this.defaultProviderStore.push(...e), this;
673
+ }
674
+ addColumn(e) {
675
+ return this.defaultProviderStore.push(e), this;
676
+ }
677
+ /** Fetches labels for a given axis from the registered providers */
678
+ findLabels(e) {
679
+ for (const t of this.axisLabelProviders) {
680
+ const n = t.findLabels(e);
681
+ if (n) return n;
682
+ }
683
+ }
684
+ getUniversalEntries(e, t) {
685
+ const { anchorCtx: n, labelOps: i, dontWaitAllData: s = !1, overrideLabelAnnotation: o = !1, exclude: a } = t ?? {}, l = {
686
+ ...o && (i == null ? void 0 : i.includeNativeLabel) !== !1 ? { includeNativeLabel: !0 } : {},
687
+ ...i ?? {}
688
+ };
689
+ let y = () => !1;
690
+ if (a) {
691
+ const u = (Array.isArray(a) ? a : [a]).map((h) => {
692
+ if (ge(h)) {
693
+ if (!n)
694
+ throw new Error("Anchored selectors in exclude require an AnchoredIdDeriver to be provided in options.");
695
+ return W(de(n.anchors, h, t));
696
+ } else
697
+ return W(h);
698
+ });
699
+ y = (h) => u.some((v) => v(h));
700
+ }
701
+ const j = typeof e == "function" ? [e] : Array.isArray(e) ? e : [e], E = [], F = /* @__PURE__ */ new Set();
702
+ for (const u of j) {
703
+ const h = ge(u);
704
+ let v;
705
+ if (h) {
706
+ if (!n)
707
+ throw new Error("Anchored selectors require an AnchoredIdDeriver to be provided in options.");
708
+ v = de(n.anchors, u, t);
709
+ } else
710
+ v = u;
711
+ const C = /* @__PURE__ */ new Set(), L = [];
712
+ for (const p of this.providers) {
713
+ const g = p.selectColumns(v);
714
+ for (const m of g) {
715
+ if (y(m.spec)) continue;
716
+ if (C.has(m.id))
717
+ throw new Error(`Duplicate column id ${m.id} in provider ${p.constructor.name}`);
718
+ const T = Oe(m.spec);
719
+ F.has(T) || (C.add(m.id), F.add(T), L.push(m));
720
+ }
721
+ }
722
+ if (L.length === 0) continue;
723
+ const d = lt(u), x = d.length > 0;
724
+ for (const p of L) {
725
+ if (!G(p.spec)) continue;
726
+ const g = p.spec;
727
+ if (x) {
728
+ if (rt(p.data))
729
+ throw new Error(`Splitting is not supported for PColumns with PColumnValues data format. Column id: ${p.id}`);
730
+ const m = tt(p.data);
731
+ if (!m) {
732
+ if (s) continue;
733
+ return;
734
+ }
735
+ if (!Re(m))
736
+ throw new Error(`Splitting requires Partitioned DataInfoEntries, but parsing resulted in ${m.type} for column ${p.id}`);
737
+ const T = et(m), A = d[d.length - 1];
738
+ if (A >= m.partitionKeyLength)
739
+ throw new Error(`Not enough partition keys (${m.partitionKeyLength}) for requested split axes (max index ${A}) in column ${g.name}`);
740
+ const B = d.map((b) => this.findLabels(pe(g.axesSpec[b]))), O = [], D = (b, J) => {
741
+ if (J >= d.length) {
742
+ if (O.push([...b]), O.length > 1e4)
743
+ throw new Error("Too many key combinations, aborting.");
744
+ return;
745
+ }
746
+ const R = d[J];
747
+ if (R >= T.length)
748
+ throw new Error(`Axis index ${R} out of bounds for unique keys array (length ${T.length}) during split key generation for column ${p.id}`);
749
+ const K = T[R];
750
+ if (!K || K.length === 0) {
751
+ O.length = 0;
752
+ return;
753
+ }
754
+ for (const q of K)
755
+ b.push(q), D(b, J + 1), b.pop();
756
+ };
757
+ if (D([], 0), O.length === 0)
758
+ continue;
759
+ const k = [...g.axesSpec], Ae = d.map((b) => b);
760
+ for (let b = d.length - 1; b >= 0; b--)
761
+ k.splice(d[b], 1);
762
+ const Ie = { ...g, axesSpec: k };
763
+ for (const b of O) {
764
+ const J = b.map((R, K) => {
765
+ const q = Ae[K], Se = pe(g.axesSpec[q]), ue = B[K], Ce = (ue == null ? void 0 : ue[R]) ?? String(R);
766
+ return { axisIdx: q, axisId: Se, value: R, label: Ce };
767
+ });
768
+ E.push({
769
+ type: "split",
770
+ originalColumn: p,
771
+ spec: g,
772
+ adjustedSpec: Ie,
773
+ dataEntries: m,
774
+ axisFilters: J
775
+ });
776
+ }
777
+ } else
778
+ E.push({
779
+ type: "direct",
780
+ originalColumn: p,
781
+ spec: g,
782
+ adjustedSpec: g
783
+ });
784
+ }
785
+ }
786
+ if (E.length === 0) return [];
787
+ const f = Pe(
788
+ E,
789
+ (u) => ({
790
+ spec: u.spec,
791
+ suffixTrace: u.type === "split" ? st(u.axisFilters) : void 0
792
+ }),
793
+ l
794
+ ), P = [];
795
+ for (const { value: u, label: h } of f) {
796
+ const { originalColumn: v, spec: C } = u, L = u.type === "split" ? u.axisFilters : void 0, d = ot(L);
797
+ let x;
798
+ n ? x = n.deriveS(C, d) : x = at(v.id, d);
799
+ let p = { ...u.adjustedSpec };
800
+ o && (p = {
801
+ ...p,
802
+ annotations: {
803
+ ...p.annotations ?? {},
804
+ "pl7.app/label": h
805
+ }
806
+ }), P.push({
807
+ id: x,
808
+ spec: p,
809
+ data: () => u.type === "split" ? De(nt(u.dataEntries, d)) : u.originalColumn.data,
810
+ label: h
811
+ });
812
+ }
813
+ return P;
814
+ }
815
+ getColumns(e, t) {
816
+ const n = this.getUniversalEntries(e, {
817
+ overrideLabelAnnotation: !0,
818
+ // default for getColumns
819
+ ...t ?? {}
820
+ });
821
+ if (!n) return;
822
+ const i = [];
823
+ for (const s of n) {
824
+ const o = s.data();
825
+ if (!o) {
826
+ if (t != null && t.dontWaitAllData) continue;
827
+ return;
828
+ }
829
+ i.push({
830
+ id: s.id,
831
+ spec: s.spec,
832
+ data: o
833
+ });
834
+ }
835
+ return i;
836
+ }
837
+ }
838
+ function ee(r, e) {
839
+ if (r === void 0) return e === void 0;
840
+ if (e === void 0) return !0;
841
+ for (const t in e)
842
+ if (r[t] !== e[t]) return !1;
843
+ return !0;
844
+ }
845
+ function ye(r) {
846
+ return le(r, (e) => e instanceof S ? e.handle : ae(e) ? Ne(e, (t) => t.handle) : e);
847
+ }
848
+ class ut {
849
+ constructor() {
850
+ I(this, "ctx", c());
851
+ }
852
+ /**
853
+ * @deprecated use getOptions()
854
+ */
855
+ calculateOptions(e) {
856
+ return this.ctx.calculateOptions(e);
857
+ }
858
+ getOptions(e, t) {
859
+ const n = typeof e == "function" ? e : W(e), i = this.getSpecs().entries.filter((a) => n(a.obj));
860
+ let s = {}, o = !1;
861
+ return typeof t < "u" && (typeof t == "function" ? s = t : typeof t == "object" && ("includeNativeLabel" in t || "separator" in t || "addLabelAsSuffix" in t ? s = t : (t = t, s = t.label ?? {}, o = t.refsWithEnrichments ?? !1))), typeof s == "object" ? Pe(i, (a) => a.obj, s ?? {}).map(({ value: { ref: a }, label: l }) => ({
862
+ ref: ce(a, o),
863
+ label: l
864
+ })) : i.map(({ ref: a, obj: l }) => ({
865
+ ref: ce(a, o),
866
+ label: s(l, a)
867
+ }));
868
+ }
869
+ resolveAnchorCtx(e) {
870
+ if (e instanceof he) return e;
871
+ const t = {};
872
+ for (const [n, i] of Object.entries(e))
873
+ if (Te(i)) {
874
+ const s = this.getPColumnSpecByRef(i);
875
+ if (!s)
876
+ return;
877
+ t[n] = s;
878
+ } else
879
+ t[n] = i;
880
+ return new he(t);
881
+ }
882
+ /**
883
+ * Returns columns that match the provided anchors and selectors. It applies axis filters and label derivation.
884
+ *
885
+ * @param anchorsOrCtx - Anchor context for column selection (same as in getCanonicalOptions)
886
+ * @param predicateOrSelectors - Predicate or selectors for filtering columns (same as in getCanonicalOptions)
887
+ * @param opts - Optional configuration for label generation and data waiting
888
+ * @returns A PFrameHandle for the created PFrame, or undefined if any required data is missing
889
+ */
890
+ getAnchoredPColumns(e, t, n) {
891
+ const i = this.resolveAnchorCtx(e);
892
+ if (i)
893
+ return new me().addColumnProvider(this).addAxisLabelProvider(this).getColumns(t, {
894
+ ...n,
895
+ anchorCtx: i
896
+ });
897
+ }
898
+ /**
899
+ * Calculates anchored identifier options for columns matching a given predicate and returns their
900
+ * canonicalized representations.
901
+ *
902
+ * This function filters column specifications from the result pool that match the provided predicate,
903
+ * creates a standardized AnchorCtx from the provided anchors, and generates a list of label-value
904
+ * pairs for UI components (like dropdowns).
905
+ *
906
+ * @param anchorsOrCtx - Either:
907
+ * - An existing AnchorCtx instance
908
+ * - A record mapping anchor IDs to PColumnSpec objects
909
+ * - A record mapping anchor IDs to PlRef objects (which will be resolved to PColumnSpec)
910
+ * @param predicateOrSelectors - Either:
911
+ * - A predicate function that takes a PColumnSpec and returns a boolean.
912
+ * Only specs that return true will be included.
913
+ * - An APColumnSelector object for declarative filtering, which will be
914
+ * resolved against the provided anchors and matched using matchPColumn.
915
+ * - An array of APColumnSelector objects - columns matching ANY selector
916
+ * in the array will be included (OR operation).
917
+ * @param opts - Optional configuration for label generation:
918
+ * - labelOps: Optional configuration for label generation:
919
+ * - includeNativeLabel: Whether to include native column labels
920
+ * - separator: String to use between label parts (defaults to " / ")
921
+ * - addLabelAsSuffix: Whether to add labels as suffix instead of prefix
922
+ * - dontWaitAllData: Whether to skip columns that don't have all data (if not set, will return undefined,
923
+ * if at least one column that requires splitting is missing data)
924
+ * @returns An array of objects with `label` (display text) and `value` (anchored ID string) properties,
925
+ * or undefined if any PlRef resolution fails.
926
+ */
927
+ getCanonicalOptions(e, t, n) {
928
+ const i = this.resolveAnchorCtx(e);
929
+ if (!i) return;
930
+ const s = new me().addColumnProvider(this).addAxisLabelProvider(this).getUniversalEntries(t, {
931
+ ...n,
932
+ anchorCtx: i
933
+ });
934
+ if (s)
935
+ return s.map((o) => ({
936
+ value: o.id,
937
+ label: o.label
938
+ }));
939
+ }
940
+ /**
941
+ * @deprecated use getData()
942
+ */
943
+ getDataFromResultPool() {
944
+ return this.getData();
945
+ }
946
+ getData() {
947
+ const e = this.ctx.getDataFromResultPool();
948
+ return {
949
+ isComplete: e.isComplete,
950
+ entries: e.entries.map((t) => ({
951
+ ref: t.ref,
952
+ obj: {
953
+ ...t.obj,
954
+ data: new S(t.obj.data, [t.ref.blockId, t.ref.name])
955
+ }
956
+ }))
957
+ };
958
+ }
959
+ /**
960
+ * @deprecated use getDataWithErrors()
961
+ */
962
+ getDataWithErrorsFromResultPool() {
963
+ return this.getDataWithErrors();
964
+ }
965
+ getDataWithErrors() {
966
+ const e = this.ctx.getDataWithErrorsFromResultPool();
967
+ return {
968
+ isComplete: e.isComplete,
969
+ entries: e.entries.map((t) => ({
970
+ ref: t.ref,
971
+ obj: {
972
+ ...t.obj,
973
+ data: Fe(
974
+ t.obj.data,
975
+ (n) => new S(n, [t.ref.blockId, t.ref.name])
976
+ )
977
+ }
978
+ }))
979
+ };
980
+ }
981
+ /**
982
+ * @deprecated use getSpecs()
983
+ */
984
+ getSpecsFromResultPool() {
985
+ return this.getSpecs();
986
+ }
987
+ getSpecs() {
988
+ return this.ctx.getSpecsFromResultPool();
989
+ }
990
+ /**
991
+ * @param ref a Ref
992
+ * @returns data associated with the ref
993
+ */
994
+ getDataByRef(e) {
995
+ var t;
996
+ if (typeof this.ctx.getDataFromResultPoolByRef > "u")
997
+ return (t = this.getData().entries.find(
998
+ (i) => i.ref.blockId === e.blockId && i.ref.name === e.name
999
+ )) == null ? void 0 : t.obj;
1000
+ const n = this.ctx.getDataFromResultPoolByRef(e.blockId, e.name);
1001
+ if (n)
1002
+ return le(
1003
+ n,
1004
+ (i) => new S(i, [e.blockId, e.name])
1005
+ );
1006
+ }
1007
+ /**
1008
+ * Returns data associated with the ref ensuring that it is a p-column.
1009
+ * @param ref a Ref
1010
+ * @returns p-column associated with the ref
1011
+ */
1012
+ getPColumnByRef(e) {
1013
+ const t = this.getDataByRef(e);
1014
+ if (t)
1015
+ return ke(t);
1016
+ }
1017
+ /**
1018
+ * Returns spec associated with the ref ensuring that it is a p-column spec.
1019
+ * @param ref a Ref
1020
+ * @returns p-column spec associated with the ref
1021
+ */
1022
+ getPColumnSpecByRef(e) {
1023
+ const t = this.getSpecByRef(e);
1024
+ if (t) {
1025
+ if (!G(t)) throw new Error(`not a PColumn spec (kind = ${t.kind})`);
1026
+ return t;
1027
+ }
1028
+ }
1029
+ /**
1030
+ * @param ref a Ref
1031
+ * @returns object spec associated with the ref
1032
+ */
1033
+ getSpecByRef(e) {
1034
+ return this.ctx.getSpecFromResultPoolByRef(e.blockId, e.name);
1035
+ }
1036
+ /**
1037
+ * @param spec object specification
1038
+ * @returns array of data objects with compatible specs
1039
+ * @deprecated delete this method after Jan 1, 2025
1040
+ */
1041
+ findDataWithCompatibleSpec(e) {
1042
+ const t = [];
1043
+ e: for (const n of this.getData().entries) {
1044
+ if (!G(n.obj.spec))
1045
+ continue;
1046
+ const i = n.obj.spec;
1047
+ if (e.name === i.name && e.valueType === i.valueType && e.axesSpec.length === i.axesSpec.length && ee(e.domain, i.domain)) {
1048
+ for (let s = 0; s < e.axesSpec.length; ++s) {
1049
+ const o = e.axesSpec[s], a = i.axesSpec[s];
1050
+ if (o.name !== a.name || o.type !== a.type || !ee(o.domain, a.domain))
1051
+ continue e;
1052
+ }
1053
+ t.push(n.obj);
1054
+ }
1055
+ }
1056
+ return t;
1057
+ }
1058
+ /**
1059
+ * Find labels data for a given axis id. It will search for a label column and return its data as a map.
1060
+ * @returns a map of axis value => label
1061
+ */
1062
+ findLabels(e) {
1063
+ const t = this.getData();
1064
+ for (const n of t.entries) {
1065
+ if (!ve(n.obj)) continue;
1066
+ const i = n.obj.spec;
1067
+ if (i.name === "pl7.app/label" && i.axesSpec.length === 1 && i.axesSpec[0].name === e.name && i.axesSpec[0].type === e.type && ee(e.domain, i.axesSpec[0].domain)) {
1068
+ if (n.obj.data.resourceType.name !== "PColumnData/Json")
1069
+ throw Error(`Expected JSON column for labels, got: ${n.obj.data.resourceType.name}`);
1070
+ return Object.fromEntries(
1071
+ Object.entries(
1072
+ n.obj.data.getDataAsJson().data
1073
+ ).map((s) => [JSON.parse(s[0])[0], s[1]])
1074
+ );
1075
+ }
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Selects columns based on the provided selectors, returning PColumn objects
1080
+ * with lazily loaded data.
1081
+ *
1082
+ * @param selectors - A predicate function, a single selector, or an array of selectors.
1083
+ * @returns An array of PColumn objects matching the selectors. Data is loaded on first access.
1084
+ */
1085
+ selectColumns(e) {
1086
+ const t = typeof e == "function" ? e : W(e);
1087
+ return this.getSpecs().entries.filter(({ obj: n }) => G(n) ? t(n) : !1).map(({ ref: n, obj: i }) => {
1088
+ const s = i;
1089
+ let o = null;
1090
+ const a = this;
1091
+ return {
1092
+ id: _e(n),
1093
+ spec: s,
1094
+ get data() {
1095
+ var l;
1096
+ return o !== null || (o = (l = a.getPColumnByRef(n)) == null ? void 0 : l.data), o;
1097
+ }
1098
+ };
1099
+ });
1100
+ }
1101
+ /**
1102
+ * Find labels data for a given axis id of a p-column.
1103
+ * @returns a map of axis value => label
1104
+ */
1105
+ findLabelsForColumnAxis(e, t) {
1106
+ var n;
1107
+ const i = this.findLabels(e.axesSpec[t]);
1108
+ if (!i) return;
1109
+ const s = (n = e.annotations) == null ? void 0 : n["pl7.app/axisKeys/" + t];
1110
+ if (s !== void 0) {
1111
+ const o = JSON.parse(s);
1112
+ return Object.fromEntries(o.map((a) => [a, i[a] ?? "Unlabelled"]));
1113
+ } else
1114
+ return i;
1115
+ }
1116
+ }
1117
+ class z {
1118
+ constructor() {
1119
+ I(this, "ctx"), I(this, "_argsCache"), I(this, "_uiStateCache"), I(this, "_activeArgsCache"), I(this, "resultPool", new ut()), this.ctx = c();
1120
+ }
1121
+ get args() {
1122
+ if (this._argsCache === void 0) {
1123
+ const e = this.ctx.args, t = typeof e == "function" ? e() : e;
1124
+ this._argsCache = { v: JSON.parse(t) };
1125
+ }
1126
+ return this._argsCache.v;
1127
+ }
1128
+ get uiState() {
1129
+ if (this._uiStateCache === void 0) {
1130
+ const e = this.ctx.uiState, t = typeof e == "function" ? e() : e;
1131
+ this._uiStateCache = { v: t ? JSON.parse(t) : {} };
1132
+ }
1133
+ return this._uiStateCache.v;
1134
+ }
1135
+ /**
1136
+ * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
1137
+ * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
1138
+ * */
1139
+ get activeArgs() {
1140
+ if (this._activeArgsCache === void 0) {
1141
+ const e = this.ctx.activeArgs, t = typeof e == "function" ? e() : e;
1142
+ this._activeArgsCache = {
1143
+ v: t ? JSON.parse(t) : void 0
1144
+ };
1145
+ }
1146
+ return this._activeArgsCache.v;
1147
+ }
1148
+ // /** Can be used to determine features provided by the desktop instance. */
1149
+ // public get featureFlags() {
1150
+ // return this.ctx.featureFlags;
1151
+ // }
1152
+ getNamedAccessor(e) {
1153
+ return ne(
1154
+ this.ctx.getAccessorHandleByName(e),
1155
+ (t) => new S(t, [e])
1156
+ );
1157
+ }
1158
+ get prerun() {
1159
+ return this.getNamedAccessor(Me);
1160
+ }
1161
+ get outputs() {
1162
+ return this.getNamedAccessor(We);
1163
+ }
1164
+ /**
1165
+ * Find labels data for a given axis id. It will search for a label column and return its data as a map.
1166
+ * @returns a map of axis value => label
1167
+ * @deprecated Use resultPool.findLabels instead
1168
+ */
1169
+ findLabels(e) {
1170
+ return this.resultPool.findLabels(e);
1171
+ }
1172
+ verifyInlineAndExplicitColumnsSupport(e) {
1173
+ var t;
1174
+ const n = e.some((s) => !(s.data instanceof S) || ae(s.data)), i = ((t = this.ctx.featureFlags) == null ? void 0 : t.inlineColumnsSupport) === !0;
1175
+ if (n && !i) throw Error("Inline or explicit columns not supported");
1176
+ }
1177
+ patchPTableDef(e) {
1178
+ var t;
1179
+ return (t = this.ctx.featureFlags) != null && t.pTablePartitionFiltersSupport ? e : {
1180
+ ...e,
1181
+ partitionFilters: [],
1182
+ filters: [...e.partitionFilters, ...e.filters]
1183
+ };
1184
+ }
1185
+ // TODO remove all non-PColumn fields
1186
+ createPFrame(e) {
1187
+ return this.verifyInlineAndExplicitColumnsSupport(e), this.ctx.createPFrame(
1188
+ e.map((t) => ye(t))
1189
+ );
1190
+ }
1191
+ createPTable(e) {
1192
+ let t;
1193
+ return "columns" in e ? t = this.patchPTableDef({
1194
+ src: {
1195
+ type: "full",
1196
+ entries: e.columns.map((n) => ({ type: "column", column: n }))
1197
+ },
1198
+ partitionFilters: e.filters ?? [],
1199
+ filters: [],
1200
+ sorting: e.sorting ?? []
1201
+ }) : t = this.patchPTableDef(e), this.verifyInlineAndExplicitColumnsSupport(Le(t.src)), this.ctx.createPTable(
1202
+ Ee(t, (n) => ye(n))
1203
+ );
1204
+ }
1205
+ /** @deprecated scheduled for removal from SDK */
1206
+ getBlockLabel(e) {
1207
+ return this.ctx.getBlockLabel(e);
1208
+ }
1209
+ getCurrentUnstableMarker() {
1210
+ return this.ctx.getCurrentUnstableMarker();
1211
+ }
1212
+ logInfo(e) {
1213
+ this.ctx.logInfo(e);
1214
+ }
1215
+ logWarn(e) {
1216
+ this.ctx.logWarn(e);
1217
+ }
1218
+ logError(e) {
1219
+ this.ctx.logError(e);
1220
+ }
1221
+ }
1222
+ const Y = "1.39.0";
1223
+ function ct(r) {
1224
+ return r.__renderLambda === !0;
1225
+ }
1226
+ function te(r) {
1227
+ if (r !== void 0)
1228
+ return ct(r) ? r.handle : r;
1229
+ }
1230
+ const ht = class _ {
1231
+ constructor(e, t, n, i, s, o, a, l, y) {
1232
+ this._renderingMode = e, this._initialArgs = t, this._initialUiState = n, this._outputs = i, this._inputsValid = s, this._sections = o, this._title = a, this._enrichmentTargets = l, this._featureFlags = y;
1233
+ }
1234
+ static create(e = "Heavy") {
1235
+ return new _(
1236
+ e,
1237
+ void 0,
1238
+ {},
1239
+ {},
1240
+ Q(!0),
1241
+ Q([]),
1242
+ void 0,
1243
+ void 0,
1244
+ { ..._.INITIAL_BLOCK_FEATURE_FLAGS }
1245
+ );
1246
+ }
1247
+ output(e, t, n = {}) {
1248
+ if (typeof t == "function") {
1249
+ const i = `output#${e}`;
1250
+ return U(i, () => t(new z())), new _(
1251
+ this._renderingMode,
1252
+ this._initialArgs,
1253
+ this._initialUiState,
1254
+ {
1255
+ ...this._outputs,
1256
+ [e]: {
1257
+ __renderLambda: !0,
1258
+ handle: i,
1259
+ ...n
1260
+ }
1261
+ },
1262
+ this._inputsValid,
1263
+ this._sections,
1264
+ this._title,
1265
+ this._enrichmentTargets,
1266
+ this._featureFlags
1267
+ );
1268
+ } else
1269
+ return new _(
1270
+ this._renderingMode,
1271
+ this._initialArgs,
1272
+ this._initialUiState,
1273
+ {
1274
+ ...this._outputs,
1275
+ [e]: t
1276
+ },
1277
+ this._inputsValid,
1278
+ this._sections,
1279
+ this._title,
1280
+ this._enrichmentTargets,
1281
+ this._featureFlags
1282
+ );
1283
+ }
1284
+ /** Shortcut for {@link output} with retentive flag set to true. */
1285
+ retentiveOutput(e, t) {
1286
+ return this.output(e, t, { retentive: !0 });
1287
+ }
1288
+ argsValid(e) {
1289
+ return typeof e == "function" ? (U("inputsValid", () => e(new z())), new _(
1290
+ this._renderingMode,
1291
+ this._initialArgs,
1292
+ this._initialUiState,
1293
+ this._outputs,
1294
+ {
1295
+ __renderLambda: !0,
1296
+ handle: "inputsValid"
1297
+ },
1298
+ this._sections,
1299
+ this._title,
1300
+ this._enrichmentTargets,
1301
+ this._featureFlags
1302
+ )) : new _(
1303
+ this._renderingMode,
1304
+ this._initialArgs,
1305
+ this._initialUiState,
1306
+ this._outputs,
1307
+ e,
1308
+ this._sections,
1309
+ this._title,
1310
+ this._enrichmentTargets,
1311
+ this._featureFlags
1312
+ );
1313
+ }
1314
+ sections(e) {
1315
+ return Array.isArray(e) ? this.sections(Q(e)) : typeof e == "function" ? (U("sections", () => e(new z())), new _(
1316
+ this._renderingMode,
1317
+ this._initialArgs,
1318
+ this._initialUiState,
1319
+ this._outputs,
1320
+ this._inputsValid,
1321
+ { __renderLambda: !0, handle: "sections" },
1322
+ this._title,
1323
+ this._enrichmentTargets,
1324
+ this._featureFlags
1325
+ )) : new _(
1326
+ this._renderingMode,
1327
+ this._initialArgs,
1328
+ this._initialUiState,
1329
+ this._outputs,
1330
+ this._inputsValid,
1331
+ e,
1332
+ this._title,
1333
+ this._enrichmentTargets,
1334
+ this._featureFlags
1335
+ );
1336
+ }
1337
+ /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
1338
+ title(e) {
1339
+ return U("title", () => e(new z())), new _(
1340
+ this._renderingMode,
1341
+ this._initialArgs,
1342
+ this._initialUiState,
1343
+ this._outputs,
1344
+ this._inputsValid,
1345
+ this._sections,
1346
+ { __renderLambda: !0, handle: "title" },
1347
+ this._enrichmentTargets,
1348
+ this._featureFlags
1349
+ );
1350
+ }
1351
+ /**
1352
+ * Sets initial args for the block, this value must be specified.
1353
+ * @deprecated use {@link withArgs}
1354
+ * */
1355
+ initialArgs(e) {
1356
+ return new _(
1357
+ this._renderingMode,
1358
+ e,
1359
+ this._initialUiState,
1360
+ this._outputs,
1361
+ this._inputsValid,
1362
+ this._sections,
1363
+ this._title,
1364
+ this._enrichmentTargets,
1365
+ this._featureFlags
1366
+ );
1367
+ }
1368
+ /** Sets initial args for the block, this value must be specified. */
1369
+ withArgs(e) {
1370
+ return new _(
1371
+ this._renderingMode,
1372
+ e,
1373
+ this._initialUiState,
1374
+ this._outputs,
1375
+ this._inputsValid,
1376
+ this._sections,
1377
+ this._title,
1378
+ this._enrichmentTargets,
1379
+ this._featureFlags
1380
+ );
1381
+ }
1382
+ /** Defines type and sets initial value for block UiState. */
1383
+ withUiState(e) {
1384
+ return new _(
1385
+ this._renderingMode,
1386
+ this._initialArgs,
1387
+ e,
1388
+ this._outputs,
1389
+ this._inputsValid,
1390
+ this._sections,
1391
+ this._title,
1392
+ this._enrichmentTargets,
1393
+ this._featureFlags
1394
+ );
1395
+ }
1396
+ /**
1397
+ * Defines how to derive list of upstream references this block is meant to enrich with its exports from block args.
1398
+ * Influences dependency graph construction.
1399
+ */
1400
+ enriches(e) {
1401
+ return U("enrichmentTargets", e), new _(
1402
+ this._renderingMode,
1403
+ this._initialArgs,
1404
+ this._initialUiState,
1405
+ this._outputs,
1406
+ this._inputsValid,
1407
+ this._sections,
1408
+ this._title,
1409
+ { __renderLambda: !0, handle: "enrichmentTargets" },
1410
+ this._featureFlags
1411
+ );
1412
+ }
1413
+ /** Renders all provided block settings into a pre-configured platforma API
1414
+ * instance, that can be used in frontend to interact with block state, and
1415
+ * other features provided by the platforma to the block. */
1416
+ done() {
1417
+ if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
1418
+ const e = {
1419
+ v3: {
1420
+ sdkVersion: Y,
1421
+ renderingMode: this._renderingMode,
1422
+ initialArgs: this._initialArgs,
1423
+ initialUiState: this._initialUiState,
1424
+ inputsValid: this._inputsValid,
1425
+ sections: this._sections,
1426
+ title: this._title,
1427
+ outputs: this._outputs,
1428
+ enrichmentTargets: this._enrichmentTargets,
1429
+ featureFlags: this._featureFlags
1430
+ },
1431
+ // fields below are added to allow previous desktop versions read generated configs
1432
+ sdkVersion: Y,
1433
+ renderingMode: this._renderingMode,
1434
+ initialArgs: this._initialArgs,
1435
+ inputsValid: te(this._inputsValid),
1436
+ sections: te(this._sections),
1437
+ outputs: Object.fromEntries(
1438
+ Object.entries(this._outputs).map(([t, n]) => [t, te(n)])
1439
+ )
1440
+ };
1441
+ return Je() ? we({ sdkVersion: Y }) : { config: e };
1442
+ }
1443
+ };
1444
+ I(ht, "INITIAL_BLOCK_FEATURE_FLAGS", {
1445
+ supportsLazyState: !0,
1446
+ requiresUIAPIVersion: 1,
1447
+ requiresModelAPIVersion: 1
15
1448
  });
16
- r.array(e);
17
- const a = "1.38.0";
18
- function l() {
19
- return o({ sdkVersion: a });
1449
+ function gt() {
1450
+ return we({ sdkVersion: Y });
20
1451
  }
21
1452
  export {
22
- u as BasePlErrorLike,
23
- b as ErrorLike,
24
- h as PlErrorLike,
25
- m as PlIdLength,
26
- P as StandardErrorLike,
27
- e as TraceEntry,
28
- f as getFileNameFromHandle,
29
- p as getFilePathFromHandle,
30
- l as getRawPlatformaInstance,
31
- g as isImportFileHandleIndex,
32
- d as isImportFileHandleUpload
1453
+ he as AnchoredIdDeriver,
1454
+ Tt as BasePlErrorLike,
1455
+ Ft as ErrorLike,
1456
+ w as FutureRef,
1457
+ He as PAnnotationLabel,
1458
+ qe as PAnnotationTrace,
1459
+ me as PColumnCollection,
1460
+ kt as PlErrorLike,
1461
+ vt as PlIdLength,
1462
+ N as RT_BINARY_PARTITIONED,
1463
+ M as RT_BINARY_SUPER_PARTITIONED,
1464
+ V as RT_JSON_PARTITIONED,
1465
+ Z as RT_JSON_SUPER_PARTITIONED,
1466
+ re as RT_RESOURCE_MAP,
1467
+ ie as RT_RESOURCE_MAP_PARTITIONED,
1468
+ z as RenderCtx,
1469
+ ut as ResultPool,
1470
+ Ot as StandardErrorLike,
1471
+ Ge as Trace,
1472
+ ze as TraceEntry,
1473
+ S as TreeNodeAccessor,
1474
+ $e as canonicalizeAxisId,
1475
+ tt as convertOrParsePColumnData,
1476
+ Ke as dataInfoToEntries,
1477
+ Pe as deriveLabels,
1478
+ Oe as deriveNativeId,
1479
+ te as downgradeCfgOrLambda,
1480
+ ke as ensurePColumn,
1481
+ De as entriesToDataInfo,
1482
+ Le as extractAllColumns,
1483
+ nt as filterDataInfoEntries,
1484
+ bt as getAxesId,
1485
+ pe as getAxisId,
1486
+ _t as getFileNameFromHandle,
1487
+ wt as getFilePathFromHandle,
1488
+ Q as getImmediate,
1489
+ Qe as getPartitionKeysList,
1490
+ gt as getRawPlatformaInstance,
1491
+ et as getUniquePartitionKeys,
1492
+ ne as ifDef,
1493
+ ct as isConfigLambda,
1494
+ ae as isDataInfo,
1495
+ be as isDataInfoEntries,
1496
+ Pt as isImportFileHandleIndex,
1497
+ xt as isImportFileHandleUpload,
1498
+ ve as isPColumn,
1499
+ G as isPColumnSpec,
1500
+ Re as isPartitionedDataInfoEntries,
1501
+ Te as isPlRef,
1502
+ Ne as mapDataInfo,
1503
+ At as mapJoinEntry,
1504
+ le as mapPObjectData,
1505
+ Ee as mapPTableDef,
1506
+ Fe as mapValueInVOE,
1507
+ It as matchAxis,
1508
+ St as matchAxisId,
1509
+ Ct as matchPColumn,
1510
+ oe as parsePColumnData,
1511
+ de as resolveAnchors,
1512
+ W as selectorsToPredicate,
1513
+ Lt as stringifyColumnId,
1514
+ ce as withEnrichments
33
1515
  };
34
1516
  //# sourceMappingURL=index.js.map