@blue-labs/document-processor 2.0.0-rc.3 → 2.0.0-rc.5

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.js CHANGED
@@ -1,39 +1,39 @@
1
1
  import { blueIds as m, ContractSchema as Xe, ChannelSchema as et, HandlerSchema as tt, MarkerSchema as nt, DocumentUpdateChannelSchema as rt, EmbeddedNodeChannelSchema as it, LifecycleEventChannelSchema as st, TriggeredEventChannelSchema as ot, ChannelEventCheckpointSchema as at, ProcessingInitializedMarkerSchema as ct, ProcessEmbeddedSchema as lt, ProcessingTerminatedMarkerSchema as ut, repository as dt } from "@blue-repository/core";
2
2
  import { getQuickJS as ht } from "quickjs-emscripten";
3
- import { BlueNode as d, blueNodeField as z, withTypeBlueId as ft, Blue as pt, MergingProcessors as T } from "@blue-labs/language";
3
+ import { BlueNode as d, blueNodeField as z, withTypeBlueId as ft, BlueIdCalculator as pt, Blue as mt, MergingProcessors as R } from "@blue-labs/language";
4
4
  import he from "picomatch";
5
5
  import { z as S, ZodError as Pe } from "zod";
6
- import { TimelineChannelSchema as mt, OperationSchema as x, SequentialWorkflowSchema as gt, SequentialWorkflowOperationSchema as Et, TimelineEntrySchema as k, blueIds as R, TriggerEventSchema as fe, JavaScriptCodeSchema as pe, UpdateDocumentSchema as me, OperationRequestSchema as te, repository as yt } from "@blue-repository/conversation";
7
- import { MyOSTimelineChannelSchema as wt, blueIds as bt, MyOSTimelineEntrySchema as ge, repository as St } from "@blue-repository/myos";
6
+ import { TimelineChannelSchema as gt, OperationSchema as x, SequentialWorkflowSchema as Et, SequentialWorkflowOperationSchema as yt, TimelineEntrySchema as v, blueIds as T, TriggerEventSchema as fe, JavaScriptCodeSchema as pe, UpdateDocumentSchema as me, OperationRequestSchema as te, repository as wt } from "@blue-repository/conversation";
7
+ import { MyOSTimelineChannelSchema as bt, blueIds as St, MyOSTimelineEntrySchema as ge, repository as Ct } from "@blue-repository/myos";
8
8
  import { isNullable as ne } from "@blue-labs/shared-utils";
