@milaboratories/milaboratories.ui-examples.model 1.0.38 → 1.0.40

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/bundle.js CHANGED
@@ -20,10 +20,10 @@
20
20
  return obj;
21
21
  };
22
22
  util2.getValidEnumValues = (obj) => {
23
- const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
23
+ const validKeys = util2.objectKeys(obj).filter((k2) => typeof obj[obj[k2]] !== "number");
24
24
  const filtered = {};
25
- for (const k of validKeys) {
26
- filtered[k] = obj[k];
25
+ for (const k2 of validKeys) {
26
+ filtered[k2] = obj[k2];
27
27
  }
28
28
  return util2.objectValues(filtered);
29
29
  };
@@ -368,7 +368,7 @@
368
368
  };
369
369
  }
370
370
  let errorMessage = "";
371
- const maps = errorMaps.filter((m2) => !!m2).slice().reverse();
371
+ const maps = errorMaps.filter((m) => !!m).slice().reverse();
372
372
  for (const map of maps) {
373
373
  errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
374
374
  }
@@ -458,12 +458,12 @@
458
458
  const isDirty = (x2) => x2.status === "dirty";
459
459
  const isValid = (x2) => x2.status === "valid";
460
460
  const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
461
- function __classPrivateFieldGet(receiver, state, kind, f2) {
462
- if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
461
+ function __classPrivateFieldGet(receiver, state, kind, f) {
462
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
463
463
  return state.get(receiver);
464
464
  }
465
- function __classPrivateFieldSet(receiver, state, value, kind, f2) {
466
- if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
465
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
466
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
467
467
  return state.set(receiver, value), value;
468
468
  }
469
469
  typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
@@ -2659,17 +2659,17 @@
2659
2659
  });
2660
2660
  }
2661
2661
  }
2662
- function mergeValues(a, b2) {
2662
+ function mergeValues(a, b) {
2663
2663
  const aType = getParsedType(a);
2664
- const bType = getParsedType(b2);
2665
- if (a === b2) {
2664
+ const bType = getParsedType(b);
2665
+ if (a === b) {
2666
2666
  return { valid: true, data: a };
2667
2667
  } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2668
- const bKeys = util.objectKeys(b2);
2668
+ const bKeys = util.objectKeys(b);
2669
2669
  const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2670
- const newObj = { ...a, ...b2 };
2670
+ const newObj = { ...a, ...b };
2671
2671
  for (const key of sharedKeys) {
2672
- const sharedValue = mergeValues(a[key], b2[key]);
2672
+ const sharedValue = mergeValues(a[key], b[key]);
2673
2673
  if (!sharedValue.valid) {
2674
2674
  return { valid: false };
2675
2675
  }
@@ -2677,13 +2677,13 @@
2677
2677
  }
2678
2678
  return { valid: true, data: newObj };
2679
2679
  } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2680
- if (a.length !== b2.length) {
2680
+ if (a.length !== b.length) {
2681
2681
  return { valid: false };
2682
2682
  }
2683
2683
  const newArray = [];
2684
2684
  for (let index = 0; index < a.length; index++) {
2685
2685
  const itemA = a[index];
2686
- const itemB = b2[index];
2686
+ const itemB = b[index];
2687
2687
  const sharedValue = mergeValues(itemA, itemB);
2688
2688
  if (!sharedValue.valid) {
2689
2689
  return { valid: false };
@@ -2691,7 +2691,7 @@
2691
2691
  newArray.push(sharedValue.data);
2692
2692
  }
2693
2693
  return { valid: true, data: newArray };
2694
- } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b2) {
2694
+ } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
2695
2695
  return { valid: true, data: a };
2696
2696
  } else {
2697
2697
  return { valid: false };
@@ -3662,10 +3662,10 @@
3662
3662
  }
3663
3663
  }
3664
3664
  }
