@blue-labs/document-processor 2.0.0-rc.6 → 2.0.0

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
- import { blueIds as m, ContractSchema as et, ChannelSchema as tt, HandlerSchema as nt, MarkerSchema as rt, DocumentUpdateChannelSchema as it, EmbeddedNodeChannelSchema as st, LifecycleEventChannelSchema as ot, TriggeredEventChannelSchema as at, ChannelEventCheckpointSchema as ct, ProcessingInitializedMarkerSchema as lt, ProcessEmbeddedSchema as ut, ProcessingTerminatedMarkerSchema as dt, repository as ht } from "@blue-repository/core";
2
- import { getQuickJS as ft } from "quickjs-emscripten";
3
- import { BlueNode as d, blueNodeField as V, withTypeBlueId as pt, BlueIdCalculator as mt, Blue as gt, MergingProcessors as P } from "@blue-labs/language";
1
+ import { blueIds as m, ContractSchema as nt, ChannelSchema as rt, HandlerSchema as it, MarkerSchema as st, DocumentUpdateChannelSchema as ot, EmbeddedNodeChannelSchema as at, LifecycleEventChannelSchema as ct, TriggeredEventChannelSchema as lt, ChannelEventCheckpointSchema as ut, ProcessingInitializedMarkerSchema as dt, ProcessEmbeddedSchema as ht, ProcessingTerminatedMarkerSchema as ft, repository as pt } from "@blue-repository/core";
2
+ import { getQuickJS as mt } from "quickjs-emscripten";
3
+ import { BlueNode as d, blueNodeField as V, withTypeBlueId as gt, BlueIdCalculator as Et, Blue as yt, MergingProcessors as P } from "@blue-labs/language";
4
4
  import fe from "picomatch";
5
- import { z as b, ZodError as Ne } from "zod";
6
- import { TimelineChannelSchema as Et, OperationSchema as z, SequentialWorkflowSchema as yt, SequentialWorkflowOperationSchema as wt, TimelineEntrySchema as v, blueIds as R, TriggerEventSchema as pe, JavaScriptCodeSchema as me, UpdateDocumentSchema as ge, OperationRequestSchema as ne, repository as St } from "@blue-repository/conversation";
7
- import { MyOSTimelineChannelSchema as bt, DocumentAnchorsSchema as Ct, DocumentLinksSchema as It, MyOSParticipantsOrchestrationSchema as kt, MyOSSessionInteractionSchema as vt, MyOSWorkerAgencySchema as Tt, blueIds as D, MyOSTimelineEntrySchema as Ee, repository as Rt } from "@blue-repository/myos";
5
+ import { z as b, ZodError as Me } from "zod";
6
+ import { TimelineChannelSchema as wt, OperationSchema as z, SequentialWorkflowSchema as St, SequentialWorkflowOperationSchema as bt, TimelineEntrySchema as v, blueIds as R, TriggerEventSchema as pe, JavaScriptCodeSchema as me, UpdateDocumentSchema as ge, OperationRequestSchema as ne, repository as Ct } from "@blue-repository/conversation";
7
+ import { MyOSTimelineChannelSchema as It, DocumentAnchorsSchema as vt, DocumentLinksSchema as kt, MyOSParticipantsOrchestrationSchema as Tt, MyOSSessionInteractionSchema as Rt, MyOSWorkerAgencySchema as Pt, blueIds as D, MyOSTimelineEntrySchema as Ee, repository as Nt } from "@blue-repository/myos";
8
8
  import { isNullable as re } from "@blue-labs/shared-utils";
