@milaboratories/pl-middle-layer 1.14.25 → 1.14.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,101 +1,101 @@
1
- var Ut = Object.defineProperty;
2
- var $t = (s, e, t) => e in s ? Ut(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
- var d = (s, e, t) => $t(s, typeof e != "symbol" ? e + "" : e, t);
4
- import { executePSpecPredicate as Gt, mapPObjectData as Q, mapValueInVOE as Ht, mapPTableDef as ut, isFunctionHandle as lt, normalizeBlockConfig as je, DefaultNavigationState as _t } from "@platforma-sdk/model";
1
+ var zt = Object.defineProperty;
2
+ var Yt = (o, e, t) => e in o ? zt(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
+ var d = (o, e, t) => Yt(o, typeof e != "symbol" ? e + "" : e, t);
4
+ import { executePSpecPredicate as qt, mapPObjectData as Z, mapValueInVOE as Qt, mapPTableDef as ht, isFunctionHandle as ft, normalizeBlockConfig as Ie, DefaultNavigationState as Zt } from "@platforma-sdk/model";
5
5
  export * from "@platforma-sdk/model";
6
- import { blockPackIdEquals as me } from "@milaboratories/pl-model-middle-layer";
6
+ import { blockPackIdEquals as ve } from "@milaboratories/pl-model-middle-layer";
7
7
  export * from "@milaboratories/pl-model-middle-layer";
8
- import { request as H, RetryAgent as Wt } from "undici";
9
- import { RegistryV1 as _, tryLoadPackDescription as dt, BlockPackMetaEmbedAbsoluteBytes as zt, RegistryV2Reader as Yt, folderReaderByUrl as qt, loadPackDescription as _e } from "@platforma-sdk/block-tools";
10
- import T from "node:fs";
11
- import E from "node:path";
12
- import Qt from "yaml";
13
- import { assertNever as D, notEmpty as w, ConsoleLoggerAdapter as Zt, ConcurrencyLimitingExecutor as Xt, HmacSha256Signer as pt } from "@milaboratories/ts-helpers";
14
- import * as ht from "node:fs/promises";
15
- import { tryResolve as er } from "@milaboratories/resolve-helper";
16
- import { resourceTypesEqual as U, field as S, Pl as y, PlClient as tr, isNullResourceId as ce, ensureResourceIdNotNull as Se, isResource as rr, isResourceRef as or, isNotNullResourceId as We, resourceType as re, resourceTypeToString as sr, resourceIdToString as gt, isNotFoundError as ir, isTimeoutOrCancelError as nr, toGlobalResourceId as ar } from "@milaboratories/pl-client";
8
+ import { request as M, RetryAgent as Xt } from "undici";
9
+ import { RegistryV1 as _, tryLoadPackDescription as mt, BlockPackMetaEmbedAbsoluteBytes as er, RegistryV2Reader as tr, folderReaderByUrl as rr, loadPackDescription as qe } from "@platforma-sdk/block-tools";
10
+ import A from "node:fs";
11
+ import T from "node:path";
12
+ import sr from "yaml";
13
+ import { assertNever as D, notEmpty as w, ConsoleLoggerAdapter as or, ConcurrencyLimitingExecutor as nr, HmacSha256Signer as vt } from "@milaboratories/ts-helpers";
14
+ import * as yt from "node:fs/promises";
15
+ import { tryResolve as ir } from "@milaboratories/resolve-helper";
16
+ import { resourceTypesEqual as $, field as S, Pl as b, PlClient as ar, isNullResourceId as ue, ensureResourceIdNotNull as Pe, isResource as cr, isResourceRef as ur, isNotNullResourceId as Qe, resourceType as se, resourceTypeToString as lr, resourceIdToString as bt, isNotFoundError as dr, isTimeoutOrCancelError as pr, toGlobalResourceId as gr, plAddressToConfig as hr, UnauthenticatedPlClient as Ze } from "@milaboratories/pl-client";
17
17
  export * from "@milaboratories/pl-client";
18
- import { SynchronizedTreeState as ft, PlError as cr } from "@milaboratories/pl-tree";
19
- import { Computable as F, ChangeSource as ze, PollComputablePool as ur, WatchableValue as lr } from "@milaboratories/computable";
20
- import { randomUUID as X, createHash as he } from "node:crypto";
21
- import mt from "denque";
22
- import { Templates as dr } from "@platforma-sdk/workflow-tengo";
23
- import Ee from "canonicalize";
24
- import pr from "node:assert";
25
- import { Scope as ke, getQuickJS as hr } from "quickjs-emscripten";
26
- import { setTimeout as gr } from "node:timers/promises";
27
- import { createDownloadClient as fr, createLogsClient as mr, createUploadBlobClient as vr, createUploadProgressClient as yr, DownloadDriver as br, UploadDriver as wr, LogsStreamDriver as Sr, LogsDriver as kr, LsDriver as Cr, DownloadUrlDriver as Pr } from "@milaboratories/pl-drivers";
28
- import { PFrame as Fr } from "@milaboratories/pframes-node";
29
- import { LRUCache as Br } from "lru-cache";
30
- async function Ye(s) {
18
+ import { SynchronizedTreeState as wt, PlError as fr } from "@milaboratories/pl-tree";
19
+ import { Computable as F, ChangeSource as Xe, PollComputablePool as mr, WatchableValue as vr } from "@milaboratories/computable";
20
+ import { randomUUID as ee, createHash as he } from "node:crypto";
21
+ import St from "denque";
22
+ import { Templates as yr } from "@platforma-sdk/workflow-tengo";
23
+ import Ve from "canonicalize";
24
+ import br from "node:assert";
25
+ import { Scope as Fe, getQuickJS as wr } from "quickjs-emscripten";
26
+ import { setTimeout as kt } from "node:timers/promises";
27
+ import { createDownloadClient as Sr, createLogsClient as kr, createUploadBlobClient as Cr, createUploadProgressClient as Pr, DownloadDriver as Fr, UploadDriver as Rr, LogsStreamDriver as Br, LogsDriver as Or, LsDriver as Dr, DownloadUrlDriver as xr } from "@milaboratories/pl-drivers";
28
+ import { PFrame as jr } from "@milaboratories/pframes-node";
29
+ import { LRUCache as Tr } from "lru-cache";
30
+ async function et(o) {
31
31
  try {
32
- return await ht.stat(s, { bigint: !0 });
32
+ return await yt.stat(o, { bigint: !0 });
33
33
  } catch (e) {
34
34
  if (e.code === "ENOENT")
35
35
  return;
36
36
  throw e;
37
37
  }
38
38
  }
39
- const Rr = [_.PlPackageYamlConfigFile], Or = [_.PlPackageJsonConfigFile], Ae = ["backend", "dist", "tengo", "tpl", "main.plj.gz"], Te = ["config", "dist", "config.json"], vt = ["frontend", "dist"], qe = "block-model/dist/config.json", Dr = "block-ui/package.json", xr = [
40
- Ae,
41
- Te,
42
- Rr,
43
- Or,
44
- vt
39
+ const Er = [_.PlPackageYamlConfigFile], Ar = [_.PlPackageJsonConfigFile], Ne = ["backend", "dist", "tengo", "tpl", "main.plj.gz"], Le = ["config", "dist", "config.json"], Ct = ["frontend", "dist"], tt = "block-model/dist/config.json", Ir = "block-ui/package.json", Vr = [
40
+ Ne,
41
+ Le,
42
+ Er,
43
+ Ar,
44
+ Ct
45
45
  ];
46
- async function jr(s) {
47
- return await Ye(E.join(s, ...Te)) !== void 0 || await Ye(E.join(s, ...Ae)) !== void 0;
46
+ async function Nr(o) {
47
+ return await et(T.join(o, ...Le)) !== void 0 || await et(T.join(o, ...Ne)) !== void 0;
48
48
  }
49
- function ve(s, e) {
50
- const t = er(s, e);
51
- if (t === void 0) throw new Error(`Can't resolve ${e} against ${s}`);
49
+ function ye(o, e) {
50
+ const t = ir(o, e);
51
+ if (t === void 0) throw new Error(`Can't resolve ${e} against ${o}`);
52
52
  return t;
53
53
  }
54
- async function Qe(s, e) {
55
- if (E.isAbsolute(s) || (s = E.resolve(s)), await jr(s))
54
+ async function rt(o, e) {
55
+ if (T.isAbsolute(o) || (o = T.resolve(o)), await Nr(o))
56
56
  return {
57
- workflow: E.join(s, ...Ae),
58
- config: E.join(s, ...Te),
59
- ui: E.join(s, ...vt)
57
+ workflow: T.join(o, ...Ne),
58
+ config: T.join(o, ...Le),
59
+ ui: T.join(o, ...Ct)
60
60
  };
61
61
  {
62
- const t = ve(s, qe), r = ve(s, qe), o = ve(s, Dr);
63
- return { workflow: t, config: r, ui: E.resolve(o, "..", "dist") };
62
+ const t = ye(o, tt), r = ye(o, tt), s = ye(o, Ir);
63
+ return { workflow: t, config: r, ui: T.resolve(s, "..", "dist") };
64
64
  }
65
65
  }
66
- async function Er(s) {
66
+ async function Lr(o) {
67
67
  try {
68
- return await T.promises.readFile(s, "utf8");
68
+ return await A.promises.readFile(o, "utf8");
69
69
  } catch (e) {
70
70
  if (e.code === "ENOENT")
71
71
  return;
72
72
  throw e;
73
73
  }
74
74
  }
75
- async function Ar(s) {
75
+ async function Jr(o) {
76
76
  try {
77
- return await T.promises.stat(s, { bigint: !0 });
77
+ return await A.promises.stat(o, { bigint: !0 });
78
78
  } catch (e) {
79
79
  if (e.code === "ENOENT")
80
80
  return;
81
81
  throw e;
82
82
  }
83
83
  }
84
- async function yt(s) {
84
+ async function Pt(o) {
85
85
  let e = 0n;
86
- for (const t of xr) {
87
- const r = E.join(s, ...t), o = await Ar(r);
88
- o !== void 0 && e < o.mtimeNs && (e = o.mtimeNs);
86
+ for (const t of Vr) {
87
+ const r = T.join(o, ...t), s = await Jr(r);
88
+ s !== void 0 && e < s.mtimeNs && (e = s.mtimeNs);
89
89
  }
90
90
  return e.toString();
91
91
  }
92
- async function Ie(s) {
93
- const e = await T.promises.stat(s.components.workflow.main.file, {
92
+ async function Je(o) {
93
+ const e = await A.promises.stat(o.components.workflow.main.file, {
94
94
  bigint: !0
95
- }), t = await T.promises.stat(s.components.model.file, { bigint: !0 });
95
+ }), t = await A.promises.stat(o.components.model.file, { bigint: !0 });
96
96
  return (e.mtimeNs > t.mtimeNs ? e.mtimeNs : t.mtimeNs).toString();
97
97
  }
98
- class oi {
98
+ class dn {
99
99
  constructor(e, t, r) {
100
100
  this.v2Provider = e, this.registries = t, this.http = r;
101
101
  }
@@ -103,19 +103,19 @@ class oi {
103
103
  const t = [], r = e.spec;
104
104
  switch (r.type) {
105
105
  case "remote-v1":
106
- const o = this.http !== void 0 ? { dispatcher: this.http } : {}, n = await (await H(
106
+ const s = this.http !== void 0 ? { dispatcher: this.http } : {}, i = await (await M(
107
107
  `${r.url}/${_.GlobalOverviewPath}`,
108
- o
108
+ s
109
109
  )).body.json();
110
- for (const a of n) {
111
- const { organization: c, package: u, latestMeta: l, latestVersion: p } = a, h = {
110
+ for (const a of i) {
111
+ const { organization: c, package: u, latestMeta: l, latestVersion: p } = a, g = {
112
112
  organization: c,
113
113
  name: u,
114
114
  version: p
115
115
  };
116
116
  t.push({
117
117
  registryId: e.id,
118
- id: h,
118
+ id: g,
119
119
  meta: {
120
120
  title: l.title ?? "No title",
121
121
  description: l.description ?? "No Description",
@@ -126,7 +126,7 @@ class oi {
126
126
  },
127
127
  spec: {
128
128
  type: "from-registry-v1",
129
- id: h,
129
+ id: g,
130
130
  registryUrl: r.url
131
131
  },
132
132
  otherVersions: a.allVersions
@@ -139,20 +139,20 @@ class oi {
139
139
  registryId: e.id
140
140
  }));
141
141
  case "local-dev":
142
- for (const a of await T.promises.readdir(r.path, { withFileTypes: !0 })) {
142
+ for (const a of await A.promises.readdir(r.path, { withFileTypes: !0 })) {
143
143
  if (!a.isDirectory()) continue;
144
- const c = E.join(r.path, a.name), u = await Er(
145
- E.join(c, _.PlPackageYamlConfigFile)
144
+ const c = T.join(r.path, a.name), u = await Lr(
145
+ T.join(c, _.PlPackageYamlConfigFile)
146
146
  );
147
147
  if (u !== void 0) {
148
- const l = _.PlPackageConfigData.parse(Qt.parse(u)), p = await yt(c), h = {
148
+ const l = _.PlPackageConfigData.parse(sr.parse(u)), p = await Pt(c), g = {
149
149
  organization: l.organization,
150
150
  name: l.package,
151
151
  version: "DEV"
152
152
  };
153
153
  t.push({
154
154
  registryId: e.id,
155
- id: h,
155
+ id: g,
156
156
  meta: {
157
157
  title: l.meta.title ?? "No title",
158
158
  description: l.meta.description ?? "No Description",
@@ -169,13 +169,13 @@ class oi {
169
169
  otherVersions: []
170
170
  });
171
171
  } else {
172
- const l = await dt(c);
172
+ const l = await mt(c);
173
173
  if (l !== void 0) {
174
- const p = await Ie(l);
174
+ const p = await Je(l);
175
175
  t.push({
176
176
  registryId: e.id,
177
177
  id: l.id,
178
- meta: await zt.parseAsync(l.meta),
178
+ meta: await er.parseAsync(l.meta),
179
179
  spec: {
180
180
  type: "dev-v2",
181
181
  folder: c,
@@ -198,7 +198,7 @@ class oi {
198
198
  return { registries: t, blockPacks: e };
199
199
  }
200
200
  }
201
- class Tr {
201
+ class Mr {
202
202
  constructor(e) {
203
203
  d(this, "registries", /* @__PURE__ */ new Map());
204
204
  this.http = e;
@@ -206,164 +206,164 @@ class Tr {
206
206
  getRegistry(e) {
207
207
  const t = this.registries.get(e);
208
208
  if (t) return t;
209
- const r = new Yt(qt(e, this.http));
209
+ const r = new tr(rr(e, this.http));
210
210
  return this.registries.set(e, r), r;
211
211
  }
212
212
  }
213
- const si = {
213
+ const pn = {
214
214
  type: "remote-v2",
215
215
  url: "https://blocks.pl-open.science/"
216
- }, ii = {
216
+ }, gn = {
217
217
  type: "remote-v1",
218
218
  url: "https://block.registry.platforma.bio/releases"
219
- }, ni = {
219
+ }, hn = {
220
220
  type: "remote-v1",
221
221
  url: "https://block.registry.platforma.bio/dev"
222
- }, Ir = {
222
+ }, Ur = {
223
223
  groups: [{ id: "default", label: "Default", blocks: [] }]
224
- }, Vr = {
224
+ }, Kr = {
225
225
  stagingRefreshTimestamp: 0,
226
226
  blocksInLimbo: []
227
- }, Lr = {
227
+ }, $r = {
228
228
  label: "New Project"
229
- }, Nr = { name: "UserProject", version: "2" }, bt = "SchemaVersion", wt = "1", Ve = "ProjectCreated", ee = "ProjectLastModified", te = "ProjectMeta", W = "ProjectStructure", ue = "BlockRenderingState", Jr = "BlockFrontendState/", Kr = /^BlockFrontendState\/(?<blockid>.*)$/;
230
- function Ce(s) {
231
- return `${Jr}${s}`;
229
+ }, Gr = { name: "UserProject", version: "2" }, Ft = "SchemaVersion", Rt = "1", Me = "ProjectCreated", te = "ProjectLastModified", re = "ProjectMeta", W = "ProjectStructure", le = "BlockRenderingState", Hr = "BlockFrontendState/", _r = /^BlockFrontendState\/(?<blockid>.*)$/;
230
+ function Re(o) {
231
+ return `${Hr}${o}`;
232
232
  }
233
- const Mr = "BlockArgsAuthor/";
234
- function Pe(s) {
235
- return `${Mr}${s}`;
233
+ const Wr = "BlockArgsAuthor/";
234
+ function Be(o) {
235
+ return `${Wr}${o}`;
236
236
  }
237
- const Fe = "ProjectStructureAuthor";
238
- function Ur(s) {
239
- const e = s.match(Kr);
237
+ const Oe = "ProjectStructureAuthor";
238
+ function zr(o) {
239
+ const e = o.match(_r);
240
240
  if (e !== null)
241
241
  return e.groups.blockid;
242
242
  }
243
- const $r = "__serviceTemplate_";
244
- function Be(s) {
245
- return `${$r}${s}`;
243
+ const Yr = "__serviceTemplate_";
244
+ function De(o) {
245
+ return `${Yr}${o}`;
246
246
  }
247
- function P(s, e) {
248
- return `${s}-${e}`;
247
+ function P(o, e) {
248
+ return `${o}-${e}`;
249
249
  }
250
- const Gr = /^(?<blockId>.*)-(?<fieldName>blockPack|prodArgs|currentArgs|prodCtx|prodUiCtx|prodOutput|prodCtxPrevious|prodUiCtxPrevious|prodOutputPrevious|stagingCtx|stagingUiCtx|stagingOutput|stagingCtxPrevious|stagingUiCtxPrevious|stagingOutputPrevious)$/;
251
- function Hr(s) {
252
- const e = s.match(Gr);
250
+ const qr = /^(?<blockId>.*)-(?<fieldName>blockPack|prodArgs|currentArgs|prodCtx|prodUiCtx|prodOutput|prodCtxPrevious|prodUiCtxPrevious|prodOutputPrevious|stagingCtx|stagingUiCtx|stagingOutput|stagingCtxPrevious|stagingUiCtxPrevious|stagingOutputPrevious)$/;
251
+ function Qr(o) {
252
+ const e = o.match(qr);
253
253
  if (e === null) return;
254
254
  const { blockId: t, fieldName: r } = e.groups;
255
255
  return { blockId: t, fieldName: r };
256
256
  }
257
- const _r = "projects", St = { name: "Projects", version: "1" }, Wr = (s) => U(s.type, St) ? s.fields : [];
258
- async function zr(s, e, t, r) {
259
- const o = await ft.init(
260
- s,
257
+ const Zr = "projects", Bt = { name: "Projects", version: "1" }, Xr = (o) => $(o.type, Bt) ? o.fields : [];
258
+ async function es(o, e, t, r) {
259
+ const s = await wt.init(
260
+ o,
261
261
  e,
262
262
  {
263
263
  ...r.ops.defaultTreeOptions,
264
- pruning: Wr
264
+ pruning: Xr
265
265
  },
266
266
  r.logger
267
267
  );
268
- return { computable: F.make((n) => {
269
- const a = n.accessor(o.entry()).node(), c = t.getValue(n);
268
+ return { computable: F.make((i) => {
269
+ const a = i.accessor(s.entry()).node(), c = t.getValue(i);
270
270
  if (a === void 0) return;
271
271
  const u = [];
272
272
  for (const l of a.listDynamicFields()) {
273
273
  const p = a.traverse(l);
274
274
  if (p === void 0) continue;
275
- const h = w(p.getKeyValueAsJson(te)), f = w(p.getKeyValueAsJson(Ve)), b = w(p.getKeyValueAsJson(ee));
275
+ const g = w(p.getKeyValueAsJson(re)), m = w(p.getKeyValueAsJson(Me)), h = w(p.getKeyValueAsJson(te));
276
276
  u.push({
277
277
  id: l,
278
278
  rid: p.id,
279
- created: new Date(f),
280
- lastModified: new Date(b),
279
+ created: new Date(m),
280
+ lastModified: new Date(h),
281
281
  opened: c.indexOf(p.id) >= 0,
282
- meta: h
282
+ meta: g
283
283
  });
284
284
  }
285
285
  return u.sort((l) => -l.lastModified.valueOf()), u;
286
- }).withStableType(), tree: o };
286
+ }).withStableType(), tree: s };
287
287
  }
288
- const Yr = {
288
+ const ts = {
289
289
  name: "EphRenderTemplate",
290
290
  version: "1"
291
- }, qr = {
291
+ }, rs = {
292
292
  name: "RenderTemplate",
293
293
  version: "1"
294
294
  };
295
- function kt(s, e, t, r, o) {
296
- if (o.length === 0) throw new Error("Zero output names provided");
297
- const i = t ? s.createEphemeral(Yr) : s.createStruct(qr), n = S(i, "template"), a = S(i, "inputs");
298
- return s.createField(n, "Input", e), s.createField(a, "Input", y.createPlMap(s, r, t)), s.lockInputs(i), y.futureRecord(s, i, o, "Output", "outputs/");
295
+ function Ot(o, e, t, r, s) {
296
+ if (s.length === 0) throw new Error("Zero output names provided");
297
+ const n = t ? o.createEphemeral(ts) : o.createStruct(rs), i = S(n, "template"), a = S(n, "inputs");
298
+ return o.createField(i, "Input", e), o.createField(a, "Input", b.createPlMap(o, r, t)), o.lockInputs(n), b.futureRecord(o, n, s, "Output", "outputs/");
299
299
  }
300
- const Qr = { name: "BContextEnd", version: "1" }, Zr = { name: "BContext", version: "1" }, Xr = "id", eo = "parent/", to = ["context", "result"];
301
- function Ze(s, e, t) {
302
- return kt(s, e, !0, t, to);
300
+ const ss = { name: "BContextEnd", version: "1" }, os = { name: "BContext", version: "1" }, ns = "id", is = "parent/", as = ["context", "result"];
301
+ function st(o, e, t) {
302
+ return Ot(o, e, !0, t, as);
303
303
  }
304
- function ro(s) {
305
- const e = s.createEphemeral(Qr);
306
- return s.lock(e), e;
304
+ function cs(o) {
305
+ const e = o.createEphemeral(ss);
306
+ return o.lock(e), e;
307
307
  }
308
- function oo(s, e) {
309
- if (e.length === 0) return ro(s);
308
+ function us(o, e) {
309
+ if (e.length === 0) return cs(o);
310
310
  if (e.length === 1) return e[0];
311
- const t = s.createEphemeral(Zr);
312
- s.createField(S(t, Xr), "Input", y.createPlString(s, X()));
311
+ const t = o.createEphemeral(os);
312
+ o.createField(S(t, ns), "Input", b.createPlString(o, ee()));
313
313
  for (let r = 0; r < e.length; r++)
314
- s.createField(S(t, `${eo}${r}`), "Input", e[r]);
315
- return s.lock(t), t;
314
+ o.createField(S(t, `${is}${r}`), "Input", e[r]);
315
+ return o.lock(t), t;
316
316
  }
317
- const so = { name: "TengoTemplateGet", version: "1" }, io = "registry", no = "templateURI", ao = "template", co = { name: "TengoTemplatePack", version: "1" }, uo = {
317
+ const ls = { name: "TengoTemplateGet", version: "1" }, ds = "registry", ps = "templateURI", gs = "template", hs = { name: "TengoTemplatePack", version: "1" }, fs = {
318
318
  name: "TengoTemplatePackConvert",
319
319
  version: "1"
320
- }, lo = "templatePack", po = "template";
321
- async function ho(s) {
322
- switch (s.type) {
320
+ }, ms = "templatePack", vs = "template";
321
+ async function ys(o) {
322
+ switch (o.type) {
323
323
  case "from-file":
324
324
  return {
325
325
  type: "explicit",
326
- content: await T.promises.readFile(s.path)
326
+ content: await A.promises.readFile(o.path)
327
327
  };
328
328
  case "from-registry":
329
329
  case "explicit":
330
- return s;
330
+ return o;
331
331
  default:
332
- return D(s);
332
+ return D(o);
333
333
  }
334
334
  }
335
- function go(s, e) {
336
- const t = s.createStruct(so), r = S(t, io), o = S(t, no), i = S(t, ao);
337
- return s.setField(r, s.createValue(y.JsonString, Buffer.from(JSON.stringify(e.registry)))), s.setField(o, s.createValue(y.JsonString, Buffer.from(JSON.stringify(e.path)))), i;
335
+ function bs(o, e) {
336
+ const t = o.createStruct(ls), r = S(t, ds), s = S(t, ps), n = S(t, gs);
337
+ return o.setField(r, o.createValue(b.JsonString, Buffer.from(JSON.stringify(e.registry)))), o.setField(s, o.createValue(b.JsonString, Buffer.from(JSON.stringify(e.path)))), n;
338
338
  }
339
- function fo(s, e) {
340
- const t = s.createValue(co, e.content), r = s.createStruct(uo), o = S(r, lo), i = S(r, po);
341
- return s.setField(o, t), i;
339
+ function ws(o, e) {
340
+ const t = o.createValue(hs, e.content), r = o.createStruct(fs), s = S(r, ms), n = S(r, vs);
341
+ return o.setField(s, t), n;
342
342
  }
343
- function Le(s, e) {
343
+ function Ue(o, e) {
344
344
  switch (e.type) {
345
345
  case "from-registry":
346
- return go(s, e);
346
+ return bs(o, e);
347
347
  case "explicit":
348
- return fo(s, e);
348
+ return ws(o, e);
349
349
  default:
350
350
  return D(e);
351
351
  }
352
352
  }
353
- const Ct = { name: "Frontend/FromUrl", version: "1" }, Pt = {
353
+ const Dt = { name: "Frontend/FromUrl", version: "1" }, xt = {
354
354
  name: "Frontend/FromFolder",
355
355
  version: "1"
356
356
  };
357
- function mo(s, e) {
357
+ function Ss(o, e) {
358
358
  switch (e.type) {
359
359
  case "url":
360
- return s.createValue(
361
- Ct,
360
+ return o.createValue(
361
+ Dt,
362
362
  JSON.stringify({ url: e.url })
363
363
  );
364
364
  case "local":
365
- return s.createValue(
366
- Pt,
365
+ return o.createValue(
366
+ xt,
367
367
  JSON.stringify({
368
368
  path: e.path,
369
369
  signature: e.signature
@@ -373,11 +373,11 @@ function mo(s, e) {
373
373
  return D(e);
374
374
  }
375
375
  }
376
- const vo = { name: "BlockPackCustom", version: "1" }, Ft = "template", Bt = "frontend";
377
- function Xe(s) {
378
- return s.endsWith("/") ? s : `${s}/`;
376
+ const ks = { name: "BlockPackCustom", version: "1" }, jt = "template", Tt = "frontend";
377
+ function ot(o) {
378
+ return o.endsWith("/") ? o : `${o}/`;
379
379
  }
380
- class yo {
380
+ class Cs {
381
381
  constructor(e, t, r) {
382
382
  this.v2RegistryProvider = e, this.signer = t, this.http = r;
383
383
  }
@@ -386,22 +386,22 @@ class yo {
386
386
  case "explicit":
387
387
  return e.config;
388
388
  case "dev-v1": {
389
- const t = await Qe(e.folder), r = await T.promises.readFile(t.config, { encoding: "utf-8" });
389
+ const t = await rt(e.folder), r = await A.promises.readFile(t.config, { encoding: "utf-8" });
390
390
  return JSON.parse(r);
391
391
  }
392
392
  case "dev-v2": {
393
- const t = await _e(e.folder), r = await T.promises.readFile(t.components.model.file, {
393
+ const t = await qe(e.folder), r = await A.promises.readFile(t.components.model.file, {
394
394
  encoding: "utf-8"
395
395
  });
396
396
  return JSON.parse(r);
397
397
  }
398
398
  case "from-registry-v1": {
399
- const t = this.http !== void 0 ? { dispatcher: this.http } : {}, r = `${Xe(e.registryUrl)}${_.packageContentPrefix({ organization: e.id.organization, package: e.id.name, version: e.id.version })}`;
400
- return await (await H(`${r}/config.json`, t)).body.json();
399
+ const t = this.http !== void 0 ? { dispatcher: this.http } : {}, r = `${ot(e.registryUrl)}${_.packageContentPrefix({ organization: e.id.organization, package: e.id.name, version: e.id.version })}`;
400
+ return await (await M(`${r}/config.json`, t)).body.json();
401
401
  }
402
402
  case "from-registry-v2": {
403
- const t = this.http !== void 0 ? { dispatcher: this.http } : {}, o = await this.v2RegistryProvider.getRegistry(e.registryUrl).getComponents(e.id);
404
- return await (await H(o.model.url, t)).body.json();
403
+ const t = this.http !== void 0 ? { dispatcher: this.http } : {}, s = await this.v2RegistryProvider.getRegistry(e.registryUrl).getComponents(e.id);
404
+ return await (await M(s.model.url, t)).body.json();
405
405
  }
406
406
  default:
407
407
  return D(e);
@@ -412,59 +412,59 @@ class yo {
412
412
  case "explicit":
413
413
  return e;
414
414
  case "dev-v1": {
415
- const t = await Qe(e.folder), r = await T.promises.readFile(t.workflow), o = JSON.parse(
416
- await T.promises.readFile(t.config, "utf-8")
417
- ), i = t.ui;
415
+ const t = await rt(e.folder), r = await A.promises.readFile(t.workflow), s = JSON.parse(
416
+ await A.promises.readFile(t.config, "utf-8")
417
+ ), n = t.ui;
418
418
  return {
419
419
  type: "explicit",
420
420
  template: {
421
421
  type: "explicit",
422
422
  content: r
423
423
  },
424
- config: o,
424
+ config: s,
425
425
  frontend: {
426
426
  type: "local",
427
- path: i,
428
- signature: this.signer.sign(i)
427
+ path: n,
428
+ signature: this.signer.sign(n)
429
429
  },
430
430
  source: e
431
431
  };
432
432
  }
433
433
  case "dev-v2": {
434
- const t = await _e(e.folder), r = JSON.parse(
435
- await T.promises.readFile(t.components.model.file, {
434
+ const t = await qe(e.folder), r = JSON.parse(
435
+ await A.promises.readFile(t.components.model.file, {
436
436
  encoding: "utf-8"
437
437
  })
438
- ), o = await T.promises.readFile(
438
+ ), s = await A.promises.readFile(
439
439
  t.components.workflow.main.file
440
- ), i = t.components.ui.folder, n = { ...e };
441
- return e.mtime === void 0 && (n.mtime = await Ie(t)), {
440
+ ), n = t.components.ui.folder, i = { ...e };
441
+ return e.mtime === void 0 && (i.mtime = await Je(t)), {
442
442
  type: "explicit",
443
443
  template: {
444
444
  type: "explicit",
445
- content: o
445
+ content: s
446
446
  },
447
447
  config: r,
448
448
  frontend: {
449
449
  type: "local",
450
- path: i,
451
- signature: this.signer.sign(i)
450
+ path: n,
451
+ signature: this.signer.sign(n)
452
452
  },
453
- source: n
453
+ source: i
454
454
  };
455
455
  }
456
456
  case "from-registry-v1": {
457
- const t = this.http !== void 0 ? { dispatcher: this.http } : {}, r = `${Xe(e.registryUrl)}${_.packageContentPrefix({ organization: e.id.organization, package: e.id.name, version: e.id.version })}`, o = `${r}/template.plj.gz`, i = await H(o, t);
458
- if (i.statusCode !== 200)
457
+ const t = this.http !== void 0 ? { dispatcher: this.http } : {}, r = `${ot(e.registryUrl)}${_.packageContentPrefix({ organization: e.id.organization, package: e.id.name, version: e.id.version })}`, s = `${r}/template.plj.gz`, n = await M(s, t);
458
+ if (n.statusCode !== 200)
459
459
  throw new Error(
460
- `Block not found in registry (url = ${o} ; code = ${i.statusCode}): ` + JSON.stringify(e)
460
+ `Block not found in registry (url = ${s} ; code = ${n.statusCode}): ` + JSON.stringify(e)
461
461
  );
462
- const n = new Uint8Array(await i.body.arrayBuffer()), c = await (await H(`${r}/config.json`, t)).body.json();
462
+ const i = new Uint8Array(await n.body.arrayBuffer()), c = await (await M(`${r}/config.json`, t)).body.json();
463
463
  return {
464
464
  type: "explicit",
465
465
  template: {
466
466
  type: "explicit",
467
- content: n
467
+ content: i
468
468
  },
469
469
  config: c,
470
470
  frontend: {
@@ -475,7 +475,7 @@ class yo {
475
475
  };
476
476
  }
477
477
  case "from-registry-v2": {
478
- const t = this.http !== void 0 ? { dispatcher: this.http } : {}, o = await this.v2RegistryProvider.getRegistry(e.registryUrl).getComponents(e.id), i = async () => await (await H(o.model.url, t)).body.json(), n = async () => await (await H(o.workflow.main.url, t)).body.arrayBuffer(), [a, c] = await Promise.all([i(), n()]);
478
+ const t = this.http !== void 0 ? { dispatcher: this.http } : {}, s = await this.v2RegistryProvider.getRegistry(e.registryUrl).getComponents(e.id), n = async () => await (await M(s.model.url, t)).body.json(), i = async () => await (await M(s.workflow.main.url, t)).body.arrayBuffer(), [a, c] = await Promise.all([n(), i()]);
479
479
  return {
480
480
  type: "explicit",
481
481
  template: {
@@ -485,7 +485,7 @@ class yo {
485
485
  config: a,
486
486
  frontend: {
487
487
  type: "url",
488
- url: o.ui.url
488
+ url: s.ui.url
489
489
  },
490
490
  source: e
491
491
  };
@@ -495,25 +495,25 @@ class yo {
495
495
  }
496
496
  }
497
497
  }
498
- function bo(s, e) {
499
- const t = { config: e.config, source: e.source }, r = s.createStruct(vo, JSON.stringify(t));
500
- return s.createField(S(r, Ft), "Input", Le(s, e.template)), s.createField(S(r, Bt), "Input", mo(s, e.frontend)), s.lock(r), r;
498
+ function Ps(o, e) {
499
+ const t = { config: e.config, source: e.source }, r = o.createStruct(ks, JSON.stringify(t));
500
+ return o.createField(S(r, jt), "Input", Ue(o, e.template)), o.createField(S(r, Tt), "Input", Ss(o, e.frontend)), o.lock(r), r;
501
501
  }
502
- function et(s, e) {
502
+ function nt(o, e) {
503
503
  switch (e.type) {
504
504
  case "explicit":
505
- return bo(s, e);
505
+ return Ps(o, e);
506
506
  default:
507
507
  return D(e.type);
508
508
  }
509
509
  }
510
- function ie(s, e) {
511
- return { __isRef: !0, blockId: s, name: e };
510
+ function ie(o, e) {
511
+ return { __isRef: !0, blockId: o, name: e };
512
512
  }
513
- function wo(s) {
514
- return typeof s == "object" && s !== null && s.__isRef === !0 && "blockId" in s && "name" in s;
513
+ function Fs(o) {
514
+ return typeof o == "object" && o !== null && o.__isRef === !0 && "blockId" in o && "name" in o;
515
515
  }
516
- function Re(s, e, t) {
516
+ function xe(o, e, t) {
517
517
  const r = typeof e;
518
518
  switch (r) {
519
519
  case "function":
@@ -526,30 +526,30 @@ function Re(s, e, t) {
526
526
  return;
527
527
  case "object":
528
528
  if (e === null) return;
529
- if (wo(e))
530
- t === void 0 || t.has(e.blockId) ? s.upstreams.add(e.blockId) : s.missingReferences = !0;
529
+ if (Fs(e))
530
+ t === void 0 || t.has(e.blockId) ? o.upstreams.add(e.blockId) : o.missingReferences = !0;
531
531
  else if (Array.isArray(e))
532
- for (const o of e) Re(s, o, t);
532
+ for (const s of e) xe(o, s, t);
533
533
  else
534
- for (const [, o] of Object.entries(e))
535
- Re(s, o, t);
534
+ for (const [, s] of Object.entries(e))
535
+ xe(o, s, t);
536
536
  return;
537
537
  default:
538
538
  D(r);
539
539
  }
540
540
  }
541
- function So(s, e) {
541
+ function Rs(o, e) {
542
542
  const t = { upstreams: /* @__PURE__ */ new Set(), missingReferences: !1 };
543
- return Re(t, s, e), t;
543
+ return xe(t, o, e), t;
544
544
  }
545
- function L(s) {
545
+ function N(o) {
546
546
  return {
547
547
  *[Symbol.iterator]() {
548
- for (const e of s.groups) for (const t of e.blocks) yield t;
548
+ for (const e of o.groups) for (const t of e.blocks) yield t;
549
549
  }
550
550
  };
551
551
  }
552
- class Rt {
552
+ class Et {
553
553
  constructor(e) {
554
554
  /** Nodes are stored in the map in topological order */
555
555
  d(this, "nodes");
@@ -557,104 +557,104 @@ class Rt {
557
557
  }
558
558
  traverseIds(e, ...t) {
559
559
  const r = /* @__PURE__ */ new Set();
560
- return this.traverse(e, t, (o) => r.add(o.id)), r;
560
+ return this.traverse(e, t, (s) => r.add(s.id)), r;
561
561
  }
562
562
  traverseIdsExcludingRoots(e, ...t) {
563
563
  const r = this.traverseIds(e, ...t);
564
- for (const o of t) r.delete(o);
564
+ for (const s of t) r.delete(s);
565
565
  return r;
566
566
  }
567
567
  traverse(e, t, r) {
568
- let o = [...t];
569
- const i = new Set(o);
570
- for (; o.length > 0; ) {
571
- let n = [];
572
- for (const a of o) {
568
+ let s = [...t];
569
+ const n = new Set(s);
570
+ for (; s.length > 0; ) {
571
+ let i = [];
572
+ for (const a of s) {
573
573
  const c = this.nodes.get(a);
574
574
  r(c), c[e].forEach((u) => {
575
- i.has(u) || (i.add(u), n.push(u));
575
+ n.has(u) || (n.add(u), i.push(u));
576
576
  });
577
577
  }
578
- o = n;
578
+ s = i;
579
579
  }
580
580
  }
581
581
  }
582
- function Oe(s) {
582
+ function je(o) {
583
583
  const e = /* @__PURE__ */ new Map();
584
584
  let t;
585
- for (const { id: r } of L(s)) {
586
- const o = {
585
+ for (const { id: r } of N(o)) {
586
+ const s = {
587
587
  id: r,
588
588
  missingReferences: !1
589
589
  };
590
- e.set(r, o), t === void 0 ? o.upstream = /* @__PURE__ */ new Set() : (o.upstream = /* @__PURE__ */ new Set([t.id]), t.downstream = /* @__PURE__ */ new Set([o.id])), t = o;
590
+ e.set(r, s), t === void 0 ? s.upstream = /* @__PURE__ */ new Set() : (s.upstream = /* @__PURE__ */ new Set([t.id]), t.downstream = /* @__PURE__ */ new Set([s.id])), t = s;
591
591
  }
592
- return t !== void 0 && (t.downstream = /* @__PURE__ */ new Set()), new Rt(e);
592
+ return t !== void 0 && (t.downstream = /* @__PURE__ */ new Set()), new Et(e);
593
593
  }
594
- function ne(s, e) {
594
+ function ae(o, e) {
595
595
  const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
596
- for (const { id: o } of L(s)) {
597
- const i = e(o);
598
- if (i === void 0) continue;
599
- const n = So(i, r), a = {
600
- id: o,
601
- missingReferences: n.missingReferences,
602
- upstream: n.upstreams,
596
+ for (const { id: s } of N(o)) {
597
+ const n = e(s);
598
+ if (n === void 0) continue;
599
+ const i = Rs(n, r), a = {
600
+ id: s,
601
+ missingReferences: i.missingReferences,
602
+ upstream: i.upstreams,
603
603
  downstream: /* @__PURE__ */ new Set()
604
604
  // will be populated from downstream blocks
605
605
  };
606
- t.set(o, a), n.upstreams.forEach((c) => t.get(c).downstream.add(o)), r.add(o);
606
+ t.set(s, a), i.upstreams.forEach((c) => t.get(c).downstream.add(s)), r.add(s);
607
607
  }
608
- return new Rt(t);
608
+ return new Et(t);
609
609
  }
610
- function ko(s, e) {
611
- if (s.size !== e.size) return !1;
612
- for (const t of s) if (!e.has(t)) return !1;
610
+ function Bs(o, e) {
611
+ if (o.size !== e.size) return !1;
612
+ for (const t of o) if (!e.has(t)) return !1;
613
613
  return !0;
614
614
  }
615
- function De(s, e) {
616
- if (s.size > e.size) return De(e, s);
617
- for (const t of s) if (e.has(t)) return !0;
615
+ function Te(o, e) {
616
+ if (o.size > e.size) return Te(e, o);
617
+ for (const t of o) if (e.has(t)) return !0;
618
618
  return !1;
619
619
  }
620
- function tt(s, e) {
621
- const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
622
- return s.nodes.forEach((i) => {
623
- const n = e.nodes.get(i.id);
624
- n === void 0 ? t.add(i.id) : (!ko(i.upstream, n.upstream) || De(i.upstream, o)) && o.add(i.id);
625
- }), e.nodes.forEach((i) => {
626
- s.nodes.has(i.id) ? De(i.upstream, o) && o.add(i.id) : r.add(i.id);
627
- }), { onlyInA: t, onlyInB: r, different: o };
628
- }
629
- let ye;
630
- async function Ot() {
631
- if (ye === void 0) {
632
- const s = await ho(dr["pframes.export-pframe"]);
633
- if (s.type !== "explicit") throw new Error("Unexpected prepared template type.");
634
- const e = he("sha256").update(s.content).digest("hex");
635
- ye = { spec: s, hash: e };
636
- }
637
- return ye;
638
- }
639
- function Co(s, e, t) {
640
- return kt(s, e, !0, { pf: t }, ["result"]).result;
641
- }
642
- function be(s, e) {
643
- let t = !1, r, o;
620
+ function it(o, e) {
621
+ const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
622
+ return o.nodes.forEach((n) => {
623
+ const i = e.nodes.get(n.id);
624
+ i === void 0 ? t.add(n.id) : (!Bs(n.upstream, i.upstream) || Te(n.upstream, s)) && s.add(n.id);
625
+ }), e.nodes.forEach((n) => {
626
+ o.nodes.has(n.id) ? Te(n.upstream, s) && s.add(n.id) : r.add(n.id);
627
+ }), { onlyInA: t, onlyInB: r, different: s };
628
+ }
629
+ let be;
630
+ async function At() {
631
+ if (be === void 0) {
632
+ const o = await ys(yr["pframes.export-pframe"]);
633
+ if (o.type !== "explicit") throw new Error("Unexpected prepared template type.");
634
+ const e = he("sha256").update(o.content).digest("hex");
635
+ be = { spec: o, hash: e };
636
+ }
637
+ return be;
638
+ }
639
+ function Os(o, e, t) {
640
+ return Ot(o, e, !0, { pf: t }, ["result"]).result;
641
+ }
642
+ function we(o, e) {
643
+ let t = !1, r, s;
644
644
  return () => {
645
645
  if (!t)
646
- return t = !0, r = s(), o = e(), o;
647
- const i = s();
648
- return r !== i && (r = i, o = e()), e();
646
+ return t = !0, r = o(), s = e(), s;
647
+ const n = o();
648
+ return r !== n && (r = n, s = e()), e();
649
649
  };
650
650
  }
651
- class rt {
651
+ class at {
652
652
  constructor(e, t) {
653
- d(this, "currentInputsC", be(
653
+ d(this, "currentInputsC", we(
654
654
  () => this.fields.currentArgs.modCount,
655
655
  () => JSON.parse(Buffer.from(this.fields.currentArgs.value).toString())
656
656
  ));
657
- d(this, "actualProductionInputsC", be(
657
+ d(this, "actualProductionInputsC", we(
658
658
  () => {
659
659
  var e;
660
660
  return (e = this.fields.prodArgs) == null ? void 0 : e.modCount;
@@ -666,7 +666,7 @@ class rt {
666
666
  return JSON.parse(Buffer.from(e).toString());
667
667
  }
668
668
  ));
669
- d(this, "productionStaleC", be(
669
+ d(this, "productionStaleC", we(
670
670
  () => {
671
671
  var e;
672
672
  return `${this.fields.currentArgs.modCount}_${(e = this.fields.prodArgs) == null ? void 0 : e.modCount}`;
@@ -707,17 +707,17 @@ class rt {
707
707
  }
708
708
  getTemplate(e) {
709
709
  return e.getFutureFieldValue(
710
- y.unwrapHolder(e, this.fields.blockPack.ref),
711
- Ft,
710
+ b.unwrapHolder(e, this.fields.blockPack.ref),
711
+ jt,
712
712
  "Input"
713
713
  );
714
714
  }
715
715
  }
716
- const Po = (s) => {
717
- throw new Error(`No new block info for ${s}`);
716
+ const Ds = (o) => {
717
+ throw new Error(`No new block info for ${o}`);
718
718
  };
719
- class le {
720
- constructor(e, t, r, o, i, n, a, c, u, l, p, h) {
719
+ class de {
720
+ constructor(e, t, r, s, n, i, a, c, u, l, p, g) {
721
721
  d(this, "globalModCount", 0);
722
722
  d(this, "fieldsChanged", !1);
723
723
  //
@@ -736,7 +736,7 @@ class le {
736
736
  d(this, "stagingGraph");
737
737
  d(this, "pendingProductionGraph");
738
738
  d(this, "actualProductionGraph");
739
- this.rid = e, this.tx = t, this.author = r, this.schema = o, this.lastModified = i, this.meta = n, this.struct = a, this.renderingState = c, this.blocksInLimbo = u, this.blockInfos = l, this.blockFrontendStates = p, this.ctxExportTplHolder = h;
739
+ this.rid = e, this.tx = t, this.author = r, this.schema = s, this.lastModified = n, this.meta = i, this.struct = a, this.renderingState = c, this.blocksInLimbo = u, this.blockInfos = l, this.blockFrontendStates = p, this.ctxExportTplHolder = g;
740
740
  }
741
741
  fixProblems() {
742
742
  this.blockInfos.forEach((e) => {
@@ -750,16 +750,16 @@ class le {
750
750
  return JSON.parse(JSON.stringify(this.struct));
751
751
  }
752
752
  getStagingGraph() {
753
- return this.stagingGraph === void 0 && (this.stagingGraph = Oe(this.struct)), this.stagingGraph;
753
+ return this.stagingGraph === void 0 && (this.stagingGraph = je(this.struct)), this.stagingGraph;
754
754
  }
755
755
  getPendingProductionGraph() {
756
- return this.pendingProductionGraph === void 0 && (this.pendingProductionGraph = ne(
756
+ return this.pendingProductionGraph === void 0 && (this.pendingProductionGraph = ae(
757
757
  this.struct,
758
758
  (e) => this.getBlockInfo(e).currentInputs
759
759
  )), this.pendingProductionGraph;
760
760
  }
761
761
  getActualProductionGraph() {
762
- return this.actualProductionGraph === void 0 && (this.actualProductionGraph = ne(
762
+ return this.actualProductionGraph === void 0 && (this.actualProductionGraph = ae(
763
763
  this.struct,
764
764
  (e) => this.getBlockInfo(e).actualProductionInputs
765
765
  )), this.actualProductionGraph;
@@ -771,26 +771,26 @@ class le {
771
771
  return w(this.blockInfos.get(e));
772
772
  }
773
773
  getBlock(e) {
774
- for (const t of L(this.struct)) if (t.id === e) return t;
774
+ for (const t of N(this.struct)) if (t.id === e) return t;
775
775
  throw new Error("block not found");
776
776
  }
777
777
  setBlockFieldObj(e, t, r) {
778
- const o = S(this.rid, P(e, t));
778
+ const s = S(this.rid, P(e, t));
779
779
  if (r.ref === void 0) throw new Error("Can't set value with empty ref");
780
- this.getBlockInfo(e).fields[t] === void 0 ? this.tx.createField(o, "Dynamic", r.ref) : this.tx.setField(o, r.ref), this.getBlockInfo(e).fields[t] = {
780
+ this.getBlockInfo(e).fields[t] === void 0 ? this.tx.createField(s, "Dynamic", r.ref) : this.tx.setField(s, r.ref), this.getBlockInfo(e).fields[t] = {
781
781
  modCount: this.globalModCount++,
782
782
  ...r
783
783
  }, this.fieldsChanged = !0;
784
784
  }
785
- setBlockField(e, t, r, o, i) {
786
- this.setBlockFieldObj(e, t, { ref: r, status: o, value: i });
785
+ setBlockField(e, t, r, s, n) {
786
+ this.setBlockFieldObj(e, t, { ref: r, status: s, value: n });
787
787
  }
788
788
  deleteBlockFields(e, ...t) {
789
789
  let r = !1;
790
- const o = this.getBlockInfo(e);
791
- for (const i of t) {
792
- const n = o.fields;
793
- i in n && (this.tx.removeField(S(this.rid, P(e, i))), delete n[i], this.fieldsChanged = !0, r = !0);
790
+ const s = this.getBlockInfo(e);
791
+ for (const n of t) {
792
+ const i = s.fields;
793
+ n in i && (this.tx.removeField(S(this.rid, P(e, n))), delete i[n], this.fieldsChanged = !0, r = !0);
794
794
  }
795
795
  return r;
796
796
  }
@@ -804,32 +804,32 @@ class le {
804
804
  this.renderingState.stagingRefreshTimestamp = Date.now(), this.renderingStateChanged = !0;
805
805
  }
806
806
  resetStaging(e) {
807
- var r, o, i;
807
+ var r, s, n;
808
808
  const t = this.getBlockInfo(e).fields;
809
- ((r = t.stagingOutput) == null ? void 0 : r.status) === "Ready" && ((o = t.stagingCtx) == null ? void 0 : o.status) === "Ready" && ((i = t.stagingUiCtx) == null ? void 0 : i.status) === "Ready" && (this.setBlockFieldObj(e, "stagingOutputPrevious", t.stagingOutput), this.setBlockFieldObj(e, "stagingCtxPrevious", t.stagingCtx), this.setBlockFieldObj(e, "stagingUiCtxPrevious", t.stagingUiCtx)), this.deleteBlockFields(e, "stagingOutput", "stagingCtx", "stagingUiCtx") && this.resetStagingRefreshTimestamp();
809
+ ((r = t.stagingOutput) == null ? void 0 : r.status) === "Ready" && ((s = t.stagingCtx) == null ? void 0 : s.status) === "Ready" && ((n = t.stagingUiCtx) == null ? void 0 : n.status) === "Ready" && (this.setBlockFieldObj(e, "stagingOutputPrevious", t.stagingOutput), this.setBlockFieldObj(e, "stagingCtxPrevious", t.stagingCtx), this.setBlockFieldObj(e, "stagingUiCtxPrevious", t.stagingUiCtx)), this.deleteBlockFields(e, "stagingOutput", "stagingCtx", "stagingUiCtx") && this.resetStagingRefreshTimestamp();
810
810
  }
811
811
  resetProduction(e) {
812
- var r, o, i;
812
+ var r, s, n;
813
813
  const t = this.getBlockInfo(e).fields;
814
- ((r = t.prodOutput) == null ? void 0 : r.status) === "Ready" && ((o = t.prodCtx) == null ? void 0 : o.status) === "Ready" && ((i = t.prodUiCtx) == null ? void 0 : i.status) === "Ready" && (this.setBlockFieldObj(e, "prodOutputPrevious", t.prodOutput), this.setBlockFieldObj(e, "prodCtxPrevious", t.prodCtx), this.setBlockFieldObj(e, "prodUiCtxPrevious", t.prodUiCtx)), this.deleteBlockFields(e, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
814
+ ((r = t.prodOutput) == null ? void 0 : r.status) === "Ready" && ((s = t.prodCtx) == null ? void 0 : s.status) === "Ready" && ((n = t.prodUiCtx) == null ? void 0 : n.status) === "Ready" && (this.setBlockFieldObj(e, "prodOutputPrevious", t.prodOutput), this.setBlockFieldObj(e, "prodCtxPrevious", t.prodCtx), this.setBlockFieldObj(e, "prodUiCtxPrevious", t.prodUiCtx)), this.deleteBlockFields(e, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
815
815
  }
816
816
  /** Running blocks are reset, already computed moved to limbo. Returns if
817
817
  * either of the actions were actually performed. */
818
818
  resetOrLimboProduction(e) {
819
- var r, o;
819
+ var r, s;
820
820
  const t = this.getBlockInfo(e).fields;
821
- return ((r = t.prodOutput) == null ? void 0 : r.status) === "Ready" && ((o = t.prodCtx) == null ? void 0 : o.status) === "Ready" ? this.blocksInLimbo.has(e) ? !1 : (this.blocksInLimbo.add(e), this.renderingStateChanged = !0, this.deleteBlockFields(e, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious"), !0) : this.deleteBlockFields(e, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
821
+ return ((r = t.prodOutput) == null ? void 0 : r.status) === "Ready" && ((s = t.prodCtx) == null ? void 0 : s.status) === "Ready" ? this.blocksInLimbo.has(e) ? !1 : (this.blocksInLimbo.add(e), this.renderingStateChanged = !0, this.deleteBlockFields(e, "prodOutputPrevious", "prodCtxPrevious", "prodUiCtxPrevious"), !0) : this.deleteBlockFields(e, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs");
822
822
  }
823
823
  /** Optimally sets inputs for multiple blocks in one go */
824
824
  setArgs(e) {
825
825
  const t = [];
826
- for (const { blockId: r, args: o } of e) {
827
- const i = this.getBlockInfo(r);
828
- JSON.parse(o);
829
- const n = Buffer.from(o);
830
- if (Buffer.compare(i.fields.currentArgs.value, n) === 0) continue;
831
- const a = this.tx.createValue(y.JsonObject, n);
832
- this.setBlockField(r, "currentArgs", a, "Ready", n), this.blocksWithChangedInputs.add(r), t.push(r);
826
+ for (const { blockId: r, args: s } of e) {
827
+ const n = this.getBlockInfo(r);
828
+ JSON.parse(s);
829
+ const i = Buffer.from(s);
830
+ if (Buffer.compare(n.fields.currentArgs.value, i) === 0) continue;
831
+ const a = this.tx.createValue(b.JsonObject, i);
832
+ this.setBlockField(r, "currentArgs", a, "Ready", i), this.blocksWithChangedInputs.add(r), t.push(r);
833
833
  }
834
834
  this.getStagingGraph().traverse("downstream", t, ({ id: r }) => this.resetStaging(r)), t.length > 0 && this.updateLastModified();
835
835
  }
@@ -840,43 +840,43 @@ class le {
840
840
  /** Update block label */
841
841
  setBlockLabel(e, t) {
842
842
  const r = this.structure;
843
- let o = !1;
844
- for (const i of L(r))
845
- if (i.id === e) {
846
- i.label = t, o = !0;
843
+ let s = !1;
844
+ for (const n of N(r))
845
+ if (n.id === e) {
846
+ n.label = t, s = !0;
847
847
  break;
848
848
  }
849
- if (!o) throw new Error(`block ${e} not found`);
849
+ if (!s) throw new Error(`block ${e} not found`);
850
850
  this.updateStructure(r), this.updateLastModified();
851
851
  }
852
852
  createCtx(e, t) {
853
853
  const r = [];
854
- return e.forEach((o) => {
855
- const i = this.getBlockInfo(o);
856
- if (i.fields[t] === void 0 || i.fields[t].ref === void 0)
854
+ return e.forEach((s) => {
855
+ const n = this.getBlockInfo(s);
856
+ if (n.fields[t] === void 0 || n.fields[t].ref === void 0)
857
857
  throw new Error("One of the upstreams staging is not rendered.");
858
- r.push(y.unwrapHolder(this.tx, i.fields[t].ref));
859
- }), oo(this.tx, r);
858
+ r.push(b.unwrapHolder(this.tx, n.fields[t].ref));
859
+ }), us(this.tx, r);
860
860
  }
861
861
  exportCtx(e) {
862
- return Co(this.tx, y.unwrapHolder(this.tx, this.ctxExportTplHolder), e);
862
+ return Os(this.tx, b.unwrapHolder(this.tx, this.ctxExportTplHolder), e);
863
863
  }
864
864
  renderStagingFor(e) {
865
865
  this.resetStaging(e);
866
866
  const t = this.getBlockInfo(e), r = this.createCtx(this.getStagingGraph().nodes.get(e).upstream, "stagingCtx");
867
867
  if (this.getBlock(e).renderingMode !== "Heavy") throw new Error("not supported yet");
868
- const o = t.getTemplate(this.tx), i = Ze(this.tx, o, {
868
+ const s = t.getTemplate(this.tx), n = st(this.tx, s, {
869
869
  args: t.fields.currentArgs.ref,
870
- blockId: this.tx.createValue(y.JsonString, JSON.stringify(e)),
871
- isProduction: this.tx.createValue(y.JsonBool, JSON.stringify(!1)),
870
+ blockId: this.tx.createValue(b.JsonString, JSON.stringify(e)),
871
+ isProduction: this.tx.createValue(b.JsonBool, JSON.stringify(!1)),
872
872
  context: r
873
873
  });
874
874
  this.setBlockField(
875
875
  e,
876
876
  "stagingCtx",
877
- y.wrapInEphHolder(this.tx, i.context),
877
+ b.wrapInEphHolder(this.tx, n.context),
878
878
  "NotReady"
879
- ), this.setBlockField(e, "stagingUiCtx", this.exportCtx(i.context), "NotReady"), this.setBlockField(e, "stagingOutput", i.result, "NotReady");
879
+ ), this.setBlockField(e, "stagingUiCtx", this.exportCtx(n.context), "NotReady"), this.setBlockField(e, "stagingOutput", n.result, "NotReady");
880
880
  }
881
881
  renderProductionFor(e) {
882
882
  this.resetProduction(e);
@@ -886,45 +886,45 @@ class le {
886
886
  );
887
887
  if (this.getBlock(e).renderingMode === "Light")
888
888
  throw new Error("Can't render production for light block.");
889
- const o = t.getTemplate(this.tx), i = Ze(this.tx, o, {
889
+ const s = t.getTemplate(this.tx), n = st(this.tx, s, {
890
890
  args: t.fields.currentArgs.ref,
891
- blockId: this.tx.createValue(y.JsonString, JSON.stringify(e)),
892
- isProduction: this.tx.createValue(y.JsonBool, JSON.stringify(!0)),
891
+ blockId: this.tx.createValue(b.JsonString, JSON.stringify(e)),
892
+ isProduction: this.tx.createValue(b.JsonBool, JSON.stringify(!0)),
893
893
  context: r
894
894
  });
895
895
  this.setBlockField(
896
896
  e,
897
897
  "prodCtx",
898
- y.wrapInEphHolder(this.tx, i.context),
898
+ b.wrapInEphHolder(this.tx, n.context),
899
899
  "NotReady"
900
- ), this.setBlockField(e, "prodUiCtx", this.exportCtx(i.context), "NotReady"), this.setBlockField(e, "prodOutput", i.result, "NotReady"), this.setBlockFieldObj(e, "prodArgs", t.fields.currentArgs), this.blocksInLimbo.delete(e) && (this.renderingStateChanged = !0);
900
+ ), this.setBlockField(e, "prodUiCtx", this.exportCtx(n.context), "NotReady"), this.setBlockField(e, "prodOutput", n.result, "NotReady"), this.setBlockFieldObj(e, "prodArgs", t.fields.currentArgs), this.blocksInLimbo.delete(e) && (this.renderingStateChanged = !0);
901
901
  }
902
902
  //
903
903
  // Structure changes
904
904
  //
905
905
  /** Very generic method, better check for more specialized case-specific methods first. */
906
- updateStructure(e, t = Po) {
907
- const r = this.getStagingGraph(), o = this.getActualProductionGraph(), i = Oe(e), n = ne(
906
+ updateStructure(e, t = Ds) {
907
+ const r = this.getStagingGraph(), s = this.getActualProductionGraph(), n = je(e), i = ae(
908
908
  e,
909
909
  (u) => {
910
910
  var l;
911
911
  return (l = this.blockInfos.get(u)) == null ? void 0 : l.actualProductionInputs;
912
912
  }
913
- ), a = tt(r, i), c = tt(o, n);
913
+ ), a = it(r, n), c = it(s, i);
914
914
  for (const u of a.onlyInA) {
915
915
  const { fields: l } = this.getBlockInfo(u);
916
916
  this.deleteBlockFields(u, ...Object.keys(l)), this.blockInfos.delete(u), this.blocksInLimbo.delete(u) && (this.renderingStateChanged = !0), this.blockFrontendStates.delete(u) && this.changedBlockFrontendStates.add(u);
917
917
  }
918
918
  for (const u of a.onlyInB) {
919
- const l = new rt(u, {});
919
+ const l = new at(u, {});
920
920
  this.blockInfos.set(u, l);
921
- const p = t(u), h = et(this.tx, p.blockPack);
922
- this.setBlockField(u, "blockPack", y.wrapInHolder(this.tx, h), "NotReady");
923
- const f = Buffer.from(p.args), b = this.tx.createValue(y.JsonObject, f);
924
- this.setBlockField(u, "currentArgs", b, "Ready", f), l.check();
921
+ const p = t(u), g = nt(this.tx, p.blockPack);
922
+ this.setBlockField(u, "blockPack", b.wrapInHolder(this.tx, g), "NotReady");
923
+ const m = Buffer.from(p.args), h = this.tx.createValue(b.JsonObject, m);
924
+ this.setBlockField(u, "currentArgs", h, "Ready", m), l.check();
925
925
  }
926
926
  for (const u of a.different) this.resetStaging(u);
927
- o.traverse("downstream", [...c.different], (u) => {
927
+ s.traverse("downstream", [...c.different], (u) => {
928
928
  this.resetOrLimboProduction(u.id);
929
929
  }), (a.onlyInB.size > 0 || a.onlyInA.size > 0 || a.different.size > 0) && this.resetStagingRefreshTimestamp(), this.struct = e, this.structureChanged = !0, this.stagingGraph = void 0, this.pendingProductionGraph = void 0, this.actualProductionGraph = void 0, this.updateLastModified();
930
930
  }
@@ -932,32 +932,32 @@ class le {
932
932
  // Structure change helpers
933
933
  //
934
934
  addBlock(e, t, r) {
935
- const o = this.structure;
935
+ const s = this.structure;
936
936
  if (r === void 0)
937
- o.groups[o.groups.length - 1].blocks.push(e);
937
+ s.groups[s.groups.length - 1].blocks.push(e);
938
938
  else {
939
- let i = !1;
940
- for (const n of o.groups) {
941
- const a = n.blocks.findIndex((c) => c.id === r);
939
+ let n = !1;
940
+ for (const i of s.groups) {
941
+ const a = i.blocks.findIndex((c) => c.id === r);
942
942
  if (!(a < 0)) {
943
- n.blocks.splice(a, 0, e), i = !0;
943
+ i.blocks.splice(a, 0, e), n = !0;
944
944
  break;
945
945
  }
946
946
  }
947
- if (!i) throw new Error(`Can't find element with id: ${r}`);
947
+ if (!n) throw new Error(`Can't find element with id: ${r}`);
948
948
  }
949
- this.updateStructure(o, (i) => {
950
- if (i !== e.id) throw new Error("Unexpected");
949
+ this.updateStructure(s, (n) => {
950
+ if (n !== e.id) throw new Error("Unexpected");
951
951
  return t;
952
952
  });
953
953
  }
954
954
  deleteBlock(e) {
955
955
  const t = this.structure;
956
956
  let r = !1;
957
- for (const o of t.groups) {
958
- const i = o.blocks.findIndex((n) => n.id === e);
959
- if (!(i < 0)) {
960
- o.blocks.splice(i, 1), r = !0;
957
+ for (const s of t.groups) {
958
+ const n = s.blocks.findIndex((i) => i.id === e);
959
+ if (!(n < 0)) {
960
+ s.blocks.splice(n, 1), r = !0;
961
961
  break;
962
962
  }
963
963
  }
@@ -968,85 +968,85 @@ class le {
968
968
  // Block-pack migration
969
969
  //
970
970
  migrateBlockPack(e, t, r) {
971
- const o = this.getBlockInfo(e);
971
+ const s = this.getBlockInfo(e);
972
972
  this.setBlockField(
973
973
  e,
974
974
  "blockPack",
975
- y.wrapInHolder(this.tx, et(this.tx, t)),
975
+ b.wrapInHolder(this.tx, nt(this.tx, t)),
976
976
  "NotReady"
977
- ), r !== void 0 ? (this.setArgs([{ blockId: e, args: r }]), this.setUiState(e, void 0)) : this.getStagingGraph().traverse("downstream", [e], ({ id: i }) => this.resetStaging(i)), o.productionRendered && this.getActualProductionGraph().traverse(
977
+ ), r !== void 0 ? (this.setArgs([{ blockId: e, args: r }]), this.setUiState(e, void 0)) : this.getStagingGraph().traverse("downstream", [e], ({ id: n }) => this.resetStaging(n)), s.productionRendered && this.getActualProductionGraph().traverse(
978
978
  "downstream",
979
979
  [e],
980
- ({ id: i }) => this.resetOrLimboProduction(i)
980
+ ({ id: n }) => this.resetOrLimboProduction(n)
981
981
  ), this.updateLastModified();
982
982
  }
983
983
  //
984
984
  // Render
985
985
  //
986
986
  renderProduction(e, t = !1) {
987
- const r = new Set(e), o = this.getPendingProductionGraph();
987
+ const r = new Set(e), s = this.getPendingProductionGraph();
988
988
  if (t)
989
- o.traverse("upstream", e, (n) => {
990
- r.add(n.id);
989
+ s.traverse("upstream", e, (i) => {
990
+ r.add(i.id);
991
991
  });
992
992
  else
993
- for (const n of r) {
994
- const a = o.nodes.get(n);
995
- if (a === void 0) throw new Error(`Can't find block with id: ${n}`);
993
+ for (const i of r) {
994
+ const a = s.nodes.get(i);
995
+ if (a === void 0) throw new Error(`Can't find block with id: ${i}`);
996
996
  for (const c of a.upstream)
997
997
  if (!r.has(c))
998
998
  throw new Error("Can't render blocks not including all upstreams.");
999
999
  }
1000
- const i = /* @__PURE__ */ new Set();
1001
- for (const n of L(this.structure)) {
1002
- if (!r.has(n.id)) continue;
1003
- let a = this.getBlockInfo(n.id).requireProductionRendering || this.blocksInLimbo.has(n.id);
1000
+ const n = /* @__PURE__ */ new Set();
1001
+ for (const i of N(this.structure)) {
1002
+ if (!r.has(i.id)) continue;
1003
+ let a = this.getBlockInfo(i.id).requireProductionRendering || this.blocksInLimbo.has(i.id);
1004
1004
  if (!a) {
1005
- for (const c of o.nodes.get(n.id).upstream)
1006
- if (i.has(c)) {
1005
+ for (const c of s.nodes.get(i.id).upstream)
1006
+ if (n.has(c)) {
1007
1007
  a = !0;
1008
1008
  break;
1009
1009
  }
1010
1010
  }
1011
- a && (this.renderProductionFor(n.id), i.add(n.id));
1011
+ a && (this.renderProductionFor(i.id), n.add(i.id));
1012
1012
  }
1013
- return o.traverse("downstream", [...i], (n) => {
1014
- i.has(n.id) || this.resetOrLimboProduction(n.id);
1015
- }), i.size > 0 && this.updateLastModified(), i;
1013
+ return s.traverse("downstream", [...n], (i) => {
1014
+ n.has(i.id) || this.resetOrLimboProduction(i.id);
1015
+ }), n.size > 0 && this.updateLastModified(), n;
1016
1016
  }
1017
1017
  /** Stops running blocks from the list and modify states of other blocks
1018
1018
  * accordingly */
1019
1019
  stopProduction(...e) {
1020
- var n, a;
1021
- const t = this.getActualProductionGraph(), r = new mt(e), o = new Set(e), i = [];
1020
+ var i, a;
1021
+ const t = this.getActualProductionGraph(), r = new St(e), s = new Set(e), n = [];
1022
1022
  for (; !r.isEmpty(); ) {
1023
1023
  const c = r.shift(), u = this.getBlockInfo(c).fields;
1024
- if (!(((n = u.prodOutput) == null ? void 0 : n.status) === "Ready" && ((a = u.prodCtx) == null ? void 0 : a.status) === "Ready") && this.deleteBlockFields(c, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
1025
- i.push(c);
1024
+ if (!(((i = u.prodOutput) == null ? void 0 : i.status) === "Ready" && ((a = u.prodCtx) == null ? void 0 : a.status) === "Ready") && this.deleteBlockFields(c, "prodOutput", "prodCtx", "prodUiCtx", "prodArgs")) {
1025
+ n.push(c);
1026
1026
  for (const l of t.traverseIdsExcludingRoots("downstream", c))
1027
- o.has(l) || (r.push(l), o.add(l));
1027
+ s.has(l) || (r.push(l), s.add(l));
1028
1028
  }
1029
1029
  }
1030
- for (const c of t.traverseIdsExcludingRoots("downstream", ...i))
1030
+ for (const c of t.traverseIdsExcludingRoots("downstream", ...n))
1031
1031
  this.resetOrLimboProduction(c);
1032
1032
  }
1033
1033
  traverseWithStagingLag(e) {
1034
1034
  const t = /* @__PURE__ */ new Map();
1035
- this.getStagingGraph().nodes.forEach((o) => {
1036
- let n = this.getBlockInfo(o.id).stagingRendered ? 0 : 1;
1037
- o.upstream.forEach((a) => {
1035
+ this.getStagingGraph().nodes.forEach((s) => {
1036
+ let i = this.getBlockInfo(s.id).stagingRendered ? 0 : 1;
1037
+ s.upstream.forEach((a) => {
1038
1038
  const c = t.get(a);
1039
- c !== 0 && (n = Math.max(c + 1, n));
1040
- }), e(o.id, n), t.set(o.id, n);
1039
+ c !== 0 && (i = Math.max(c + 1, i));
1040
+ }), e(s.id, i), t.set(s.id, i);
1041
1041
  });
1042
1042
  }
1043
1043
  /** @param stagingRenderingRate rate in blocks per second */
1044
1044
  refreshStagings(e) {
1045
1045
  const t = Date.now() - this.renderingState.stagingRefreshTimestamp, r = e === void 0 ? void 0 : 1 + Math.max(0, t * e / 1e3);
1046
- let o = 0;
1047
- this.traverseWithStagingLag((i, n) => {
1048
- n !== 0 && (r === void 0 || n <= r) && (this.renderStagingFor(i), o++);
1049
- }), o > 0 && this.resetStagingRefreshTimestamp();
1046
+ let s = 0;
1047
+ this.traverseWithStagingLag((n, i) => {
1048
+ i !== 0 && (r === void 0 || i <= r) && (this.renderStagingFor(n), s++);
1049
+ }), s > 0 && this.resetStagingRefreshTimestamp();
1050
1050
  }
1051
1051
  //
1052
1052
  // Meta
@@ -1061,13 +1061,13 @@ class le {
1061
1061
  /** @param stagingRenderingRate rate in blocks per second */
1062
1062
  doRefresh(e) {
1063
1063
  this.refreshStagings(e), this.blockInfos.forEach((t) => {
1064
- var r, o, i, n;
1065
- ((r = t.fields.prodCtx) == null ? void 0 : r.status) === "Ready" && ((o = t.fields.prodOutput) == null ? void 0 : o.status) === "Ready" && this.deleteBlockFields(
1064
+ var r, s, n, i;
1065
+ ((r = t.fields.prodCtx) == null ? void 0 : r.status) === "Ready" && ((s = t.fields.prodOutput) == null ? void 0 : s.status) === "Ready" && this.deleteBlockFields(
1066
1066
  t.id,
1067
1067
  "prodOutputPrevious",
1068
1068
  "prodCtxPrevious",
1069
1069
  "prodUiCtxPrevious"
1070
- ), ((i = t.fields.stagingCtx) == null ? void 0 : i.status) === "Ready" && ((n = t.fields.stagingOutput) == null ? void 0 : n.status) === "Ready" && this.deleteBlockFields(
1070
+ ), ((n = t.fields.stagingCtx) == null ? void 0 : n.status) === "Ready" && ((i = t.fields.stagingOutput) == null ? void 0 : i.status) === "Ready" && this.deleteBlockFields(
1071
1071
  t.id,
1072
1072
  "stagingOutputPrevious",
1073
1073
  "stagingCtxPrevious",
@@ -1078,215 +1078,215 @@ class le {
1078
1078
  assignAuthorMarkers() {
1079
1079
  const e = this.author ? JSON.stringify(this.author) : void 0;
1080
1080
  for (const t of this.blocksWithChangedInputs)
1081
- e === void 0 ? this.tx.deleteKValue(this.rid, Pe(t)) : this.tx.setKValue(this.rid, Pe(t), e);
1082
- (this.metaChanged || this.structureChanged) && (e === void 0 ? this.tx.deleteKValue(this.rid, Fe) : this.tx.setKValue(this.rid, Fe, e));
1081
+ e === void 0 ? this.tx.deleteKValue(this.rid, Be(t)) : this.tx.setKValue(this.rid, Be(t), e);
1082
+ (this.metaChanged || this.structureChanged) && (e === void 0 ? this.tx.deleteKValue(this.rid, Oe) : this.tx.setKValue(this.rid, Oe, e));
1083
1083
  }
1084
1084
  save() {
1085
1085
  if (this.wasModified) {
1086
- this.lastModifiedChanged && this.tx.setKValue(this.rid, ee, JSON.stringify(this.lastModified)), this.structureChanged && this.tx.setKValue(this.rid, W, JSON.stringify(this.struct)), this.renderingStateChanged && this.tx.setKValue(
1086
+ this.lastModifiedChanged && this.tx.setKValue(this.rid, te, JSON.stringify(this.lastModified)), this.structureChanged && this.tx.setKValue(this.rid, W, JSON.stringify(this.struct)), this.renderingStateChanged && this.tx.setKValue(
1087
1087
  this.rid,
1088
- ue,
1088
+ le,
1089
1089
  JSON.stringify({
1090
1090
  ...this.renderingState,
1091
1091
  blocksInLimbo: [...this.blocksInLimbo]
1092
1092
  })
1093
- ), this.metaChanged && this.tx.setKValue(this.rid, te, JSON.stringify(this.meta));
1093
+ ), this.metaChanged && this.tx.setKValue(this.rid, re, JSON.stringify(this.meta));
1094
1094
  for (const e of this.changedBlockFrontendStates) {
1095
1095
  const t = this.blockFrontendStates.get(e);
1096
- t === void 0 ? this.tx.deleteKValue(this.rid, Ce(e)) : this.tx.setKValue(this.rid, Ce(e), t);
1096
+ t === void 0 ? this.tx.deleteKValue(this.rid, Re(e)) : this.tx.setKValue(this.rid, Re(e), t);
1097
1097
  }
1098
1098
  this.assignAuthorMarkers();
1099
1099
  }
1100
1100
  }
1101
1101
  static async load(e, t, r) {
1102
- const o = e.getResourceData(t, !0), i = e.getKValueJson(t, bt), n = e.getKValueJson(t, ee), a = e.getKValueJson(t, te), c = e.getKValueJson(t, W), u = e.getKValueJson(t, ue), l = e.listKeyValuesString(t), [
1102
+ const s = e.getResourceData(t, !0), n = e.getKValueJson(t, Ft), i = e.getKValueJson(t, te), a = e.getKValueJson(t, re), c = e.getKValueJson(t, W), u = e.getKValueJson(t, le), l = e.listKeyValuesString(t), [
1103
1103
  p,
1104
+ g,
1105
+ m,
1104
1106
  h,
1105
- f,
1106
- b,
1107
1107
  C,
1108
- { stagingRefreshTimestamp: I, blocksInLimbo: $ },
1109
- K
1108
+ { stagingRefreshTimestamp: I, blocksInLimbo: G },
1109
+ U
1110
1110
  ] = await Promise.all([
1111
- o,
1112
- i,
1111
+ s,
1113
1112
  n,
1113
+ i,
1114
1114
  a,
1115
1115
  c,
1116
1116
  u,
1117
1117
  l
1118
1118
  ]);
1119
- if (h !== wt)
1119
+ if (g !== Rt)
1120
1120
  throw new Error(
1121
- `Can't act on this project resource because it has a wrong schema version: ${h}`
1121
+ `Can't act on this project resource because it has a wrong schema version: ${g}`
1122
1122
  );
1123
- const G = /* @__PURE__ */ new Map();
1124
- for (const v of p.fields) {
1125
- const O = Hr(v.name);
1123
+ const H = /* @__PURE__ */ new Map();
1124
+ for (const y of p.fields) {
1125
+ const O = Qr(y.name);
1126
1126
  if (O === void 0) continue;
1127
- let B = G.get(O.blockId);
1128
- B === void 0 && (B = {
1127
+ let R = H.get(O.blockId);
1128
+ R === void 0 && (R = {
1129
1129
  id: O.blockId,
1130
1130
  fields: {}
1131
- }, G.set(O.blockId, B)), B.fields[O.fieldName] = ce(v.value) ? { modCount: 0 } : { modCount: 0, ref: v.value };
1131
+ }, H.set(O.blockId, R)), R.fields[O.fieldName] = ue(y.value) ? { modCount: 0 } : { modCount: 0, ref: y.value };
1132
1132
  }
1133
- const z = await Ot(), oe = Be(z.hash), k = p.fields.find(
1134
- (v) => v.name === oe
1133
+ const z = await At(), oe = De(z.hash), k = p.fields.find(
1134
+ (y) => y.name === oe
1135
1135
  );
1136
1136
  let J;
1137
- k !== void 0 ? J = Se(k.value) : (J = y.wrapInHolder(e, Le(e, z.spec)), e.createField(
1138
- S(t, Be(z.hash)),
1137
+ k !== void 0 ? J = Pe(k.value) : (J = b.wrapInHolder(e, Ue(e, z.spec)), e.createField(
1138
+ S(t, De(z.hash)),
1139
1139
  "Dynamic",
1140
1140
  J
1141
1141
  ));
1142
- const Y = { stagingRefreshTimestamp: I }, A = new Set($), x = /* @__PURE__ */ new Map();
1143
- for (const v of K) {
1144
- const O = Ur(v.key);
1145
- O !== void 0 && x.set(O, v.value);
1142
+ const Y = { stagingRefreshTimestamp: I }, E = new Set(G), x = /* @__PURE__ */ new Map();
1143
+ for (const y of U) {
1144
+ const O = zr(y.key);
1145
+ O !== void 0 && x.set(O, y.value);
1146
1146
  }
1147
- const R = [];
1148
- G.forEach(({ id: v, fields: O }) => {
1149
- for (const [, B] of Object.entries(O))
1150
- if (B.ref !== void 0) {
1151
- if (!rr(B.ref) || or(B.ref))
1147
+ const B = [];
1148
+ H.forEach(({ id: y, fields: O }) => {
1149
+ for (const [, R] of Object.entries(O))
1150
+ if (R.ref !== void 0) {
1151
+ if (!cr(R.ref) || ur(R.ref))
1152
1152
  throw new Error("unexpected behaviour");
1153
- R.push([B, e.getResourceData(B.ref, !1)]);
1153
+ B.push([R, e.getResourceData(R.ref, !1)]);
1154
1154
  }
1155
1155
  });
1156
- for (const [v, O] of R) {
1157
- const B = await O;
1158
- v.value = B.data, We(B.error) ? v.status = "Error" : B.resourceReady || We(B.originalResourceId) ? v.status = "Ready" : v.status = "NotReady";
1156
+ for (const [y, O] of B) {
1157
+ const R = await O;
1158
+ y.value = R.data, Qe(R.error) ? y.status = "Error" : R.resourceReady || Qe(R.originalResourceId) ? y.status = "Ready" : y.status = "NotReady";
1159
1159
  }
1160
- const M = /* @__PURE__ */ new Map();
1161
- G.forEach(({ id: v, fields: O }) => M.set(v, new rt(v, O)));
1162
- const N = /* @__PURE__ */ new Set();
1163
- for (const v of L(C)) {
1164
- if (!M.has(v.id))
1165
- throw new Error(`Inconsistent project structure: no inputs for ${v.id}`);
1166
- N.add(v.id);
1160
+ const K = /* @__PURE__ */ new Map();
1161
+ H.forEach(({ id: y, fields: O }) => K.set(y, new at(y, O)));
1162
+ const L = /* @__PURE__ */ new Set();
1163
+ for (const y of N(C)) {
1164
+ if (!K.has(y.id))
1165
+ throw new Error(`Inconsistent project structure: no inputs for ${y.id}`);
1166
+ L.add(y.id);
1167
1167
  }
1168
- M.forEach((v) => {
1169
- if (!N.has(v.id))
1170
- throw new Error(`Inconsistent project structure: no structure entry for ${v.id}`);
1171
- v.check();
1168
+ K.forEach((y) => {
1169
+ if (!L.has(y.id))
1170
+ throw new Error(`Inconsistent project structure: no structure entry for ${y.id}`);
1171
+ y.check();
1172
1172
  });
1173
- const se = new le(
1173
+ const ne = new de(
1174
1174
  t,
1175
1175
  e,
1176
1176
  r,
1177
+ g,
1178
+ m,
1177
1179
  h,
1178
- f,
1179
- b,
1180
1180
  C,
1181
1181
  Y,
1182
- A,
1183
- M,
1182
+ E,
1183
+ K,
1184
1184
  x,
1185
1185
  J
1186
1186
  );
1187
- return se.fixProblems(), se;
1187
+ return ne.fixProblems(), ne;
1188
1188
  }
1189
1189
  }
1190
- async function Fo(s, e = Lr) {
1191
- const t = s.createEphemeral(Nr);
1192
- s.lock(t);
1190
+ async function xs(o, e = $r) {
1191
+ const t = o.createEphemeral(Gr);
1192
+ o.lock(t);
1193
1193
  const r = String(Date.now());
1194
- s.setKValue(t, bt, JSON.stringify(wt)), s.setKValue(t, Ve, r), s.setKValue(t, ee, r), s.setKValue(t, te, JSON.stringify(e)), s.setKValue(t, W, JSON.stringify(Ir)), s.setKValue(t, ue, JSON.stringify(Vr));
1195
- const o = await Ot();
1196
- return s.createField(
1197
- S(t, Be(o.hash)),
1194
+ o.setKValue(t, Ft, JSON.stringify(Rt)), o.setKValue(t, Me, r), o.setKValue(t, te, r), o.setKValue(t, re, JSON.stringify(e)), o.setKValue(t, W, JSON.stringify(Ur)), o.setKValue(t, le, JSON.stringify(Kr));
1195
+ const s = await At();
1196
+ return o.createField(
1197
+ S(t, De(s.hash)),
1198
1198
  "Dynamic",
1199
- y.wrapInHolder(s, Le(s, o.spec))
1199
+ b.wrapInHolder(o, Ue(o, s.spec))
1200
1200
  ), t;
1201
1201
  }
1202
- async function we(s, e, t) {
1203
- return V(s, e, void 0, t);
1202
+ async function Se(o, e, t) {
1203
+ return V(o, e, void 0, t);
1204
1204
  }
1205
- async function V(s, e, t, r) {
1206
- if (s instanceof tr)
1207
- return await s.withWriteTx("ProjectAction", async (o) => {
1208
- const i = await le.load(o, e, t), n = await r(i);
1209
- return i.wasModified && (i.save(), await o.commit()), n;
1205
+ async function V(o, e, t, r) {
1206
+ if (o instanceof ar)
1207
+ return await o.withWriteTx("ProjectAction", async (s) => {
1208
+ const n = await de.load(s, e, t), i = await r(n);
1209
+ return n.wasModified && (n.save(), await s.commit()), i;
1210
1210
  });
1211
1211
  {
1212
- const o = await le.load(s, e, t), i = await r(o);
1213
- return o.save(), i;
1212
+ const s = await de.load(o, e, t), n = await r(s);
1213
+ return s.save(), n;
1214
1214
  }
1215
1215
  }
1216
- function* Bo(s) {
1217
- switch (s.type) {
1216
+ function* js(o) {
1217
+ switch (o.type) {
1218
1218
  case "Json":
1219
1219
  return;
1220
1220
  case "JsonPartitioned":
1221
- for (const [, e] of Object.entries(s.parts)) yield e;
1221
+ for (const [, e] of Object.entries(o.parts)) yield e;
1222
1222
  return;
1223
1223
  case "BinaryPartitioned":
1224
- for (const [, { index: e, values: t }] of Object.entries(s.parts))
1224
+ for (const [, { index: e, values: t }] of Object.entries(o.parts))
1225
1225
  yield e, yield t;
1226
1226
  return;
1227
1227
  default:
1228
- D(s);
1228
+ D(o);
1229
1229
  }
1230
1230
  }
1231
- function ot(s, e) {
1231
+ function ct(o, e) {
1232
1232
  return Object.fromEntries(
1233
- Object.entries(s).map(([t, r]) => [t, e(r, t)])
1233
+ Object.entries(o).map(([t, r]) => [t, e(r, t)])
1234
1234
  );
1235
1235
  }
1236
- function Ro(s, e) {
1237
- switch (s.type) {
1236
+ function Ts(o, e) {
1237
+ switch (o.type) {
1238
1238
  case "Json":
1239
- return { ...s };
1239
+ return { ...o };
1240
1240
  case "JsonPartitioned":
1241
- return { ...s, parts: ot(s.parts, e) };
1241
+ return { ...o, parts: ct(o.parts, e) };
1242
1242
  case "BinaryPartitioned":
1243
1243
  return {
1244
- ...s,
1245
- parts: ot(s.parts, (t) => ({
1244
+ ...o,
1245
+ parts: ct(o.parts, (t) => ({
1246
1246
  index: e(t.index),
1247
1247
  values: e(t.values)
1248
1248
  }))
1249
1249
  };
1250
1250
  default:
1251
- D(s);
1251
+ D(o);
1252
1252
  }
1253
1253
  }
1254
- const Oo = re("PColumnData/JsonPartitioned", "1"), Do = re(
1254
+ const Es = se("PColumnData/JsonPartitioned", "1"), As = se(
1255
1255
  "PColumnData/Partitioned/JsonPartitioned",
1256
1256
  "1"
1257
- ), xo = re("PColumnData/BinaryPartitioned", "1"), jo = re(
1257
+ ), Is = se("PColumnData/BinaryPartitioned", "1"), Vs = se(
1258
1258
  "PColumnData/Partitioned/BinaryPartitioned",
1259
1259
  "1"
1260
- ), Eo = re("PColumnData/Json", "1");
1261
- function Ao(s) {
1262
- if (!s.getIsReadyOrError()) throw new Error("Data not ready.");
1263
- const e = s.getDataAsJson();
1260
+ ), Ns = se("PColumnData/Json", "1");
1261
+ function Ls(o) {
1262
+ if (!o.getIsReadyOrError()) throw new Error("Data not ready.");
1263
+ const e = o.getDataAsJson();
1264
1264
  if (e === void 0)
1265
1265
  throw new Error("unexpected data info structure, no resource data");
1266
- if (U(s.resourceType, Eo)) {
1266
+ if ($(o.resourceType, Ns)) {
1267
1267
  const t = e;
1268
1268
  return {
1269
1269
  type: "Json",
1270
1270
  keyLength: t.keyLength,
1271
1271
  data: t.data
1272
1272
  };
1273
- } else if (U(s.resourceType, Oo)) {
1273
+ } else if ($(o.resourceType, Es)) {
1274
1274
  const t = e, r = Object.fromEntries(
1275
- s.listInputFields().map((o) => [o, s.traverse({ field: o, errorIfFieldNotSet: !0 }).resourceInfo])
1275
+ o.listInputFields().map((s) => [s, o.traverse({ field: s, errorIfFieldNotSet: !0 }).resourceInfo])
1276
1276
  );
1277
1277
  return {
1278
1278
  type: "JsonPartitioned",
1279
1279
  partitionKeyLength: t.partitionKeyLength,
1280
1280
  parts: r
1281
1281
  };
1282
- } else if (U(s.resourceType, Do)) {
1282
+ } else if ($(o.resourceType, As)) {
1283
1283
  const t = e, r = {};
1284
- for (const o of s.listInputFields()) {
1285
- const i = s.traverse({ field: o, errorIfFieldNotSet: !0 }), n = i.listInputFields();
1286
- if (n === void 0) throw new Error(`no partition keys for super key ${o}`);
1287
- for (const a of n) {
1288
- const c = JSON.stringify([...JSON.parse(o), ...JSON.parse(a)]);
1289
- r[c] = i.traverse({ field: a, errorIfFieldNotSet: !0 }).resourceInfo;
1284
+ for (const s of o.listInputFields()) {
1285
+ const n = o.traverse({ field: s, errorIfFieldNotSet: !0 }), i = n.listInputFields();
1286
+ if (i === void 0) throw new Error(`no partition keys for super key ${s}`);
1287
+ for (const a of i) {
1288
+ const c = JSON.stringify([...JSON.parse(s), ...JSON.parse(a)]);
1289
+ r[c] = n.traverse({ field: a, errorIfFieldNotSet: !0 }).resourceInfo;
1290
1290
  }
1291
1291
  }
1292
1292
  return {
@@ -1294,44 +1294,44 @@ function Ao(s) {
1294
1294
  partitionKeyLength: t.superPartitionKeyLength + t.partitionKeyLength,
1295
1295
  parts: r
1296
1296
  };
1297
- } else if (U(s.resourceType, xo)) {
1297
+ } else if ($(o.resourceType, Is)) {
1298
1298
  const t = e, r = {};
1299
- for (const o of s.listInputFields())
1300
- if (o.endsWith(".index")) {
1301
- const i = o.slice(0, o.length - 6);
1302
- let n = r[i];
1303
- n === void 0 && (n = {}, r[i] = n), n.index = s.traverse({ field: o, errorIfFieldNotSet: !0 }).resourceInfo;
1304
- } else if (o.endsWith(".values")) {
1305
- const i = o.slice(0, o.length - 7);
1306
- let n = r[i];
1307
- n === void 0 && (n = {}, r[i] = n), n.values = s.traverse({ field: o, errorIfFieldNotSet: !0 }).resourceInfo;
1308
- } else throw new Error(`unrecognized part field name: ${o}`);
1309
- for (const [o, i] of Object.entries(r)) {
1310
- if (i.index === void 0) throw new Error(`no index for part ${o}`);
1311
- if (i.values === void 0) throw new Error(`no values for part ${o}`);
1299
+ for (const s of o.listInputFields())
1300
+ if (s.endsWith(".index")) {
1301
+ const n = s.slice(0, s.length - 6);
1302
+ let i = r[n];
1303
+ i === void 0 && (i = {}, r[n] = i), i.index = o.traverse({ field: s, errorIfFieldNotSet: !0 }).resourceInfo;
1304
+ } else if (s.endsWith(".values")) {
1305
+ const n = s.slice(0, s.length - 7);
1306
+ let i = r[n];
1307
+ i === void 0 && (i = {}, r[n] = i), i.values = o.traverse({ field: s, errorIfFieldNotSet: !0 }).resourceInfo;
1308
+ } else throw new Error(`unrecognized part field name: ${s}`);
1309
+ for (const [s, n] of Object.entries(r)) {
1310
+ if (n.index === void 0) throw new Error(`no index for part ${s}`);
1311
+ if (n.values === void 0) throw new Error(`no values for part ${s}`);
1312
1312
  }
1313
1313
  return {
1314
1314
  type: "BinaryPartitioned",
1315
1315
  partitionKeyLength: t.partitionKeyLength,
1316
1316
  parts: r
1317
1317
  };
1318
- } else if (U(s.resourceType, jo)) {
1318
+ } else if ($(o.resourceType, Vs)) {
1319
1319
  const t = e, r = {};
1320
- for (const o of s.listInputFields()) {
1321
- const i = s.traverse({ field: o, errorIfFieldNotSet: !0 }), n = i.listInputFields();
1322
- if (n === void 0) throw new Error(`no partition keys for super key ${o}`);
1323
- for (const a of n)
1320
+ for (const s of o.listInputFields()) {
1321
+ const n = o.traverse({ field: s, errorIfFieldNotSet: !0 }), i = n.listInputFields();
1322
+ if (i === void 0) throw new Error(`no partition keys for super key ${s}`);
1323
+ for (const a of i)
1324
1324
  if (a.endsWith(".index")) {
1325
- const c = a.slice(0, a.length - 6), u = JSON.stringify([...JSON.parse(o), ...JSON.parse(c)]);
1325
+ const c = a.slice(0, a.length - 6), u = JSON.stringify([...JSON.parse(s), ...JSON.parse(c)]);
1326
1326
  let l = r[u];
1327
- l === void 0 && (l = {}, r[u] = l), r[u].index = i.traverse({
1327
+ l === void 0 && (l = {}, r[u] = l), r[u].index = n.traverse({
1328
1328
  field: a,
1329
1329
  errorIfFieldNotSet: !0
1330
1330
  }).resourceInfo;
1331
1331
  } else if (a.endsWith(".values")) {
1332
- const c = a.slice(0, a.length - 7), u = JSON.stringify([...JSON.parse(o), ...JSON.parse(c)]);
1332
+ const c = a.slice(0, a.length - 7), u = JSON.stringify([...JSON.parse(s), ...JSON.parse(c)]);
1333
1333
  let l = r[u];
1334
- l === void 0 && (l = {}, r[u] = l), r[u].values = i.traverse({
1334
+ l === void 0 && (l = {}, r[u] = l), r[u].values = n.traverse({
1335
1335
  field: a,
1336
1336
  errorIfFieldNotSet: !0
1337
1337
  }).resourceInfo;
@@ -1343,39 +1343,39 @@ function Ao(s) {
1343
1343
  parts: r
1344
1344
  };
1345
1345
  }
1346
- throw new Error(`unsupported resource type: ${sr(s.resourceType)}`);
1346
+ throw new Error(`unsupported resource type: ${lr(o.resourceType)}`);
1347
1347
  }
1348
- function Dt(s, e) {
1348
+ function It(o, e) {
1349
1349
  const t = he("sha256");
1350
- return t.update(Ee(s)), t.update(String(ce(e.originalId) ? e.id : e.originalId)), t.digest().toString("hex");
1350
+ return t.update(Ve(o)), t.update(String(ue(e.originalId) ? e.id : e.originalId)), t.digest().toString("hex");
1351
1351
  }
1352
- function xt(s, e = !0, t = !1, r = "") {
1352
+ function Vt(o, e = !0, t = !1, r = "") {
1353
1353
  var a, c, u;
1354
- const o = /^(?<name>.*)\.(?<type>spec|data)$/, i = /* @__PURE__ */ new Map();
1355
- for (const l of s.listInputFields()) {
1356
- const p = l.match(o);
1354
+ const s = /^(?<name>.*)\.(?<type>spec|data)$/, n = /* @__PURE__ */ new Map();
1355
+ for (const l of o.listInputFields()) {
1356
+ const p = l.match(s);
1357
1357
  if (!p) {
1358
1358
  if (e) throw new Error(`unexpected field name ${l}`);
1359
1359
  continue;
1360
1360
  }
1361
- let h = w((a = p.groups) == null ? void 0 : a.name);
1362
- if (!h.startsWith(r)) {
1361
+ let g = w((a = p.groups) == null ? void 0 : a.name);
1362
+ if (!g.startsWith(r)) {
1363
1363
  if (e) throw new Error(`unexpected field name ${l}`);
1364
1364
  continue;
1365
1365
  }
1366
- h = h.slice(r.length);
1367
- const f = w((c = p.groups) == null ? void 0 : c.type);
1368
- let b = i.get(h);
1369
- switch (b === void 0 && (b = {}, i.set(h, b)), f) {
1366
+ g = g.slice(r.length);
1367
+ const m = w((c = p.groups) == null ? void 0 : c.type);
1368
+ let h = n.get(g);
1369
+ switch (h === void 0 && (h = {}, n.set(g, h)), m) {
1370
1370
  case "spec":
1371
- b.spec = (u = s.traverse({
1371
+ h.spec = (u = o.traverse({
1372
1372
  field: l,
1373
1373
  ignoreError: t,
1374
1374
  pureFieldErrorToUndefined: t
1375
1375
  })) == null ? void 0 : u.getDataAsJson();
1376
1376
  break;
1377
1377
  case "data":
1378
- b.hasData = !0, b.data = () => s.traverseOrError({
1378
+ h.hasData = !0, h.data = () => o.traverseOrError({
1379
1379
  field: l,
1380
1380
  ignoreError: t
1381
1381
  });
@@ -1383,45 +1383,45 @@ function xt(s, e = !0, t = !1, r = "") {
1383
1383
  continue;
1384
1384
  }
1385
1385
  }
1386
- const n = s.getInputsLocked();
1387
- if (n)
1388
- for (const [, l] of i) l.data === void 0 && (l.hasData = !1);
1389
- return { locked: n, results: i };
1390
- }
1391
- function To(s, e = !0, t = "") {
1392
- if (!s.getIsReadyOrError()) throw new Error("resource is not ready");
1393
- const r = xt(s, e, !1, t);
1394
- pr(r.locked);
1395
- const o = {};
1396
- for (const [i, n] of r.results) {
1397
- if (n.spec === void 0) throw new Error(`no spec for key ${i}`);
1398
- if (n.hasData !== !0 || n.data === void 0)
1399
- throw new Error(`no data for key ${i}`);
1400
- const a = n.data();
1401
- if (a === void 0) throw new Error(`no data for key ${i}`);
1402
- if (!a.ok) throw new cr(a.error);
1403
- o[i] = {
1404
- id: Dt(n.spec, a.value),
1405
- spec: n.spec,
1386
+ const i = o.getInputsLocked();
1387
+ if (i)
1388
+ for (const [, l] of n) l.data === void 0 && (l.hasData = !1);
1389
+ return { locked: i, results: n };
1390
+ }
1391
+ function Js(o, e = !0, t = "") {
1392
+ if (!o.getIsReadyOrError()) throw new Error("resource is not ready");
1393
+ const r = Vt(o, e, !1, t);
1394
+ br(r.locked);
1395
+ const s = {};
1396
+ for (const [n, i] of r.results) {
1397
+ if (i.spec === void 0) throw new Error(`no spec for key ${n}`);
1398
+ if (i.hasData !== !0 || i.data === void 0)
1399
+ throw new Error(`no data for key ${n}`);
1400
+ const a = i.data();
1401
+ if (a === void 0) throw new Error(`no data for key ${n}`);
1402
+ if (!a.ok) throw new fr(a.error);
1403
+ s[n] = {
1404
+ id: It(i.spec, a.value),
1405
+ spec: i.spec,
1406
1406
  data: a.value
1407
1407
  };
1408
1408
  }
1409
- return o;
1409
+ return s;
1410
1410
  }
1411
- class Ne {
1411
+ class Ke {
1412
1412
  constructor(e, t) {
1413
1413
  d(this, "allSpecsAvailable");
1414
1414
  this.ctx = e, this.blocks = t;
1415
1415
  let r = !0;
1416
- e: for (const o of t.values())
1417
- for (const i of [o.prod, o.staging])
1418
- if (i !== void 0) {
1419
- if (!i.locked) {
1416
+ e: for (const s of t.values())
1417
+ for (const n of [s.prod, s.staging])
1418
+ if (n !== void 0) {
1419
+ if (!n.locked) {
1420
1420
  r = !1;
1421
1421
  break e;
1422
1422
  }
1423
- for (const n of i.results.values())
1424
- if (n.spec === void 0) {
1423
+ for (const i of n.results.values())
1424
+ if (i.spec === void 0) {
1425
1425
  r = !1;
1426
1426
  break e;
1427
1427
  }
@@ -1452,32 +1452,32 @@ class Ne {
1452
1452
  getDataWithErrors() {
1453
1453
  const e = [];
1454
1454
  let t = !0, r;
1455
- const o = (n) => {
1456
- r === void 0 && (r = n), t = !1;
1457
- }, i = (n, a, c) => {
1455
+ const s = (i) => {
1456
+ r === void 0 && (r = i), t = !1;
1457
+ }, n = (i, a, c) => {
1458
1458
  if (c.spec !== void 0 && c.hasData === !0 && c.data !== void 0) {
1459
1459
  const u = c.data();
1460
1460
  u !== void 0 ? e.push({
1461
- ref: ie(n, a),
1461
+ ref: ie(i, a),
1462
1462
  obj: {
1463
- id: u.ok ? Dt(c.spec, u.value) : void 0,
1463
+ id: u.ok ? It(c.spec, u.value) : void 0,
1464
1464
  spec: c.spec,
1465
1465
  data: u
1466
1466
  }
1467
- }) : o(`no_data:${n}:${a}`);
1467
+ }) : s(`no_data:${i}:${a}`);
1468
1468
  }
1469
1469
  };
1470
- for (const [n, a] of this.blocks) {
1470
+ for (const [i, a] of this.blocks) {
1471
1471
  const c = /* @__PURE__ */ new Set();
1472
1472
  if (a.prod !== void 0) {
1473
- a.prod.locked || o(`prod_not_locked:${n}`);
1473
+ a.prod.locked || s(`prod_not_locked:${i}`);
1474
1474
  for (const [u, l] of a.prod.results)
1475
- c.add(u), i(n, u, l);
1475
+ c.add(u), n(i, u, l);
1476
1476
  }
1477
1477
  if (a.staging !== void 0) {
1478
- a.staging.locked || o(`staging_not_locked:${n}`);
1478
+ a.staging.locked || s(`staging_not_locked:${i}`);
1479
1479
  for (const [u, l] of a.staging.results)
1480
- c.has(u) || i(n, u, l);
1480
+ c.has(u) || n(i, u, l);
1481
1481
  }
1482
1482
  }
1483
1483
  return { entries: e, isComplete: t, instabilityMarker: r };
@@ -1485,24 +1485,24 @@ class Ne {
1485
1485
  getSpecs() {
1486
1486
  const e = [];
1487
1487
  let t = !0, r;
1488
- const o = (i) => {
1489
- r === void 0 && (r = i), t = !1;
1488
+ const s = (n) => {
1489
+ r === void 0 && (r = n), t = !1;
1490
1490
  };
1491
- for (const [i, n] of this.blocks) {
1491
+ for (const [n, i] of this.blocks) {
1492
1492
  const a = /* @__PURE__ */ new Set();
1493
- if (n.staging !== void 0) {
1494
- n.staging.locked || o(`staging_not_locked:${i}`);
1495
- for (const [c, u] of n.staging.results)
1493
+ if (i.staging !== void 0) {
1494
+ i.staging.locked || s(`staging_not_locked:${n}`);
1495
+ for (const [c, u] of i.staging.results)
1496
1496
  u.spec !== void 0 && (e.push({
1497
- ref: ie(i, c),
1497
+ ref: ie(n, c),
1498
1498
  obj: u.spec
1499
1499
  }), a.add(c));
1500
- } else o(`staging_not_rendered:${i}`);
1501
- if (n.prod !== void 0) {
1502
- n.prod.locked || o(`prod_not_locked:${i}`);
1503
- for (const [c, u] of n.prod.results)
1500
+ } else s(`staging_not_rendered:${n}`);
1501
+ if (i.prod !== void 0) {
1502
+ i.prod.locked || s(`prod_not_locked:${n}`);
1503
+ for (const [c, u] of i.prod.results)
1504
1504
  a.has(c) || u.spec !== void 0 && e.push({
1505
- ref: ie(i, c),
1505
+ ref: ie(n, c),
1506
1506
  obj: u.spec
1507
1507
  });
1508
1508
  }
@@ -1512,116 +1512,116 @@ class Ne {
1512
1512
  calculateOptions(e) {
1513
1513
  const t = [];
1514
1514
  for (const r of this.blocks.values()) {
1515
- const o = /* @__PURE__ */ new Set(), i = (n) => {
1516
- for (const [a, c] of n.results)
1517
- o.has(a) || c.spec === void 0 || (o.add(a), Gt(e, c.spec) && t.push({
1515
+ const s = /* @__PURE__ */ new Set(), n = (i) => {
1516
+ for (const [a, c] of i.results)
1517
+ s.has(a) || c.spec === void 0 || (s.add(a), qt(e, c.spec) && t.push({
1518
1518
  label: r.info.label + " / " + a,
1519
1519
  ref: ie(r.info.id, a),
1520
1520
  spec: c.spec
1521
1521
  }));
1522
1522
  };
1523
- r.staging !== void 0 && i(r.staging), r.prod !== void 0 && i(r.prod);
1523
+ r.staging !== void 0 && n(r.staging), r.prod !== void 0 && n(r.prod);
1524
1524
  }
1525
1525
  return t;
1526
1526
  }
1527
1527
  static create(e, t, r) {
1528
- const o = e.accessor(t).node(), i = w(o.getKeyValueAsJson(W)), a = Oe(i).traverseIds("upstream", r), c = /* @__PURE__ */ new Map();
1529
- for (const u of L(i)) {
1528
+ const s = e.accessor(t).node(), n = w(s.getKeyValueAsJson(W)), a = je(n).traverseIds("upstream", r), c = /* @__PURE__ */ new Map();
1529
+ for (const u of N(n)) {
1530
1530
  if (!a.has(u.id)) continue;
1531
- const l = st(
1532
- o.traverse({
1531
+ const l = ut(
1532
+ s.traverse({
1533
1533
  field: P(u.id, "prodCtx"),
1534
1534
  ignoreError: !0,
1535
1535
  pureFieldErrorToUndefined: !0,
1536
1536
  stableIfNotFound: !0
1537
1537
  }) !== void 0,
1538
- o.traverseOrError({
1538
+ s.traverseOrError({
1539
1539
  field: P(u.id, "prodUiCtx"),
1540
1540
  stableIfNotFound: !0
1541
1541
  })
1542
- ), p = st(
1543
- o.traverse({
1542
+ ), p = ut(
1543
+ s.traverse({
1544
1544
  field: P(u.id, "stagingCtx"),
1545
1545
  ignoreError: !0,
1546
1546
  pureFieldErrorToUndefined: !0
1547
1547
  }) !== void 0,
1548
- o.traverseOrError({
1548
+ s.traverseOrError({
1549
1549
  field: P(u.id, "stagingUiCtx")
1550
1550
  })
1551
1551
  );
1552
1552
  c.set(u.id, { info: u, prod: l, staging: p });
1553
1553
  }
1554
- return new Ne(e, c);
1554
+ return new Ke(e, c);
1555
1555
  }
1556
1556
  }
1557
- function st(s, e) {
1557
+ function ut(o, e) {
1558
1558
  if (e === void 0)
1559
- return s ? { locked: !1, results: /* @__PURE__ */ new Map() } : void 0;
1560
- if (e.ok) return xt(e.value, !1, !0);
1559
+ return o ? { locked: !1, results: /* @__PURE__ */ new Map() } : void 0;
1560
+ if (e.ok) return Vt(e.value, !1, !0);
1561
1561
  }
1562
- function Je(s, e) {
1563
- const t = s.persist(), r = w(
1564
- s.traverse({
1562
+ function $e(o, e) {
1563
+ const t = o.persist(), r = w(
1564
+ o.traverse({
1565
1565
  field: P(e, "currentArgs"),
1566
1566
  errorIfFieldNotSet: !0
1567
1567
  }).getDataAsString()
1568
- ), o = s.getKeyValueAsString(Ce(e));
1568
+ ), s = o.getKeyValueAsString(Re(e));
1569
1569
  return {
1570
1570
  blockId: e,
1571
1571
  args: r,
1572
- uiState: o,
1573
- blockMeta: (i) => {
1574
- const n = i.accessor(t).node(), a = w(n.getKeyValueAsJson(W)), c = /* @__PURE__ */ new Map();
1575
- for (const u of L(a)) c.set(u.id, u);
1572
+ uiState: s,
1573
+ blockMeta: (n) => {
1574
+ const i = n.accessor(t).node(), a = w(i.getKeyValueAsJson(W)), c = /* @__PURE__ */ new Map();
1575
+ for (const u of N(a)) c.set(u.id, u);
1576
1576
  return c;
1577
1577
  }
1578
1578
  };
1579
1579
  }
1580
- function jt(s, e) {
1581
- const t = s.persist();
1580
+ function Nt(o, e) {
1581
+ const t = o.persist();
1582
1582
  return {
1583
- ...Je(s, e),
1583
+ ...$e(o, e),
1584
1584
  prod: (r) => {
1585
- var o;
1586
- return (o = r.accessor(t).node({ ignoreError: !0 }).traverse({
1585
+ var s;
1586
+ return (s = r.accessor(t).node({ ignoreError: !0 }).traverse({
1587
1587
  field: P(e, "prodOutput"),
1588
1588
  stableIfNotFound: !0,
1589
1589
  ignoreError: !0
1590
- })) == null ? void 0 : o.persist();
1590
+ })) == null ? void 0 : s.persist();
1591
1591
  },
1592
1592
  staging: (r) => {
1593
- var i;
1594
- const o = (i = r.accessor(t).node({ ignoreError: !0 }).traverse({
1593
+ var n;
1594
+ const s = (n = r.accessor(t).node({ ignoreError: !0 }).traverse({
1595
1595
  field: P(e, "stagingOutput"),
1596
1596
  ignoreError: !0
1597
- })) == null ? void 0 : i.persist();
1598
- return o === void 0 && r.markUnstable("staging_not_rendered"), o;
1597
+ })) == null ? void 0 : n.persist();
1598
+ return s === void 0 && r.markUnstable("staging_not_rendered"), s;
1599
1599
  },
1600
- getResultsPool: (r) => Ne.create(r, t, e)
1600
+ getResultsPool: (r) => Ke.create(r, t, e)
1601
1601
  };
1602
1602
  }
1603
- function* j(s, e) {
1604
- switch (yield s, s.type) {
1603
+ function* j(o, e) {
1604
+ switch (yield o, o.type) {
1605
1605
  case "GetFromCtx":
1606
1606
  case "Immediate":
1607
1607
  return;
1608
1608
  case "Isolate":
1609
- yield* j(s.cfg);
1609
+ yield* j(o.cfg);
1610
1610
  return;
1611
1611
  case "MakeObject":
1612
- for (const [, t] of Object.entries(s.template)) yield* j(t);
1612
+ for (const [, t] of Object.entries(o.template)) yield* j(t);
1613
1613
  return;
1614
1614
  case "MakeArray":
1615
- for (const t of s.template) yield* j(t);
1615
+ for (const t of o.template) yield* j(t);
1616
1616
  return;
1617
1617
  case "GetJsonField":
1618
1618
  case "GetResourceField":
1619
- yield* j(s.source), yield* j(s.field);
1619
+ yield* j(o.source), yield* j(o.field);
1620
1620
  return;
1621
1621
  case "MapRecordValues":
1622
1622
  case "MapArrayValues":
1623
1623
  case "MapResourceFields":
1624
- yield* j(s.source), yield* j(s.mapping);
1624
+ yield* j(o.source), yield* j(o.mapping);
1625
1625
  return;
1626
1626
  case "Flatten":
1627
1627
  case "GetResourceValueAsJson":
@@ -1634,153 +1634,153 @@ function* j(s, e) {
1634
1634
  case "GetLastLogs":
1635
1635
  case "GetProgressLog":
1636
1636
  case "GetLogHandle":
1637
- yield* j(s.source);
1637
+ yield* j(o.source);
1638
1638
  return;
1639
1639
  case "IsEmpty":
1640
- yield* j(s.arg);
1640
+ yield* j(o.arg);
1641
1641
  return;
1642
1642
  case "Not":
1643
- yield* j(s.operand);
1643
+ yield* j(o.operand);
1644
1644
  return;
1645
1645
  case "And":
1646
1646
  case "Or":
1647
- yield* j(s.operand1), yield* j(s.operand2);
1647
+ yield* j(o.operand1), yield* j(o.operand2);
1648
1648
  return;
1649
1649
  default:
1650
- D(s);
1650
+ D(o);
1651
1651
  }
1652
1652
  }
1653
- function Io(s, e) {
1653
+ function Ms(o, e) {
1654
1654
  const t = {};
1655
- for (const [r, o] of Object.entries(s)) t[r] = e(o);
1655
+ for (const [r, s] of Object.entries(o)) t[r] = e(s);
1656
1656
  return t;
1657
1657
  }
1658
- function de(s, e) {
1659
- return s === void 0 ? void 0 : e(s);
1658
+ function pe(o, e) {
1659
+ return o === void 0 ? void 0 : e(o);
1660
1660
  }
1661
- function Vo(s) {
1662
- switch (s.type) {
1661
+ function Us(o) {
1662
+ switch (o.type) {
1663
1663
  case "GetImportProgress":
1664
1664
  return !0;
1665
1665
  default:
1666
1666
  return !1;
1667
1667
  }
1668
1668
  }
1669
- function Lo(s) {
1670
- for (const e of j(s)) if (Vo(e)) return !0;
1669
+ function Ks(o) {
1670
+ for (const e of j(o)) if (Us(e)) return !0;
1671
1671
  return !1;
1672
1672
  }
1673
- function ge(s) {
1673
+ function fe(o) {
1674
1674
  return {
1675
1675
  type: "ReturnResult",
1676
- result: s
1676
+ result: o
1677
1677
  };
1678
1678
  }
1679
- function g(s) {
1680
- return () => ge(s);
1679
+ function f(o) {
1680
+ return () => fe(o);
1681
1681
  }
1682
- const No = (s) => {
1682
+ const $s = (o) => {
1683
1683
  const e = {};
1684
- for (const [t, r] of Object.entries(s)) e[t] = r;
1685
- return g(e);
1686
- }, Jo = (s) => {
1687
- const e = s.source;
1688
- if (e === void 0) return g(void 0);
1684
+ for (const [t, r] of Object.entries(o)) e[t] = r;
1685
+ return f(e);
1686
+ }, Gs = (o) => {
1687
+ const e = o.source;
1688
+ if (e === void 0) return f(void 0);
1689
1689
  const t = [];
1690
1690
  for (const r of e)
1691
1691
  r instanceof Array ? t.push(...r) : t.push(r);
1692
- return g(t);
1693
- }, Ko = (s) => {
1694
- const e = s.source, t = s.field;
1695
- return e === void 0 || t === void 0 ? g(void 0) : ({ cCtx: r }) => {
1696
- var o;
1697
- return ge((o = r.accessor(e).node().traverse(t)) == null ? void 0 : o.persist());
1692
+ return f(t);
1693
+ }, Hs = (o) => {
1694
+ const e = o.source, t = o.field;
1695
+ return e === void 0 || t === void 0 ? f(void 0) : ({ cCtx: r }) => {
1696
+ var s;
1697
+ return fe((s = r.accessor(e).node().traverse(t)) == null ? void 0 : s.persist());
1698
1698
  };
1699
1699
  };
1700
- function Et(s, e) {
1701
- const t = {}, r = s.length;
1702
- for (let o = 0; o < r; o++) t[String(o)] = e(s[o]);
1700
+ function Lt(o, e) {
1701
+ const t = {}, r = o.length;
1702
+ for (let s = 0; s < r; s++) t[String(s)] = e(o[s]);
1703
1703
  return t;
1704
1704
  }
1705
- function Mo(s, e) {
1705
+ function _s(o, e) {
1706
1706
  return (t) => {
1707
1707
  const r = t.source;
1708
- return r === void 0 ? g(void 0) : () => ({
1708
+ return r === void 0 ? f(void 0) : () => ({
1709
1709
  type: "ScheduleSubroutine",
1710
- subroutine: At(r.length),
1711
- args: Et(r, (o) => m({ ...s, [e.itVar]: o }, e.mapping))
1710
+ subroutine: Jt(r.length),
1711
+ args: Lt(r, (s) => v({ ...o, [e.itVar]: s }, e.mapping))
1712
1712
  });
1713
1713
  };
1714
1714
  }
1715
- function At(s) {
1715
+ function Jt(o) {
1716
1716
  return (e) => {
1717
1717
  const t = [];
1718
- for (let r = 0; r < s; r++) t.push(e[String(r)]);
1719
- return g(t);
1718
+ for (let r = 0; r < o; r++) t.push(e[String(r)]);
1719
+ return f(t);
1720
1720
  };
1721
1721
  }
1722
- function Uo(s, e) {
1722
+ function Ws(o, e) {
1723
1723
  return (t) => {
1724
1724
  const r = t.source;
1725
- if (r === void 0) return g(void 0);
1726
- const o = {};
1727
- for (const [i, n] of Object.entries(r)) {
1728
- const a = { ...s, [e.itVar]: n };
1729
- o[i] = m(a, e.mapping);
1725
+ if (r === void 0) return f(void 0);
1726
+ const s = {};
1727
+ for (const [n, i] of Object.entries(r)) {
1728
+ const a = { ...o, [e.itVar]: i };
1729
+ s[n] = v(a, e.mapping);
1730
1730
  }
1731
1731
  return () => ({
1732
1732
  type: "ScheduleSubroutine",
1733
- subroutine: $o,
1734
- args: o
1733
+ subroutine: zs,
1734
+ args: s
1735
1735
  });
1736
1736
  };
1737
1737
  }
1738
- const $o = (s) => g(s), Go = (s) => {
1739
- const e = s.arg;
1740
- return g(e === void 0 ? void 0 : e.length === 0);
1741
- }, Ho = (s) => {
1742
- const e = s.operand;
1743
- return g(e === void 0 ? void 0 : !e);
1744
- }, _o = (s) => {
1745
- const e = s.operand1, t = s.operand2;
1746
- return g(e === void 0 || t === void 0 ? void 0 : e && t);
1747
- }, Wo = (s) => {
1748
- const e = s.operand1, t = s.operand2;
1749
- return g(e === void 0 || t === void 0 ? void 0 : e || t);
1750
- }, zo = (s) => {
1751
- const e = s.source;
1752
- return e === void 0 ? g(void 0) : ({ cCtx: t }) => {
1738
+ const zs = (o) => f(o), Ys = (o) => {
1739
+ const e = o.arg;
1740
+ return f(e === void 0 ? void 0 : e.length === 0);
1741
+ }, qs = (o) => {
1742
+ const e = o.operand;
1743
+ return f(e === void 0 ? void 0 : !e);
1744
+ }, Qs = (o) => {
1745
+ const e = o.operand1, t = o.operand2;
1746
+ return f(e === void 0 || t === void 0 ? void 0 : e && t);
1747
+ }, Zs = (o) => {
1748
+ const e = o.operand1, t = o.operand2;
1749
+ return f(e === void 0 || t === void 0 ? void 0 : e || t);
1750
+ }, Xs = (o) => {
1751
+ const e = o.source;
1752
+ return e === void 0 ? f(void 0) : ({ cCtx: t }) => {
1753
1753
  var r;
1754
- return ge((r = t.accessor(e).node()) == null ? void 0 : r.getDataAsJson());
1754
+ return fe((r = t.accessor(e).node()) == null ? void 0 : r.getDataAsJson());
1755
1755
  };
1756
- }, Yo = (s) => {
1757
- const e = s.source, t = s.field;
1758
- return g(e === void 0 || t === void 0 ? void 0 : e[t]);
1756
+ }, eo = (o) => {
1757
+ const e = o.source, t = o.field;
1758
+ return f(e === void 0 || t === void 0 ? void 0 : e[t]);
1759
1759
  };
1760
- function qo(s, e) {
1760
+ function to(o, e) {
1761
1761
  return (t) => {
1762
1762
  const r = t.source;
1763
- return r === void 0 ? g(void 0) : ({ cCtx: o }) => {
1764
- const i = o.accessor(r).node(), n = {};
1765
- for (const a of i.listInputFields()) {
1766
- const c = i.traverse(a);
1767
- if (c === void 0) n[a] = g(void 0);
1763
+ return r === void 0 ? f(void 0) : ({ cCtx: s }) => {
1764
+ const n = s.accessor(r).node(), i = {};
1765
+ for (const a of n.listInputFields()) {
1766
+ const c = n.traverse(a);
1767
+ if (c === void 0) i[a] = f(void 0);
1768
1768
  else {
1769
- const u = { ...s, [e.itVar]: c.persist() };
1770
- n[a] = m(u, e.mapping);
1769
+ const u = { ...o, [e.itVar]: c.persist() };
1770
+ i[a] = v(u, e.mapping);
1771
1771
  }
1772
1772
  }
1773
1773
  return {
1774
1774
  type: "ScheduleSubroutine",
1775
- subroutine: Qo,
1776
- args: n
1775
+ subroutine: ro,
1776
+ args: i
1777
1777
  };
1778
1778
  };
1779
1779
  };
1780
1780
  }
1781
- const Qo = (s) => g(s), Zo = (s) => {
1782
- const e = s.source;
1783
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1781
+ const ro = (o) => f(o), so = (o) => {
1782
+ const e = o.source;
1783
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1784
1784
  type: "ScheduleComputable",
1785
1785
  computable: F.make(
1786
1786
  (r) => t.blobDriver.getDownloadedBlob(r.accessor(e).node().resourceInfo),
@@ -1792,308 +1792,308 @@ const Qo = (s) => g(s), Zo = (s) => {
1792
1792
  }
1793
1793
  )
1794
1794
  });
1795
- }, Xo = (s) => {
1796
- const e = s.source;
1797
- return e === void 0 ? g(void 0) : ({ cCtx: t, drivers: r }) => {
1798
- const o = t.accessor(e).node().resourceInfo;
1795
+ }, oo = (o) => {
1796
+ const e = o.source;
1797
+ return e === void 0 ? f(void 0) : ({ cCtx: t, drivers: r }) => {
1798
+ const s = t.accessor(e).node().resourceInfo;
1799
1799
  return {
1800
1800
  type: "ScheduleComputable",
1801
- computable: F.make(() => r.blobDriver.getDownloadedBlob(o), {
1802
- postprocessValue: async (i) => i === void 0 ? void 0 : (await r.blobDriver.getContent(i.handle)).toString()
1801
+ computable: F.make(() => r.blobDriver.getDownloadedBlob(s), {
1802
+ postprocessValue: async (n) => n === void 0 ? void 0 : (await r.blobDriver.getContent(n.handle)).toString()
1803
1803
  })
1804
1804
  };
1805
1805
  };
1806
- }, es = (s) => {
1807
- const e = s.source;
1808
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1806
+ }, no = (o) => {
1807
+ const e = o.source;
1808
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1809
1809
  type: "ScheduleComputable",
1810
1810
  computable: F.make(
1811
1811
  (r) => t.blobDriver.getDownloadedBlob(r.accessor(e).node().resourceInfo),
1812
1812
  {
1813
1813
  postprocessValue: async (r) => {
1814
1814
  if (r == null) return;
1815
- const o = await t.blobDriver.getContent(r.handle);
1816
- if (o != null)
1817
- return JSON.parse(Buffer.from(o).toString());
1815
+ const s = await t.blobDriver.getContent(r.handle);
1816
+ if (s != null)
1817
+ return JSON.parse(Buffer.from(s).toString());
1818
1818
  }
1819
1819
  }
1820
1820
  )
1821
1821
  });
1822
- }, ts = (s) => {
1823
- const e = s.source;
1824
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1822
+ }, io = (o) => {
1823
+ const e = o.source;
1824
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1825
1825
  type: "ScheduleComputable",
1826
1826
  computable: t.blobDriver.getDownloadedBlob(e)
1827
1827
  });
1828
- }, rs = (s) => {
1829
- const e = s.source;
1830
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1828
+ }, ao = (o) => {
1829
+ const e = o.source;
1830
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1831
1831
  type: "ScheduleComputable",
1832
1832
  computable: t.blobDriver.getOnDemandBlob(e)
1833
1833
  });
1834
- }, os = (s) => {
1835
- const e = s.source;
1836
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1834
+ }, co = (o) => {
1835
+ const e = o.source;
1836
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1837
1837
  type: "ScheduleComputable",
1838
1838
  computable: t.uploadDriver.getProgressId(e)
1839
1839
  });
1840
- }, ss = (s) => (e) => {
1840
+ }, uo = (o) => (e) => {
1841
1841
  const t = e.source;
1842
- return t === void 0 ? g(void 0) : ({ drivers: r }) => ({
1842
+ return t === void 0 ? f(void 0) : ({ drivers: r }) => ({
1843
1843
  type: "ScheduleComputable",
1844
- computable: r.logDriver.getLastLogs(t, s)
1844
+ computable: r.logDriver.getLastLogs(t, o)
1845
1845
  });
1846
- }, is = (s) => (e) => {
1846
+ }, lo = (o) => (e) => {
1847
1847
  const t = e.source;
1848
- return t === void 0 ? g(void 0) : ({ drivers: r }) => ({
1848
+ return t === void 0 ? f(void 0) : ({ drivers: r }) => ({
1849
1849
  type: "ScheduleComputable",
1850
- computable: r.logDriver.getProgressLog(t, s)
1850
+ computable: r.logDriver.getProgressLog(t, o)
1851
1851
  });
1852
- }, ns = (s) => {
1853
- const e = s.source;
1854
- return e === void 0 ? g(void 0) : ({ drivers: t }) => ({
1852
+ }, po = (o) => {
1853
+ const e = o.source;
1854
+ return e === void 0 ? f(void 0) : ({ drivers: t }) => ({
1855
1855
  type: "ScheduleComputable",
1856
1856
  computable: t.logDriver.getLogHandle(e)
1857
1857
  });
1858
1858
  };
1859
- function m(s, e) {
1859
+ function v(o, e) {
1860
1860
  switch (e.type) {
1861
1861
  case "GetFromCtx":
1862
- const t = s[e.variable];
1863
- return typeof t == "function" ? (r) => ge(t(r.cCtx)) : (t === void 0 && console.log("asdasd"), g(t));
1862
+ const t = o[e.variable];
1863
+ return typeof t == "function" ? (r) => fe(t(r.cCtx)) : (t === void 0 && console.log("asdasd"), f(t));
1864
1864
  case "Isolate":
1865
1865
  return ({ drivers: r }) => ({
1866
1866
  type: "ScheduleComputable",
1867
- computable: Lt(r, s, e.cfg)
1867
+ computable: $t(r, o, e.cfg)
1868
1868
  });
1869
1869
  case "Immediate":
1870
- return g(e.value);
1870
+ return f(e.value);
1871
1871
  case "GetJsonField":
1872
1872
  return () => ({
1873
1873
  type: "ScheduleSubroutine",
1874
- subroutine: Yo,
1874
+ subroutine: eo,
1875
1875
  args: {
1876
- source: m(s, e.source),
1877
- field: m(s, e.field)
1876
+ source: v(o, e.source),
1877
+ field: v(o, e.field)
1878
1878
  }
1879
1879
  });
1880
1880
  case "MapArrayValues":
1881
1881
  return () => ({
1882
1882
  type: "ScheduleSubroutine",
1883
- subroutine: Mo(s, e),
1883
+ subroutine: _s(o, e),
1884
1884
  args: {
1885
- source: m(s, e.source)
1885
+ source: v(o, e.source)
1886
1886
  }
1887
1887
  });
1888
1888
  case "MapRecordValues":
1889
1889
  return () => ({
1890
1890
  type: "ScheduleSubroutine",
1891
- subroutine: Uo(s, e),
1891
+ subroutine: Ws(o, e),
1892
1892
  args: {
1893
- source: m(s, e.source)
1893
+ source: v(o, e.source)
1894
1894
  }
1895
1895
  });
1896
1896
  case "MakeObject":
1897
1897
  return () => ({
1898
1898
  type: "ScheduleSubroutine",
1899
- subroutine: No,
1900
- args: Io(e.template, (r) => m(s, r))
1899
+ subroutine: $s,
1900
+ args: Ms(e.template, (r) => v(o, r))
1901
1901
  });
1902
1902
  case "MakeArray":
1903
1903
  return () => ({
1904
1904
  type: "ScheduleSubroutine",
1905
- subroutine: At(e.template.length),
1906
- args: Et(e.template, (r) => m(s, r))
1905
+ subroutine: Jt(e.template.length),
1906
+ args: Lt(e.template, (r) => v(o, r))
1907
1907
  });
1908
1908
  case "Flatten":
1909
1909
  return () => ({
1910
1910
  type: "ScheduleSubroutine",
1911
- subroutine: Jo,
1911
+ subroutine: Gs,
1912
1912
  args: {
1913
- source: m(s, e.source)
1913
+ source: v(o, e.source)
1914
1914
  }
1915
1915
  });
1916
1916
  case "IsEmpty":
1917
1917
  return () => ({
1918
1918
  type: "ScheduleSubroutine",
1919
- subroutine: Go,
1919
+ subroutine: Ys,
1920
1920
  args: {
1921
- arg: m(s, e.arg)
1921
+ arg: v(o, e.arg)
1922
1922
  }
1923
1923
  });
1924
1924
  case "Not":
1925
1925
  return () => ({
1926
1926
  type: "ScheduleSubroutine",
1927
- subroutine: Ho,
1927
+ subroutine: qs,
1928
1928
  args: {
1929
- operand: m(s, e.operand)
1929
+ operand: v(o, e.operand)
1930
1930
  }
1931
1931
  });
1932
1932
  case "And":
1933
1933
  return () => ({
1934
1934
  type: "ScheduleSubroutine",
1935
- subroutine: _o,
1935
+ subroutine: Qs,
1936
1936
  args: {
1937
- operand1: m(s, e.operand1),
1938
- operand2: m(s, e.operand2)
1937
+ operand1: v(o, e.operand1),
1938
+ operand2: v(o, e.operand2)
1939
1939
  }
1940
1940
  });
1941
1941
  case "Or":
1942
1942
  return () => ({
1943
1943
  type: "ScheduleSubroutine",
1944
- subroutine: Wo,
1944
+ subroutine: Zs,
1945
1945
  args: {
1946
- operand1: m(s, e.operand1),
1947
- operand2: m(s, e.operand2)
1946
+ operand1: v(o, e.operand1),
1947
+ operand2: v(o, e.operand2)
1948
1948
  }
1949
1949
  });
1950
1950
  case "MapResourceFields":
1951
1951
  return () => ({
1952
1952
  type: "ScheduleSubroutine",
1953
- subroutine: qo(s, e),
1953
+ subroutine: to(o, e),
1954
1954
  args: {
1955
- source: m(s, e.source)
1955
+ source: v(o, e.source)
1956
1956
  }
1957
1957
  });
1958
1958
  case "GetResourceField":
1959
1959
  return () => ({
1960
1960
  type: "ScheduleSubroutine",
1961
- subroutine: Ko,
1961
+ subroutine: Hs,
1962
1962
  args: {
1963
- source: m(s, e.source),
1964
- field: m(s, e.field)
1963
+ source: v(o, e.source),
1964
+ field: v(o, e.field)
1965
1965
  }
1966
1966
  });
1967
1967
  case "GetResourceValueAsJson":
1968
1968
  return () => ({
1969
1969
  type: "ScheduleSubroutine",
1970
- subroutine: zo,
1970
+ subroutine: Xs,
1971
1971
  args: {
1972
- source: m(s, e.source)
1972
+ source: v(o, e.source)
1973
1973
  }
1974
1974
  });
1975
1975
  case "GetBlobContent":
1976
1976
  return () => ({
1977
1977
  type: "ScheduleSubroutine",
1978
- subroutine: Zo,
1978
+ subroutine: so,
1979
1979
  args: {
1980
- source: m(s, e.source)
1980
+ source: v(o, e.source)
1981
1981
  }
1982
1982
  });
1983
1983
  case "GetBlobContentAsString":
1984
1984
  return () => ({
1985
1985
  type: "ScheduleSubroutine",
1986
- subroutine: Xo,
1986
+ subroutine: oo,
1987
1987
  args: {
1988
- source: m(s, e.source)
1988
+ source: v(o, e.source)
1989
1989
  }
1990
1990
  });
1991
1991
  case "GetBlobContentAsJson":
1992
1992
  return () => ({
1993
1993
  type: "ScheduleSubroutine",
1994
- subroutine: es,
1994
+ subroutine: no,
1995
1995
  args: {
1996
- source: m(s, e.source)
1996
+ source: v(o, e.source)
1997
1997
  }
1998
1998
  });
1999
1999
  case "GetDownloadedBlobContent":
2000
2000
  return () => ({
2001
2001
  type: "ScheduleSubroutine",
2002
- subroutine: ts,
2002
+ subroutine: io,
2003
2003
  args: {
2004
- source: m(s, e.source)
2004
+ source: v(o, e.source)
2005
2005
  }
2006
2006
  });
2007
2007
  case "GetOnDemandBlobContent":
2008
2008
  return () => ({
2009
2009
  type: "ScheduleSubroutine",
2010
- subroutine: rs,
2010
+ subroutine: ao,
2011
2011
  args: {
2012
- source: m(s, e.source)
2012
+ source: v(o, e.source)
2013
2013
  }
2014
2014
  });
2015
2015
  case "GetImportProgress":
2016
2016
  return () => ({
2017
2017
  type: "ScheduleSubroutine",
2018
- subroutine: os,
2018
+ subroutine: co,
2019
2019
  args: {
2020
- source: m(s, e.source)
2020
+ source: v(o, e.source)
2021
2021
  }
2022
2022
  });
2023
2023
  case "GetLastLogs":
2024
2024
  return () => ({
2025
2025
  type: "ScheduleSubroutine",
2026
- subroutine: ss(e.lines),
2026
+ subroutine: uo(e.lines),
2027
2027
  args: {
2028
- source: m(s, e.source)
2028
+ source: v(o, e.source)
2029
2029
  }
2030
2030
  });
2031
2031
  case "GetProgressLog":
2032
2032
  return () => ({
2033
2033
  type: "ScheduleSubroutine",
2034
- subroutine: is(e.patternToSearch),
2034
+ subroutine: lo(e.patternToSearch),
2035
2035
  args: {
2036
- source: m(s, e.source)
2036
+ source: v(o, e.source)
2037
2037
  }
2038
2038
  });
2039
2039
  case "GetLogHandle":
2040
2040
  return () => ({
2041
2041
  type: "ScheduleSubroutine",
2042
- subroutine: ns,
2042
+ subroutine: po,
2043
2043
  args: {
2044
- source: m(s, e.source)
2044
+ source: v(o, e.source)
2045
2045
  }
2046
2046
  });
2047
2047
  default:
2048
2048
  return D(e);
2049
2049
  }
2050
2050
  }
2051
- const as = ["$prod", "$staging"];
2052
- function cs(s) {
2051
+ const go = ["$prod", "$staging"];
2052
+ function ho(o) {
2053
2053
  return {
2054
- $blockId: s.blockId,
2055
- $args: JSON.parse(s.args),
2056
- $ui: s.uiState !== void 0 ? JSON.parse(s.uiState) : void 0,
2057
- $prod: s.prod,
2058
- $staging: s.staging
2054
+ $blockId: o.blockId,
2055
+ $args: JSON.parse(o.args),
2056
+ $ui: o.uiState !== void 0 ? JSON.parse(o.uiState) : void 0,
2057
+ $prod: o.prod,
2058
+ $staging: o.staging
2059
2059
  };
2060
2060
  }
2061
- const Tt = Symbol(), It = "return", us = { op: Tt, arg: It };
2062
- function ls(s) {
2063
- return s.op == Tt && s.arg == It;
2061
+ const Mt = Symbol(), Ut = "return", fo = { op: Mt, arg: Ut };
2062
+ function mo(o) {
2063
+ return o.op == Mt && o.arg == Ut;
2064
2064
  }
2065
- function ds() {
2065
+ function vo() {
2066
2066
  return { pendingSubroutines: /* @__PURE__ */ new Map() };
2067
2067
  }
2068
- function it(s, e, t, r) {
2069
- const o = new mt(t), i = (a, c) => {
2070
- if (ls(a))
2068
+ function lt(o, e, t, r) {
2069
+ const s = new St(t), n = (a, c) => {
2070
+ if (mo(a))
2071
2071
  return e.result = c, !1;
2072
2072
  const u = w(e.pendingSubroutines.get(a.op));
2073
2073
  if (a.arg in u.args) throw new Error("argument already set");
2074
- return u.args[a.arg] = c, u.argCounter--, u.argCounter === 0 && (e.pendingSubroutines.delete(a.op), o.push({
2074
+ return u.args[a.arg] = c, u.argCounter--, u.argCounter === 0 && (e.pendingSubroutines.delete(a.op), s.push({
2075
2075
  destination: u.destination,
2076
2076
  operation: u.subroutine(u.args)
2077
2077
  })), !0;
2078
- }, n = [];
2079
- e: for (; o.length > 0; ) {
2080
- const a = o.shift(), c = a.operation(s);
2078
+ }, i = [];
2079
+ e: for (; s.length > 0; ) {
2080
+ const a = s.shift(), c = a.operation(o);
2081
2081
  switch (c.type) {
2082
2082
  case "ReturnResult":
2083
- if (!i(a.destination, c.result)) break e;
2083
+ if (!n(a.destination, c.result)) break e;
2084
2084
  break;
2085
2085
  case "ScheduleSubroutine":
2086
2086
  const u = Symbol(), l = Object.entries(c.args), p = l.length;
2087
2087
  if (p === 0)
2088
- o.push({
2088
+ s.push({
2089
2089
  destination: a.destination,
2090
2090
  operation: c.subroutine({})
2091
2091
  });
2092
2092
  else {
2093
- for (const [h, f] of l)
2094
- o.push({
2095
- destination: { op: u, arg: h },
2096
- operation: f
2093
+ for (const [g, m] of l)
2094
+ s.push({
2095
+ destination: { op: u, arg: g },
2096
+ operation: m
2097
2097
  });
2098
2098
  e.pendingSubroutines.set(u, {
2099
2099
  argCounter: p,
@@ -2106,7 +2106,7 @@ function it(s, e, t, r) {
2106
2106
  case "ScheduleComputable":
2107
2107
  if (!r)
2108
2108
  throw new Error("asynchronous operations are forbidden in this context");
2109
- n.push({
2109
+ i.push({
2110
2110
  destination: a.destination,
2111
2111
  computable: c.computable
2112
2112
  });
@@ -2115,27 +2115,27 @@ function it(s, e, t, r) {
2115
2115
  D(c);
2116
2116
  }
2117
2117
  }
2118
- return n;
2118
+ return i;
2119
2119
  }
2120
- function Vt(s, e, t, r = {}) {
2121
- return Lt(s, cs(e), t, r);
2120
+ function Kt(o, e, t, r = {}) {
2121
+ return $t(o, ho(e), t, r);
2122
2122
  }
2123
- function Lt(s, e, t, r = {}) {
2124
- const o = Ee({
2125
- ctx: Object.fromEntries(Object.entries(e).filter(([i]) => as.indexOf(i) === -1)),
2123
+ function $t(o, e, t, r = {}) {
2124
+ const s = Ve({
2125
+ ctx: Object.fromEntries(Object.entries(e).filter(([n]) => go.indexOf(n) === -1)),
2126
2126
  cfg: t
2127
2127
  });
2128
2128
  return F.makeRaw(
2129
- (i) => {
2130
- const n = { drivers: s, cCtx: i }, a = ds();
2129
+ (n) => {
2130
+ const i = { drivers: o, cCtx: n }, a = vo();
2131
2131
  return {
2132
- ir: it(
2133
- n,
2132
+ ir: lt(
2133
+ i,
2134
2134
  a,
2135
2135
  [
2136
2136
  {
2137
- destination: us,
2138
- operation: m(e, t)
2137
+ destination: fo,
2138
+ operation: v(e, t)
2139
2139
  }
2140
2140
  ],
2141
2141
  !0
@@ -2143,36 +2143,36 @@ function Lt(s, e, t, r = {}) {
2143
2143
  async postprocessValue(u, l) {
2144
2144
  const p = [];
2145
2145
  for (const C of u)
2146
- p.push({ destination: C.destination, operation: g(C.computable) });
2147
- const h = {
2148
- drivers: s,
2146
+ p.push({ destination: C.destination, operation: f(C.computable) });
2147
+ const g = {
2148
+ drivers: o,
2149
2149
  get cCtx() {
2150
2150
  throw new Error("asynchronous operations are forbidden in this context");
2151
2151
  }
2152
- }, f = /* @__PURE__ */ new Map();
2152
+ }, m = /* @__PURE__ */ new Map();
2153
2153
  for (const [C, I] of a.pendingSubroutines)
2154
- f.set(C, { ...I, args: { ...I.args } });
2155
- const b = {
2154
+ m.set(C, { ...I, args: { ...I.args } });
2155
+ const h = {
2156
2156
  result: a.result,
2157
- pendingSubroutines: f
2157
+ pendingSubroutines: m
2158
2158
  };
2159
- if (it(h, b, p, !1), !("result" in b))
2159
+ if (lt(g, h, p, !1), !("result" in h))
2160
2160
  throw new Error("illegal cfg rendering stack state, no result");
2161
- return b.result;
2161
+ return h.result;
2162
2162
  }
2163
2163
  };
2164
2164
  },
2165
- { ...r, key: o }
2165
+ { ...r, key: s }
2166
2166
  );
2167
2167
  }
2168
- function ps(s) {
2169
- return s instanceof ArrayBuffer || ArrayBuffer.isView(s);
2168
+ function yo(o) {
2169
+ return o instanceof ArrayBuffer || ArrayBuffer.isView(o);
2170
2170
  }
2171
- function nt(s) {
2172
- return s !== void 0 ? Buffer.from(s).toString("base64") : void 0;
2171
+ function dt(o) {
2172
+ return o !== void 0 ? Buffer.from(o).toString("base64") : void 0;
2173
2173
  }
2174
- class pe {
2175
- constructor(e, t, r, o, i) {
2174
+ class ge {
2175
+ constructor(e, t, r, s, n) {
2176
2176
  d(this, "callbackRegistry");
2177
2177
  d(this, "fnJSONStringify");
2178
2178
  d(this, "fnJSONParse");
@@ -2184,14 +2184,14 @@ class pe {
2184
2184
  // Result Pool
2185
2185
  //
2186
2186
  d(this, "_resultPool");
2187
- if (this.scope = e, this.vm = t, this.blockCtx = r, this.env = o, this.computableCtx = i, this.callbackRegistry = this.scope.manage(this.vm.newObject()), this.fnJSONStringify = e.manage(
2188
- t.getProp(t.global, "JSON").consume((n) => t.getProp(n, "stringify"))
2187
+ if (this.scope = e, this.vm = t, this.blockCtx = r, this.env = s, this.computableCtx = n, this.callbackRegistry = this.scope.manage(this.vm.newObject()), this.fnJSONStringify = e.manage(
2188
+ t.getProp(t.global, "JSON").consume((i) => t.getProp(i, "stringify"))
2189
2189
  ), t.typeof(this.fnJSONStringify) !== "function")
2190
2190
  throw new Error("JSON.stringify() not found.");
2191
2191
  if (this.fnJSONParse = e.manage(
2192
- t.getProp(t.global, "JSON").consume((n) => t.getProp(n, "parse"))
2192
+ t.getProp(t.global, "JSON").consume((i) => t.getProp(i, "parse"))
2193
2193
  ), t.typeof(this.fnJSONParse) !== "function") throw new Error("JSON.parse() not found.");
2194
- this.meta = r.blockMeta(i), this.injectCtx();
2194
+ this.meta = r.blockMeta(n), this.injectCtx();
2195
2195
  }
2196
2196
  resetComputableCtx() {
2197
2197
  this.computableCtx = void 0, this.accessors.clear();
@@ -2203,27 +2203,27 @@ class pe {
2203
2203
  try {
2204
2204
  this.vm.unwrapResult(this.vm.evalCode(e, "bundle.js", { type: "global" })).dispose();
2205
2205
  } catch (t) {
2206
- throw pe.cleanErrorContext(t), t;
2206
+ throw ge.cleanErrorContext(t), t;
2207
2207
  }
2208
2208
  }
2209
2209
  runCallback(e, ...t) {
2210
2210
  try {
2211
- return ke.withScope((r) => {
2212
- const o = r.manage(this.vm.getProp(this.callbackRegistry, e));
2213
- if (this.vm.typeof(o) !== "function")
2211
+ return Fe.withScope((r) => {
2212
+ const s = r.manage(this.vm.getProp(this.callbackRegistry, e));
2213
+ if (this.vm.typeof(s) !== "function")
2214
2214
  throw new Error(`No such callback: ${e}`);
2215
2215
  return this.scope.manage(
2216
2216
  this.vm.unwrapResult(
2217
2217
  this.vm.callFunction(
2218
- o,
2218
+ s,
2219
2219
  this.vm.undefined,
2220
- ...t.map((i) => this.exportObjectUniversal(i, r))
2220
+ ...t.map((n) => this.exportObjectUniversal(n, r))
2221
2221
  )
2222
2222
  )
2223
2223
  );
2224
2224
  });
2225
2225
  } catch (r) {
2226
- throw pe.cleanErrorContext(r), r;
2226
+ throw ge.cleanErrorContext(r), r;
2227
2227
  }
2228
2228
  }
2229
2229
  //
@@ -2232,12 +2232,12 @@ class pe {
2232
2232
  getAccessorHandleByName(e) {
2233
2233
  if (this.computableCtx === void 0)
2234
2234
  throw new Error("Accessors can't be used in this context");
2235
- const t = (r, o) => {
2235
+ const t = (r, s) => {
2236
2236
  if (!this.accessors.has(r)) {
2237
- const i = this.blockCtx[o];
2238
- if (i === void 0) throw new Error("Staging context not available");
2239
- const n = i(this.computableCtx);
2240
- n ? this.accessors.set(r, this.computableCtx.accessor(n).node({ ignoreError: !0 })) : this.accessors.set(r, void 0);
2237
+ const n = this.blockCtx[s];
2238
+ if (n === void 0) throw new Error("Staging context not available");
2239
+ const i = n(this.computableCtx);
2240
+ i ? this.accessors.set(r, this.computableCtx.accessor(i).node({ ignoreError: !0 })) : this.accessors.set(r, void 0);
2241
2241
  }
2242
2242
  return this.accessors.get(r) ? r : void 0;
2243
2243
  };
@@ -2278,13 +2278,13 @@ class pe {
2278
2278
  return this.getAccessor(e).listDynamicFields();
2279
2279
  }
2280
2280
  getKeyValueBase64(e, t) {
2281
- return nt(this.getAccessor(e).getKeyValue(t));
2281
+ return dt(this.getAccessor(e).getKeyValue(t));
2282
2282
  }
2283
2283
  getKeyValueAsString(e, t) {
2284
2284
  return this.getAccessor(e).getKeyValueAsString(t);
2285
2285
  }
2286
2286
  getDataBase64(e) {
2287
- return nt(this.getAccessor(e).getData());
2287
+ return dt(this.getAccessor(e).getData());
2288
2288
  }
2289
2289
  getDataAsString(e) {
2290
2290
  return this.getAccessor(e).getDataAsString();
@@ -2293,18 +2293,18 @@ class pe {
2293
2293
  // Accessor helpers
2294
2294
  //
2295
2295
  parsePObjectCollection(e, t, r) {
2296
- const o = this.getAccessor(e);
2297
- if (!o.getIsReadyOrError()) return;
2298
- const i = To(o, t, r), n = {};
2299
- for (const [a, c] of Object.entries(i))
2300
- n[a] = Q(c, (u) => this.wrapAccessor(u));
2301
- return n;
2296
+ const s = this.getAccessor(e);
2297
+ if (!s.getIsReadyOrError()) return;
2298
+ const n = Js(s, t, r), i = {};
2299
+ for (const [a, c] of Object.entries(n))
2300
+ i[a] = Z(c, (u) => this.wrapAccessor(u));
2301
+ return i;
2302
2302
  }
2303
2303
  //
2304
2304
  // Blobs
2305
2305
  //
2306
2306
  registerComputable(e, t) {
2307
- const r = `${e}_${X()}`;
2307
+ const r = `${e}_${ee()}`;
2308
2308
  return this.computablesToResolve[r] = t, r;
2309
2309
  }
2310
2310
  getBlobContentAsString(e) {
@@ -2413,7 +2413,7 @@ class pe {
2413
2413
  isComplete: e.isComplete,
2414
2414
  entries: e.entries.map((t) => ({
2415
2415
  ref: t.ref,
2416
- obj: Q(t.obj, (r) => this.wrapAccessor(r))
2416
+ obj: Z(t.obj, (r) => this.wrapAccessor(r))
2417
2417
  }))
2418
2418
  };
2419
2419
  }
@@ -2426,7 +2426,7 @@ class pe {
2426
2426
  obj: {
2427
2427
  id: t.obj.id,
2428
2428
  spec: t.obj.spec,
2429
- data: Ht(t.obj.data, (r) => this.wrapAccessor(r))
2429
+ data: Qt(t.obj.data, (r) => this.wrapAccessor(r))
2430
2430
  }
2431
2431
  }))
2432
2432
  };
@@ -2444,7 +2444,7 @@ class pe {
2444
2444
  "can't instantiate PFrames from this context (most porbably called from the future mapper)"
2445
2445
  );
2446
2446
  return this.env.driverKit.pFrameDriver.createPFrame(
2447
- e.map((t) => Q(t, (r) => this.getAccessor(r))),
2447
+ e.map((t) => Z(t, (r) => this.getAccessor(r))),
2448
2448
  this.computableCtx
2449
2449
  );
2450
2450
  }
@@ -2454,7 +2454,7 @@ class pe {
2454
2454
  "can't instantiate PTable from this context (most porbably called from the future mapper)"
2455
2455
  );
2456
2456
  return this.env.driverKit.pFrameDriver.createPTable(
2457
- ut(e, (t) => Q(t, (r) => this.getAccessor(r))),
2457
+ ht(e, (t) => Z(t, (r) => this.getAccessor(r))),
2458
2458
  this.computableCtx
2459
2459
  );
2460
2460
  }
@@ -2468,7 +2468,7 @@ class pe {
2468
2468
  }
2469
2469
  wrapAccessor(e) {
2470
2470
  if (e !== void 0) {
2471
- const t = X();
2471
+ const t = ee();
2472
2472
  return this.accessors.set(t, e), t;
2473
2473
  }
2474
2474
  }
@@ -2481,13 +2481,13 @@ class pe {
2481
2481
  return r;
2482
2482
  }
2483
2483
  tryExportSingleValue(e, t) {
2484
- let r, o = !1;
2484
+ let r, s = !1;
2485
2485
  switch (typeof e) {
2486
2486
  case "string":
2487
- r = this.vm.newString(e), o = !0;
2487
+ r = this.vm.newString(e), s = !0;
2488
2488
  break;
2489
2489
  case "number":
2490
- r = this.vm.newNumber(e), o = !0;
2490
+ r = this.vm.newNumber(e), s = !0;
2491
2491
  break;
2492
2492
  case "undefined":
2493
2493
  r = this.vm.undefined;
@@ -2500,13 +2500,13 @@ class pe {
2500
2500
  r = this.vm.null;
2501
2501
  break;
2502
2502
  }
2503
- if (ps(e)) {
2504
- r = this.vm.newArrayBuffer(e), o = !0;
2503
+ if (yo(e)) {
2504
+ r = this.vm.newArrayBuffer(e), s = !0;
2505
2505
  break;
2506
2506
  }
2507
2507
  return;
2508
2508
  }
2509
- return o && t != null ? t.manage(r) : r;
2509
+ return s && t != null ? t.manage(r) : r;
2510
2510
  }
2511
2511
  exportObjectUniversal(e, t) {
2512
2512
  const r = this.tryExportSingleValue(e, t);
@@ -2514,7 +2514,7 @@ class pe {
2514
2514
  }
2515
2515
  exportObjectViaJson(e, t) {
2516
2516
  const r = this.vm.newString(JSON.stringify(e)).consume(
2517
- (o) => this.vm.unwrapResult(this.vm.callFunction(this.fnJSONParse, this.vm.undefined, o))
2517
+ (s) => this.vm.unwrapResult(this.vm.callFunction(this.fnJSONParse, this.vm.undefined, s))
2518
2518
  );
2519
2519
  return t !== void 0 ? t.manage(r) : r;
2520
2520
  }
@@ -2536,233 +2536,233 @@ class pe {
2536
2536
  return JSON.parse(t);
2537
2537
  }
2538
2538
  injectCtx() {
2539
- ke.withScope((e) => {
2539
+ Fe.withScope((e) => {
2540
2540
  const t = e.manage(this.vm.newObject());
2541
2541
  this.vm.setProp(t, "args", e.manage(this.vm.newString(this.blockCtx.args))), this.blockCtx.uiState !== void 0 && this.vm.setProp(
2542
2542
  t,
2543
2543
  "uiState",
2544
2544
  e.manage(this.vm.newString(this.blockCtx.uiState))
2545
2545
  ), this.vm.setProp(t, "callbackRegistry", this.callbackRegistry);
2546
- const r = (o, i) => {
2547
- this.vm.newFunction(o, i).consume((n) => this.vm.setProp(t, o, n));
2546
+ const r = (s, n) => {
2547
+ this.vm.newFunction(s, n).consume((i) => this.vm.setProp(t, s, i));
2548
2548
  };
2549
- r("getAccessorHandleByName", (o) => this.exportSingleValue(
2550
- this.getAccessorHandleByName(this.vm.getString(o)),
2549
+ r("getAccessorHandleByName", (s) => this.exportSingleValue(
2550
+ this.getAccessorHandleByName(this.vm.getString(s)),
2551
2551
  void 0
2552
- )), r("resolveWithCommon", (o, i, ...n) => this.exportSingleValue(
2552
+ )), r("resolveWithCommon", (s, n, ...i) => this.exportSingleValue(
2553
2553
  this.resolveWithCommon(
2554
- this.vm.getString(o),
2555
- this.importObjectViaJson(i),
2556
- ...n.map(
2554
+ this.vm.getString(s),
2555
+ this.importObjectViaJson(n),
2556
+ ...i.map(
2557
2557
  (a) => this.importObjectViaJson(a)
2558
2558
  )
2559
2559
  ),
2560
2560
  void 0
2561
- )), r("getResourceType", (o) => this.exportObjectViaJson(this.getResourceType(this.vm.getString(o)), void 0)), r("getInputsLocked", (o) => this.exportSingleValue(this.getInputsLocked(this.vm.getString(o)), void 0)), r("getOutputsLocked", (o) => this.exportSingleValue(this.getOutputsLocked(this.vm.getString(o)), void 0)), r("getIsReadyOrError", (o) => this.exportSingleValue(this.getIsReadyOrError(this.vm.getString(o)), void 0)), r("getIsFinal", (o) => this.exportSingleValue(this.getIsFinal(this.vm.getString(o)), void 0)), r("getError", (o) => this.exportSingleValue(this.getError(this.vm.getString(o)), void 0)), r("listInputFields", (o) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(o)), void 0)), r("listOutputFields", (o) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(o)), void 0)), r("listDynamicFields", (o) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(o)), void 0)), r("getKeyValueBase64", (o, i) => this.exportSingleValue(
2562
- this.getKeyValueBase64(this.vm.getString(o), this.vm.getString(i)),
2561
+ )), r("getResourceType", (s) => this.exportObjectViaJson(this.getResourceType(this.vm.getString(s)), void 0)), r("getInputsLocked", (s) => this.exportSingleValue(this.getInputsLocked(this.vm.getString(s)), void 0)), r("getOutputsLocked", (s) => this.exportSingleValue(this.getOutputsLocked(this.vm.getString(s)), void 0)), r("getIsReadyOrError", (s) => this.exportSingleValue(this.getIsReadyOrError(this.vm.getString(s)), void 0)), r("getIsFinal", (s) => this.exportSingleValue(this.getIsFinal(this.vm.getString(s)), void 0)), r("getError", (s) => this.exportSingleValue(this.getError(this.vm.getString(s)), void 0)), r("listInputFields", (s) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(s)), void 0)), r("listOutputFields", (s) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(s)), void 0)), r("listDynamicFields", (s) => this.exportObjectViaJson(this.listInputFields(this.vm.getString(s)), void 0)), r("getKeyValueBase64", (s, n) => this.exportSingleValue(
2562
+ this.getKeyValueBase64(this.vm.getString(s), this.vm.getString(n)),
2563
2563
  void 0
2564
- )), r("getKeyValueAsString", (o, i) => this.exportSingleValue(
2565
- this.getKeyValueAsString(this.vm.getString(o), this.vm.getString(i)),
2564
+ )), r("getKeyValueAsString", (s, n) => this.exportSingleValue(
2565
+ this.getKeyValueAsString(this.vm.getString(s), this.vm.getString(n)),
2566
2566
  void 0
2567
- )), r("getDataBase64", (o) => this.exportSingleValue(this.getDataBase64(this.vm.getString(o)), void 0)), r("getDataAsString", (o) => this.exportSingleValue(this.getDataAsString(this.vm.getString(o)), void 0)), r("parsePObjectCollection", (o, i, n) => this.exportObjectUniversal(
2567
+ )), r("getDataBase64", (s) => this.exportSingleValue(this.getDataBase64(this.vm.getString(s)), void 0)), r("getDataAsString", (s) => this.exportSingleValue(this.getDataAsString(this.vm.getString(s)), void 0)), r("parsePObjectCollection", (s, n, i) => this.exportObjectUniversal(
2568
2568
  this.parsePObjectCollection(
2569
- this.vm.getString(o),
2570
- this.vm.dump(i),
2571
- this.vm.getString(n)
2569
+ this.vm.getString(s),
2570
+ this.vm.dump(n),
2571
+ this.vm.getString(i)
2572
2572
  ),
2573
2573
  void 0
2574
- )), r("getBlobContentAsBase64", (o) => this.exportSingleValue(
2575
- this.getBlobContentAsBase64(this.vm.getString(o)),
2574
+ )), r("getBlobContentAsBase64", (s) => this.exportSingleValue(
2575
+ this.getBlobContentAsBase64(this.vm.getString(s)),
2576
2576
  void 0
2577
- )), r("getBlobContentAsString", (o) => this.exportSingleValue(
2578
- this.getBlobContentAsString(this.vm.getString(o)),
2577
+ )), r("getBlobContentAsString", (s) => this.exportSingleValue(
2578
+ this.getBlobContentAsString(this.vm.getString(s)),
2579
2579
  void 0
2580
- )), r("getDownloadedBlobContentHandle", (o) => this.exportSingleValue(
2581
- this.getDownloadedBlobContentHandle(this.vm.getString(o)),
2580
+ )), r("getDownloadedBlobContentHandle", (s) => this.exportSingleValue(
2581
+ this.getDownloadedBlobContentHandle(this.vm.getString(s)),
2582
2582
  void 0
2583
- )), r("getOnDemandBlobContentHandle", (o) => this.exportSingleValue(
2584
- this.getOnDemandBlobContentHandle(this.vm.getString(o)),
2583
+ )), r("getOnDemandBlobContentHandle", (s) => this.exportSingleValue(
2584
+ this.getOnDemandBlobContentHandle(this.vm.getString(s)),
2585
2585
  void 0
2586
- )), r("getImportProgress", (o) => this.exportSingleValue(this.getImportProgress(this.vm.getString(o)), void 0)), r("getLastLogs", (o, i) => this.exportSingleValue(
2587
- this.getLastLogs(this.vm.getString(o), this.vm.getNumber(i)),
2586
+ )), r("getImportProgress", (s) => this.exportSingleValue(this.getImportProgress(this.vm.getString(s)), void 0)), r("getLastLogs", (s, n) => this.exportSingleValue(
2587
+ this.getLastLogs(this.vm.getString(s), this.vm.getNumber(n)),
2588
2588
  void 0
2589
- )), r("getProgressLog", (o, i) => this.exportSingleValue(
2590
- this.getProgressLog(this.vm.getString(o), this.vm.getString(i)),
2589
+ )), r("getProgressLog", (s, n) => this.exportSingleValue(
2590
+ this.getProgressLog(this.vm.getString(s), this.vm.getString(n)),
2591
2591
  void 0
2592
- )), r("getLogHandle", (o) => this.exportSingleValue(this.getLogHandle(this.vm.getString(o)), void 0)), r("getBlockLabel", (o) => this.exportSingleValue(this.getBlockLabel(this.vm.getString(o)), void 0)), r("getDataFromResultPool", (o) => this.exportObjectUniversal(this.getDataFromResultPool(), void 0)), r("getDataWithErrorsFromResultPool", (o) => this.exportObjectUniversal(this.getDataWithErrorsFromResultPool(), void 0)), r("getSpecsFromResultPool", (o) => this.exportObjectUniversal(this.getSpecsFromResultPool(), void 0)), r("calculateOptions", (o) => this.exportObjectUniversal(
2593
- this.calculateOptions(this.importObjectViaJson(o)),
2592
+ )), r("getLogHandle", (s) => this.exportSingleValue(this.getLogHandle(this.vm.getString(s)), void 0)), r("getBlockLabel", (s) => this.exportSingleValue(this.getBlockLabel(this.vm.getString(s)), void 0)), r("getDataFromResultPool", (s) => this.exportObjectUniversal(this.getDataFromResultPool(), void 0)), r("getDataWithErrorsFromResultPool", (s) => this.exportObjectUniversal(this.getDataWithErrorsFromResultPool(), void 0)), r("getSpecsFromResultPool", (s) => this.exportObjectUniversal(this.getSpecsFromResultPool(), void 0)), r("calculateOptions", (s) => this.exportObjectUniversal(
2593
+ this.calculateOptions(this.importObjectViaJson(s)),
2594
2594
  void 0
2595
- )), r("createPFrame", (o) => this.exportSingleValue(
2596
- this.createPFrame(this.importObjectViaJson(o)),
2595
+ )), r("createPFrame", (s) => this.exportSingleValue(
2596
+ this.createPFrame(this.importObjectViaJson(s)),
2597
2597
  void 0
2598
- )), r("createPTable", (o) => this.exportSingleValue(
2599
- this.createPTable(this.importObjectViaJson(o)),
2598
+ )), r("createPTable", (s) => this.exportSingleValue(
2599
+ this.createPTable(this.importObjectViaJson(s)),
2600
2600
  void 0
2601
2601
  )), this.vm.setProp(this.vm.global, "cfgRenderCtx", t);
2602
2602
  });
2603
2603
  }
2604
2604
  }
2605
- function hs(s, e, t, r, o = {}) {
2606
- return F.makeRaw((i) => {
2607
- const n = new ke();
2608
- i.addOnDestroy(() => n.dispose());
2609
- const a = n.manage(s.quickJs.newRuntime());
2605
+ function bo(o, e, t, r, s = {}) {
2606
+ return F.makeRaw((n) => {
2607
+ const i = new Fe();
2608
+ n.addOnDestroy(() => i.dispose());
2609
+ const a = i.manage(o.quickJs.newRuntime());
2610
2610
  a.setMemoryLimit(1024 * 640), a.setMaxStackSize(1024 * 320);
2611
- const c = n.manage(a.newContext()), u = new pe(n, c, e, s, i);
2611
+ const c = i.manage(a.newContext()), u = new ge(i, c, e, o, n);
2612
2612
  u.evaluateBundle(r.content);
2613
2613
  const l = u.runCallback(t);
2614
2614
  return u.resetComputableCtx(), {
2615
2615
  ir: u.computablesToResolve,
2616
2616
  postprocessValue: async (p) => {
2617
- for (const [h, f] of Object.entries(p)) u.runCallback(h, f);
2617
+ for (const [g, m] of Object.entries(p)) u.runCallback(g, m);
2618
2618
  return u.importObjectUniversal(l);
2619
2619
  }
2620
2620
  };
2621
- }, o);
2621
+ }, s);
2622
2622
  }
2623
- function xe(s, e, t, r, o = {}) {
2624
- if (lt(t)) {
2623
+ function Ee(o, e, t, r, s = {}) {
2624
+ if (ft(t)) {
2625
2625
  if (r === void 0) throw new Error("No code bundle.");
2626
- return hs(s, e, t, r, o);
2627
- } else return Vt(s.driverKit, e, t, o);
2626
+ return bo(o, e, t, r, s);
2627
+ } else return Kt(o.driverKit, e, t, s);
2628
2628
  }
2629
- function gs(s, e, t) {
2629
+ function wo(o, e, t) {
2630
2630
  return F.make(
2631
2631
  (r) => {
2632
- var b, C, I, $, K, G, z, oe;
2633
- const o = r.accessor(s).node(), i = w(o.getKeyValueAsJson(Ve)), n = w(o.getKeyValueAsJson(ee)), a = w(o.getKeyValueAsJson(te)), c = w(o.getKeyValueAsJson(W)), u = w(
2634
- o.getKeyValueAsJson(ue)
2632
+ var h, C, I, G, U, H, z, oe;
2633
+ const s = r.accessor(o).node(), n = w(s.getKeyValueAsJson(Me)), i = w(s.getKeyValueAsJson(te)), a = w(s.getKeyValueAsJson(re)), c = w(s.getKeyValueAsJson(W)), u = w(
2634
+ s.getKeyValueAsJson(le)
2635
2635
  ), l = /* @__PURE__ */ new Map();
2636
- for (const { id: k } of L(c)) {
2637
- const J = o.traverse({
2636
+ for (const { id: k } of N(c)) {
2637
+ const J = s.traverse({
2638
2638
  field: P(k, "currentArgs"),
2639
2639
  assertFieldType: "Dynamic",
2640
2640
  errorIfFieldNotSet: !0
2641
2641
  });
2642
2642
  let Y;
2643
- const A = o.traverse({
2643
+ const E = s.traverse({
2644
2644
  field: P(k, "prodArgs"),
2645
2645
  assertFieldType: "Dynamic",
2646
2646
  stableIfNotFound: !0
2647
2647
  });
2648
- if (A !== void 0) {
2649
- const x = o.getField({
2648
+ if (E !== void 0) {
2649
+ const x = s.getField({
2650
2650
  field: P(k, "prodOutput"),
2651
2651
  assertFieldType: "Dynamic",
2652
2652
  errorIfFieldNotFound: !0
2653
- }), R = o.getField({
2653
+ }), B = s.getField({
2654
2654
  field: P(k, "prodUiCtx"),
2655
2655
  assertFieldType: "Dynamic",
2656
2656
  errorIfFieldNotFound: !0
2657
2657
  });
2658
2658
  Y = {
2659
- arguments: A.getDataAsJson(),
2660
- stale: J.id !== A.id,
2661
- outputError: x.error !== void 0 || R.error !== void 0 || ((b = x.value) == null ? void 0 : b.getError()) !== void 0 || ((C = R.value) == null ? void 0 : C.getError()) !== void 0,
2662
- outputsError: ((I = x.error) == null ? void 0 : I.getDataAsString()) ?? ((K = ($ = x.value) == null ? void 0 : $.getError()) == null ? void 0 : K.getDataAsString()),
2663
- exportsError: ((G = R.error) == null ? void 0 : G.getDataAsString()) ?? ((oe = (z = R.value) == null ? void 0 : z.getError()) == null ? void 0 : oe.getDataAsString()),
2664
- finished: (x.value !== void 0 && x.value.getIsReadyOrError() || x.error !== void 0 && x.error.getIsReadyOrError()) && (R.value !== void 0 && R.value.getIsReadyOrError() || R.error !== void 0 && R.error.getIsReadyOrError())
2659
+ arguments: E.getDataAsJson(),
2660
+ stale: J.id !== E.id,
2661
+ outputError: x.error !== void 0 || B.error !== void 0 || ((h = x.value) == null ? void 0 : h.getError()) !== void 0 || ((C = B.value) == null ? void 0 : C.getError()) !== void 0,
2662
+ outputsError: ((I = x.error) == null ? void 0 : I.getDataAsString()) ?? ((U = (G = x.value) == null ? void 0 : G.getError()) == null ? void 0 : U.getDataAsString()),
2663
+ exportsError: ((H = B.error) == null ? void 0 : H.getDataAsString()) ?? ((oe = (z = B.value) == null ? void 0 : z.getError()) == null ? void 0 : oe.getDataAsString()),
2664
+ finished: (x.value !== void 0 && x.value.getIsReadyOrError() || x.error !== void 0 && x.error.getIsReadyOrError()) && (B.value !== void 0 && B.value.getIsReadyOrError() || B.error !== void 0 && B.error.getIsReadyOrError())
2665
2665
  };
2666
2666
  }
2667
2667
  l.set(k, { currentArguments: J.getDataAsJson(), prod: Y });
2668
2668
  }
2669
- const p = ne(c, (k) => l.get(k).currentArguments), h = new Set(u.blocksInLimbo), f = [...L(c)].map(({ id: k, label: J, renderingMode: Y }) => {
2670
- var Me, Ue, $e, Ge;
2671
- const A = w(l.get(k)), x = w(p.nodes.get(k));
2672
- let R = "NotCalculated";
2673
- A.prod !== void 0 && (h.has(k) ? R = "Limbo" : R = A.prod.finished ? "Done" : "Running");
2674
- const M = o.traverse(
2669
+ const p = ae(c, (k) => l.get(k).currentArguments), g = new Set(u.blocksInLimbo), m = [...N(c)].map(({ id: k, label: J, renderingMode: Y }) => {
2670
+ var He, _e, We, ze;
2671
+ const E = w(l.get(k)), x = w(p.nodes.get(k));
2672
+ let B = "NotCalculated";
2673
+ E.prod !== void 0 && (g.has(k) ? B = "Limbo" : B = E.prod.finished ? "Done" : "Running");
2674
+ const K = s.traverse(
2675
2675
  {
2676
2676
  field: P(k, "blockPack"),
2677
2677
  assertFieldType: "Dynamic",
2678
2678
  errorIfFieldNotSet: !0
2679
2679
  },
2680
- { field: y.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2681
- ), N = M == null ? void 0 : M.getDataAsJson(), { sections: se, inputsValid: v, sdkVersion: O } = de(N == null ? void 0 : N.config, (fe) => {
2682
- const q = je(fe), He = Je(o, k);
2680
+ { field: b.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2681
+ ), L = K == null ? void 0 : K.getDataAsJson(), { sections: ne, inputsValid: y, sdkVersion: O } = pe(L == null ? void 0 : L.config, (me) => {
2682
+ const q = Ie(me), Ye = $e(s, k);
2683
2683
  return {
2684
- sections: xe(
2684
+ sections: Ee(
2685
2685
  t,
2686
- He,
2686
+ Ye,
2687
2687
  q.sections,
2688
2688
  q.code
2689
2689
  ),
2690
- inputsValid: xe(
2690
+ inputsValid: Ee(
2691
2691
  t,
2692
- He,
2692
+ Ye,
2693
2693
  q.inputsValid,
2694
2694
  q.code
2695
2695
  ),
2696
2696
  sdkVersion: q.sdkVersion
2697
2697
  };
2698
- }) || {}, B = de(
2699
- N,
2700
- (fe) => t.blockUpdateWatcher.get(fe.source)
2698
+ }) || {}, R = pe(
2699
+ L,
2700
+ (me) => t.blockUpdateWatcher.get(me.source)
2701
2701
  );
2702
2702
  return {
2703
2703
  id: k,
2704
2704
  label: J,
2705
2705
  renderingMode: Y,
2706
- stale: ((Me = A.prod) == null ? void 0 : Me.stale) !== !1 || R === "Limbo",
2706
+ stale: ((He = E.prod) == null ? void 0 : He.stale) !== !1 || B === "Limbo",
2707
2707
  missingReference: x.missingReferences,
2708
2708
  upstreams: [...p.traverseIdsExcludingRoots("upstream", k)],
2709
2709
  downstreams: [...p.traverseIdsExcludingRoots("downstream", k)],
2710
- calculationStatus: R,
2711
- outputErrors: ((Ue = A.prod) == null ? void 0 : Ue.outputError) === !0,
2712
- outputsError: ($e = A.prod) == null ? void 0 : $e.outputsError,
2713
- exportsError: (Ge = A.prod) == null ? void 0 : Ge.exportsError,
2714
- sections: se,
2715
- inputsValid: v,
2716
- currentBlockPack: N == null ? void 0 : N.source,
2717
- updatedBlockPack: B,
2710
+ calculationStatus: B,
2711
+ outputErrors: ((_e = E.prod) == null ? void 0 : _e.outputError) === !0,
2712
+ outputsError: (We = E.prod) == null ? void 0 : We.outputsError,
2713
+ exportsError: (ze = E.prod) == null ? void 0 : ze.exportsError,
2714
+ sections: ne,
2715
+ inputsValid: y,
2716
+ currentBlockPack: L == null ? void 0 : L.source,
2717
+ updatedBlockPack: R,
2718
2718
  sdkVersion: O,
2719
2719
  navigationState: e.getState(k)
2720
2720
  };
2721
2721
  });
2722
2722
  return {
2723
2723
  meta: a,
2724
- created: new Date(i),
2725
- lastModified: new Date(n),
2726
- authorMarker: o.getKeyValueAsJson(Fe),
2727
- blocks: f
2724
+ created: new Date(n),
2725
+ lastModified: new Date(i),
2726
+ authorMarker: s.getKeyValueAsJson(Oe),
2727
+ blocks: m
2728
2728
  };
2729
2729
  },
2730
2730
  {
2731
2731
  postprocessValue: (r) => {
2732
- const o = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
2732
+ const s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
2733
2733
  return {
2734
2734
  ...r,
2735
- blocks: r.blocks.map((n) => {
2736
- n.inputsValid || o.add(n.id), n.stale && i.add(n.id);
2737
- const a = n.stale || n.upstreams.findIndex((u) => i.has(u)) !== -1, c = (a || n.outputErrors) && !!n.inputsValid && !n.missingReference && n.upstreams.findIndex((u) => o.has(u)) === -1;
2738
- return { ...n, canRun: c, stale: a };
2735
+ blocks: r.blocks.map((i) => {
2736
+ i.inputsValid || s.add(i.id), i.stale && n.add(i.id);
2737
+ const a = i.stale || i.upstreams.findIndex((u) => n.has(u)) !== -1, c = (a || i.outputErrors) && !!i.inputsValid && !i.missingReference && i.upstreams.findIndex((u) => s.has(u)) === -1;
2738
+ return { ...i, canRun: c, stale: a };
2739
2739
  })
2740
2740
  };
2741
2741
  }
2742
2742
  }
2743
2743
  ).withStableType();
2744
2744
  }
2745
- function Nt(s, e) {
2745
+ function Gt(o, e) {
2746
2746
  var t, r;
2747
- return de(
2748
- (r = (t = s.traverse(
2747
+ return pe(
2748
+ (r = (t = o.traverse(
2749
2749
  {
2750
2750
  field: P(e, "blockPack"),
2751
2751
  assertFieldType: "Dynamic",
2752
2752
  errorIfFieldNotSet: !0
2753
2753
  },
2754
- { field: y.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2754
+ { field: b.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2755
2755
  )) == null ? void 0 : t.getDataAsJson()) == null ? void 0 : r.config,
2756
- (o) => je(o)
2756
+ (s) => Ie(s)
2757
2757
  );
2758
2758
  }
2759
- function fs(s, e) {
2760
- const t = s.node();
2761
- if (U(t.resourceType, Ct)) {
2759
+ function So(o, e) {
2760
+ const t = o.node();
2761
+ if ($(t.resourceType, Dt)) {
2762
2762
  const r = t.getDataAsJson();
2763
2763
  if (r === void 0) throw new Error("No resource data.");
2764
2764
  return e.frontendDownloadDriver.getPath(new URL(r.url)).withStableType();
2765
- } else if (U(t.resourceType, Pt)) {
2765
+ } else if ($(t.resourceType, xt)) {
2766
2766
  const r = t.getDataAsJson();
2767
2767
  if (r === void 0) throw new Error("No resource data.");
2768
2768
  return e.signer.verify(
@@ -2773,10 +2773,10 @@ function fs(s, e) {
2773
2773
  } else
2774
2774
  throw new Error(`Unsupported resource type: ${JSON.stringify(t.resourceType)}`);
2775
2775
  }
2776
- function ms(s, e) {
2777
- if (s !== void 0)
2776
+ function ko(o, e) {
2777
+ if (o !== void 0)
2778
2778
  return F.make(
2779
- (t) => fs(t.accessor(s), e),
2779
+ (t) => So(t.accessor(o), e),
2780
2780
  {
2781
2781
  postprocessValue: (t) => {
2782
2782
  if (t !== void 0) {
@@ -2788,89 +2788,89 @@ function ms(s, e) {
2788
2788
  }
2789
2789
  ).withStableType();
2790
2790
  }
2791
- function vs(s, e, t) {
2791
+ function Co(o, e, t) {
2792
2792
  return F.make(
2793
2793
  (r) => {
2794
2794
  var a;
2795
- const o = r.accessor(s).node(), i = Nt(o, e), n = (a = o.traverse(
2795
+ const s = r.accessor(o).node(), n = Gt(s, e), i = (a = s.traverse(
2796
2796
  {
2797
2797
  field: P(e, "blockPack"),
2798
2798
  assertFieldType: "Dynamic"
2799
2799
  },
2800
- { field: y.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 },
2801
- { field: Bt, assertFieldType: "Input" }
2800
+ { field: b.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 },
2801
+ { field: Tt, assertFieldType: "Input" }
2802
2802
  )) == null ? void 0 : a.persist();
2803
- return { path: ms(n, t), sdkVersion: i == null ? void 0 : i.sdkVersion };
2803
+ return { path: ko(i, t), sdkVersion: n == null ? void 0 : n.sdkVersion };
2804
2804
  },
2805
2805
  { mode: "StableOnlyLive" }
2806
2806
  );
2807
2807
  }
2808
- function ys(s, e, t) {
2808
+ function Po(o, e, t) {
2809
2809
  return F.make(
2810
2810
  (r) => {
2811
- const o = r.accessor(s).node(), i = Je(o, e);
2811
+ const s = r.accessor(o).node(), n = $e(s, e);
2812
2812
  return {
2813
- author: o.getKeyValueAsJson(Pe(e)),
2814
- args: JSON.parse(i.args),
2815
- ui: i.uiState !== void 0 ? JSON.parse(i.uiState) : void 0
2813
+ author: s.getKeyValueAsJson(Be(e)),
2814
+ args: JSON.parse(n.args),
2815
+ ui: n.uiState !== void 0 ? JSON.parse(n.uiState) : void 0
2816
2816
  };
2817
2817
  },
2818
- { key: "inputs#" + gt(s.rid) + e }
2818
+ { key: "inputs#" + bt(o.rid) + e }
2819
2819
  );
2820
2820
  }
2821
- function bs(s, e, t) {
2821
+ function Fo(o, e, t) {
2822
2822
  return F.make(
2823
2823
  (r) => {
2824
- const o = r.accessor(s).node(), i = jt(o, e), n = Nt(o, e);
2825
- return de(n, (a) => {
2824
+ const s = r.accessor(o).node(), n = Nt(s, e), i = Gt(s, e);
2825
+ return pe(i, (a) => {
2826
2826
  const c = {};
2827
2827
  for (const [u, l] of Object.entries(a.outputs))
2828
2828
  c[u] = F.wrapError(
2829
- xe(t, i, l, a.code)
2829
+ Ee(t, n, l, a.code)
2830
2830
  );
2831
2831
  return c;
2832
2832
  });
2833
2833
  },
2834
- { key: "outputs#" + gt(s.rid) + e }
2834
+ { key: "outputs#" + bt(o.rid) + e }
2835
2835
  ).withStableType();
2836
2836
  }
2837
- function ws(s, e) {
2837
+ function Ro(o, e) {
2838
2838
  return F.make((t) => {
2839
- const r = t.accessor(s).node(), o = w(r.getKeyValueAsJson(W)), i = [];
2840
- for (const { id: n, renderingMode: a } of L(o)) {
2839
+ const r = t.accessor(o).node(), s = w(r.getKeyValueAsJson(W)), n = [];
2840
+ for (const { id: i, renderingMode: a } of N(s)) {
2841
2841
  const c = r.traverse(
2842
2842
  {
2843
- field: P(n, "blockPack"),
2843
+ field: P(i, "blockPack"),
2844
2844
  assertFieldType: "Dynamic",
2845
2845
  errorIfFieldNotSet: !0
2846
2846
  },
2847
- { field: y.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2847
+ { field: b.HolderRefField, assertFieldType: "Input", errorIfFieldNotFound: !0 }
2848
2848
  ), u = c == null ? void 0 : c.getDataAsJson();
2849
2849
  if ((u == null ? void 0 : u.config) === void 0) continue;
2850
- const l = je(u.config), p = Object.entries(l.outputs).map(([, f]) => f).filter((f) => !lt(f) && Lo(f)).map((f) => f);
2850
+ const l = Ie(u.config), p = Object.entries(l.outputs).map(([, m]) => m).filter((m) => !ft(m) && Ks(m)).map((m) => m);
2851
2851
  if (p.length === 0) continue;
2852
- const h = jt(r, n);
2853
- for (const f of p)
2854
- i.push(F.wrapError(Vt(e.driverKit, h, f)));
2852
+ const g = Nt(r, i);
2853
+ for (const m of p)
2854
+ n.push(F.wrapError(Kt(e.driverKit, g, m)));
2855
2855
  }
2856
- return i;
2856
+ return n;
2857
2857
  });
2858
2858
  }
2859
- class Ss {
2859
+ class Bo {
2860
2860
  constructor() {
2861
2861
  d(this, "states", /* @__PURE__ */ new Map());
2862
2862
  }
2863
2863
  setState(e, t) {
2864
2864
  const r = this.states.get(e);
2865
2865
  if (r === void 0) {
2866
- this.states.set(e, { state: t, change: new ze() });
2866
+ this.states.set(e, { state: t, change: new Xe() });
2867
2867
  return;
2868
2868
  }
2869
2869
  r.state = { ...t }, r.change.markChanged();
2870
2870
  }
2871
2871
  readState(e, t) {
2872
2872
  let r = this.states.get(t);
2873
- return r === void 0 && (r = { state: { ..._t }, change: new ze() }, this.states.set(t, r)), r.change.attachWatcher(e.watcher), r.state;
2873
+ return r === void 0 && (r = { state: { ...Zt }, change: new Xe() }, this.states.set(t, r)), r.change.attachWatcher(e.watcher), r.state;
2874
2874
  }
2875
2875
  getState(e) {
2876
2876
  return F.make(
@@ -2883,38 +2883,38 @@ class Ss {
2883
2883
  t !== void 0 && (this.states.delete(e), t.change.markChanged());
2884
2884
  }
2885
2885
  }
2886
- class Ke {
2886
+ class Ge {
2887
2887
  constructor(e, t, r) {
2888
2888
  /** Underlying pl resource id */
2889
2889
  d(this, "rid");
2890
2890
  /** Data for the left panel, contain basic information about block status. */
2891
2891
  d(this, "overview");
2892
- d(this, "navigationStates", new Ss());
2892
+ d(this, "navigationStates", new Bo());
2893
2893
  d(this, "blockComputables", /* @__PURE__ */ new Map());
2894
2894
  d(this, "blockFrontends", /* @__PURE__ */ new Map());
2895
2895
  d(this, "activeConfigs");
2896
2896
  d(this, "refreshLoopResult");
2897
2897
  d(this, "abortController", new AbortController());
2898
2898
  d(this, "destroyed", !1);
2899
- this.env = e, this.projectTree = r, this.overview = gs(
2899
+ this.env = e, this.projectTree = r, this.overview = wo(
2900
2900
  r.entry(),
2901
2901
  this.navigationStates,
2902
2902
  e
2903
- ).withPreCalculatedValueTree(), this.rid = t, this.refreshLoopResult = this.refreshLoop(), this.activeConfigs = ws(r.entry(), e);
2903
+ ).withPreCalculatedValueTree(), this.rid = t, this.refreshLoopResult = this.refreshLoop(), this.activeConfigs = Ro(r.entry(), e);
2904
2904
  }
2905
2905
  async refreshLoop() {
2906
2906
  for (; !this.destroyed; )
2907
2907
  try {
2908
- await we(this.env.pl, this.rid, (e) => {
2908
+ await Se(this.env.pl, this.rid, (e) => {
2909
2909
  e.doRefresh(this.env.ops.stagingRenderingRate);
2910
- }), await this.activeConfigs.getValue(), await gr(this.env.ops.projectRefreshInterval, this.abortController.signal);
2910
+ }), await this.activeConfigs.getValue(), await kt(this.env.ops.projectRefreshInterval, this.abortController.signal);
2911
2911
  } catch (e) {
2912
- if (ir(e)) {
2912
+ if (dr(e)) {
2913
2913
  console.warn(
2914
2914
  "project refresh routine terminated, because project was externally deleted"
2915
2915
  );
2916
2916
  break;
2917
- } else if (!nr(e))
2917
+ } else if (!pr(e))
2918
2918
  throw new Error("Unexpected exception", { cause: e });
2919
2919
  }
2920
2920
  }
@@ -2929,40 +2929,40 @@ class Ke {
2929
2929
  *
2930
2930
  * @return returns newly created block id
2931
2931
  * */
2932
- async addBlock(e, t, r, o = void 0, i = X()) {
2933
- const n = await this.env.bpPreparer.prepare(t), a = await this.env.bpPreparer.getBlockConfig(t);
2932
+ async addBlock(e, t, r, s = void 0, n = ee()) {
2933
+ const i = await this.env.bpPreparer.prepare(t), a = await this.env.bpPreparer.getBlockConfig(t);
2934
2934
  return await V(
2935
2935
  this.env.pl,
2936
2936
  this.rid,
2937
- o,
2937
+ s,
2938
2938
  (c) => c.addBlock(
2939
2939
  {
2940
- id: i,
2940
+ id: n,
2941
2941
  label: e,
2942
2942
  renderingMode: a.renderingMode
2943
2943
  },
2944
2944
  {
2945
2945
  args: JSON.stringify(a.initialArgs),
2946
- blockPack: n
2946
+ blockPack: i
2947
2947
  },
2948
2948
  r
2949
2949
  )
2950
- ), await this.projectTree.refreshState(), i;
2950
+ ), await this.projectTree.refreshState(), n;
2951
2951
  }
2952
2952
  /**
2953
2953
  * Update block to new block pack, optionally resetting args and ui state to
2954
2954
  * initial values
2955
2955
  * */
2956
- async updateBlockPack(e, t, r = !1, o) {
2957
- const i = await this.env.bpPreparer.prepare(t), n = await this.env.bpPreparer.getBlockConfig(t);
2956
+ async updateBlockPack(e, t, r = !1, s) {
2957
+ const n = await this.env.bpPreparer.prepare(t), i = await this.env.bpPreparer.getBlockConfig(t);
2958
2958
  await V(
2959
2959
  this.env.pl,
2960
2960
  this.rid,
2961
- o,
2961
+ s,
2962
2962
  (a) => a.migrateBlockPack(
2963
2963
  e,
2964
- i,
2965
- r ? JSON.stringify(n.initialArgs) : void 0
2964
+ n,
2965
+ r ? JSON.stringify(i.initialArgs) : void 0
2966
2966
  )
2967
2967
  ), await this.projectTree.refreshState();
2968
2968
  }
@@ -2978,27 +2978,27 @@ class Ke {
2978
2978
  */
2979
2979
  async reorderBlocks(e, t) {
2980
2980
  await V(this.env.pl, this.rid, t, (r) => {
2981
- const o = r.structure;
2982
- if (o.groups.length !== 1)
2981
+ const s = r.structure;
2982
+ if (s.groups.length !== 1)
2983
2983
  throw new Error("Unexpected project structure, non-sinular block group");
2984
- const i = o.groups[0];
2985
- if (i.blocks.length !== e.length)
2986
- throw new Error(`Lengh mismatch: ${i.blocks.length} !== ${e.length}`);
2984
+ const n = s.groups[0];
2985
+ if (n.blocks.length !== e.length)
2986
+ throw new Error(`Lengh mismatch: ${n.blocks.length} !== ${e.length}`);
2987
2987
  if (new Set(e).size !== e.length) throw new Error("Repeated block ids");
2988
- const n = {
2988
+ const i = {
2989
2989
  groups: [
2990
2990
  {
2991
- id: i.id,
2992
- label: i.label,
2991
+ id: n.id,
2992
+ label: n.label,
2993
2993
  blocks: e.map((a) => {
2994
- const c = i.blocks.find((u) => u.id === a);
2994
+ const c = n.blocks.find((u) => u.id === a);
2995
2995
  if (c === void 0) throw new Error(`Can't find block: ${a}`);
2996
2996
  return c;
2997
2997
  })
2998
2998
  }
2999
2999
  ]
3000
3000
  };
3001
- r.updateStructure(n);
3001
+ r.updateStructure(i);
3002
3002
  }), await this.projectTree.refreshState();
3003
3003
  }
3004
3004
  /**
@@ -3007,7 +3007,7 @@ class Ke {
3007
3007
  * stale state.
3008
3008
  * */
3009
3009
  async runBlock(e) {
3010
- await we(this.env.pl, this.rid, (t) => t.renderProduction([e], !0)), await this.projectTree.refreshState();
3010
+ await Se(this.env.pl, this.rid, (t) => t.renderProduction([e], !0)), await this.projectTree.refreshState();
3011
3011
  }
3012
3012
  /**
3013
3013
  * Stops the block if it is running by destroying its production state. All
@@ -3015,12 +3015,12 @@ class Ke {
3015
3015
  * calculated.
3016
3016
  * */
3017
3017
  async stopBlock(e) {
3018
- await we(this.env.pl, this.rid, (t) => t.stopProduction(e)), await this.projectTree.refreshState();
3018
+ await Se(this.env.pl, this.rid, (t) => t.stopProduction(e)), await this.projectTree.refreshState();
3019
3019
  }
3020
3020
  /** Update block label. */
3021
3021
  async setBlockLabel(e, t, r) {
3022
- await V(this.env.pl, this.rid, r, (o) => {
3023
- o.setBlockLabel(e, t);
3022
+ await V(this.env.pl, this.rid, r, (s) => {
3023
+ s.setBlockLabel(e, t);
3024
3024
  }), await this.projectTree.refreshState();
3025
3025
  }
3026
3026
  /**
@@ -3034,7 +3034,7 @@ class Ke {
3034
3034
  this.env.pl,
3035
3035
  this.rid,
3036
3036
  r,
3037
- (o) => o.setArgs([{ blockId: e, args: JSON.stringify(t) }])
3037
+ (s) => s.setArgs([{ blockId: e, args: JSON.stringify(t) }])
3038
3038
  ), await this.projectTree.refreshState();
3039
3039
  }
3040
3040
  /**
@@ -3048,7 +3048,7 @@ class Ke {
3048
3048
  this.env.pl,
3049
3049
  this.rid,
3050
3050
  r,
3051
- (o) => o.setUiState(e, t === void 0 ? void 0 : JSON.stringify(t))
3051
+ (s) => s.setUiState(e, t === void 0 ? void 0 : JSON.stringify(t))
3052
3052
  ), await this.projectTree.refreshState();
3053
3053
  }
3054
3054
  /**
@@ -3063,20 +3063,20 @@ class Ke {
3063
3063
  * transactionally associated with the block, to facilitate conflict resolution
3064
3064
  * in collaborative editing scenario.
3065
3065
  * */
3066
- async setBlockArgsAndUiState(e, t, r, o) {
3067
- await V(this.env.pl, this.rid, o, (i) => {
3068
- i.setArgs([{ blockId: e, args: JSON.stringify(t) }]), i.setUiState(e, JSON.stringify(r));
3066
+ async setBlockArgsAndUiState(e, t, r, s) {
3067
+ await V(this.env.pl, this.rid, s, (n) => {
3068
+ n.setArgs([{ blockId: e, args: JSON.stringify(t) }]), n.setUiState(e, JSON.stringify(r));
3069
3069
  }), await this.projectTree.refreshState();
3070
3070
  }
3071
3071
  /** Resets arguments and ui state of the block to initial state */
3072
3072
  async resetBlockArgsAndUiState(e, t) {
3073
3073
  await this.env.pl.withWriteTx("BlockInputsReset", async (r) => {
3074
- const o = Se(
3074
+ const s = Pe(
3075
3075
  (await r.getField(S(this.rid, P(e, "blockPack")))).value
3076
- ), i = Se(
3077
- (await r.getField(S(o, y.HolderRefField))).value
3078
- ), n = await r.getResourceData(i, !1), a = JSON.parse(
3079
- Buffer.from(w(n.data)).toString("utf-8")
3076
+ ), n = Pe(
3077
+ (await r.getField(S(s, b.HolderRefField))).value
3078
+ ), i = await r.getResourceData(n, !1), a = JSON.parse(
3079
+ Buffer.from(w(i.data)).toString("utf-8")
3080
3080
  );
3081
3081
  await V(r, this.rid, t, (c) => {
3082
3082
  c.setArgs([{ blockId: e, args: JSON.stringify(a.config.initialArgs) }]), c.setUiState(e, void 0);
@@ -3086,23 +3086,23 @@ class Ke {
3086
3086
  getBlockComputables(e) {
3087
3087
  const t = this.blockComputables.get(e);
3088
3088
  if (t === void 0) {
3089
- const r = bs(this.projectTree.entry(), e, this.env), i = {
3089
+ const r = Fo(this.projectTree.entry(), e, this.env), n = {
3090
3090
  fullState: F.make(
3091
- (n) => ({
3092
- argsAndUiState: ys(this.projectTree.entry(), e),
3091
+ (i) => ({
3092
+ argsAndUiState: Po(this.projectTree.entry(), e),
3093
3093
  outputs: r,
3094
3094
  navigationState: this.navigationStates.getState(e)
3095
3095
  }),
3096
3096
  {
3097
- postprocessValue: (n) => ({
3098
- ...n.argsAndUiState,
3099
- outputs: n.outputs,
3100
- navigationState: n.navigationState
3097
+ postprocessValue: (i) => ({
3098
+ ...i.argsAndUiState,
3099
+ outputs: i.outputs,
3100
+ navigationState: i.navigationState
3101
3101
  })
3102
3102
  }
3103
3103
  ).withPreCalculatedValueTree()
3104
3104
  };
3105
- return this.blockComputables.set(e, i), i;
3105
+ return this.blockComputables.set(e, n), n;
3106
3106
  }
3107
3107
  return t;
3108
3108
  }
@@ -3120,7 +3120,7 @@ class Ke {
3120
3120
  getBlockFrontend(e) {
3121
3121
  const t = this.blockFrontends.get(e);
3122
3122
  if (t === void 0) {
3123
- const r = vs(
3123
+ const r = Co(
3124
3124
  this.projectTree.entry(),
3125
3125
  e,
3126
3126
  this.env
@@ -3140,32 +3140,32 @@ class Ke {
3140
3140
  await this.destroy();
3141
3141
  }
3142
3142
  static async init(e, t) {
3143
- const r = await ft.init(
3143
+ const r = await wt.init(
3144
3144
  e.pl,
3145
3145
  t,
3146
3146
  {
3147
3147
  ...e.ops.defaultTreeOptions,
3148
- pruning: ks
3148
+ pruning: Oo
3149
3149
  },
3150
3150
  e.logger
3151
3151
  );
3152
- return new Ke(e, t, r);
3152
+ return new Ge(e, t, r);
3153
3153
  }
3154
3154
  }
3155
- function ks(s) {
3156
- switch (s.type.name) {
3155
+ function Oo(o) {
3156
+ switch (o.type.name) {
3157
3157
  case "BlockPackCustom":
3158
- return s.fields.filter((e) => e.name !== "template");
3158
+ return o.fields.filter((e) => e.name !== "template");
3159
3159
  case "UserProject":
3160
- return s.fields.filter((e) => !e.name.startsWith("__serviceTemplate"));
3160
+ return o.fields.filter((e) => !e.name.startsWith("__serviceTemplate"));
3161
3161
  case "Blob":
3162
3162
  return [];
3163
3163
  default:
3164
- return s.fields;
3164
+ return o.fields;
3165
3165
  }
3166
3166
  }
3167
- const Jt = {
3168
- logger: new Zt(),
3167
+ const Ht = {
3168
+ logger: new or(),
3169
3169
  blobDriverOps: {
3170
3170
  cacheSoftSizeBytes: 100 * 1024 * 1024,
3171
3171
  // 100MB
@@ -3183,13 +3183,13 @@ const Jt = {
3183
3183
  stopPollingDelay: 1e3
3184
3184
  }
3185
3185
  };
3186
- function Kt(s) {
3186
+ function _t(o) {
3187
3187
  return {
3188
- blobDownloadPath: E.join(s, "download")
3188
+ blobDownloadPath: T.join(o, "download")
3189
3189
  };
3190
3190
  }
3191
- const Cs = {
3192
- ...Jt,
3191
+ const Do = {
3192
+ ...Ht,
3193
3193
  defaultTreeOptions: {
3194
3194
  pollingInterval: 350,
3195
3195
  stopPollingDelay: 2500
@@ -3198,20 +3198,20 @@ const Cs = {
3198
3198
  projectRefreshInterval: 700,
3199
3199
  stagingRenderingRate: 5
3200
3200
  };
3201
- function Ps(s) {
3201
+ function xo(o) {
3202
3202
  return {
3203
- ...Kt(s),
3204
- frontendDownloadPath: E.join(s, "frontend")
3203
+ ..._t(o),
3204
+ frontendDownloadPath: T.join(o, "frontend")
3205
3205
  };
3206
3206
  }
3207
- const Fs = {
3207
+ const jo = {
3208
3208
  minDelay: 1500
3209
- }, Bs = "__no_updates__";
3210
- class Rs extends ur {
3211
- constructor(t, r, o = {}) {
3212
- super({ ...o, ...Fs }, r);
3209
+ }, To = "__no_updates__";
3210
+ class Eo extends mr {
3211
+ constructor(t, r, s = {}) {
3212
+ super({ ...s, ...jo }, r);
3213
3213
  d(this, "http");
3214
- this.registryProvider = t, this.http = o.http;
3214
+ this.registryProvider = t, this.http = s.http;
3215
3215
  }
3216
3216
  getKey(t) {
3217
3217
  switch (t.type) {
@@ -3222,7 +3222,7 @@ class Rs extends ur {
3222
3222
  case "from-registry-v2":
3223
3223
  return `from_registry_v2_${t.registryUrl}_${t.id.organization}_${t.id.name}_${t.id.version}`;
3224
3224
  default:
3225
- return Bs;
3225
+ return To;
3226
3226
  }
3227
3227
  }
3228
3228
  async readValue(t) {
@@ -3231,42 +3231,42 @@ class Rs extends ur {
3231
3231
  switch (t.type) {
3232
3232
  case "dev-v1":
3233
3233
  try {
3234
- const o = await yt(t.folder);
3235
- return o === t.mtime ? void 0 : { ...t, mtime: o };
3236
- } catch (o) {
3237
- this.logger.warn(o);
3234
+ const s = await Pt(t.folder);
3235
+ return s === t.mtime ? void 0 : { ...t, mtime: s };
3236
+ } catch (s) {
3237
+ this.logger.warn(s);
3238
3238
  return;
3239
3239
  }
3240
3240
  case "dev-v2":
3241
3241
  try {
3242
- const o = await dt(t.folder, this.logger);
3243
- if (o === void 0) return;
3244
- const i = await Ie(o);
3245
- return i === t.mtime ? void 0 : { ...t, mtime: i };
3246
- } catch (o) {
3247
- this.logger.warn(o);
3242
+ const s = await mt(t.folder, this.logger);
3243
+ if (s === void 0) return;
3244
+ const n = await Je(s);
3245
+ return n === t.mtime ? void 0 : { ...t, mtime: n };
3246
+ } catch (s) {
3247
+ this.logger.warn(s);
3248
3248
  return;
3249
3249
  }
3250
3250
  case "from-registry-v2":
3251
3251
  try {
3252
- const o = this.registryProvider.getRegistry(t.registryUrl), i = (r = await o.getOverviewForSpec(t.id)) == null ? void 0 : r.spec;
3253
- if ((i == null ? void 0 : i.type) !== "from-registry-v2") throw new Error("Unexpected");
3254
- return me(i.id, t.id) ? void 0 : ((async () => {
3252
+ const s = this.registryProvider.getRegistry(t.registryUrl), n = (r = await s.getOverviewForSpec(t.id)) == null ? void 0 : r.spec;
3253
+ if ((n == null ? void 0 : n.type) !== "from-registry-v2") throw new Error("Unexpected");
3254
+ return ve(n.id, t.id) ? void 0 : ((async () => {
3255
3255
  try {
3256
- await o.getComponents(i.id);
3257
- } catch (n) {
3258
- this.logger.warn(n);
3256
+ await s.getComponents(n.id);
3257
+ } catch (i) {
3258
+ this.logger.warn(i);
3259
3259
  }
3260
- })(), i);
3261
- } catch (o) {
3262
- this.logger.warn(o);
3260
+ })(), n);
3261
+ } catch (s) {
3262
+ this.logger.warn(s);
3263
3263
  return;
3264
3264
  }
3265
3265
  default:
3266
3266
  return;
3267
3267
  }
3268
- } catch (o) {
3269
- this.logger.warn(o);
3268
+ } catch (s) {
3269
+ this.logger.warn(s);
3270
3270
  return;
3271
3271
  }
3272
3272
  }
@@ -3275,9 +3275,9 @@ class Rs extends ur {
3275
3275
  if (t === void 0 || r === void 0 || t.type !== r.type) return !1;
3276
3276
  switch (t.type) {
3277
3277
  case "from-registry-v1":
3278
- return r.type !== "from-registry-v1" ? !1 : t.registryUrl === r.registryUrl && me(t.id, r.id);
3278
+ return r.type !== "from-registry-v1" ? !1 : t.registryUrl === r.registryUrl && ve(t.id, r.id);
3279
3279
  case "from-registry-v2":
3280
- return r.type !== "from-registry-v2" ? !1 : t.registryUrl === r.registryUrl && me(t.id, r.id);
3280
+ return r.type !== "from-registry-v2" ? !1 : t.registryUrl === r.registryUrl && ve(t.id, r.id);
3281
3281
  case "dev-v1":
3282
3282
  return r.type !== "dev-v1" ? !1 : t.folder === r.folder && t.mtime === r.mtime;
3283
3283
  case "dev-v2":
@@ -3287,7 +3287,7 @@ class Rs extends ur {
3287
3287
  }
3288
3288
  }
3289
3289
  }
3290
- class at {
3290
+ class pt {
3291
3291
  constructor() {
3292
3292
  d(this, "resources", /* @__PURE__ */ new Map());
3293
3293
  }
@@ -3304,12 +3304,12 @@ class at {
3304
3304
  const t = this.calculateParamsKey(e);
3305
3305
  let r = this.resources.get(t);
3306
3306
  r === void 0 && (r = { refCount: 0, resource: this.createNewResource(e) }, this.resources.set(t, r)), r.refCount++;
3307
- let o = !1;
3307
+ let s = !1;
3308
3308
  return {
3309
3309
  resource: r.resource,
3310
3310
  key: t,
3311
3311
  unref: () => {
3312
- o || (r.refCount--, o = !0, this.check(t));
3312
+ s || (r.refCount--, s = !0, this.check(t));
3313
3313
  }
3314
3314
  };
3315
3315
  }
@@ -3322,12 +3322,12 @@ class at {
3322
3322
  return (t = this.resources.get(e)) == null ? void 0 : t.resource;
3323
3323
  }
3324
3324
  }
3325
- function ct(s) {
3326
- return String(s.id);
3325
+ function gt(o) {
3326
+ return String(o.id);
3327
3327
  }
3328
- class Os {
3328
+ class Ao {
3329
3329
  constructor(e, t, r) {
3330
- d(this, "pFrame", new Fr());
3330
+ d(this, "pFrame", new jr());
3331
3331
  d(this, "blobIdToResource", /* @__PURE__ */ new Map());
3332
3332
  d(this, "blobHandleComputables", /* @__PURE__ */ new Map());
3333
3333
  d(this, "preloadBlob", async (e) => {
@@ -3343,14 +3343,14 @@ class Os {
3343
3343
  return await this.blobContentCache.forceFetch(r);
3344
3344
  });
3345
3345
  this.blobDriver = e, this.blobContentCache = t, this.columns = r, this.pFrame.setDataSource(this);
3346
- for (const o of r) {
3347
- for (const n of Bo(o.data)) this.blobIdToResource.set(ct(n), n);
3348
- const i = Ro(o.data, ct);
3346
+ for (const s of r) {
3347
+ for (const i of js(s.data)) this.blobIdToResource.set(gt(i), i);
3348
+ const n = Ts(s.data, gt);
3349
3349
  try {
3350
- this.pFrame.addColumnSpec(o.id, o.spec), this.pFrame.setColumnData(o.id, i);
3351
- } catch (n) {
3350
+ this.pFrame.addColumnSpec(s.id, s.spec), this.pFrame.setColumnData(s.id, n);
3351
+ } catch (i) {
3352
3352
  throw new Error(
3353
- `Adding column ${o.id} to PFrame failed: ${n}; Spec: ${o.spec}, DataInfo: ${i}.`
3353
+ `Adding column ${s.id} to PFrame failed: ${i}; Spec: ${s.spec}, DataInfo: ${n}.`
3354
3354
  );
3355
3355
  }
3356
3356
  }
@@ -3367,7 +3367,7 @@ class Os {
3367
3367
  this.pFrame.dispose();
3368
3368
  }
3369
3369
  }
3370
- class Ds {
3370
+ class Io {
3371
3371
  constructor(e) {
3372
3372
  d(this, "pFrames");
3373
3373
  d(this, "pTables");
@@ -3375,37 +3375,37 @@ class Ds {
3375
3375
  /** Limits concurrent requests to PFrame API to prevent deadlock with Node's IO threads */
3376
3376
  d(this, "concurrencyLimiter");
3377
3377
  this.blobDriver = e;
3378
- const t = new Br({
3378
+ const t = new Tr({
3379
3379
  maxSize: 1e9,
3380
3380
  // 1Gb
3381
- fetchMethod: async (o) => await ht.readFile(o),
3382
- sizeCalculation: (o) => o.length
3383
- }), r = new Xt(1);
3384
- this.blobContentCache = t, this.concurrencyLimiter = r, this.pFrames = new class extends at {
3385
- constructor(o) {
3386
- super(), this.blobDriver = o;
3381
+ fetchMethod: async (s) => await yt.readFile(s),
3382
+ sizeCalculation: (s) => s.length
3383
+ }), r = new nr(1);
3384
+ this.blobContentCache = t, this.concurrencyLimiter = r, this.pFrames = new class extends pt {
3385
+ constructor(s) {
3386
+ super(), this.blobDriver = s;
3387
3387
  }
3388
- createNewResource(o) {
3389
- return new Os(this.blobDriver, t, o);
3388
+ createNewResource(s) {
3389
+ return new Ao(this.blobDriver, t, s);
3390
3390
  }
3391
- calculateParamsKey(o) {
3392
- return js(o);
3391
+ calculateParamsKey(s) {
3392
+ return No(s);
3393
3393
  }
3394
- }(this.blobDriver), this.pTables = new class extends at {
3395
- constructor(o) {
3396
- super(), this.pFrames = o;
3394
+ }(this.blobDriver), this.pTables = new class extends pt {
3395
+ constructor(s) {
3396
+ super(), this.pFrames = s;
3397
3397
  }
3398
- async createNewResource(o) {
3399
- const i = this.pFrames.getByKey(o.pFrameHandle), n = await r.run(
3400
- async () => await i.pFrame.createTable({
3401
- src: Z(o.def.src),
3402
- filters: o.def.filters
3398
+ async createNewResource(s) {
3399
+ const n = this.pFrames.getByKey(s.pFrameHandle), i = await r.run(
3400
+ async () => await n.pFrame.createTable({
3401
+ src: X(s.def.src),
3402
+ filters: s.def.filters
3403
3403
  })
3404
3404
  );
3405
- return o.def.sorting.length !== 0 ? n.sort(o.def.sorting) : n;
3405
+ return s.def.sorting.length !== 0 ? i.sort(s.def.sorting) : i;
3406
3406
  }
3407
- calculateParamsKey(o) {
3408
- return xs(o);
3407
+ calculateParamsKey(s) {
3408
+ return Vo(s);
3409
3409
  }
3410
3410
  }(this.pFrames);
3411
3411
  }
@@ -3413,12 +3413,12 @@ class Ds {
3413
3413
  // Internal / Config API Methods
3414
3414
  //
3415
3415
  createPFrame(e, t) {
3416
- const r = e.map((i) => Q(i, (n) => Ao(n))), o = this.pFrames.acquire(r);
3417
- return t.addOnDestroy(o.unref), o.key;
3416
+ const r = e.map((n) => Z(n, (i) => Ls(i))), s = this.pFrames.acquire(r);
3417
+ return t.addOnDestroy(s.unref), s.key;
3418
3418
  }
3419
3419
  createPTable(e, t) {
3420
- const r = this.createPFrame(Es(e.src), t), o = ut(e, (n) => n.id), i = this.pTables.acquire({ def: o, pFrameHandle: r });
3421
- return t.addOnDestroy(i.unref), i.key;
3420
+ const r = this.createPFrame(Lo(e.src), t), s = ht(e, (i) => i.id), n = this.pTables.acquire({ def: s, pFrameHandle: r });
3421
+ return t.addOnDestroy(n.unref), n.key;
3422
3422
  }
3423
3423
  //
3424
3424
  // PFrame istance methods
@@ -3431,7 +3431,7 @@ class Ds {
3431
3431
  return {
3432
3432
  hits: (await this.concurrencyLimiter.run(
3433
3433
  async () => await this.pFrames.getByKey(e).pFrame.findColumns(r)
3434
- )).hits.map((o) => o.hit)
3434
+ )).hits.map((s) => s.hit)
3435
3435
  };
3436
3436
  }
3437
3437
  async getColumnSpec(e, t) {
@@ -3447,22 +3447,22 @@ class Ds {
3447
3447
  async calculateTableData(e, t) {
3448
3448
  let r = await this.concurrencyLimiter.run(
3449
3449
  async () => await this.pFrames.getByKey(e).pFrame.createTable({
3450
- src: Z(t.src),
3450
+ src: X(t.src),
3451
3451
  filters: t.filters
3452
3452
  })
3453
3453
  );
3454
3454
  if (t.sorting.length > 0) {
3455
- const n = await this.concurrencyLimiter.run(
3455
+ const i = await this.concurrencyLimiter.run(
3456
3456
  async () => await r.sort(t.sorting)
3457
3457
  );
3458
- r.dispose(), r = n;
3458
+ r.dispose(), r = i;
3459
3459
  }
3460
- const o = r.getSpec(), i = await this.concurrencyLimiter.run(
3461
- async () => await r.getData([...o.keys()])
3460
+ const s = r.getSpec(), n = await this.concurrencyLimiter.run(
3461
+ async () => await r.getData([...s.keys()])
3462
3462
  );
3463
- return r.dispose(), o.map((n, a) => ({
3464
- spec: n,
3465
- data: i[a]
3463
+ return r.dispose(), s.map((i, a) => ({
3464
+ spec: i,
3465
+ data: n[a]
3466
3466
  }));
3467
3467
  }
3468
3468
  async getUniqueValues(e, t) {
@@ -3480,105 +3480,105 @@ class Ds {
3480
3480
  return (await this.pTables.getByKey(e)).getSpec();
3481
3481
  }
3482
3482
  async getData(e, t, r) {
3483
- const o = await this.pTables.getByKey(e);
3483
+ const s = await this.pTables.getByKey(e);
3484
3484
  return await this.concurrencyLimiter.run(
3485
- async () => await o.getData(t, r)
3485
+ async () => await s.getData(t, r)
3486
3486
  );
3487
3487
  }
3488
3488
  }
3489
- function Z(s) {
3490
- switch (s.type) {
3489
+ function X(o) {
3490
+ switch (o.type) {
3491
3491
  case "column":
3492
3492
  return {
3493
3493
  type: "column",
3494
- columnId: s.column,
3494
+ columnId: o.column,
3495
3495
  qualifications: []
3496
3496
  };
3497
3497
  case "inner":
3498
3498
  case "full":
3499
3499
  return {
3500
- type: s.type,
3501
- entries: s.entries.map((e) => Z(e))
3500
+ type: o.type,
3501
+ entries: o.entries.map((e) => X(e))
3502
3502
  };
3503
3503
  case "outer":
3504
3504
  return {
3505
3505
  type: "outer",
3506
- primary: Z(s.primary),
3507
- secondary: s.secondary.map((e) => Z(e))
3506
+ primary: X(o.primary),
3507
+ secondary: o.secondary.map((e) => X(e))
3508
3508
  };
3509
3509
  default:
3510
- D(s);
3510
+ D(o);
3511
3511
  }
3512
3512
  }
3513
- function xs(s) {
3513
+ function Vo(o) {
3514
3514
  const e = he("sha256");
3515
- return e.update(s.pFrameHandle), e.update(Ee(s.def)), e.digest().toString("hex");
3515
+ return e.update(o.pFrameHandle), e.update(Ve(o.def)), e.digest().toString("hex");
3516
3516
  }
3517
- function js(s) {
3518
- const e = s.map((o) => o.id).sort(), t = he("sha256");
3517
+ function No(o) {
3518
+ const e = o.map((s) => s.id).sort(), t = he("sha256");
3519
3519
  let r = "";
3520
- for (const o of e)
3521
- r !== o && (t.update(o), r = o);
3520
+ for (const s of e)
3521
+ r !== s && (t.update(s), r = s);
3522
3522
  return t.digest().toString("hex");
3523
3523
  }
3524
- function Es(s) {
3524
+ function Lo(o) {
3525
3525
  const e = /* @__PURE__ */ new Map();
3526
- return ae(s, e), [...e.values()];
3526
+ return ce(o, e), [...e.values()];
3527
3527
  }
3528
- function ae(s, e) {
3529
- switch (s.type) {
3528
+ function ce(o, e) {
3529
+ switch (o.type) {
3530
3530
  case "column":
3531
- e.set(s.column.id, s.column);
3531
+ e.set(o.column.id, o.column);
3532
3532
  return;
3533
3533
  case "full":
3534
3534
  case "inner":
3535
- for (const t of s.entries) ae(t, e);
3535
+ for (const t of o.entries) ce(t, e);
3536
3536
  return;
3537
3537
  case "outer":
3538
- ae(s.primary, e);
3539
- for (const t of s.secondary) ae(t, e);
3538
+ ce(o.primary, e);
3539
+ for (const t of o.secondary) ce(t, e);
3540
3540
  return;
3541
3541
  default:
3542
- D(s);
3542
+ D(o);
3543
3543
  }
3544
3544
  }
3545
- async function As(s, e, t) {
3545
+ async function Jo(o, e, t) {
3546
3546
  const r = {
3547
- ...Jt,
3548
- ...Kt(e),
3547
+ ...Ht,
3548
+ ..._t(e),
3549
3549
  ...t
3550
- }, o = new pt(r.localSecret), i = fr(r.logger, s, r.localProjections), n = mr(s, r.logger), a = vr(s, r.logger), c = yr(s, r.logger), u = new br(
3550
+ }, s = new vt(r.localSecret), n = Sr(r.logger, o, r.localProjections), i = kr(o, r.logger), a = Cr(o, r.logger), c = Pr(o, r.logger), u = new Fr(
3551
3551
  r.logger,
3552
- i,
3553
3552
  n,
3553
+ i,
3554
3554
  r.blobDownloadPath,
3555
- o,
3555
+ s,
3556
3556
  r.blobDriverOps
3557
- ), l = new wr(
3557
+ ), l = new Rr(
3558
3558
  r.logger,
3559
- o,
3559
+ s,
3560
3560
  a,
3561
3561
  c,
3562
3562
  r.uploadDriverOps
3563
- ), p = new Sr(r.logger, n, r.logStreamDriverOps), h = new kr(r.logger, p, u), f = await Cr.init(
3563
+ ), p = new Br(r.logger, i, r.logStreamDriverOps), g = new Or(r.logger, p, u), m = await Dr.init(
3564
3564
  r.logger,
3565
- s,
3566
3565
  o,
3566
+ s,
3567
3567
  r.localProjections,
3568
3568
  r.openFileDialogCallback,
3569
3569
  r.virtualLocalStoragesOverride
3570
- ), b = new Ds(u);
3570
+ ), h = new Io(u);
3571
3571
  return {
3572
3572
  blobDriver: u,
3573
- logDriver: h,
3574
- lsDriver: f,
3575
- signer: o,
3573
+ logDriver: g,
3574
+ lsDriver: m,
3575
+ signer: s,
3576
3576
  uploadDriver: l,
3577
- pFrameDriver: b
3577
+ pFrameDriver: h
3578
3578
  };
3579
3579
  }
3580
- class Mt {
3581
- constructor(e, t, r, o, i, n, a, c) {
3580
+ class Wt {
3581
+ constructor(e, t, r, s, n, i, a, c) {
3582
3582
  d(this, "pl");
3583
3583
  /** Contains a reactive list of projects along with their meta information. */
3584
3584
  d(this, "projectList");
@@ -3586,7 +3586,7 @@ class Mt {
3586
3586
  // Projects
3587
3587
  //
3588
3588
  d(this, "openedProjectsByRid", /* @__PURE__ */ new Map());
3589
- this.env = e, this.driverKit = t, this.signer = r, this.projectListResourceId = o, this.openedProjectsList = i, this.projectListTree = n, this.blockRegistryProvider = a, this.projectList = c, this.pl = this.env.pl;
3589
+ this.env = e, this.driverKit = t, this.signer = r, this.projectListResourceId = s, this.openedProjectsList = n, this.projectListTree = i, this.blockRegistryProvider = a, this.projectList = c, this.pl = this.env.pl;
3590
3590
  }
3591
3591
  /** Returns extended API driver kit used internally by middle layer. */
3592
3592
  get internalDriverKit() {
@@ -3596,17 +3596,17 @@ class Mt {
3596
3596
  // Project List Manipulation
3597
3597
  //
3598
3598
  /** Creates a project with initial state and adds it to project list. */
3599
- async createProject(e, t = X()) {
3600
- const r = await this.pl.withWriteTx("MLCreateProject", async (o) => {
3601
- const i = await Fo(o, e);
3602
- return o.createField(S(this.projectListResourceId, t), "Dynamic", i), await o.commit(), await ar(i);
3599
+ async createProject(e, t = ee()) {
3600
+ const r = await this.pl.withWriteTx("MLCreateProject", async (s) => {
3601
+ const n = await xs(s, e);
3602
+ return s.createField(S(this.projectListResourceId, t), "Dynamic", n), await s.commit(), await gr(n);
3603
3603
  });
3604
3604
  return await this.projectListTree.refreshState(), r;
3605
3605
  }
3606
3606
  /** Updates project metadata */
3607
3607
  async setProjectMeta(e, t, r) {
3608
- await V(this.pl, e, r, async (o) => {
3609
- o.setMeta(t);
3608
+ await V(this.pl, e, r, async (s) => {
3609
+ s.setMeta(t);
3610
3610
  }), await this.projectListTree.refreshState();
3611
3611
  }
3612
3612
  /** Permanently deletes project from the project list, this will result in
@@ -3619,7 +3619,7 @@ class Mt {
3619
3619
  async projectIdToResourceId(e) {
3620
3620
  return await this.pl.withReadTx("Project id to resource id", async (t) => {
3621
3621
  const r = (await t.getField(S(this.projectListResourceId, e))).value;
3622
- if (ce(r)) throw new Error("Unexpected project list structure.");
3622
+ if (ue(r)) throw new Error("Unexpected project list structure.");
3623
3623
  return r;
3624
3624
  });
3625
3625
  }
@@ -3630,7 +3630,7 @@ class Mt {
3630
3630
  async openProject(e) {
3631
3631
  const t = await this.ensureProjectRid(e);
3632
3632
  if (this.openedProjectsByRid.has(t)) throw new Error(`Project ${t} already opened`);
3633
- this.openedProjectsByRid.set(t, await Ke.init(this.env, t)), this.openedProjectsList.setValue([...this.openedProjectsByRid.keys()]);
3633
+ this.openedProjectsByRid.set(t, await Ge.init(this.env, t)), this.openedProjectsList.setValue([...this.openedProjectsByRid.keys()]);
3634
3634
  }
3635
3635
  /** Closes the project, and deallocate all corresponding resources. */
3636
3636
  async closeProject(e) {
@@ -3658,91 +3658,226 @@ class Mt {
3658
3658
  /** Generates sufficiently random string to be used as local secret for the
3659
3659
  * middle layer */
3660
3660
  static generateLocalSecret() {
3661
- return pt.generateSecret();
3661
+ return vt.generateSecret();
3662
3662
  }
3663
3663
  /** Initialize middle layer */
3664
3664
  static async init(e, t, r) {
3665
- const o = {
3666
- ...Cs,
3667
- ...Ps(t),
3665
+ const s = {
3666
+ ...Do,
3667
+ ...xo(t),
3668
3668
  ...r
3669
3669
  };
3670
- process.env.MI_LOG_TREE_STAT && (o.defaultTreeOptions.logStat = process.env.MI_LOG_TREE_STAT === "cumulative" ? "cumulative" : "per-request");
3671
- const i = await e.withWriteTx("MLInitialization", async (C) => {
3672
- const I = S(C.clientRoot, _r);
3670
+ process.env.MI_LOG_TREE_STAT && (s.defaultTreeOptions.logStat = process.env.MI_LOG_TREE_STAT === "cumulative" ? "cumulative" : "per-request");
3671
+ const n = await e.withWriteTx("MLInitialization", async (C) => {
3672
+ const I = S(C.clientRoot, Zr);
3673
3673
  C.createField(I, "Dynamic");
3674
- const $ = await C.getField(I);
3675
- if (ce($.value)) {
3676
- const K = C.createEphemeral(St);
3677
- return C.lock(K), C.setField(I, K), await C.commit(), await K.globalId;
3674
+ const G = await C.getField(I);
3675
+ if (ue(G.value)) {
3676
+ const U = C.createEphemeral(Bt);
3677
+ return C.lock(U), C.setField(I, U), await C.commit(), await U.globalId;
3678
3678
  } else
3679
- return $.value;
3680
- }), n = o.logger, a = await As(e, t, o), c = new Wt(e.httpDispatcher, {
3679
+ return G.value;
3680
+ }), i = s.logger, a = await Jo(e, t, s), c = new Xt(e.httpDispatcher, {
3681
3681
  minTimeout: 250,
3682
3682
  maxRetries: 4
3683
- }), u = new Tr(c), l = new yo(
3683
+ }), u = new Mr(c), l = new Cs(
3684
3684
  u,
3685
3685
  a.signer,
3686
3686
  c
3687
- ), p = new Pr(
3688
- n,
3687
+ ), p = new xr(
3688
+ i,
3689
3689
  e.httpDispatcher,
3690
- o.frontendDownloadPath
3691
- ), h = {
3690
+ s.frontendDownloadPath
3691
+ ), g = {
3692
3692
  pl: e,
3693
3693
  signer: a.signer,
3694
- logger: n,
3694
+ logger: i,
3695
3695
  httpDispatcher: e.httpDispatcher,
3696
3696
  retryHttpDispatcher: c,
3697
- ops: o,
3697
+ ops: s,
3698
3698
  bpPreparer: l,
3699
3699
  frontendDownloadDriver: p,
3700
3700
  driverKit: a,
3701
- blockUpdateWatcher: new Rs(u, n, {
3702
- minDelay: o.devBlockUpdateRecheckInterval,
3701
+ blockUpdateWatcher: new Eo(u, i, {
3702
+ minDelay: s.devBlockUpdateRecheckInterval,
3703
3703
  http: c
3704
3704
  }),
3705
- quickJs: await hr()
3706
- }, f = new lr([]), b = await zr(e, i, f, h);
3707
- return new Mt(
3708
- h,
3705
+ quickJs: await wr()
3706
+ }, m = new vr([]), h = await es(e, n, m, g);
3707
+ return new Wt(
3708
+ g,
3709
3709
  a,
3710
3710
  a.signer,
3711
- i,
3712
- f,
3713
- b.tree,
3711
+ n,
3712
+ m,
3713
+ h.tree,
3714
3714
  u,
3715
- b.computable
3715
+ h.computable
3716
3716
  );
3717
3717
  }
3718
3718
  }
3719
+ async function fn(o, e = {}) {
3720
+ const t = {
3721
+ pingCheckDurationMs: 1e4,
3722
+ pingTimeoutMs: 3e3,
3723
+ maxPingsPerSecond: 50,
3724
+ httpTimeoutMs: 3e3,
3725
+ blockRegistryDurationMs: 5e3,
3726
+ maxRegistryChecksPerSecond: 1,
3727
+ blockRegistryUrl: "https://blocks.pl-open.science/v2/overview.json",
3728
+ autoUpdateCdnDurationMs: 5e3,
3729
+ maxAutoUpdateCdnChecksPerSecond: 1,
3730
+ autoUpdateCdnUrl: "https://cdn.platforma.bio/software/platforma-desktop-v2/windows/amd64/latest.yml",
3731
+ ...e
3732
+ }, r = {
3733
+ plPings: [],
3734
+ blockRegistryChecks: [],
3735
+ autoUpdateCdnChecks: []
3736
+ }, s = hr(
3737
+ o,
3738
+ { defaultRequestTimeout: t.pingTimeoutMs }
3739
+ );
3740
+ r.plPings = await ke(
3741
+ t.pingCheckDurationMs,
3742
+ t.maxPingsPerSecond,
3743
+ async () => {
3744
+ const c = await new Ze(s).ping();
3745
+ return JSON.stringify(c).slice(0, 100) + "...";
3746
+ }
3747
+ );
3748
+ const i = new Ze(s).ll.httpDispatcher;
3749
+ return r.blockRegistryChecks = await ke(
3750
+ t.blockRegistryDurationMs,
3751
+ t.maxRegistryChecksPerSecond,
3752
+ async () => {
3753
+ const { body: a, statusCode: c } = await M(t.blockRegistryUrl, {
3754
+ dispatcher: i,
3755
+ bodyTimeout: t.httpTimeoutMs
3756
+ }), u = await a.text();
3757
+ return {
3758
+ statusCode: c,
3759
+ beginningOfBody: u.slice(0, 100) + "..."
3760
+ };
3761
+ }
3762
+ ), r.autoUpdateCdnChecks = await ke(
3763
+ t.autoUpdateCdnDurationMs,
3764
+ t.maxAutoUpdateCdnChecksPerSecond,
3765
+ async () => {
3766
+ const { body: a, statusCode: c } = await M(t.autoUpdateCdnUrl, {
3767
+ dispatcher: i,
3768
+ bodyTimeout: t.httpTimeoutMs
3769
+ }), u = await a.text();
3770
+ return {
3771
+ statusCode: c,
3772
+ beginningOfBody: u.slice(0, 100) + "..."
3773
+ };
3774
+ }
3775
+ ), Mo(r, o, t);
3776
+ }
3777
+ async function ke(o, e, t) {
3778
+ const r = Ae(), s = [];
3779
+ for (; Q(r) < o; ) {
3780
+ const n = Ae();
3781
+ try {
3782
+ const i = await t();
3783
+ s.push({
3784
+ elapsedMs: Q(n),
3785
+ response: { ok: !0, value: i }
3786
+ });
3787
+ } catch (i) {
3788
+ s.push({
3789
+ elapsedMs: Q(n),
3790
+ response: { ok: !1, error: i }
3791
+ });
3792
+ }
3793
+ Q(n) < 1e3 / e && await kt(1e3 / e - Q(n));
3794
+ }
3795
+ return s;
3796
+ }
3797
+ function Mo(o, e, t) {
3798
+ const r = o.plPings.filter((h) => h.response.ok), s = o.plPings.filter((h) => !h.response.ok), { mean: n, median: i } = Ce(o.plPings), a = [...new Set(r.map((h) => JSON.stringify(h.response.value)))], c = o.blockRegistryChecks.filter((h) => h.response.ok).length, { mean: u, median: l } = Ce(o.blockRegistryChecks), p = o.autoUpdateCdnChecks.filter((h) => h.response.ok).length, { mean: g, median: m } = Ce(o.autoUpdateCdnChecks);
3799
+ return `
3800
+ Network report:
3801
+ pl endpoint: ${e};
3802
+ options: ${JSON.stringify(t, null, 2)}.
3803
+
3804
+ Platforma pings:
3805
+ total: ${o.plPings.length};
3806
+ successes: ${r.length};
3807
+ errors: ${o.plPings.length - r.length};
3808
+ mean in ms: ${n};
3809
+ median in ms: ${i};
3810
+
3811
+ Block registry responses:
3812
+ total: ${o.blockRegistryChecks.length};
3813
+ successes: ${c};
3814
+ errors: ${o.blockRegistryChecks.length - c};
3815
+ mean in ms: ${u};
3816
+ median in ms: ${l};
3817
+
3818
+ Auto-update CDN responses:
3819
+ total: ${o.autoUpdateCdnChecks.length};
3820
+ successes: ${p};
3821
+ errors: ${o.autoUpdateCdnChecks.length - p};
3822
+ mean in ms: ${g};
3823
+ median in ms: ${m};
3824
+
3825
+ Block registry dumps:
3826
+ ${JSON.stringify(o.blockRegistryChecks, null, 2)}
3827
+
3828
+ Auto-update CDN dumps:
3829
+ ${JSON.stringify(o.autoUpdateCdnChecks, null, 2)}
3830
+
3831
+ Platforma pings error dumps:
3832
+ ${JSON.stringify(s, null, 2)}
3833
+
3834
+ Platforma pings success dump examples:
3835
+ ${JSON.stringify(a, null, 2)}
3836
+ `;
3837
+ }
3838
+ function Ce(o) {
3839
+ const e = o.map((s) => s.elapsedMs), t = e.reduce((s, n) => s + n) / e.length;
3840
+ let r;
3841
+ if (e.length > 0) {
3842
+ const s = Math.floor(e.length / 2);
3843
+ r = e.length % 2 ? e[s] : (e[s - 1] + e[s]) / 2;
3844
+ }
3845
+ return { mean: t, median: r };
3846
+ }
3847
+ function Ae() {
3848
+ return Date.now();
3849
+ }
3850
+ function Q(o) {
3851
+ return Ae() - o;
3852
+ }
3719
3853
  export {
3720
- oi as BlockPackRegistry,
3721
- si as CentralBlockRegistry,
3722
- Kt as DefaultDriverKitOpsPaths,
3723
- Jt as DefaultDriverKitOpsSettings,
3724
- Ps as DefaultMiddleLayerOpsPaths,
3725
- Cs as DefaultMiddleLayerOpsSettings,
3726
- Pt as FrontendFromFolderResourceType,
3727
- Ct as FrontendFromUrlResourceType,
3728
- Mt as MiddleLayer,
3729
- Ke as Project,
3730
- so as TengoTemplateGet,
3731
- io as TengoTemplateGetRegistry,
3732
- ao as TengoTemplateGetTemplate,
3733
- no as TengoTemplateGetTemplateURI,
3734
- co as TengoTemplatePack,
3735
- uo as TengoTemplatePackConvert,
3736
- po as TengoTemplatePackConvertTemplate,
3737
- lo as TengoTemplatePackConvertTemplatePack,
3738
- ni as V1CentralDevSnapshotRegistry,
3739
- ii as V1CentralRegistry,
3740
- Tr as V2RegistryProvider,
3741
- kt as createRenderTemplate,
3742
- yt as getDevV1PacketMtime,
3743
- Ie as getDevV2PacketMtime,
3744
- As as initDriverKit,
3745
- Le as loadTemplate,
3746
- ho as prepareTemplateSpec
3854
+ dn as BlockPackRegistry,
3855
+ pn as CentralBlockRegistry,
3856
+ _t as DefaultDriverKitOpsPaths,
3857
+ Ht as DefaultDriverKitOpsSettings,
3858
+ xo as DefaultMiddleLayerOpsPaths,
3859
+ Do as DefaultMiddleLayerOpsSettings,
3860
+ xt as FrontendFromFolderResourceType,
3861
+ Dt as FrontendFromUrlResourceType,
3862
+ Wt as MiddleLayer,
3863
+ Ge as Project,
3864
+ ls as TengoTemplateGet,
3865
+ ds as TengoTemplateGetRegistry,
3866
+ gs as TengoTemplateGetTemplate,
3867
+ ps as TengoTemplateGetTemplateURI,
3868
+ hs as TengoTemplatePack,
3869
+ fs as TengoTemplatePackConvert,
3870
+ vs as TengoTemplatePackConvertTemplate,
3871
+ ms as TengoTemplatePackConvertTemplatePack,
3872
+ hn as V1CentralDevSnapshotRegistry,
3873
+ gn as V1CentralRegistry,
3874
+ Mr as V2RegistryProvider,
3875
+ fn as checkNetwork,
3876
+ Ot as createRenderTemplate,
3877
+ Pt as getDevV1PacketMtime,
3878
+ Je as getDevV2PacketMtime,
3879
+ Jo as initDriverKit,
3880
+ Ue as loadTemplate,
3881
+ ys as prepareTemplateSpec
3747
3882
  };
3748
3883
  //# sourceMappingURL=index.mjs.map