@dotbep/core 0.2.14 → 0.2.16

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +24 -18
  2. package/dist/index.js +276 -293
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import se from "jszip";
2
2
  import { z as r, ZodError as We } from "zod";
3
- const Xe = r.enum([
3
+ const Ge = r.enum([
4
4
  "appointing-party",
5
5
  "lead-appointed-party",
6
6
  "appointed-party"
7
- ]), Ge = r.enum(["video", "document"]), Ve = r.enum(["zone", "location"]), He = r.enum(["LR", "TB"]), xs = r.enum(["start", "end", "process", "decision", "automation"]), Ye = r.enum(["info", "warning", "blocking"]), Qe = r.enum([
7
+ ]), Xe = r.enum(["video", "document"]), Ve = r.enum(["zone", "location"]), He = r.enum(["LR", "TB"]), Ps = r.enum(["start", "end", "process", "decision", "automation"]), Ye = r.enum(["info", "warning", "blocking"]), Qe = r.enum([
8
8
  "roles",
9
9
  "members",
10
10
  "teams",
@@ -32,7 +32,12 @@ const Xe = r.enum([
32
32
  clientId: r.string().describe("ref Team.id").optional(),
33
33
  description: r.string().optional(),
34
34
  image: r.string().optional(),
35
- websiteUrl: r.url().optional()
35
+ websiteUrl: r.url().optional(),
36
+ location: r.object({
37
+ address: r.string().optional(),
38
+ coordinates: r.tuple([r.number(), r.number()]).optional().describe("[longitude, latitude] — GeoJSON order")
39
+ }).optional(),
40
+ customData: r.record(r.string(), r.unknown()).optional()
36
41
  }).describe("General metadata about the construction project the BEP belongs to."), le = r.object({
37
42
  id: r.uuid(),
38
43
  name: r.string().min(1),
@@ -47,7 +52,7 @@ const Xe = r.enum([
47
52
  }).describe("A project participant identified by email. Each member holds one role, which determines their responsibilities across workflow steps."), et = r.object({
48
53
  id: r.string().min(1).describe("Must comply with the naming convention token pattern."),
49
54
  name: r.string().min(1),
50
- isoRole: Xe,
55
+ isoRole: Ge,
51
56
  description: r.string().optional(),
52
57
  disciplineIds: r.array(r.string()).optional(),
53
58
  representativeEmail: r.email().optional().describe("ref Member.email"),
@@ -93,10 +98,10 @@ const Xe = r.enum([
93
98
  }), ge = r.object({
94
99
  id: r.string().min(1).describe("Used in deliverables nomenclature."),
95
100
  name: r.string().min(1)
96
- }).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), ye = r.object({
101
+ }).describe("A project discipline used to classify deliverables and information requirements. Represents a technical domain such as structure, architecture, or MEP."), we = r.object({
97
102
  id: r.string().min(1),
98
103
  name: r.string().min(1)
99
- }).describe("A file format or extension accepted for deliverables, such as IFC, PDF, or DWG. Used to specify the required output formats per deliverable."), we = r.object({
104
+ }).describe("A file format or extension accepted for deliverables, such as IFC, PDF, or DWG. Used to specify the required output formats per deliverable."), ye = r.object({
100
105
  id: r.string().min(1).describe("Used in deliverables nomenclature."),
101
106
  name: r.string().min(1),
102
107
  extensionIds: r.array(r.string()).optional()
@@ -123,7 +128,7 @@ const Xe = r.enum([
123
128
  description: r.string().optional(),
124
129
  softwareIds: r.array(r.string()).optional().describe("ref Software.id[]"),
125
130
  guideIds: r.array(r.string()).optional().describe("ref Guide.id[]")
126
- }).describe("A human-performed activity referenced by workflow process nodes. Actions represent what a person in a given role does at a specific step."), L = r.object({
131
+ }).describe("A human-performed activity referenced by workflow process nodes. Actions represent what a person in a given role does at a specific step."), C = r.object({
127
132
  key: r.string().min(1),
128
133
  type: r.enum(["string", "number", "boolean"]),
129
134
  required: r.boolean(),
@@ -135,18 +140,18 @@ const Xe = r.enum([
135
140
  }), Se = r.object({
136
141
  id: r.string().min(1).describe('Human-readable slug, e.g. "status-changed".'),
137
142
  name: r.string().min(1),
138
- payload: r.array(L).optional()
143
+ payload: r.array(C).optional()
139
144
  }).describe("A signal that advances a workflow instance from one node to the next. Carries a typed payload that moves the workflow instance forward and can be evaluated by decision guards."), Ne = r.object({
140
145
  id: r.string().min(1).describe('Human-readable slug, e.g. "notify".'),
141
146
  name: r.string().min(1),
142
147
  description: r.string().min(1).describe("Describe exactly what this effect must do so the runtime developer knows what to implement: what action it performs and what external system or service it calls."),
143
- payload: r.array(L).optional()
148
+ payload: r.array(C).optional()
144
149
  }).describe("A fire-and-forget side effect triggered on a workflow edge. Executed by the runtime when the edge is traversed, using fields from the instance context as payload."), ke = r.object({
145
150
  id: r.string().min(1).describe('Human-readable slug, e.g. "verify-tolerances".'),
146
151
  name: r.string().min(1),
147
152
  description: r.string().min(1).describe("Describe what this handler checks and what decision it produces: what condition or business rule it evaluates and where that data comes from."),
148
- payload: r.array(L).optional().describe("Fields consumed from instance context and passed to the handler."),
149
- output: r.array(L).describe("Fields the handler must return. Guards on outgoing edges reference these.")
153
+ payload: r.array(C).optional().describe("Fields consumed from instance context and passed to the handler."),
154
+ output: r.array(C).describe("Fields the handler must return. Guards on outgoing edges reference these.")
150
155
  }).describe("A system-executed node in a workflow. Runs a handler automatically, produces a typed output, and must be followed by a decision node that branches on that output."), it = r.object({
151
156
  hours: r.number().positive(),
152
157
  effectId: r.string().min(1).describe("ref FlowEffect.id")
@@ -217,7 +222,7 @@ const Xe = r.enum([
217
222
  triggerEventId: r.string().min(1).describe("ref FlowEvent.id — the event that fires this transition")
218
223
  }), pt = Y.extend({
219
224
  guard: ut.describe("Condition evaluated against the instance context to determine which path to take.")
220
- }), ht = Y, gt = r.union([mt, pt, ht]), yt = r.object({
225
+ }), ht = Y, gt = r.union([mt, pt, ht]), wt = r.object({
221
226
  direction: He.default("LR"),
222
227
  nodes: r.record(r.string(), ft),
223
228
  edges: r.record(r.string(), gt)
@@ -277,20 +282,20 @@ const Xe = r.enum([
277
282
  path: ["edges", a, "guard"]
278
283
  });
279
284
  }
280
- }).describe("The visual and structural definition of a workflow."), $e = r.object({
285
+ }).describe("The visual and structural definition of a workflow."), Re = r.object({
281
286
  id: r.uuid(),
282
287
  name: r.string().min(1),
283
288
  description: r.string().optional(),
284
289
  example: r.string().optional().describe("Narrative example showcasing one cycle of this workflow."),
285
290
  trackedAssetTypeId: r.string().optional().describe("ref AssetType.id"),
286
- diagram: yt
287
- }).describe("A reusable process definition associated with one or more BIM uses. Describes the ordered steps, responsibilities, and transitions that govern how work is carried out."), Re = r.object({
291
+ diagram: wt
292
+ }).describe("A reusable process definition associated with one or more BIM uses. Describes the ordered steps, responsibilities, and transitions that govern how work is carried out."), Te = r.object({
288
293
  id: r.uuid(),
289
294
  name: r.string().min(1),
290
- type: Ge,
295
+ type: Xe,
291
296
  url: r.string().min(1),
292
297
  description: r.string().optional()
293
- }).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), je = r.object({
298
+ }).describe("Supporting material attached to the BEP, such as a reference document or instructional video."), $e = r.object({
294
299
  id: r.uuid(),
295
300
  name: r.string().min(1),
296
301
  description: r.string().optional().describe("Short guide description, not it's content"),
@@ -300,7 +305,7 @@ const Xe = r.enum([
300
305
  name: r.string().min(1),
301
306
  description: r.string().optional(),
302
307
  contentPath: r.string().describe("Relative path to the .md file inside the .bep archive.")
303
- }).describe("A normative reference or rule that governs how work is carried out on the project. Standards define what must be followed, as opposed to guides which explain how."), Te = r.object({
308
+ }).describe("A normative reference or rule that governs how work is carried out on the project. Standards define what must be followed, as opposed to guides which explain how."), je = r.object({
304
309
  id: r.string().min(1),
305
310
  name: r.string().min(1),
306
311
  checklist: r.array(r.string()).optional()
@@ -308,17 +313,17 @@ const Xe = r.enum([
308
313
  id: r.string().min(1),
309
314
  name: r.string().min(1),
310
315
  checklist: r.array(r.string()).optional()
311
- }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), wt = r.object({
316
+ }).describe("An information detail level assigned to model elements in LOIN requirements. Specifies the non-geometric properties required of a model element at a given milestone."), yt = r.object({
312
317
  milestoneId: r.string(),
313
318
  lodId: r.string().min(1),
314
319
  loiId: r.string().min(1),
315
320
  idsPath: r.string().optional().describe("Relative path to the .ids (Information Delivery Specification) file inside the .bep archive.")
316
- }), Me = r.object({
321
+ }), Be = r.object({
317
322
  id: r.uuid(),
318
323
  element: r.string().min(1),
319
324
  disciplineId: r.string(),
320
- milestones: r.array(wt).optional()
321
- }).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), Be = r.object({
325
+ milestones: r.array(yt).optional()
326
+ }).describe("An information requirement for a model element. Declares what geometric detail and information properties are required for a specific model element and discipline across project milestones."), Me = r.object({
322
327
  id: r.uuid(),
323
328
  message: r.string().min(1),
324
329
  memberEmail: r.email(),
@@ -330,7 +335,7 @@ const Xe = r.enum([
330
335
  severity: Ye,
331
336
  message: r.string().min(1),
332
337
  generatedAt: r.iso.datetime()
333
- }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), xe = vt.refine((n) => n.entity === null == (n.entityId === null), {
338
+ }).describe("A diagnostic message attached to the BEP or one of its entities. Indicates an issue or observation with a severity level that guides the author."), Pe = vt.refine((n) => n.entity === null == (n.entityId === null), {
334
339
  message: "entity and entityId must both be null (BEP-level) or both be non-null (entity-level)."
335
340
  }), bt = r.object({
336
341
  id: r.uuid(),
@@ -345,25 +350,25 @@ const Xe = r.enum([
345
350
  predecessorId: r.string().optional(),
346
351
  url: r.url().optional(),
347
352
  resolverId: r.string().min(1).optional()
348
- }).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), Pe = bt.refine((n) => !n.predecessorId || n.predecessorId !== n.id, {
353
+ }).describe("A formal output committed by a team at a milestone. Defines what must be delivered, in what format, by whom, and by when."), xe = bt.refine((n) => !n.predecessorId || n.predecessorId !== n.id, {
349
354
  message: "predecessorId cannot reference the deliverable itself.",
350
355
  path: ["predecessorId"]
351
356
  }), Fe = r.object({
352
357
  key: r.string().min(1),
353
358
  description: r.string().min(1).describe("Describe what this variable holds and which service it belongs to."),
354
359
  sensitive: r.boolean().optional()
355
- }).describe("A runtime configuration entry for handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Le = r.object({
360
+ }).describe("A runtime configuration entry for handlers. Used to store credentials, endpoints, or other runtime settings without hardcoding them."), Ce = r.object({
356
361
  id: r.string().min(1).describe('Human-readable slug, e.g. "google-sheet"'),
357
362
  name: r.string().min(1),
358
363
  description: r.string().min(1).describe("Describe what external data this fetches, from where, and what format it returns: which service or API it calls, what credentials it needs, and the shape of the raw payload it returns."),
359
364
  envKeys: r.array(r.string().min(1)).describe("ref EnvVar.key[] — env vars required by this resolver handler.")
360
- }).describe("A server-side handler declared in the BEP bundle that authenticates against an external service, fetches data, and returns a raw payload for a live resource."), Ce = r.object({
365
+ }).describe("A server-side handler declared in the BEP bundle that authenticates against an external service, fetches data, and returns a raw payload for a live resource."), Le = r.object({
361
366
  id: r.uuid(),
362
367
  name: r.string().min(1),
363
368
  description: r.string().min(1).describe("Describe what this data source represents in the project context: what information it holds, how it is used in the BEP, and who or what system produces it."),
364
369
  url: r.url(),
365
370
  resolverId: r.string().min(1).optional().describe("ref Resolver.id")
366
- }).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."), Ps = r.object({
371
+ }).describe("A reference to an external data source that is fetched at runtime. The BEP does not store the data — it only declares where it lives and how to access it using a resolver."), xs = r.object({
367
372
  project: de,
368
373
  deliverableNamingConvention: ue.optional(),
369
374
  roles: r.array(le),
@@ -373,8 +378,8 @@ const Xe = r.enum([
373
378
  milestones: r.array(pe),
374
379
  lbs: r.array(he),
375
380
  disciplines: r.array(ge),
376
- extensions: r.array(ye),
377
- assetTypes: r.array(we),
381
+ extensions: r.array(we),
382
+ assetTypes: r.array(ye),
378
383
  softwares: r.array(ve),
379
384
  objectives: r.array(be),
380
385
  bimUses: r.array(Ie),
@@ -383,18 +388,18 @@ const Xe = r.enum([
383
388
  effects: r.array(Ne),
384
389
  automations: r.array(ke),
385
390
  env: r.array(Fe),
386
- resolvers: r.array(Le),
387
- remoteData: r.array(Ce),
388
- workflows: r.array($e),
389
- guides: r.array(je),
390
- annexes: r.array(Re),
391
+ resolvers: r.array(Ce),
392
+ remoteData: r.array(Le),
393
+ workflows: r.array(Re),
394
+ guides: r.array($e),
395
+ annexes: r.array(Te),
391
396
  standards: r.array(Ae),
392
- lods: r.array(Te),
397
+ lods: r.array(je),
393
398
  lois: r.array(Oe),
394
- loin: r.array(Me),
395
- deliverables: r.array(Pe),
396
- notes: r.array(Be),
397
- flags: r.array(xe)
399
+ loin: r.array(Be),
400
+ deliverables: r.array(xe),
401
+ notes: r.array(Me),
402
+ flags: r.array(Pe)
398
403
  }), ne = r.object({
399
404
  version: r.string().regex(/^\d+\.\d+$/).describe('Format: "{major}.{minor}" (e.g. "1.0", "2.3").'),
400
405
  date: r.iso.datetime(),
@@ -411,7 +416,7 @@ const Xe = r.enum([
411
416
  current: r.string().regex(/^\d+\.\d+$/).describe('Current version in "{major}.{minor}" format.'),
412
417
  versions: r.array(It)
413
418
  });
414
- function j(n) {
419
+ function $(n) {
415
420
  return n.roles ??= [], n.members ??= [], n.teams ??= [], n.phases ??= [], n.milestones ??= [], n.lbs ??= [], n.disciplines ??= [], n.extensions ??= [], n.assetTypes ??= [], n.softwares ??= [], n.objectives ??= [], n.bimUses ??= [], n.actions ??= [], n.events ??= [], n.effects ??= [], n.workflows ??= [], n.guides ??= [], n.annexes ??= [], n.standards ??= [], n.lods ??= [], n.lois ??= [], n.loin ??= [], n.deliverables ??= [], n.notes ??= [], n.flags ??= [], n.env ??= [], n.automations ??= [], n.resolvers ??= [], n.remoteData ??= [], n;
416
421
  }
417
422
  const Et = "-", St = "^[A-Z0-9]{3}$";
@@ -422,13 +427,13 @@ function Nt(n, e) {
422
427
  }
423
428
  return St;
424
429
  }
425
- function T(n, e, s) {
430
+ function j(n, e, s) {
426
431
  const t = s?.delimiter ?? Et, i = Nt(n, s);
427
432
  return new RegExp(i).test(e) ? e.includes(t) ? `"${e}" contains the naming delimiter "${t}"` : null : `"${e}" does not match naming pattern ${i} for token "${n}"`;
428
433
  }
429
434
  function kt(n, e) {
430
435
  const s = [], t = (i, o) => {
431
- const a = T(i, o, e);
436
+ const a = j(i, o, e);
432
437
  a && s.push(a);
433
438
  };
434
439
  t("project", n.project.code);
@@ -499,7 +504,7 @@ const De = [
499
504
  // lbs (self-referential)
500
505
  { entity: "lbs", references: "lbs", inField: "lbsNodeIds", array: !0 }
501
506
  ];
502
- function $t(n, e, s) {
507
+ function Rt(n, e, s) {
503
508
  return De.filter((t) => t.references === e).flatMap((t) => s[t.entity].filter((o) => {
504
509
  const a = o[t.inField];
505
510
  return t.array ? Array.isArray(a) && a.includes(n) : a === n;
@@ -519,7 +524,7 @@ function ie(n, e, s) {
519
524
  function z(n) {
520
525
  return n instanceof We ? n.issues.map((e) => (e.path.length ? e.path.join(".") + ": " : "") + e.message).join("; ") : n.message;
521
526
  }
522
- class y {
527
+ class w {
523
528
  constructor(e, s, t) {
524
529
  this.getItems = e, this.getBep = s, this.config = t, this.idField = t.idField ?? "id";
525
530
  }
@@ -594,7 +599,7 @@ class y {
594
599
  continue;
595
600
  }
596
601
  try {
597
- const d = $t(i, this.config.key, this.getBep());
602
+ const d = Rt(i, this.config.key, this.getBep());
598
603
  if (d.length) throw new Error(`Referenced by: ${d.join(", ")}`);
599
604
  this.config.beforeRemove?.(i, this.getBep()), o.splice(a, 1), s.push(i);
600
605
  } catch (d) {
@@ -604,7 +609,7 @@ class y {
604
609
  return { succeeded: s, failed: t };
605
610
  }
606
611
  }
607
- class Rt extends y {
612
+ class Tt extends w {
608
613
  constructor(e) {
609
614
  super(
610
615
  () => e().actions,
@@ -623,20 +628,20 @@ class Rt extends y {
623
628
  );
624
629
  }
625
630
  }
626
- class jt extends y {
631
+ class $t extends w {
627
632
  constructor(e) {
628
633
  super(
629
634
  () => e().annexes,
630
635
  e,
631
636
  {
632
637
  key: "annexes",
633
- schema: Re,
638
+ schema: Te,
634
639
  autoId: !0
635
640
  }
636
641
  );
637
642
  }
638
643
  }
639
- class At extends y {
644
+ class At extends w {
640
645
  constructor(e) {
641
646
  super(
642
647
  () => e().effects,
@@ -658,7 +663,7 @@ class At extends y {
658
663
  );
659
664
  }
660
665
  }
661
- class Tt extends y {
666
+ class jt extends w {
662
667
  constructor(e) {
663
668
  super(
664
669
  () => e().automations,
@@ -676,7 +681,7 @@ class Tt extends y {
676
681
  );
677
682
  }
678
683
  }
679
- class Ot extends y {
684
+ class Ot extends w {
680
685
  constructor(e) {
681
686
  super(
682
687
  () => e().env,
@@ -689,7 +694,7 @@ class Ot extends y {
689
694
  );
690
695
  }
691
696
  }
692
- class Mt extends y {
697
+ class Bt extends w {
693
698
  constructor(e) {
694
699
  super(
695
700
  () => e().events,
@@ -707,7 +712,7 @@ class Mt extends y {
707
712
  );
708
713
  }
709
714
  }
710
- function P(n) {
715
+ function x(n) {
711
716
  const e = /* @__PURE__ */ new Map();
712
717
  for (const s of n)
713
718
  for (const t of s.lbsNodeIds ?? [])
@@ -722,7 +727,7 @@ function Q(n) {
722
727
  }
723
728
  function Ue(n, e) {
724
729
  if (!n) return { zoneCode: "XXX", locationCode: "XXX" };
725
- const s = new Map(e.map((d) => [d.id, d])), t = P(e), i = Q(e), o = s.get(n);
730
+ const s = new Map(e.map((d) => [d.id, d])), t = x(e), i = Q(e), o = s.get(n);
726
731
  if (!o) return { zoneCode: "XXX", locationCode: "XXX" };
727
732
  if (i.has(o.id)) return { zoneCode: "ZZZ", locationCode: "ZZZ" };
728
733
  if (o.type === "zone") return { zoneCode: o.id, locationCode: "ZZZ" };
@@ -736,7 +741,7 @@ function Ue(n, e) {
736
741
  }
737
742
  return { zoneCode: "ZZZ", locationCode: o.id };
738
743
  }
739
- function Bt(n) {
744
+ function Mt(n) {
740
745
  const e = [], s = new Map(n.map((d) => [d.id, d])), t = Q(n);
741
746
  for (const d of t) {
742
747
  const l = s.get(d);
@@ -768,7 +773,7 @@ function K(n) {
768
773
  }
769
774
  return e;
770
775
  }
771
- const x = "XXX";
776
+ const P = "XXX";
772
777
  function ze(n, e, s, t, i) {
773
778
  const { zoneCode: o, locationCode: a } = Ue(n.lbsNodeId, t);
774
779
  if (!i) {
@@ -782,13 +787,13 @@ function ze(n, e, s, t, i) {
782
787
  }
783
788
  switch (l.token) {
784
789
  case "project":
785
- return e || x;
790
+ return e || P;
786
791
  case "team":
787
- return n.responsibleId || x;
792
+ return n.responsibleId || P;
788
793
  case "discipline":
789
- return n.disciplineId || x;
794
+ return n.disciplineId || P;
790
795
  case "assetType":
791
- return n.assetTypeId || x;
796
+ return n.assetTypeId || P;
792
797
  case "lbsZone":
793
798
  return o;
794
799
  case "lbsLocation":
@@ -803,7 +808,7 @@ function Ze(n, e, s, t) {
803
808
  ze(o, e, i, s, t)
804
809
  ]));
805
810
  }
806
- class xt {
811
+ class Pt {
807
812
  constructor(e) {
808
813
  this.getBep = e;
809
814
  }
@@ -828,14 +833,14 @@ class xt {
828
833
  return Ze(e.deliverables, e.project.code, e.lbs, e.deliverableNamingConvention);
829
834
  }
830
835
  }
831
- class Pt extends y {
836
+ class xt extends w {
832
837
  constructor(e, s, t, i, o) {
833
838
  super(
834
839
  () => e().deliverables,
835
840
  e,
836
841
  {
837
842
  key: "deliverables",
838
- schema: Pe,
843
+ schema: xe,
839
844
  autoId: !0
840
845
  }
841
846
  ), this.getTeams = s, this.getAssetTypes = t, this.getLBSNodes = i, this.getMilestones = o;
@@ -869,27 +874,27 @@ class Pt extends y {
869
874
  return [...d.values()];
870
875
  }
871
876
  }
872
- class Ft extends y {
877
+ class Ft extends w {
873
878
  constructor(e) {
874
879
  super(
875
880
  () => e().flags,
876
881
  e,
877
882
  {
878
883
  key: "flags",
879
- schema: xe,
884
+ schema: Pe,
880
885
  autoId: !0
881
886
  }
882
887
  );
883
888
  }
884
889
  }
885
- class Lt extends y {
890
+ class Ct extends w {
886
891
  constructor(e, s) {
887
892
  super(
888
893
  () => e().notes,
889
894
  e,
890
895
  {
891
896
  key: "notes",
892
- schema: Be,
897
+ schema: Me,
893
898
  autoId: !0
894
899
  }
895
900
  ), this.getMembers = s;
@@ -903,7 +908,7 @@ class Lt extends y {
903
908
  }));
904
909
  }
905
910
  }
906
- class Ct extends y {
911
+ class Lt extends w {
907
912
  constructor(e, s) {
908
913
  super(
909
914
  () => e().bimUses,
@@ -939,7 +944,7 @@ class Ct extends y {
939
944
  }));
940
945
  }
941
946
  }
942
- class Dt extends y {
947
+ class Dt extends w {
943
948
  constructor(e) {
944
949
  super(
945
950
  () => e().disciplines,
@@ -948,21 +953,21 @@ class Dt extends y {
948
953
  key: "disciplines",
949
954
  schema: ge,
950
955
  validate: (s, t) => {
951
- const i = T("discipline", s.id, t.deliverableNamingConvention);
956
+ const i = j("discipline", s.id, t.deliverableNamingConvention);
952
957
  return i ? [i] : [];
953
958
  }
954
959
  }
955
960
  );
956
961
  }
957
962
  }
958
- class Ut extends y {
963
+ class Ut extends w {
959
964
  constructor(e) {
960
965
  super(
961
966
  () => e().guides,
962
967
  e,
963
968
  {
964
969
  key: "guides",
965
- schema: je,
970
+ schema: $e,
966
971
  autoId: !0
967
972
  }
968
973
  );
@@ -975,14 +980,14 @@ class Ut extends y {
975
980
  }));
976
981
  }
977
982
  }
978
- class zt extends y {
983
+ class zt extends w {
979
984
  constructor(e) {
980
985
  super(
981
986
  () => e().lods,
982
987
  e,
983
988
  {
984
989
  key: "lods",
985
- schema: Te,
990
+ schema: je,
986
991
  beforeRemove: (s, t) => {
987
992
  for (const i of t.loin)
988
993
  if (i.milestones?.find((a) => a.lodId === s)) throw new Error(`Referenced by: loin["${i.id}"].milestones[lodId=${s}]`);
@@ -991,7 +996,7 @@ class zt extends y {
991
996
  );
992
997
  }
993
998
  }
994
- class Zt extends y {
999
+ class Zt extends w {
995
1000
  constructor(e) {
996
1001
  super(
997
1002
  () => e().lois,
@@ -1007,14 +1012,14 @@ class Zt extends y {
1007
1012
  );
1008
1013
  }
1009
1014
  }
1010
- class Jt extends y {
1015
+ class Jt extends w {
1011
1016
  constructor(e) {
1012
1017
  super(
1013
1018
  () => e().loin,
1014
1019
  e,
1015
1020
  {
1016
1021
  key: "loin",
1017
- schema: Me,
1022
+ schema: Be,
1018
1023
  autoId: !0,
1019
1024
  validate: (s, t) => {
1020
1025
  const i = [];
@@ -1111,16 +1116,16 @@ class Jt extends y {
1111
1116
  }));
1112
1117
  }
1113
1118
  }
1114
- class Kt extends y {
1119
+ class Kt extends w {
1115
1120
  constructor(e) {
1116
1121
  super(
1117
1122
  () => e().assetTypes,
1118
1123
  e,
1119
1124
  {
1120
1125
  key: "assetTypes",
1121
- schema: we,
1126
+ schema: ye,
1122
1127
  validate: (s, t) => {
1123
- const i = T("assetType", s.id, t.deliverableNamingConvention);
1128
+ const i = j("assetType", s.id, t.deliverableNamingConvention);
1124
1129
  return i ? [i] : [];
1125
1130
  }
1126
1131
  }
@@ -1134,19 +1139,19 @@ class Kt extends y {
1134
1139
  }));
1135
1140
  }
1136
1141
  }
1137
- class qt extends y {
1142
+ class qt extends w {
1138
1143
  constructor(e) {
1139
1144
  super(
1140
1145
  () => e().extensions,
1141
1146
  e,
1142
1147
  {
1143
1148
  key: "extensions",
1144
- schema: ye
1149
+ schema: we
1145
1150
  }
1146
1151
  );
1147
1152
  }
1148
1153
  }
1149
- class Wt extends y {
1154
+ class Wt extends w {
1150
1155
  constructor(e) {
1151
1156
  super(
1152
1157
  () => e().roles,
@@ -1169,7 +1174,7 @@ class Wt extends y {
1169
1174
  );
1170
1175
  }
1171
1176
  }
1172
- class Xt extends y {
1177
+ class Gt extends w {
1173
1178
  constructor(e) {
1174
1179
  super(
1175
1180
  () => e().lbs,
@@ -1178,7 +1183,7 @@ class Xt extends y {
1178
1183
  key: "lbs",
1179
1184
  schema: he,
1180
1185
  validate: (s, t) => {
1181
- const i = [], o = s.type === "zone" ? "lbsZone" : "lbsLocation", a = T(o, s.id, t.deliverableNamingConvention);
1186
+ const i = [], o = s.type === "zone" ? "lbsZone" : "lbsLocation", a = j(o, s.id, t.deliverableNamingConvention);
1182
1187
  if (a && i.push(a), s.type === "location" && s.lbsNodeIds?.length) {
1183
1188
  const d = new Map(t.lbs.map((l) => [l.id, l]));
1184
1189
  for (const l of s.lbsNodeIds ?? [])
@@ -1190,7 +1195,7 @@ class Xt extends y {
1190
1195
  );
1191
1196
  }
1192
1197
  listResolved() {
1193
- const e = this.getBep(), s = P(e.lbs), t = Q(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1198
+ const e = this.getBep(), s = x(e.lbs), t = Q(e.lbs), i = new Map(e.lbs.map((o) => [o.id, o]));
1194
1199
  return e.lbs.map((o) => {
1195
1200
  const a = s.get(o.id), d = a ? i.get(a) : void 0;
1196
1201
  return {
@@ -1239,7 +1244,7 @@ class Xt extends y {
1239
1244
  i.push({ id: o.id, error: "A node cannot be its own parent." });
1240
1245
  continue;
1241
1246
  }
1242
- const a = s.lbs.find((h) => h.id === o.id), d = P(s.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
1247
+ const a = s.lbs.find((h) => h.id === o.id), d = x(s.lbs).get(o.id) ?? null, { parentId: l, ...c } = o, u = this.update([c]);
1243
1248
  if (u.failed.length > 0) {
1244
1249
  i.push({ id: o.id, error: u.failed[0].error });
1245
1250
  continue;
@@ -1247,9 +1252,9 @@ class Xt extends y {
1247
1252
  const f = { name: a.name, type: a.type, description: a.description, parentId: d }, m = s.lbs.find((h) => h.id === o.id);
1248
1253
  if (l !== void 0) {
1249
1254
  for (const h of s.lbs)
1250
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((w) => w !== o.id));
1255
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== o.id));
1251
1256
  if (l) {
1252
- const h = s.lbs.find((w) => w.id === l);
1257
+ const h = s.lbs.find((y) => y.id === l);
1253
1258
  h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id);
1254
1259
  }
1255
1260
  }
@@ -1257,16 +1262,16 @@ class Xt extends y {
1257
1262
  if (p.length > 0) {
1258
1263
  if (m.name = f.name, m.type = f.type, f.description !== void 0 ? m.description = f.description : delete m.description, l !== void 0) {
1259
1264
  for (const h of s.lbs)
1260
- h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((w) => w !== o.id));
1265
+ h.lbsNodeIds?.includes(o.id) && (h.lbsNodeIds = h.lbsNodeIds.filter((y) => y !== o.id));
1261
1266
  if (f.parentId) {
1262
- const h = s.lbs.find((w) => w.id === f.parentId);
1267
+ const h = s.lbs.find((y) => y.id === f.parentId);
1263
1268
  h && (h.lbsNodeIds ??= [], h.lbsNodeIds.push(o.id));
1264
1269
  }
1265
1270
  }
1266
1271
  i.push({ id: o.id, error: p.join("; ") });
1267
1272
  continue;
1268
1273
  }
1269
- const g = P(s.lbs).get(m.id) ?? null;
1274
+ const g = x(s.lbs).get(m.id) ?? null;
1270
1275
  t.push({ id: o.id, before: f, after: { name: m.name, type: m.type, description: m.description, parentId: g } });
1271
1276
  }
1272
1277
  return { succeeded: t, failed: i };
@@ -1277,10 +1282,10 @@ class Xt extends y {
1277
1282
  }
1278
1283
  /** Validates the full LBS tree and returns a list of structural errors. */
1279
1284
  validateTree() {
1280
- return Bt(this.list());
1285
+ return Mt(this.list());
1281
1286
  }
1282
1287
  }
1283
- class Gt extends y {
1288
+ class Xt extends w {
1284
1289
  constructor(e) {
1285
1290
  super(
1286
1291
  () => e().members,
@@ -1373,7 +1378,7 @@ class Gt extends y {
1373
1378
  return { succeeded: s, failed: t };
1374
1379
  }
1375
1380
  }
1376
- class Vt extends y {
1381
+ class Vt extends w {
1377
1382
  constructor(e) {
1378
1383
  super(
1379
1384
  () => e().milestones,
@@ -1397,7 +1402,7 @@ class Vt extends y {
1397
1402
  }));
1398
1403
  }
1399
1404
  }
1400
- class Ht extends y {
1405
+ class Ht extends w {
1401
1406
  constructor(e) {
1402
1407
  super(
1403
1408
  () => e().objectives,
@@ -1410,7 +1415,7 @@ class Ht extends y {
1410
1415
  );
1411
1416
  }
1412
1417
  }
1413
- class Yt extends y {
1418
+ class Yt extends w {
1414
1419
  constructor(e) {
1415
1420
  super(
1416
1421
  () => e().phases,
@@ -1423,27 +1428,27 @@ class Yt extends y {
1423
1428
  );
1424
1429
  }
1425
1430
  }
1426
- class Qt extends y {
1431
+ class Qt extends w {
1427
1432
  constructor(e) {
1428
1433
  super(
1429
1434
  () => e().remoteData,
1430
1435
  e,
1431
1436
  {
1432
1437
  key: "remoteData",
1433
- schema: Ce,
1438
+ schema: Le,
1434
1439
  autoId: !0
1435
1440
  }
1436
1441
  );
1437
1442
  }
1438
1443
  }
1439
- class es extends y {
1444
+ class es extends w {
1440
1445
  constructor(e) {
1441
1446
  super(
1442
1447
  () => e().resolvers,
1443
1448
  e,
1444
1449
  {
1445
1450
  key: "resolvers",
1446
- schema: Le,
1451
+ schema: Ce,
1447
1452
  beforeRemove: (s, t) => {
1448
1453
  const i = t.remoteData.find((o) => o.resolverId === s);
1449
1454
  if (i) throw new Error(`Referenced by: remoteData["${i.id}"].resolverId`);
@@ -1452,7 +1457,7 @@ class es extends y {
1452
1457
  );
1453
1458
  }
1454
1459
  }
1455
- class ts extends y {
1460
+ class ts extends w {
1456
1461
  constructor(e, s) {
1457
1462
  super(
1458
1463
  () => e().softwares,
@@ -1472,7 +1477,7 @@ class ts extends y {
1472
1477
  }));
1473
1478
  }
1474
1479
  }
1475
- class ss extends y {
1480
+ class ss extends w {
1476
1481
  constructor(e, s) {
1477
1482
  super(
1478
1483
  () => e().standards,
@@ -1524,7 +1529,7 @@ class ss extends y {
1524
1529
  this.getZip().file(t.contentPath, s);
1525
1530
  }
1526
1531
  }
1527
- class ns extends y {
1532
+ class ns extends w {
1528
1533
  constructor(e, s) {
1529
1534
  super(
1530
1535
  () => e().teams,
@@ -1533,7 +1538,7 @@ class ns extends y {
1533
1538
  key: "teams",
1534
1539
  schema: fe,
1535
1540
  validate: (t, i) => {
1536
- const o = [], a = T("team", t.id, i.deliverableNamingConvention);
1541
+ const o = [], a = j("team", t.id, i.deliverableNamingConvention);
1537
1542
  return a && o.push(a), t.representativeEmail && !(t.memberEmails ?? []).includes(t.representativeEmail) && o.push(`representativeEmail "${t.representativeEmail}" is not a member of this team`), o;
1538
1543
  },
1539
1544
  beforeRemove: (t, i) => {
@@ -1604,14 +1609,14 @@ function is(n, e, s) {
1604
1609
  }
1605
1610
  return t;
1606
1611
  }
1607
- class os extends y {
1612
+ class os extends w {
1608
1613
  constructor(e, s, t) {
1609
1614
  super(
1610
1615
  () => e().workflows,
1611
1616
  e,
1612
1617
  {
1613
1618
  key: "workflows",
1614
- schema: $e,
1619
+ schema: Re,
1615
1620
  autoId: !0,
1616
1621
  validate: (i, o) => is(i.diagram, o, i.id)
1617
1622
  }
@@ -1740,7 +1745,7 @@ function W(n) {
1740
1745
  q(n, i) && t.push(i);
1741
1746
  return t;
1742
1747
  }
1743
- function N(n) {
1748
+ function S(n) {
1744
1749
  switch (typeof n) {
1745
1750
  case "object":
1746
1751
  return JSON.parse(JSON.stringify(n));
@@ -1752,7 +1757,7 @@ function N(n) {
1752
1757
  return n;
1753
1758
  }
1754
1759
  }
1755
- function X(n) {
1760
+ function G(n) {
1756
1761
  for (var e = 0, s = n.length, t; e < s; ) {
1757
1762
  if (t = n.charCodeAt(e), t >= 48 && t <= 57) {
1758
1763
  e++;
@@ -1762,23 +1767,23 @@ function X(n) {
1762
1767
  }
1763
1768
  return !0;
1764
1769
  }
1765
- function $(n) {
1770
+ function _(n) {
1766
1771
  return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(/~/g, "~0").replace(/\//g, "~1");
1767
1772
  }
1768
1773
  function Je(n) {
1769
1774
  return n.replace(/~1/g, "/").replace(/~0/g, "~");
1770
1775
  }
1771
- function G(n) {
1776
+ function X(n) {
1772
1777
  if (n === void 0)
1773
1778
  return !0;
1774
1779
  if (n) {
1775
1780
  if (Array.isArray(n)) {
1776
1781
  for (var e = 0, s = n.length; e < s; e++)
1777
- if (G(n[e]))
1782
+ if (X(n[e]))
1778
1783
  return !0;
1779
1784
  } else if (typeof n == "object") {
1780
1785
  for (var t = W(n), i = t.length, o = 0; o < i; o++)
1781
- if (G(n[t[o]]))
1786
+ if (X(n[t[o]]))
1782
1787
  return !0;
1783
1788
  }
1784
1789
  }
@@ -1803,7 +1808,7 @@ var Ke = (
1803
1808
  }
1804
1809
  return e;
1805
1810
  })(Error)
1806
- ), b = Ke, ds = N, A = {
1811
+ ), b = Ke, ds = S, A = {
1807
1812
  add: function(n, e, s) {
1808
1813
  return n[e] = this.value, { newDocument: s };
1809
1814
  },
@@ -1816,24 +1821,24 @@ var Ke = (
1816
1821
  return n[e] = this.value, { newDocument: s, removed: t };
1817
1822
  },
1818
1823
  move: function(n, e, s) {
1819
- var t = C(s, this.path);
1820
- t && (t = N(t));
1824
+ var t = L(s, this.path);
1825
+ t && (t = S(t));
1821
1826
  var i = R(s, { op: "remove", path: this.from }).removed;
1822
1827
  return R(s, { op: "add", path: this.path, value: i }), { newDocument: s, removed: t };
1823
1828
  },
1824
1829
  copy: function(n, e, s) {
1825
- var t = C(s, this.from);
1826
- return R(s, { op: "add", path: this.path, value: N(t) }), { newDocument: s };
1830
+ var t = L(s, this.from);
1831
+ return R(s, { op: "add", path: this.path, value: S(t) }), { newDocument: s };
1827
1832
  },
1828
1833
  test: function(n, e, s) {
1829
- return { newDocument: s, test: M(n[e], this.value) };
1834
+ return { newDocument: s, test: B(n[e], this.value) };
1830
1835
  },
1831
1836
  _get: function(n, e, s) {
1832
1837
  return this.value = n[e], { newDocument: s };
1833
1838
  }
1834
1839
  }, ls = {
1835
1840
  add: function(n, e, s) {
1836
- return X(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: s, index: e };
1841
+ return G(e) ? n.splice(e, 0, this.value) : n[e] = this.value, { newDocument: s, index: e };
1837
1842
  },
1838
1843
  remove: function(n, e, s) {
1839
1844
  var t = n.splice(e, 1);
@@ -1848,7 +1853,7 @@ var Ke = (
1848
1853
  test: A.test,
1849
1854
  _get: A._get
1850
1855
  };
1851
- function C(n, e) {
1856
+ function L(n, e) {
1852
1857
  if (e == "")
1853
1858
  return n;
1854
1859
  var s = { op: "_get", path: e };
@@ -1862,9 +1867,9 @@ function R(n, e, s, t, i, o) {
1862
1867
  if (e.op === "replace")
1863
1868
  return a.newDocument = e.value, a.removed = n, a;
1864
1869
  if (e.op === "move" || e.op === "copy")
1865
- return a.newDocument = C(n, e.from), e.op === "move" && (a.removed = n), a;
1870
+ return a.newDocument = L(n, e.from), e.op === "move" && (a.removed = n), a;
1866
1871
  if (e.op === "test") {
1867
- if (a.test = M(n, e.value), a.test === !1)
1872
+ if (a.test = B(n, e.value), a.test === !1)
1868
1873
  throw new b("Test operation failed", "TEST_OPERATION_FAILED", o, e, n);
1869
1874
  return a.newDocument = n, a;
1870
1875
  } else {
@@ -1877,7 +1882,7 @@ function R(n, e, s, t, i, o) {
1877
1882
  return a;
1878
1883
  }
1879
1884
  } else {
1880
- t || (n = N(n));
1885
+ t || (n = S(n));
1881
1886
  var d = e.path || "", l = d.split("/"), c = n, u = 1, f = l.length, m = void 0, p = void 0, g = void 0;
1882
1887
  for (typeof s == "function" ? g = s : g = D; ; ) {
1883
1888
  if (p = l[u], p && p.indexOf("~") != -1 && (p = Je(p)), i && (p == "__proto__" || p == "prototype" && u > 0 && l[u - 1] == "constructor"))
@@ -1886,9 +1891,9 @@ function R(n, e, s, t, i, o) {
1886
1891
  if (p === "-")
1887
1892
  p = c.length;
1888
1893
  else {
1889
- if (s && !X(p))
1894
+ if (s && !G(p))
1890
1895
  throw new b("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", o, e, n);
1891
- X(p) && (p = ~~p);
1896
+ G(p) && (p = ~~p);
1892
1897
  }
1893
1898
  if (u >= f) {
1894
1899
  if (s && e.op === "add" && p > c.length)
@@ -1912,7 +1917,7 @@ function R(n, e, s, t, i, o) {
1912
1917
  function U(n, e, s, t, i) {
1913
1918
  if (t === void 0 && (t = !0), i === void 0 && (i = !0), s && !Array.isArray(e))
1914
1919
  throw new b("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1915
- t || (n = N(n));
1920
+ t || (n = S(n));
1916
1921
  for (var o = new Array(e.length), a = 0, d = e.length; a < d; a++)
1917
1922
  o[a] = R(n, e[a], s, !0, i, a), n = o[a].newDocument;
1918
1923
  return o.newDocument = n, o;
@@ -1935,7 +1940,7 @@ function D(n, e, s, t) {
1935
1940
  throw new b("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", e, n, s);
1936
1941
  if ((n.op === "add" || n.op === "replace" || n.op === "test") && n.value === void 0)
1937
1942
  throw new b("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", e, n, s);
1938
- if ((n.op === "add" || n.op === "replace" || n.op === "test") && G(n.value))
1943
+ if ((n.op === "add" || n.op === "replace" || n.op === "test") && X(n.value))
1939
1944
  throw new b("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", e, n, s);
1940
1945
  if (s) {
1941
1946
  if (n.op == "add") {
@@ -1958,7 +1963,7 @@ function qe(n, e, s) {
1958
1963
  if (!Array.isArray(n))
1959
1964
  throw new b("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
1960
1965
  if (e)
1961
- U(N(e), N(n), s || !0);
1966
+ U(S(e), S(n), s || !0);
1962
1967
  else {
1963
1968
  s = s || D;
1964
1969
  for (var t = 0; t < n.length; t++)
@@ -1970,7 +1975,7 @@ function qe(n, e, s) {
1970
1975
  throw i;
1971
1976
  }
1972
1977
  }
1973
- function M(n, e) {
1978
+ function B(n, e) {
1974
1979
  if (n === e)
1975
1980
  return !0;
1976
1981
  if (n && e && typeof n == "object" && typeof e == "object") {
@@ -1979,7 +1984,7 @@ function M(n, e) {
1979
1984
  if (o = n.length, o != e.length)
1980
1985
  return !1;
1981
1986
  for (i = o; i-- !== 0; )
1982
- if (!M(n[i], e[i]))
1987
+ if (!B(n[i], e[i]))
1983
1988
  return !1;
1984
1989
  return !0;
1985
1990
  }
@@ -1992,7 +1997,7 @@ function M(n, e) {
1992
1997
  if (!e.hasOwnProperty(d[i]))
1993
1998
  return !1;
1994
1999
  for (i = o; i-- !== 0; )
1995
- if (a = d[i], !M(n[a], e[a]))
2000
+ if (a = d[i], !B(n[a], e[a]))
1996
2001
  return !1;
1997
2002
  return !0;
1998
2003
  }
@@ -2001,12 +2006,12 @@ function M(n, e) {
2001
2006
  const fs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2002
2007
  __proto__: null,
2003
2008
  JsonPatchError: b,
2004
- _areEquals: M,
2009
+ _areEquals: B,
2005
2010
  applyOperation: R,
2006
2011
  applyPatch: U,
2007
2012
  applyReducer: cs,
2008
2013
  deepClone: ds,
2009
- getValueByPointer: C,
2014
+ getValueByPointer: L,
2010
2015
  validate: qe,
2011
2016
  validator: D
2012
2017
  }, Symbol.toStringTag, { value: "Module" }));
@@ -2036,10 +2041,10 @@ function hs(n, e) {
2036
2041
  function gs(n, e) {
2037
2042
  n.observers.delete(e.callback);
2038
2043
  }
2039
- function ys(n, e) {
2044
+ function ws(n, e) {
2040
2045
  e.unobserve();
2041
2046
  }
2042
- function ws(n, e) {
2047
+ function ys(n, e) {
2043
2048
  var s = [], t, i = ps(n);
2044
2049
  if (!i)
2045
2050
  i = new us(n), ee.set(n, i);
@@ -2049,7 +2054,7 @@ function ws(n, e) {
2049
2054
  }
2050
2055
  if (t)
2051
2056
  return t;
2052
- if (t = {}, i.value = N(n), e) {
2057
+ if (t = {}, i.value = S(n), e) {
2053
2058
  t.callback = e, t.next = null;
2054
2059
  var a = function() {
2055
2060
  V(t);
@@ -2076,13 +2081,13 @@ function te(n, e, s, t, i) {
2076
2081
  var c = a[l], u = n[c];
2077
2082
  if (q(e, c) && !(e[c] === void 0 && u !== void 0 && Array.isArray(e) === !1)) {
2078
2083
  var f = e[c];
2079
- typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? te(u, f, s, t + "/" + $(c), i) : u !== f && (i && s.push({ op: "test", path: t + "/" + $(c), value: N(u) }), s.push({ op: "replace", path: t + "/" + $(c), value: N(f) }));
2080
- } else Array.isArray(n) === Array.isArray(e) ? (i && s.push({ op: "test", path: t + "/" + $(c), value: N(u) }), s.push({ op: "remove", path: t + "/" + $(c) }), d = !0) : (i && s.push({ op: "test", path: t, value: n }), s.push({ op: "replace", path: t, value: e }));
2084
+ typeof u == "object" && u != null && typeof f == "object" && f != null && Array.isArray(u) === Array.isArray(f) ? te(u, f, s, t + "/" + _(c), i) : u !== f && (i && s.push({ op: "test", path: t + "/" + _(c), value: S(u) }), s.push({ op: "replace", path: t + "/" + _(c), value: S(f) }));
2085
+ } else Array.isArray(n) === Array.isArray(e) ? (i && s.push({ op: "test", path: t + "/" + _(c), value: S(u) }), s.push({ op: "remove", path: t + "/" + _(c) }), d = !0) : (i && s.push({ op: "test", path: t, value: n }), s.push({ op: "replace", path: t, value: e }));
2081
2086
  }
2082
2087
  if (!(!d && o.length == a.length))
2083
2088
  for (var l = 0; l < o.length; l++) {
2084
2089
  var c = o[l];
2085
- !q(n, c) && e[c] !== void 0 && s.push({ op: "add", path: t + "/" + $(c), value: N(e[c]) });
2090
+ !q(n, c) && e[c] !== void 0 && s.push({ op: "add", path: t + "/" + _(c), value: S(e[c]) });
2086
2091
  }
2087
2092
  }
2088
2093
  }
@@ -2095,13 +2100,13 @@ const vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2095
2100
  __proto__: null,
2096
2101
  compare: H,
2097
2102
  generate: V,
2098
- observe: ws,
2099
- unobserve: ys
2103
+ observe: ys,
2104
+ unobserve: ws
2100
2105
  }, Symbol.toStringTag, { value: "Module" }));
2101
2106
  Object.assign({}, fs, vs, {
2102
2107
  JsonPatchError: Ke,
2103
- deepClone: N,
2104
- escapePathComponent: $,
2108
+ deepClone: S,
2109
+ escapePathComponent: _,
2105
2110
  unescapePathComponent: Je
2106
2111
  });
2107
2112
  function v(n, e, s) {
@@ -2160,7 +2165,7 @@ function Es(n, e) {
2160
2165
  const i = [...s ? ["project"] : [], ...Object.keys(t)];
2161
2166
  return { project: s, sections: t, changedKeys: i };
2162
2167
  }
2163
- class E {
2168
+ class I {
2164
2169
  constructor(e, s, t) {
2165
2170
  this.getBep = e, this.setBep = s, this.getZip = t;
2166
2171
  }
@@ -2173,7 +2178,7 @@ class E {
2173
2178
  return { major: s, minor: t };
2174
2179
  }
2175
2180
  static compareVersions(e, s) {
2176
- const t = E.parseVersion(e), i = E.parseVersion(s);
2181
+ const t = I.parseVersion(e), i = I.parseVersion(s);
2177
2182
  return t.major !== i.major ? t.major - i.major : t.minor - i.minor;
2178
2183
  }
2179
2184
  static bumpVersion(e, s) {
@@ -2187,7 +2192,7 @@ class E {
2187
2192
  }
2188
2193
  async readBaseline() {
2189
2194
  const e = this.getZip().file("baseline/bep.json");
2190
- return e ? j(JSON.parse(await e.async("string"))) : null;
2195
+ return e ? $(JSON.parse(await e.async("string"))) : null;
2191
2196
  }
2192
2197
  // ─── Standards versioning helpers ─────────────────────────────────────────
2193
2198
  /**
@@ -2202,7 +2207,7 @@ class E {
2202
2207
  const a = await o.async("string"), d = `changelog/standards/${i.id}/`, l = Object.keys(t.files).filter((u) => u.startsWith(d) && u.endsWith(".md") && u.slice(d.length).startsWith("v")).map((u) => u.slice(d.length + 1, -3));
2203
2208
  let c = null;
2204
2209
  if (l.length > 0) {
2205
- const u = l.sort((m, p) => E.compareVersions(p, m))[0], f = t.file(`${d}v${u}.md`);
2210
+ const u = l.sort((m, p) => I.compareVersions(p, m))[0], f = t.file(`${d}v${u}.md`);
2206
2211
  f && (c = await f.async("string"));
2207
2212
  }
2208
2213
  c !== a && t.file(`${d}v${s}.md`, a);
@@ -2227,7 +2232,7 @@ class E {
2227
2232
  * Falls back to the current file if no snapshot exists (content never changed).
2228
2233
  */
2229
2234
  async resolveStandardContent(e, s) {
2230
- const t = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(t.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => E.compareVersions(d, s) <= 0).sort((d, l) => E.compareVersions(l, d));
2235
+ const t = this.getZip(), i = `changelog/standards/${e.id}/`, o = Object.keys(t.files).filter((d) => d.startsWith(i) && d.endsWith(".md") && d.slice(i.length).startsWith("v")).map((d) => d.slice(i.length + 1, -3)).filter((d) => I.compareVersions(d, s) <= 0).sort((d, l) => I.compareVersions(l, d));
2231
2236
  if (o.length === 0) {
2232
2237
  const d = t.file(e.contentPath);
2233
2238
  return d ? d.async("string") : null;
@@ -2246,12 +2251,12 @@ class E {
2246
2251
  const t = this.getZip(), i = this.getBep(), o = await this.readChangelog(), a = await this.readBaseline(), d = (/* @__PURE__ */ new Date()).toISOString();
2247
2252
  if (!a) throw new Error("No baseline found — create a BEP with Bep.create() or open one with Bep.open()");
2248
2253
  if (e.type === "version") {
2249
- const g = e.approvedBy.filter((h) => !i.members.some((w) => w.email === h));
2254
+ const g = e.approvedBy.filter((h) => !i.members.some((y) => y.email === h));
2250
2255
  if (g.length) throw new Error(`Members not found: ${g.join(", ")}`);
2251
2256
  }
2252
2257
  if (!s && !await this.hasPendingChanges())
2253
2258
  throw new Error("No pending changes since last commit");
2254
- const l = o?.current ?? "0.0", c = E.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = H(i, a), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
2259
+ const l = o?.current ?? "0.0", c = I.bumpVersion(l, e.type), u = `changelog/v${c}.diff.json`, f = H(i, a), m = e.type === "patch" ? { version: c, type: "patch", date: d, author: e.author, description: e.description, diff: u } : { version: c, type: "version", date: d, author: e.author, description: e.description, approvedBy: e.approvedBy, diff: u }, p = {
2255
2260
  current: c,
2256
2261
  versions: [...o?.versions ?? [], m]
2257
2262
  };
@@ -2270,14 +2275,14 @@ class E {
2270
2275
  if (t === -1) {
2271
2276
  const a = this.getZip().file(`changelog/v${e}.json`);
2272
2277
  if (!a) throw new Error(`Version not found: ${e}`);
2273
- return j(JSON.parse(await a.async("string")));
2278
+ return $(JSON.parse(await a.async("string")));
2274
2279
  }
2275
2280
  if (s.versions[t].diff === null) {
2276
2281
  const a = this.getZip().file(`changelog/v${e}.json`);
2277
2282
  if (!a) throw new Error(`Missing terminus: changelog/v${e}.json`);
2278
- return j(JSON.parse(await a.async("string")));
2283
+ return $(JSON.parse(await a.async("string")));
2279
2284
  }
2280
- const i = s.versions.filter((a) => E.compareVersions(a.version, e) > 0).sort((a, d) => E.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2285
+ const i = s.versions.filter((a) => I.compareVersions(a.version, e) > 0).sort((a, d) => I.compareVersions(d.version, a.version)), o = JSON.parse(JSON.stringify(this.getBep()));
2281
2286
  for (const a of i) {
2282
2287
  if (!a.diff) break;
2283
2288
  const d = this.getZip().file(a.diff);
@@ -2285,7 +2290,7 @@ class E {
2285
2290
  const l = JSON.parse(await d.async("string"));
2286
2291
  U(o, l);
2287
2292
  }
2288
- return j(o);
2293
+ return $(o);
2289
2294
  }
2290
2295
  /** Returns the RFC 6902 diff and standards summary between two versions. */
2291
2296
  async compare(e, s) {
@@ -2293,12 +2298,12 @@ class E {
2293
2298
  this.get(e),
2294
2299
  this.get(s),
2295
2300
  this.readChangelog()
2296
- ]), a = H(t, i), d = new Set(t.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = t.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => E.compareVersions(h.version, e) > 0 && E.compareVersions(h.version, s) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2301
+ ]), a = H(t, i), d = new Set(t.standards.map((h) => h.id)), l = new Set(i.standards.map((h) => h.id)), c = i.standards.filter((h) => !d.has(h.id)).map((h) => ({ id: h.id, name: h.name })), u = t.standards.filter((h) => !l.has(h.id)).map((h) => ({ id: h.id, name: h.name })), m = (o?.versions ?? []).filter((h) => I.compareVersions(h.version, e) > 0 && I.compareVersions(h.version, s) <= 0).map((h) => h.version), p = this.getZip(), g = (await Promise.all(
2297
2302
  i.standards.filter((h) => d.has(h.id)).map(async (h) => {
2298
- const w = (await Promise.all(
2299
- m.map(async (S) => p.file(`changelog/standards/${h.id}/v${S}.md`) !== null ? S : null)
2300
- )).filter((S) => S !== null);
2301
- return w.length > 0 ? { id: h.id, name: h.name, changedIn: w } : null;
2303
+ const y = (await Promise.all(
2304
+ m.map(async (N) => p.file(`changelog/standards/${h.id}/v${N}.md`) !== null ? N : null)
2305
+ )).filter((N) => N !== null);
2306
+ return y.length > 0 ? { id: h.id, name: h.name, changedIn: y } : null;
2302
2307
  })
2303
2308
  )).filter((h) => h !== null);
2304
2309
  return { diff: a, standards: { added: c, removed: u, contentModified: g } };
@@ -2359,7 +2364,7 @@ class E {
2359
2364
  /** Returns all versions sorted ascending, with author/approvedBy resolved to { email, name } objects. */
2360
2365
  async listResolved() {
2361
2366
  const [e, s] = await Promise.all([this.list(), this.current()]), t = this.getBep().members;
2362
- return e.sort((i, o) => E.compareVersions(i.version, o.version)).map((i) => ({
2367
+ return e.sort((i, o) => I.compareVersions(i.version, o.version)).map((i) => ({
2363
2368
  version: i.version,
2364
2369
  type: i.type,
2365
2370
  date: i.date,
@@ -2395,7 +2400,7 @@ class E {
2395
2400
  throw new Error(`Version not found: ${e}`);
2396
2401
  if (e === t.current)
2397
2402
  throw new Error(`Already at version ${e}`);
2398
- const a = t.versions.filter((c) => E.compareVersions(c.version, e) > 0), d = await this.get(e);
2403
+ const a = t.versions.filter((c) => I.compareVersions(c.version, e) > 0), d = await this.get(e);
2399
2404
  for (const c of d.standards) {
2400
2405
  const u = await this.resolveStandardContent(c, e);
2401
2406
  u !== null && s.file(c.contentPath, u);
@@ -2406,7 +2411,7 @@ class E {
2406
2411
  const l = JSON.stringify(d, null, 2);
2407
2412
  s.file("changelog.json", JSON.stringify({
2408
2413
  current: e,
2409
- versions: t.versions.filter((c) => E.compareVersions(c.version, e) <= 0)
2414
+ versions: t.versions.filter((c) => I.compareVersions(c.version, e) <= 0)
2410
2415
  }, null, 2)), s.file("bep.json", l), s.file("baseline/bep.json", l), this.setBep(d);
2411
2416
  }
2412
2417
  /**
@@ -2419,7 +2424,7 @@ class E {
2419
2424
  if (!t) throw new Error("No changelog found");
2420
2425
  if (!/^\d+\.0$/.test(e.newBase))
2421
2426
  throw new Error(`newBase must be in X.0 format (e.g. "2.0"), got "${e.newBase}"`);
2422
- if (E.compareVersions(e.newBase, t.current) <= 0)
2427
+ if (I.compareVersions(e.newBase, t.current) <= 0)
2423
2428
  throw new Error(`newBase "${e.newBase}" must be greater than current version "${t.current}"`);
2424
2429
  const i = this.getBep(), o = e.approvedBy.filter((d) => !i.members.some((l) => l.email === d));
2425
2430
  if (o.length) throw new Error(`Members not found: ${o.join(", ")}`);
@@ -2488,13 +2493,13 @@ function ks(n, e, s, t) {
2488
2493
  if (!a && !d) return !0;
2489
2494
  const c = n.members.find((m) => m.email === t)?.roleId, u = new Set(n.teams.filter((m) => (m.memberEmails ?? []).includes(t)).map((m) => m.id)), f = (m, p, g) => {
2490
2495
  if (g?.includes(t)) return !0;
2491
- const h = !!m?.length, w = !!p?.length;
2492
- return w && h ? !!c && m.includes(c) && p.some((S) => u.has(S)) : w ? p.some((S) => u.has(S)) : h ? !!c && m.includes(c) : !1;
2496
+ const h = !!m?.length, y = !!p?.length;
2497
+ return y && h ? !!c && m.includes(c) && p.some((N) => u.has(N)) : y ? p.some((N) => u.has(N)) : h ? !!c && m.includes(c) : !1;
2493
2498
  };
2494
2499
  return a && f(o.responsibleRoleIds, o.responsibleTeamIds, o.responsibleEmails) || d && f(o.accountableRoleIds, o.accountableTeamIds, o.accountableEmails);
2495
2500
  }
2496
2501
  const _s = { string: "string", number: "number", boolean: "boolean" };
2497
- function $s(n, e, s) {
2502
+ function Rs(n, e, s) {
2498
2503
  const t = n.events.find((d) => d.id === e);
2499
2504
  if (!t?.payload?.length) return [];
2500
2505
  const i = [], o = s ?? {};
@@ -2518,10 +2523,10 @@ function $s(n, e, s) {
2518
2523
  a.has(d) || i.push({ field: d, reason: "unknown_field" });
2519
2524
  return i;
2520
2525
  }
2521
- function Rs(n, e) {
2526
+ function Ts(n, e) {
2522
2527
  return !(!("triggerEventId" in n) || n.triggerEventId !== e.eventId);
2523
2528
  }
2524
- function js(n, e, s, t, i) {
2529
+ function $s(n, e, s, t, i) {
2525
2530
  const o = n.workflows.find((f) => f.id === e);
2526
2531
  if (!o) return null;
2527
2532
  const a = Object.keys(o.diagram.nodes).find(
@@ -2550,37 +2555,37 @@ function J(n, e, s, t) {
2550
2555
  return { ok: !1, error: "INSTANCE_NOT_ACTIVE" };
2551
2556
  if (!t?.skipRaci && !ks(n, e.currentNodeId, e.workflowId, s.actor))
2552
2557
  return { ok: !1, error: "UNAUTHORIZED" };
2553
- const i = n.workflows.find((I) => I.id === e.workflowId);
2558
+ const i = n.workflows.find((E) => E.id === e.workflowId);
2554
2559
  if (!i) return { ok: !1, error: "NO_MATCHING_EDGE" };
2555
2560
  const { nodes: o, edges: a } = i.diagram;
2556
2561
  let d = e.currentNodeId;
2557
2562
  const l = [], c = [], u = [], f = Object.entries(a).filter(
2558
- ([, I]) => I.from === d && Rs(I, s)
2563
+ ([, E]) => E.from === d && Ts(E, s)
2559
2564
  );
2560
2565
  if (f.length === 0) return { ok: !1, error: "NO_MATCHING_EDGE" };
2561
2566
  if (f.length > 1) return { ok: !1, error: "AMBIGUOUS_TRANSITION" };
2562
2567
  const [m, p] = f[0];
2563
2568
  if ("triggerEventId" in p) {
2564
- const I = $s(n, p.triggerEventId, s.payload);
2565
- if (I.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: I };
2569
+ const E = Rs(n, p.triggerEventId, s.payload);
2570
+ if (E.length > 0) return { ok: !1, error: "INVALID_PAYLOAD", payloadErrors: E };
2566
2571
  }
2567
- l.push(re(m, d, p.to, s)), c.push(...(p.effectIds ?? []).map((I) => ({ effectId: I, fromEdgeId: m, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2572
+ l.push(re(m, d, p.to, s)), c.push(...(p.effectIds ?? []).map((E) => ({ effectId: E, fromEdgeId: m, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: m, fromNodeId: d, toNodeId: p.to }), d = p.to;
2568
2573
  let g = 0;
2569
2574
  for (; o[d]?.type === "decision"; ) {
2570
2575
  if (++g > Ss) return { ok: !1, error: "DECISION_LOOP" };
2571
- const I = Object.entries(a).filter(([, O]) => O.from !== d || !("guard" in O) ? !1 : Ns(O.guard, s.payload ?? {}));
2572
- if (I.length === 0) break;
2573
- const [_, B] = I[0];
2574
- l.push(re(_, d, B.to, s, !0)), c.push(...(B.effectIds ?? []).map((O) => ({ effectId: O, fromEdgeId: _, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: _, fromNodeId: d, toNodeId: B.to }), d = B.to;
2576
+ const E = Object.entries(a).filter(([, O]) => O.from !== d || !("guard" in O) ? !1 : Ns(O.guard, s.payload ?? {}));
2577
+ if (E.length === 0) break;
2578
+ const [k, T] = E[0];
2579
+ l.push(re(k, d, T.to, s, !0)), c.push(...(T.effectIds ?? []).map((O) => ({ effectId: O, fromEdgeId: k, triggerPayload: s.payload ?? {} }))), u.push({ edgeId: k, fromNodeId: d, toNodeId: T.to }), d = T.to;
2575
2580
  }
2576
- const h = o[d], w = h?.type === "end" ? "completed" : "active", S = {
2581
+ const h = o[d], y = h?.type === "end" ? "completed" : "active", N = {
2577
2582
  ...e,
2578
2583
  currentNodeId: d,
2579
- status: w,
2584
+ status: y,
2580
2585
  history: [...e.history, ...l],
2581
2586
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
2582
- }, k = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: s.payload ?? {} } : void 0;
2583
- return { ok: !0, instance: S, transitionsApplied: u, effectsToFire: c, automationNodePending: k };
2587
+ }, M = h?.type === "automation" && h.automationId ? { nodeId: d, automationId: h.automationId, triggerPayload: s.payload ?? {} } : void 0;
2588
+ return { ok: !0, instance: N, transitionsApplied: u, effectsToFire: c, automationNodePending: M };
2584
2589
  }
2585
2590
  function As(n, e) {
2586
2591
  const s = n.workflows.find((m) => m.id === e.workflowId), { nodes: t, edges: i } = s.diagram, o = t[e.currentNodeId], a = (m) => (m ?? []).flatMap((p) => {
@@ -2638,7 +2643,7 @@ function re(n, e, s, t, i) {
2638
2643
  ...i ? { auto: !0 } : {}
2639
2644
  };
2640
2645
  }
2641
- class Ts {
2646
+ class js {
2642
2647
  instances = /* @__PURE__ */ new Map();
2643
2648
  async listInstances(e) {
2644
2649
  let s = [...this.instances.values()];
@@ -2709,7 +2714,7 @@ class Os {
2709
2714
  * Returns `this` for chaining.
2710
2715
  */
2711
2716
  init(e) {
2712
- return this._runtime = e.runtime, this.storage = e.storage ?? new Ts(), this.skipRaci = e.events?.skipRaci ?? !1, e.runtime._engine = this, this;
2717
+ return this._runtime = e.runtime, this.storage = e.storage ?? new js(), this.skipRaci = e.events?.skipRaci ?? !1, e.runtime._engine = this, this;
2713
2718
  }
2714
2719
  // ─── Remote data ──────────────────────────────────────────────────────────
2715
2720
  async getRemoteData(e) {
@@ -2722,29 +2727,36 @@ class Os {
2722
2727
  // ─── Private workflow instance operations ─────────────────────────────────
2723
2728
  async _create(e, s, t) {
2724
2729
  this._assertInit();
2725
- const i = this.getBep(), a = js(i, e, s, t, "unversioned");
2726
- if (!a) return null;
2727
- const { instance: d, startEffects: l } = a;
2728
- for (const h of l)
2729
- await this._executeEffect(d, h);
2730
- const u = i.workflows.find((h) => h.id === e)?.diagram.nodes[d.currentNodeId];
2731
- let f = u?.type === "automation" && u.automationId ? { automationId: u.automationId, triggerPayload: {} } : void 0, m = d;
2732
- const p = 10;
2733
- let g = 0;
2734
- for (; f && g++ < p; ) {
2735
- const { automationId: h, triggerPayload: w } = f, { eventId: S, ...k } = await this._executeAutomationNode(m, h, w), I = J(i, m, {
2736
- eventId: S,
2737
- actor: "_system",
2738
- softwareId: "_system",
2739
- payload: k
2730
+ let i;
2731
+ if ("rawPayload" in s) {
2732
+ const y = this._runtime.triggers[e];
2733
+ if (!y) throw new Error(`No trigger handler declared for workflow "${e}"`);
2734
+ i = await y(s.rawPayload), t = "dotBEP";
2735
+ } else
2736
+ i = s;
2737
+ const o = this.getBep(), d = $s(o, e, i, t, "unversioned");
2738
+ if (!d) return null;
2739
+ const { instance: l, startEffects: c } = d;
2740
+ for (const y of c)
2741
+ await this._executeEffect(l, y);
2742
+ const f = o.workflows.find((y) => y.id === e)?.diagram.nodes[l.currentNodeId];
2743
+ let m = f?.type === "automation" && f.automationId ? { automationId: f.automationId, triggerPayload: {} } : void 0, p = l;
2744
+ const g = 10;
2745
+ let h = 0;
2746
+ for (; m && h++ < g; ) {
2747
+ const { automationId: y, triggerPayload: N } = m, { eventId: M, ...E } = await this._executeAutomationNode(p, y, N), k = J(o, p, {
2748
+ eventId: M,
2749
+ actor: "dotBEP",
2750
+ softwareId: "dotBEP",
2751
+ payload: E
2740
2752
  });
2741
- if (!I.ok) break;
2742
- m = I.instance;
2743
- for (const _ of I.effectsToFire ?? [])
2744
- await this._executeEffect(m, _);
2745
- f = I.automationNodePending;
2753
+ if (!k.ok) break;
2754
+ p = k.instance;
2755
+ for (const T of k.effectsToFire ?? [])
2756
+ await this._executeEffect(p, T);
2757
+ m = k.automationNodePending;
2746
2758
  }
2747
- return await this.storage.saveInstance(m), await this._fire(this._createdListeners, m), m;
2759
+ return await this.storage.saveInstance(p), await this._fire(this._createdListeners, p), p;
2748
2760
  }
2749
2761
  async _emit(e, s) {
2750
2762
  this._assertInit();
@@ -2763,8 +2775,8 @@ class Os {
2763
2775
  const { automationId: f, triggerPayload: m } = o.automationNodePending, { eventId: p, ...g } = await this._executeAutomationNode(l, f, m);
2764
2776
  if (o = J(i, l, {
2765
2777
  eventId: p,
2766
- actor: "_system",
2767
- softwareId: "_system",
2778
+ actor: "dotBEP",
2779
+ softwareId: "dotBEP",
2768
2780
  payload: g
2769
2781
  }), !o.ok) break;
2770
2782
  l = o.instance, a.push(...o.transitionsApplied ?? []);
@@ -2865,7 +2877,7 @@ class Os {
2865
2877
  }
2866
2878
  }
2867
2879
  }
2868
- function Ls(n, e) {
2880
+ function Cs(n, e) {
2869
2881
  const s = /* @__PURE__ */ new Map();
2870
2882
  for (const t of n) {
2871
2883
  const i = [e(t)].flat();
@@ -2874,50 +2886,12 @@ function Ls(n, e) {
2874
2886
  }
2875
2887
  return Array.from(s.entries()).map(([t, i]) => ({ key: t, rows: i }));
2876
2888
  }
2877
- function Cs(n, e = "responsible", s = {}) {
2878
- const { topologicalSort: t = !1 } = s, i = (m) => `_${m}`, o = "#444444", a = Object.entries(n.nodes), d = a.find(([, m]) => m.type === "start")?.[0], l = a.find(([, m]) => m.type === "end")?.[0];
2879
- let c;
2880
- if (t && d) {
2881
- const m = /* @__PURE__ */ new Set(), p = [d], g = [];
2882
- for (; p.length; ) {
2883
- const h = p.shift();
2884
- if (!m.has(h)) {
2885
- m.add(h), g.push(h);
2886
- for (const w of Object.values(n.edges))
2887
- w.from === h && !m.has(w.to) && p.push(w.to);
2888
- }
2889
- }
2890
- for (const [h] of a)
2891
- m.has(h) || g.push(h);
2892
- c = g;
2893
- } else {
2894
- const m = a.map(([p]) => p).filter((p) => p !== d && p !== l);
2895
- c = [
2896
- ...d ? [d] : [],
2897
- ...m,
2898
- ...l ? [l] : []
2899
- ];
2900
- }
2901
- const u = [`flowchart ${n.direction}`];
2902
- for (const m of c) {
2903
- const p = n.nodes[m];
2904
- if (!p) continue;
2905
- const g = p.type === "start" || p.type === "end", w = (p.type === "decision" ? p.label ?? m : p.action?.name ?? p.automation?.name ?? "").replace(/"/g, "&quot;"), S = g || p.type === "decision" ? [] : p[e].roles.map((_) => _.name), k = S.length > 0 ? `"<b>${S.join(" · ")}</b><br/>${w}"` : `"${w || m}"`;
2906
- g ? u.push(` ${i(m)}([${w || p.type.toUpperCase()}])`) : p.type === "decision" ? u.push(` ${i(m)}{${k}}`) : p.type === "automation" ? u.push(` ${i(m)}[[${k}]]`) : u.push(` ${i(m)}(${k})`);
2907
- const I = p[e].roles[0]?.color ?? o;
2908
- g ? u.push(` style ${i(m)} fill:#2962FF,stroke:none`) : u.push(` style ${i(m)} fill:none,stroke:${I},stroke-width:3px`);
2909
- }
2910
- const f = t ? c.flatMap((m) => Object.values(n.edges).filter((p) => p.from === m)) : Object.values(n.edges);
2911
- for (const m of f)
2912
- m.label ? u.push(` ${i(m.from)} -->|${m.label}| ${i(m.to)}`) : u.push(` ${i(m.from)} --> ${i(m.to)}`);
2913
- return u.join(`
2914
- `);
2915
- }
2916
- class Ds {
2889
+ class Ls {
2917
2890
  env;
2918
2891
  effects = {};
2919
2892
  automations = {};
2920
2893
  resolvers = {};
2894
+ triggers = {};
2921
2895
  /** Set by Engine.init() — available inside handlers via this.engine */
2922
2896
  _engine = null;
2923
2897
  get engine() {
@@ -2936,6 +2910,9 @@ class Ds {
2936
2910
  resolver(e, s) {
2937
2911
  return this.resolvers[e] = s, this;
2938
2912
  }
2913
+ trigger(e, s) {
2914
+ return this.triggers[e] = s, this;
2915
+ }
2939
2916
  /** @internal Called by Engine.getRemoteData — keeps env encapsulated inside the Runtime. */
2940
2917
  _runResolver(e, s) {
2941
2918
  const t = this.resolvers[e];
@@ -2954,20 +2931,20 @@ class F {
2954
2931
  },
2955
2932
  de,
2956
2933
  (i, o) => {
2957
- const a = [], d = T("project", i.code, o.deliverableNamingConvention);
2934
+ const a = [], d = j("project", i.code, o.deliverableNamingConvention);
2958
2935
  return d && a.push(d), i.clientId && !o.teams.some((l) => l.id === i.clientId) && a.push(`teams["${i.clientId}"] not found`), a;
2959
2936
  },
2960
2937
  t
2961
- ), this.actions = new Rt(t), this.annexes = new jt(t), this.env = new Ot(t), this.events = new Mt(t), this.effects = new At(t), this.automations = new Tt(t), this.bimUses = new Ct(t, () => this.workflows), this.disciplines = new Dt(t), this.guides = new Ut(t), this.lods = new zt(t), this.lois = new Zt(t), this.loin = new Jt(t), this.lbsNodes = new Xt(t), this.assetTypes = new Kt(t), this.extensions = new qt(t), this.roles = new Wt(t), this.members = new Gt(t), this.milestones = new Vt(t), this.objectives = new Ht(t), this.phases = new Yt(t), this.remoteData = new Qt(t), this.resolvers = new es(t), this.softwares = new ts(t, () => this.assetTypes), this.standards = new ss(t, () => this._zip), this.teams = new ns(t, () => this.members), this.workflows = new os(t, () => this.members, () => this.teams), this.deliverables = new Pt(t, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Lt(t, () => this.members), this.flags = new Ft(t), this.engine = new Os(
2938
+ ), this.actions = new Tt(t), this.annexes = new $t(t), this.env = new Ot(t), this.events = new Bt(t), this.effects = new At(t), this.automations = new jt(t), this.bimUses = new Lt(t, () => this.workflows), this.disciplines = new Dt(t), this.guides = new Ut(t), this.lods = new zt(t), this.lois = new Zt(t), this.loin = new Jt(t), this.lbsNodes = new Gt(t), this.assetTypes = new Kt(t), this.extensions = new qt(t), this.roles = new Wt(t), this.members = new Xt(t), this.milestones = new Vt(t), this.objectives = new Ht(t), this.phases = new Yt(t), this.remoteData = new Qt(t), this.resolvers = new es(t), this.softwares = new ts(t, () => this.assetTypes), this.standards = new ss(t, () => this._zip), this.teams = new ns(t, () => this.members), this.workflows = new os(t, () => this.members, () => this.teams), this.deliverables = new xt(t, () => this.teams, () => this.assetTypes, () => this.lbsNodes, () => this.milestones), this.notes = new Ct(t, () => this.members), this.flags = new Ft(t), this.engine = new Os(
2962
2939
  () => this._data,
2963
2940
  (i) => this.history.get(i)
2964
- ), this.history = new E(
2941
+ ), this.history = new I(
2965
2942
  t,
2966
2943
  (i) => {
2967
2944
  this._data = i;
2968
2945
  },
2969
2946
  () => this._zip
2970
- ), this.nomenclature = new xt(t), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2947
+ ), this.nomenclature = new Pt(t), this.memory = new Z("memory.md", () => this._zip), this.skill = new Z("skills/bep-authoring/SKILL.md", () => this._zip), this.icon = new Z("icon.svg", () => this._zip);
2971
2948
  }
2972
2949
  _data;
2973
2950
  _zip;
@@ -3026,7 +3003,7 @@ class F {
3026
3003
  static async open(e) {
3027
3004
  const s = await se.loadAsync(e), t = s.file("bep.json");
3028
3005
  if (!t) throw new Error("Invalid .bep file: missing bep.json");
3029
- const i = await t.async("string"), o = j(JSON.parse(i));
3006
+ const i = await t.async("string"), o = $(JSON.parse(i));
3030
3007
  return await F._initialize(o, s), new F(o, s);
3031
3008
  }
3032
3009
  /**
@@ -3054,7 +3031,7 @@ class F {
3054
3031
  }
3055
3032
  }
3056
3033
  static create(e) {
3057
- const s = j({
3034
+ const s = $({
3058
3035
  project: { name: e.name, code: e.code, clientId: e.clientId, description: e.description },
3059
3036
  roles: [],
3060
3037
  members: [],
@@ -3198,6 +3175,12 @@ ${t.join(`
3198
3175
  c,
3199
3176
  "}",
3200
3177
  "",
3178
+ "// ─── Triggers ─────────────────────────────────────────────────────────────────",
3179
+ "",
3180
+ "export interface BepTriggers {",
3181
+ " [key: string]: (rawPayload: unknown) => Promise<{ assetTypeId: string; source: string; id: string; label: string }>",
3182
+ "}",
3183
+ "",
3201
3184
  "// ─── Env ──────────────────────────────────────────────────────────────────────",
3202
3185
  "",
3203
3186
  "export interface BepEnv {",
@@ -3210,6 +3193,7 @@ ${t.join(`
3210
3193
  " effects: BepEffects",
3211
3194
  " automations: BepAutomations",
3212
3195
  " resolvers: BepResolvers",
3196
+ " triggers: BepTriggers",
3213
3197
  " env: BepEnv",
3214
3198
  "}",
3215
3199
  ""
@@ -3228,46 +3212,46 @@ ${t.join(`
3228
3212
  }
3229
3213
  export {
3230
3214
  Ee as ActionSchema,
3231
- Rt as Actions,
3232
- Re as AnnexSchema,
3233
- Ge as AnnexType,
3234
- jt as Annexes,
3235
- we as AssetTypeSchema,
3215
+ Tt as Actions,
3216
+ Te as AnnexSchema,
3217
+ Xe as AnnexType,
3218
+ $t as Annexes,
3219
+ ye as AssetTypeSchema,
3236
3220
  Kt as AssetTypes,
3237
- Tt as Automations,
3238
- Ps as BEPSchema,
3221
+ jt as Automations,
3222
+ xs as BEPSchema,
3239
3223
  ne as BEPVersionBase,
3240
3224
  It as BEPVersionSchema,
3241
3225
  Ie as BIMUseSchema,
3242
- Ct as BIMUses,
3226
+ Lt as BIMUses,
3243
3227
  F as Bep,
3244
3228
  Fs as ChangelogSchema,
3245
3229
  Et as DEFAULT_DELIMITER,
3246
3230
  St as DEFAULT_TOKEN_PATTERN,
3247
3231
  bt as DeliverableBaseSchema,
3248
- Pe as DeliverableSchema,
3249
- Pt as Deliverables,
3232
+ xe as DeliverableSchema,
3233
+ xt as Deliverables,
3250
3234
  ge as DisciplineSchema,
3251
3235
  Dt as Disciplines,
3252
3236
  ut as EdgeGuardSchema,
3253
3237
  At as Effects,
3254
3238
  Os as Engine,
3255
- y as Entity,
3239
+ w as Entity,
3256
3240
  Ot as Env,
3257
3241
  Fe as EnvVarSchema,
3258
- Mt as Events,
3259
- ye as ExtensionSchema,
3242
+ Bt as Events,
3243
+ we as ExtensionSchema,
3260
3244
  qt as Extensions,
3261
3245
  vt as FlagBaseSchema,
3262
3246
  Qe as FlagEntityType,
3263
- xe as FlagSchema,
3247
+ Pe as FlagSchema,
3264
3248
  Ye as FlagSeverity,
3265
3249
  Ft as Flags,
3266
3250
  lt as FlowAutomationNodeSchema,
3267
3251
  ke as FlowAutomationSchema,
3268
3252
  pt as FlowDecisionEdgeSchema,
3269
3253
  dt as FlowDecisionNodeSchema,
3270
- yt as FlowDiagramSchema,
3254
+ wt as FlowDiagramSchema,
3271
3255
  ht as FlowDirectEdgeSchema,
3272
3256
  He as FlowDirection,
3273
3257
  gt as FlowEdgeSchema,
@@ -3275,50 +3259,50 @@ export {
3275
3259
  at as FlowEndNodeSchema,
3276
3260
  Se as FlowEventSchema,
3277
3261
  ft as FlowNodeSchema,
3278
- L as FlowPayloadFieldSchema,
3262
+ C as FlowPayloadFieldSchema,
3279
3263
  ct as FlowProcessNodeSchema,
3280
3264
  rt as FlowStartNodeSchema,
3281
3265
  mt as FlowTransitionEdgeSchema,
3282
- je as GuideSchema,
3266
+ $e as GuideSchema,
3283
3267
  Ut as Guides,
3284
- E as History,
3285
- Xe as ISORole,
3268
+ I as History,
3269
+ Ge as ISORole,
3286
3270
  nt as LBSNodeBaseSchema,
3287
3271
  he as LBSNodeSchema,
3288
3272
  Ve as LBSNodeType,
3289
- Xt as LBSNodes,
3290
- Te as LODSchema,
3273
+ Gt as LBSNodes,
3274
+ je as LODSchema,
3291
3275
  zt as LODs,
3292
3276
  Jt as LOINEntity,
3293
- wt as LOINMilestoneSchema,
3294
- Me as LOINSchema,
3277
+ yt as LOINMilestoneSchema,
3278
+ Be as LOINSchema,
3295
3279
  Oe as LOISchema,
3296
3280
  Zt as LOIs,
3297
3281
  ce as MemberSchema,
3298
- Gt as Members,
3299
- Ts as MemoryStorage,
3282
+ Xt as Members,
3283
+ js as MemoryStorage,
3300
3284
  pe as MilestoneSchema,
3301
3285
  Vt as Milestones,
3302
3286
  ue as NamingConventionSchema,
3303
3287
  st as NamingSegmentSchema,
3304
3288
  tt as NamingTokenSchema,
3305
3289
  it as NodeTimeoutSchema,
3306
- xs as NodeType,
3307
- xt as Nomenclature,
3308
- Be as NoteSchema,
3309
- Lt as Notes,
3290
+ Ps as NodeType,
3291
+ Pt as Nomenclature,
3292
+ Me as NoteSchema,
3293
+ Ct as Notes,
3310
3294
  be as ObjectiveSchema,
3311
3295
  Ht as Objectives,
3312
3296
  me as PhaseSchema,
3313
3297
  Yt as Phases,
3314
3298
  de as ProjectSchema,
3315
3299
  Qt as RemoteDataEntity,
3316
- Ce as RemoteDataSchema,
3317
- Le as ResolverSchema,
3300
+ Le as RemoteDataSchema,
3301
+ Ce as ResolverSchema,
3318
3302
  es as Resolvers,
3319
3303
  le as RoleSchema,
3320
3304
  Wt as Roles,
3321
- Ds as Runtime,
3305
+ Ls as Runtime,
3322
3306
  _t as Singleton,
3323
3307
  ve as SoftwareSchema,
3324
3308
  ts as Softwares,
@@ -3328,22 +3312,21 @@ export {
3328
3312
  fe as TeamSchema,
3329
3313
  ns as Teams,
3330
3314
  Z as TextFile,
3331
- $e as WorkflowSchema,
3315
+ Re as WorkflowSchema,
3332
3316
  os as Workflows,
3333
3317
  bs as arrayDefs,
3334
3318
  Ze as buildCodeMap,
3335
3319
  K as buildConsecutivoMap,
3336
- P as buildParentMap,
3320
+ x as buildParentMap,
3337
3321
  Es as diffBep,
3338
3322
  Is as diffEntities,
3339
- Cs as flowDiagramToMermaid,
3340
3323
  ze as getNomenCode,
3341
3324
  Q as getRootIds,
3342
3325
  Nt as getTokenPattern,
3343
- Ls as groupRaciRows,
3344
- j as normalizeBep,
3326
+ Cs as groupRaciRows,
3327
+ $ as normalizeBep,
3345
3328
  Ue as resolveLBSCodes,
3346
3329
  kt as validateAllTokens,
3347
- Bt as validateLBS,
3348
- T as validateTokenValue
3330
+ Mt as validateLBS,
3331
+ j as validateTokenValue
3349
3332
  };