9
- function Ct(i) {
9
+ function It(i) {
10
10
  return { ok: !0, value: i };
11
11
  }
12
12
  function vt(i) {
13
13
  return { ok: !1, error: i };
14
14
  }
15
- function Yr(i) {
15
+ function Xr(i) {
16
16
  return i.ok;
17
17
  }
18
- function Zr(i) {
18
+ function ei(i) {
19
19
  return !i.ok;
20
20
  }
21
- function Xr(i, e) {
22
- return i.ok ? Ct(e(i.value)) : i;
21
+ function ti(i, e) {
22
+ return i.ok ? It(e(i.value)) : i;
23
23
  }
24
- function ei(i, e) {
24
+ function ni(i, e) {
25
25
  return i.ok ? i : vt(e(i.error));
26
26
  }
27
- function ti(i, e) {
27
+ function ri(i, e) {
28
28
  return i.ok ? e(i.value) : i;
29
29
  }
30
- function ni(i, e) {
30
+ function ii(i, e) {
31
31
  return i.ok ? i.value : e;
32
32
  }
33
- function ri(i, e) {
33
+ function si(i, e) {
34
34
  return i.ok ? i.value : e(i.error);
35
35
  }
36
- function ii(i, e) {
36
+ function oi(i, e) {
37
37
  return i.ok ? e.ok(i.value) : e.err(i.error);
38
38
  }
39
39
  const E = {
@@ -59,7 +59,7 @@ const E = {
59
59
  function kt(i) {
60
60
  return Object.freeze([...i]);
61
61
  }
62
- const It = {
62
+ const Tt = {
63
63
  of(i, e, t) {
64
64
  return {
65
65
  document: i,
@@ -78,20 +78,20 @@ const It = {
78
78
  failureReason: e ?? null
79
79
  };
80
80
  }
81
- }, Ne = It, Rt = [
81
+ }, Ne = Tt, Rt = [
82
82
  "embedded",
83
83
  "initialized",
84
84
  "terminated",
85
85
  "checkpoint"
86
- ], Tt = [
86
+ ], Pt = [
87
87
  m["Document Update Channel"],
88
88
  m["Triggered Event Channel"],
89
89
  m["Lifecycle Event Channel"],
90
90
  m["Embedded Node Channel"]
91
- ], Me = "embedded", Ae = "initialized", De = "terminated", I = "checkpoint", se = new Set(
91
+ ], Ae = "embedded", Me = "initialized", De = "terminated", k = "checkpoint", se = new Set(
92
92
  Rt
93
- ), Oe = new Set(Tt);
94
- function Pt(i) {
93
+ ), Oe = new Set(Pt);
94
+ function Nt(i) {
95
95
  return i != null && se.has(i);
96
96
  }
97
97
  function oe(i) {
@@ -99,34 +99,34 @@ function oe(i) {
99
99
  i
100
100
  );
101
101
  }
102
- const si = {
103
- KEY_EMBEDDED: Me,
104
- KEY_INITIALIZED: Ae,
102
+ const ai = {
103
+ KEY_EMBEDDED: Ae,
104
+ KEY_INITIALIZED: Me,
105
105
  KEY_TERMINATED: De,
106
- KEY_CHECKPOINT: I,
106
+ KEY_CHECKPOINT: k,
107
107
  RESERVED_CONTRACT_KEYS: se,
108
108
  PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: Oe,
109
- isReservedContractKey: Pt,
109
+ isReservedContractKey: Nt,
110
110
  isProcessorManagedChannelBlueId: oe
111
- }, D = "/contracts", re = `${D}/${Ae}`, Be = `${D}/${De}`, Nt = `${D}/${Me}`, Le = `${D}/${I}`, _e = "/lastEvents", $e = "/lastSignatures";
112
- function J(i) {
111
+ }, D = "/contracts", re = `${D}/${Me}`, Be = `${D}/${De}`, At = `${D}/${Ae}`, Le = `${D}/${k}`, _e = "/lastEvents", $e = "/lastSignatures";
112
+ function j(i) {
113
113
  return `${D}/${i}`;
114
114
  }
115
115
  function xe(i, e) {
116
- return `${J(i)}${_e}/${e}`;
116
+ return `${j(i)}${_e}/${e}`;
117
117
  }
118
118
  function Fe(i, e) {
119
- return `${J(i)}${$e}/${e}`;
119
+ return `${j(i)}${$e}/${e}`;
120
120
  }
121
- const oi = {
121
+ const ci = {
122
122
  RELATIVE_CONTRACTS: D,
123
123
  RELATIVE_INITIALIZED: re,
124
124
  RELATIVE_TERMINATED: Be,
125
- RELATIVE_EMBEDDED: Nt,
125
+ RELATIVE_EMBEDDED: At,
126
126
  RELATIVE_CHECKPOINT: Le,
127
127
  LAST_EVENTS_SUFFIX: _e,
128
128
  LAST_SIGNATURES_SUFFIX: $e,
129
- relativeContractsEntry: J,
129
+ relativeContractsEntry: j,
130
130
  relativeCheckpointLastEvent: xe,
131
131
  relativeCheckpointLastSignature: Fe
132
132
  };
@@ -151,7 +151,7 @@ function Ee(i) {
151
151
  e = e.substring(0, e.length - 1);
152
152
  return e;
153
153
  }
154
- function ai(i, e) {
154
+ function li(i, e) {
155
155
  const t = Ee(i), n = Ee(e);
156
156
  return t.length === 0 && n.length === 0 ? "/" : t.length === 0 ? `/${n}` : n.length === 0 ? `/${t}` : `/${t}/${n}`;
157
157
  }
@@ -168,11 +168,11 @@ function Mt(i, e) {
168
168
  const r = n.substring(t.length);
169
169
  return r.length === 0 ? "/" : r.startsWith("/") ? r : `/${r}`;
170
170
  }
171
- function At(i) {
171
+ function Dt(i) {
172
172
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
173
173
  }
174
174
  var Z, ye;
175
- function Dt() {
175
+ function Ot() {
176
176
  return ye || (ye = 1, Z = function i(e) {
177
177
  if (typeof e == "number" && isNaN(e))
178
178
  throw new Error("NaN is not allowed");
@@ -186,29 +186,29 @@ function Dt() {
186
186
  }, "")}}`;
187
187
  }), Z;
188
188
  }
189
- var Ot = Dt();
190
- const Bt = /* @__PURE__ */ At(Ot);
191
- function Lt(i, e) {
189
+ var Bt = Ot();
190
+ const Lt = /* @__PURE__ */ Dt(Bt);
191
+ function _t(i, e) {
192
192
  return i.nodeToJson(e, "official");
193
193
  }
194
- function _t(i, e) {
195
- const t = Lt(i, e);
196
- return Bt(t);
194
+ function $t(i, e) {
195
+ const t = _t(i, e);
196
+ return Lt(t);
197
197
  }
198
- function He(i, e) {
199
- return e ? _t(i, e) : null;
198
+ function Ve(i, e) {
199
+ return e ? $t(i, e) : null;
200
200
  }
201
201
  function we(i, e) {
202
- const t = He(i, e);
202
+ const t = Ve(i, e);
203
203
  return t == null ? 0 : new TextEncoder().encode(t).length;
204
204
  }
205
- function Ue(i) {
205
+ function He(i) {
206
206
  return typeof i == "object" && i !== null && !Array.isArray(i);
207
207
  }
208
- function $t(i) {
208
+ function xt(i) {
209
209
  return i.replace(/~1/g, "/").replace(/~0/g, "~");
210
210
  }
211
- function xt(i) {
211
+ function Ft(i) {
212
212
  if (i.length === 0 || !/^\d+$/.test(i))
213
213
  return !1;
214
214
  const e = Number(i);
@@ -217,7 +217,7 @@ function xt(i) {
217
217
  function _(i, e = !0) {
218
218
  if (Array.isArray(i))
219
219
  return e ? i.map((r) => _(r, !0)) : i.slice();
220
- if (!Ue(i))
220
+ if (!He(i))
221
221
  return i;
222
222
  if (Object.prototype.hasOwnProperty.call(i, "value")) {
223
223
  const r = i.value;
@@ -231,24 +231,24 @@ function _(i, e = !0) {
231
231
  n[r] = e ? _(s, !0) : s;
232
232
  return n;
233
233
  }
234
- function Ft(i, e) {
234
+ function zt(i, e) {
235
235
  if (e === "")
236
236
  return i;
237
237
  if (!e.startsWith("/"))
238
238
  throw new TypeError('JSON pointer must start with "/"');
239
- const t = e.split("/").slice(1).map((r) => $t(r));
239
+ const t = e.split("/").slice(1).map((r) => xt(r));
240
240
  let n = i;
241
241
  for (const r of t) {
242
242
  if (n == null)
243
243
  return;
244
244
  if (Array.isArray(n)) {
245
- if (!xt(r))
245
+ if (!Ft(r))
246
246
  return;
247
247
  const s = Number(r);
248
248
  n = n[s];
249
249
  continue;
250
250
  }
251
- if (Ue(n)) {
251
+ if (He(n)) {
252
252
  n = n[r];
253
253
  continue;
254
254
  }
@@ -256,14 +256,14 @@ function Ft(i, e) {
256
256
  }
257
257
  return n;
258
258
  }
259
- const zt = 500, Ht = 32 * 1024 * 1024;
259
+ const Vt = 500, Ht = 32 * 1024 * 1024;
260
260
  class ae {
261
261
  modulePromise;
262
262
  moduleInstance;
263
263
  async evaluate({
264
264
  code: e,
265
265
  bindings: t,
266
- timeout: n = zt,
266
+ timeout: n = Vt,
267
267
  memoryLimit: r = Ht
268
268
  }) {
269
269
  const o = (await this.ensureModule()).newRuntime();
@@ -273,17 +273,17 @@ class ae {
273
273
  const c = o.newContext();
274
274
  try {
275
275
  this.installConsole(c), this.installDeterministicGlobals(c), this.installCanonNamespace(c), this.installBindings(c, t);
276
- const l = this.wrapCode(e), u = c.evalCode(l), f = c.unwrapResult(u);
277
- let h = null;
276
+ const l = this.wrapCode(e), u = c.evalCode(l), h = c.unwrapResult(u);
277
+ let f = null;
278
278
  try {
279
- return h = await this.resolveHandle(
279
+ return f = await this.resolveHandle(
280
280
  c,
281
281
  o,
282
- f,
282
+ h,
283
283
  a
284
- ), c.dump(h);
284
+ ), c.dump(f);
285
285
  } finally {
286
- h ? h.dispose() : f.dispose();
286
+ f ? f.dispose() : h.dispose();
287
287
  }
288
288
  } finally {
289
289
  c.dispose(), o.removeInterruptHandler?.(), o.dispose();
@@ -333,7 +333,7 @@ ${e}
333
333
  const a = e.dump(s);
334
334
  if (typeof a != "string")
335
335
  throw new TypeError("canon.at pointer must be a string");
336
- const c = Ft(o, a);
336
+ const c = zt(o, a);
337
337
  return this.createReturnHandle(e, c);
338
338
  } catch (r) {
339
339
  const s = r instanceof Error ? r.message : String(r);
@@ -495,22 +495,22 @@ const be = 120;
495
495
  function Ut(i) {
496
496
  return i.length <= be ? i : `${i.slice(0, be - 3)}...`;
497
497
  }
498
- class Ve extends Error {
498
+ class Ue extends Error {
499
499
  constructor(e, t) {
500
500
  super(`Failed to evaluate code block: ${Ut(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
501
501
  }
502
502
  }
503
- const Ke = /^\$\{([\s\S]*)\}$/, Vt = /\$\{([\s\S]+?)\}/, We = /\$\{([\s\S]+?)\}/g;
503
+ const Ke = /^\$\{([\s\S]*)\}$/, Kt = /\$\{([\s\S]+?)\}/, We = /\$\{([\s\S]+?)\}/g;
504
504
  function W(i) {
505
505
  if (typeof i != "string" || !Ke.test(i))
506
506
  return !1;
507
507
  const e = i.indexOf("${"), t = i.lastIndexOf("${");
508
508
  return e === t;
509
509
  }
510
- function Kt(i) {
511
- return typeof i != "string" ? !1 : Ke.test(i) ? !0 : Vt.test(i);
512
- }
513
510
  function Wt(i) {
511
+ return typeof i != "string" ? !1 : Ke.test(i) ? !0 : Kt.test(i);
512
+ }
513
+ function Gt(i) {
514
514
  if (!W(i))
515
515
  throw new Error(`Invalid expression: ${i}`);
516
516
  return i.slice(2, -1);
@@ -520,10 +520,10 @@ async function Ge(i, e, t) {
520
520
  try {
521
521
  return await i.evaluate({ code: n, bindings: t });
522
522
  } catch (r) {
523
- throw new Ve(e, r);
523
+ throw new Ue(e, r);
524
524
  }
525
525
  }
526
- async function Gt(i, e, t) {
526
+ async function qt(i, e, t) {
527
527
  let n = "", r = 0;
528
528
  for (const s of e.matchAll(We)) {
529
529
  const o = s[0], a = s[1], c = s.index ?? 0;
@@ -565,21 +565,21 @@ async function G(i) {
565
565
  if (l !== void 0) {
566
566
  if (typeof l == "string" && r(a)) {
567
567
  if (W(l)) {
568
- const h = Wt(l);
569
- o.gasMeter().chargeExpression(h);
568
+ const f = Gt(l);
569
+ o.gasMeter().chargeExpression(f);
570
570
  const p = await Ge(
571
571
  e,
572
- h,
572
+ f,
573
573
  n
574
574
  );
575
575
  return o.blue.jsonValueToNode(p ?? null);
576
- } else if (Kt(l)) {
577
- const h = new RegExp(We);
576
+ } else if (Wt(l)) {
577
+ const f = new RegExp(We);
578
578
  let p = 0;
579
- for (h.lastIndex = 0; h.exec(l); )
579
+ for (f.lastIndex = 0; f.exec(l); )
580
580
  p += 1;
581
581
  o.gasMeter().chargeTemplate(p, l);
582
- const C = await Gt(
582
+ const C = await qt(
583
583
  e,
584
584
  l,
585
585
  n
@@ -591,7 +591,7 @@ async function G(i) {
591
591
  }
592
592
  const u = c.getItems?.();
593
593
  if (Array.isArray(u)) {
594
- const h = await Promise.all(
594
+ const f = await Promise.all(
595
595
  u.map(
596
596
  (p, C) => G({
597
597
  ...i,
@@ -600,20 +600,20 @@ async function G(i) {
600
600
  })
601
601
  )
602
602
  );
603
- return c.setItems(h), c;
603
+ return c.setItems(f), c;
604
604
  }
605
- const f = c.getProperties?.();
606
- if (f) {
607
- const h = {};
608
- for (const [p, C] of Object.entries(f)) {
605
+ const h = c.getProperties?.();
606
+ if (h) {
607
+ const f = {};
608
+ for (const [p, C] of Object.entries(h)) {
609
609
  const Y = a === "/" ? `/${p}` : `${a}/${p}`;
610
- h[p] = await G({
610
+ f[p] = await G({
611
611
  ...i,
612
612
  node: C,
613
613
  pointer: Y
614
614
  });
615
615
  }
616
- c.setProperties(h);
616
+ c.setProperties(f);
617
617
  }
618
618
  return c;
619
619
  }
@@ -622,12 +622,12 @@ const ce = Xe, O = et.merge(
622
622
  ).extend({
623
623
  path: S.string().optional(),
624
624
  definition: z().optional()
625
- }), je = tt.merge(ce), H = nt.merge(ce), qt = S.object({
625
+ }), Je = tt.merge(ce), V = nt.merge(ce), Jt = S.object({
626
626
  op: S.enum(["ADD", "REPLACE", "REMOVE"]),
627
627
  path: S.string(),
628
628
  val: z().optional()
629
- }), ci = ft("JsonPatch")(
630
- qt
629
+ }), ui = ft("JsonPatch")(
630
+ Jt
631
631
  ).superRefine((i, e) => {
632
632
  i.op === "REMOVE" && i.val !== void 0 && e.addIssue({
633
633
  code: S.ZodIssueCode.custom,
@@ -640,50 +640,50 @@ const ce = Xe, O = et.merge(
640
640
  });
641
641
  }), jt = rt.merge(
642
642
  O
643
- ), Jt = it.merge(
643
+ ), Qt = it.merge(
644
644
  O
645
- ), Qt = st.merge(
645
+ ), Yt = st.merge(
646
646
  O
647
- ), Yt = ot.merge(O), Zt = mt.merge(
647
+ ), Zt = ot.merge(O), Xt = gt.merge(
648
648
  O
649
- ), Xt = wt.merge(O), en = at.merge(H).extend({
649
+ ), en = bt.merge(O), tn = at.merge(V).extend({
650
650
  lastSignatures: S.record(S.string()).optional()
651
- }), tn = ct.merge(H), nn = lt.merge(
652
- H
653
- ), rn = ut.merge(H), sn = x.merge(
654
- H
655
- ), li = z(), on = gt.merge(je).extend({
651
+ }), nn = ct.merge(V), rn = lt.merge(
652
+ V
653
+ ), sn = ut.merge(V), on = x.merge(
654
+ V
655
+ ), di = z(), an = Et.merge(Je).extend({
656
656
  steps: S.array(z()).optional()
657
- }), an = Et.merge(
658
- je
657
+ }), cn = yt.merge(
658
+ Je
659
659
  ).extend({
660
660
  steps: S.array(z()).optional()
661
661
  });
662
- function cn(i) {
662
+ function ln(i) {
663
663
  if (!Array.isArray(i.blueIds) || i.blueIds.length === 0)
664
664
  throw new Error("Contract processors must declare at least one BlueId");
665
665
  for (const e of i.blueIds)
666
666
  if (typeof e != "string" || e.trim().length === 0)
667
667
  throw new Error("Contract processor BlueIds must be non-empty strings");
668
668
  }
669
- function V(i, e) {
670
- cn(i);
669
+ function U(i, e) {
670
+ ln(i);
671
671
  for (const t of i.blueIds)
672
672
  e.set(t, i);
673
673
  }
674
- class ln {
674
+ class un {
675
675
  processorsByBlueId = /* @__PURE__ */ new Map();
676
676
  handlerProcessors = /* @__PURE__ */ new Map();
677
677
  channelProcessors = /* @__PURE__ */ new Map();
678
678
  markerProcessors = /* @__PURE__ */ new Map();
679
679
  registerHandler(e) {
680
- V(e, this.handlerProcessors), this.registerProcessorMap(e);
680
+ U(e, this.handlerProcessors), this.registerProcessorMap(e);
681
681
  }
682
682
  registerChannel(e) {
683
- V(e, this.channelProcessors), this.registerProcessorMap(e);
683
+ U(e, this.channelProcessors), this.registerProcessorMap(e);
684
684
  }
685
685
  registerMarker(e) {
686
- V(e, this.markerProcessors), this.registerProcessorMap(e);
686
+ U(e, this.markerProcessors), this.registerProcessorMap(e);
687
687
  }
688
688
  register(e) {
689
689
  switch (e.kind) {
@@ -717,16 +717,16 @@ class ln {
717
717
  return new Map(this.processorsByBlueId);
718
718
  }
719
719
  registerProcessorMap(e) {
720
- V(e, this.processorsByBlueId);
720
+ U(e, this.processorsByBlueId);
721
721
  }
722
722
  }
723
723
  function Se(i, e) {
724
- return i.isTypeOf(e, ge) ? i.nodeToSchemaOutput(e, ge) : i.isTypeOf(e, k) ? i.nodeToSchemaOutput(e, k) : null;
724
+ return i.isTypeOf(e, ge) ? i.nodeToSchemaOutput(e, ge) : i.isTypeOf(e, v) ? i.nodeToSchemaOutput(e, v) : null;
725
725
  }
726
- class un {
726
+ class dn {
727
727
  kind = "channel";
728
- blueIds = [bt["MyOS Timeline Channel"]];
729
- schema = Xt;
728
+ blueIds = [St["MyOS Timeline Channel"]];
729
+ schema = en;
730
730
  matches(e, t) {
731
731
  const { event: n, blue: r } = t;
732
732
  if (!n)
@@ -742,24 +742,24 @@ class un {
742
742
  return !n || !Se(r, n) ? null : n.clone();
743
743
  }
744
744
  }
745
- class dn {
745
+ class hn {
746
746
  kind = "channel";
747
- blueIds = [R["Timeline Channel"]];
748
- schema = Zt;
747
+ blueIds = [T["Timeline Channel"]];
748
+ schema = Xt;
749
749
  matches(e, t) {
750
750
  const { event: n, blue: r } = t;
751
- if (!n || !r.isTypeOf(n, k))
751
+ if (!n || !r.isTypeOf(n, v))
752
752
  return !1;
753
- const o = r.nodeToSchemaOutput(n, k).timeline?.timelineId;
753
+ const o = r.nodeToSchemaOutput(n, v).timeline?.timelineId;
754
754
  return !(!o || !e.timelineId || o !== e.timelineId);
755
755
  }
756
756
  channelize(e, t) {
757
757
  const { event: n, blue: r } = t;
758
- return !n || !r.isTypeOf(n, k) ? null : n.clone();
758
+ return !n || !r.isTypeOf(n, v) ? null : n.clone();
759
759
  }
760
760
  }
761
761
  function le(i) {
762
- const { context: e, eventNode: t, stepResults: n } = i, r = hn(e);
762
+ const { context: e, eventNode: t, stepResults: n } = i, r = pn(e);
763
763
  return {
764
764
  event: e.blue.nodeToJson(t, "simple"),
765
765
  eventCanonical: e.blue.nodeToJson(t, "official"),
@@ -767,21 +767,27 @@ function le(i) {
767
767
  document: r
768
768
  };
769
769
  }
770
- function hn(i) {
771
- const e = (r) => {
772
- const s = r == null ? "/" : typeof r == "string" ? r : (() => {
770
+ const fn = /* @__PURE__ */ new Set(["blueId", "name", "description", "value"]);
771
+ function pn(i) {
772
+ const e = (s) => {
773
+ if (s === "/")
774
+ return !1;
775
+ const o = s.lastIndexOf("/"), a = s.substring(o + 1);
776
+ return fn.has(a);
777
+ }, t = (s) => {
778
+ const o = s == null ? "/" : typeof s == "string" ? s : (() => {
773
779
  throw new TypeError("document() expects a string pointer");
774
- })(), o = s.startsWith("/") ? s : i.resolvePointer(s), a = b(o), c = i.documentAt(a);
775
- return i.gasMeter().chargeDocumentSnapshot(a, c), { snapshot: c, normalizedPointer: a };
776
- }, t = (r, s) => {
777
- const { snapshot: o } = e(r);
778
- if (o)
779
- return i.blue.nodeToJson(o, s);
780
- }, n = (r) => t(r, "simple");
781
- return n.canonical = (r) => t(r, "official"), n;
782
- }
783
- class fn {
784
- supportedBlueIds = [R["Trigger Event"]];
780
+ })(), a = o.startsWith("/") ? o : i.resolvePointer(o), c = b(a), l = i.documentAt(c);
781
+ return i.gasMeter().chargeDocumentSnapshot(c, l), { snapshot: l, normalizedPointer: c };
782
+ }, n = (s, o) => {
783
+ const { snapshot: a, normalizedPointer: c } = t(s);
784
+ if (a)
785
+ return e(c) ? i.blue.nodeToJson(a, "simple") : i.blue.nodeToJson(a, o);
786
+ }, r = (s) => n(s, "simple");
787
+ return r.canonical = (s) => n(s, "official"), r;
788
+ }
789
+ class mn {
790
+ supportedBlueIds = [T["Trigger Event"]];
785
791
  evaluator = new ae();
786
792
  async execute(e) {
787
793
  const { stepNode: t, context: n } = e;
@@ -795,7 +801,7 @@ class fn {
795
801
  shouldResolve: qe({
796
802
  include: ["/event", "/event/**"]
797
803
  }),
798
- shouldDescend: pn(),
804
+ shouldDescend: gn(),
799
805
  context: n
800
806
  }), o = n.blue.nodeToSchemaOutput(
801
807
  r,
@@ -808,15 +814,15 @@ class fn {
808
814
  n.emitEvent(o.clone());
809
815
  }
810
816
  }
811
- function pn() {
812
- return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !mn(e);
817
+ function gn() {
818
+ return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !En(e);
813
819
  }
814
- function mn(i) {
820
+ function En(i) {
815
821
  const e = i.getProperties?.();
816
822
  return e ? !!e.contracts : !1;
817
823
  }
818
- class gn {
819
- supportedBlueIds = [R["JavaScript Code"]];
824
+ class yn {
825
+ supportedBlueIds = [T["JavaScript Code"]];
820
826
  evaluator = new ae();
821
827
  async execute(e) {
822
828
  const { context: t, stepNode: n } = e, { blue: r } = t;
@@ -839,7 +845,7 @@ class gn {
839
845
  });
840
846
  return this.handleEvents(c, t), c;
841
847
  } catch (c) {
842
- throw new Ve(o, c);
848
+ throw new Ue(o, c);
843
849
  }
844
850
  }
845
851
  handleEvents(e, t) {
@@ -853,8 +859,8 @@ class gn {
853
859
  }
854
860
  }
855
861
  }
856
- class En {
857
- supportedBlueIds = [R["Update Document"]];
862
+ class wn {
863
+ supportedBlueIds = [T["Update Document"]];
858
864
  evaluator = new ae();
859
865
  async execute(e) {
860
866
  const { context: t, stepNode: n } = e, { blue: r } = t;
@@ -899,11 +905,11 @@ class En {
899
905
  }
900
906
  }
901
907
  const ue = [
902
- new fn(),
903
- new gn(),
904
- new En()
908
+ new mn(),
909
+ new yn(),
910
+ new wn()
905
911
  ];
906
- class Je {
912
+ class je {
907
913
  executorIndex;
908
914
  constructor(e = ue) {
909
915
  const t = /* @__PURE__ */ new Map();
@@ -930,17 +936,17 @@ class Je {
930
936
  `Unsupported workflow step type "${p}"`
931
937
  );
932
938
  }
933
- const f = {
939
+ const h = {
934
940
  workflow: t,
935
941
  stepNode: c,
936
942
  eventNode: n,
937
943
  context: r,
938
944
  stepResults: o,
939
945
  stepIndex: a
940
- }, h = await u.execute(f);
941
- if (h !== void 0) {
946
+ }, f = await u.execute(h);
947
+ if (f !== void 0) {
942
948
  const p = this.stepResultKey(c, a);
943
- o[p] = h;
949
+ o[p] = f;
944
950
  }
945
951
  }
946
952
  return o;
@@ -950,13 +956,13 @@ class Je {
950
956
  return n && typeof n == "string" && n.length > 0 ? n : `Step${t + 1}`;
951
957
  }
952
958
  }
953
- class yn {
959
+ class bn {
954
960
  kind = "handler";
955
- blueIds = [R["Sequential Workflow"]];
956
- schema = on;
961
+ blueIds = [T["Sequential Workflow"]];
962
+ schema = an;
957
963
  runner;
958
964
  constructor(e = ue) {
959
- this.runner = new Je(e);
965
+ this.runner = new je(e);
960
966
  }
961
967
  async matches(e, t) {
962
968
  const n = t.event();
@@ -967,10 +973,10 @@ class yn {
967
973
  n && await this.runner.run({ workflow: e, eventNode: n, context: t });
968
974
  }
969
975
  }
970
- class wn {
976
+ class Sn {
971
977
  kind = "marker";
972
- blueIds = [R.Operation];
973
- schema = sn;
978
+ blueIds = [T.Operation];
979
+ schema = on;
974
980
  }
975
981
  function Qe(i) {
976
982
  const e = i.channel;
@@ -981,19 +987,19 @@ function Qe(i) {
981
987
  }
982
988
  return null;
983
989
  }
984
- function bn(i, e) {
990
+ function Cn(i, e) {
985
991
  const t = i.getProperties()?.document;
986
992
  return t instanceof d ? e.blue.calculateBlueIdSync(t) : null;
987
993
  }
988
- function Sn(i, e) {
994
+ function In(i, e) {
989
995
  if (e.isTypeOf(i, te, {
990
996
  checkSchemaExtensions: !0
991
997
  }))
992
998
  return i;
993
- if (e.isTypeOf(i, k, {
999
+ if (e.isTypeOf(i, v, {
994
1000
  checkSchemaExtensions: !0
995
1001
  })) {
996
- const n = e.nodeToSchemaOutput(i, k).message;
1002
+ const n = e.nodeToSchemaOutput(i, v).message;
997
1003
  if (n && e.isTypeOf(n, te, {
998
1004
  checkSchemaExtensions: !0
999
1005
  }))
@@ -1001,11 +1007,11 @@ function Sn(i, e) {
1001
1007
  }
1002
1008
  return null;
1003
1009
  }
1004
- function Cn(i, e, t, n) {
1010
+ function vn(i, e, t, n) {
1005
1011
  const { blue: r } = n, s = i.operation;
1006
1012
  return !(!s || t.operation !== s || i.event && !r.isTypeOfNode(e, i.event));
1007
1013
  }
1008
- function vn(i, e) {
1014
+ function kn(i, e) {
1009
1015
  const t = i.operation;
1010
1016
  if (!t)
1011
1017
  return null;
@@ -1018,10 +1024,10 @@ function vn(i, e) {
1018
1024
  ), o = Qe(s);
1019
1025
  return { operationNode: r, operation: s, channelKey: o };
1020
1026
  }
1021
- function kn(i, e) {
1027
+ function Tn(i, e) {
1022
1028
  return !(i && e && i !== e);
1023
1029
  }
1024
- function In(i, e, t) {
1030
+ function Rn(i, e, t) {
1025
1031
  const n = i.getProperties()?.request, r = e.getProperties()?.request;
1026
1032
  if (!(n instanceof d) || !(r instanceof d))
1027
1033
  return !1;
@@ -1033,10 +1039,10 @@ function In(i, e, t) {
1033
1039
  }
1034
1040
  return !0;
1035
1041
  }
1036
- function Rn(i, e, t) {
1042
+ function Pn(i, e, t) {
1037
1043
  if (!i || i.allowNewerVersion !== !1)
1038
1044
  return !0;
1039
- const n = bn(e, t);
1045
+ const n = Cn(e, t);
1040
1046
  if (!n)
1041
1047
  return !0;
1042
1048
  const r = t.resolvePointer("/"), s = t.documentAt(r);
@@ -1045,15 +1051,15 @@ function Rn(i, e, t) {
1045
1051
  const c = (s.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, l = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(s);
1046
1052
  return n === l;
1047
1053
  }
1048
- class Tn {
1054
+ class Nn {
1049
1055
  kind = "handler";
1050
1056
  blueIds = [
1051
- R["Sequential Workflow Operation"]
1057
+ T["Sequential Workflow Operation"]
1052
1058
  ];
1053
- schema = an;
1059
+ schema = cn;
1054
1060
  runner;
1055
1061
  constructor(e = ue) {
1056
- this.runner = new Je(e);
1062
+ this.runner = new je(e);
1057
1063
  }
1058
1064
  deriveChannel(e, t) {
1059
1065
  const n = e.operation;
@@ -1071,7 +1077,7 @@ class Tn {
1071
1077
  const n = t.event();
1072
1078
  if (!n)
1073
1079
  return !1;
1074
- const r = Sn(
1080
+ const r = In(
1075
1081
  n,
1076
1082
  t.blue
1077
1083
  );
@@ -1081,17 +1087,17 @@ class Tn {
1081
1087
  r,
1082
1088
  te
1083
1089
  );
1084
- if (!s || !Cn(e, n, s, t))
1090
+ if (!s || !vn(e, n, s, t))
1085
1091
  return !1;
1086
- const o = vn(e, t);
1092
+ const o = kn(e, t);
1087
1093
  if (!o)
1088
1094
  return !1;
1089
1095
  const a = typeof e.channel == "string" ? e.channel.trim() : "", c = a.length > 0 ? a : null;
1090
- return !(!kn(o.channelKey, c) || !In(
1096
+ return !(!Tn(o.channelKey, c) || !Rn(
1091
1097
  r,
1092
1098
  o.operationNode,
1093
1099
  t.blue
1094
- ) || s?.allowNewerVersion === !1 && !Rn(s, r, t));
1100
+ ) || s?.allowNewerVersion === !1 && !Pn(s, r, t));
1095
1101
  }
1096
1102
  async execute(e, t) {
1097
1103
  const n = t.event();
@@ -1108,11 +1114,11 @@ class Q {
1108
1114
  }
1109
1115
  static create() {
1110
1116
  return new Q(
1111
- new ln()
1117
+ new un()
1112
1118
  );
1113
1119
  }
1114
1120
  registerDefaults() {
1115
- return this.registry.register(new un()), this.registry.register(new dn()), this.registry.register(new yn()), this.registry.register(new wn()), this.registry.register(new Tn()), this;
1121
+ return this.registry.register(new dn()), this.registry.register(new hn()), this.registry.register(new bn()), this.registry.register(new Sn()), this.registry.register(new Nn()), this;
1116
1122
  }
1117
1123
  register(e) {
1118
1124
  return this.registry.register(e), this;
@@ -1125,7 +1131,7 @@ const ie = m["Channel Event Checkpoint"];
1125
1131
  function Ye(i) {
1126
1132
  return typeof i.order == "number" ? i.order : 0;
1127
1133
  }
1128
- class Pn {
1134
+ class An {
1129
1135
  constructor(e, t, n) {
1130
1136
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1131
1137
  }
@@ -1142,7 +1148,7 @@ class Pn {
1142
1148
  return Ye(this.bindingContract);
1143
1149
  }
1144
1150
  }
1145
- class Nn {
1151
+ class Mn {
1146
1152
  constructor(e, t, n) {
1147
1153
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1148
1154
  }
@@ -1159,13 +1165,13 @@ class Nn {
1159
1165
  return Ye(this.bindingContract);
1160
1166
  }
1161
1167
  }
1162
- class A {
1168
+ class M {
1163
1169
  constructor(e, t, n, r, s) {
1164
1170
  this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = s;
1165
1171
  }
1166
1172
  checkpointDeclared;
1167
1173
  static fromComponents(e, t, n, r, s) {
1168
- return new A(
1174
+ return new M(
1169
1175
  e,
1170
1176
  t,
1171
1177
  n,
@@ -1174,10 +1180,10 @@ class A {
1174
1180
  );
1175
1181
  }
1176
1182
  static builder() {
1177
- return new Mn();
1183
+ return new Dn();
1178
1184
  }
1179
1185
  static empty() {
1180
- return A.builder().build();
1186
+ return M.builder().build();
1181
1187
  }
1182
1188
  markers() {
1183
1189
  return new Map(
@@ -1207,8 +1213,8 @@ class A {
1207
1213
  throw new Error(
1208
1214
  "Duplicate Channel Event Checkpoint markers detected in same contracts map"
1209
1215
  );
1210
- this.markerStore.set(I, {
1211
- key: I,
1216
+ this.markerStore.set(k, {
1217
+ key: k,
1212
1218
  contract: e,
1213
1219
  blueId: ie
1214
1220
  }), this.checkpointDeclared = !0;
@@ -1216,7 +1222,7 @@ class A {
1216
1222
  handlersFor(e) {
1217
1223
  const t = this.handlersByChannel.get(e);
1218
1224
  return !t || t.length === 0 ? [] : [...t].map(
1219
- (n) => new Nn(n.key, n.contract, n.blueId)
1225
+ (n) => new Mn(n.key, n.contract, n.blueId)
1220
1226
  ).sort((n, r) => {
1221
1227
  const s = n.order() - r.order();
1222
1228
  return s !== 0 ? s : n.key().localeCompare(r.key());
@@ -1224,7 +1230,7 @@ class A {
1224
1230
  }
1225
1231
  channelsOfType(...e) {
1226
1232
  const t = e.length > 0 ? new Set(e) : null, n = Array.from(this.channels.values()).filter((r) => !t || t.has(r.blueId)).map(
1227
- (r) => new Pn(r.key, r.contract, r.blueId)
1233
+ (r) => new An(r.key, r.contract, r.blueId)
1228
1234
  );
1229
1235
  return n.sort((r, s) => {
1230
1236
  const o = r.order() - s.order();
@@ -1232,7 +1238,7 @@ class A {
1232
1238
  }), n;
1233
1239
  }
1234
1240
  }
1235
- class Mn {
1241
+ class Dn {
1236
1242
  channels = /* @__PURE__ */ new Map();
1237
1243
  handlersByChannel = /* @__PURE__ */ new Map();
1238
1244
  markerStore = /* @__PURE__ */ new Map();
@@ -1257,12 +1263,12 @@ class Mn {
1257
1263
  return this.embeddedDeclared = !0, this.embeddedPaths = e.paths ? [...e.paths] : [], this;
1258
1264
  }
1259
1265
  addMarker(e, t, n) {
1260
- if (e === I && n !== ie)
1266
+ if (e === k && n !== ie)
1261
1267
  throw new Error(
1262
1268
  "Reserved key 'checkpoint' must contain a Channel Event Checkpoint"
1263
1269
  );
1264
1270
  if (n === ie) {
1265
- if (e !== I)
1271
+ if (e !== k)
1266
1272
  throw new Error(
1267
1273
  `Channel Event Checkpoint must use reserved key 'checkpoint' at key '${e}'`
1268
1274
  );
@@ -1275,7 +1281,7 @@ class Mn {
1275
1281
  return this.markerStore.set(e, { key: e, contract: t, blueId: n }), this;
1276
1282
  }
1277
1283
  build() {
1278
- return A.fromComponents(
1284
+ return M.fromComponents(
1279
1285
  new Map(this.channels),
1280
1286
  new Map(
1281
1287
  Array.from(this.handlersByChannel.entries(), ([e, t]) => [
@@ -1294,7 +1300,7 @@ class g extends Error {
1294
1300
  super(e || "Processor fatal error"), this.processorError = t, this.name = "ProcessorFatalError";
1295
1301
  }
1296
1302
  }
1297
- class An {
1303
+ class On {
1298
1304
  constructor(e, t, n) {
1299
1305
  this.blue = e, this.registry = t, this.builtinChannelSchemas = n;
1300
1306
  }
@@ -1391,49 +1397,49 @@ class F extends Error {
1391
1397
  super(e ?? "MustUnderstand failure"), this.name = "MustUnderstandFailure";
1392
1398
  }
1393
1399
  }
1394
- const Dn = m["Document Update Channel"], On = m["Embedded Node Channel"], Bn = m["Lifecycle Event Channel"], Ln = m["Triggered Event Channel"], Ce = m["Process Embedded"], _n = m["Processing Initialized Marker"], $n = m["Processing Terminated Marker"], xn = m["Channel Event Checkpoint"], ve = /* @__PURE__ */ new Map([
1400
+ const Bn = m["Document Update Channel"], Ln = m["Embedded Node Channel"], _n = m["Lifecycle Event Channel"], $n = m["Triggered Event Channel"], Ce = m["Process Embedded"], xn = m["Processing Initialized Marker"], Fn = m["Processing Terminated Marker"], zn = m["Channel Event Checkpoint"], Ie = /* @__PURE__ */ new Map([
1395
1401
  [
1396
- Dn,
1402
+ Bn,
1397
1403
  jt
1398
1404
  ],
1399
1405
  [
1400
- On,
1401
- Jt
1402
- ],
1403
- [
1404
- Bn,
1406
+ Ln,
1405
1407
  Qt
1406
1408
  ],
1407
1409
  [
1408
- Ln,
1410
+ _n,
1409
1411
  Yt
1412
+ ],
1413
+ [
1414
+ $n,
1415
+ Zt
1410
1416
  ]
1411
- ]), Fn = /* @__PURE__ */ new Map([
1417
+ ]), Vn = /* @__PURE__ */ new Map([
1412
1418
  [
1413
- _n,
1414
- tn
1419
+ xn,
1420
+ nn
1415
1421
  ],
1416
1422
  [
1417
- $n,
1418
- rn
1423
+ Fn,
1424
+ sn
1419
1425
  ],
1420
1426
  [
1421
- xn,
1422
- en
1427
+ zn,
1428
+ tn
1423
1429
  ]
1424
1430
  ]);
1425
- class zn {
1431
+ class Hn {
1426
1432
  constructor(e, t) {
1427
- this.registry = e, this.blue = t, this.handlerRegistration = new An(
1433
+ this.registry = e, this.blue = t, this.handlerRegistration = new On(
1428
1434
  this.blue,
1429
1435
  this.registry,
1430
- ve
1436
+ Ie
1431
1437
  );
1432
1438
  }
1433
1439
  handlerRegistration;
1434
1440
  load(e, t) {
1435
1441
  try {
1436
- const n = A.builder(), r = e.getContracts();
1442
+ const n = M.builder(), r = e.getContracts();
1437
1443
  if (!r)
1438
1444
  return n.build();
1439
1445
  const s = this.buildScopeContractsIndex(r);
@@ -1461,12 +1467,12 @@ class zn {
1461
1467
  this.handleProcessEmbedded(e, t, n);
1462
1468
  return;
1463
1469
  }
1464
- const o = Fn.get(s);
1470
+ const o = Vn.get(s);
1465
1471
  if (o) {
1466
1472
  this.handleMarker(e, t, n, o, s);
1467
1473
  return;
1468
1474
  }
1469
- const a = ve.get(s);
1475
+ const a = Ie.get(s);
1470
1476
  if (a) {
1471
1477
  this.handleChannel(e, t, n, a, s);
1472
1478
  return;
@@ -1518,7 +1524,7 @@ class zn {
1518
1524
  try {
1519
1525
  const r = this.convert(
1520
1526
  n,
1521
- nn
1527
+ rn
1522
1528
  );
1523
1529
  e.setEmbedded(r);
1524
1530
  } catch (r) {
@@ -1599,24 +1605,24 @@ class zn {
1599
1605
  function X(i) {
1600
1606
  return i instanceof Pe;
1601
1607
  }
1602
- const Hn = m["Channel Event Checkpoint"];
1603
- function Un(i) {
1608
+ const Un = m["Channel Event Checkpoint"];
1609
+ function Kn(i) {
1604
1610
  return i.jsonValueToNode({
1605
- type: { blueId: Hn },
1611
+ type: { blueId: Un },
1606
1612
  lastEvents: {},
1607
1613
  lastSignatures: {}
1608
1614
  });
1609
1615
  }
1610
- function Vn() {
1616
+ function Wn() {
1611
1617
  return {
1612
1618
  lastEvents: {},
1613
1619
  lastSignatures: {}
1614
1620
  };
1615
1621
  }
1616
- function ke(i) {
1622
+ function ve(i) {
1617
1623
  return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
1618
1624
  }
1619
- class Kn {
1625
+ class Gn {
1620
1626
  constructor(e, t, n, r, s) {
1621
1627
  this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = s;
1622
1628
  }
@@ -1626,28 +1632,28 @@ class Kn {
1626
1632
  return e != null && e === this.lastEventSignature;
1627
1633
  }
1628
1634
  }
1629
- class Wn {
1635
+ class qn {
1630
1636
  constructor(e, t) {
1631
1637
  this.runtime = e, this.signatureFn = t;
1632
1638
  }
1633
1639
  ensureCheckpointMarker(e, t) {
1634
- const n = t.marker(I), r = w(e, Le);
1640
+ const n = t.marker(k), r = w(e, Le);
1635
1641
  if (!n) {
1636
- const s = Un(this.runtime.blue());
1637
- this.runtime.directWrite(r, s), t.registerCheckpointMarker(Vn());
1642
+ const s = Kn(this.runtime.blue());
1643
+ this.runtime.directWrite(r, s), t.registerCheckpointMarker(Wn());
1638
1644
  return;
1639
1645
  }
1640
- if (!ke(n))
1646
+ if (!ve(n))
1641
1647
  throw new Error(
1642
1648
  `Reserved key 'checkpoint' must contain a Channel Event Checkpoint at ${r}`
1643
1649
  );
1644
1650
  }
1645
1651
  findCheckpoint(e, t) {
1646
1652
  for (const [n, r] of e.markerEntries()) {
1647
- if (!ke(r))
1653
+ if (!ve(r))
1648
1654
  continue;
1649
1655
  const o = (r.lastEvents?.[t] ?? null)?.clone() ?? null, c = r.lastSignatures?.[t] ?? null ?? this.signatureFn(o);
1650
- return new Kn(
1656
+ return new Gn(
1651
1657
  n,
1652
1658
  r,
1653
1659
  t,
@@ -1675,7 +1681,7 @@ class Wn {
1675
1681
  this.runtime.directWrite(c, l), n.checkpoint.lastSignatures || (n.checkpoint.lastSignatures = {}), r == null ? delete n.checkpoint.lastSignatures[n.channelKey] : n.checkpoint.lastSignatures[n.channelKey] = r, n.lastEventSignature = r ?? null;
1676
1682
  }
1677
1683
  }
1678
- class Gn {
1684
+ class Jn {
1679
1685
  constructor(e, t, n) {
1680
1686
  this.runtime = e, this.checkpointManager = t, this.deps = n;
1681
1687
  }
@@ -1735,10 +1741,10 @@ class Gn {
1735
1741
  }
1736
1742
  }
1737
1743
  }
1738
- function qn(i, e) {
1744
+ function jn(i, e) {
1739
1745
  return e.isResolved() ? i.createResolvedNode(e) : i.resolve(e);
1740
1746
  }
1741
- class M extends g {
1747
+ class A extends g {
1742
1748
  constructor(e) {
1743
1749
  super(e, E.illegalState(e)), this.name = "IllegalStateException";
1744
1750
  }
@@ -1748,8 +1754,8 @@ class P extends Error {
1748
1754
  super(e), this.name = "BoundaryViolationException";
1749
1755
  }
1750
1756
  }
1751
- const jn = m["Document Update Channel"], Jn = m["Embedded Node Channel"], Qn = m["Triggered Event Channel"], Yn = m["Lifecycle Event Channel"], Ie = m["Processing Initialized Marker"], Zn = m["Document Processing Initiated"];
1752
- class Xn {
1757
+ const Qn = m["Document Update Channel"], Yn = m["Embedded Node Channel"], Zn = m["Triggered Event Channel"], Xn = m["Lifecycle Event Channel"], ke = m["Processing Initialized Marker"], er = m["Document Processing Initiated"];
1758
+ class tr {
1753
1759
  runtime;
1754
1760
  contractLoader;
1755
1761
  channelRunner;
@@ -1766,22 +1772,22 @@ class Xn {
1766
1772
  const n = y(e), r = /* @__PURE__ */ new Set();
1767
1773
  let s = null, o = null;
1768
1774
  for (t && this.runtime.gasMeter().chargeScopeEntry(n); ; ) {
1769
- const f = this.nodeAt(n);
1770
- if (!f)
1771
- return;
1772
- o || (o = f.clone()), s = this.loadBundle(f, n), this.bundles.set(n, s);
1773
- const h = s.embeddedPaths().find((Y) => !r.has(Y)) ?? null;
1775
+ const h = this.nodeAt(n);
1774
1776
  if (!h)
1777
+ return;
1778
+ o || (o = h.clone()), s = this.loadBundle(h, n), this.bundles.set(n, s);
1779
+ const f = s.embeddedPaths().find((Y) => !r.has(Y)) ?? null;
1780
+ if (!f)
1775
1781
  break;
1776
- r.add(h);
1777
- const p = w(n, h);
1782
+ r.add(f);
1783
+ const p = w(n, f);
1778
1784
  this.nodeAt(p) && await this.initializeScope(p, !0);
1779
1785
  }
1780
1786
  if (!s)
1781
1787
  return;
1782
1788
  const a = this.hasInitializationMarker(n);
1783
1789
  if (!a && s.hasCheckpoint())
1784
- throw new M(
1790
+ throw new A(
1785
1791
  `Reserved key 'checkpoint' must not appear before initialization at scope ${n}`
1786
1792
  );
1787
1793
  if (a)
@@ -1800,7 +1806,7 @@ class Xn {
1800
1806
  const t = y(e);
1801
1807
  if (this.bundles.has(t))
1802
1808
  return;
1803
- const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : A.empty();
1809
+ const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : M.empty();
1804
1810
  this.bundles.set(t, r);
1805
1811
  for (const s of r.embeddedPaths()) {
1806
1812
  const o = w(t, s);
@@ -1808,7 +1814,7 @@ class Xn {
1808
1814
  }
1809
1815
  }
1810
1816
  async processExternalEvent(e, t) {
1811
- const n = qn(this.runtime.blue(), t);
1817
+ const n = jn(this.runtime.blue(), t);
1812
1818
  await this.processPreparedExternalEvent(e, n);
1813
1819
  }
1814
1820
  async processPreparedExternalEvent(e, t) {
@@ -1874,13 +1880,13 @@ class Xn {
1874
1880
  if (!a || this.hooks.isScopeInactive(o))
1875
1881
  continue;
1876
1882
  const c = this.createDocumentUpdateEvent(s, o), l = a.channelsOfType(
1877
- jn
1883
+ Qn
1878
1884
  );
1879
1885
  for (const u of l) {
1880
- const f = u.contract();
1886
+ const h = u.contract();
1881
1887
  if (this.matchesDocumentUpdate(
1882
1888
  o,
1883
- f.path ?? null,
1889
+ h.path ?? null,
1884
1890
  s.path
1885
1891
  ) && (await this.channelRunner.runHandlers(
1886
1892
  o,
@@ -1898,7 +1904,7 @@ class Xn {
1898
1904
  await this.hooks.enterFatalTermination(e, t, o);
1899
1905
  return;
1900
1906
  }
1901
- if (s instanceof M || s instanceof Error && !(s instanceof g)) {
1907
+ if (s instanceof A || s instanceof Error && !(s instanceof g)) {
1902
1908
  const o = this.hooks.fatalReason(s, "Runtime fatal");
1903
1909
  await this.hooks.enterFatalTermination(e, t, o);
1904
1910
  return;
@@ -1911,7 +1917,7 @@ class Xn {
1911
1917
  if (this.runtime.gasMeter().chargeLifecycleDelivery(), await this.hooks.recordLifecycleForBridging(e, n), !t)
1912
1918
  return;
1913
1919
  const s = t.channelsOfType(
1914
- Yn
1920
+ Xn
1915
1921
  );
1916
1922
  for (const o of s)
1917
1923
  if (await this.channelRunner.runHandlers(
@@ -1973,7 +1979,7 @@ class Xn {
1973
1979
  }
1974
1980
  }
1975
1981
  async addInitializationMarker(e, t) {
1976
- const n = new d().setType(new d().setBlueId(Ie)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(re);
1982
+ const n = new d().setType(new d().setBlueId(ke)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(re);
1977
1983
  await e.applyPatch({
1978
1984
  op: "ADD",
1979
1985
  path: r,
@@ -1987,7 +1993,7 @@ class Xn {
1987
1993
  if (this.hooks.isScopeInactive(e) || t.embeddedPaths().length === 0)
1988
1994
  return;
1989
1995
  const n = t.channelsOfType(
1990
- Jn
1996
+ Yn
1991
1997
  );
1992
1998
  if (n.length !== 0)
1993
1999
  for (const r of t.embeddedPaths()) {
@@ -1996,8 +2002,8 @@ class Xn {
1996
2002
  for (const c of a) {
1997
2003
  let l = !1;
1998
2004
  for (const u of n) {
1999
- const h = u.contract().childPath ?? "/";
2000
- w(e, h) === s && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
2005
+ const f = u.contract().childPath ?? "/";
2006
+ w(e, f) === s && (l || (this.runtime.gasMeter().chargeBridge(), l = !0), await this.channelRunner.runHandlers(
2001
2007
  e,
2002
2008
  t,
2003
2009
  u.key(),
@@ -2012,7 +2018,7 @@ class Xn {
2012
2018
  if (this.hooks.isScopeInactive(e))
2013
2019
  return;
2014
2020
  const n = this.runtime.scope(e), r = t.channelsOfType(
2015
- Qn
2021
+ Zn
2016
2022
  );
2017
2023
  if (r.length === 0) {
2018
2024
  n.clearTriggered();
@@ -2066,7 +2072,7 @@ class Xn {
2066
2072
  for (const o of se) {
2067
2073
  const a = w(
2068
2074
  r,
2069
- J(o)
2075
+ j(o)
2070
2076
  );
2071
2077
  if (s === a || s.startsWith(`${a}/`))
2072
2078
  throw new P(
@@ -2089,16 +2095,16 @@ class Xn {
2089
2095
  return !1;
2090
2096
  if (!(n instanceof d)) {
2091
2097
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2092
- throw new M(s);
2098
+ throw new A(s);
2093
2099
  }
2094
- if (n.getType()?.getBlueId() !== Ie) {
2100
+ if (n.getType()?.getBlueId() !== ke) {
2095
2101
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2096
- throw new M(s);
2102
+ throw new A(s);
2097
2103
  }
2098
2104
  return !0;
2099
2105
  }
2100
2106
  createLifecycleEvent(e) {
2101
- return new d().setType(new d().setBlueId(Zn)).setProperties({
2107
+ return new d().setType(new d().setBlueId(er)).setProperties({
2102
2108
  type: new d().setValue("Document Processing Initiated"),
2103
2109
  documentId: new d().setValue(e)
2104
2110
  });
@@ -2111,8 +2117,8 @@ class q extends Error {
2111
2117
  ), this.fatal = e, this.name = "RunTerminationError";
2112
2118
  }
2113
2119
  }
2114
- const er = m["Processing Terminated Marker"], tr = m["Document Processing Terminated"];
2115
- class nr {
2120
+ const nr = m["Processing Terminated Marker"], rr = m["Document Processing Terminated"];
2121
+ class ir {
2116
2122
  constructor(e) {
2117
2123
  this.runtime = e;
2118
2124
  }
@@ -2121,9 +2127,9 @@ class nr {
2121
2127
  const o = e.normalizeScope(t), a = w(o, Be);
2122
2128
  this.runtime.directWrite(
2123
2129
  a,
2124
- rr(this.runtime.blue(), r, s)
2130
+ sr(this.runtime.blue(), r, s)
2125
2131
  ), this.runtime.gasMeter().chargeTerminationMarker();
2126
- const c = n ?? e.bundleForScope(o) ?? null, l = ir(r, s);
2132
+ const c = n ?? e.bundleForScope(o) ?? null, l = or(r, s);
2127
2133
  if (await e.deliverLifecycle(
2128
2134
  o,
2129
2135
  c,
@@ -2135,32 +2141,32 @@ class nr {
2135
2141
  throw this.runtime.markRunTerminated(), new q(!1);
2136
2142
  }
2137
2143
  }
2138
- function rr(i, e, t) {
2139
- return sr(i, {
2140
- type: { blueId: er },
2144
+ function sr(i, e, t) {
2145
+ return ar(i, {
2146
+ type: { blueId: nr },
2141
2147
  cause: e === "GRACEFUL" ? "graceful" : "fatal",
2142
2148
  ...t ? { reason: t } : {}
2143
2149
  });
2144
2150
  }
2145
- function ir(i, e) {
2151
+ function or(i, e) {
2146
2152
  const t = new d().setType(
2147
- new d().setBlueId(tr)
2153
+ new d().setBlueId(rr)
2148
2154
  );
2149
2155
  return t.addProperty(
2150
2156
  "cause",
2151
2157
  new d().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
2152
2158
  ), e && t.addProperty("reason", new d().setValue(e)), t;
2153
2159
  }
2154
- function sr(i, e) {
2160
+ function ar(i, e) {
2155
2161
  return i.jsonValueToNode(e);
2156
2162
  }
2157
2163
  const $ = "-";
2158
- class or {
2164
+ class cr {
2159
2165
  constructor(e) {
2160
2166
  this.document = e;
2161
2167
  }
2162
2168
  applyPatch(e, t) {
2163
- const n = y(e), r = b(t.path), s = Te(r), o = Re(this.document, s, "before", r);
2169
+ const n = y(e), r = b(t.path), s = Re(r), o = Te(this.document, s, "before", r);
2164
2170
  switch (t.op) {
2165
2171
  case "ADD":
2166
2172
  this.applyAdd(s, r, t.val ?? null);
@@ -2172,21 +2178,21 @@ class or {
2172
2178
  this.applyRemove(s, r);
2173
2179
  break;
2174
2180
  }
2175
- const a = t.op === "REMOVE" ? null : Re(this.document, s, "after", r);
2181
+ const a = t.op === "REMOVE" ? null : Te(this.document, s, "after", r);
2176
2182
  return {
2177
2183
  path: r,
2178
2184
  before: o,
2179
2185
  after: a,
2180
2186
  op: t.op.toLowerCase(),
2181
2187
  originScope: n,
2182
- cascadeScopes: ar(n)
2188
+ cascadeScopes: lr(n)
2183
2189
  };
2184
2190
  }
2185
2191
  directWrite(e, t) {
2186
2192
  const n = b(e);
2187
2193
  if (n === "/")
2188
2194
  throw new Error("Direct write cannot target root document");
2189
- const r = Te(n), { parent: s, leaf: o } = this.resolveParent(r);
2195
+ const r = Re(n), { parent: s, leaf: o } = this.resolveParent(r);
2190
2196
  if (o === $)
2191
2197
  throw new Error(
2192
2198
  `Direct write does not support append token '-' for path ${n}`
@@ -2199,7 +2205,7 @@ class or {
2199
2205
  this.directWriteObject(s, o, t);
2200
2206
  }
2201
2207
  directWriteArray(e, t, n, r, s) {
2202
- const o = ee(e, t), a = v(n, s);
2208
+ const o = ee(e, t), a = I(n, s);
2203
2209
  if (r == null) {
2204
2210
  if (a < 0 || a >= o.length)
2205
2211
  return;
@@ -2246,7 +2252,7 @@ class or {
2246
2252
  );
2247
2253
  const s = e.getItems();
2248
2254
  if (s && N(t)) {
2249
- const c = v(t, B(n, r));
2255
+ const c = I(t, B(n, r));
2250
2256
  if (c < 0 || c >= s.length)
2251
2257
  throw new Error(
2252
2258
  `Array index out of bounds: ${B(n, r)}`
@@ -2281,10 +2287,10 @@ class or {
2281
2287
  ee(r, l).push(L(n));
2282
2288
  return;
2283
2289
  }
2284
- const f = v(s, t);
2285
- if (f < 0 || f > l.length)
2290
+ const h = I(s, t);
2291
+ if (h < 0 || h > l.length)
2286
2292
  throw new Error(`Array index out of bounds in path: ${t}`);
2287
- ee(r, l).splice(f, 0, L(n));
2293
+ ee(r, l).splice(h, 0, L(n));
2288
2294
  return;
2289
2295
  }
2290
2296
  const c = K(r);
@@ -2306,7 +2312,7 @@ class or {
2306
2312
  const c = r.getItems();
2307
2313
  if (!c)
2308
2314
  throw new Error(`Array index segment requires array at ${t}`);
2309
- const l = v(s, t);
2315
+ const l = I(s, t);
2310
2316
  if (l < 0 || l >= c.length)
2311
2317
  throw new Error(`Array index out of bounds in path: ${t}`);
2312
2318
  c[l] = L(n), r.setItems(c);
@@ -2330,7 +2336,7 @@ class or {
2330
2336
  const a = n.getItems();
2331
2337
  if (!a)
2332
2338
  throw new Error(`Array index segment requires array at ${t}`);
2333
- const c = v(r, t);
2339
+ const c = I(r, t);
2334
2340
  if (c < 0 || c >= a.length)
2335
2341
  throw new Error(`Array index out of bounds in path: ${t}`);
2336
2342
  a.splice(c, 1), n.setItems(a);
@@ -2350,25 +2356,25 @@ class or {
2350
2356
  for (let a = 0; a < e.length - 1; a += 1) {
2351
2357
  const c = e[a], l = B(e, a + 1);
2352
2358
  if (N(c)) {
2353
- const h = r.getItems();
2354
- if (!h)
2359
+ const f = r.getItems();
2360
+ if (!f)
2355
2361
  throw new Error(`Array index segment requires array at ${l}`);
2356
- const p = v(c, l);
2357
- if (p < 0 || p >= h.length)
2362
+ const p = I(c, l);
2363
+ if (p < 0 || p >= f.length)
2358
2364
  throw new Error(`Array index out of bounds in path: ${l}`);
2359
- const C = h[p];
2365
+ const C = f[p];
2360
2366
  if (!(C instanceof d))
2361
2367
  throw new Error(`Array index out of bounds in path: ${l}`);
2362
2368
  r = C;
2363
2369
  continue;
2364
2370
  }
2365
- let u = r.getProperties(), f = u?.[c] ?? null;
2366
- if (!(f instanceof d)) {
2371
+ let u = r.getProperties(), h = u?.[c] ?? null;
2372
+ if (!(h instanceof d)) {
2367
2373
  if (n === "REMOVE")
2368
2374
  throw new Error(`Path does not exist: ${l}`);
2369
- f = new d(), u || (u = {}), u[c] = f, r.setProperties(u), s.push({ owner: r, key: c });
2375
+ h = new d(), u || (u = {}), u[c] = h, r.setProperties(u), s.push({ owner: r, key: c });
2370
2376
  }
2371
- r = f;
2377
+ r = h;
2372
2378
  }
2373
2379
  const o = e[e.length - 1];
2374
2380
  return { parent: r, key: o, pointer: t, created: s };
@@ -2380,7 +2386,7 @@ class or {
2380
2386
  }
2381
2387
  }
2382
2388
  }
2383
- function ar(i) {
2389
+ function lr(i) {
2384
2390
  const e = [];
2385
2391
  let t = i;
2386
2392
  for (; e.push(t), t !== "/"; ) {
@@ -2389,26 +2395,26 @@ function ar(i) {
2389
2395
  }
2390
2396
  return e;
2391
2397
  }
2392
- function Re(i, e, t, n) {
2398
+ function Te(i, e, t, n) {
2393
2399
  try {
2394
2400
  if (e.length === 0)
2395
2401
  return i.clone();
2396
- const r = cr(i, e, t, n);
2402
+ const r = ur(i, e, t, n);
2397
2403
  return r ? r.clone() : null;
2398
2404
  } catch {
2399
2405
  return null;
2400
2406
  }
2401
2407
  }
2402
- function cr(i, e, t, n) {
2408
+ function ur(i, e, t, n) {
2403
2409
  let r = i;
2404
2410
  for (let s = 0; s < e.length; s += 1) {
2405
2411
  const o = e[s] ?? "", a = s === e.length - 1;
2406
- if (r = lr(r, o, a, t, n), !r)
2412
+ if (r = dr(r, o, a, t, n), !r)
2407
2413
  return null;
2408
2414
  }
2409
2415
  return r;
2410
2416
  }
2411
- function lr(i, e, t, n, r) {
2417
+ function dr(i, e, t, n, r) {
2412
2418
  if (!i)
2413
2419
  return null;
2414
2420
  const s = i.getItems();
@@ -2418,7 +2424,7 @@ function lr(i, e, t, n, r) {
2418
2424
  throw new Error(`Append token '-' must be final segment: ${r}`);
2419
2425
  return n === "before" || s.length === 0 ? null : s[s.length - 1] ?? null;
2420
2426
  }
2421
- const c = v(e, r);
2427
+ const c = I(e, r);
2422
2428
  return c < 0 || c >= s.length ? null : s[c] ?? null;
2423
2429
  }
2424
2430
  const o = i.getProperties();
@@ -2427,13 +2433,13 @@ function lr(i, e, t, n, r) {
2427
2433
  const a = o[e];
2428
2434
  return a instanceof d ? a : null;
2429
2435
  }
2430
- function Te(i) {
2436
+ function Re(i) {
2431
2437
  if (i === "/" || i === "")
2432
2438
  return [];
2433
2439
  const e = i.startsWith("/") ? i.slice(1) : i;
2434
2440
  return e.length === 0 ? [] : e.split("/");
2435
2441
  }
2436
- function v(i, e) {
2442
+ function I(i, e) {
2437
2443
  const t = Number.parseInt(i, 10);
2438
2444
  if (Number.isNaN(t))
2439
2445
  throw new Error(`Expected numeric array index in path: ${e}`);
@@ -2469,7 +2475,7 @@ function N(i) {
2469
2475
  function L(i) {
2470
2476
  return i == null ? new d().setValue(null) : i.clone();
2471
2477
  }
2472
- class ur {
2478
+ class hr {
2473
2479
  constructor(e) {
2474
2480
  this.path = e;
2475
2481
  }
@@ -2531,7 +2537,7 @@ class ur {
2531
2537
  return this.cutOff;
2532
2538
  }
2533
2539
  }
2534
- class dr {
2540
+ class fr {
2535
2541
  scopesMap = /* @__PURE__ */ new Map();
2536
2542
  rootEmissionList = [];
2537
2543
  scopes() {
@@ -2539,7 +2545,7 @@ class dr {
2539
2545
  }
2540
2546
  scope(e) {
2541
2547
  let t = this.scopesMap.get(e);
2542
- return t || (t = new ur(e), this.scopesMap.set(e, t)), t;
2548
+ return t || (t = new hr(e), this.scopesMap.set(e, t)), t;
2543
2549
  }
2544
2550
  existingScope(e) {
2545
2551
  return this.scopesMap.get(e);
@@ -2557,45 +2563,45 @@ class dr {
2557
2563
  this.scopesMap.delete(e);
2558
2564
  }
2559
2565
  }
2560
- function U(i) {
2566
+ function H(i) {
2561
2567
  return Math.floor((i + 99) / 100);
2562
2568
  }
2563
2569
  function de(i) {
2564
2570
  return new TextEncoder().encode(i).length;
2565
2571
  }
2566
- function hr(i) {
2572
+ function pr(i) {
2567
2573
  const e = b(i);
2568
2574
  return e === "/" ? 0 : e.split("/").length - 1;
2569
2575
  }
2570
- function fr(i) {
2571
- return 100 + U(de(i));
2576
+ function mr(i) {
2577
+ return 100 + H(de(i));
2572
2578
  }
2573
- function pr(i) {
2579
+ function gr(i) {
2574
2580
  return 40 + 5 * Math.max(0, i);
2575
2581
  }
2576
- function mr(i) {
2577
- return 5 + U(de(i));
2582
+ function Er(i) {
2583
+ return 5 + H(de(i));
2578
2584
  }
2579
- function gr(i, e) {
2580
- return 3 * Math.max(0, i) + U(de(e));
2585
+ function yr(i, e) {
2586
+ return 3 * Math.max(0, i) + H(de(e));
2581
2587
  }
2582
- function Er(i, e) {
2583
- return 8 + hr(i) + U(e);
2588
+ function wr(i, e) {
2589
+ return 8 + pr(i) + H(e);
2584
2590
  }
2585
- const yr = 1e3, wr = 5, br = 50, Sr = 2, Cr = 10, vr = 10, kr = 10, Ir = 20, Rr = 20, Tr = 30, Pr = 30, Nr = 100;
2586
- function Mr(i) {
2591
+ const br = 1e3, Sr = 5, Cr = 50, Ir = 2, vr = 10, kr = 10, Tr = 10, Rr = 20, Pr = 20, Nr = 30, Ar = 30, Mr = 100;
2592
+ function Dr(i) {
2587
2593
  return 50 + 10 * i;
2588
2594
  }
2589
- function Ar(i) {
2595
+ function Or(i) {
2590
2596
  return 20 + i;
2591
2597
  }
2592
- function Dr(i) {
2598
+ function Br(i) {
2593
2599
  return 10 * i;
2594
2600
  }
2595
- function Or(i) {
2601
+ function Lr(i) {
2596
2602
  return 20 + i;
2597
2603
  }
2598
- class Br {
2604
+ class _r {
2599
2605
  constructor(e) {
2600
2606
  this.blue = e;
2601
2607
  }
@@ -2607,74 +2613,74 @@ class Br {
2607
2613
  this.total += e;
2608
2614
  }
2609
2615
  chargeScopeEntry(e) {
2610
- this.add(Mr(this.scopeDepth(e)));
2616
+ this.add(Dr(this.scopeDepth(e)));
2611
2617
  }
2612
2618
  chargeInitialization() {
2613
- this.add(yr);
2619
+ this.add(br);
2614
2620
  }
2615
2621
  chargeChannelMatchAttempt() {
2616
- this.add(wr);
2622
+ this.add(Sr);
2617
2623
  }
2618
2624
  chargeHandlerOverhead() {
2619
- this.add(br);
2625
+ this.add(Cr);
2620
2626
  }
2621
2627
  chargeBoundaryCheck() {
2622
- this.add(Sr);
2628
+ this.add(Ir);
2623
2629
  }
2624
2630
  chargePatchAddOrReplace(e) {
2625
- this.add(Ar(this.payloadSizeCharge(e)));
2631
+ this.add(Or(this.payloadSizeCharge(e)));
2626
2632
  }
2627
2633
  chargePatchRemove() {
2628
- this.add(Cr);
2634
+ this.add(vr);
2629
2635
  }
2630
2636
  chargeCascadeRouting(e) {
2631
- e > 0 && this.add(Dr(e));
2637
+ e > 0 && this.add(Br(e));
2632
2638
  }
2633
2639
  chargeEmitEvent(e) {
2634
- this.add(Or(this.payloadSizeCharge(e)));
2640
+ this.add(Lr(this.payloadSizeCharge(e)));
2635
2641
  }
2636
2642
  chargeBridge() {
2637
- this.add(vr);
2643
+ this.add(kr);
2638
2644
  }
2639
2645
  chargeDrainEvent() {
2640
- this.add(kr);
2646
+ this.add(Tr);
2641
2647
  }
2642
2648
  chargeCheckpointUpdate() {
2643
- this.add(Ir);
2649
+ this.add(Rr);
2644
2650
  }
2645
2651
  chargeTerminationMarker() {
2646
- this.add(Rr);
2652
+ this.add(Pr);
2647
2653
  }
2648
2654
  chargeLifecycleDelivery() {
2649
- this.add(Tr);
2655
+ this.add(Nr);
2650
2656
  }
2651
2657
  chargeFatalTerminationOverhead() {
2652
- this.add(Nr);
2658
+ this.add(Mr);
2653
2659
  }
2654
2660
  chargeJavaScriptCodeBase(e) {
2655
- this.add(fr(e));
2661
+ this.add(mr(e));
2656
2662
  }
2657
2663
  chargeTriggerEventBase() {
2658
- this.add(Pr);
2664
+ this.add(Ar);
2659
2665
  }
2660
2666
  chargeUpdateDocumentBase(e) {
2661
- this.add(pr(e));
2667
+ this.add(gr(e));
2662
2668
  }
2663
2669
  chargeExpression(e) {
2664
- this.add(mr(e));
2670
+ this.add(Er(e));
2665
2671
  }
2666
2672
  chargeTemplate(e, t) {
2667
- this.add(gr(e, t));
2673
+ this.add(yr(e, t));
2668
2674
  }
2669
2675
  chargeDocumentSnapshot(e, t) {
2670
2676
  const n = t ? we(this.blue, t) : 0;
2671
- this.add(Er(e, n));
2677
+ this.add(wr(e, n));
2672
2678
  }
2673
2679
  payloadSizeCharge(e) {
2674
2680
  if (!e)
2675
2681
  return 0;
2676
2682
  const t = we(this.blue, e);
2677
- return U(t);
2683
+ return H(t);
2678
2684
  }
2679
2685
  scopeDepth(e) {
2680
2686
  const t = y(e);
@@ -2686,12 +2692,12 @@ class Br {
2686
2692
  return n;
2687
2693
  }
2688
2694
  }
2689
- class Lr {
2695
+ class $r {
2690
2696
  constructor(e, t) {
2691
- this.documentRef = e, this.blueRef = t, this.patchEngine = new or(this.documentRef), this.meter = new Br(this.blueRef);
2697
+ this.documentRef = e, this.blueRef = t, this.patchEngine = new cr(this.documentRef), this.meter = new _r(this.blueRef);
2692
2698
  }
2693
2699
  patchEngine;
2694
- emissionRegistry = new dr();
2700
+ emissionRegistry = new fr();
2695
2701
  meter;
2696
2702
  runTerminated = !1;
2697
2703
  document() {
@@ -2740,15 +2746,15 @@ class Lr {
2740
2746
  return this.patchEngine.applyPatch(e, t);
2741
2747
  }
2742
2748
  }
2743
- const _r = m["Processing Initialized Marker"], $r = m["Document Update"];
2744
- class xr {
2749
+ const xr = m["Processing Initialized Marker"], Fr = m["Document Update"];
2750
+ class zr {
2745
2751
  constructor(e, t, n, r) {
2746
- this.contractLoader = e, this.registry = t, this.runtimeRef = new Lr(r, n);
2747
- const s = (o) => He(this.runtimeRef.blue(), o);
2748
- this.checkpointManager = new Wn(
2752
+ this.contractLoader = e, this.registry = t, this.runtimeRef = new $r(r, n);
2753
+ const s = (o) => Ve(this.runtimeRef.blue(), o);
2754
+ this.checkpointManager = new qn(
2749
2755
  this.runtimeRef,
2750
2756
  s
2751
- ), this.terminationService = new nr(this.runtimeRef), this.channelRunner = new Gn(
2757
+ ), this.terminationService = new ir(this.runtimeRef), this.channelRunner = new Jn(
2752
2758
  this.runtimeRef,
2753
2759
  this.checkpointManager,
2754
2760
  {
@@ -2777,7 +2783,7 @@ class xr {
2777
2783
  handleHandlerError: async (o, a, c) => this.handleHandlerError(o, a, c),
2778
2784
  canonicalSignature: s
2779
2785
  }
2780
- ), this.scopeExecutor = new Xn({
2786
+ ), this.scopeExecutor = new tr({
2781
2787
  runtime: this.runtimeRef,
2782
2788
  contractLoader: this.contractLoader,
2783
2789
  channelRunner: this.channelRunner,
@@ -2828,7 +2834,7 @@ class xr {
2828
2834
  );
2829
2835
  }
2830
2836
  createContext(e, t, n, r = !1, s = !1) {
2831
- return new Fr(
2837
+ return new Vr(
2832
2838
  this,
2833
2839
  t,
2834
2840
  e,
@@ -2900,7 +2906,9 @@ class xr {
2900
2906
  }
2901
2907
  nodeAt(e) {
2902
2908
  const t = y(e);
2903
- return j.nodeAt(this.runtimeRef.document(), t);
2909
+ return J.nodeAt(this.runtimeRef.document(), t, {
2910
+ calculateBlueId: (n) => this.runtimeRef.blue().calculateBlueIdSync(n)
2911
+ });
2904
2912
  }
2905
2913
  async evaluateChannel(e, t, n, r) {
2906
2914
  const s = this.registry.lookupChannel(e.blueId());
@@ -2918,11 +2926,11 @@ class xr {
2918
2926
  c
2919
2927
  ))
2920
2928
  return { matches: !1 };
2921
- const u = s.channelize, f = u ? u.call(s, e.contract(), c) : void 0;
2929
+ const u = s.channelize, h = u ? u.call(s, e.contract(), c) : void 0;
2922
2930
  return {
2923
2931
  matches: !0,
2924
2932
  eventId: o,
2925
- eventNode: f ?? a.clone()
2933
+ eventNode: h ?? a.clone()
2926
2934
  };
2927
2935
  }
2928
2936
  async executeHandler(e, t) {
@@ -2952,7 +2960,7 @@ class xr {
2952
2960
  }
2953
2961
  createDocumentUpdateEvent(e, t) {
2954
2962
  const n = Mt(t, e.path), r = e.before != null ? e.before.clone() : new d().setValue(null), s = e.after != null ? e.after.clone() : new d().setValue(null), o = new d().setType(
2955
- new d().setBlueId($r)
2963
+ new d().setBlueId(Fr)
2956
2964
  );
2957
2965
  return o.setProperties({
2958
2966
  op: new d().setValue(e.op),
@@ -2968,13 +2976,13 @@ class xr {
2968
2976
  return r === "/" || s === r ? !0 : s.startsWith(`${r}/`);
2969
2977
  }
2970
2978
  }
2971
- class j {
2979
+ class J {
2972
2980
  constructor(e, t, n) {
2973
2981
  this.contractLoader = e, this.registry = t, this.blue = n;
2974
2982
  }
2975
2983
  async initializeDocument(e) {
2976
2984
  if (this.isInitialized(e))
2977
- throw new M("Document already initialized");
2985
+ throw new A("Document already initialized");
2978
2986
  const t = this.createExecution(e.clone());
2979
2987
  return this.run(e, t, async () => {
2980
2988
  await t.initializeScope("/", !0);
@@ -2982,7 +2990,7 @@ class j {
2982
2990
  }
2983
2991
  async processDocument(e, t) {
2984
2992
  if (!this.isInitialized(e))
2985
- throw new M("Document not initialized");
2993
+ throw new A("Document not initialized");
2986
2994
  const n = this.createExecution(e.clone()), r = t.clone();
2987
2995
  return this.run(e, n, async () => {
2988
2996
  n.loadBundles("/"), await n.processExternalEvent("/", r);
@@ -2992,7 +3000,7 @@ class j {
2992
3000
  return this.initializationMarker(e) != null;
2993
3001
  }
2994
3002
  createExecution(e) {
2995
- return new xr(
3003
+ return new zr(
2996
3004
  this.contractLoader,
2997
3005
  this.registry,
2998
3006
  this.blue,
@@ -3027,7 +3035,7 @@ class j {
3027
3035
  "Initialization Marker must be a BlueNode"
3028
3036
  )
3029
3037
  );
3030
- if (n.getType()?.getBlueId() !== _r)
3038
+ if (n.getType()?.getBlueId() !== xr)
3031
3039
  throw new g(
3032
3040
  "Initialization Marker must declare type 'Processing Initialized Marker'",
3033
3041
  E.illegalState(
@@ -3036,37 +3044,72 @@ class j {
3036
3044
  );
3037
3045
  return n;
3038
3046
  }
3039
- static nodeAt(e, t) {
3047
+ static nodeAt(e, t, n) {
3040
3048
  if (!(e instanceof d))
3041
3049
  return null;
3042
- const n = b(t);
3043
- if (n === "/")
3050
+ const r = b(t);
3051
+ if (r === "/")
3044
3052
  return e;
3045
- const r = n.slice(1).split("/");
3046
- let s = e;
3047
- for (const o of r) {
3048
- if (!s)
3049
- return null;
3053
+ const s = r.slice(1).split("/");
3054
+ let o = e;
3055
+ for (const a of s) {
3050
3056
  if (!o)
3057
+ return null;
3058
+ if (!a)
3051
3059
  continue;
3052
- const a = s.getItems();
3053
- if (a && /^\d+$/.test(o)) {
3054
- const u = Number.parseInt(o, 10);
3055
- s = a[u] ?? null;
3060
+ const c = o.getItems();
3061
+ if (c && /^\d+$/.test(a)) {
3062
+ const h = Number.parseInt(a, 10);
3063
+ o = c[h] ?? null;
3056
3064
  continue;
3057
3065
  }
3058
- const c = s.getProperties();
3059
- if (!c)
3060
- return null;
3061
- const l = c[o];
3062
- if (!(l instanceof d))
3063
- return null;
3064
- s = l;
3066
+ const l = o.getProperties();
3067
+ if (l && a in l) {
3068
+ const h = l[a];
3069
+ if (!(h instanceof d))
3070
+ return null;
3071
+ o = h;
3072
+ continue;
3073
+ }
3074
+ const u = this.specialSegmentNode(o, a, n);
3075
+ if (u !== void 0) {
3076
+ o = u;
3077
+ continue;
3078
+ }
3079
+ return null;
3080
+ }
3081
+ return o;
3082
+ }
3083
+ static specialSegmentNode(e, t, n) {
3084
+ switch (t) {
3085
+ case "name":
3086
+ return new d().setValue(e.getName() ?? null);
3087
+ case "description":
3088
+ return new d().setValue(e.getDescription() ?? null);
3089
+ case "type":
3090
+ return e.getType() ?? null;
3091
+ case "itemType":
3092
+ return e.getItemType() ?? null;
3093
+ case "keyType":
3094
+ return e.getKeyType() ?? null;
3095
+ case "valueType":
3096
+ return e.getValueType() ?? null;
3097
+ case "value":
3098
+ return new d().setValue(e.getValue() ?? null);
3099
+ case "blue":
3100
+ return e.getBlue() ?? null;
3101
+ case "contracts":
3102
+ return new d().setContracts(e.getContracts());
3103
+ case "blueId": {
3104
+ const r = e.getBlueId() ?? n?.calculateBlueId?.(e) ?? pt.calculateBlueIdSync(e);
3105
+ return new d().setValue(r ?? null);
3106
+ }
3107
+ default:
3108
+ return;
3065
3109
  }
3066
- return s;
3067
3110
  }
3068
3111
  }
3069
- class Fr {
3112
+ class Vr {
3070
3113
  constructor(e, t, n, r, s, o) {
3071
3114
  this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = s, this.allowReservedMutation = o;
3072
3115
  }
@@ -3121,18 +3164,24 @@ class Fr {
3121
3164
  if (!e)
3122
3165
  return !1;
3123
3166
  try {
3124
- return j.nodeAt(
3167
+ return J.nodeAt(
3125
3168
  this.execution.runtime().document(),
3126
- e
3169
+ e,
3170
+ {
3171
+ calculateBlueId: (t) => this.execution.runtime().blue().calculateBlueIdSync(t)
3172
+ }
3127
3173
  ) != null;
3128
3174
  } catch {
3129
3175
  return !1;
3130
3176
  }
3131
3177
  }
3132
3178
  documentNodeAt(e) {
3133
- const t = j.nodeAt(
3179
+ const t = J.nodeAt(
3134
3180
  this.execution.runtime().document(),
3135
- e
3181
+ e,
3182
+ {
3183
+ calculateBlueId: (n) => this.execution.runtime().blue().calculateBlueIdSync(n)
3184
+ }
3136
3185
  );
3137
3186
  return t instanceof d ? t : null;
3138
3187
  }
@@ -3154,16 +3203,16 @@ class Fr {
3154
3203
  return !this.allowTerminatedWork && this.execution.isScopeInactive(this.scopePathValue);
3155
3204
  }
3156
3205
  }
3157
- const zr = new pt({
3158
- repositories: [dt, yt, St]
3206
+ const Hr = new mt({
3207
+ repositories: [dt, wt, Ct]
3159
3208
  });
3160
- class Hr {
3209
+ class Ur {
3161
3210
  blue;
3162
3211
  registryRef;
3163
3212
  contractLoaderRef;
3164
3213
  engine;
3165
3214
  constructor(e) {
3166
- this.registryRef = e?.registry ?? Q.create().registerDefaults().build(), this.blue = e?.blue ?? zr, this.contractLoaderRef = new zn(this.registryRef, this.blue), this.engine = new j(
3215
+ this.registryRef = e?.registry ?? Q.create().registerDefaults().build(), this.blue = e?.blue ?? Hr, this.contractLoaderRef = new Hn(this.registryRef, this.blue), this.engine = new J(
3167
3216
  this.contractLoaderRef,
3168
3217
  this.registryRef,
3169
3218
  this.blue
@@ -3196,10 +3245,10 @@ class Hr {
3196
3245
  return this.contractLoaderRef;
3197
3246
  }
3198
3247
  static builder() {
3199
- return new Ur();
3248
+ return new Kr();
3200
3249
  }
3201
3250
  }
3202
- class Ur {
3251
+ class Kr {
3203
3252
  contractRegistry;
3204
3253
  blueInstance;
3205
3254
  constructor() {
@@ -3215,7 +3264,7 @@ class Ur {
3215
3264
  return this.blueInstance = e, this;
3216
3265
  }
3217
3266
  build() {
3218
- return new Hr({
3267
+ return new Ur({
3219
3268
  registry: this.contractRegistry,
3220
3269
  blue: this.blueInstance
3221
3270
  });
@@ -3242,111 +3291,111 @@ class Ze {
3242
3291
  return e;
3243
3292
  }
3244
3293
  }
3245
- const ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3294
+ const hi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3246
3295
  __proto__: null,
3247
3296
  ExpressionPreserver: Ze
3248
3297
  }, Symbol.toStringTag, { value: "Module" }));
3249
- function di() {
3250
- return new T.SequentialMergingProcessor([
3251
- new T.ValuePropagator(),
3298
+ function fi() {
3299
+ return new R.SequentialMergingProcessor([
3300
+ new R.ValuePropagator(),
3252
3301
  new Ze(),
3253
- new T.TypeAssigner(),
3254
- new T.ListProcessor(),
3255
- new T.DictionaryProcessor(),
3256
- new T.BasicTypesVerifier()
3302
+ new R.TypeAssigner(),
3303
+ new R.ListProcessor(),
3304
+ new R.DictionaryProcessor(),
3305
+ new R.BasicTypesVerifier()
3257
3306
  ]);
3258
3307
  }
3259
3308
  export {
3260
- Pn as ChannelBinding,
3261
- Gn as ChannelRunner,
3262
- Wn as CheckpointManager,
3263
- Kn as CheckpointRecord,
3264
- Ve as CodeBlockEvaluationError,
3265
- A as ContractBundle,
3266
- Mn as ContractBundleBuilder,
3267
- zn as ContractLoader,
3268
- ln as ContractProcessorRegistry,
3309
+ An as ChannelBinding,
3310
+ Jn as ChannelRunner,
3311
+ qn as CheckpointManager,
3312
+ Gn as CheckpointRecord,
3313
+ Ue as CodeBlockEvaluationError,
3314
+ M as ContractBundle,
3315
+ Dn as ContractBundleBuilder,
3316
+ Hn as ContractLoader,
3317
+ un as ContractProcessorRegistry,
3269
3318
  Q as ContractProcessorRegistryBuilder,
3270
3319
  Ne as DocumentProcessingResult,
3271
- Lr as DocumentProcessingRuntime,
3272
- Hr as DocumentProcessor,
3273
- Ur as DocumentProcessorBuilder,
3274
- dr as EmissionRegistry,
3275
- Br as GasMeter,
3276
- Nn as HandlerBinding,
3277
- I as KEY_CHECKPOINT,
3278
- Me as KEY_EMBEDDED,
3279
- Ae as KEY_INITIALIZED,
3320
+ $r as DocumentProcessingRuntime,
3321
+ Ur as DocumentProcessor,
3322
+ Kr as DocumentProcessorBuilder,
3323
+ fr as EmissionRegistry,
3324
+ _r as GasMeter,
3325
+ Mn as HandlerBinding,
3326
+ k as KEY_CHECKPOINT,
3327
+ Ae as KEY_EMBEDDED,
3328
+ Me as KEY_INITIALIZED,
3280
3329
  De as KEY_TERMINATED,
3281
- ui as MergingProcessors,
3330
+ hi as MergingProcessors,
3282
3331
  Oe as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3283
- or as PatchEngine,
3284
- si as ProcessorContractConstants,
3285
- j as ProcessorEngine,
3332
+ cr as PatchEngine,
3333
+ ai as ProcessorContractConstants,
3334
+ J as ProcessorEngine,
3286
3335
  E as ProcessorErrors,
3287
- xr as ProcessorExecution,
3288
- Fr as ProcessorExecutionContext,
3336
+ zr as ProcessorExecution,
3337
+ Vr as ProcessorExecutionContext,
3289
3338
  g as ProcessorFatalError,
3290
- oi as ProcessorPointerConstants,
3339
+ ci as ProcessorPointerConstants,
3291
3340
  ae as QuickJSEvaluator,
3292
3341
  Le as RELATIVE_CHECKPOINT,
3293
3342
  D as RELATIVE_CONTRACTS,
3294
- Nt as RELATIVE_EMBEDDED,
3343
+ At as RELATIVE_EMBEDDED,
3295
3344
  re as RELATIVE_INITIALIZED,
3296
3345
  Be as RELATIVE_TERMINATED,
3297
3346
  se as RESERVED_CONTRACT_KEYS,
3298
3347
  q as RunTerminationError,
3299
- Xn as ScopeExecutor,
3300
- ur as ScopeRuntimeContext,
3301
- nr as TerminationService,
3302
- ti as andThen,
3303
- He as canonicalSignature,
3348
+ tr as ScopeExecutor,
3349
+ hr as ScopeRuntimeContext,
3350
+ ir as TerminationService,
3351
+ ri as andThen,
3352
+ Ve as canonicalSignature,
3304
3353
  we as canonicalSize,
3305
3354
  O as channelContractBaseSchema,
3306
- en as channelEventCheckpointSchema,
3307
- Kt as containsExpression,
3355
+ tn as channelEventCheckpointSchema,
3356
+ Wt as containsExpression,
3308
3357
  ce as contractBaseSchema,
3309
- di as createDefaultMergingProcessor,
3358
+ fi as createDefaultMergingProcessor,
3310
3359
  qe as createPicomatchShouldResolve,
3311
3360
  jt as documentUpdateChannelSchema,
3312
- Jt as embeddedNodeChannelSchema,
3361
+ Qt as embeddedNodeChannelSchema,
3313
3362
  vt as err,
3314
3363
  Ge as evaluateQuickJSExpression,
3315
- Wt as extractExpressionContent,
3316
- je as handlerContractBaseSchema,
3317
- tn as initializationMarkerSchema,
3318
- Zr as isErr,
3364
+ Gt as extractExpressionContent,
3365
+ Je as handlerContractBaseSchema,
3366
+ nn as initializationMarkerSchema,
3367
+ ei as isErr,
3319
3368
  W as isExpression,
3320
- Yr as isOk,
3369
+ Xr as isOk,
3321
3370
  oe as isProcessorManagedChannelBlueId,
3322
- Pt as isReservedContractKey,
3323
- ai as joinRelativePointers,
3324
- ci as jsonPatchSchema,
3325
- Qt as lifecycleChannelSchema,
3326
- Xr as map,
3327
- ei as mapErr,
3328
- H as markerContractBaseSchema,
3329
- ii as match,
3330
- Xt as myosTimelineChannelSchema,
3371
+ Nt as isReservedContractKey,
3372
+ li as joinRelativePointers,
3373
+ ui as jsonPatchSchema,
3374
+ Yt as lifecycleChannelSchema,
3375
+ ti as map,
3376
+ ni as mapErr,
3377
+ V as markerContractBaseSchema,
3378
+ oi as match,
3379
+ en as myosTimelineChannelSchema,
3331
3380
  b as normalizePointer,
3332
3381
  y as normalizeScope,
3333
- Ct as ok,
3334
- sn as operationMarkerSchema,
3335
- nn as processEmbeddedMarkerSchema,
3336
- rn as processingTerminatedMarkerSchema,
3382
+ It as ok,
3383
+ on as operationMarkerSchema,
3384
+ rn as processEmbeddedMarkerSchema,
3385
+ sn as processingTerminatedMarkerSchema,
3337
3386
  xe as relativeCheckpointLastEvent,
3338
3387
  Fe as relativeCheckpointLastSignature,
3339
- J as relativeContractsEntry,
3388
+ j as relativeContractsEntry,
3340
3389
  Mt as relativizePointer,
3341
3390
  G as resolveNodeExpressions,
3342
3391
  w as resolvePointer,
3343
- Gt as resolveTemplateString,
3344
- an as sequentialWorkflowOperationSchema,
3345
- on as sequentialWorkflowSchema,
3346
- li as sequentialWorkflowStepSchema,
3392
+ qt as resolveTemplateString,
3393
+ cn as sequentialWorkflowOperationSchema,
3394
+ an as sequentialWorkflowSchema,
3395
+ di as sequentialWorkflowStepSchema,
3347
3396
  Ee as stripSlashes,
3348
- Zt as timelineChannelSchema,
3349
- Yt as triggeredEventChannelSchema,
3350
- ni as unwrapOr,
3351
- ri as unwrapOrElse
3397
+ Xt as timelineChannelSchema,
3398
+ Zt as triggeredEventChannelSchema,
3399
+ ii as unwrapOr,
3400
+ si as unwrapOrElse
3352
3401
  };