3665
- static create(a, b2) {
3665
+ static create(a, b) {
3666
3666
  return new ZodPipeline({
3667
3667
  in: a,
3668
- out: b2,
3668
+ out: b,
3669
3669
  typeName: ZodFirstPartyTypeKind.ZodPipeline
3670
3670
  });
3671
3671
  }
@@ -3697,10 +3697,10 @@
3697
3697
  return ZodAny.create().superRefine((data, ctx) => {
3698
3698
  var _a, _b;
3699
3699
  if (!check(data)) {
3700
- const p2 = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3701
- const _fatal = (_b = (_a = p2.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3702
- const p22 = typeof p2 === "string" ? { message: p2 } : p2;
3703
- ctx.addIssue({ code: "custom", ...p22, fatal: _fatal });
3700
+ const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
3701
+ const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
3702
+ const p2 = typeof p === "string" ? { message: p } : p;
3703
+ ctx.addIssue({ code: "custom", ...p2, fatal: _fatal });
3704
3704
  }
3705
3705
  });
3706
3706
  return ZodAny.create();
@@ -3917,7 +3917,7 @@
3917
3917
  function c(n) {
3918
3918
  throw new Error("Unexpected object: " + n);
3919
3919
  }
3920
- function D(n, t) {
3920
+ function D$1(n, t) {
3921
3921
  return { ...n, src: i(n.src, t) };
3922
3922
  }
3923
3923
  function i(n, t) {
@@ -3955,104 +3955,108 @@
3955
3955
  function r(n) {
3956
3956
  return n.kind === "PColumn";
3957
3957
  }
3958
- function x$1(n) {
3958
+ function x(n) {
3959
3959
  return r(n.spec);
3960
3960
  }
3961
- function L$1(n, t) {
3961
+ function B(n) {
3962
+ if (!x(n)) throw new Error(`not a PColumn (kind = ${n.spec.kind})`);
3963
+ return n;
3964
+ }
3965
+ function L(n, t) {
3962
3966
  return n === void 0 ? void 0 : {
3963
3967
  ...n,
3964
3968
  data: t(n.data)
3965
3969
  };
3966
3970
  }
3967
- function O(n, t) {
3971
+ function O$1(n, t) {
3968
3972
  return n.ok ? { ok: true, value: t(n.value) } : n;
3969
3973
  }
3970
- var M = Object.defineProperty;
3971
- var U = (e, t, n) => t in e ? M(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
3972
- var f = (e, t, n) => U(e, typeof t != "symbol" ? t + "" : t, n);
3973
- function C(e) {
3974
+ var ct = Object.defineProperty;
3975
+ var dt = (e, t, n) => t in e ? ct(e, t, { enumerable: true, configurable: true, writable: true, value: n }) : e[t] = n;
3976
+ var _ = (e, t, n) => dt(e, typeof t != "symbol" ? t + "" : t, n);
3977
+ function k(e) {
3974
3978
  return { type: "Immediate", value: e };
3975
3979
  }
3976
- function K() {
3980
+ function _t() {
3977
3981
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
3978
3982
  }
3979
- function x(e) {
3983
+ function rt(e) {
3980
3984
  if (e && typeof globalThis.getPlatforma == "function")
3981
3985
  return globalThis.getPlatforma(e);
3982
3986
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
3983
3987
  throw new Error("Can't get platforma instance.");
3984
3988
  }
3985
- function W() {
3989
+ function vt() {
3986
3990
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
3987
3991
  }
3988
- function o() {
3992
+ function u() {
3989
3993
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
3990
3994
  throw new Error("Not in config rendering context");
3991
3995
  }
3992
- function _(e, t) {
3993
- const n = W();
3996
+ function O(e, t) {
3997
+ const n = vt();
3994
3998
  if (n === void 0) return false;
3995
3999
  if (e in n.callbackRegistry) throw new Error(`Callback with key ${e} already registered.`);
3996
4000
  return n.callbackRegistry[e] = t, true;
3997
4001
  }
3998
- const F = /* @__PURE__ */ new Map();
3999
- function q(e, t) {
4000
- e in o().callbackRegistry || (o().callbackRegistry[e] = (n) => {
4001
- for (const i2 of F.get(e))
4002
- i2(n);
4003
- }, F.set(e, [])), F.get(e).push(t);
4002
+ const N = /* @__PURE__ */ new Map();
4003
+ function wt(e, t) {
4004
+ e in u().callbackRegistry || (u().callbackRegistry[e] = (n) => {
4005
+ for (const r2 of N.get(e))
4006
+ r2(n);
4007
+ }, N.set(e, [])), N.get(e).push(t);
4004
4008
  }
4005
- class h {
4006
- constructor(t, n = (i2) => i2) {
4007
- f(this, "isResolved", false);
4008
- f(this, "resolvedValue");
4009
- this.handle = t, this.postProcess = n, q(t, (i2) => {
4010
- this.resolvedValue = n(i2), this.isResolved = true;
4009
+ class g {
4010
+ constructor(t, n = (r2) => r2) {
4011
+ _(this, "isResolved", false);
4012
+ _(this, "resolvedValue");
4013
+ this.handle = t, this.postProcess = n, wt(t, (r2) => {
4014
+ this.resolvedValue = n(r2), this.isResolved = true;
4011
4015
  });
4012
4016
  }
4013
4017
  map(t) {
4014
- return new h(this.handle, (n) => t(this.postProcess(n)));
4018
+ return new g(this.handle, (n) => t(this.postProcess(n)));
4015
4019
  }
4016
4020
  mapDefined(t) {
4017
- return new h(this.handle, (n) => {
4018
- const i2 = this.postProcess(n);
4019
- return i2 ? t(i2) : void 0;
4021
+ return new g(this.handle, (n) => {
4022
+ const r2 = this.postProcess(n);
4023
+ return r2 ? t(r2) : void 0;
4020
4024
  });
4021
4025
  }
4022
4026
  toJSON() {
4023
4027
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
4024
4028
  }
4025
4029
  }
4026
- function V(e) {
4027
- return e === void 0 ? void 0 : new m(e);
4030
+ function X(e) {
4031
+ return e === void 0 ? void 0 : new w(e);
4028
4032
  }
4029
- class m {
4033
+ class w {
4030
4034
  constructor(t) {
4031
4035
  this.handle = t;
4032
4036
  }
4033
4037
  resolve(...t) {
4034
4038
  const n = t.map(
4035
- (i2) => ({
4039
+ (r2) => ({
4036
4040
  assertFieldType: "Input",
4037
- ...typeof i2 == "string" ? { field: i2 } : i2
4041
+ ...typeof r2 == "string" ? { field: r2 } : r2
4038
4042
  })
4039
4043
  );
4040
4044
  return this.resolveWithCommon({}, ...n);
4041
4045
  }
4042
4046
  resolveOutput(...t) {
4043
4047
  const n = t.map(
4044
- (i2) => ({
4048
+ (r2) => ({
4045
4049
  assertFieldType: "Output",
4046
- ...typeof i2 == "string" ? { field: i2 } : i2
4050
+ ...typeof r2 == "string" ? { field: r2 } : r2
4047
4051
  })
4048
4052
  );
4049
4053
  return this.resolveWithCommon({}, ...n);
4050
4054
  }
4051
4055
  resolveInput(...t) {
4052
4056
  const n = t.map(
4053
- (i2) => ({
4057
+ (r2) => ({
4054
4058
  assertFieldType: "Input",
4055
- ...typeof i2 == "string" ? { field: i2 } : i2
4059
+ ...typeof r2 == "string" ? { field: r2 } : r2
4056
4060
  })
4057
4061
  );
4058
4062
  return this.resolveWithCommon({}, ...n);
@@ -4061,40 +4065,40 @@
4061
4065
  return this.resolveWithCommon({}, ...t);
4062
4066
  }
4063
4067
  resolveWithCommon(t, ...n) {
4064
- return V(o().resolveWithCommon(this.handle, t, ...n));
4068
+ return X(u().resolveWithCommon(this.handle, t, ...n));
4065
4069
  }
4066
4070
  get resourceType() {
4067
- return o().getResourceType(this.handle);
4071
+ return u().getResourceType(this.handle);
4068
4072
  }
4069
4073
  getInputsLocked() {
4070
- return o().getInputsLocked(this.handle);
4074
+ return u().getInputsLocked(this.handle);
4071
4075
  }
4072
4076
  getOutputsLocked() {
4073
- return o().getOutputsLocked(this.handle);
4077
+ return u().getOutputsLocked(this.handle);
4074
4078
  }
4075
4079
  getIsReadyOrError() {
4076
- return o().getIsReadyOrError(this.handle);
4080
+ return u().getIsReadyOrError(this.handle);
4077
4081
  }
4078
4082
  getIsFinal() {
4079
- return o().getIsFinal(this.handle);
4083
+ return u().getIsFinal(this.handle);
4080
4084
  }
4081
4085
  getError() {
4082
- return V(o().getError(this.handle));
4086
+ return X(u().getError(this.handle));
4083
4087
  }
4084
4088
  listInputFields() {
4085
- return o().listInputFields(this.handle);
4089
+ return u().listInputFields(this.handle);
4086
4090
  }
4087
4091
  listOutputFields() {
4088
- return o().listOutputFields(this.handle);
4092
+ return u().listOutputFields(this.handle);
4089
4093
  }
4090
4094
  listDynamicFields() {
4091
- return o().listDynamicFields(this.handle);
4095
+ return u().listDynamicFields(this.handle);
4092
4096
  }
4093
4097
  getKeyValueBase64(t) {
4094
- return o().getKeyValueBase64(this.handle, t);
4098
+ return u().getKeyValueBase64(this.handle, t);
4095
4099
  }
4096
4100
  getKeyValueAsString(t) {
4097
- return o().getKeyValueAsString(this.handle, t);
4101
+ return u().getKeyValueAsString(this.handle, t);
4098
4102
  }
4099
4103
  getKeyValueAsJson(t) {
4100
4104
  const n = this.getKeyValueAsString(t);
@@ -4102,10 +4106,10 @@
4102
4106
  return JSON.parse(n);
4103
4107
  }
4104
4108
  getDataBase64() {
4105
- return o().getDataBase64(this.handle);
4109
+ return u().getDataBase64(this.handle);
4106
4110
  }
4107
4111
  getDataAsString() {
4108
- return o().getDataAsString(this.handle);
4112
+ return u().getDataAsString(this.handle);
4109
4113
  }
4110
4114
  getDataAsJson() {
4111
4115
  const t = this.getDataAsString();
@@ -4116,36 +4120,36 @@
4116
4120
  *
4117
4121
  */
4118
4122
  getPColumns(t = false, n = "") {
4119
- const i2 = this.parsePObjectCollection(t, n);
4120
- return i2 === void 0 ? void 0 : Object.entries(i2).map(([, s]) => {
4121
- if (!x$1(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
4122
- return s;
4123
+ const r2 = this.parsePObjectCollection(t, n);
4124
+ return r2 === void 0 ? void 0 : Object.entries(r2).map(([, i2]) => {
4125
+ if (!x(i2)) throw new Error(`not a PColumn (kind = ${i2.spec.kind})`);
4126
+ return i2;
4123
4127
  });
4124
4128
  }
4125
4129
  /**
4126
4130
  *
4127
4131
  */
4128
4132
  parsePObjectCollection(t = false, n = "") {
4129
- const i2 = o().parsePObjectCollection(
4133
+ const r2 = u().parsePObjectCollection(
4130
4134
  this.handle,
4131
4135
  t,
4132
4136
  n
4133
4137
  );
4134
- if (i2 === void 0) return;
4135
- const r2 = {};
4136
- for (const [s, u] of Object.entries(i2))
4137
- r2[s] = L$1(u, (a) => new m(a));
4138
- return r2;
4138
+ if (r2 === void 0) return;
4139
+ const s = {};
4140
+ for (const [i2, o] of Object.entries(r2))
4141
+ s[i2] = L(o, (a) => new w(a));
4142
+ return s;
4139
4143
  }
4140
4144
  getFileContentAsBase64() {
4141
- return new h(o().getBlobContentAsBase64(this.handle));
4145
+ return new g(u().getBlobContentAsBase64(this.handle));
4142
4146
  }
4143
4147
  getFileContentAsString() {
4144
- return new h(o().getBlobContentAsString(this.handle));
4148
+ return new g(u().getBlobContentAsString(this.handle));
4145
4149
  }
4146
4150
  getFileContentAsJson() {
4147
- return new h(
4148
- o().getBlobContentAsString(this.handle)
4151
+ return new g(
4152
+ u().getBlobContentAsString(this.handle)
4149
4153
  ).mapDefined((t) => JSON.parse(t));
4150
4154
  }
4151
4155
  /**
@@ -4164,7 +4168,7 @@
4164
4168
  * @returns downloaded file handle
4165
4169
  */
4166
4170
  getFileHandle() {
4167
- return new h(o().getDownloadedBlobContentHandle(this.handle));
4171
+ return new g(u().getDownloadedBlobContentHandle(this.handle));
4168
4172
  }
4169
4173
  /**
4170
4174
  * @deprecated use getFileHandle
@@ -4176,7 +4180,7 @@
4176
4180
  * @returns downloaded file handle
4177
4181
  */
4178
4182
  getRemoteFileHandle() {
4179
- return new h(o().getOnDemandBlobContentHandle(this.handle));
4183
+ return new g(u().getOnDemandBlobContentHandle(this.handle));
4180
4184
  }
4181
4185
  /**
4182
4186
  * @deprecated use getRemoteFileHandle
@@ -4185,16 +4189,16 @@
4185
4189
  return this.getRemoteFileHandle();
4186
4190
  }
4187
4191
  getImportProgress() {
4188
- return new h(o().getImportProgress(this.handle));
4192
+ return new g(u().getImportProgress(this.handle));
4189
4193
  }
4190
4194
  getLastLogs(t) {
4191
- return new h(o().getLastLogs(this.handle, t));
4195
+ return new g(u().getLastLogs(this.handle, t));
4192
4196
  }
4193
4197
  getProgressLog(t) {
4194
- return new h(o().getProgressLog(this.handle, t));
4198
+ return new g(u().getProgressLog(this.handle, t));
4195
4199
  }
4196
4200
  getLogHandle() {
4197
- return new h(o().getLogHandle(this.handle));
4201
+ return new g(u().getLogHandle(this.handle));
4198
4202
  }
4199
4203
  allFieldsResolved(t = "Input") {
4200
4204
  switch (t) {
@@ -4209,27 +4213,84 @@
4209
4213
  }
4210
4214
  }
4211
4215
  mapFields(t, n) {
4212
- const { fieldType: i2, requireLocked: r2, skipUnresolved: s } = {
4216
+ const { fieldType: r2, requireLocked: s, skipUnresolved: i2 } = {
4213
4217
  fieldType: "Input",
4214
4218
  requireLocked: true,
4215
4219
  skipUnresolved: false,
4216
4220
  ...n
4217
- }, u = t;
4218
- if (r2 && (i2 === "Input" && !this.getInputsLocked() || i2 === "Output" && !this.getOutputsLocked()))
4221
+ }, o = t;
4222
+ if (s && (r2 === "Input" && !this.getInputsLocked() || r2 === "Output" && !this.getOutputsLocked()))
4219
4223
  return;
4220
- let d = (i2 === "Input" ? this.listInputFields() : i2 === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
4221
- (l) => [l, this.resolve({ field: l, assertFieldType: i2 })]
4224
+ let l = (r2 === "Input" ? this.listInputFields() : r2 === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
4225
+ (c2) => [c2, this.resolve({ field: c2, assertFieldType: r2 })]
4222
4226
  );
4223
- return s && (d = d.filter((l) => l[1] !== void 0)), d.map(([l, g]) => u(l, g));
4227
+ return i2 && (l = l.filter((c2) => c2[1] !== void 0)), l.map(([c2, f]) => o(c2, f));
4224
4228
  }
4225
4229
  }
4226
- const L = "staging", T = "main";
4227
- class Q {
4230
+ const st = "staging", it = "main";
4231
+ const At = "pl7.app/label", Pt = "pl7.app/trace", It = z.object({
4232
+ type: z.string(),
4233
+ importance: z.number().optional(),
4234
+ id: z.string().optional(),
4235
+ label: z.string()
4236
+ }), Ct = z.array(It), Tt = 1e-3, Rt = "__LABEL__", Q = "__LABEL__@1";
4237
+ function Ft(e, t, n = {}) {
4238
+ const r2 = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i2 = e.map((d) => {
4239
+ var z2, Y;
4240
+ const m = t(d), y = (z2 = m.annotations) == null ? void 0 : z2[At], F = (Y = m.annotations) == null ? void 0 : Y[Pt], b = (F ? Ct.safeParse(JSON.parse(F)).data : void 0) ?? [];
4241
+ y && b.splice(0, 0, { label: y, type: Rt, importance: -2 });
4242
+ const V = [], q = /* @__PURE__ */ new Map();
4243
+ for (let S = b.length - 1; S >= 0; --S) {
4244
+ const { type: E } = b[S], ut = b[S].importance ?? 0, j = (q.get(E) ?? 0) + 1;
4245
+ q.set(E, j);
4246
+ const I = `${E}@${j}`;
4247
+ s.set(I, (s.get(I) ?? 0) + 1), r2.set(
4248
+ I,
4249
+ Math.max(
4250
+ r2.get(I) ?? Number.NEGATIVE_INFINITY,
4251
+ ut - (b.length - S) * Tt
4252
+ )
4253
+ ), V.push({ ...b[S], fullType: I, occurenceIndex: j });
4254
+ }
4255
+ return V.reverse(), {
4256
+ value: d,
4257
+ spec: m,
4258
+ label: y,
4259
+ fullTrace: V
4260
+ };
4261
+ }), o = [], a = [], l = [...r2];
4262
+ l.sort(([, d], [, m]) => m - d);
4263
+ for (const [d] of l)
4264
+ d.endsWith("@1") || s.get(d) === e.length ? o.push(d) : a.push(d);
4265
+ const c2 = (d) => i2.map((m) => {
4266
+ const y = m.fullTrace.filter((b) => d.has(b.fullType)).map((b) => b.label), F = n.separator ?? " / ";
4267
+ return {
4268
+ label: y.join(F),
4269
+ value: m.value
4270
+ };
4271
+ });
4272
+ if (o.length === 0) {
4273
+ if (a.length !== 0) throw new Error("Assertion error.");
4274
+ return c2(new Set(Q));
4275
+ }
4276
+ let f = 0, v = 0;
4277
+ for (; f < o.length; ) {
4278
+ const d = /* @__PURE__ */ new Set();
4279
+ for (let y = 0; y < f; ++y) d.add(o[y]);
4280
+ d.add(o[v]);
4281
+ const m = c2(d);
4282
+ if (new Set(m.map((y) => y.label)).size === e.length)
4283
+ return n.includeNativeLabel ? (d.add(Q), c2(d)) : m;
4284
+ v++, v == o.length && (f++, v = f);
4285
+ }
4286
+ return c2(/* @__PURE__ */ new Set([...o, ...a]));
4287
+ }
4288
+ class Ot {
4228
4289
  constructor() {
4229
- f(this, "ctx", o());
4230
- f(this, "defaultLabelFn", (t, n) => {
4231
- var i2;
4232
- return ((i2 = t.annotations) == null ? void 0 : i2["pl7.app/label"]) ?? "Unlabelled";
4290
+ _(this, "ctx", u());
4291
+ _(this, "defaultLabelFn", (t, n) => {
4292
+ var r2;
4293
+ return ((r2 = t.annotations) == null ? void 0 : r2["pl7.app/label"]) ?? "Unlabelled";
4233
4294
  });
4234
4295
  }
4235
4296
  /**
@@ -4238,10 +4299,16 @@
4238
4299
  calculateOptions(t) {
4239
4300
  return this.ctx.calculateOptions(t);
4240
4301
  }
4241
- getOptions(t, n = this.defaultLabelFn) {
4242
- return this.getSpecs().entries.filter((i2) => t(i2.obj)).map((i2) => ({
4243
- ref: i2.ref,
4244
- label: n(i2.obj, i2.ref)
4302
+ getOptions(t, n) {
4303
+ const r2 = this.getSpecs().entries.filter((s) => t(s.obj));
4304
+ return typeof n == "object" || typeof n > "u" ? Ft(r2, (s) => s.obj, n ?? {}).map(
4305
+ ({ value: { ref: s }, label: i2 }) => ({
4306
+ ref: s,
4307
+ label: i2
4308
+ })
4309
+ ) : r2.map((s) => ({
4310
+ ref: s.ref,
4311
+ label: n(s.obj, s.ref)
4245
4312
  }));
4246
4313
  }
4247
4314
  /**
@@ -4258,7 +4325,7 @@
4258
4325
  ref: n.ref,
4259
4326
  obj: {
4260
4327
  ...n.obj,
4261
- data: new m(n.obj.data)
4328
+ data: new w(n.obj.data)
4262
4329
  }
4263
4330
  }))
4264
4331
  };
@@ -4277,7 +4344,7 @@
4277
4344
  ref: n.ref,
4278
4345
  obj: {
4279
4346
  ...n.obj,
4280
- data: O(n.obj.data, (i2) => new m(i2))
4347
+ data: O$1(n.obj.data, (r2) => new w(r2))
4281
4348
  }
4282
4349
  }))
4283
4350
  };
@@ -4298,12 +4365,22 @@
4298
4365
  getDataByRef(t) {
4299
4366
  var n;
4300
4367
  return typeof this.ctx.getDataFromResultPoolByRef > "u" ? (n = this.getData().entries.find(
4301
- (i2) => i2.ref.blockId === t.blockId && i2.ref.name === t.name
4302
- )) == null ? void 0 : n.obj : L$1(
4368
+ (r2) => r2.ref.blockId === t.blockId && r2.ref.name === t.name
4369
+ )) == null ? void 0 : n.obj : L(
4303
4370
  this.ctx.getDataFromResultPoolByRef(t.blockId, t.name),
4304
- (i2) => new m(i2)
4371
+ (r2) => new w(r2)
4305
4372
  );
4306
4373
  }
4374
+ /**
4375
+ * Returns data associated with the ref ensuring that it is a p-column.
4376
+ * @param ref a Ref
4377
+ * @returns p-column associated with the ref
4378
+ */
4379
+ getPColumnByRef(t) {
4380
+ const n = this.getDataByRef(t);
4381
+ if (n)
4382
+ return B(n);
4383
+ }
4307
4384
  /**
4308
4385
  * @param ref a Ref
4309
4386
  * @returns object spec associated with the ref
@@ -4311,52 +4388,53 @@
4311
4388
  getSpecByRef(t) {
4312
4389
  var n;
4313
4390
  return typeof this.ctx.getSpecFromResultPoolByRef > "u" ? (n = this.getSpecs().entries.find(
4314
- (i2) => i2.ref.blockId === t.blockId && i2.ref.name === t.name
4391
+ (r2) => r2.ref.blockId === t.blockId && r2.ref.name === t.name
4315
4392
  )) == null ? void 0 : n.obj : this.ctx.getSpecFromResultPoolByRef(t.blockId, t.name);
4316
4393
  }
4317
4394
  /**
4318
4395
  * @param spec object specification
4319
4396
  * @returns array of data objects with compatible specs
4397
+ * @deprecated delete this method after Jan 1, 2025
4320
4398
  */
4321
4399
  findDataWithCompatibleSpec(t) {
4322
4400
  const n = [];
4323
- t: for (const i2 of this.getData().entries) {
4324
- if (!r(i2.obj.spec))
4401
+ t: for (const r$1 of this.getData().entries) {
4402
+ if (!r(r$1.obj.spec))
4325
4403
  continue;
4326
- const r$1 = i2.obj.spec;
4327
- if (t.name === r$1.name && t.valueType === r$1.valueType && t.axesSpec.length === r$1.axesSpec.length && P(t.domain, r$1.domain)) {
4328
- for (let s = 0; s < t.axesSpec.length; ++s) {
4329
- const u = t.axesSpec[s], a = r$1.axesSpec[s];
4330
- if (u.name !== a.name || u.type !== a.type || !P(u.domain, a.domain))
4404
+ const s = r$1.obj.spec;
4405
+ if (t.name === s.name && t.valueType === s.valueType && t.axesSpec.length === s.axesSpec.length && K(t.domain, s.domain)) {
4406
+ for (let i2 = 0; i2 < t.axesSpec.length; ++i2) {
4407
+ const o = t.axesSpec[i2], a = s.axesSpec[i2];
4408
+ if (o.name !== a.name || o.type !== a.type || !K(o.domain, a.domain))
4331
4409
  continue t;
4332
4410
  }
4333
- n.push(i2.obj);
4411
+ n.push(r$1.obj);
4334
4412
  }
4335
4413
  }
4336
4414
  return n;
4337
4415
  }
4338
4416
  }
4339
- function P(e, t) {
4417
+ function K(e, t) {
4340
4418
  if (e === void 0) return t === void 0;
4341
4419
  if (t === void 0) return true;
4342
4420
  for (const n in t)
4343
4421
  if (e[n] !== t[n]) return false;
4344
4422
  return true;
4345
4423
  }
4346
- class w {
4424
+ class D {
4347
4425
  constructor() {
4348
- f(this, "ctx");
4349
- f(this, "args");
4350
- f(this, "uiState");
4351
- f(this, "resultPool", new Q());
4352
- this.ctx = o(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : void 0;
4426
+ _(this, "ctx");
4427
+ _(this, "args");
4428
+ _(this, "uiState");
4429
+ _(this, "resultPool", new Ot());
4430
+ this.ctx = u(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : void 0;
4353
4431
  }
4354
4432
  getNamedAccessor(t) {
4355
4433
  const n = this.ctx.getAccessorHandleByName(t);
4356
- return n ? new m(n) : void 0;
4434
+ return n ? new w(n) : void 0;
4357
4435
  }
4358
4436
  get prerun() {
4359
- return this.getNamedAccessor(L);
4437
+ return this.getNamedAccessor(st);
4360
4438
  }
4361
4439
  /**
4362
4440
  * @deprecated use prerun
@@ -4371,7 +4449,7 @@
4371
4449
  return this.precalc;
4372
4450
  }
4373
4451
  get outputs() {
4374
- return this.getNamedAccessor(T);
4452
+ return this.getNamedAccessor(it);
4375
4453
  }
4376
4454
  /**
4377
4455
  * @deprecated use outputs
@@ -4379,19 +4457,39 @@
4379
4457
  get mainOutput() {
4380
4458
  return this.outputs;
4381
4459
  }
4460
+ /**
4461
+ * Find labels data for a given axis id. It will search for a label column and return its data as a map.
4462
+ * @returns a map of axis value => label
4463
+ */
4464
+ findLabels(t) {
4465
+ const n = this.resultPool.getData();
4466
+ for (const r2 of n.entries) {
4467
+ if (!x(r2.obj)) continue;
4468
+ const s = r2.obj.spec;
4469
+ if (s.name === "pl7.app/label" && s.axesSpec.length === 1 && s.axesSpec[0].name === t.name && s.axesSpec[0].type === t.type && K(t.domain, s.axesSpec[0].domain)) {
4470
+ if (r2.obj.data.resourceType.name !== "PColumnData/Json")
4471
+ throw Error(`Expected JSON column for labels, got: ${r2.obj.data.resourceType.name}`);
4472
+ return new Map(
4473
+ Object.entries(
4474
+ r2.obj.data.getDataAsJson().data
4475
+ ).map((o) => [JSON.parse(o[0])[0], o[1]])
4476
+ );
4477
+ }
4478
+ }
4479
+ }
4382
4480
  createPFrame(t) {
4383
- return this.ctx.createPFrame(t.map((n) => L$1(n, (i2) => i2.handle)));
4481
+ return this.ctx.createPFrame(t.map((n) => L(n, (r2) => r2.handle)));
4384
4482
  }
4385
4483
  createPTable(t) {
4386
4484
  var n;
4387
4485
  return "columns" in t ? n = {
4388
4486
  src: {
4389
- type: "inner",
4390
- entries: t.columns.map((i2) => ({ type: "column", column: i2 }))
4487
+ type: "full",
4488
+ entries: t.columns.map((r2) => ({ type: "column", column: r2 }))
4391
4489
  },
4392
4490
  filters: t.filters ?? [],
4393
4491
  sorting: t.sorting ?? []
4394
- } : n = t, this.ctx.createPTable(D(n, (i2) => L$1(i2, (r2) => r2.handle)));
4492
+ } : n = t, this.ctx.createPTable(D$1(n, (r2) => L(r2, (s) => s.handle)));
4395
4493
  }
4396
4494
  /** @deprecated scheduled for removal from SDK */
4397
4495
  getBlockLabel(t) {
@@ -4402,33 +4500,33 @@
4402
4500
  return this.ctx.getCurrentUnstableMarker();
4403
4501
  }
4404
4502
  }
4405
- const b = "1.10.12";
4406
- function Z(e) {
4503
+ const C = "1.13.0";
4504
+ function kt(e) {
4407
4505
  return e.__renderLambda === true;
4408
4506
  }
4409
- function I(e) {
4507
+ function U(e) {
4410
4508
  if (e !== void 0)
4411
- return Z(e) ? e.handle : e;
4509
+ return kt(e) ? e.handle : e;
4412
4510
  }
4413
- class p {
4414
- constructor(t, n, i2, r2, s, u, a) {
4415
- this._renderingMode = t, this._initialArgs = n, this._initialUiState = i2, this._outputs = r2, this._inputsValid = s, this._sections = u, this._title = a;
4511
+ class h {
4512
+ constructor(t, n, r2, s, i2, o, a) {
4513
+ this._renderingMode = t, this._initialArgs = n, this._initialUiState = r2, this._outputs = s, this._inputsValid = i2, this._sections = o, this._title = a;
4416
4514
  }
4417
4515
  static create(t = "Heavy") {
4418
- return new p(
4516
+ return new h(
4419
4517
  t,
4420
4518
  void 0,
4421
4519
  {},
4422
4520
  {},
4423
- C(true),
4424
- C([]),
4521
+ k(true),
4522
+ k([]),
4425
4523
  void 0
4426
4524
  );
4427
4525
  }
4428
- output(t, n, i2 = {}) {
4526
+ output(t, n, r2 = {}) {
4429
4527
  if (typeof n == "function") {
4430
- const r2 = `output#${t}`;
4431
- return _(r2, () => n(new w())), new p(
4528
+ const s = `output#${t}`;
4529
+ return O(s, () => n(new D())), new h(
4432
4530
  this._renderingMode,
4433
4531
  this._initialArgs,
4434
4532
  this._initialUiState,
@@ -4436,8 +4534,8 @@
4436
4534
  ...this._outputs,
4437
4535
  [t]: {
4438
4536
  __renderLambda: true,
4439
- handle: r2,
4440
- ...i2
4537
+ handle: s,
4538
+ ...r2
4441
4539
  }
4442
4540
  },
4443
4541
  this._inputsValid,
@@ -4445,7 +4543,7 @@
4445
4543
  this._title
4446
4544
  );
4447
4545
  } else
4448
- return new p(
4546
+ return new h(
4449
4547
  this._renderingMode,
4450
4548
  this._initialArgs,
4451
4549
  this._initialUiState,
@@ -4467,7 +4565,7 @@
4467
4565
  return this.inputsValid(t);
4468
4566
  }
4469
4567
  argsValid(t) {
4470
- return typeof t == "function" ? (_("inputsValid", () => t(new w())), new p(
4568
+ return typeof t == "function" ? (O("inputsValid", () => t(new D())), new h(
4471
4569
  this._renderingMode,
4472
4570
  this._initialArgs,
4473
4571
  this._initialUiState,
@@ -4478,7 +4576,7 @@
4478
4576
  },
4479
4577
  this._sections,
4480
4578
  this._title
4481
- )) : new p(
4579
+ )) : new h(
4482
4580
  this._renderingMode,
4483
4581
  this._initialArgs,
4484
4582
  this._initialUiState,
@@ -4492,7 +4590,7 @@
4492
4590
  return this.argsValid(t);
4493
4591
  }
4494
4592
  sections(t) {
4495
- return Array.isArray(t) ? this.sections(C(t)) : typeof t == "function" ? (_("sections", () => t(new w())), new p(
4593
+ return Array.isArray(t) ? this.sections(k(t)) : typeof t == "function" ? (O("sections", () => t(new D())), new h(
4496
4594
  this._renderingMode,
4497
4595
  this._initialArgs,
4498
4596
  this._initialUiState,
@@ -4500,7 +4598,7 @@
4500
4598
  this._inputsValid,
4501
4599
  { __renderLambda: true, handle: "sections" },
4502
4600
  this._title
4503
- )) : new p(
4601
+ )) : new h(
4504
4602
  this._renderingMode,
4505
4603
  this._initialArgs,
4506
4604
  this._initialUiState,
@@ -4511,7 +4609,7 @@
4511
4609
  );
4512
4610
  }
4513
4611
  title(t) {
4514
- return _("title", () => t(new w())), new p(
4612
+ return O("title", () => t(new D())), new h(
4515
4613
  this._renderingMode,
4516
4614
  this._initialArgs,
4517
4615
  this._initialUiState,
@@ -4526,7 +4624,7 @@
4526
4624
  * @deprecated use {@link withArgs}
4527
4625
  * */
4528
4626
  initialArgs(t) {
4529
- return new p(
4627
+ return new h(
4530
4628
  this._renderingMode,
4531
4629
  t,
4532
4630
  this._initialUiState,
@@ -4538,7 +4636,7 @@
4538
4636
  }
4539
4637
  /** Sets initial args for the block, this value must be specified. */
4540
4638
  withArgs(t) {
4541
- return new p(
4639
+ return new h(
4542
4640
  this._renderingMode,
4543
4641
  t,
4544
4642
  this._initialUiState,
@@ -4550,7 +4648,7 @@
4550
4648
  }
4551
4649
  /** Defines type and sets initial value for block UiState. */
4552
4650
  withUiState(t) {
4553
- return new p(
4651
+ return new h(
4554
4652
  this._renderingMode,
4555
4653
  this._initialArgs,
4556
4654
  t,
@@ -4567,7 +4665,7 @@
4567
4665
  if (this._initialArgs === void 0) throw new Error("Initial arguments not set.");
4568
4666
  const t = {
4569
4667
  v3: {
4570
- sdkVersion: b,
4668
+ sdkVersion: C,
4571
4669
  renderingMode: this._renderingMode,
4572
4670
  initialArgs: this._initialArgs,
4573
4671
  initialUiState: this._initialUiState,
@@ -4577,29 +4675,29 @@
4577
4675
  outputs: this._outputs
4578
4676
  },
4579
4677
  // fields below are added to allow previous desktop versions read generated configs
4580
- sdkVersion: b,
4678
+ sdkVersion: C,
4581
4679
  renderingMode: this._renderingMode,
4582
4680
  initialArgs: this._initialArgs,
4583
- inputsValid: I(this._inputsValid),
4584
- sections: I(this._sections),
4681
+ inputsValid: U(this._inputsValid),
4682
+ sections: U(this._sections),
4585
4683
  outputs: Object.fromEntries(
4586
- Object.entries(this._outputs).map(([n, i2]) => [n, I(i2)])
4684
+ Object.entries(this._outputs).map(([n, r2]) => [n, U(r2)])
4587
4685
  )
4588
4686
  };
4589
- return K() ? x({ sdkVersion: b }) : { config: t };
4687
+ return _t() ? rt({ sdkVersion: C }) : { config: t };
4590
4688
  }
4591
4689
  }
4592
4690
  const $BlockArgs = z.object({
4593
4691
  numbers: z.array(z.coerce.number())
4594
4692
  });
4595
- const platforma = p.create("Heavy").withArgs({ numbers: [1, 2, 3] }).withUiState({ dataTableState: void 0 }).output("numbers", (ctx) => {
4693
+ const platforma = h.create("Heavy").withArgs({ numbers: [1, 2, 3] }).withUiState({ dataTableState: void 0 }).output("numbers", (ctx) => {
4596
4694
  var _a, _b;
4597
4695
  return (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve("numbers")) == null ? void 0 : _b.getDataAsJson();
4598
4696
  }).output("pFrame", (ctx) => {
4599
4697
  const collection = ctx.resultPool.getData();
4600
4698
  if (collection === void 0 || !collection.isComplete) return void 0;
4601
4699
  const valueTypes = ["Int", "Long", "Float", "Double", "String", "Bytes"];
4602
- const columns = collection.entries.map(({ obj }) => obj).filter(x$1).filter((column) => valueTypes.find((valueType) => valueType === column.spec.valueType));
4700
+ const columns = collection.entries.map(({ obj }) => obj).filter(x).filter((column) => valueTypes.find((valueType) => valueType === column.spec.valueType));
4603
4701
  try {
4604
4702
  return ctx.createPFrame(columns);
4605
4703
  } catch (err) {
@@ -4611,11 +4709,11 @@
4611
4709
  if (!join) return void 0;
4612
4710
  const collection = ctx.resultPool.getData();
4613
4711
  if (!collection || !collection.isComplete) return void 0;
4614
- const columns = collection.entries.map(({ obj }) => obj).filter(x$1);
4712
+ const columns = collection.entries.map(({ obj }) => obj).filter(x);
4615
4713
  if (columns.length === 0) return void 0;
4616
4714
  let columnMissing = false;
4617
4715
  const src = i(join, (idAndSpec) => {
4618
- const column = columns.find((it) => it.id === idAndSpec.columnId);
4716
+ const column = columns.find((it2) => it2.id === idAndSpec.columnId);
4619
4717
  if (!column) columnMissing = true;
4620
4718
  return column;
4621
4719
  });