9
- function Pt(i) {
9
+ function Mt(i) {
10
10
  return { ok: !0, value: i };
11
11
  }
12
- function Nt(i) {
12
+ function Ot(i) {
13
13
  return { ok: !1, error: i };
14
14
  }
15
- function pi(i) {
15
+ function gi(i) {
16
16
  return i.ok;
17
17
  }
18
- function mi(i) {
18
+ function Ei(i) {
19
19
  return !i.ok;
20
20
  }
21
- function gi(i, e) {
22
- return i.ok ? Pt(e(i.value)) : i;
21
+ function yi(i, e) {
22
+ return i.ok ? Mt(e(i.value)) : i;
23
23
  }
24
- function Ei(i, e) {
25
- return i.ok ? i : Nt(e(i.error));
24
+ function wi(i, e) {
25
+ return i.ok ? i : Ot(e(i.error));
26
26
  }
27
- function yi(i, e) {
27
+ function Si(i, e) {
28
28
  return i.ok ? e(i.value) : i;
29
29
  }
30
- function wi(i, e) {
30
+ function bi(i, e) {
31
31
  return i.ok ? i.value : e;
32
32
  }
33
- function Si(i, e) {
33
+ function Ci(i, e) {
34
34
  return i.ok ? i.value : e(i.error);
35
35
  }
36
- function bi(i, e) {
36
+ function Ii(i, e) {
37
37
  return i.ok ? e.ok(i.value) : e.err(i.error);
38
38
  }
39
39
  const E = {
@@ -56,14 +56,14 @@ const E = {
56
56
  return { kind: "UnsupportedOp", operation: i, reason: e };
57
57
  }
58
58
  };
59
- function Mt(i) {
59
+ function At(i) {
60
60
  return Object.freeze([...i]);
61
61
  }
62
- const At = {
62
+ const Dt = {
63
63
  of(i, e, t) {
64
64
  return {
65
65
  document: i,
66
- triggeredEvents: Mt(e),
66
+ triggeredEvents: At(e),
67
67
  totalGas: t,
68
68
  capabilityFailure: !1,
69
69
  failureReason: null
@@ -78,66 +78,66 @@ const At = {
78
78
  failureReason: e ?? null
79
79
  };
80
80
  }
81
- }, Me = At, Ot = [
81
+ }, Oe = Dt, Bt = [
82
82
  "embedded",
83
83
  "initialized",
84
84
  "terminated",
85
85
  "checkpoint"
86
- ], Dt = [
86
+ ], _t = [
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
- ], Ae = "embedded", Oe = "initialized", De = "terminated", T = "checkpoint", oe = new Set(
92
- Ot
93
- ), Be = new Set(Dt);
94
- function Bt(i) {
91
+ ], Ae = "embedded", De = "initialized", Be = "terminated", T = "checkpoint", oe = new Set(
92
+ Bt
93
+ ), _e = new Set(_t);
94
+ function Lt(i) {
95
95
  return i != null && oe.has(i);
96
96
  }
97
97
  function ae(i) {
98
- return i != null && Be.has(
98
+ return i != null && _e.has(
99
99
  i
100
100
  );
101
101
  }
102
- const Ci = {
102
+ const vi = {
103
103
  KEY_EMBEDDED: Ae,
104
- KEY_INITIALIZED: Oe,
105
- KEY_TERMINATED: De,
104
+ KEY_INITIALIZED: De,
105
+ KEY_TERMINATED: Be,
106
106
  KEY_CHECKPOINT: T,
107
107
  RESERVED_CONTRACT_KEYS: oe,
108
- PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: Be,
109
- isReservedContractKey: Bt,
108
+ PROCESSOR_MANAGED_CHANNEL_BLUE_IDS: _e,
109
+ isReservedContractKey: Lt,
110
110
  isProcessorManagedChannelBlueId: ae
111
- }, B = "/contracts", ie = `${B}/${Oe}`, _e = `${B}/${De}`, _t = `${B}/${Ae}`, Le = `${B}/${T}`, $e = "/lastEvents", xe = "/lastSignatures";
111
+ }, B = "/contracts", ie = `${B}/${De}`, Le = `${B}/${Be}`, $t = `${B}/${Ae}`, $e = `${B}/${T}`, xe = "/lastEvents", Fe = "/lastSignatures";
112
112
  function Q(i) {
113
113
  return `${B}/${i}`;
114
114
  }
115
- function Fe(i, e) {
116
- return `${Q(i)}${$e}/${e}`;
117
- }
118
115
  function ze(i, e) {
119
116
  return `${Q(i)}${xe}/${e}`;
120
117
  }
121
- const Ii = {
118
+ function Ue(i, e) {
119
+ return `${Q(i)}${Fe}/${e}`;
120
+ }
121
+ const ki = {
122
122
  RELATIVE_CONTRACTS: B,
123
123
  RELATIVE_INITIALIZED: ie,
124
- RELATIVE_TERMINATED: _e,
125
- RELATIVE_EMBEDDED: _t,
126
- RELATIVE_CHECKPOINT: Le,
127
- LAST_EVENTS_SUFFIX: $e,
128
- LAST_SIGNATURES_SUFFIX: xe,
124
+ RELATIVE_TERMINATED: Le,
125
+ RELATIVE_EMBEDDED: $t,
126
+ RELATIVE_CHECKPOINT: $e,
127
+ LAST_EVENTS_SUFFIX: xe,
128
+ LAST_SIGNATURES_SUFFIX: Fe,
129
129
  relativeContractsEntry: Q,
130
- relativeCheckpointLastEvent: Fe,
131
- relativeCheckpointLastSignature: ze
130
+ relativeCheckpointLastEvent: ze,
131
+ relativeCheckpointLastSignature: Ue
132
132
  };
133
- function Ue(i) {
133
+ function Ve(i) {
134
134
  return i == null || i.length === 0;
135
135
  }
136
136
  function y(i) {
137
- return Ue(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
137
+ return Ve(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
138
138
  }
139
139
  function S(i) {
140
- return Ue(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
140
+ return Ve(i) ? "/" : i.startsWith("/") ? i : `/${i}`;
141
141
  }
142
142
  function ye(i) {
143
143
  if (i == null)
@@ -151,7 +151,7 @@ function ye(i) {
151
151
  e = e.substring(0, e.length - 1);
152
152
  return e;
153
153
  }
154
- function ki(i, e) {
154
+ function Ti(i, e) {
155
155
  const t = ye(i), n = ye(e);
156
156
  return t.length === 0 && n.length === 0 ? "/" : t.length === 0 ? `/${n}` : n.length === 0 ? `/${t}` : `/${t}/${n}`;
157
157
  }
@@ -159,7 +159,7 @@ function w(i, e) {
159
159
  const t = y(i), n = S(e);
160
160
  return t === "/" ? n : n === "/" || n.length === 1 ? t : `${t}${n}`;
161
161
  }
162
- function Lt(i, e) {
162
+ function xt(i, e) {
163
163
  const t = y(i), n = S(e);
164
164
  if (t === "/" || !n.startsWith(t))
165
165
  return n;
@@ -168,11 +168,11 @@ function Lt(i, e) {
168
168
  const r = n.substring(t.length);
169
169
  return r.length === 0 ? "/" : r.startsWith("/") ? r : `/${r}`;
170
170
  }
171
- function $t(i) {
171
+ function Ft(i) {
172
172
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
173
173
  }
174
174
  var X, we;
175
- function xt() {
175
+ function zt() {
176
176
  return we || (we = 1, X = 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 xt() {
186
186
  }, "")}}`;
187
187
  }), X;
188
188
  }
189
- var Ft = xt();
190
- const zt = /* @__PURE__ */ $t(Ft);
191
- function Ut(i, e) {
189
+ var Ut = zt();
190
+ const Vt = /* @__PURE__ */ Ft(Ut);
191
+ function Ht(i, e) {
192
192
  return i.nodeToJson(e, "official");
193
193
  }
194
- function Vt(i, e) {
195
- const t = Ut(i, e);
196
- return zt(t);
194
+ function Kt(i, e) {
195
+ const t = Ht(i, e);
196
+ return Vt(t);
197
197
  }
198
- function Ve(i, e) {
199
- return e ? Vt(i, e) : null;
198
+ function He(i, e) {
199
+ return e ? Kt(i, e) : null;
200
200
  }
201
201
  function Se(i, e) {
202
- const t = Ve(i, e);
202
+ const t = He(i, e);
203
203
  return t == null ? 0 : new TextEncoder().encode(t).length;
204
204
  }
205
- function He(i) {
205
+ function Ke(i) {
206
206
  return typeof i == "object" && i !== null && !Array.isArray(i);
207
207
  }
208
- function Ht(i) {
208
+ function Wt(i) {
209
209
  return i.replace(/~1/g, "/").replace(/~0/g, "~");
210
210
  }
211
- function Kt(i) {
211
+ function Gt(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 Kt(i) {
217
217
  function x(i, e = !0) {
218
218
  if (Array.isArray(i))
219
219
  return e ? i.map((r) => x(r, !0)) : i.slice();
220
- if (!He(i))
220
+ if (!Ke(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 x(i, e = !0) {
231
231
  n[r] = e ? x(s, !0) : s;
232
232
  return n;
233
233
  }
234
- function Wt(i, e) {
234
+ function qt(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) => Ht(r));
239
+ const t = e.split("/").slice(1).map((r) => Wt(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 (!Kt(r))
245
+ if (!Gt(r))
246
246
  return;
247
247
  const s = Number(r);
248
248
  n = n[s];
249
249
  continue;
250
250
  }
251
- if (He(n)) {
251
+ if (Ke(n)) {
252
252
  n = n[r];
253
253
  continue;
254
254
  }
@@ -256,15 +256,15 @@ function Wt(i, e) {
256
256
  }
257
257
  return n;
258
258
  }
259
- const Gt = 500, qt = 32 * 1024 * 1024;
259
+ const Jt = 500, jt = 32 * 1024 * 1024;
260
260
  class ce {
261
261
  modulePromise;
262
262
  moduleInstance;
263
263
  async evaluate({
264
264
  code: e,
265
265
  bindings: t,
266
- timeout: n = Gt,
267
- memoryLimit: r = qt
266
+ timeout: n = Jt,
267
+ memoryLimit: r = jt
268
268
  }) {
269
269
  const o = (await this.ensureModule()).newRuntime();
270
270
  o.setMemoryLimit(r);
@@ -290,7 +290,7 @@ class ce {
290
290
  }
291
291
  }
292
292
  async ensureModule() {
293
- return this.moduleInstance ? this.moduleInstance : (this.modulePromise || (this.modulePromise = ft().then((e) => (this.moduleInstance = e, e))), this.modulePromise);
293
+ return this.moduleInstance ? this.moduleInstance : (this.modulePromise || (this.modulePromise = mt().then((e) => (this.moduleInstance = e, e))), this.modulePromise);
294
294
  }
295
295
  wrapCode(e) {
296
296
  return `(async () => {
@@ -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 = Wt(o, a);
336
+ const c = qt(o, a);
337
337
  return this.createReturnHandle(e, c);
338
338
  } catch (r) {
339
339
  const s = r instanceof Error ? r.message : String(r);
@@ -492,43 +492,43 @@ ${e}
492
492
  }
493
493
  }
494
494
  const be = 120;
495
- function Jt(i) {
495
+ function Qt(i) {
496
496
  return i.length <= be ? i : `${i.slice(0, be - 3)}...`;
497
497
  }
498
- class Ke extends Error {
498
+ class We extends Error {
499
499
  constructor(e, t) {
500
- super(`Failed to evaluate code block: ${Jt(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
500
+ super(`Failed to evaluate code block: ${Qt(e)}`, { cause: t }), this.code = e, this.cause = t, this.name = "CodeBlockEvaluationError";
501
501
  }
502
502
  }
503
- const We = /^\$\{([\s\S]*)\}$/, jt = /\$\{([\s\S]+?)\}/, Ge = /\$\{([\s\S]+?)\}/g;
503
+ const Ge = /^\$\{([\s\S]*)\}$/, Yt = /\$\{([\s\S]+?)\}/, qe = /\$\{([\s\S]+?)\}/g;
504
504
  function G(i) {
505
- if (typeof i != "string" || !We.test(i))
505
+ if (typeof i != "string" || !Ge.test(i))
506
506
  return !1;
507
507
  const e = i.indexOf("${"), t = i.lastIndexOf("${");
508
508
  return e === t;
509
509
  }
510
- function Qt(i) {
511
- return typeof i != "string" ? !1 : We.test(i) ? !0 : jt.test(i);
510
+ function Zt(i) {
511
+ return typeof i != "string" ? !1 : Ge.test(i) ? !0 : Yt.test(i);
512
512
  }
513
- function Yt(i) {
513
+ function Xt(i) {
514
514
  if (!G(i))
515
515
  throw new Error(`Invalid expression: ${i}`);
516
516
  return i.slice(2, -1);
517
517
  }
518
- async function qe(i, e, t) {
518
+ async function Je(i, e, t) {
519
519
  const n = `return await (${e});`;
520
520
  try {
521
521
  return await i.evaluate({ code: n, bindings: t });
522
522
  } catch (r) {
523
- throw new Ke(e, r);
523
+ throw new We(e, r);
524
524
  }
525
525
  }
526
- async function Zt(i, e, t) {
526
+ async function en(i, e, t) {
527
527
  let n = "", r = 0;
528
- for (const s of e.matchAll(Ge)) {
528
+ for (const s of e.matchAll(qe)) {
529
529
  const o = s[0], a = s[1], c = s.index ?? 0;
530
530
  n += e.slice(r, c);
531
- const l = await qe(
531
+ const l = await Je(
532
532
  i,
533
533
  a,
534
534
  t
@@ -537,7 +537,7 @@ async function Zt(i, e, t) {
537
537
  }
538
538
  return n += e.slice(r), n;
539
539
  }
540
- function Je({
540
+ function je({
541
541
  include: i,
542
542
  exclude: e = [],
543
543
  options: t
@@ -565,21 +565,21 @@ async function q(i) {
565
565
  if (l !== void 0) {
566
566
  if (typeof l == "string" && r(a)) {
567
567
  if (G(l)) {
568
- const h = Yt(l);
568
+ const h = Xt(l);
569
569
  o.gasMeter().chargeExpression(h);
570
- const p = await qe(
570
+ const p = await Je(
571
571
  e,
572
572
  h,
573
573
  n
574
574
  );
575
575
  return o.blue.jsonValueToNode(p ?? null);
576
- } else if (Qt(l)) {
577
- const h = new RegExp(Ge);
576
+ } else if (Zt(l)) {
577
+ const h = new RegExp(qe);
578
578
  let p = 0;
579
579
  for (h.lastIndex = 0; h.exec(l); )
580
580
  p += 1;
581
581
  o.gasMeter().chargeTemplate(p, l);
582
- const I = await Zt(
582
+ const I = await en(
583
583
  e,
584
584
  l,
585
585
  n
@@ -617,17 +617,17 @@ async function q(i) {
617
617
  }
618
618
  return c;
619
619
  }
620
- const le = et, _ = tt.merge(
620
+ const le = nt, _ = rt.merge(
621
621
  le
622
622
  ).extend({
623
623
  path: b.string().optional(),
624
624
  definition: V().optional()
625
- }), je = nt.merge(le), C = rt.merge(le), Xt = b.object({
625
+ }), Qe = it.merge(le), C = st.merge(le), tn = b.object({
626
626
  op: b.enum(["ADD", "REPLACE", "REMOVE"]),
627
627
  path: b.string(),
628
628
  val: V().optional()
629
- }), vi = pt("JsonPatch")(
630
- Xt
629
+ }), Ri = gt("JsonPatch")(
630
+ tn
631
631
  ).superRefine((i, e) => {
632
632
  i.op === "REMOVE" && i.val !== void 0 && e.addIssue({
633
633
  code: b.ZodIssueCode.custom,
@@ -638,32 +638,32 @@ const le = et, _ = tt.merge(
638
638
  message: `${i.op} operations must include a value`,
639
639
  path: ["val"]
640
640
  });
641
- }), en = it.merge(
641
+ }), nn = ot.merge(
642
642
  _
643
- ), tn = st.merge(
643
+ ), rn = at.merge(
644
644
  _
645
- ), nn = ot.merge(
645
+ ), sn = ct.merge(
646
646
  _
647
- ), rn = at.merge(_), sn = Et.merge(
647
+ ), on = lt.merge(_), an = wt.merge(
648
648
  _
649
- ), on = bt.merge(_), an = ct.merge(C).extend({
649
+ ), cn = It.merge(_), ln = ut.merge(C).extend({
650
650
  lastSignatures: b.record(b.string()).optional()
651
- }), cn = lt.merge(C), ln = ut.merge(
651
+ }), un = dt.merge(C), dn = ht.merge(
652
652
  C
653
- ), un = dt.merge(C), dn = z.merge(
653
+ ), hn = ft.merge(C), fn = z.merge(
654
654
  C
655
- ), hn = Ct.merge(C), fn = It.merge(
655
+ ), pn = vt.merge(C), mn = kt.merge(
656
656
  C
657
- ), pn = kt.merge(C), mn = vt.merge(C), gn = Tt.merge(
657
+ ), gn = Tt.merge(C), En = Rt.merge(C), yn = Pt.merge(
658
658
  C
659
- ), Ti = V(), En = yt.merge(je).extend({
659
+ ), Pi = V(), wn = St.merge(Qe).extend({
660
660
  steps: b.array(V()).optional()
661
- }), yn = wt.merge(
662
- je
661
+ }), Sn = bt.merge(
662
+ Qe
663
663
  ).extend({
664
664
  steps: b.array(V()).optional()
665
665
  });
666
- function wn(i) {
666
+ function bn(i) {
667
667
  if (!Array.isArray(i.blueIds) || i.blueIds.length === 0)
668
668
  throw new Error("Contract processors must declare at least one BlueId");
669
669
  for (const e of i.blueIds)
@@ -671,11 +671,11 @@ function wn(i) {
671
671
  throw new Error("Contract processor BlueIds must be non-empty strings");
672
672
  }
673
673
  function K(i, e) {
674
- wn(i);
674
+ bn(i);
675
675
  for (const t of i.blueIds)
676
676
  e.set(t, i);
677
677
  }
678
- class Sn {
678
+ class Cn {
679
679
  processorsByBlueId = /* @__PURE__ */ new Map();
680
680
  handlerProcessors = /* @__PURE__ */ new Map();
681
681
  channelProcessors = /* @__PURE__ */ new Map();
@@ -725,17 +725,27 @@ class Sn {
725
725
  }
726
726
  }
727
727
  function Ce(i, e) {
728
+ return e && i.isTypeOf(e, v, { checkSchemaExtensions: !0 }) ? i.nodeToSchemaOutput(e, v) : null;
729
+ }
730
+ function Ye(i, e, t) {
731
+ const n = Ce(i, e), r = Ce(i, t);
732
+ if (!n || !r)
733
+ return !0;
734
+ const s = n.timestamp, o = r.timestamp;
735
+ return typeof s != "number" || typeof o != "number" ? !0 : s >= o;
736
+ }
737
+ function Ie(i, e) {
728
738
  return i.isTypeOf(e, Ee) ? i.nodeToSchemaOutput(e, Ee) : i.isTypeOf(e, v) ? i.nodeToSchemaOutput(e, v) : null;
729
739
  }
730
- class bn {
740
+ class In {
731
741
  kind = "channel";
732
742
  blueIds = [D["MyOS Timeline Channel"]];
733
- schema = on;
743
+ schema = cn;
734
744
  matches(e, t) {
735
745
  const { event: n, blue: r } = t;
736
746
  if (!n)
737
747
  return !1;
738
- const s = Ce(r, n);
748
+ const s = Ie(r, n);
739
749
  if (!s)
740
750
  return !1;
741
751
  const o = s.timeline?.timelineId;
@@ -743,13 +753,17 @@ class bn {
743
753
  }
744
754
  channelize(e, t) {
745
755
  const { event: n, blue: r } = t;
746
- return !n || !Ce(r, n) ? null : n.clone();
756
+ return !n || !Ie(r, n) ? null : n.clone();
757
+ }
758
+ isNewerEvent(e, t, n) {
759
+ const { event: r, blue: s } = t;
760
+ return r ? Ye(s, r, n) : !0;
747
761
  }
748
762
  }
749
- class Cn {
763
+ class vn {
750
764
  kind = "channel";
751
765
  blueIds = [R["Timeline Channel"]];
752
- schema = sn;
766
+ schema = an;
753
767
  matches(e, t) {
754
768
  const { event: n, blue: r } = t;
755
769
  if (!n || !r.isTypeOf(n, v))
@@ -761,9 +775,13 @@ class Cn {
761
775
  const { event: n, blue: r } = t;
762
776
  return !n || !r.isTypeOf(n, v) ? null : n.clone();
763
777
  }
778
+ isNewerEvent(e, t, n) {
779
+ const { event: r, blue: s } = t;
780
+ return r ? Ye(s, r, n) : !0;
781
+ }
764
782
  }
765
783
  function ue(i) {
766
- const { context: e, eventNode: t, stepResults: n } = i, r = kn(e);
784
+ const { context: e, eventNode: t, stepResults: n } = i, r = Tn(e);
767
785
  return {
768
786
  event: e.blue.nodeToJson(t, "simple"),
769
787
  eventCanonical: e.blue.nodeToJson(t, "official"),
@@ -771,13 +789,13 @@ function ue(i) {
771
789
  document: r
772
790
  };
773
791
  }
774
- const In = /* @__PURE__ */ new Set(["blueId", "name", "description", "value"]);
775
- function kn(i) {
792
+ const kn = /* @__PURE__ */ new Set(["blueId", "name", "description", "value"]);
793
+ function Tn(i) {
776
794
  const e = (s) => {
777
795
  if (s === "/")
778
796
  return !1;
779
797
  const o = s.lastIndexOf("/"), a = s.substring(o + 1);
780
- return In.has(a);
798
+ return kn.has(a);
781
799
  }, t = (s) => {
782
800
  const o = s == null ? "/" : typeof s == "string" ? s : (() => {
783
801
  throw new TypeError("document() expects a string pointer");
@@ -790,7 +808,7 @@ function kn(i) {
790
808
  }, r = (s) => n(s, "simple");
791
809
  return r.canonical = (s) => n(s, "official"), r;
792
810
  }
793
- class vn {
811
+ class Rn {
794
812
  supportedBlueIds = [R["Trigger Event"]];
795
813
  evaluator = new ce();
796
814
  async execute(e) {
@@ -802,10 +820,10 @@ class vn {
802
820
  evaluator: this.evaluator,
803
821
  node: t,
804
822
  bindings: ue(e),
805
- shouldResolve: Je({
823
+ shouldResolve: je({
806
824
  include: ["/event", "/event/**"]
807
825
  }),
808
- shouldDescend: Tn(),
826
+ shouldDescend: Pn(),
809
827
  context: n
810
828
  }), o = n.blue.nodeToSchemaOutput(
811
829
  r,
@@ -818,14 +836,14 @@ class vn {
818
836
  n.emitEvent(o.clone());
819
837
  }
820
838
  }
821
- function Tn() {
822
- return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !Rn(e);
839
+ function Pn() {
840
+ return (i, e) => i === "/event" || !i.startsWith("/event/") ? !0 : !Nn(e);
823
841
  }
824
- function Rn(i) {
842
+ function Nn(i) {
825
843
  const e = i.getProperties?.();
826
844
  return e ? !!e.contracts : !1;
827
845
  }
828
- class Pn {
846
+ class Mn {
829
847
  supportedBlueIds = [R["JavaScript Code"]];
830
848
  evaluator = new ce();
831
849
  async execute(e) {
@@ -849,7 +867,7 @@ class Pn {
849
867
  });
850
868
  return this.handleEvents(c, t), c;
851
869
  } catch (c) {
852
- throw new Ke(o, c);
870
+ throw new We(o, c);
853
871
  }
854
872
  }
855
873
  handleEvents(e, t) {
@@ -863,7 +881,7 @@ class Pn {
863
881
  }
864
882
  }
865
883
  }
866
- class Nn {
884
+ class On {
867
885
  supportedBlueIds = [R["Update Document"]];
868
886
  evaluator = new ce();
869
887
  async execute(e) {
@@ -874,7 +892,7 @@ class Nn {
874
892
  evaluator: this.evaluator,
875
893
  node: n,
876
894
  bindings: ue(e),
877
- shouldResolve: Je({
895
+ shouldResolve: je({
878
896
  include: ["/changeset", "/changeset/**"]
879
897
  }),
880
898
  context: t
@@ -909,11 +927,11 @@ class Nn {
909
927
  }
910
928
  }
911
929
  const de = [
912
- new vn(),
913
- new Pn(),
914
- new Nn()
930
+ new Rn(),
931
+ new Mn(),
932
+ new On()
915
933
  ];
916
- class Qe {
934
+ class Ze {
917
935
  executorIndex;
918
936
  constructor(e = de) {
919
937
  const t = /* @__PURE__ */ new Map();
@@ -960,13 +978,13 @@ class Qe {
960
978
  return n && typeof n == "string" && n.length > 0 ? n : `Step${t + 1}`;
961
979
  }
962
980
  }
963
- class Mn {
981
+ class An {
964
982
  kind = "handler";
965
983
  blueIds = [R["Sequential Workflow"]];
966
- schema = En;
984
+ schema = wn;
967
985
  runner;
968
986
  constructor(e = de) {
969
- this.runner = new Qe(e);
987
+ this.runner = new Ze(e);
970
988
  }
971
989
  async matches(e, t) {
972
990
  const n = t.event();
@@ -977,12 +995,12 @@ class Mn {
977
995
  n && await this.runner.run({ workflow: e, eventNode: n, context: t });
978
996
  }
979
997
  }
980
- class An {
998
+ class Dn {
981
999
  kind = "marker";
982
1000
  blueIds = [R.Operation];
983
- schema = dn;
1001
+ schema = fn;
984
1002
  }
985
- function Ye(i) {
1003
+ function Xe(i) {
986
1004
  const e = i.channel;
987
1005
  if (typeof e == "string") {
988
1006
  const t = e.trim();
@@ -991,11 +1009,11 @@ function Ye(i) {
991
1009
  }
992
1010
  return null;
993
1011
  }
994
- function On(i, e) {
1012
+ function Bn(i, e) {
995
1013
  const t = i.getProperties()?.document;
996
1014
  return t instanceof d ? e.blue.calculateBlueIdSync(t) : null;
997
1015
  }
998
- function Dn(i, e) {
1016
+ function _n(i, e) {
999
1017
  if (e.isTypeOf(i, ne, {
1000
1018
  checkSchemaExtensions: !0
1001
1019
  }))
@@ -1011,11 +1029,11 @@ function Dn(i, e) {
1011
1029
  }
1012
1030
  return null;
1013
1031
  }
1014
- function Bn(i, e, t, n) {
1032
+ function Ln(i, e, t, n) {
1015
1033
  const { blue: r } = n, s = i.operation;
1016
1034
  return !(!s || t.operation !== s || i.event && !r.isTypeOfNode(e, i.event));
1017
1035
  }
1018
- function _n(i, e) {
1036
+ function $n(i, e) {
1019
1037
  const t = i.operation;
1020
1038
  if (!t)
1021
1039
  return null;
@@ -1025,13 +1043,13 @@ function _n(i, e) {
1025
1043
  const s = e.blue.nodeToSchemaOutput(
1026
1044
  r,
1027
1045
  z
1028
- ), o = Ye(s);
1046
+ ), o = Xe(s);
1029
1047
  return { operationNode: r, operation: s, channelKey: o };
1030
1048
  }
1031
- function Ln(i, e) {
1049
+ function xn(i, e) {
1032
1050
  return !(i && e && i !== e);
1033
1051
  }
1034
- function $n(i, e, t) {
1052
+ function Fn(i, e, t) {
1035
1053
  const n = i.getProperties()?.request, r = e.getProperties()?.request;
1036
1054
  if (!(n instanceof d) || !(r instanceof d))
1037
1055
  return !1;
@@ -1043,10 +1061,10 @@ function $n(i, e, t) {
1043
1061
  }
1044
1062
  return !0;
1045
1063
  }
1046
- function xn(i, e, t) {
1064
+ function zn(i, e, t) {
1047
1065
  if (!i || i.allowNewerVersion !== !1)
1048
1066
  return !0;
1049
- const n = On(e, t);
1067
+ const n = Bn(e, t);
1050
1068
  if (!n)
1051
1069
  return !0;
1052
1070
  const r = t.resolvePointer("/"), s = t.documentAt(r);
@@ -1055,15 +1073,15 @@ function xn(i, e, t) {
1055
1073
  const c = (s.getContracts()?.initialized ?? null)?.get("/documentId") ?? null, l = typeof c == "string" && c.length > 0 ? c : t.blue.calculateBlueIdSync(s);
1056
1074
  return n === l;
1057
1075
  }
1058
- class Fn {
1076
+ class Un {
1059
1077
  kind = "handler";
1060
1078
  blueIds = [
1061
1079
  R["Sequential Workflow Operation"]
1062
1080
  ];
1063
- schema = yn;
1081
+ schema = Sn;
1064
1082
  runner;
1065
1083
  constructor(e = de) {
1066
- this.runner = new Qe(e);
1084
+ this.runner = new Ze(e);
1067
1085
  }
1068
1086
  deriveChannel(e, t) {
1069
1087
  const n = e.operation;
@@ -1075,13 +1093,13 @@ class Fn {
1075
1093
  }))
1076
1094
  return null;
1077
1095
  const s = t.blue.nodeToSchemaOutput(r.node, z);
1078
- return s ? Ye(s) : null;
1096
+ return s ? Xe(s) : null;
1079
1097
  }
1080
1098
  async matches(e, t) {
1081
1099
  const n = t.event();
1082
1100
  if (!n)
1083
1101
  return !1;
1084
- const r = Dn(
1102
+ const r = _n(
1085
1103
  n,
1086
1104
  t.blue
1087
1105
  );
@@ -1091,17 +1109,17 @@ class Fn {
1091
1109
  r,
1092
1110
  ne
1093
1111
  );
1094
- if (!s || !Bn(e, n, s, t))
1112
+ if (!s || !Ln(e, n, s, t))
1095
1113
  return !1;
1096
- const o = _n(e, t);
1114
+ const o = $n(e, t);
1097
1115
  if (!o)
1098
1116
  return !1;
1099
1117
  const a = typeof e.channel == "string" ? e.channel.trim() : "", c = a.length > 0 ? a : null;
1100
- return !(!Ln(o.channelKey, c) || !$n(
1118
+ return !(!xn(o.channelKey, c) || !Fn(
1101
1119
  r,
1102
1120
  o.operationNode,
1103
1121
  t.blue
1104
- ) || s?.allowNewerVersion === !1 && !xn(s, r, t));
1122
+ ) || s?.allowNewerVersion === !1 && !zn(s, r, t));
1105
1123
  }
1106
1124
  async execute(e, t) {
1107
1125
  const n = t.event();
@@ -1118,11 +1136,11 @@ class Y {
1118
1136
  }
1119
1137
  static create() {
1120
1138
  return new Y(
1121
- new Sn()
1139
+ new Cn()
1122
1140
  );
1123
1141
  }
1124
1142
  registerDefaults() {
1125
- return this.registry.register(new bn()), this.registry.register(new Cn()), this.registry.register(new Mn()), this.registry.register(new An()), this.registry.register(new Fn()), this;
1143
+ return this.registry.register(new In()), this.registry.register(new vn()), this.registry.register(new An()), this.registry.register(new Dn()), this.registry.register(new Un()), this;
1126
1144
  }
1127
1145
  register(e) {
1128
1146
  return this.registry.register(e), this;
@@ -1132,10 +1150,10 @@ class Y {
1132
1150
  }
1133
1151
  }
1134
1152
  const se = m["Channel Event Checkpoint"];
1135
- function Ze(i) {
1153
+ function et(i) {
1136
1154
  return typeof i.order == "number" ? i.order : 0;
1137
1155
  }
1138
- class zn {
1156
+ class Vn {
1139
1157
  constructor(e, t, n) {
1140
1158
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1141
1159
  }
@@ -1149,10 +1167,10 @@ class zn {
1149
1167
  return this.bindingBlueId;
1150
1168
  }
1151
1169
  order() {
1152
- return Ze(this.bindingContract);
1170
+ return et(this.bindingContract);
1153
1171
  }
1154
1172
  }
1155
- class Un {
1173
+ class Hn {
1156
1174
  constructor(e, t, n) {
1157
1175
  this.bindingKey = e, this.bindingContract = t, this.bindingBlueId = n;
1158
1176
  }
@@ -1166,16 +1184,16 @@ class Un {
1166
1184
  return this.bindingBlueId;
1167
1185
  }
1168
1186
  order() {
1169
- return Ze(this.bindingContract);
1187
+ return et(this.bindingContract);
1170
1188
  }
1171
1189
  }
1172
- class O {
1190
+ class A {
1173
1191
  constructor(e, t, n, r, s) {
1174
1192
  this.channels = e, this.handlersByChannel = t, this.markerStore = n, this.embeddedPathsInternal = r, this.checkpointDeclared = s;
1175
1193
  }
1176
1194
  checkpointDeclared;
1177
1195
  static fromComponents(e, t, n, r, s) {
1178
- return new O(
1196
+ return new A(
1179
1197
  e,
1180
1198
  t,
1181
1199
  n,
@@ -1184,10 +1202,10 @@ class O {
1184
1202
  );
1185
1203
  }
1186
1204
  static builder() {
1187
- return new Vn();
1205
+ return new Kn();
1188
1206
  }
1189
1207
  static empty() {
1190
- return O.builder().build();
1208
+ return A.builder().build();
1191
1209
  }
1192
1210
  markers() {
1193
1211
  return new Map(
@@ -1226,7 +1244,7 @@ class O {
1226
1244
  handlersFor(e) {
1227
1245
  const t = this.handlersByChannel.get(e);
1228
1246
  return !t || t.length === 0 ? [] : [...t].map(
1229
- (n) => new Un(n.key, n.contract, n.blueId)
1247
+ (n) => new Hn(n.key, n.contract, n.blueId)
1230
1248
  ).sort((n, r) => {
1231
1249
  const s = n.order() - r.order();
1232
1250
  return s !== 0 ? s : n.key().localeCompare(r.key());
@@ -1234,7 +1252,7 @@ class O {
1234
1252
  }
1235
1253
  channelsOfType(...e) {
1236
1254
  const t = e.length > 0 ? new Set(e) : null, n = Array.from(this.channels.values()).filter((r) => !t || t.has(r.blueId)).map(
1237
- (r) => new zn(r.key, r.contract, r.blueId)
1255
+ (r) => new Vn(r.key, r.contract, r.blueId)
1238
1256
  );
1239
1257
  return n.sort((r, s) => {
1240
1258
  const o = r.order() - s.order();
@@ -1242,7 +1260,7 @@ class O {
1242
1260
  }), n;
1243
1261
  }
1244
1262
  }
1245
- class Vn {
1263
+ class Kn {
1246
1264
  channels = /* @__PURE__ */ new Map();
1247
1265
  handlersByChannel = /* @__PURE__ */ new Map();
1248
1266
  markerStore = /* @__PURE__ */ new Map();
@@ -1285,7 +1303,7 @@ class Vn {
1285
1303
  return this.markerStore.set(e, { key: e, contract: t, blueId: n }), this;
1286
1304
  }
1287
1305
  build() {
1288
- return O.fromComponents(
1306
+ return A.fromComponents(
1289
1307
  new Map(this.channels),
1290
1308
  new Map(
1291
1309
  Array.from(this.handlersByChannel.entries(), ([e, t]) => [
@@ -1304,7 +1322,7 @@ class g extends Error {
1304
1322
  super(e || "Processor fatal error"), this.processorError = t, this.name = "ProcessorFatalError";
1305
1323
  }
1306
1324
  }
1307
- class Hn {
1325
+ class Wn {
1308
1326
  constructor(e, t, n) {
1309
1327
  this.blue = e, this.registry = t, this.builtinChannelSchemas = n;
1310
1328
  }
@@ -1393,7 +1411,7 @@ class Hn {
1393
1411
  return this.builtinChannelSchemas.has(e) ? !0 : this.registry.lookupChannel(e) != null;
1394
1412
  }
1395
1413
  isZodError(e) {
1396
- return e instanceof Ne;
1414
+ return e instanceof Me;
1397
1415
  }
1398
1416
  }
1399
1417
  class U extends Error {
@@ -1401,15 +1419,7 @@ class U extends Error {
1401
1419
  super(e ?? "MustUnderstand failure"), this.name = "MustUnderstandFailure";
1402
1420
  }
1403
1421
  }
1404
- const Kn = m["Document Update Channel"], Wn = m["Embedded Node Channel"], Gn = m["Lifecycle Event Channel"], qn = m["Triggered Event Channel"], Ie = m["Process Embedded"], Jn = m["Processing Initialized Marker"], jn = m["Processing Terminated Marker"], Qn = m["Channel Event Checkpoint"], Yn = D["Document Anchors"], Zn = D["Document Links"], Xn = D["MyOS Participants Orchestration"], er = D["MyOS Session Interaction"], tr = D["MyOS Worker Agency"], ke = /* @__PURE__ */ new Map([
1405
- [
1406
- Kn,
1407
- en
1408
- ],
1409
- [
1410
- Wn,
1411
- tn
1412
- ],
1422
+ const Gn = m["Document Update Channel"], qn = m["Embedded Node Channel"], Jn = m["Lifecycle Event Channel"], jn = m["Triggered Event Channel"], ve = m["Process Embedded"], Qn = m["Processing Initialized Marker"], Yn = m["Processing Terminated Marker"], Zn = m["Channel Event Checkpoint"], Xn = D["Document Anchors"], er = D["Document Links"], tr = D["MyOS Participants Orchestration"], nr = D["MyOS Session Interaction"], rr = D["MyOS Worker Agency"], ke = /* @__PURE__ */ new Map([
1413
1423
  [
1414
1424
  Gn,
1415
1425
  nn
@@ -1417,19 +1427,19 @@ const Kn = m["Document Update Channel"], Wn = m["Embedded Node Channel"], Gn = m
1417
1427
  [
1418
1428
  qn,
1419
1429
  rn
1420
- ]
1421
- ]), nr = /* @__PURE__ */ new Map([
1430
+ ],
1422
1431
  [
1423
1432
  Jn,
1424
- cn
1433
+ sn
1425
1434
  ],
1426
1435
  [
1427
1436
  jn,
1428
- un
1429
- ],
1437
+ on
1438
+ ]
1439
+ ]), ir = /* @__PURE__ */ new Map([
1430
1440
  [
1431
1441
  Qn,
1432
- an
1442
+ un
1433
1443
  ],
1434
1444
  [
1435
1445
  Yn,
@@ -1437,7 +1447,7 @@ const Kn = m["Document Update Channel"], Wn = m["Embedded Node Channel"], Gn = m
1437
1447
  ],
1438
1448
  [
1439
1449
  Zn,
1440
- fn
1450
+ ln
1441
1451
  ],
1442
1452
  [
1443
1453
  Xn,
@@ -1450,11 +1460,19 @@ const Kn = m["Document Update Channel"], Wn = m["Embedded Node Channel"], Gn = m
1450
1460
  [
1451
1461
  tr,
1452
1462
  gn
1463
+ ],
1464
+ [
1465
+ nr,
1466
+ En
1467
+ ],
1468
+ [
1469
+ rr,
1470
+ yn
1453
1471
  ]
1454
1472
  ]);
1455
- class rr {
1473
+ class sr {
1456
1474
  constructor(e, t) {
1457
- this.registry = e, this.blue = t, this.handlerRegistration = new Hn(
1475
+ this.registry = e, this.blue = t, this.handlerRegistration = new Wn(
1458
1476
  this.blue,
1459
1477
  this.registry,
1460
1478
  ke
@@ -1463,7 +1481,7 @@ class rr {
1463
1481
  handlerRegistration;
1464
1482
  load(e, t) {
1465
1483
  try {
1466
- const n = O.builder(), r = e.getContracts();
1484
+ const n = A.builder(), r = e.getContracts();
1467
1485
  if (!r)
1468
1486
  return n.build();
1469
1487
  const s = this.buildScopeContractsIndex(r);
@@ -1487,11 +1505,11 @@ class rr {
1487
1505
  const s = n.getType()?.getBlueId();
1488
1506
  if (!s)
1489
1507
  return;
1490
- if (s === Ie) {
1508
+ if (s === ve) {
1491
1509
  this.handleProcessEmbedded(e, t, n);
1492
1510
  return;
1493
1511
  }
1494
- const o = nr.get(s);
1512
+ const o = ir.get(s);
1495
1513
  if (o) {
1496
1514
  this.handleMarker(e, t, n, o, s);
1497
1515
  return;
@@ -1548,14 +1566,14 @@ class rr {
1548
1566
  try {
1549
1567
  const r = this.convert(
1550
1568
  n,
1551
- ln
1569
+ dn
1552
1570
  );
1553
1571
  e.setEmbedded(r);
1554
1572
  } catch (r) {
1555
1573
  throw ee(r) ? new g(
1556
1574
  "Failed to parse ProcessEmbedded marker",
1557
1575
  E.invalidContract(
1558
- Ie,
1576
+ ve,
1559
1577
  "Failed to parse ProcessEmbedded marker",
1560
1578
  t,
1561
1579
  r
@@ -1627,26 +1645,26 @@ class rr {
1627
1645
  }
1628
1646
  }
1629
1647
  function ee(i) {
1630
- return i instanceof Ne;
1648
+ return i instanceof Me;
1631
1649
  }
1632
- const ir = m["Channel Event Checkpoint"];
1633
- function sr(i) {
1650
+ const or = m["Channel Event Checkpoint"];
1651
+ function ar(i) {
1634
1652
  return i.jsonValueToNode({
1635
- type: { blueId: ir },
1653
+ type: { blueId: or },
1636
1654
  lastEvents: {},
1637
1655
  lastSignatures: {}
1638
1656
  });
1639
1657
  }
1640
- function or() {
1658
+ function cr() {
1641
1659
  return {
1642
1660
  lastEvents: {},
1643
1661
  lastSignatures: {}
1644
1662
  };
1645
1663
  }
1646
- function ve(i) {
1664
+ function Te(i) {
1647
1665
  return i != null && Object.prototype.hasOwnProperty.call(i, "lastEvents") && Object.prototype.hasOwnProperty.call(i, "lastSignatures");
1648
1666
  }
1649
- class ar {
1667
+ class lr {
1650
1668
  constructor(e, t, n, r, s) {
1651
1669
  this.markerKey = e, this.checkpoint = t, this.channelKey = n, this.lastEventNode = r, this.lastEventSignature = s;
1652
1670
  }
@@ -1656,28 +1674,28 @@ class ar {
1656
1674
  return e != null && e === this.lastEventSignature;
1657
1675
  }
1658
1676
  }
1659
- class cr {
1677
+ class ur {
1660
1678
  constructor(e, t) {
1661
1679
  this.runtime = e, this.signatureFn = t;
1662
1680
  }
1663
1681
  ensureCheckpointMarker(e, t) {
1664
- const n = t.marker(T), r = w(e, Le);
1682
+ const n = t.marker(T), r = w(e, $e);
1665
1683
  if (!n) {
1666
- const s = sr(this.runtime.blue());
1667
- this.runtime.directWrite(r, s), t.registerCheckpointMarker(or());
1684
+ const s = ar(this.runtime.blue());
1685
+ this.runtime.directWrite(r, s), t.registerCheckpointMarker(cr());
1668
1686
  return;
1669
1687
  }
1670
- if (!ve(n))
1688
+ if (!Te(n))
1671
1689
  throw new Error(
1672
1690
  `Reserved key 'checkpoint' must contain a Channel Event Checkpoint at ${r}`
1673
1691
  );
1674
1692
  }
1675
1693
  findCheckpoint(e, t) {
1676
1694
  for (const [n, r] of e.markerEntries()) {
1677
- if (!ve(r))
1695
+ if (!Te(r))
1678
1696
  continue;
1679
1697
  const o = (r.lastEvents?.[t] ?? null)?.clone() ?? null, c = r.lastSignatures?.[t] ?? null ?? this.signatureFn(o);
1680
- return new ar(
1698
+ return new lr(
1681
1699
  n,
1682
1700
  r,
1683
1701
  t,
@@ -1695,17 +1713,17 @@ class cr {
1695
1713
  return;
1696
1714
  const o = w(
1697
1715
  e,
1698
- Fe(n.markerKey, n.channelKey)
1716
+ ze(n.markerKey, n.channelKey)
1699
1717
  ), a = s?.clone() ?? null;
1700
1718
  this.runtime.gasMeter().chargeCheckpointUpdate(), this.runtime.directWrite(o, a), n.checkpoint.lastEvents || (n.checkpoint.lastEvents = {}), a ? n.checkpoint.lastEvents[n.channelKey] = a.clone() ?? null : delete n.checkpoint.lastEvents[n.channelKey], n.lastEventNode = a?.clone() ?? null;
1701
1719
  const c = w(
1702
1720
  e,
1703
- ze(n.markerKey, n.channelKey)
1721
+ Ue(n.markerKey, n.channelKey)
1704
1722
  ), l = r == null ? null : new d().setValue(r);
1705
1723
  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;
1706
1724
  }
1707
1725
  }
1708
- class lr {
1726
+ class dr {
1709
1727
  constructor(e, t, n) {
1710
1728
  this.runtime = e, this.checkpointManager = t, this.deps = n;
1711
1729
  }
@@ -1727,7 +1745,13 @@ class lr {
1727
1745
  t,
1728
1746
  n.key()
1729
1747
  ), l = o.eventId ?? this.deps.canonicalSignature(s);
1730
- this.checkpointManager.isDuplicate(c, l) || (await this.runHandlers(
1748
+ this.checkpointManager.isDuplicate(c, l) || !await this.shouldProcessRelativeToCheckpoint(
1749
+ e,
1750
+ t,
1751
+ n,
1752
+ s,
1753
+ c
1754
+ ) || (await this.runHandlers(
1731
1755
  e,
1732
1756
  t,
1733
1757
  n.key(),
@@ -1764,11 +1788,30 @@ class lr {
1764
1788
  }
1765
1789
  }
1766
1790
  }
1791
+ async shouldProcessRelativeToCheckpoint(e, t, n, r, s) {
1792
+ if (!s?.lastEventNode)
1793
+ return !0;
1794
+ const o = this.deps.channelProcessorFor(n.blueId());
1795
+ if (!o || typeof o.isNewerEvent != "function")
1796
+ return !0;
1797
+ const a = {
1798
+ scopePath: e,
1799
+ blue: this.runtime.blue(),
1800
+ event: r.clone(),
1801
+ markers: t.markers(),
1802
+ bindingKey: n.key()
1803
+ };
1804
+ return await o.isNewerEvent(
1805
+ n.contract(),
1806
+ a,
1807
+ s.lastEventNode.clone()
1808
+ );
1809
+ }
1767
1810
  }
1768
- function ur(i, e) {
1811
+ function hr(i, e) {
1769
1812
  return e.isResolved() ? i.createResolvedNode(e) : i.resolve(e);
1770
1813
  }
1771
- class A extends g {
1814
+ class O extends g {
1772
1815
  constructor(e) {
1773
1816
  super(e, E.illegalState(e)), this.name = "IllegalStateException";
1774
1817
  }
@@ -1778,8 +1821,8 @@ class N extends Error {
1778
1821
  super(e), this.name = "BoundaryViolationException";
1779
1822
  }
1780
1823
  }
1781
- const dr = m["Document Update Channel"], hr = m["Embedded Node Channel"], fr = m["Triggered Event Channel"], pr = m["Lifecycle Event Channel"], Te = m["Processing Initialized Marker"], mr = m["Document Processing Initiated"];
1782
- class gr {
1824
+ const fr = m["Document Update Channel"], pr = m["Embedded Node Channel"], mr = m["Triggered Event Channel"], gr = m["Lifecycle Event Channel"], Re = m["Processing Initialized Marker"], Er = m["Document Processing Initiated"];
1825
+ class yr {
1783
1826
  runtime;
1784
1827
  contractLoader;
1785
1828
  channelRunner;
@@ -1811,7 +1854,7 @@ class gr {
1811
1854
  return;
1812
1855
  const a = this.hasInitializationMarker(n);
1813
1856
  if (!a && s.hasCheckpoint())
1814
- throw new A(
1857
+ throw new O(
1815
1858
  `Reserved key 'checkpoint' must not appear before initialization at scope ${n}`
1816
1859
  );
1817
1860
  if (a)
@@ -1830,7 +1873,7 @@ class gr {
1830
1873
  const t = y(e);
1831
1874
  if (this.bundles.has(t))
1832
1875
  return;
1833
- const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : O.empty();
1876
+ const n = this.nodeAt(t), r = n ? this.loadBundle(n, t) : A.empty();
1834
1877
  this.bundles.set(t, r);
1835
1878
  for (const s of r.embeddedPaths()) {
1836
1879
  const o = w(t, s);
@@ -1838,7 +1881,7 @@ class gr {
1838
1881
  }
1839
1882
  }
1840
1883
  async processExternalEvent(e, t) {
1841
- const n = ur(this.runtime.blue(), t);
1884
+ const n = hr(this.runtime.blue(), t);
1842
1885
  await this.processPreparedExternalEvent(e, n);
1843
1886
  }
1844
1887
  async processPreparedExternalEvent(e, t) {
@@ -1904,7 +1947,7 @@ class gr {
1904
1947
  if (!a || this.hooks.isScopeInactive(o))
1905
1948
  continue;
1906
1949
  const c = this.createDocumentUpdateEvent(s, o), l = a.channelsOfType(
1907
- dr
1950
+ fr
1908
1951
  );
1909
1952
  for (const u of l) {
1910
1953
  const f = u.contract();
@@ -1928,7 +1971,7 @@ class gr {
1928
1971
  await this.hooks.enterFatalTermination(e, t, o);
1929
1972
  return;
1930
1973
  }
1931
- if (s instanceof A || s instanceof Error && !(s instanceof g)) {
1974
+ if (s instanceof O || s instanceof Error && !(s instanceof g)) {
1932
1975
  const o = this.hooks.fatalReason(s, "Runtime fatal");
1933
1976
  await this.hooks.enterFatalTermination(e, t, o);
1934
1977
  return;
@@ -1941,7 +1984,7 @@ class gr {
1941
1984
  if (this.runtime.gasMeter().chargeLifecycleDelivery(), await this.hooks.recordLifecycleForBridging(e, n), !t)
1942
1985
  return;
1943
1986
  const s = t.channelsOfType(
1944
- pr
1987
+ gr
1945
1988
  );
1946
1989
  for (const o of s)
1947
1990
  if (await this.channelRunner.runHandlers(
@@ -2003,7 +2046,7 @@ class gr {
2003
2046
  }
2004
2047
  }
2005
2048
  async addInitializationMarker(e, t) {
2006
- const n = new d().setType(new d().setBlueId(Te)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(ie);
2049
+ const n = new d().setType(new d().setBlueId(Re)).addProperty("documentId", new d().setValue(t)), r = e.resolvePointer(ie);
2007
2050
  await e.applyPatch({
2008
2051
  op: "ADD",
2009
2052
  path: r,
@@ -2017,7 +2060,7 @@ class gr {
2017
2060
  if (this.hooks.isScopeInactive(e) || t.embeddedPaths().length === 0)
2018
2061
  return;
2019
2062
  const n = t.channelsOfType(
2020
- hr
2063
+ pr
2021
2064
  );
2022
2065
  if (n.length !== 0)
2023
2066
  for (const r of t.embeddedPaths()) {
@@ -2042,7 +2085,7 @@ class gr {
2042
2085
  if (this.hooks.isScopeInactive(e))
2043
2086
  return;
2044
2087
  const n = this.runtime.scope(e), r = t.channelsOfType(
2045
- fr
2088
+ mr
2046
2089
  );
2047
2090
  if (r.length === 0) {
2048
2091
  n.clearTriggered();
@@ -2119,16 +2162,16 @@ class gr {
2119
2162
  return !1;
2120
2163
  if (!(n instanceof d)) {
2121
2164
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2122
- throw new A(s);
2165
+ throw new O(s);
2123
2166
  }
2124
- if (n.getType()?.getBlueId() !== Te) {
2167
+ if (n.getType()?.getBlueId() !== Re) {
2125
2168
  const s = `Reserved key 'initialized' must contain a Processing Initialized Marker at ${t}`;
2126
- throw new A(s);
2169
+ throw new O(s);
2127
2170
  }
2128
2171
  return !0;
2129
2172
  }
2130
2173
  createLifecycleEvent(e) {
2131
- return new d().setType(new d().setBlueId(mr)).setProperties({
2174
+ return new d().setType(new d().setBlueId(Er)).setProperties({
2132
2175
  type: new d().setValue("Document Processing Initiated"),
2133
2176
  documentId: new d().setValue(e)
2134
2177
  });
@@ -2141,19 +2184,19 @@ class J extends Error {
2141
2184
  ), this.fatal = e, this.name = "RunTerminationError";
2142
2185
  }
2143
2186
  }
2144
- const Er = m["Processing Terminated Marker"], yr = m["Document Processing Terminated"];
2145
- class wr {
2187
+ const wr = m["Processing Terminated Marker"], Sr = m["Document Processing Terminated"];
2188
+ class br {
2146
2189
  constructor(e) {
2147
2190
  this.runtime = e;
2148
2191
  }
2149
2192
  async terminateScope(e, t, n, r, s) {
2150
2193
  e.recordPendingTermination(t, r, s ?? null);
2151
- const o = e.normalizeScope(t), a = w(o, _e);
2194
+ const o = e.normalizeScope(t), a = w(o, Le);
2152
2195
  this.runtime.directWrite(
2153
2196
  a,
2154
- Sr(this.runtime.blue(), r, s)
2197
+ Cr(this.runtime.blue(), r, s)
2155
2198
  ), this.runtime.gasMeter().chargeTerminationMarker();
2156
- const c = n ?? e.bundleForScope(o) ?? null, l = br(r, s);
2199
+ const c = n ?? e.bundleForScope(o) ?? null, l = Ir(r, s);
2157
2200
  if (await e.deliverLifecycle(
2158
2201
  o,
2159
2202
  c,
@@ -2165,32 +2208,32 @@ class wr {
2165
2208
  throw this.runtime.markRunTerminated(), new J(!1);
2166
2209
  }
2167
2210
  }
2168
- function Sr(i, e, t) {
2169
- return Cr(i, {
2170
- type: { blueId: Er },
2211
+ function Cr(i, e, t) {
2212
+ return vr(i, {
2213
+ type: { blueId: wr },
2171
2214
  cause: e === "GRACEFUL" ? "graceful" : "fatal",
2172
2215
  ...t ? { reason: t } : {}
2173
2216
  });
2174
2217
  }
2175
- function br(i, e) {
2218
+ function Ir(i, e) {
2176
2219
  const t = new d().setType(
2177
- new d().setBlueId(yr)
2220
+ new d().setBlueId(Sr)
2178
2221
  );
2179
2222
  return t.addProperty(
2180
2223
  "cause",
2181
2224
  new d().setValue(i === "GRACEFUL" ? "graceful" : "fatal")
2182
2225
  ), e && t.addProperty("reason", new d().setValue(e)), t;
2183
2226
  }
2184
- function Cr(i, e) {
2227
+ function vr(i, e) {
2185
2228
  return i.jsonValueToNode(e);
2186
2229
  }
2187
2230
  const F = "-";
2188
- class Ir {
2231
+ class kr {
2189
2232
  constructor(e) {
2190
2233
  this.document = e;
2191
2234
  }
2192
2235
  applyPatch(e, t) {
2193
- const n = y(e), r = S(t.path), s = Pe(r), o = Re(this.document, s, "before", r);
2236
+ const n = y(e), r = S(t.path), s = Ne(r), o = Pe(this.document, s, "before", r);
2194
2237
  switch (t.op) {
2195
2238
  case "ADD":
2196
2239
  this.applyAdd(s, r, t.val ?? null);
@@ -2202,21 +2245,21 @@ class Ir {
2202
2245
  this.applyRemove(s, r);
2203
2246
  break;
2204
2247
  }
2205
- const a = t.op === "REMOVE" ? null : Re(this.document, s, "after", r);
2248
+ const a = t.op === "REMOVE" ? null : Pe(this.document, s, "after", r);
2206
2249
  return {
2207
2250
  path: r,
2208
2251
  before: o,
2209
2252
  after: a,
2210
2253
  op: t.op.toLowerCase(),
2211
2254
  originScope: n,
2212
- cascadeScopes: kr(n)
2255
+ cascadeScopes: Tr(n)
2213
2256
  };
2214
2257
  }
2215
2258
  directWrite(e, t) {
2216
2259
  const n = S(e);
2217
2260
  if (n === "/")
2218
2261
  throw new Error("Direct write cannot target root document");
2219
- const r = Pe(n), { parent: s, leaf: o } = this.resolveParent(r);
2262
+ const r = Ne(n), { parent: s, leaf: o } = this.resolveParent(r);
2220
2263
  if (o === F)
2221
2264
  throw new Error(
2222
2265
  `Direct write does not support append token '-' for path ${n}`
@@ -2410,7 +2453,7 @@ class Ir {
2410
2453
  }
2411
2454
  }
2412
2455
  }
2413
- function kr(i) {
2456
+ function Tr(i) {
2414
2457
  const e = [];
2415
2458
  let t = i;
2416
2459
  for (; e.push(t), t !== "/"; ) {
@@ -2419,26 +2462,26 @@ function kr(i) {
2419
2462
  }
2420
2463
  return e;
2421
2464
  }
2422
- function Re(i, e, t, n) {
2465
+ function Pe(i, e, t, n) {
2423
2466
  try {
2424
2467
  if (e.length === 0)
2425
2468
  return i.clone();
2426
- const r = vr(i, e, t, n);
2469
+ const r = Rr(i, e, t, n);
2427
2470
  return r ? r.clone() : null;
2428
2471
  } catch {
2429
2472
  return null;
2430
2473
  }
2431
2474
  }
2432
- function vr(i, e, t, n) {
2475
+ function Rr(i, e, t, n) {
2433
2476
  let r = i;
2434
2477
  for (let s = 0; s < e.length; s += 1) {
2435
2478
  const o = e[s] ?? "", a = s === e.length - 1;
2436
- if (r = Tr(r, o, a, t, n), !r)
2479
+ if (r = Pr(r, o, a, t, n), !r)
2437
2480
  return null;
2438
2481
  }
2439
2482
  return r;
2440
2483
  }
2441
- function Tr(i, e, t, n, r) {
2484
+ function Pr(i, e, t, n, r) {
2442
2485
  if (!i)
2443
2486
  return null;
2444
2487
  const s = i.getItems();
@@ -2457,7 +2500,7 @@ function Tr(i, e, t, n, r) {
2457
2500
  const a = o[e];
2458
2501
  return a instanceof d ? a : null;
2459
2502
  }
2460
- function Pe(i) {
2503
+ function Ne(i) {
2461
2504
  if (i === "/" || i === "")
2462
2505
  return [];
2463
2506
  const e = i.startsWith("/") ? i.slice(1) : i;
@@ -2499,7 +2542,7 @@ function M(i) {
2499
2542
  function $(i) {
2500
2543
  return i == null ? new d().setValue(null) : i.clone();
2501
2544
  }
2502
- class Rr {
2545
+ class Nr {
2503
2546
  constructor(e) {
2504
2547
  this.path = e;
2505
2548
  }
@@ -2561,7 +2604,7 @@ class Rr {
2561
2604
  return this.cutOff;
2562
2605
  }
2563
2606
  }
2564
- class Pr {
2607
+ class Mr {
2565
2608
  scopesMap = /* @__PURE__ */ new Map();
2566
2609
  rootEmissionList = [];
2567
2610
  scopes() {
@@ -2569,7 +2612,7 @@ class Pr {
2569
2612
  }
2570
2613
  scope(e) {
2571
2614
  let t = this.scopesMap.get(e);
2572
- return t || (t = new Rr(e), this.scopesMap.set(e, t)), t;
2615
+ return t || (t = new Nr(e), this.scopesMap.set(e, t)), t;
2573
2616
  }
2574
2617
  existingScope(e) {
2575
2618
  return this.scopesMap.get(e);
@@ -2593,39 +2636,39 @@ function H(i) {
2593
2636
  function he(i) {
2594
2637
  return new TextEncoder().encode(i).length;
2595
2638
  }
2596
- function Nr(i) {
2639
+ function Or(i) {
2597
2640
  const e = S(i);
2598
2641
  return e === "/" ? 0 : e.split("/").length - 1;
2599
2642
  }
2600
- function Mr(i) {
2643
+ function Ar(i) {
2601
2644
  return 100 + H(he(i));
2602
2645
  }
2603
- function Ar(i) {
2646
+ function Dr(i) {
2604
2647
  return 40 + 5 * Math.max(0, i);
2605
2648
  }
2606
- function Or(i) {
2649
+ function Br(i) {
2607
2650
  return 5 + H(he(i));
2608
2651
  }
2609
- function Dr(i, e) {
2652
+ function _r(i, e) {
2610
2653
  return 3 * Math.max(0, i) + H(he(e));
2611
2654
  }
2612
- function Br(i, e) {
2613
- return 8 + Nr(i) + H(e);
2655
+ function Lr(i, e) {
2656
+ return 8 + Or(i) + H(e);
2614
2657
  }
2615
- const _r = 1e3, Lr = 5, $r = 50, xr = 2, Fr = 10, zr = 10, Ur = 10, Vr = 20, Hr = 20, Kr = 30, Wr = 30, Gr = 100;
2616
- function qr(i) {
2658
+ const $r = 1e3, xr = 5, Fr = 50, zr = 2, Ur = 10, Vr = 10, Hr = 10, Kr = 20, Wr = 20, Gr = 30, qr = 30, Jr = 100;
2659
+ function jr(i) {
2617
2660
  return 50 + 10 * i;
2618
2661
  }
2619
- function Jr(i) {
2662
+ function Qr(i) {
2620
2663
  return 20 + i;
2621
2664
  }
2622
- function jr(i) {
2665
+ function Yr(i) {
2623
2666
  return 10 * i;
2624
2667
  }
2625
- function Qr(i) {
2668
+ function Zr(i) {
2626
2669
  return 20 + i;
2627
2670
  }
2628
- class Yr {
2671
+ class Xr {
2629
2672
  constructor(e) {
2630
2673
  this.blue = e;
2631
2674
  }
@@ -2637,68 +2680,68 @@ class Yr {
2637
2680
  this.total += e;
2638
2681
  }
2639
2682
  chargeScopeEntry(e) {
2640
- this.add(qr(this.scopeDepth(e)));
2683
+ this.add(jr(this.scopeDepth(e)));
2641
2684
  }
2642
2685
  chargeInitialization() {
2643
- this.add(_r);
2686
+ this.add($r);
2644
2687
  }
2645
2688
  chargeChannelMatchAttempt() {
2646
- this.add(Lr);
2689
+ this.add(xr);
2647
2690
  }
2648
2691
  chargeHandlerOverhead() {
2649
- this.add($r);
2692
+ this.add(Fr);
2650
2693
  }
2651
2694
  chargeBoundaryCheck() {
2652
- this.add(xr);
2695
+ this.add(zr);
2653
2696
  }
2654
2697
  chargePatchAddOrReplace(e) {
2655
- this.add(Jr(this.payloadSizeCharge(e)));
2698
+ this.add(Qr(this.payloadSizeCharge(e)));
2656
2699
  }
2657
2700
  chargePatchRemove() {
2658
- this.add(Fr);
2701
+ this.add(Ur);
2659
2702
  }
2660
2703
  chargeCascadeRouting(e) {
2661
- e > 0 && this.add(jr(e));
2704
+ e > 0 && this.add(Yr(e));
2662
2705
  }
2663
2706
  chargeEmitEvent(e) {
2664
- this.add(Qr(this.payloadSizeCharge(e)));
2707
+ this.add(Zr(this.payloadSizeCharge(e)));
2665
2708
  }
2666
2709
  chargeBridge() {
2667
- this.add(zr);
2710
+ this.add(Vr);
2668
2711
  }
2669
2712
  chargeDrainEvent() {
2670
- this.add(Ur);
2713
+ this.add(Hr);
2671
2714
  }
2672
2715
  chargeCheckpointUpdate() {
2673
- this.add(Vr);
2716
+ this.add(Kr);
2674
2717
  }
2675
2718
  chargeTerminationMarker() {
2676
- this.add(Hr);
2719
+ this.add(Wr);
2677
2720
  }
2678
2721
  chargeLifecycleDelivery() {
2679
- this.add(Kr);
2722
+ this.add(Gr);
2680
2723
  }
2681
2724
  chargeFatalTerminationOverhead() {
2682
- this.add(Gr);
2725
+ this.add(Jr);
2683
2726
  }
2684
2727
  chargeJavaScriptCodeBase(e) {
2685
- this.add(Mr(e));
2728
+ this.add(Ar(e));
2686
2729
  }
2687
2730
  chargeTriggerEventBase() {
2688
- this.add(Wr);
2731
+ this.add(qr);
2689
2732
  }
2690
2733
  chargeUpdateDocumentBase(e) {
2691
- this.add(Ar(e));
2734
+ this.add(Dr(e));
2692
2735
  }
2693
2736
  chargeExpression(e) {
2694
- this.add(Or(e));
2737
+ this.add(Br(e));
2695
2738
  }
2696
2739
  chargeTemplate(e, t) {
2697
- this.add(Dr(e, t));
2740
+ this.add(_r(e, t));
2698
2741
  }
2699
2742
  chargeDocumentSnapshot(e, t) {
2700
2743
  const n = t ? Se(this.blue, t) : 0;
2701
- this.add(Br(e, n));
2744
+ this.add(Lr(e, n));
2702
2745
  }
2703
2746
  payloadSizeCharge(e) {
2704
2747
  if (!e)
@@ -2716,12 +2759,12 @@ class Yr {
2716
2759
  return n;
2717
2760
  }
2718
2761
  }
2719
- class Zr {
2762
+ class ei {
2720
2763
  constructor(e, t) {
2721
- this.documentRef = e, this.blueRef = t, this.patchEngine = new Ir(this.documentRef), this.meter = new Yr(this.blueRef);
2764
+ this.documentRef = e, this.blueRef = t, this.patchEngine = new kr(this.documentRef), this.meter = new Xr(this.blueRef);
2722
2765
  }
2723
2766
  patchEngine;
2724
- emissionRegistry = new Pr();
2767
+ emissionRegistry = new Mr();
2725
2768
  meter;
2726
2769
  runTerminated = !1;
2727
2770
  document() {
@@ -2770,15 +2813,15 @@ class Zr {
2770
2813
  return this.patchEngine.applyPatch(e, t);
2771
2814
  }
2772
2815
  }
2773
- const Xr = m["Processing Initialized Marker"], ei = m["Document Update"];
2774
- class ti {
2816
+ const ti = m["Processing Initialized Marker"], ni = m["Document Update"];
2817
+ class ri {
2775
2818
  constructor(e, t, n, r) {
2776
- this.contractLoader = e, this.registry = t, this.runtimeRef = new Zr(r, n);
2777
- const s = (o) => Ve(this.runtimeRef.blue(), o);
2778
- this.checkpointManager = new cr(
2819
+ this.contractLoader = e, this.registry = t, this.runtimeRef = new ei(r, n);
2820
+ const s = (o) => He(this.runtimeRef.blue(), o);
2821
+ this.checkpointManager = new ur(
2779
2822
  this.runtimeRef,
2780
2823
  s
2781
- ), this.terminationService = new wr(this.runtimeRef), this.channelRunner = new lr(
2824
+ ), this.terminationService = new br(this.runtimeRef), this.channelRunner = new dr(
2782
2825
  this.runtimeRef,
2783
2826
  this.checkpointManager,
2784
2827
  {
@@ -2805,9 +2848,10 @@ class ti {
2805
2848
  },
2806
2849
  executeHandler: async (o, a) => this.executeHandler(o, a),
2807
2850
  handleHandlerError: async (o, a, c) => this.handleHandlerError(o, a, c),
2808
- canonicalSignature: s
2851
+ canonicalSignature: s,
2852
+ channelProcessorFor: (o) => this.registry.lookupChannel(o) ?? null
2809
2853
  }
2810
- ), this.scopeExecutor = new gr({
2854
+ ), this.scopeExecutor = new yr({
2811
2855
  runtime: this.runtimeRef,
2812
2856
  contractLoader: this.contractLoader,
2813
2857
  channelRunner: this.channelRunner,
@@ -2858,7 +2902,7 @@ class ti {
2858
2902
  );
2859
2903
  }
2860
2904
  createContext(e, t, n, r = !1, s = !1) {
2861
- return new ni(
2905
+ return new ii(
2862
2906
  this,
2863
2907
  t,
2864
2908
  e,
@@ -2869,7 +2913,7 @@ class ti {
2869
2913
  }
2870
2914
  result() {
2871
2915
  const e = this.runtimeRef.document().clone(), t = this.runtimeRef.rootEmissions().map((n) => n.clone());
2872
- return Me.of(
2916
+ return Oe.of(
2873
2917
  e,
2874
2918
  t,
2875
2919
  this.runtimeRef.totalGas()
@@ -2983,8 +3027,8 @@ class ti {
2983
3027
  return e instanceof Error && typeof e.message == "string" ? e.message : t;
2984
3028
  }
2985
3029
  createDocumentUpdateEvent(e, t) {
2986
- const n = Lt(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(
2987
- new d().setBlueId(ei)
3030
+ const n = xt(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(
3031
+ new d().setBlueId(ni)
2988
3032
  );
2989
3033
  return o.setProperties({
2990
3034
  op: new d().setValue(e.op),
@@ -3006,7 +3050,7 @@ class j {
3006
3050
  }
3007
3051
  async initializeDocument(e) {
3008
3052
  if (this.isInitialized(e))
3009
- throw new A("Document already initialized");
3053
+ throw new O("Document already initialized");
3010
3054
  const t = this.createExecution(e.clone());
3011
3055
  return this.run(e, t, async () => {
3012
3056
  await t.initializeScope("/", !0);
@@ -3014,7 +3058,7 @@ class j {
3014
3058
  }
3015
3059
  async processDocument(e, t) {
3016
3060
  if (!this.isInitialized(e))
3017
- throw new A("Document not initialized");
3061
+ throw new O("Document not initialized");
3018
3062
  const n = this.createExecution(e.clone()), r = t.clone();
3019
3063
  return this.run(e, n, async () => {
3020
3064
  n.loadBundles("/"), await n.processExternalEvent("/", r);
@@ -3024,7 +3068,7 @@ class j {
3024
3068
  return this.initializationMarker(e) != null;
3025
3069
  }
3026
3070
  createExecution(e) {
3027
- return new ti(
3071
+ return new ri(
3028
3072
  this.contractLoader,
3029
3073
  this.registry,
3030
3074
  this.blue,
@@ -3039,7 +3083,7 @@ class j {
3039
3083
  return t.result();
3040
3084
  if (r instanceof U) {
3041
3085
  const s = e.clone();
3042
- return Me.capabilityFailure(
3086
+ return Oe.capabilityFailure(
3043
3087
  s,
3044
3088
  r.message ?? null
3045
3089
  );
@@ -3059,7 +3103,7 @@ class j {
3059
3103
  "Initialization Marker must be a BlueNode"
3060
3104
  )
3061
3105
  );
3062
- if (n.getType()?.getBlueId() !== Xr)
3106
+ if (n.getType()?.getBlueId() !== ti)
3063
3107
  throw new g(
3064
3108
  "Initialization Marker must declare type 'Processing Initialized Marker'",
3065
3109
  E.illegalState(
@@ -3125,7 +3169,7 @@ class j {
3125
3169
  case "contracts":
3126
3170
  return new d().setContracts(e.getContracts());
3127
3171
  case "blueId": {
3128
- const r = e.getBlueId() ?? n?.calculateBlueId?.(e) ?? mt.calculateBlueIdSync(e);
3172
+ const r = e.getBlueId() ?? n?.calculateBlueId?.(e) ?? Et.calculateBlueIdSync(e);
3129
3173
  return new d().setValue(r ?? null);
3130
3174
  }
3131
3175
  default:
@@ -3133,7 +3177,7 @@ class j {
3133
3177
  }
3134
3178
  }
3135
3179
  }
3136
- class ni {
3180
+ class ii {
3137
3181
  constructor(e, t, n, r, s, o) {
3138
3182
  this.execution = e, this.bundle = t, this.scopePathValue = n, this.eventNode = r, this.allowTerminatedWork = s, this.allowReservedMutation = o;
3139
3183
  }
@@ -3227,16 +3271,16 @@ class ni {
3227
3271
  return !this.allowTerminatedWork && this.execution.isScopeInactive(this.scopePathValue);
3228
3272
  }
3229
3273
  }
3230
- const ri = new gt({
3231
- repositories: [ht, St, Rt]
3274
+ const si = new yt({
3275
+ repositories: [pt, Ct, Nt]
3232
3276
  });
3233
- class ii {
3277
+ class oi {
3234
3278
  blue;
3235
3279
  registryRef;
3236
3280
  contractLoaderRef;
3237
3281
  engine;
3238
3282
  constructor(e) {
3239
- this.registryRef = e?.registry ?? Y.create().registerDefaults().build(), this.blue = e?.blue ?? ri, this.contractLoaderRef = new rr(this.registryRef, this.blue), this.engine = new j(
3283
+ this.registryRef = e?.registry ?? Y.create().registerDefaults().build(), this.blue = e?.blue ?? si, this.contractLoaderRef = new sr(this.registryRef, this.blue), this.engine = new j(
3240
3284
  this.contractLoaderRef,
3241
3285
  this.registryRef,
3242
3286
  this.blue
@@ -3269,10 +3313,10 @@ class ii {
3269
3313
  return this.contractLoaderRef;
3270
3314
  }
3271
3315
  static builder() {
3272
- return new si();
3316
+ return new ai();
3273
3317
  }
3274
3318
  }
3275
- class si {
3319
+ class ai {
3276
3320
  contractRegistry;
3277
3321
  blueInstance;
3278
3322
  constructor() {
@@ -3288,13 +3332,13 @@ class si {
3288
3332
  return this.blueInstance = e, this;
3289
3333
  }
3290
3334
  build() {
3291
- return new ii({
3335
+ return new oi({
3292
3336
  registry: this.contractRegistry,
3293
3337
  blue: this.blueInstance
3294
3338
  });
3295
3339
  }
3296
3340
  }
3297
- class Xe {
3341
+ class tt {
3298
3342
  process(e, t) {
3299
3343
  const n = t.getValue();
3300
3344
  if (G(n)) {
@@ -3315,14 +3359,14 @@ class Xe {
3315
3359
  return e;
3316
3360
  }
3317
3361
  }
3318
- const Ri = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3362
+ const Ni = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3319
3363
  __proto__: null,
3320
- ExpressionPreserver: Xe
3364
+ ExpressionPreserver: tt
3321
3365
  }, Symbol.toStringTag, { value: "Module" }));
3322
- function Pi() {
3366
+ function Mi() {
3323
3367
  return new P.SequentialMergingProcessor([
3324
3368
  new P.ValuePropagator(),
3325
- new Xe(),
3369
+ new tt(),
3326
3370
  new P.TypeAssigner(),
3327
3371
  new P.ListProcessor(),
3328
3372
  new P.DictionaryProcessor(),
@@ -3330,101 +3374,101 @@ function Pi() {
3330
3374
  ]);
3331
3375
  }
3332
3376
  export {
3333
- zn as ChannelBinding,
3334
- lr as ChannelRunner,
3335
- cr as CheckpointManager,
3336
- ar as CheckpointRecord,
3337
- Ke as CodeBlockEvaluationError,
3338
- O as ContractBundle,
3339
- Vn as ContractBundleBuilder,
3340
- rr as ContractLoader,
3341
- Sn as ContractProcessorRegistry,
3377
+ Vn as ChannelBinding,
3378
+ dr as ChannelRunner,
3379
+ ur as CheckpointManager,
3380
+ lr as CheckpointRecord,
3381
+ We as CodeBlockEvaluationError,
3382
+ A as ContractBundle,
3383
+ Kn as ContractBundleBuilder,
3384
+ sr as ContractLoader,
3385
+ Cn as ContractProcessorRegistry,
3342
3386
  Y as ContractProcessorRegistryBuilder,
3343
- Me as DocumentProcessingResult,
3344
- Zr as DocumentProcessingRuntime,
3345
- ii as DocumentProcessor,
3346
- si as DocumentProcessorBuilder,
3347
- Pr as EmissionRegistry,
3348
- Yr as GasMeter,
3349
- Un as HandlerBinding,
3387
+ Oe as DocumentProcessingResult,
3388
+ ei as DocumentProcessingRuntime,
3389
+ oi as DocumentProcessor,
3390
+ ai as DocumentProcessorBuilder,
3391
+ Mr as EmissionRegistry,
3392
+ Xr as GasMeter,
3393
+ Hn as HandlerBinding,
3350
3394
  T as KEY_CHECKPOINT,
3351
3395
  Ae as KEY_EMBEDDED,
3352
- Oe as KEY_INITIALIZED,
3353
- De as KEY_TERMINATED,
3354
- Ri as MergingProcessors,
3355
- Be as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3356
- Ir as PatchEngine,
3357
- Ci as ProcessorContractConstants,
3396
+ De as KEY_INITIALIZED,
3397
+ Be as KEY_TERMINATED,
3398
+ Ni as MergingProcessors,
3399
+ _e as PROCESSOR_MANAGED_CHANNEL_BLUE_IDS,
3400
+ kr as PatchEngine,
3401
+ vi as ProcessorContractConstants,
3358
3402
  j as ProcessorEngine,
3359
3403
  E as ProcessorErrors,
3360
- ti as ProcessorExecution,
3361
- ni as ProcessorExecutionContext,
3404
+ ri as ProcessorExecution,
3405
+ ii as ProcessorExecutionContext,
3362
3406
  g as ProcessorFatalError,
3363
- Ii as ProcessorPointerConstants,
3407
+ ki as ProcessorPointerConstants,
3364
3408
  ce as QuickJSEvaluator,
3365
- Le as RELATIVE_CHECKPOINT,
3409
+ $e as RELATIVE_CHECKPOINT,
3366
3410
  B as RELATIVE_CONTRACTS,
3367
- _t as RELATIVE_EMBEDDED,
3411
+ $t as RELATIVE_EMBEDDED,
3368
3412
  ie as RELATIVE_INITIALIZED,
3369
- _e as RELATIVE_TERMINATED,
3413
+ Le as RELATIVE_TERMINATED,
3370
3414
  oe as RESERVED_CONTRACT_KEYS,
3371
3415
  J as RunTerminationError,
3372
- gr as ScopeExecutor,
3373
- Rr as ScopeRuntimeContext,
3374
- wr as TerminationService,
3375
- yi as andThen,
3376
- Ve as canonicalSignature,
3416
+ yr as ScopeExecutor,
3417
+ Nr as ScopeRuntimeContext,
3418
+ br as TerminationService,
3419
+ Si as andThen,
3420
+ He as canonicalSignature,
3377
3421
  Se as canonicalSize,
3378
3422
  _ as channelContractBaseSchema,
3379
- an as channelEventCheckpointSchema,
3380
- Qt as containsExpression,
3423
+ ln as channelEventCheckpointSchema,
3424
+ Zt as containsExpression,
3381
3425
  le as contractBaseSchema,
3382
- Pi as createDefaultMergingProcessor,
3383
- Je as createPicomatchShouldResolve,
3384
- hn as documentAnchorsMarkerSchema,
3385
- fn as documentLinksMarkerSchema,
3386
- en as documentUpdateChannelSchema,
3387
- tn as embeddedNodeChannelSchema,
3388
- Nt as err,
3389
- qe as evaluateQuickJSExpression,
3390
- Yt as extractExpressionContent,
3391
- je as handlerContractBaseSchema,
3392
- cn as initializationMarkerSchema,
3393
- mi as isErr,
3426
+ Mi as createDefaultMergingProcessor,
3427
+ je as createPicomatchShouldResolve,
3428
+ pn as documentAnchorsMarkerSchema,
3429
+ mn as documentLinksMarkerSchema,
3430
+ nn as documentUpdateChannelSchema,
3431
+ rn as embeddedNodeChannelSchema,
3432
+ Ot as err,
3433
+ Je as evaluateQuickJSExpression,
3434
+ Xt as extractExpressionContent,
3435
+ Qe as handlerContractBaseSchema,
3436
+ un as initializationMarkerSchema,
3437
+ Ei as isErr,
3394
3438
  G as isExpression,
3395
- pi as isOk,
3439
+ gi as isOk,
3396
3440
  ae as isProcessorManagedChannelBlueId,
3397
- Bt as isReservedContractKey,
3398
- ki as joinRelativePointers,
3399
- vi as jsonPatchSchema,
3400
- nn as lifecycleChannelSchema,
3401
- gi as map,
3402
- Ei as mapErr,
3441
+ Lt as isReservedContractKey,
3442
+ Ti as joinRelativePointers,
3443
+ Ri as jsonPatchSchema,
3444
+ sn as lifecycleChannelSchema,
3445
+ yi as map,
3446
+ wi as mapErr,
3403
3447
  C as markerContractBaseSchema,
3404
- bi as match,
3405
- pn as myosParticipantsOrchestrationMarkerSchema,
3406
- mn as myosSessionInteractionMarkerSchema,
3407
- on as myosTimelineChannelSchema,
3408
- gn as myosWorkerAgencyMarkerSchema,
3448
+ Ii as match,
3449
+ gn as myosParticipantsOrchestrationMarkerSchema,
3450
+ En as myosSessionInteractionMarkerSchema,
3451
+ cn as myosTimelineChannelSchema,
3452
+ yn as myosWorkerAgencyMarkerSchema,
3409
3453
  S as normalizePointer,
3410
3454
  y as normalizeScope,
3411
- Pt as ok,
3412
- dn as operationMarkerSchema,
3413
- ln as processEmbeddedMarkerSchema,
3414
- un as processingTerminatedMarkerSchema,
3415
- Fe as relativeCheckpointLastEvent,
3416
- ze as relativeCheckpointLastSignature,
3455
+ Mt as ok,
3456
+ fn as operationMarkerSchema,
3457
+ dn as processEmbeddedMarkerSchema,
3458
+ hn as processingTerminatedMarkerSchema,
3459
+ ze as relativeCheckpointLastEvent,
3460
+ Ue as relativeCheckpointLastSignature,
3417
3461
  Q as relativeContractsEntry,
3418
- Lt as relativizePointer,
3462
+ xt as relativizePointer,
3419
3463
  q as resolveNodeExpressions,
3420
3464
  w as resolvePointer,
3421
- Zt as resolveTemplateString,
3422
- yn as sequentialWorkflowOperationSchema,
3423
- En as sequentialWorkflowSchema,
3424
- Ti as sequentialWorkflowStepSchema,
3465
+ en as resolveTemplateString,
3466
+ Sn as sequentialWorkflowOperationSchema,
3467
+ wn as sequentialWorkflowSchema,
3468
+ Pi as sequentialWorkflowStepSchema,
3425
3469
  ye as stripSlashes,
3426
- sn as timelineChannelSchema,
3427
- rn as triggeredEventChannelSchema,
3428
- wi as unwrapOr,
3429
- Si as unwrapOrElse
3470
+ an as timelineChannelSchema,
3471
+ on as triggeredEventChannelSchema,
3472
+ bi as unwrapOr,
3473
+ Ci as unwrapOrElse
3430
3474
  };