@milaboratories/milaboratories.ui-examples.model 1.1.13 → 1.1.15

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
@@ -4006,17 +4006,17 @@
4006
4006
  const Q = 24;
4007
4007
  z.string().length(Q).regex(/[ABCDEFGHIJKLMNOPQRSTUVWXYZ234567]/).brand("PlId");
4008
4008
  var fe = Object.defineProperty;
4009
- var he = (n, e, t) => e in n ? fe(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t;
4010
- var w = (n, e, t) => he(n, typeof e != "symbol" ? e + "" : e, t);
4011
- function V(n) {
4012
- return { type: "Immediate", value: n };
4009
+ var he = (t, e, n) => e in t ? fe(t, e, { enumerable: true, configurable: true, writable: true, value: n }) : t[e] = n;
4010
+ var S = (t, e, n) => he(t, typeof e != "symbol" ? e + "" : e, n);
4011
+ function V(t) {
4012
+ return { type: "Immediate", value: t };
4013
4013
  }
4014
4014
  function Se() {
4015
4015
  return typeof globalThis.getPlatforma < "u" || typeof globalThis.platforma < "u";
4016
4016
  }
4017
- function oe(n) {
4018
- if (n && typeof globalThis.getPlatforma == "function")
4019
- return globalThis.getPlatforma(n);
4017
+ function oe(t) {
4018
+ if (t && typeof globalThis.getPlatforma == "function")
4019
+ return globalThis.getPlatforma(t);
4020
4020
  if (typeof globalThis.platforma < "u") return globalThis.platforma;
4021
4021
  throw new Error("Can't get platforma instance.");
4022
4022
  }
@@ -4027,33 +4027,33 @@
4027
4027
  if (typeof globalThis.cfgRenderCtx < "u") return globalThis.cfgRenderCtx;
4028
4028
  throw new Error("Not in config rendering context");
4029
4029
  }
4030
- function E(n, e) {
4031
- const t = we();
4032
- if (t === void 0) return false;
4033
- if (n in t.callbackRegistry) throw new Error(`Callback with key ${n} already registered.`);
4034
- return t.callbackRegistry[n] = e, true;
4030
+ function L(t, e) {
4031
+ const n = we();
4032
+ if (n === void 0) return false;
4033
+ if (t in n.callbackRegistry) throw new Error(`Callback with key ${t} already registered.`);
4034
+ return n.callbackRegistry[t] = e, true;
4035
4035
  }
4036
4036
  const J = /* @__PURE__ */ new Map();
4037
- function Ce(n, e) {
4038
- n in c().callbackRegistry || (c().callbackRegistry[n] = (t) => {
4039
- for (const r of J.get(n))
4040
- r(t);
4041
- }, J.set(n, [])), J.get(n).push(e);
4037
+ function Ae(t, e) {
4038
+ t in c().callbackRegistry || (c().callbackRegistry[t] = (n) => {
4039
+ for (const r of J.get(t))
4040
+ r(n);
4041
+ }, J.set(t, [])), J.get(t).push(e);
4042
4042
  }
4043
- class _ {
4044
- constructor(e, t = (r) => r) {
4045
- w(this, "isResolved", false);
4046
- w(this, "resolvedValue");
4047
- this.handle = e, this.postProcess = t, Ce(e, (r) => {
4048
- this.resolvedValue = t(r), this.isResolved = true;
4043
+ class b {
4044
+ constructor(e, n = (r) => r) {
4045
+ S(this, "isResolved", false);
4046
+ S(this, "resolvedValue");
4047
+ this.handle = e, this.postProcess = n, Ae(e, (r) => {
4048
+ this.resolvedValue = n(r), this.isResolved = true;
4049
4049
  });
4050
4050
  }
4051
4051
  map(e) {
4052
- return new _(this.handle, (t) => e(this.postProcess(t)));
4052
+ return new b(this.handle, (n) => e(this.postProcess(n)));
4053
4053
  }
4054
4054
  mapDefined(e) {
4055
- return new _(this.handle, (t) => {
4056
- const r = this.postProcess(t);
4055
+ return new b(this.handle, (n) => {
4056
+ const r = this.postProcess(n);
4057
4057
  return r ? e(r) : void 0;
4058
4058
  });
4059
4059
  }
@@ -4061,51 +4061,51 @@
4061
4061
  return this.isResolved ? this.resolvedValue : { __awaited_futures__: [this.handle] };
4062
4062
  }
4063
4063
  }
4064
- function H(n, e) {
4065
- return n === void 0 ? void 0 : e(n);
4064
+ function H(t, e) {
4065
+ return t === void 0 ? void 0 : e(t);
4066
4066
  }
4067
- class b {
4068
- constructor(e, t) {
4069
- this.handle = e, this.resolvePath = t;
4067
+ class v {
4068
+ constructor(e, n) {
4069
+ this.handle = e, this.resolvePath = n;
4070
4070
  }
4071
4071
  resolve(...e) {
4072
- const t = e.map(
4072
+ const n = e.map(
4073
4073
  (r) => ({
4074
4074
  assertFieldType: "Input",
4075
4075
  ...typeof r == "string" ? { field: r } : r
4076
4076
  })
4077
4077
  );
4078
- return this.resolveWithCommon({}, ...t);
4078
+ return this.resolveWithCommon({}, ...n);
4079
4079
  }
4080
4080
  resolveOutput(...e) {
4081
- const t = e.map(
4081
+ const n = e.map(
4082
4082
  (r) => ({
4083
4083
  assertFieldType: "Output",
4084
4084
  ...typeof r == "string" ? { field: r } : r
4085
4085
  })
4086
4086
  );
4087
- return this.resolveWithCommon({}, ...t);
4087
+ return this.resolveWithCommon({}, ...n);
4088
4088
  }
4089
4089
  resolveInput(...e) {
4090
- const t = e.map(
4090
+ const n = e.map(
4091
4091
  (r) => ({
4092
4092
  assertFieldType: "Input",
4093
4093
  ...typeof r == "string" ? { field: r } : r
4094
4094
  })
4095
4095
  );
4096
- return this.resolveWithCommon({}, ...t);
4096
+ return this.resolveWithCommon({}, ...n);
4097
4097
  }
4098
4098
  resolveAny(...e) {
4099
4099
  return this.resolveWithCommon({}, ...e);
4100
4100
  }
4101
- resolveWithCommon(e, ...t) {
4101
+ resolveWithCommon(e, ...n) {
4102
4102
  const r = [
4103
4103
  ...this.resolvePath,
4104
- ...t.map((s) => typeof s == "string" ? s : s.field)
4104
+ ...n.map((i2) => typeof i2 == "string" ? i2 : i2.field)
4105
4105
  ];
4106
4106
  return H(
4107
- c().resolveWithCommon(this.handle, e, ...t),
4108
- (s) => new b(s, r)
4107
+ c().resolveWithCommon(this.handle, e, ...n),
4108
+ (i2) => new v(i2, r)
4109
4109
  );
4110
4110
  }
4111
4111
  get resourceType() {
@@ -4127,7 +4127,7 @@
4127
4127
  const e = [...this.resolvePath, "error"];
4128
4128
  return H(
4129
4129
  c().getError(this.handle),
4130
- (t) => new b(t, e)
4130
+ (n) => new v(n, e)
4131
4131
  );
4132
4132
  }
4133
4133
  listInputFields() {
@@ -4146,9 +4146,9 @@
4146
4146
  return c().getKeyValueAsString(this.handle, e);
4147
4147
  }
4148
4148
  getKeyValueAsJson(e) {
4149
- const t = this.getKeyValueAsString(e);
4150
- if (t == null) throw new Error("Resource has no content.");
4151
- return JSON.parse(t);
4149
+ const n = this.getKeyValueAsString(e);
4150
+ if (n == null) throw new Error("Resource has no content.");
4151
+ return JSON.parse(n);
4152
4152
  }
4153
4153
  getDataBase64() {
4154
4154
  return c().getDataBase64(this.handle);
@@ -4164,39 +4164,39 @@
4164
4164
  /**
4165
4165
  *
4166
4166
  */
4167
- getPColumns(e = false, t = "") {
4168
- const r = this.parsePObjectCollection(e, t);
4169
- return r === void 0 ? void 0 : Object.entries(r).map(([, i2]) => {
4170
- if (!W(i2)) throw new Error(`not a PColumn (kind = ${i2.spec.kind})`);
4171
- return i2;
4167
+ getPColumns(e = false, n = "") {
4168
+ const r = this.parsePObjectCollection(e, n);
4169
+ return r === void 0 ? void 0 : Object.entries(r).map(([, s]) => {
4170
+ if (!W(s)) throw new Error(`not a PColumn (kind = ${s.spec.kind})`);
4171
+ return s;
4172
4172
  });
4173
4173
  }
4174
4174
  /**
4175
4175
  *
4176
4176
  */
4177
- parsePObjectCollection(e = false, t = "") {
4177
+ parsePObjectCollection(e = false, n = "") {
4178
4178
  const r = c().parsePObjectCollection(
4179
4179
  this.handle,
4180
4180
  e,
4181
- t,
4181
+ n,
4182
4182
  ...this.resolvePath
4183
4183
  );
4184
4184
  if (r === void 0) return;
4185
- const s = {};
4186
- for (const [i2, o] of Object.entries(r)) {
4187
- const l = [...this.resolvePath, i2];
4188
- s[i2] = lt(o, (a) => new b(a, l));
4185
+ const i2 = {};
4186
+ for (const [s, o] of Object.entries(r)) {
4187
+ const l = [...this.resolvePath, s];
4188
+ i2[s] = lt(o, (a) => new v(a, l));
4189
4189
  }
4190
- return s;
4190
+ return i2;
4191
4191
  }
4192
4192
  getFileContentAsBase64() {
4193
- return new _(c().getBlobContentAsBase64(this.handle));
4193
+ return new b(c().getBlobContentAsBase64(this.handle));
4194
4194
  }
4195
4195
  getFileContentAsString() {
4196
- return new _(c().getBlobContentAsString(this.handle));
4196
+ return new b(c().getBlobContentAsString(this.handle));
4197
4197
  }
4198
4198
  getFileContentAsJson() {
4199
- return new _(
4199
+ return new b(
4200
4200
  c().getBlobContentAsString(this.handle)
4201
4201
  ).mapDefined((e) => JSON.parse(e));
4202
4202
  }
@@ -4216,7 +4216,7 @@
4216
4216
  * @returns downloaded file handle
4217
4217
  */
4218
4218
  getFileHandle() {
4219
- return new _(c().getDownloadedBlobContentHandle(this.handle));
4219
+ return new b(c().getDownloadedBlobContentHandle(this.handle));
4220
4220
  }
4221
4221
  /**
4222
4222
  * @deprecated use getFileHandle
@@ -4228,7 +4228,7 @@
4228
4228
  * @returns downloaded file handle
4229
4229
  */
4230
4230
  getRemoteFileHandle() {
4231
- return new _(c().getOnDemandBlobContentHandle(this.handle));
4231
+ return new b(c().getOnDemandBlobContentHandle(this.handle));
4232
4232
  }
4233
4233
  /**
4234
4234
  * @deprecated use getRemoteFileHandle
@@ -4236,72 +4236,78 @@
4236
4236
  getOnDemandBlobHandle() {
4237
4237
  return this.getRemoteFileHandle();
4238
4238
  }
4239
+ /**
4240
+ * @returns the url to the extracted folder
4241
+ */
4242
+ extractArchiveAndGetURL(e) {
4243
+ return new b(c().extractArchiveAndGetURL(this.handle, e));
4244
+ }
4239
4245
  getImportProgress() {
4240
- return new _(c().getImportProgress(this.handle));
4246
+ return new b(c().getImportProgress(this.handle));
4241
4247
  }
4242
4248
  getLastLogs(e) {
4243
- return new _(c().getLastLogs(this.handle, e));
4249
+ return new b(c().getLastLogs(this.handle, e));
4244
4250
  }
4245
4251
  getProgressLog(e) {
4246
- return new _(c().getProgressLog(this.handle, e));
4252
+ return new b(c().getProgressLog(this.handle, e));
4247
4253
  }
4248
4254
  getLogHandle() {
4249
- return new _(c().getLogHandle(this.handle));
4255
+ return new b(c().getLogHandle(this.handle));
4250
4256
  }
4251
4257
  allFieldsResolved(e = "Input") {
4252
4258
  switch (e) {
4253
4259
  case "Input":
4254
4260
  return this.getInputsLocked() && this.listInputFields().every(
4255
- (t) => this.resolve({ field: t, assertFieldType: "Input" }) !== void 0
4261
+ (n) => this.resolve({ field: n, assertFieldType: "Input" }) !== void 0
4256
4262
  );
4257
4263
  case "Output":
4258
4264
  return this.getOutputsLocked() && this.listOutputFields().every(
4259
- (t) => this.resolve({ field: t, assertFieldType: "Output" }) !== void 0
4265
+ (n) => this.resolve({ field: n, assertFieldType: "Output" }) !== void 0
4260
4266
  );
4261
4267
  }
4262
4268
  }
4263
- mapFields(e, t) {
4264
- const { fieldType: r, requireLocked: s, skipUnresolved: i2 } = {
4269
+ mapFields(e, n) {
4270
+ const { fieldType: r, requireLocked: i2, skipUnresolved: s } = {
4265
4271
  fieldType: "Input",
4266
4272
  requireLocked: true,
4267
4273
  skipUnresolved: false,
4268
- ...t
4274
+ ...n
4269
4275
  }, o = e;
4270
- if (s && (r === "Input" && !this.getInputsLocked() || r === "Output" && !this.getOutputsLocked()))
4276
+ if (i2 && (r === "Input" && !this.getInputsLocked() || r === "Output" && !this.getOutputsLocked()))
4271
4277
  return;
4272
4278
  let a = (r === "Input" ? this.listInputFields() : r === "Output" ? this.listOutputFields() : this.listDynamicFields()).map(
4273
4279
  (u) => [u, this.resolve({ field: u, assertFieldType: r })]
4274
4280
  );
4275
- return i2 && (a = a.filter((u) => u[1] !== void 0)), a.map(([u, h]) => o(u, h));
4281
+ return s && (a = a.filter((u) => u[1] !== void 0)), a.map(([u, h]) => o(u, h));
4276
4282
  }
4277
4283
  }
4278
4284
  const ae = "staging", le = "main";
4279
- const Ie = "pl7.app/label", Fe = "pl7.app/trace", Re = z.object({
4285
+ const Ie = "pl7.app/label", Re = "pl7.app/trace", Fe = z.object({
4280
4286
  type: z.string(),
4281
4287
  importance: z.number().optional(),
4282
4288
  id: z.string().optional(),
4283
4289
  label: z.string()
4284
- }), Oe = z.array(Re), Te = 1e-3, ke = "__LABEL__", ee = "__LABEL__@1";
4285
- function xe(n, e, t = {}) {
4286
- const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i2 = n.map((p) => {
4287
- var F, Q2;
4288
- const g = e(p), f2 = (F = g.annotations) == null ? void 0 : F[Ie], C = (Q2 = g.annotations) == null ? void 0 : Q2[Fe], y = (C ? Oe.safeParse(JSON.parse(C)).data : void 0) ?? [];
4290
+ }), xe = z.array(Fe), Te = 1e-3, Oe = "__LABEL__", ee = "__LABEL__@1";
4291
+ function ke(t, e, n = {}) {
4292
+ const r = /* @__PURE__ */ new Map(), i2 = /* @__PURE__ */ new Map(), s = t.map((p) => {
4293
+ var R, Q2;
4294
+ const g = e(p), f2 = (R = g.annotations) == null ? void 0 : R[Ie], A = (Q2 = g.annotations) == null ? void 0 : Q2[Re], y = (A ? xe.safeParse(JSON.parse(A)).data : void 0) ?? [];
4289
4295
  if (f2) {
4290
- const S = { label: f2, type: ke, importance: -2 };
4291
- t.addLabelAsSuffix ? y.push(S) : y.splice(0, 0, S);
4296
+ const w = { label: f2, type: Oe, importance: -2 };
4297
+ n.addLabelAsSuffix ? y.push(w) : y.splice(0, 0, w);
4292
4298
  }
4293
4299
  const I = [], D = /* @__PURE__ */ new Map();
4294
- for (let S = y.length - 1; S >= 0; --S) {
4295
- const { type: M } = y[S], pe = y[S].importance ?? 0, U = (D.get(M) ?? 0) + 1;
4296
- D.set(M, U);
4297
- const R = `${M}@${U}`;
4298
- s.set(R, (s.get(R) ?? 0) + 1), r.set(
4299
- R,
4300
+ for (let w = y.length - 1; w >= 0; --w) {
4301
+ const { type: N } = y[w], pe = y[w].importance ?? 0, M = (D.get(N) ?? 0) + 1;
4302
+ D.set(N, M);
4303
+ const F = `${N}@${M}`;
4304
+ i2.set(F, (i2.get(F) ?? 0) + 1), r.set(
4305
+ F,
4300
4306
  Math.max(
4301
- r.get(R) ?? Number.NEGATIVE_INFINITY,
4302
- pe - (y.length - S) * Te
4307
+ r.get(F) ?? Number.NEGATIVE_INFINITY,
4308
+ pe - (y.length - w) * Te
4303
4309
  )
4304
- ), I.push({ ...y[S], fullType: R, occurenceIndex: U });
4310
+ ), I.push({ ...y[w], fullType: F, occurenceIndex: M });
4305
4311
  }
4306
4312
  return I.reverse(), {
4307
4313
  value: p,
@@ -4312,11 +4318,11 @@
4312
4318
  }), o = [], l = [], a = [...r];
4313
4319
  a.sort(([, p], [, g]) => g - p);
4314
4320
  for (const [p] of a)
4315
- p.endsWith("@1") || s.get(p) === n.length ? o.push(p) : l.push(p);
4316
- const u = (p) => i2.map((g) => {
4317
- const f2 = g.fullTrace.filter((y) => p.has(y.fullType)).map((y) => y.label), C = t.separator ?? " / ";
4321
+ p.endsWith("@1") || i2.get(p) === t.length ? o.push(p) : l.push(p);
4322
+ const u = (p) => s.map((g) => {
4323
+ const f2 = g.fullTrace.filter((y) => p.has(y.fullType)).map((y) => y.label), A = n.separator ?? " / ";
4318
4324
  return {
4319
- label: f2.join(C),
4325
+ label: f2.join(A),
4320
4326
  value: g.value
4321
4327
  };
4322
4328
  });
@@ -4327,19 +4333,19 @@
4327
4333
  let h = 0, d = 0;
4328
4334
  for (; h < o.length; ) {
4329
4335
  const p = /* @__PURE__ */ new Set();
4330
- t.includeNativeLabel && p.add(ee);
4336
+ n.includeNativeLabel && p.add(ee);
4331
4337
  for (let f2 = 0; f2 < h; ++f2) p.add(o[f2]);
4332
4338
  p.add(o[d]);
4333
4339
  const g = u(p);
4334
- if (new Set(g.map((f2) => f2.label)).size === n.length) return g;
4340
+ if (new Set(g.map((f2) => f2.label)).size === t.length) return g;
4335
4341
  d++, d == o.length && (h++, d = h);
4336
4342
  }
4337
4343
  return u(/* @__PURE__ */ new Set([...o, ...l]));
4338
4344
  }
4339
4345
  class De {
4340
4346
  constructor() {
4341
- w(this, "ctx", c());
4342
- w(this, "defaultLabelFn", (e, t) => {
4347
+ S(this, "ctx", c());
4348
+ S(this, "defaultLabelFn", (e, n) => {
4343
4349
  var r;
4344
4350
  return ((r = e.annotations) == null ? void 0 : r["pl7.app/label"]) ?? "Unlabelled";
4345
4351
  });
@@ -4350,14 +4356,14 @@
4350
4356
  calculateOptions(e) {
4351
4357
  return this.ctx.calculateOptions(e);
4352
4358
  }
4353
- getOptions(e, t) {
4354
- const r = this.getSpecs().entries.filter((s) => e(s.obj));
4355
- return typeof t == "object" || typeof t > "u" ? xe(r, (s) => s.obj, t ?? {}).map(({ value: { ref: s }, label: i2 }) => ({
4356
- ref: s,
4357
- label: i2
4358
- })) : r.map((s) => ({
4359
- ref: s.ref,
4360
- label: t(s.obj, s.ref)
4359
+ getOptions(e, n) {
4360
+ const r = this.getSpecs().entries.filter((i2) => e(i2.obj));
4361
+ return typeof n == "object" || typeof n > "u" ? ke(r, (i2) => i2.obj, n ?? {}).map(({ value: { ref: i2 }, label: s }) => ({
4362
+ ref: i2,
4363
+ label: s
4364
+ })) : r.map((i2) => ({
4365
+ ref: i2.ref,
4366
+ label: n(i2.obj, i2.ref)
4361
4367
  }));
4362
4368
  }
4363
4369
  /**
@@ -4370,11 +4376,11 @@
4370
4376
  const e = this.ctx.getDataFromResultPool();
4371
4377
  return {
4372
4378
  isComplete: e.isComplete,
4373
- entries: e.entries.map((t) => ({
4374
- ref: t.ref,
4379
+ entries: e.entries.map((n) => ({
4380
+ ref: n.ref,
4375
4381
  obj: {
4376
- ...t.obj,
4377
- data: new b(t.obj.data, [t.ref.blockId, t.ref.name])
4382
+ ...n.obj,
4383
+ data: new v(n.obj.data, [n.ref.blockId, n.ref.name])
4378
4384
  }
4379
4385
  }))
4380
4386
  };
@@ -4389,13 +4395,13 @@
4389
4395
  const e = this.ctx.getDataWithErrorsFromResultPool();
4390
4396
  return {
4391
4397
  isComplete: e.isComplete,
4392
- entries: e.entries.map((t) => ({
4393
- ref: t.ref,
4398
+ entries: e.entries.map((n) => ({
4399
+ ref: n.ref,
4394
4400
  obj: {
4395
- ...t.obj,
4401
+ ...n.obj,
4396
4402
  data: mt(
4397
- t.obj.data,
4398
- (r) => new b(r, [t.ref.blockId, t.ref.name])
4403
+ n.obj.data,
4404
+ (r) => new v(r, [n.ref.blockId, n.ref.name])
4399
4405
  )
4400
4406
  }
4401
4407
  }))
@@ -4415,12 +4421,12 @@
4415
4421
  * @returns data associated with the ref
4416
4422
  */
4417
4423
  getDataByRef(e) {
4418
- var t;
4419
- return typeof this.ctx.getDataFromResultPoolByRef > "u" ? (t = this.getData().entries.find(
4424
+ var n;
4425
+ return typeof this.ctx.getDataFromResultPoolByRef > "u" ? (n = this.getData().entries.find(
4420
4426
  (r) => r.ref.blockId === e.blockId && r.ref.name === e.name
4421
- )) == null ? void 0 : t.obj : lt(
4427
+ )) == null ? void 0 : n.obj : lt(
4422
4428
  this.ctx.getDataFromResultPoolByRef(e.blockId, e.name),
4423
- (r) => new b(r, [e.blockId, e.name])
4429
+ (r) => new v(r, [e.blockId, e.name])
4424
4430
  );
4425
4431
  }
4426
4432
  /**
@@ -4429,9 +4435,9 @@
4429
4435
  * @returns p-column associated with the ref
4430
4436
  */
4431
4437
  getPColumnByRef(e) {
4432
- const t = this.getDataByRef(e);
4433
- if (t)
4434
- return dt(t);
4438
+ const n = this.getDataByRef(e);
4439
+ if (n)
4440
+ return dt(n);
4435
4441
  }
4436
4442
  /**
4437
4443
  * Returns spec associated with the ref ensuring that it is a p-column spec.
@@ -4439,10 +4445,10 @@
4439
4445
  * @returns p-column spec associated with the ref
4440
4446
  */
4441
4447
  getPColumnSpecByRef(e) {
4442
- const t = this.getSpecByRef(e);
4443
- if (t) {
4444
- if (!i(t)) throw new Error(`not a PColumn spec (kind = ${t.kind})`);
4445
- return t;
4448
+ const n = this.getSpecByRef(e);
4449
+ if (n) {
4450
+ if (!i(n)) throw new Error(`not a PColumn spec (kind = ${n.kind})`);
4451
+ return n;
4446
4452
  }
4447
4453
  }
4448
4454
  /**
@@ -4450,10 +4456,10 @@
4450
4456
  * @returns object spec associated with the ref
4451
4457
  */
4452
4458
  getSpecByRef(e) {
4453
- var t;
4454
- return typeof this.ctx.getSpecFromResultPoolByRef > "u" ? (t = this.getSpecs().entries.find(
4459
+ var n;
4460
+ return typeof this.ctx.getSpecFromResultPoolByRef > "u" ? (n = this.getSpecs().entries.find(
4455
4461
  (r) => r.ref.blockId === e.blockId && r.ref.name === e.name
4456
- )) == null ? void 0 : t.obj : this.ctx.getSpecFromResultPoolByRef(e.blockId, e.name);
4462
+ )) == null ? void 0 : n.obj : this.ctx.getSpecFromResultPoolByRef(e.blockId, e.name);
4457
4463
  }
4458
4464
  /**
4459
4465
  * @param spec object specification
@@ -4461,78 +4467,74 @@
4461
4467
  * @deprecated delete this method after Jan 1, 2025
4462
4468
  */
4463
4469
  findDataWithCompatibleSpec(e) {
4464
- const t = [];
4470
+ const n = [];
4465
4471
  e: for (const r of this.getData().entries) {
4466
4472
  if (!i(r.obj.spec))
4467
4473
  continue;
4468
- const s = r.obj.spec;
4469
- if (e.name === s.name && e.valueType === s.valueType && e.axesSpec.length === s.axesSpec.length && q(e.domain, s.domain)) {
4470
- for (let i2 = 0; i2 < e.axesSpec.length; ++i2) {
4471
- const o = e.axesSpec[i2], l = s.axesSpec[i2];
4474
+ const i$1 = r.obj.spec;
4475
+ if (e.name === i$1.name && e.valueType === i$1.valueType && e.axesSpec.length === i$1.axesSpec.length && q(e.domain, i$1.domain)) {
4476
+ for (let s = 0; s < e.axesSpec.length; ++s) {
4477
+ const o = e.axesSpec[s], l = i$1.axesSpec[s];
4472
4478
  if (o.name !== l.name || o.type !== l.type || !q(o.domain, l.domain))
4473
4479
  continue e;
4474
4480
  }
4475
- t.push(r.obj);
4481
+ n.push(r.obj);
4476
4482
  }
4477
4483
  }
4478
- return t;
4484
+ return n;
4479
4485
  }
4480
4486
  }
4481
- function q(n, e) {
4482
- if (n === void 0) return e === void 0;
4487
+ function q(t, e) {
4488
+ if (t === void 0) return e === void 0;
4483
4489
  if (e === void 0) return true;
4484
- for (const t in e)
4485
- if (n[t] !== e[t]) return false;
4490
+ for (const n in e)
4491
+ if (t[n] !== e[n]) return false;
4486
4492
  return true;
4487
4493
  }
4488
- class L {
4494
+ class E {
4489
4495
  constructor() {
4490
- w(this, "ctx");
4491
- w(this, "args");
4492
- w(this, "uiState");
4493
- w(this, "resultPool", new De());
4496
+ S(this, "ctx");
4497
+ S(this, "args");
4498
+ S(this, "uiState");
4499
+ S(this, "_activeArgsCache");
4500
+ S(this, "resultPool", new De());
4494
4501
  this.ctx = c(), this.args = JSON.parse(this.ctx.args), this.uiState = this.ctx.uiState !== void 0 ? JSON.parse(this.ctx.uiState) : {};
4495
4502
  }
4503
+ /**
4504
+ * Returns args snapshot the block was executed for (i.e. when "Run" button was pressed).
4505
+ * Returns undefined, if block was never executed or stopped mid-way execution, so that the result was cleared.
4506
+ * */
4507
+ get activeArgs() {
4508
+ return this._activeArgsCache === void 0 && (this._activeArgsCache = {
4509
+ v: this.ctx.activeArgs ? JSON.parse(this.ctx.activeArgs) : void 0
4510
+ }), this._activeArgsCache.v;
4511
+ }
4512
+ // /** Can be used to determine features provided by the desktop instance. */
4513
+ // public get featureFlags() {
4514
+ // return this.ctx.featureFlags;
4515
+ // }
4496
4516
  getNamedAccessor(e) {
4497
4517
  return H(
4498
4518
  this.ctx.getAccessorHandleByName(e),
4499
- (t) => new b(t, [e])
4519
+ (n) => new v(n, [e])
4500
4520
  );
4501
4521
  }
4502
4522
  get prerun() {
4503
4523
  return this.getNamedAccessor(ae);
4504
4524
  }
4505
- /**
4506
- * @deprecated use prerun
4507
- */
4508
- get precalc() {
4509
- return this.prerun;
4510
- }
4511
- /**
4512
- * @deprecated use prerun
4513
- */
4514
- get stagingOutput() {
4515
- return this.precalc;
4516
- }
4517
4525
  get outputs() {
4518
4526
  return this.getNamedAccessor(le);
4519
4527
  }
4520
- /**
4521
- * @deprecated use outputs
4522
- */
4523
- get mainOutput() {
4524
- return this.outputs;
4525
- }
4526
4528
  /**
4527
4529
  * Find labels data for a given axis id. It will search for a label column and return its data as a map.
4528
4530
  * @returns a map of axis value => label
4529
4531
  */
4530
4532
  findLabels(e) {
4531
- const t = this.resultPool.getData();
4532
- for (const r of t.entries) {
4533
+ const n = this.resultPool.getData();
4534
+ for (const r of n.entries) {
4533
4535
  if (!W(r.obj)) continue;
4534
- const s = r.obj.spec;
4535
- if (s.name === "pl7.app/label" && s.axesSpec.length === 1 && s.axesSpec[0].name === e.name && s.axesSpec[0].type === e.type && q(e.domain, s.axesSpec[0].domain)) {
4536
+ const i2 = r.obj.spec;
4537
+ if (i2.name === "pl7.app/label" && i2.axesSpec.length === 1 && i2.axesSpec[0].name === e.name && i2.axesSpec[0].type === e.type && q(e.domain, i2.axesSpec[0].domain)) {
4536
4538
  if (r.obj.data.resourceType.name !== "PColumnData/Json")
4537
4539
  throw Error(`Expected JSON column for labels, got: ${r.obj.data.resourceType.name}`);
4538
4540
  return Object.fromEntries(
@@ -4544,28 +4546,28 @@
4544
4546
  }
4545
4547
  }
4546
4548
  verifyInlineColumnsSupport(e) {
4547
- var s;
4548
- const t = e.some((i2) => !(i2.data instanceof b)), r = ((s = this.ctx.featureFlags) == null ? void 0 : s.inlineColumnsSupport) === true;
4549
- if (t && !r) throw Error("inline columns not supported");
4549
+ var i2;
4550
+ const n = e.some((s) => !(s.data instanceof v)), r = ((i2 = this.ctx.featureFlags) == null ? void 0 : i2.inlineColumnsSupport) === true;
4551
+ if (n && !r) throw Error("inline columns not supported");
4550
4552
  }
4551
4553
  createPFrame(e) {
4552
4554
  return this.verifyInlineColumnsSupport(e), this.ctx.createPFrame(
4553
- e.map((t) => lt(t, (r) => r instanceof b ? r.handle : r))
4555
+ e.map((n) => lt(n, (r) => r instanceof v ? r.handle : r))
4554
4556
  );
4555
4557
  }
4556
4558
  createPTable(e) {
4557
- var t;
4558
- return "columns" in e ? t = {
4559
+ var n;
4560
+ return "columns" in e ? n = {
4559
4561
  src: {
4560
4562
  type: "full",
4561
4563
  entries: e.columns.map((r) => ({ type: "column", column: r }))
4562
4564
  },
4563
4565
  filters: e.filters ?? [],
4564
4566
  sorting: e.sorting ?? []
4565
- } : t = e, this.verifyInlineColumnsSupport(pt(t.src)), this.ctx.createPTable(
4567
+ } : n = e, this.verifyInlineColumnsSupport(pt(n.src)), this.ctx.createPTable(
4566
4568
  it(
4567
- t,
4568
- (r) => lt(r, (s) => s instanceof b ? s.handle : s)
4569
+ n,
4570
+ (r) => lt(r, (i2) => i2 instanceof v ? i2.handle : i2)
4569
4571
  )
4570
4572
  );
4571
4573
  }
@@ -4578,20 +4580,20 @@
4578
4580
  return this.ctx.getCurrentUnstableMarker();
4579
4581
  }
4580
4582
  }
4581
- const T = "1.21.20";
4582
- function Le(n) {
4583
- return n.__renderLambda === true;
4583
+ const T = "1.22.2";
4584
+ function Ee(t) {
4585
+ return t.__renderLambda === true;
4584
4586
  }
4585
- function G(n) {
4586
- if (n !== void 0)
4587
- return Le(n) ? n.handle : n;
4587
+ function K(t) {
4588
+ if (t !== void 0)
4589
+ return Ee(t) ? t.handle : t;
4588
4590
  }
4589
- class v {
4590
- constructor(e, t, r, s, i2, o, l) {
4591
- this._renderingMode = e, this._initialArgs = t, this._initialUiState = r, this._outputs = s, this._inputsValid = i2, this._sections = o, this._title = l;
4591
+ class _ {
4592
+ constructor(e, n, r, i2, s, o, l) {
4593
+ this._renderingMode = e, this._initialArgs = n, this._initialUiState = r, this._outputs = i2, this._inputsValid = s, this._sections = o, this._title = l;
4592
4594
  }
4593
4595
  static create(e = "Heavy") {
4594
- return new v(
4596
+ return new _(
4595
4597
  e,
4596
4598
  void 0,
4597
4599
  {},
@@ -4601,10 +4603,10 @@
4601
4603
  void 0
4602
4604
  );
4603
4605
  }
4604
- output(e, t, r = {}) {
4605
- if (typeof t == "function") {
4606
- const s = `output#${e}`;
4607
- return E(s, () => t(new L())), new v(
4606
+ output(e, n, r = {}) {
4607
+ if (typeof n == "function") {
4608
+ const i2 = `output#${e}`;
4609
+ return L(i2, () => n(new E())), new _(
4608
4610
  this._renderingMode,
4609
4611
  this._initialArgs,
4610
4612
  this._initialUiState,
@@ -4612,7 +4614,7 @@
4612
4614
  ...this._outputs,
4613
4615
  [e]: {
4614
4616
  __renderLambda: true,
4615
- handle: s,
4617
+ handle: i2,
4616
4618
  ...r
4617
4619
  }
4618
4620
  },
@@ -4621,13 +4623,13 @@
4621
4623
  this._title
4622
4624
  );
4623
4625
  } else
4624
- return new v(
4626
+ return new _(
4625
4627
  this._renderingMode,
4626
4628
  this._initialArgs,
4627
4629
  this._initialUiState,
4628
4630
  {
4629
4631
  ...this._outputs,
4630
- [e]: t
4632
+ [e]: n
4631
4633
  },
4632
4634
  this._inputsValid,
4633
4635
  this._sections,
@@ -4635,15 +4637,11 @@
4635
4637
  );
4636
4638
  }
4637
4639
  /** Shortcut for {@link output} with retentive flag set to true. */
4638
- retentiveOutput(e, t) {
4639
- return this.output(e, t, { retentive: true });
4640
- }
4641
- /** @deprecated */
4642
- canRun(e) {
4643
- return this.inputsValid(e);
4640
+ retentiveOutput(e, n) {
4641
+ return this.output(e, n, { retentive: true });
4644
4642
  }
4645
4643
  argsValid(e) {
4646
- return typeof e == "function" ? (E("inputsValid", () => e(new L())), new v(
4644
+ return typeof e == "function" ? (L("inputsValid", () => e(new E())), new _(
4647
4645
  this._renderingMode,
4648
4646
  this._initialArgs,
4649
4647
  this._initialUiState,
@@ -4654,7 +4652,7 @@
4654
4652
  },
4655
4653
  this._sections,
4656
4654
  this._title
4657
- )) : new v(
4655
+ )) : new _(
4658
4656
  this._renderingMode,
4659
4657
  this._initialArgs,
4660
4658
  this._initialUiState,
@@ -4664,11 +4662,8 @@
4664
4662
  this._title
4665
4663
  );
4666
4664
  }
4667
- inputsValid(e) {
4668
- return this.argsValid(e);
4669
- }
4670
4665
  sections(e) {
4671
- return Array.isArray(e) ? this.sections(V(e)) : typeof e == "function" ? (E("sections", () => e(new L())), new v(
4666
+ return Array.isArray(e) ? this.sections(V(e)) : typeof e == "function" ? (L("sections", () => e(new E())), new _(
4672
4667
  this._renderingMode,
4673
4668
  this._initialArgs,
4674
4669
  this._initialUiState,
@@ -4676,7 +4671,7 @@
4676
4671
  this._inputsValid,
4677
4672
  { __renderLambda: true, handle: "sections" },
4678
4673
  this._title
4679
- )) : new v(
4674
+ )) : new _(
4680
4675
  this._renderingMode,
4681
4676
  this._initialArgs,
4682
4677
  this._initialUiState,
@@ -4686,8 +4681,9 @@
4686
4681
  this._title
4687
4682
  );
4688
4683
  }
4684
+ /** Sets a rendering function to derive block title, shown for the block in the left blocks-overview panel. */
4689
4685
  title(e) {
4690
- return E("title", () => e(new L())), new v(
4686
+ return L("title", () => e(new E())), new _(
4691
4687
  this._renderingMode,
4692
4688
  this._initialArgs,
4693
4689
  this._initialUiState,
@@ -4702,7 +4698,7 @@
4702
4698
  * @deprecated use {@link withArgs}
4703
4699
  * */
4704
4700
  initialArgs(e) {
4705
- return new v(
4701
+ return new _(
4706
4702
  this._renderingMode,
4707
4703
  e,
4708
4704
  this._initialUiState,
@@ -4714,7 +4710,7 @@
4714
4710
  }
4715
4711
  /** Sets initial args for the block, this value must be specified. */
4716
4712
  withArgs(e) {
4717
- return new v(
4713
+ return new _(
4718
4714
  this._renderingMode,
4719
4715
  e,
4720
4716
  this._initialUiState,
@@ -4726,7 +4722,7 @@
4726
4722
  }
4727
4723
  /** Defines type and sets initial value for block UiState. */
4728
4724
  withUiState(e) {
4729
- return new v(
4725
+ return new _(
4730
4726
  this._renderingMode,
4731
4727
  this._initialArgs,
4732
4728
  e,
@@ -4756,19 +4752,19 @@
4756
4752
  sdkVersion: T,
4757
4753
  renderingMode: this._renderingMode,
4758
4754
  initialArgs: this._initialArgs,
4759
- inputsValid: G(this._inputsValid),
4760
- sections: G(this._sections),
4755
+ inputsValid: K(this._inputsValid),
4756
+ sections: K(this._sections),
4761
4757
  outputs: Object.fromEntries(
4762
- Object.entries(this._outputs).map(([t, r]) => [t, G(r)])
4758
+ Object.entries(this._outputs).map(([n, r]) => [n, K(r)])
4763
4759
  )
4764
4760
  };
4765
4761
  return Se() ? oe({ sdkVersion: T }) : { config: e };
4766
4762
  }
4767
4763
  }
4768
- function _t(n, e, t, r) {
4764
+ function St(t, e, n, r) {
4769
4765
  var u, h;
4770
4766
  Array.isArray(r) && (r = { filters: r });
4771
- const s = n.resultPool.getData().entries.map((d) => d.obj).filter(W).filter((d) => d.spec.name === "pl7.app/label" && d.spec.axesSpec.length === 1), i2 = (d, p) => {
4767
+ const i2 = t.resultPool.getData().entries.map((d) => d.obj).filter(W).filter((d) => d.spec.name === "pl7.app/label" && d.spec.axesSpec.length === 1), s = (d, p) => {
4772
4768
  let g = d.toString();
4773
4769
  if (p)
4774
4770
  for (const f2 in p)
@@ -4778,27 +4774,27 @@
4778
4774
  for (const d of e)
4779
4775
  for (const p of d.spec.axesSpec) {
4780
4776
  const g = J$1(p);
4781
- for (const f2 of s) {
4782
- const C = f2.spec.axesSpec[0], y = J$1(f2.spec.axesSpec[0]);
4777
+ for (const f2 of i2) {
4778
+ const A = f2.spec.axesSpec[0], y = J$1(f2.spec.axesSpec[0]);
4783
4779
  if (ot(g, y)) {
4784
4780
  const I = Object.keys(g.domain ?? {}).length, D = Object.keys(y.domain ?? {}).length;
4785
4781
  if (I > D) {
4786
- const F = i2(f2.id, g.domain);
4787
- o.set(F, {
4788
- id: F,
4782
+ const R = s(f2.id, g.domain);
4783
+ o.set(R, {
4784
+ id: R,
4789
4785
  spec: {
4790
4786
  ...f2.spec,
4791
- axesSpec: [{ ...g, annotations: C.annotations }]
4787
+ axesSpec: [{ ...g, annotations: A.annotations }]
4792
4788
  },
4793
4789
  data: f2.data
4794
4790
  });
4795
4791
  } else
4796
- o.set(i2(f2.id), f2);
4792
+ o.set(s(f2.id), f2);
4797
4793
  }
4798
4794
  }
4799
4795
  }
4800
4796
  if ([...e, ...o.values()].some(
4801
- (d) => d.data instanceof b && !d.data.getIsReadyOrError()
4797
+ (d) => d.data instanceof v && !d.data.getIsReadyOrError()
4802
4798
  ))
4803
4799
  return;
4804
4800
  let l = e;
@@ -4808,7 +4804,7 @@
4808
4804
  for (const d of e)
4809
4805
  r.coreColumnPredicate(d.spec) ? l.push(d) : a.push(d);
4810
4806
  }
4811
- return a.push(...o.values()), n.createPTable({
4807
+ return a.push(...o.values()), t.createPTable({
4812
4808
  src: {
4813
4809
  type: "outer",
4814
4810
  primary: {
@@ -4817,20 +4813,20 @@
4817
4813
  },
4818
4814
  secondary: a.map((d) => ({ type: "column", column: d }))
4819
4815
  },
4820
- filters: [...(r == null ? void 0 : r.filters) ?? [], ...((u = t == null ? void 0 : t.pTableParams) == null ? void 0 : u.filters) ?? []],
4821
- sorting: ((h = t == null ? void 0 : t.pTableParams) == null ? void 0 : h.sorting) ?? []
4816
+ filters: [...(r == null ? void 0 : r.filters) ?? [], ...((u = n == null ? void 0 : n.pTableParams) == null ? void 0 : u.filters) ?? []],
4817
+ sorting: ((h = n == null ? void 0 : n.pTableParams) == null ? void 0 : h.sorting) ?? []
4822
4818
  });
4823
4819
  }
4824
4820
  const $BlockArgs = z.object({
4825
4821
  numbers: z.array(z.coerce.number())
4826
4822
  });
4827
- const platforma = v.create("Heavy").withArgs({ numbers: [1, 2, 3, 4] }).withUiState({ dataTableState: void 0, dynamicSections: [] }).output("numbers", (ctx) => {
4823
+ const platforma = _.create("Heavy").withArgs({ numbers: [1, 2, 3, 4] }).withUiState({ dataTableState: void 0, dynamicSections: [] }).output("numbers", (ctx) => {
4828
4824
  var _a, _b;
4829
4825
  return (_b = (_a = ctx.outputs) == null ? void 0 : _a.resolve("numbers")) == null ? void 0 : _b.getDataAsJson();
4830
4826
  }).output("pt", (ctx) => {
4831
4827
  var _a, _b, _c, _d, _e;
4832
4828
  if (!((_c = (_b = (_a = ctx.uiState) == null ? void 0 : _a.dataTableState) == null ? void 0 : _b.tableState.pTableParams) == null ? void 0 : _c.filters)) return void 0;
4833
- return _t(ctx, [
4829
+ return St(ctx, [
4834
4830
  {
4835
4831
  id: "example",
4836
4832
  spec: {