@dialecte/scl 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/{hooks-D5DJSztS.js → hooks-CLIa7kxj.js} +1075 -902
  2. package/dist/v2019C1/constants/index.d.ts +3 -0
  3. package/dist/v2019C1/constants/index.d.ts.map +1 -1
  4. package/dist/v2019C1/constants/naming.d.ts +3 -0
  5. package/dist/v2019C1/constants/naming.d.ts.map +1 -0
  6. package/dist/v2019C1/constants/topology-tags.d.ts +15 -0
  7. package/dist/v2019C1/constants/topology-tags.d.ts.map +1 -0
  8. package/dist/v2019C1/constants/topology-tags.types.d.ts +6 -0
  9. package/dist/v2019C1/constants/topology-tags.types.d.ts.map +1 -0
  10. package/dist/v2019C1/extensions/data-model/transaction/import-types.d.ts.map +1 -1
  11. package/dist/v2019C1/extensions/identity/transaction/restore-cloned-uuids.d.ts +8 -10
  12. package/dist/v2019C1/extensions/identity/transaction/restore-cloned-uuids.d.ts.map +1 -1
  13. package/dist/v2019C1/extensions/lifecycle/engine/reconcile.d.ts.map +1 -1
  14. package/dist/v2019C1/extensions/lifecycle/extract/transaction/ensure-substation-structure.d.ts.map +1 -1
  15. package/dist/v2019C1/extensions/lifecycle/extract/transaction/index.d.ts +1 -0
  16. package/dist/v2019C1/extensions/lifecycle/extract/transaction/index.d.ts.map +1 -1
  17. package/dist/v2019C1/extensions/lifecycle/extract/transaction/ssd.d.ts +20 -0
  18. package/dist/v2019C1/extensions/lifecycle/extract/transaction/ssd.d.ts.map +1 -0
  19. package/dist/v2019C1/extensions/lifecycle/instance/find-instance.d.ts +3 -0
  20. package/dist/v2019C1/extensions/lifecycle/instance/find-instance.d.ts.map +1 -1
  21. package/dist/v2019C1/extensions/lifecycle/instantiate/transaction/asd.d.ts.map +1 -1
  22. package/dist/v2019C1/extensions/lifecycle/instantiate/transaction/fsd.d.ts.map +1 -1
  23. package/dist/v2019C1/extensions/lifecycle/layers/omit-filters.d.ts +6 -0
  24. package/dist/v2019C1/extensions/lifecycle/layers/omit-filters.d.ts.map +1 -1
  25. package/dist/v2019C1/extensions/lifecycle/layers/topology/clone-topology-content.d.ts +27 -0
  26. package/dist/v2019C1/extensions/lifecycle/layers/topology/clone-topology-content.d.ts.map +1 -0
  27. package/dist/v2019C1/extensions/lifecycle/layers/topology/index.d.ts +3 -0
  28. package/dist/v2019C1/extensions/lifecycle/layers/topology/index.d.ts.map +1 -0
  29. package/dist/v2019C1/extensions/lifecycle/layers/topology/root-selection.d.ts +14 -0
  30. package/dist/v2019C1/extensions/lifecycle/layers/topology/root-selection.d.ts.map +1 -0
  31. package/dist/v2019C1/extensions/lifecycle/report/query/report-asd.d.ts.map +1 -1
  32. package/dist/v2019C1/extensions/lifecycle/transplant/transaction/primitives/merge-children-into.d.ts +1 -1
  33. package/dist/v2019C1/extensions/lifecycle/transplant/transaction/primitives/merge-children-into.d.ts.map +1 -1
  34. package/dist/v2019C1/extensions/lifecycle/update/transaction/asd.d.ts.map +1 -1
  35. package/dist/v2019C1/extensions/lifecycle/update/transaction/cross-cutting-satellites.d.ts +4 -0
  36. package/dist/v2019C1/extensions/lifecycle/update/transaction/cross-cutting-satellites.d.ts.map +1 -1
  37. package/dist/v2019C1/extensions/lifecycle/update/transaction/fsd.d.ts.map +1 -1
  38. package/dist/v2019C1/extensions/lifecycle/update/transaction/function-satellites.d.ts +6 -0
  39. package/dist/v2019C1/extensions/lifecycle/update/transaction/function-satellites.d.ts.map +1 -1
  40. package/dist/v2019C1/extensions/lifecycle/update/transaction/satellite-reconcile.d.ts +6 -0
  41. package/dist/v2019C1/extensions/lifecycle/update/transaction/satellite-reconcile.d.ts.map +1 -1
  42. package/dist/v2019C1/extensions/reference/transaction/index.d.ts +1 -1
  43. package/dist/v2019C1/extensions/reference/transaction/index.d.ts.map +1 -1
  44. package/dist/v2019C1/extensions/reference/transaction/write-provenance.d.ts +9 -9
  45. package/dist/v2019C1/extensions/reference/transaction/write-provenance.d.ts.map +1 -1
  46. package/dist/v2019C1/extensions/reference/transaction/write-provenance.types.d.ts +22 -7
  47. package/dist/v2019C1/extensions/reference/transaction/write-provenance.types.d.ts.map +1 -1
  48. package/dist/v2019C1/index.js +10 -10
  49. package/dist/v2019C1/test/fixtures/generate-scl-stress-fixtures.d.ts +13 -0
  50. package/dist/v2019C1/test/fixtures/generate-scl-stress-fixtures.d.ts.map +1 -0
  51. package/dist/v2019C1/test/fixtures/run-scl-benchmarks.d.ts +2 -0
  52. package/dist/v2019C1/test/fixtures/run-scl-benchmarks.d.ts.map +1 -0
  53. package/dist/v2019C1/test/hydrated-test.d.ts +3 -0
  54. package/dist/v2019C1/test/hydrated-test.d.ts.map +1 -1
  55. package/dist/v2019C1/test.js +4 -3
  56. package/package.json +2 -2
@@ -24597,7 +24597,7 @@ async function S(e, n) {
24597
24597
  tagName: "DOType",
24598
24598
  attributes: { id: n }
24599
24599
  });
24600
- r && C(i.doTypes, n, r) && await w({
24600
+ r && C(i.doTypes, n, r) && await ee({
24601
24601
  query: e,
24602
24602
  parent: r,
24603
24603
  dataModelMap: i
@@ -24614,7 +24614,7 @@ async function S(e, n) {
24614
24614
  function C(e, t, n) {
24615
24615
  return e.has(t) ? !1 : (e.set(t, n), !0);
24616
24616
  }
24617
- async function w(e) {
24617
+ async function ee(e) {
24618
24618
  let { query: n, parent: r, dataModelMap: i } = e, a = r.tagName === "DOType" ? await n.getRecords(r.children.filter((e) => t(e, "DA"))) : await n.getRecords(r.children.filter((e) => t(e, "BDA")));
24619
24619
  for (let e of a) {
24620
24620
  if (!e) continue;
@@ -24631,7 +24631,7 @@ async function w(e) {
24631
24631
  tagName: "DAType",
24632
24632
  attributes: { id: r }
24633
24633
  });
24634
- e && C(i.daTypes, r, e) && await w({
24634
+ e && C(i.daTypes, r, e) && await ee({
24635
24635
  query: n,
24636
24636
  parent: e,
24637
24637
  dataModelMap: i
@@ -24648,7 +24648,7 @@ async function w(e) {
24648
24648
  tagName: "DOType",
24649
24649
  attributes: { id: t }
24650
24650
  });
24651
- r && C(i.doTypes, t, r) && await w({
24651
+ r && C(i.doTypes, t, r) && await ee({
24652
24652
  query: n,
24653
24653
  parent: r,
24654
24654
  dataModelMap: i
@@ -24658,15 +24658,15 @@ async function w(e) {
24658
24658
  }
24659
24659
  //#endregion
24660
24660
  //#region src/v2019C1/extensions/data-model/query/is-lnode-locked.ts
24661
- var ee = "None";
24662
- async function te(e, t) {
24661
+ var te = "None";
24662
+ async function w(e, t) {
24663
24663
  let n = await e.any.getAttribute(t, { name: "iedName" });
24664
- return !!n && n !== ee;
24664
+ return !!n && n !== te;
24665
24665
  }
24666
24666
  //#endregion
24667
24667
  //#region src/v2019C1/extensions/data-model/query/index.ts
24668
24668
  var ne = /* @__PURE__ */ l({
24669
- isLNodeLocked: () => te,
24669
+ isLNodeLocked: () => w,
24670
24670
  resolve: () => S
24671
24671
  });
24672
24672
  //#endregion
@@ -24674,7 +24674,7 @@ var ne = /* @__PURE__ */ l({
24674
24674
  async function re(e) {
24675
24675
  let t = await e.getRecordsByTagName("LNode");
24676
24676
  for (let n of t) {
24677
- if (!await te(e, n)) {
24677
+ if (!await w(e, n)) {
24678
24678
  await e.update(n, { attributes: { iedName: "None" } });
24679
24679
  continue;
24680
24680
  }
@@ -25287,10 +25287,19 @@ var D = {
25287
25287
  "InputVar",
25288
25288
  "OutputVar",
25289
25289
  "ProcessEcho"
25290
- ]), k = Object.keys(D), A = new Set(k), pe = new Set(Object.values(D).flatMap((e) => e.flatMap((e) => e.target)));
25290
+ ]), pe = Object.keys(D), k = new Set(pe), me = new Set(Object.values(D).flatMap((e) => e.flatMap((e) => e.target))), he = "TEMPLATE", ge = [
25291
+ "Substation",
25292
+ "VoltageLevel",
25293
+ "Bay"
25294
+ ], _e = [
25295
+ "ConductingEquipment",
25296
+ "PowerTransformer",
25297
+ "GeneralEquipment",
25298
+ "ConnectivityNode"
25299
+ ];
25291
25300
  //#endregion
25292
25301
  //#region src/v2019C1/extensions/reference/query/resolve/parse-path.ts
25293
- function me(e) {
25302
+ function ve(e) {
25294
25303
  if (!e) return [];
25295
25304
  let t = [], n = "", r = "/";
25296
25305
  for (let i of e) i === "/" || i === "." ? (n && t.push({
@@ -25302,7 +25311,7 @@ function me(e) {
25302
25311
  separator: r
25303
25312
  }), t;
25304
25313
  }
25305
- function he(e) {
25314
+ function A(e) {
25306
25315
  let t = e.split("/"), n = t[t.length - 1], r = n.indexOf(".");
25307
25316
  if (r === -1) return { path: e };
25308
25317
  let i = n.substring(0, r), a = n.substring(r + 1);
@@ -25311,19 +25320,19 @@ function he(e) {
25311
25320
  qualifier: a || void 0
25312
25321
  };
25313
25322
  }
25314
- function ge(e, t, n, r) {
25315
- return !e || e === M.unsupported ? null : e === M.direct ? { lookupKey: n } : e === M.iedAddress ? ve(n, r) : e === M.lnode ? _e(n) : e === M.behaviorDescription ? ye(t, n, r) : null;
25323
+ function ye(e, t, n, r) {
25324
+ return !e || e === M.unsupported ? null : e === M.direct ? { lookupKey: n } : e === M.iedAddress ? xe(n, r) : e === M.lnode ? be(n) : e === M.behaviorDescription ? Se(t, n, r) : null;
25316
25325
  }
25317
- function _e(e) {
25318
- let { path: t, qualifier: n } = he(e);
25326
+ function be(e) {
25327
+ let { path: t, qualifier: n } = A(e);
25319
25328
  return {
25320
25329
  lookupKey: t,
25321
25330
  qualifier: n
25322
25331
  };
25323
25332
  }
25324
- function ve(e, t) {
25333
+ function xe(e, t) {
25325
25334
  if (t) {
25326
- let n = Se(t);
25335
+ let n = Te(t);
25327
25336
  if (n) return {
25328
25337
  lookupKey: e,
25329
25338
  fallbackLookupKey: `${n}/${e}`
@@ -25331,15 +25340,15 @@ function ve(e, t) {
25331
25340
  }
25332
25341
  return { lookupKey: e };
25333
25342
  }
25334
- function ye(e, t, n) {
25343
+ function Se(e, t, n) {
25335
25344
  if (!n) return null;
25336
- let r = be(n);
25345
+ let r = Ce(n);
25337
25346
  return r ? e === "dataName" ? {
25338
25347
  lookupKey: r,
25339
25348
  qualifier: t
25340
- } : e === "inputName" || e === "outputName" ? { lookupKey: `${r}.${xe(t)}` } : null : null;
25349
+ } : e === "inputName" || e === "outputName" ? { lookupKey: `${r}.${we(t)}` } : null : null;
25341
25350
  }
25342
- function be(e) {
25351
+ function Ce(e) {
25343
25352
  let t = -1;
25344
25353
  for (let n = e.length - 1; n >= 0; n--) if (e[n].tagName === "BehaviorDescription") {
25345
25354
  t = n;
@@ -25353,11 +25362,11 @@ function be(e) {
25353
25362
  }
25354
25363
  return n.length === 0 ? null : de(n);
25355
25364
  }
25356
- function xe(e) {
25365
+ function we(e) {
25357
25366
  let t = e.indexOf("("), n = e.indexOf(".");
25358
25367
  return t === -1 ? n === -1 ? e : e.substring(0, n) : e.substring(0, t);
25359
25368
  }
25360
- function Se(e) {
25369
+ function Te(e) {
25361
25370
  for (let t = e.length - 1; t >= 0; t--) if (e[t].tagName === "LNode") return e[t].attributes.find((e) => e.name === "iedName")?.value ?? null;
25362
25371
  return null;
25363
25372
  }
@@ -25366,7 +25375,7 @@ function Se(e) {
25366
25375
  async function j(e, t) {
25367
25376
  let { reference: n, target: r } = t;
25368
25377
  if (P.has(n.tagName)) return null;
25369
- let a = Te(n.tagName, r.tagName);
25378
+ let a = Oe(n.tagName, r.tagName);
25370
25379
  if (!a) return null;
25371
25380
  let o = a.resolution;
25372
25381
  if (o === M.behaviorDescription) {
@@ -25379,12 +25388,12 @@ async function j(e, t) {
25379
25388
  if (o === M.lnode) {
25380
25389
  let t = await e.getRecord(n);
25381
25390
  if (!t) return c;
25382
- let r = we(t, a);
25383
- return r ? `${c}.${Ce(t, a) ?? r}` : c;
25391
+ let r = De(t, a);
25392
+ return r ? `${c}.${Ee(t, a) ?? r}` : c;
25384
25393
  }
25385
25394
  return c;
25386
25395
  }
25387
- function Ce(e, t) {
25396
+ function Ee(e, t) {
25388
25397
  let [n, r] = t.companions;
25389
25398
  if (!n) return;
25390
25399
  let i = e.attributes.find((e) => e.name === n.name)?.value;
@@ -25392,11 +25401,11 @@ function Ce(e, t) {
25392
25401
  let a = r ? e.attributes.find((e) => e.name === r.name)?.value : void 0;
25393
25402
  return a ? `${i}.${a}` : i;
25394
25403
  }
25395
- function we(e, t) {
25404
+ function De(e, t) {
25396
25405
  let n = e.attributes.find((e) => e.name === t.attribute.path)?.value;
25397
- if (n) return he(n).qualifier;
25406
+ if (n) return A(n).qualifier;
25398
25407
  }
25399
- function Te(e, t) {
25408
+ function Oe(e, t) {
25400
25409
  let n = D[e];
25401
25410
  return n ? n.find((e) => e.target.includes(t)) ?? null : null;
25402
25411
  }
@@ -25462,7 +25471,7 @@ var M = {
25462
25471
  };
25463
25472
  //#endregion
25464
25473
  //#region src/v2019C1/extensions/reference/constants/helpers.ts
25465
- function Ee(e) {
25474
+ function ke(e) {
25466
25475
  let t = {};
25467
25476
  for (let [n, r] of Object.entries(e)) for (let e of r) {
25468
25477
  let r = t[e.resolution] ??= /* @__PURE__ */ new Map();
@@ -25477,7 +25486,7 @@ function Ee(e) {
25477
25486
  }
25478
25487
  return t;
25479
25488
  }
25480
- function De(e) {
25489
+ function Ae(e) {
25481
25490
  let t = /* @__PURE__ */ new Map();
25482
25491
  for (let [n, r] of Object.entries(e)) t.set(n, r.map((e) => ({
25483
25492
  uuidAttr: e.attribute.uuid,
@@ -25487,7 +25496,7 @@ function De(e) {
25487
25496
  })));
25488
25497
  return t;
25489
25498
  }
25490
- function Oe(e) {
25499
+ function je(e) {
25491
25500
  let t = /* @__PURE__ */ new Map();
25492
25501
  for (let [n, r] of Object.entries(e)) for (let e of r) {
25493
25502
  let r = t.get(e.target) ?? [];
@@ -25501,15 +25510,15 @@ function Oe(e) {
25501
25510
  }
25502
25511
  //#endregion
25503
25512
  //#region src/v2019C1/extensions/reference/constants/derived.ts
25504
- var ke = Ee(D), Ae = [
25513
+ var Me = ke(D), Ne = [
25505
25514
  M.direct,
25506
25515
  M.lnode,
25507
25516
  M.iedAddress,
25508
25517
  M.behaviorDescription
25509
- ], je = [...Ae, M.unsupported], Me = De(D), P = new Map(Object.entries(D).flatMap(([e, t]) => t.filter((e) => e.attribute.path === "mappedDoName" || e.attribute.path === "mappedDaName").map((t) => [e, {
25518
+ ], Pe = [...Ne, M.unsupported], Fe = Ae(D), P = new Map(Object.entries(D).flatMap(([e, t]) => t.filter((e) => e.attribute.path === "mappedDoName" || e.attribute.path === "mappedDaName").map((t) => [e, {
25510
25519
  path: t.attribute.path,
25511
25520
  uuid: t.attribute.uuid
25512
- }]))), Ne = [...new Set(Object.values(D).flatMap((e) => e.map((e) => e.attribute.uuid)))], F = new Map(Object.entries(N).map(([e, t]) => [e, [...new Set(t.map((e) => e.attribute))]])), Pe = Oe(N), Fe = new Set(Pe.keys()), Ie = new Set([..._.LNode?.attributes?.identityFields ?? [], ...F.get("LNode") ?? []]), Le = {
25521
+ }]))), Ie = [...new Set(Object.values(D).flatMap((e) => e.map((e) => e.attribute.uuid)))], Le = new Map(Object.entries(N).map(([e, t]) => [e, [...new Set(t.map((e) => e.attribute))]])), Re = je(N), ze = new Set(Re.keys()), Be = new Set([..._.LNode?.attributes?.identityFields ?? [], ...Le.get("LNode") ?? []]), Ve = {
25513
25522
  FunctionCatRef: ["SubCategory", "FunctionCategory"],
25514
25523
  PowerSystemRelation: ["PowerSystemRelations"],
25515
25524
  Resource: ["ProcessResource", "ProcessResources"],
@@ -25517,22 +25526,22 @@ var ke = Ee(D), Ae = [
25517
25526
  };
25518
25527
  //#endregion
25519
25528
  //#region src/v2019C1/extensions/reference/query/build/build-mapped-name.ts
25520
- async function Re(e, t) {
25529
+ async function He(e, t) {
25521
25530
  let n = P.get(t.tagName);
25522
25531
  if (!n) return;
25523
25532
  let r = t.attributes.find((e) => e.name === "name")?.value;
25524
25533
  if (!r) return;
25525
- let i = t.attributes.find((e) => e.name === n.path)?.value, a = ze(i, t.tagName === "DAS" && !await Be(e, t)) ?? r;
25534
+ let i = t.attributes.find((e) => e.name === n.path)?.value, a = Ue(i, t.tagName === "DAS" && !await We(e, t)) ?? r;
25526
25535
  return a === r ? void 0 : a;
25527
25536
  }
25528
- function ze(e, t) {
25537
+ function Ue(e, t) {
25529
25538
  if (!e) return;
25530
- let { path: n, qualifier: r } = he(e), i = r ?? n;
25539
+ let { path: n, qualifier: r } = A(e), i = r ?? n;
25531
25540
  if (t) return i || void 0;
25532
25541
  let a = i.split(".");
25533
25542
  return a[a.length - 1] || void 0;
25534
25543
  }
25535
- async function Be(e, t) {
25544
+ async function We(e, t) {
25536
25545
  let n = (await e.findAncestors(t)).find((e) => e.tagName === "DOS" || e.tagName === "SDS");
25537
25546
  return n ? !!await e.getAttribute({
25538
25547
  tagName: n.tagName,
@@ -25541,32 +25550,32 @@ async function Be(e, t) {
25541
25550
  }
25542
25551
  //#endregion
25543
25552
  //#region src/v2019C1/extensions/reference/query/build/build-mapped-lnode-path.ts
25544
- function Ve(e) {
25553
+ function Ge(e) {
25545
25554
  let t = e.iedName;
25546
- if (!t || t === He) return null;
25555
+ if (!t || t === Ke) return null;
25547
25556
  let n = e.ldInst, r = e.lnClass;
25548
25557
  return !n || !r ? null : `${t}/${n}/${`${e.prefix ?? ""}${r}${e.lnInst ?? ""}`}`;
25549
25558
  }
25550
- var He = "None";
25559
+ var Ke = "None";
25551
25560
  //#endregion
25552
25561
  //#region src/v2019C1/extensions/reference/query/resolve/resolve-reference-path.ts
25553
- async function Ue(e, t, n) {
25554
- let r = We(t.tagName, n);
25562
+ async function qe(e, t, n) {
25563
+ let r = Je(t.tagName, n);
25555
25564
  if (!r) return;
25556
25565
  let a = t.attributes.find((e) => e.name === n)?.value;
25557
25566
  if (!a) return;
25558
- let o = await Ge(e, t, r);
25567
+ let o = await Ye(e, t, r);
25559
25568
  if (o) return {
25560
25569
  record: o,
25561
- qualifier: Ke(r, n, a)
25570
+ qualifier: Xe(r, n, a)
25562
25571
  };
25563
25572
  let s;
25564
25573
  (r.resolution === M.behaviorDescription || r.resolution === M.iedAddress) && (s = (await e.findAncestors(t, { order: "top-down" })).map((e) => i(e)));
25565
- let c = ge(r.resolution, n, a, s);
25574
+ let c = ye(r.resolution, n, a, s);
25566
25575
  if (!c) return;
25567
- let l = me(c.lookupKey);
25576
+ let l = ve(c.lookupKey);
25568
25577
  if (l.length === 0) return;
25569
- let u = l[l.length - 1], d = l.slice(0, -1), f = await Xe({
25578
+ let u = l[l.length - 1], d = l.slice(0, -1), f = await et({
25570
25579
  query: e,
25571
25580
  targets: r.target,
25572
25581
  segment: u,
@@ -25577,11 +25586,11 @@ async function Ue(e, t, n) {
25577
25586
  qualifier: c.qualifier
25578
25587
  };
25579
25588
  }
25580
- function We(e, t) {
25589
+ function Je(e, t) {
25581
25590
  let n = D[e];
25582
25591
  if (n) return n.find((e) => e.attribute.path === t);
25583
25592
  }
25584
- async function Ge(e, t, n) {
25593
+ async function Ye(e, t, n) {
25585
25594
  let r = n.attribute.uuid, i = t.attributes.find((e) => e.name === r)?.value;
25586
25595
  if (i) for (let t of n.target) {
25587
25596
  let n = await e.findByAttributes({
@@ -25591,19 +25600,19 @@ async function Ge(e, t, n) {
25591
25600
  if (n.length > 0) return n[0];
25592
25601
  }
25593
25602
  }
25594
- function Ke(e, t, n) {
25595
- if (e.resolution === M.lnode) return he(n).qualifier;
25603
+ function Xe(e, t, n) {
25604
+ if (e.resolution === M.lnode) return A(n).qualifier;
25596
25605
  if (e.resolution === M.behaviorDescription && t === "dataName") return n;
25597
25606
  }
25598
- var qe = new Set(_.LNode.attributes.details.lnClass.facets.enumeration), Je = {
25607
+ var Ze = new Set(_.LNode.attributes.details.lnClass.facets.enumeration), Qe = {
25599
25608
  LNode: "lnInst",
25600
25609
  LN: "inst",
25601
25610
  LN0: "inst"
25602
25611
  };
25603
- function Ye(e) {
25612
+ function $e(e) {
25604
25613
  for (let t = 0; t <= e.length - 4; t++) {
25605
25614
  let n = e.substring(t, t + 4);
25606
- if (qe.has(n)) return {
25615
+ if (Ze.has(n)) return {
25607
25616
  prefix: e.substring(0, t),
25608
25617
  lnClass: n,
25609
25618
  inst: e.substring(t + 4)
@@ -25611,12 +25620,12 @@ function Ye(e) {
25611
25620
  }
25612
25621
  return null;
25613
25622
  }
25614
- async function Xe(e) {
25623
+ async function et(e) {
25615
25624
  let { query: t, targets: n, segment: r, expectedAncestry: i } = e;
25616
25625
  for (let e of n) {
25617
- let n = Je[e];
25626
+ let n = Qe[e];
25618
25627
  if (n) {
25619
- let a = await Ze({
25628
+ let a = await tt({
25620
25629
  query: t,
25621
25630
  tagName: e,
25622
25631
  segment: r,
@@ -25625,7 +25634,7 @@ async function Xe(e) {
25625
25634
  });
25626
25635
  if (a) return a;
25627
25636
  } else {
25628
- let n = await Qe({
25637
+ let n = await nt({
25629
25638
  query: t,
25630
25639
  tagName: e,
25631
25640
  segment: r,
@@ -25635,8 +25644,8 @@ async function Xe(e) {
25635
25644
  }
25636
25645
  }
25637
25646
  }
25638
- async function Ze(e) {
25639
- let { query: t, tagName: n, segment: r, instAttr: i, expectedAncestry: a } = e, o = Ye(r.segment);
25647
+ async function tt(e) {
25648
+ let { query: t, tagName: n, segment: r, instAttr: i, expectedAncestry: a } = e, o = $e(r.segment);
25640
25649
  if (!o) return;
25641
25650
  let s = await t.findByAttributes({
25642
25651
  tagName: n,
@@ -25644,17 +25653,17 @@ async function Ze(e) {
25644
25653
  });
25645
25654
  for (let e of s) {
25646
25655
  let n = e.attributes.find((e) => e.name === "prefix")?.value ?? "", r = e.attributes.find((e) => e.name === i)?.value ?? "";
25647
- if (!(n !== o.prefix || r !== o.inst) && await $e(t, e, a)) return e;
25656
+ if (!(n !== o.prefix || r !== o.inst) && await rt(t, e, a)) return e;
25648
25657
  }
25649
25658
  }
25650
- async function Qe(e) {
25659
+ async function nt(e) {
25651
25660
  let { query: t, tagName: n, segment: r, expectedAncestry: a } = e, o = await t.getRecordsByTagName(n);
25652
25661
  for (let e of o) {
25653
25662
  let n = T(i(e));
25654
- if (!(!n || n.segment !== r.segment) && await $e(t, e, a)) return e;
25663
+ if (!(!n || n.segment !== r.segment) && await rt(t, e, a)) return e;
25655
25664
  }
25656
25665
  }
25657
- async function $e(e, t, n) {
25666
+ async function rt(e, t, n) {
25658
25667
  if (n.length === 0) return !0;
25659
25668
  let r = await e.findAncestors(t), a = [];
25660
25669
  for (let e = r.length - 1; e >= 0; e--) {
@@ -25665,16 +25674,16 @@ async function $e(e, t, n) {
25665
25674
  }
25666
25675
  //#endregion
25667
25676
  //#region src/v2019C1/extensions/reference/query/resolve/resolve-element-path.ts
25668
- async function et(e, t) {
25669
- let n = me(t);
25670
- if (n.length !== 0) return tt({
25677
+ async function it(e, t) {
25678
+ let n = ve(t);
25679
+ if (n.length !== 0) return at({
25671
25680
  query: e,
25672
25681
  current: await e.getRoot(),
25673
25682
  segments: n,
25674
25683
  index: 0
25675
25684
  });
25676
25685
  }
25677
- async function tt(e) {
25686
+ async function at(e) {
25678
25687
  let { query: t, current: n, segments: r, index: a } = e;
25679
25688
  if (a >= r.length) return n;
25680
25689
  let o = n.children ?? [];
@@ -25684,7 +25693,7 @@ async function tt(e) {
25684
25693
  if (!e) continue;
25685
25694
  let n = T(i(e));
25686
25695
  if (!n) {
25687
- let n = await tt({
25696
+ let n = await at({
25688
25697
  query: t,
25689
25698
  current: e,
25690
25699
  segments: r,
@@ -25694,7 +25703,7 @@ async function tt(e) {
25694
25703
  continue;
25695
25704
  }
25696
25705
  if (n.segment === c.segment && n.separator === c.separator) {
25697
- let n = await tt({
25706
+ let n = await at({
25698
25707
  query: t,
25699
25708
  current: e,
25700
25709
  segments: r,
@@ -25707,14 +25716,14 @@ async function tt(e) {
25707
25716
  }
25708
25717
  //#endregion
25709
25718
  //#region src/v2019C1/extensions/reference/query/resolve/resolve-mapped-lnode.ts
25710
- var nt = new Set(["LN", "LN0"]);
25711
- async function rt(e, t) {
25712
- let n = Ve(it(t));
25719
+ var ot = new Set(["LN", "LN0"]);
25720
+ async function st(e, t) {
25721
+ let n = Ge(ct(t));
25713
25722
  if (!n) return;
25714
- let r = await et(e, n);
25715
- if (!(!r || !nt.has(r.tagName))) return r;
25723
+ let r = await it(e, n);
25724
+ if (!(!r || !ot.has(r.tagName))) return r;
25716
25725
  }
25717
- function it(e) {
25726
+ function ct(e) {
25718
25727
  let t = (t) => e.attributes.find((e) => e.name === t)?.value;
25719
25728
  return {
25720
25729
  iedName: t("iedName"),
@@ -25726,19 +25735,19 @@ function it(e) {
25726
25735
  }
25727
25736
  //#endregion
25728
25737
  //#region src/v2019C1/extensions/reference/guards.ts
25729
- function at(e) {
25730
- return Fe.has(e);
25738
+ function lt(e) {
25739
+ return ze.has(e);
25731
25740
  }
25732
25741
  //#endregion
25733
25742
  //#region src/v2019C1/extensions/reference/query/find/find-refs-pointing-to.ts
25734
- async function I(e, t) {
25743
+ async function F(e, t) {
25735
25744
  let { target: n, containerTagName: r } = t, i = await e.getRecord(n);
25736
- return i ? at(i.tagName) ? st(e, i, r) : ot(e, i, r) : [];
25745
+ return i ? lt(i.tagName) ? dt(e, i, r) : ut(e, i, r) : [];
25737
25746
  }
25738
- async function ot(e, t, r) {
25747
+ async function ut(e, t, r) {
25739
25748
  let i = t.attributes.find((e) => e.name === "uuid")?.value;
25740
25749
  if (!i) return [];
25741
- let a = lt(t.tagName);
25750
+ let a = pt(t.tagName);
25742
25751
  if (a.length === 0) return [];
25743
25752
  let o = [];
25744
25753
  for (let t of a) {
@@ -25748,7 +25757,7 @@ async function ot(e, t, r) {
25748
25757
  attributes: { [t.uuidAttr]: i }
25749
25758
  });
25750
25759
  for (let t of a) {
25751
- let n = r ? await ut(e, t, r) : void 0;
25760
+ let n = r ? await mt(e, t, r) : void 0;
25752
25761
  o.push({
25753
25762
  ref: t,
25754
25763
  container: n
@@ -25757,10 +25766,10 @@ async function ot(e, t, r) {
25757
25766
  }
25758
25767
  return o;
25759
25768
  }
25760
- async function st(e, t, r) {
25769
+ async function dt(e, t, r) {
25761
25770
  let i = t.attributes.find((e) => e.name === "id")?.value;
25762
25771
  if (!i) return [];
25763
- let a = Pe.get(t.tagName) ?? [], o = [];
25772
+ let a = Re.get(t.tagName) ?? [], o = [];
25764
25773
  for (let t of a) {
25765
25774
  if (!n(t.refTagName, x)) continue;
25766
25775
  let a = await e.findByAttributes({
@@ -25768,8 +25777,8 @@ async function st(e, t, r) {
25768
25777
  attributes: { [t.attribute]: i }
25769
25778
  });
25770
25779
  for (let n of a) {
25771
- if (!ct(n, t)) continue;
25772
- let i = r ? await ut(e, n, r) : void 0;
25780
+ if (!ft(n, t)) continue;
25781
+ let i = r ? await mt(e, n, r) : void 0;
25773
25782
  o.push({
25774
25783
  ref: n,
25775
25784
  container: i
@@ -25778,23 +25787,23 @@ async function st(e, t, r) {
25778
25787
  }
25779
25788
  return o;
25780
25789
  }
25781
- function ct(e, t) {
25790
+ function ft(e, t) {
25782
25791
  return t.when ? e.attributes.find((e) => e.name === t.when.attribute)?.value === t.when.equals : !0;
25783
25792
  }
25784
- function lt(e) {
25793
+ function pt(e) {
25785
25794
  let t = [];
25786
- for (let n of je) {
25787
- let r = ke[n]?.get(e);
25795
+ for (let n of Pe) {
25796
+ let r = Me[n]?.get(e);
25788
25797
  r && t.push(...r);
25789
25798
  }
25790
25799
  return t;
25791
25800
  }
25792
- async function ut(e, t, n) {
25801
+ async function mt(e, t, n) {
25793
25802
  return (await e.findAncestors(t, { stopAtTagName: n })).find((e) => e.tagName === n);
25794
25803
  }
25795
25804
  //#endregion
25796
25805
  //#region src/v2019C1/extensions/reference/query/provenance/get-provenance.constants.ts
25797
- var dt = {
25806
+ var ht = {
25798
25807
  Application: "application",
25799
25808
  Function: "function",
25800
25809
  SubFunction: "function",
@@ -25805,10 +25814,10 @@ var dt = {
25805
25814
  };
25806
25815
  //#endregion
25807
25816
  //#region src/v2019C1/extensions/reference/query/provenance/get-provenance.ts
25808
- async function ft(e) {
25817
+ async function gt(e) {
25809
25818
  let t = await e.getRecordsByTagName("SclFileReference"), n = [];
25810
25819
  for (let r of t) {
25811
- let t = await pt(e, r);
25820
+ let t = await _t(e, r);
25812
25821
  if (!t) continue;
25813
25822
  let { fileType: i, fileUuid: a, fileName: o, version: s, revision: c } = await e.getAttributes(r);
25814
25823
  n.push({
@@ -25822,17 +25831,17 @@ async function ft(e) {
25822
25831
  }
25823
25832
  return n;
25824
25833
  }
25825
- async function pt(e, t) {
25834
+ async function _t(e, t) {
25826
25835
  let n = await e.findAncestors(t);
25827
25836
  for (let e of n) {
25828
- let t = dt[e.tagName];
25837
+ let t = ht[e.tagName];
25829
25838
  if (t) return {
25830
25839
  kind: t,
25831
- ref: mt(e.tagName, e.id)
25840
+ ref: vt(e.tagName, e.id)
25832
25841
  };
25833
25842
  }
25834
25843
  }
25835
- function mt(e, t) {
25844
+ function vt(e, t) {
25836
25845
  return {
25837
25846
  tagName: e,
25838
25847
  id: t
@@ -25840,23 +25849,23 @@ function mt(e, t) {
25840
25849
  }
25841
25850
  //#endregion
25842
25851
  //#region src/v2019C1/extensions/reference/query/index.ts
25843
- var ht = /* @__PURE__ */ l({
25852
+ var yt = /* @__PURE__ */ l({
25844
25853
  buildElementPath: () => fe,
25845
- buildMappedLNodePath: () => Ve,
25846
- buildMappedName: () => Re,
25854
+ buildMappedLNodePath: () => Ge,
25855
+ buildMappedName: () => He,
25847
25856
  buildReferencePath: () => j,
25848
- findRefsPointingTo: () => I,
25849
- getProvenance: () => ft,
25850
- resolveElementPath: () => et,
25851
- resolveMappedLNode: () => rt,
25852
- resolveReferencePath: () => Ue
25857
+ findRefsPointingTo: () => F,
25858
+ getProvenance: () => gt,
25859
+ resolveElementPath: () => it,
25860
+ resolveMappedLNode: () => st,
25861
+ resolveReferencePath: () => qe
25853
25862
  });
25854
25863
  //#endregion
25855
25864
  //#region src/v2019C1/extensions/reference/transaction/apply-type-id-remap.ts
25856
- async function L(e, t) {
25865
+ async function bt(e, t) {
25857
25866
  let { records: n, idRemap: r } = t;
25858
25867
  if (r.size !== 0) for (let t of n) {
25859
- let n = F.get(t.tagName);
25868
+ let n = Le.get(t.tagName);
25860
25869
  if (!n) continue;
25861
25870
  let i = await e.getRecord(t);
25862
25871
  if (!i) continue;
@@ -25872,7 +25881,7 @@ async function L(e, t) {
25872
25881
  }
25873
25882
  //#endregion
25874
25883
  //#region src/v2019C1/extensions/reference/transaction/apply-uuid-remap.ts
25875
- async function R(e, t) {
25884
+ async function I(e, t) {
25876
25885
  let { mappings: n } = t;
25877
25886
  if (n.length === 0) return;
25878
25887
  let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
@@ -25915,37 +25924,61 @@ async function R(e, t) {
25915
25924
  }
25916
25925
  //#endregion
25917
25926
  //#region src/v2019C1/extensions/reference/transaction/write-provenance.ts
25918
- var gt = {
25919
- FSD: "FunctionSclRef",
25920
- ASD: "ApplicationSclRef"
25927
+ var xt = {
25928
+ function: {
25929
+ tag: "FunctionSclRef",
25930
+ fileType: "FSD"
25931
+ },
25932
+ application: {
25933
+ tag: "ApplicationSclRef",
25934
+ fileType: "ASD"
25935
+ }
25921
25936
  };
25922
- async function _t(e, t) {
25923
- let { sourceQuery: n, targetRoot: r, fileType: i } = t, [a] = await n.getRecordsByTagName("Header"), o = a ? await n.getAttributes(a) : void 0, s = await e.addChild(r, { tagName: gt[i] }), { name: c } = await n.getDocumentInfo();
25924
- await e.addChild(s, {
25937
+ async function St(e, t) {
25938
+ let { sourceQuery: n, target: r } = t, i = await Ct(n, wt(r));
25939
+ if (r.anchor === "document") {
25940
+ let t = await e.getRecord({ tagName: "Header" });
25941
+ if (!t) throw Error("writeProvenance: document anchor requires a target Header");
25942
+ let n = await e.ensureChild(t, { tagName: "SourceFiles" });
25943
+ await e.addChild(n, {
25944
+ tagName: "SclFileReference",
25945
+ attributes: i
25946
+ });
25947
+ return;
25948
+ }
25949
+ let { tag: a } = xt[r.anchor], o = await e.addChild(r.root, { tagName: a });
25950
+ await e.addChild(o, {
25925
25951
  tagName: "SclFileReference",
25926
- attributes: {
25927
- fileType: i,
25928
- version: o?.version ?? "",
25929
- revision: o?.revision ?? "",
25930
- fileName: c,
25931
- fileUuid: o?.uuid ?? ""
25932
- }
25952
+ attributes: i
25933
25953
  });
25934
25954
  }
25955
+ async function Ct(e, t) {
25956
+ let [n] = await e.getRecordsByTagName("Header"), r = n ? await e.getAttributes(n) : void 0, { name: i } = await e.getDocumentInfo();
25957
+ return {
25958
+ fileType: t,
25959
+ version: r?.version ?? "",
25960
+ revision: r?.revision ?? "",
25961
+ fileName: i,
25962
+ fileUuid: r?.uuid ?? ""
25963
+ };
25964
+ }
25965
+ function wt(e) {
25966
+ return e.anchor === "document" ? e.fileType : xt[e.anchor].fileType;
25967
+ }
25935
25968
  //#endregion
25936
25969
  //#region src/v2019C1/extensions/reference/index.ts
25937
- var z = {
25938
- query: ht,
25970
+ var L = {
25971
+ query: yt,
25939
25972
  transaction: /* @__PURE__ */ l({
25940
- applyTypeIdRemap: () => L,
25941
- applyUuidRemap: () => R,
25942
- writeProvenance: () => _t
25973
+ applyTypeIdRemap: () => bt,
25974
+ applyUuidRemap: () => I,
25975
+ writeProvenance: () => St
25943
25976
  })
25944
25977
  };
25945
25978
  //#endregion
25946
25979
  //#region src/v2019C1/extensions/clean-up/transaction/prune-empty-containers.ts
25947
- async function vt(e) {
25948
- let t = [...Object.values(Le).flat(), "Private"];
25980
+ async function Tt(e) {
25981
+ let t = [...Object.values(Ve).flat(), "Private"];
25949
25982
  for (let n of t) {
25950
25983
  let t = await e.getRecordsByTagName(n);
25951
25984
  for (let n of t) n.children.length === 0 && await e.delete(n);
@@ -25953,14 +25986,14 @@ async function vt(e) {
25953
25986
  }
25954
25987
  //#endregion
25955
25988
  //#region src/v2019C1/extensions/clean-up/transaction/orphan-uuid-refs.ts
25956
- async function yt(e) {
25957
- for (let t of k) {
25989
+ async function Et(e) {
25990
+ for (let t of pe) {
25958
25991
  let n = D[t], r = await e.getRecordsByTagName(t);
25959
25992
  for (let i of r) {
25960
25993
  let r = !1, a = !1, o = {};
25961
25994
  for (let t of n) {
25962
25995
  let n = await e.getAttribute(i, { name: t.attribute.uuid });
25963
- if (n) if (r = !0, await bt(e, n, t.target)) a = !0;
25996
+ if (n) if (r = !0, await Dt(e, n, t.target)) a = !0;
25964
25997
  else {
25965
25998
  o[t.attribute.uuid] = void 0, o[t.attribute.path] = void 0;
25966
25999
  for (let e of t.companions) o[e.name] = void 0;
@@ -25972,7 +26005,7 @@ async function yt(e) {
25972
26005
  }
25973
26006
  }
25974
26007
  }
25975
- async function bt(e, t, n) {
26008
+ async function Dt(e, t, n) {
25976
26009
  for (let r of n) {
25977
26010
  let [n] = await e.findByAttributes({
25978
26011
  tagName: r,
@@ -25984,80 +26017,80 @@ async function bt(e, t, n) {
25984
26017
  }
25985
26018
  //#endregion
25986
26019
  //#region src/v2019C1/extensions/clean-up/index.ts
25987
- var xt = { transaction: /* @__PURE__ */ l({
25988
- orphanUuidRefs: () => yt,
25989
- pruneEmptyContainers: () => vt,
26020
+ var R = { transaction: /* @__PURE__ */ l({
26021
+ orphanUuidRefs: () => Et,
26022
+ pruneEmptyContainers: () => Tt,
25990
26023
  resetLNode: () => re
25991
- }) }, St = ["id", "uuid"];
26024
+ }) }, Ot = ["id", "uuid"];
25992
26025
  //#endregion
25993
26026
  //#region src/v2019C1/extensions/signature/query/element-signature.ts
25994
- async function Ct(e, t) {
26027
+ async function z(e, t) {
25995
26028
  let n = {
25996
26029
  query: e,
25997
26030
  resolveReferences: t.resolveReferences ?? !1,
25998
- ignore: new Set(t.ignoreAttributes ?? St),
26031
+ ignore: new Set(t.ignoreAttributes ?? Ot),
25999
26032
  signatureCache: t.signatureCache ?? /* @__PURE__ */ new Map(),
26000
26033
  seen: /* @__PURE__ */ new Set()
26001
26034
  };
26002
- return Et(t.ref, n);
26035
+ return jt(t.ref, n);
26003
26036
  }
26004
- var wt = /* @__PURE__ */ new Set();
26005
- function Tt(e, t) {
26037
+ var kt = /* @__PURE__ */ new Set();
26038
+ function At(e, t) {
26006
26039
  return _[e]?.attributes?.details?.[t]?.default;
26007
26040
  }
26008
- async function Et(e, t) {
26041
+ async function jt(e, t) {
26009
26042
  let n = `${e.tagName}:${e.id}`, r = t.signatureCache.get(n);
26010
26043
  if (r !== void 0) return r;
26011
26044
  if (t.seen.has(n)) return `@cycle:${e.tagName}`;
26012
26045
  t.seen.add(n);
26013
- let i = await t.query.getTree(e), a = i ? await Dt(i, t) : "";
26046
+ let i = await t.query.getTree(e), a = i ? await Mt(i, t) : "";
26014
26047
  return t.seen.delete(n), t.signatureCache.set(n, a), a;
26015
26048
  }
26016
- async function Dt(e, t) {
26017
- let n = t.resolveReferences ? Mt(e.tagName) : wt, r = [];
26049
+ async function Mt(e, t) {
26050
+ let n = t.resolveReferences ? Lt(e.tagName) : kt, r = [];
26018
26051
  for (let i of e.attributes) {
26019
- if (t.ignore.has(i.name) || n.has(i.name) || i.value === Tt(e.tagName, i.name)) continue;
26052
+ if (t.ignore.has(i.name) || n.has(i.name) || i.value === At(e.tagName, i.name)) continue;
26020
26053
  let a = i.value;
26021
26054
  if (t.resolveReferences) {
26022
- let n = await Ot(e, i.name, i.value, t);
26055
+ let n = await Nt(e, i.name, i.value, t);
26023
26056
  n !== null && (a = `@sig:${n}`);
26024
26057
  }
26025
26058
  r.push(`${JSON.stringify(i.name)}:${JSON.stringify(a)}`);
26026
26059
  }
26027
26060
  r.sort();
26028
26061
  let i = [];
26029
- for (let n of e.tree ?? []) i.push(await Dt(n, t));
26062
+ for (let n of e.tree ?? []) i.push(await Mt(n, t));
26030
26063
  i.sort();
26031
26064
  let a = e.value?.trim(), o = a ? `,value:${JSON.stringify(a)}` : "";
26032
26065
  return `{tag:${JSON.stringify(e.tagName)},attrs:[${r.join(",")}]${o},children:[${i.join(",")}]}`;
26033
26066
  }
26034
- async function Ot(e, t, n, r) {
26035
- let i = kt(e, t);
26067
+ async function Nt(e, t, n, r) {
26068
+ let i = Pt(e, t);
26036
26069
  if (i) {
26037
- let e = await Nt(r.query, i.target, n);
26038
- return e ? Et(e, r) : `@missing:${n}`;
26070
+ let e = await Rt(r.query, i.target, n);
26071
+ return e ? jt(e, r) : `@missing:${n}`;
26039
26072
  }
26040
- let a = jt(e.tagName, t);
26073
+ let a = It(e.tagName, t);
26041
26074
  if (a) {
26042
- let e = await Pt(r.query, a.target, n);
26043
- return e ? Et(e, r) : `@missing:${n}`;
26075
+ let e = await zt(r.query, a.target, n);
26076
+ return e ? jt(e, r) : `@missing:${n}`;
26044
26077
  }
26045
26078
  return null;
26046
26079
  }
26047
- function kt(e, t) {
26048
- return N[e.tagName]?.find((n) => n.attribute === t && At(e, n));
26080
+ function Pt(e, t) {
26081
+ return N[e.tagName]?.find((n) => n.attribute === t && Ft(e, n));
26049
26082
  }
26050
- function At(e, t) {
26083
+ function Ft(e, t) {
26051
26084
  return t.when ? e.attributes.find((e) => e.name === t.when.attribute)?.value === t.when.equals : !0;
26052
26085
  }
26053
- function jt(e, t) {
26086
+ function It(e, t) {
26054
26087
  return D[e]?.find((e) => e.attribute.uuid === t);
26055
26088
  }
26056
- function Mt(e) {
26089
+ function Lt(e) {
26057
26090
  let t = D[e];
26058
- return t ? new Set(t.map((e) => e.attribute.path)) : wt;
26091
+ return t ? new Set(t.map((e) => e.attribute.path)) : kt;
26059
26092
  }
26060
- async function Nt(e, t, n) {
26093
+ async function Rt(e, t, n) {
26061
26094
  let [r] = await e.findByAttributes({
26062
26095
  tagName: t,
26063
26096
  attributes: { id: n }
@@ -26067,7 +26100,7 @@ async function Nt(e, t, n) {
26067
26100
  id: r.id
26068
26101
  } : null;
26069
26102
  }
26070
- async function Pt(e, t, n) {
26103
+ async function zt(e, t, n) {
26071
26104
  for (let r of t) {
26072
26105
  let [t] = await e.findByAttributes({
26073
26106
  tagName: r,
@@ -26082,23 +26115,33 @@ async function Pt(e, t, n) {
26082
26115
  }
26083
26116
  //#endregion
26084
26117
  //#region src/v2019C1/extensions/signature/query/index.ts
26085
- var Ft = /* @__PURE__ */ l({ elementSignature: () => Ct });
26118
+ var Bt = /* @__PURE__ */ l({ elementSignature: () => z });
26086
26119
  //#endregion
26087
26120
  //#region src/v2019C1/extensions/data-model/transaction/import-types.ts
26088
- async function It(e, t) {
26089
- let { sourceQuery: n, records: r, cloneMappings: i = [], forkPrefix: a = "", keepNameTypesFrom: o = "target" } = t, s = Lt(await S(n, { records: r })), c = await e.ensureChild(await e.getRoot(), {
26121
+ async function Vt(e, t) {
26122
+ let { sourceQuery: n, records: r, cloneMappings: i = [], forkPrefix: a = "", keepNameTypesFrom: o = "target" } = t;
26123
+ e.perf.start("scl::importTypes");
26124
+ let s = Ht(await S(n, { records: r })), c = await e.ensureChild(await e.getRoot(), {
26090
26125
  tagName: "DataTypeTemplates",
26091
26126
  attributes: {}
26092
- }), l = await zt(e), u = /* @__PURE__ */ new Map(), d = [], f = [], p = {
26127
+ });
26128
+ e.progress.plan({
26129
+ steps: s.length,
26130
+ label: "Indexing existing types…"
26131
+ }), e.perf.start("scl::importTypes::preExistingIndex");
26132
+ let l = await Wt(e);
26133
+ e.perf.stop("scl::importTypes::preExistingIndex");
26134
+ let u = /* @__PURE__ */ new Map(), d = [], f = [], p = {
26093
26135
  reused: 0,
26094
26136
  preserved: 0,
26095
26137
  forked: 0,
26096
26138
  reclaimed: 0
26097
26139
  }, m = /* @__PURE__ */ new Map();
26140
+ e.perf.start("scl::importTypes::sourceLoop");
26098
26141
  for (let t of s) {
26099
26142
  let r = await n.getAttribute(t, { name: "id" });
26100
- if (!r) continue;
26101
- let i = await Ct(n, {
26143
+ if (e.progress.nextStep(r ? `Importing ${r}` : void 0), !r) continue;
26144
+ let i = await z(n, {
26102
26145
  ref: {
26103
26146
  tagName: t.tagName,
26104
26147
  id: t.id
@@ -26107,7 +26150,7 @@ async function It(e, t) {
26107
26150
  signatureCache: m
26108
26151
  }), s = l.get(i);
26109
26152
  if (s !== void 0) {
26110
- let n = o === "source" ? await Bt(e, {
26153
+ let n = o === "source" ? await Gt(e, {
26111
26154
  tagName: t.tagName,
26112
26155
  currentId: s,
26113
26156
  desiredId: r
@@ -26121,7 +26164,7 @@ async function It(e, t) {
26121
26164
  tagName: t.tagName,
26122
26165
  attributes: { id: r }
26123
26166
  }), _ = r, v = h;
26124
- g ? (_ = await qt(e, t.tagName, `${a}${r}_${Jt(i)}`), v = Vt(h, _), p.forked++) : p.preserved++;
26167
+ g ? (_ = await Qt(e, t.tagName, `${a}${r}_${$t(i)}`), v = Kt(h, _), p.forked++) : p.preserved++;
26125
26168
  let y = await e.deepClone(c, v);
26126
26169
  u.set(r, _), y?.record && (d.push(B(y.record.tagName, y.record.id)), g && f.push({
26127
26170
  oldId: r,
@@ -26130,26 +26173,28 @@ async function It(e, t) {
26130
26173
  forkedId: _
26131
26174
  }));
26132
26175
  }
26176
+ e.perf.stop("scl::importTypes::sourceLoop"), e.perf.start("scl::importTypes::remap");
26133
26177
  let h = [];
26134
- for (let t of i) t.target.tagName === "LNode" && await te(e, t.target) || h.push(t.target);
26178
+ for (let t of i) t.target.tagName === "LNode" && await w(e, t.target) || h.push(t.target);
26135
26179
  for (let t of d) {
26180
+ e.progress.nextStep("Repointing references…");
26136
26181
  let n = await e.getTree(t);
26137
- n && Ht(n, h);
26182
+ n && qt(n, h);
26138
26183
  }
26139
- return await L(e, {
26184
+ return await bt(e, {
26140
26185
  records: h,
26141
26186
  idRemap: u
26142
- }), f.length > 0 && await Ut(e, {
26187
+ }), e.perf.stop("scl::importTypes::remap"), f.length > 0 && (e.progress.nextStep("Reclaiming ids…"), e.perf.start("scl::importTypes::reclaim"), await Jt(e, {
26143
26188
  collisions: f,
26144
26189
  idRemap: u,
26145
26190
  referrerRecords: h,
26146
26191
  stats: p
26147
- }), {
26192
+ }), e.perf.stop("scl::importTypes::reclaim")), e.progress.endPlan(), e.perf.stop("scl::importTypes"), {
26148
26193
  idRemap: u,
26149
26194
  stats: p
26150
26195
  };
26151
26196
  }
26152
- function Lt(e) {
26197
+ function Ht(e) {
26153
26198
  return [
26154
26199
  ...e.enumTypes,
26155
26200
  ...e.daTypes,
@@ -26157,20 +26202,20 @@ function Lt(e) {
26157
26202
  ...e.lnodeTypes
26158
26203
  ];
26159
26204
  }
26160
- var Rt = [
26205
+ var Ut = [
26161
26206
  "EnumType",
26162
26207
  "DAType",
26163
26208
  "DOType",
26164
26209
  "LNodeType"
26165
26210
  ];
26166
- async function zt(e) {
26211
+ async function Wt(e) {
26167
26212
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
26168
- for (let r of Rt) {
26213
+ for (let r of Ut) {
26169
26214
  let i = await e.getRecordsByTagName(r);
26170
26215
  for (let a of i) {
26171
26216
  let i = a.attributes.find((e) => e.name === "id")?.value;
26172
26217
  if (!i) continue;
26173
- let o = await Ct(e, {
26218
+ let o = await z(e, {
26174
26219
  ref: {
26175
26220
  tagName: r,
26176
26221
  id: a.id
@@ -26183,7 +26228,7 @@ async function zt(e) {
26183
26228
  }
26184
26229
  return t;
26185
26230
  }
26186
- async function Bt(e, t) {
26231
+ async function Gt(e, t) {
26187
26232
  let { tagName: n, currentId: r, desiredId: i } = t;
26188
26233
  if (r === i) return r;
26189
26234
  let [a] = await e.findByAttributes({
@@ -26196,13 +26241,13 @@ async function Bt(e, t) {
26196
26241
  attributes: { id: i }
26197
26242
  });
26198
26243
  if (o && o.id !== a.id) return r;
26199
- let s = B(a.tagName, a.id), c = await I(e, { target: s });
26200
- return await e.update(s, { attributes: { id: i } }), await L(e, {
26244
+ let s = B(a.tagName, a.id), c = await F(e, { target: s });
26245
+ return await e.update(s, { attributes: { id: i } }), await bt(e, {
26201
26246
  records: c.map((e) => B(e.ref.tagName, e.ref.id)),
26202
26247
  idRemap: new Map([[r, i]])
26203
26248
  }), i;
26204
26249
  }
26205
- function Vt(e, t) {
26250
+ function Kt(e, t) {
26206
26251
  let n = structuredClone(e), r = n.attributes, i = r.find((e) => e.name === "id");
26207
26252
  return i ? i.value = t : r.push({
26208
26253
  name: "id",
@@ -26215,13 +26260,13 @@ function B(e, t) {
26215
26260
  id: t
26216
26261
  };
26217
26262
  }
26218
- function Ht(e, t) {
26263
+ function qt(e, t) {
26219
26264
  t.push(B(e.tagName, e.id));
26220
- for (let n of e.tree ?? []) Ht(n, t);
26265
+ for (let n of e.tree ?? []) qt(n, t);
26221
26266
  }
26222
26267
  var V = (e) => `${e.tagName}#${e.id}`;
26223
- async function Ut(e, t) {
26224
- let { collisions: n, idRemap: r, referrerRecords: i, stats: a } = t, o = await Wt(e, n), s = /* @__PURE__ */ new Map(), c = [];
26268
+ async function Jt(e, t) {
26269
+ let { collisions: n, idRemap: r, referrerRecords: i, stats: a } = t, o = await Yt(e, n), s = /* @__PURE__ */ new Map(), c = [];
26225
26270
  for (let t of n) if (o.has(t.oldId)) {
26226
26271
  await e.update(t.forkRef, { attributes: { id: t.oldId } }), s.set(t.forkedId, t.oldId), c.push(t.forkRef), a.reclaimed++;
26227
26272
  for (let [e, n] of r) n === t.forkedId && r.set(e, t.oldId);
@@ -26230,21 +26275,21 @@ async function Ut(e, t) {
26230
26275
  let l = [...i];
26231
26276
  for (let t of c) {
26232
26277
  let n = await e.getTree(t);
26233
- n && Ht(n, l);
26278
+ n && qt(n, l);
26234
26279
  }
26235
- await L(e, {
26280
+ await bt(e, {
26236
26281
  records: l,
26237
26282
  idRemap: s
26238
26283
  });
26239
26284
  }
26240
- async function Wt(e, t) {
26285
+ async function Yt(e, t) {
26241
26286
  let n = /* @__PURE__ */ new Set(), r = new Map(t.map((e) => [V(e.oldRef), e.oldId])), i = t.map((e) => e.oldRef), a = new Set(i.map(V)), o = /* @__PURE__ */ new Set(), s = !0;
26242
26287
  for (; s;) {
26243
26288
  s = !1;
26244
26289
  for (let t of i) {
26245
26290
  let c = V(t);
26246
- if (o.has(c) || (await I(e, { target: t })).length > 0) continue;
26247
- let l = await e.getTree(t), u = l ? await Gt(e, l) : [];
26291
+ if (o.has(c) || (await F(e, { target: t })).length > 0) continue;
26292
+ let l = await e.getTree(t), u = l ? await Xt(e, l) : [];
26248
26293
  await e.delete(t), o.add(c), s = !0;
26249
26294
  let d = r.get(c);
26250
26295
  d !== void 0 && n.add(d);
@@ -26256,12 +26301,12 @@ async function Wt(e, t) {
26256
26301
  }
26257
26302
  return n;
26258
26303
  }
26259
- async function Gt(e, t) {
26304
+ async function Xt(e, t) {
26260
26305
  let n = [], r = /* @__PURE__ */ new Set();
26261
26306
  async function i(t) {
26262
26307
  let a = N[t.tagName];
26263
26308
  for (let i of a ?? []) {
26264
- if (!Kt(t, i)) continue;
26309
+ if (!Zt(t, i)) continue;
26265
26310
  let a = t.attributes.find((e) => e.name === i.attribute)?.value;
26266
26311
  if (!a) continue;
26267
26312
  let [o] = await e.findByAttributes({
@@ -26276,10 +26321,10 @@ async function Gt(e, t) {
26276
26321
  }
26277
26322
  return await i(t), n;
26278
26323
  }
26279
- function Kt(e, t) {
26324
+ function Zt(e, t) {
26280
26325
  return t.when ? e.attributes.find((e) => e.name === t.when.attribute)?.value === t.when.equals : !0;
26281
26326
  }
26282
- async function qt(e, t, n) {
26327
+ async function Qt(e, t, n) {
26283
26328
  let r = n, i = 2;
26284
26329
  for (; (await e.findByAttributes({
26285
26330
  tagName: t,
@@ -26287,20 +26332,20 @@ async function qt(e, t, n) {
26287
26332
  })).length > 0;) r = `${n}_${i}`, i += 1;
26288
26333
  return r;
26289
26334
  }
26290
- function Jt(e) {
26335
+ function $t(e) {
26291
26336
  let t = 2166136261;
26292
26337
  for (let n = 0; n < e.length; n++) t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
26293
26338
  return (t >>> 0).toString(16).padStart(8, "0");
26294
26339
  }
26295
26340
  //#endregion
26296
26341
  //#region src/v2019C1/extensions/data-model/index.ts
26297
- var Yt = {
26342
+ var en = {
26298
26343
  query: ne,
26299
- transaction: /* @__PURE__ */ l({ importTypes: () => It })
26344
+ transaction: /* @__PURE__ */ l({ importTypes: () => Vt })
26300
26345
  };
26301
26346
  //#endregion
26302
26347
  //#region src/v2019C1/extensions/history/query/get-sorted-hitem.ts
26303
- async function Xt(e) {
26348
+ async function tn(e) {
26304
26349
  let t = await e.getRecord({ tagName: "History" });
26305
26350
  if (!t) return [];
26306
26351
  let { Hitem: n = [] } = await e.findDescendants(t, { collect: "Hitem" });
@@ -26314,18 +26359,18 @@ async function Xt(e) {
26314
26359
  }
26315
26360
  //#endregion
26316
26361
  //#region src/v2019C1/extensions/history/query/get-latest-hitem.ts
26317
- async function Zt(e) {
26318
- return (await Xt(e)).at(-1);
26362
+ async function nn(e) {
26363
+ return (await tn(e)).at(-1);
26319
26364
  }
26320
26365
  //#endregion
26321
26366
  //#region src/v2019C1/extensions/history/query/index.ts
26322
- var Qt = /* @__PURE__ */ l({
26323
- getLatestHitem: () => Zt,
26324
- getSortedHitems: () => Xt
26367
+ var rn = /* @__PURE__ */ l({
26368
+ getLatestHitem: () => nn,
26369
+ getSortedHitems: () => tn
26325
26370
  });
26326
26371
  //#endregion
26327
26372
  //#region src/v2019C1/extensions/history/transaction/add-entry.ts
26328
- async function $t(e, t) {
26373
+ async function an(e, t) {
26329
26374
  let { filename: n, header: r, item: i } = t, { id: a, fileType: o, nameStructure: s, version: c, tool: l } = r, { who: u, what: d, why: f } = i, p = await e.getRoot(), m = await e.getRecord({ tagName: "Header" }) ?? await e.addChild(p, {
26330
26375
  tagName: "Header",
26331
26376
  attributes: {
@@ -26340,18 +26385,18 @@ async function $t(e, t) {
26340
26385
  }), h = await e.getRecord({ tagName: "History" }) ?? await e.addChild(m, {
26341
26386
  tagName: "History",
26342
26387
  attributes: {}
26343
- }), g = await Zt(e), _ = g?.attributes.find((e) => e.name === "version")?.value, v = g?.attributes.find((e) => e.name === "revision")?.value, y = c === "keep" ? _ ?? "0" : _ ? String(Number(_) + 1) : "0", b = v ? String(Number(v) + 1) : "1";
26388
+ }), g = await nn(e), _ = g?.attributes.find((e) => e.name === "version")?.value, v = g?.attributes.find((e) => e.name === "revision")?.value, y = c === "keep" ? _ ?? "0" : _ ? String(Number(_) + 1) : "0", b = v ? String(Number(v) + 1) : "1";
26344
26389
  await e.update(m, { attributes: {
26345
26390
  version: y,
26346
26391
  revision: b
26347
26392
  } });
26348
- let x = /* @__PURE__ */ new Date(), S = x.toString().split(" "), C = x.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop(), w = `${S[0]} ${S[1]} ${S[2]} ${S[4]} ${C} ${S[3]}`;
26393
+ let x = /* @__PURE__ */ new Date(), S = x.toString().split(" "), C = x.toLocaleString("en", { timeZoneName: "short" }).split(" ").pop(), ee = `${S[0]} ${S[1]} ${S[2]} ${S[4]} ${C} ${S[3]}`;
26349
26394
  await e.addChild(h, {
26350
26395
  tagName: "Hitem",
26351
26396
  attributes: {
26352
26397
  version: y,
26353
26398
  revision: b,
26354
- when: w,
26399
+ when: ee,
26355
26400
  who: u,
26356
26401
  what: d,
26357
26402
  why: f
@@ -26363,92 +26408,74 @@ async function $t(e, t) {
26363
26408
  }
26364
26409
  //#endregion
26365
26410
  //#region src/v2019C1/extensions/history/index.ts
26366
- var en = {
26367
- query: Qt,
26368
- transaction: /* @__PURE__ */ l({ addEntry: () => $t })
26411
+ var H = {
26412
+ query: rn,
26413
+ transaction: /* @__PURE__ */ l({ addEntry: () => an })
26369
26414
  };
26370
26415
  //#endregion
26371
26416
  //#region src/v2019C1/extensions/identity/transaction/write-identity.ts
26372
- async function H(e, t) {
26417
+ async function U(e, t) {
26373
26418
  let { mappings: n, mode: r } = t;
26374
26419
  if (r !== "keep") for (let t of n) {
26375
- let n = r === "strip" ? tn() : nn(t);
26420
+ let n = r === "strip" ? on() : sn(t);
26376
26421
  if (Object.keys(n).length === 0) continue;
26377
26422
  let i = await e.getRecord(t.target);
26378
26423
  i && await e.update(i, { attributes: n });
26379
26424
  }
26380
26425
  }
26381
- function tn() {
26426
+ function on() {
26382
26427
  return {
26383
26428
  templateUuid: void 0,
26384
26429
  originUuid: void 0
26385
26430
  };
26386
26431
  }
26387
- function nn(e) {
26388
- let t = an(e.source.attributes, "uuid"), n = an(e.source.attributes, "templateUuid"), r = an(e.source.attributes, "originUuid"), i = {};
26432
+ function sn(e) {
26433
+ let t = ln(e.source.attributes, "uuid"), n = ln(e.source.attributes, "templateUuid"), r = ln(e.source.attributes, "originUuid"), i = {};
26389
26434
  t && (i.templateUuid = t);
26390
- let a = rn(e.target.tagName);
26435
+ let a = cn(e.target.tagName);
26391
26436
  return n && !r && a && (i.originUuid = n), i;
26392
26437
  }
26393
- function rn(e) {
26438
+ function cn(e) {
26394
26439
  let t = x.attributes[e];
26395
26440
  return t ? "originUuid" in t : !1;
26396
26441
  }
26397
- function an(e, t) {
26442
+ function ln(e, t) {
26398
26443
  return e.find((e) => e.name === t)?.value;
26399
26444
  }
26400
26445
  //#endregion
26401
26446
  //#region src/v2019C1/extensions/identity/transaction/restore-cloned-uuids.ts
26402
- async function on(e, t) {
26403
- let { mappings: n } = t, r = /* @__PURE__ */ new Map(), i = [];
26447
+ async function W(e, t) {
26448
+ let { mappings: n } = t;
26404
26449
  for (let t of n) {
26405
- let n = sn(t.source.attributes, "uuid");
26450
+ let n = un(t.source.attributes, "uuid");
26406
26451
  if (!n) continue;
26407
- let a = await e.getRecord(t.target), o = a ? a.attributes.find((e) => e.name === "uuid")?.value : void 0;
26408
- !o || o === n || (r.set(o, n), i.push({
26409
- ref: t.target,
26410
- sourceUuid: n
26411
- }));
26412
- }
26413
- if (r.size !== 0) {
26414
- for (let { ref: t, sourceUuid: n } of i) await e.update(t, { attributes: { uuid: n } });
26415
- for (let t of n) {
26416
- let n = D[t.target.tagName];
26417
- if (!n) continue;
26418
- let i = await e.getRecord(t.target);
26419
- if (!i) continue;
26420
- let a = {};
26421
- for (let e of n) {
26422
- let t = i.attributes.find((t) => t.name === e.attribute.uuid)?.value, n = t ? r.get(t) : void 0;
26423
- n && (a[e.attribute.uuid] = n);
26424
- }
26425
- Object.keys(a).length > 0 && await e.update(t.target, { attributes: a });
26426
- }
26452
+ let r = (await e.getRecord(t.target))?.attributes.find((e) => e.name === "uuid")?.value;
26453
+ !r || r === n || await e.update(t.target, { attributes: { uuid: n } });
26427
26454
  }
26428
26455
  }
26429
- function sn(e, t) {
26456
+ function un(e, t) {
26430
26457
  return e.find((e) => e.name === t)?.value;
26431
26458
  }
26432
26459
  //#endregion
26433
26460
  //#region src/v2019C1/extensions/identity/index.ts
26434
- var cn = { transaction: /* @__PURE__ */ l({
26435
- restoreClonedUuids: () => on,
26436
- writeIdentity: () => H
26461
+ var dn = { transaction: /* @__PURE__ */ l({
26462
+ restoreClonedUuids: () => W,
26463
+ writeIdentity: () => U
26437
26464
  }) };
26438
26465
  //#endregion
26439
26466
  //#region src/v2019C1/extensions/lifecycle/engine/group.ts
26440
- function ln(e, t) {
26467
+ function fn(e, t) {
26441
26468
  let n = [];
26442
- return un({
26469
+ return pn({
26443
26470
  node: e,
26444
26471
  scopePrefix: t,
26445
26472
  out: n
26446
26473
  }), n;
26447
26474
  }
26448
- function un(e) {
26475
+ function pn(e) {
26449
26476
  let { node: t, scopePrefix: n, out: r } = e;
26450
26477
  if (t.change === "unchanged") {
26451
- for (let e of t.children) un({
26478
+ for (let e of t.children) pn({
26452
26479
  node: e,
26453
26480
  scopePrefix: n,
26454
26481
  out: r
@@ -26456,11 +26483,11 @@ function un(e) {
26456
26483
  return;
26457
26484
  }
26458
26485
  let i = [];
26459
- dn({
26486
+ mn({
26460
26487
  node: t,
26461
26488
  out: i
26462
26489
  }), r.push({
26463
- id: fn(t, n),
26490
+ id: hn(t, n),
26464
26491
  change: t.change,
26465
26492
  title: `${t.change} ${t.tagName}`,
26466
26493
  primary: t,
@@ -26469,32 +26496,32 @@ function un(e) {
26469
26496
  suggestedAction: t.change === "target-only" ? "skip" : "accept"
26470
26497
  });
26471
26498
  }
26472
- function dn(e) {
26499
+ function mn(e) {
26473
26500
  let { node: t, out: n } = e;
26474
- for (let e of t.children) e.change !== "unchanged" && n.push(e), dn({
26501
+ for (let e of t.children) e.change !== "unchanged" && n.push(e), mn({
26475
26502
  node: e,
26476
26503
  out: n
26477
26504
  });
26478
26505
  }
26479
- function fn(e, t) {
26506
+ function hn(e, t) {
26480
26507
  let n = e.sourceRef ?? e.instanceRef, r = n ? `${n.tagName}:${n.id}` : e.tagName;
26481
26508
  return t ? `${t}::${r}` : r;
26482
26509
  }
26483
26510
  //#endregion
26484
26511
  //#region src/v2019C1/extensions/lifecycle/engine/visible-attributes.ts
26485
- var pn = new Set([
26512
+ var gn = new Set([
26486
26513
  "uuid",
26487
26514
  "templateUuid",
26488
26515
  "originUuid"
26489
- ]), mn = new Set(Object.values(D).flatMap((e) => e.flatMap((e) => [e.attribute.path, e.attribute.uuid])));
26490
- function hn(e) {
26516
+ ]), _n = new Set(Object.values(D).flatMap((e) => e.flatMap((e) => [e.attribute.path, e.attribute.uuid])));
26517
+ function vn(e) {
26491
26518
  let t = {};
26492
- for (let [n, r] of Object.entries(e)) pn.has(n) || n === "name" || mn.has(n) || (t[n] = r);
26519
+ for (let [n, r] of Object.entries(e)) gn.has(n) || n === "name" || _n.has(n) || (t[n] = r);
26493
26520
  return t;
26494
26521
  }
26495
26522
  //#endregion
26496
26523
  //#region src/v2019C1/extensions/lifecycle/engine/diff.ts
26497
- var gn = new Set([
26524
+ var yn = new Set([
26498
26525
  "LNodeSpecNaming",
26499
26526
  "FunctionSclRef",
26500
26527
  "ApplicationSclRef",
@@ -26502,30 +26529,30 @@ var gn = new Set([
26502
26529
  "FunctionRole",
26503
26530
  "FunctionRoleContent"
26504
26531
  ]);
26505
- async function _n(e) {
26532
+ async function bn(e) {
26506
26533
  let { sourceQuery: t, targetQuery: n, sourceRootRef: r, instanceRootRef: i, keepLeftoverRefs: a } = e, o = e.leftoverRefPolicy, s = e.refsAlwaysAdded ?? !1, c = e.matchKey ?? "templateUuid", l = await t.any.getTree(r);
26507
26534
  if (!l) throw Error("diff: source subtree not found");
26508
26535
  let u = i ? await n.any.getTree(i) : void 0;
26509
26536
  if (!u) {
26510
- let e = wn(l);
26537
+ let e = Dn(l);
26511
26538
  return {
26512
26539
  root: e,
26513
- groups: ln(e),
26514
- summary: Fn(e)
26540
+ groups: fn(e),
26541
+ summary: Rn(e)
26515
26542
  };
26516
26543
  }
26517
26544
  let d = /* @__PURE__ */ new Map();
26518
- await Mn(n, {
26545
+ await Fn(n, {
26519
26546
  node: u,
26520
26547
  index: d,
26521
26548
  matchKey: c
26522
26549
  });
26523
26550
  let f = /* @__PURE__ */ new Set();
26524
- await Nn(t, {
26551
+ await In(t, {
26525
26552
  node: l,
26526
26553
  out: f
26527
26554
  });
26528
- let p = await vn(t, {
26555
+ let p = await xn(t, {
26529
26556
  targetQuery: n,
26530
26557
  sourceNode: l,
26531
26558
  instanceNode: u,
@@ -26535,21 +26562,21 @@ async function _n(e) {
26535
26562
  leftoverRefPolicy: o,
26536
26563
  refsAlwaysAdded: s,
26537
26564
  matchKey: c
26538
- }), m = Fn(p);
26565
+ }), m = Rn(p);
26539
26566
  return {
26540
26567
  root: p,
26541
- groups: ln(p, u.id),
26568
+ groups: fn(p, u.id),
26542
26569
  summary: m
26543
26570
  };
26544
26571
  }
26545
- async function vn(e, t) {
26546
- let { targetQuery: n, sourceNode: r, instanceNode: i, index: o, sourceUuids: s, keepLeftoverRefs: c, matchKey: l } = t, u = t.leftoverRefPolicy, d = t.refsAlwaysAdded ?? !1, f = await jn(e, {
26572
+ async function xn(e, t) {
26573
+ let { targetQuery: n, sourceNode: r, instanceNode: i, index: o, sourceUuids: s, keepLeftoverRefs: c, matchKey: l } = t, u = t.leftoverRefPolicy, d = t.refsAlwaysAdded ?? !1, f = await Pn(e, {
26547
26574
  targetQuery: n,
26548
26575
  sourceNode: r,
26549
26576
  instanceNode: i
26550
26577
  }), p = [], m = /* @__PURE__ */ new Set();
26551
26578
  for (let t of r.tree) {
26552
- let r = await yn(e, {
26579
+ let r = await Sn(e, {
26553
26580
  targetQuery: n,
26554
26581
  sourceChild: t,
26555
26582
  instanceNode: i,
@@ -26557,7 +26584,7 @@ async function vn(e, t) {
26557
26584
  matchedInstanceIds: m,
26558
26585
  refsAlwaysAdded: d
26559
26586
  });
26560
- r ? (m.add(r.id), p.push(await vn(e, {
26587
+ r ? (m.add(r.id), p.push(await xn(e, {
26561
26588
  targetQuery: n,
26562
26589
  sourceNode: t,
26563
26590
  instanceNode: r,
@@ -26567,22 +26594,22 @@ async function vn(e, t) {
26567
26594
  leftoverRefPolicy: u,
26568
26595
  refsAlwaysAdded: d,
26569
26596
  matchKey: l
26570
- }))) : p.push(wn(t));
26597
+ }))) : p.push(Dn(t));
26571
26598
  }
26572
- let h = await Dn(e, r);
26599
+ let h = await An(e, r);
26573
26600
  for (let e of i.tree) {
26574
26601
  if (m.has(e.id)) continue;
26575
26602
  let t = await n.any.getAttribute(e, { name: l });
26576
26603
  if (t) {
26577
- s.has(t) || p.push(Tn(e));
26604
+ s.has(t) || p.push(On(e));
26578
26605
  continue;
26579
26606
  }
26580
- if (A.has(e.tagName) && !O.has(e.tagName)) {
26581
- let t = c || await On(n, e, h), r = t && u ? await u(e) === "removed" : !1;
26582
- t && !r ? p.push(En(e)) : p.push(Tn(e));
26607
+ if (k.has(e.tagName) && !O.has(e.tagName)) {
26608
+ let t = c || await jn(n, e, h), r = t && u ? await u(e) === "removed" : !1;
26609
+ t && !r ? p.push(kn(e)) : p.push(On(e));
26583
26610
  continue;
26584
26611
  }
26585
- An(e, p);
26612
+ Nn(e, p);
26586
26613
  }
26587
26614
  return {
26588
26615
  change: f.length > 0 ? "modified" : "unchanged",
@@ -26593,40 +26620,40 @@ async function vn(e, t) {
26593
26620
  children: p
26594
26621
  };
26595
26622
  }
26596
- async function yn(e, t) {
26623
+ async function Sn(e, t) {
26597
26624
  let { targetQuery: n, sourceChild: r, instanceNode: i, index: a, matchedInstanceIds: o } = t, s = await e.any.getAttribute(r, { name: "uuid" });
26598
26625
  if (s) {
26599
26626
  let e = a.get(s);
26600
26627
  return e && e.tagName === r.tagName ? e : void 0;
26601
26628
  }
26602
- if (t.refsAlwaysAdded && A.has(r.tagName)) return;
26629
+ if (t.refsAlwaysAdded && k.has(r.tagName)) return;
26603
26630
  let c = i.tree.filter((e) => e.tagName === r.tagName && !o.has(e.id));
26604
26631
  if (c.length !== 0) {
26605
- if (A.has(r.tagName)) {
26606
- let t = await bn(e, r, { mapToTemplate: !1 });
26632
+ if (k.has(r.tagName)) {
26633
+ let t = await Cn(e, r, { mapToTemplate: !1 });
26607
26634
  if (t === void 0) return c[0];
26608
- for (let e of c) if (await bn(n, e, { mapToTemplate: !0 }) === t) return e;
26609
- let i = await Sn(e, r);
26635
+ for (let e of c) if (await Cn(n, e, { mapToTemplate: !0 }) === t) return e;
26636
+ let i = await Tn(e, r);
26610
26637
  if (i === void 0) return;
26611
- for (let e of c) if (await Sn(n, e) === i) return e;
26638
+ for (let e of c) if (await Tn(n, e) === i) return e;
26612
26639
  return;
26613
26640
  }
26614
26641
  return c[0];
26615
26642
  }
26616
26643
  }
26617
- async function bn(e, t, n) {
26644
+ async function Cn(e, t, n) {
26618
26645
  let r = D[t.tagName];
26619
26646
  if (!r) return;
26620
26647
  let i = [];
26621
26648
  for (let a of r) {
26622
26649
  let r = await e.any.getAttribute(t, { name: a.attribute.uuid });
26623
26650
  if (!r) continue;
26624
- let o = n.mapToTemplate ? await xn(e, r, a.target) : r;
26651
+ let o = n.mapToTemplate ? await wn(e, r, a.target) : r;
26625
26652
  i.push(`${a.attribute.uuid}=${o}`);
26626
26653
  }
26627
26654
  return i.length > 0 ? i.sort().join("|") : void 0;
26628
26655
  }
26629
- async function xn(e, t, n) {
26656
+ async function wn(e, t, n) {
26630
26657
  for (let r of n) {
26631
26658
  let n = (await e.findByAttributes({
26632
26659
  tagName: r,
@@ -26636,19 +26663,19 @@ async function xn(e, t, n) {
26636
26663
  }
26637
26664
  return t;
26638
26665
  }
26639
- async function Sn(e, t) {
26666
+ async function Tn(e, t) {
26640
26667
  let n = D[t.tagName];
26641
26668
  if (!n) return;
26642
26669
  let r = [];
26643
26670
  for (let i of n) {
26644
26671
  let n = await e.any.getAttribute(t, { name: i.attribute.uuid });
26645
26672
  if (!n) continue;
26646
- let a = await Cn(e, n, i.target);
26673
+ let a = await En(e, n, i.target);
26647
26674
  a !== void 0 && r.push(`${i.attribute.uuid}=${a}`);
26648
26675
  }
26649
26676
  return r.length > 0 ? r.sort().join("|") : void 0;
26650
26677
  }
26651
- async function Cn(e, t, n) {
26678
+ async function En(e, t, n) {
26652
26679
  for (let r of n) {
26653
26680
  let n = (await e.findByAttributes({
26654
26681
  tagName: r,
@@ -26657,8 +26684,8 @@ async function Cn(e, t, n) {
26657
26684
  if (n) return await e.any.getAttribute(n, { name: "name" }) || void 0;
26658
26685
  }
26659
26686
  }
26660
- function wn(e) {
26661
- let t = e.tree.map((e) => wn(e));
26687
+ function Dn(e) {
26688
+ let t = e.tree.map((e) => Dn(e));
26662
26689
  return {
26663
26690
  change: "added",
26664
26691
  tagName: e.tagName,
@@ -26666,8 +26693,8 @@ function wn(e) {
26666
26693
  children: t
26667
26694
  };
26668
26695
  }
26669
- function Tn(e) {
26670
- let t = e.tree.map((e) => Tn(e));
26696
+ function On(e) {
26697
+ let t = e.tree.map((e) => On(e));
26671
26698
  return {
26672
26699
  change: "removed",
26673
26700
  tagName: e.tagName,
@@ -26675,7 +26702,7 @@ function Tn(e) {
26675
26702
  children: t
26676
26703
  };
26677
26704
  }
26678
- function En(e) {
26705
+ function kn(e) {
26679
26706
  return {
26680
26707
  change: "unchanged",
26681
26708
  tagName: e.tagName,
@@ -26683,26 +26710,26 @@ function En(e) {
26683
26710
  children: []
26684
26711
  };
26685
26712
  }
26686
- async function Dn(e, t) {
26713
+ async function An(e, t) {
26687
26714
  let n = /* @__PURE__ */ new Set();
26688
26715
  for (let r of t.tree) {
26689
- if (!A.has(r.tagName)) continue;
26690
- let t = await bn(e, r, { mapToTemplate: !1 });
26716
+ if (!k.has(r.tagName)) continue;
26717
+ let t = await Cn(e, r, { mapToTemplate: !1 });
26691
26718
  t && n.add(t);
26692
- let i = await Sn(e, r);
26719
+ let i = await Tn(e, r);
26693
26720
  i && n.add(i);
26694
26721
  }
26695
26722
  return n;
26696
26723
  }
26697
- async function On(e, t, n) {
26724
+ async function jn(e, t, n) {
26698
26725
  if (n.size === 0) return !1;
26699
- let r = await bn(e, t, { mapToTemplate: !0 });
26726
+ let r = await Cn(e, t, { mapToTemplate: !0 });
26700
26727
  if (r && n.has(r)) return !0;
26701
- let i = await Sn(e, t);
26728
+ let i = await Tn(e, t);
26702
26729
  return !!i && n.has(i);
26703
26730
  }
26704
- function kn(e) {
26705
- let t = e.tree.map((e) => kn(e));
26731
+ function Mn(e) {
26732
+ let t = e.tree.map((e) => Mn(e));
26706
26733
  return {
26707
26734
  change: "target-only",
26708
26735
  tagName: e.tagName,
@@ -26710,17 +26737,17 @@ function kn(e) {
26710
26737
  children: t
26711
26738
  };
26712
26739
  }
26713
- function An(e, t) {
26714
- if (!gn.has(e.tagName)) {
26740
+ function Nn(e, t) {
26741
+ if (!yn.has(e.tagName)) {
26715
26742
  if (e.tagName === "Private") {
26716
- for (let n of e.tree) An(n, t);
26743
+ for (let n of e.tree) Nn(n, t);
26717
26744
  return;
26718
26745
  }
26719
- t.push(kn(e));
26746
+ t.push(Mn(e));
26720
26747
  }
26721
26748
  }
26722
- async function jn(e, t) {
26723
- let { targetQuery: n, sourceNode: r, instanceNode: i } = t, a = hn(await e.any.getAttributes(r)), o = hn(await n.any.getAttributes(i)), s = [];
26749
+ async function Pn(e, t) {
26750
+ let { targetQuery: n, sourceNode: r, instanceNode: i } = t, a = vn(await e.any.getAttributes(r)), o = vn(await n.any.getAttributes(i)), s = [];
26724
26751
  for (let e of new Set([...Object.keys(a), ...Object.keys(o)])) {
26725
26752
  let t = o[e], n = a[e];
26726
26753
  t !== n && s.push({
@@ -26731,26 +26758,26 @@ async function jn(e, t) {
26731
26758
  }
26732
26759
  return s;
26733
26760
  }
26734
- async function Mn(e, t) {
26761
+ async function Fn(e, t) {
26735
26762
  let { node: n, index: r, matchKey: i } = t, a = await e.any.getAttribute(n, { name: i });
26736
26763
  a && r.set(a, n);
26737
- for (let t of n.tree) await Mn(e, {
26764
+ for (let t of n.tree) await Fn(e, {
26738
26765
  node: t,
26739
26766
  index: r,
26740
26767
  matchKey: i
26741
26768
  });
26742
26769
  }
26743
- async function Nn(e, t) {
26770
+ async function In(e, t) {
26744
26771
  let { node: n, out: r } = t, i = await e.any.getAttribute(n, { name: "uuid" });
26745
26772
  i && r.add(i);
26746
- for (let t of n.tree) await Nn(e, {
26773
+ for (let t of n.tree) await In(e, {
26747
26774
  node: t,
26748
26775
  out: r
26749
26776
  });
26750
26777
  }
26751
- function Pn(e) {
26778
+ function Ln(e) {
26752
26779
  let t = e.reduce((e, t) => {
26753
- let n = Fn(t.tree);
26780
+ let n = Rn(t.tree);
26754
26781
  return {
26755
26782
  added: e.added + n.added,
26756
26783
  removed: e.removed + n.removed,
@@ -26767,10 +26794,10 @@ function Pn(e) {
26767
26794
  summary: t
26768
26795
  };
26769
26796
  }
26770
- function U(e) {
26797
+ function G(e) {
26771
26798
  return e.instances.flatMap((e) => e.groups);
26772
26799
  }
26773
- function Fn(e) {
26800
+ function Rn(e) {
26774
26801
  let t = {
26775
26802
  added: 0,
26776
26803
  removed: 0,
@@ -26783,58 +26810,58 @@ function Fn(e) {
26783
26810
  }
26784
26811
  //#endregion
26785
26812
  //#region src/v2019C1/extensions/lifecycle/constraints/classify-attribute.constants.ts
26786
- var In = new Set([
26813
+ var zn = new Set([
26787
26814
  "uuid",
26788
26815
  "templateUuid",
26789
26816
  "originUuid"
26790
- ]), Ln = ["rename", "free"], Rn = /* @__PURE__ */ new Map();
26791
- function zn(e) {
26792
- let t = Rn.get(e);
26817
+ ]), Bn = ["rename", "free"], Vn = /* @__PURE__ */ new Map();
26818
+ function Hn(e) {
26819
+ let t = Vn.get(e);
26793
26820
  if (t) return t;
26794
26821
  let n = _[e]?.attributes?.identityFields ?? [], r = new Set(n);
26795
- return Rn.set(e, r), r;
26822
+ return Vn.set(e, r), r;
26796
26823
  }
26797
26824
  //#endregion
26798
26825
  //#region src/v2019C1/extensions/lifecycle/constraints/classify-attribute.ts
26799
- function W(e, t) {
26800
- return In.has(t) ? "identity" : Hn(e).has(t) || Un(e).has(t) ? "reference" : t === "name" ? "rename" : se.has(t) || zn(e).has(t) ? "identity" : "free";
26826
+ function Un(e, t) {
26827
+ return zn.has(t) ? "identity" : Kn(e).has(t) || qn(e).has(t) ? "reference" : t === "name" ? "rename" : se.has(t) || Hn(e).has(t) ? "identity" : "free";
26801
26828
  }
26802
- function Bn(e) {
26803
- return Ln.includes(e);
26829
+ function Wn(e) {
26830
+ return Bn.includes(e);
26804
26831
  }
26805
- function Vn(e) {
26832
+ function Gn(e) {
26806
26833
  let t = Object.keys(g[e] ?? {}), n = [];
26807
26834
  for (let r of t) {
26808
- let t = W(e, r);
26809
- Bn(t) && n.push({
26835
+ let t = Un(e, r);
26836
+ Wn(t) && n.push({
26810
26837
  attr: r,
26811
26838
  mode: t
26812
26839
  });
26813
26840
  }
26814
26841
  return n;
26815
26842
  }
26816
- function Hn(e) {
26843
+ function Kn(e) {
26817
26844
  let t = D[e];
26818
- if (!t) return Wn;
26845
+ if (!t) return Jn;
26819
26846
  let n = /* @__PURE__ */ new Set();
26820
26847
  for (let e of t) n.add(e.attribute.path), n.add(e.attribute.uuid);
26821
26848
  return n;
26822
26849
  }
26823
- function Un(e) {
26824
- let t = F.get(e);
26825
- return t ? new Set(t) : Wn;
26850
+ function qn(e) {
26851
+ let t = Le.get(e);
26852
+ return t ? new Set(t) : Jn;
26826
26853
  }
26827
- var Wn = /* @__PURE__ */ new Set();
26854
+ var Jn = /* @__PURE__ */ new Set();
26828
26855
  //#endregion
26829
26856
  //#region src/v2019C1/extensions/lifecycle/constraints/find-constraint-violation.ts
26830
- async function G(e, t) {
26831
- let { parentRef: n, childTag: r, candidate: i, excludeId: a } = t, o = Kn(n.tagName).filter((e) => (e.kind === "unique" || e.kind === "key") && qn(e, r));
26857
+ async function Yn(e, t) {
26858
+ let { parentRef: n, childTag: r, candidate: i, excludeId: a } = t, o = Zn(n.tagName).filter((e) => (e.kind === "unique" || e.kind === "key") && Qn(e, r));
26832
26859
  if (o.length === 0) return null;
26833
26860
  let s = (await e.any.getTree(n))?.tree ?? [];
26834
26861
  for (let e of o) {
26835
- let t = Jn(e);
26862
+ let t = $n(e);
26836
26863
  if (!(t.length === 0 || t.some((e) => i[e] === void 0))) {
26837
- for (let n of s) if (n.id !== a && qn(e, n.tagName) && t.every((e) => Gn(n, e) === i[e])) return {
26864
+ for (let n of s) if (n.id !== a && Qn(e, n.tagName) && t.every((e) => Xn(n, e) === i[e])) return {
26838
26865
  constraint: e.name,
26839
26866
  fields: t,
26840
26867
  offendingId: n.id
@@ -26843,41 +26870,41 @@ async function G(e, t) {
26843
26870
  }
26844
26871
  return null;
26845
26872
  }
26846
- function Gn(e, t) {
26873
+ function Xn(e, t) {
26847
26874
  return e.attributes.find((e) => e.name === t)?.value;
26848
26875
  }
26849
- function Kn(e) {
26876
+ function Zn(e) {
26850
26877
  return [..._[e]?.constraints ?? []];
26851
26878
  }
26852
- function qn(e, t) {
26879
+ function Qn(e, t) {
26853
26880
  for (let n of e.selector ?? []) {
26854
26881
  let e = (n.steps ?? []).at(-1);
26855
26882
  if (e && (e.kind === "wildcard" || e.kind === "name" && e.value === t)) return !0;
26856
26883
  }
26857
26884
  return !1;
26858
26885
  }
26859
- function Jn(e) {
26886
+ function $n(e) {
26860
26887
  return (e.fields ?? []).map((e) => e.target?.value).filter((e) => !!e);
26861
26888
  }
26862
26889
  //#endregion
26863
26890
  //#region src/v2019C1/extensions/lifecycle/constraints/resolve-unique-value.ts
26864
- var Yn = 1e3;
26865
- async function Xn(e, t) {
26891
+ var er = 1e3;
26892
+ async function tr(e, t) {
26866
26893
  let { parentRef: n, childTag: r, candidate: i, attr: a, decorate: o, excludeId: s } = t, c = i[a] ?? "";
26867
- if (!await G(e, {
26894
+ if (!await Yn(e, {
26868
26895
  parentRef: n,
26869
26896
  childTag: r,
26870
26897
  candidate: i,
26871
26898
  excludeId: s
26872
26899
  })) return c;
26873
- for (let t = 1; t <= Yn; t++) {
26900
+ for (let t = 1; t <= er; t++) {
26874
26901
  let l = o ? o({
26875
26902
  base: c,
26876
26903
  attempt: t,
26877
26904
  attr: a,
26878
26905
  childTag: r
26879
26906
  }) : `${c}_${t}`;
26880
- if (!await G(e, {
26907
+ if (!await Yn(e, {
26881
26908
  parentRef: n,
26882
26909
  childTag: r,
26883
26910
  candidate: {
@@ -26887,22 +26914,22 @@ async function Xn(e, t) {
26887
26914
  excludeId: s
26888
26915
  })) return l;
26889
26916
  }
26890
- throw Error(`could not resolve a unique ${a} for <${r}> under <${n.tagName}> after ${Yn} attempts`);
26917
+ throw Error(`could not resolve a unique ${a} for <${r}> under <${n.tagName}> after ${er} attempts`);
26891
26918
  }
26892
26919
  //#endregion
26893
26920
  //#region src/v2019C1/extensions/lifecycle/constraints/resolve-placement-collision.ts
26894
- async function K(e, t) {
26921
+ async function nr(e, t) {
26895
26922
  let { ref: n, decorate: r, overrides: i } = t, a = t.parentRef ?? (await e.getRecord(n))?.parent;
26896
26923
  if (!a) return { status: "ok" };
26897
26924
  let o = await e.getAttributes(n);
26898
26925
  if (i) for (let [t, r] of Object.entries(i)) {
26899
- let i = W(n.tagName, t);
26926
+ let i = Un(n.tagName, t);
26900
26927
  (i === "rename" || i === "free") && o[t] !== r && (await e.update(n, { attributes: { [t]: r } }), o = {
26901
26928
  ...o,
26902
26929
  [t]: r
26903
26930
  });
26904
26931
  }
26905
- let s = await G(e, {
26932
+ let s = await Yn(e, {
26906
26933
  parentRef: a,
26907
26934
  childTag: n.tagName,
26908
26935
  candidate: o,
@@ -26910,14 +26937,14 @@ async function K(e, t) {
26910
26937
  });
26911
26938
  if (!s) return { status: "ok" };
26912
26939
  let c = s.fields.find((e) => {
26913
- let t = W(n.tagName, e);
26940
+ let t = Un(n.tagName, e);
26914
26941
  return t === "rename" || t === "free";
26915
26942
  });
26916
26943
  if (!c) return {
26917
26944
  status: "unresolvable",
26918
26945
  violation: s
26919
26946
  };
26920
- let l = o[c] ?? "", u = await Xn(e, {
26947
+ let l = o[c] ?? "", u = await tr(e, {
26921
26948
  parentRef: a,
26922
26949
  childTag: n.tagName,
26923
26950
  candidate: o,
@@ -26934,12 +26961,12 @@ async function K(e, t) {
26934
26961
  }
26935
26962
  //#endregion
26936
26963
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/primitives/clone-tree.ts
26937
- var Zn = {
26964
+ var rr = {
26938
26965
  scope: "tree",
26939
26966
  attributes: ["templateUuid", "originUuid"]
26940
26967
  };
26941
- async function q(e, t) {
26942
- let { sourceQuery: n, ref: i, targetParent: a, omit: o, retagRoot: s, strip: c = Zn } = t, l = await n.getTree(i, {
26968
+ async function K(e, t) {
26969
+ let { sourceQuery: n, ref: i, targetParent: a, omit: o, retagRoot: s, strip: c = rr } = t, l = await n.getTree(i, {
26943
26970
  omit: o,
26944
26971
  unwrap: []
26945
26972
  });
@@ -26955,12 +26982,12 @@ async function q(e, t) {
26955
26982
  }
26956
26983
  //#endregion
26957
26984
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/primitives/add-children-to.ts
26958
- async function Qn(e, t) {
26985
+ async function ir(e, t) {
26959
26986
  let { sourceQuery: n, source: r, target: i, omit: a, strip: o } = t, s = await n.any.getRecord(r);
26960
26987
  if (!s) return [];
26961
26988
  let c = [];
26962
26989
  for (let t of s.children) {
26963
- let r = await q(e, {
26990
+ let r = await K(e, {
26964
26991
  sourceQuery: n,
26965
26992
  ref: {
26966
26993
  tagName: t.tagName,
@@ -26976,14 +27003,14 @@ async function Qn(e, t) {
26976
27003
  }
26977
27004
  //#endregion
26978
27005
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/deep.ts
26979
- async function J(e, t) {
26980
- let { sourceQuery: n, ref: r, targetParent: i, withTypes: a = !0, omit: o, strip: s = !1, retagRoot: c } = t, l = await $n(e, {
27006
+ async function ar(e, t) {
27007
+ let { sourceQuery: n, ref: r, targetParent: i, withTypes: a = !0, omit: o, strip: s = !1, retagRoot: c } = t, l = await or(e, {
26981
27008
  sourceQuery: n,
26982
27009
  ref: r,
26983
27010
  targetParent: i
26984
27011
  }), u, d;
26985
27012
  if (l) {
26986
- d = await Qn(e, {
27013
+ d = await ir(e, {
26987
27014
  sourceQuery: n,
26988
27015
  source: r,
26989
27016
  target: l,
@@ -26994,7 +27021,7 @@ async function J(e, t) {
26994
27021
  if (!t) throw Error(`transplant.deep: merge target vanished: ${l.id}`);
26995
27022
  u = t;
26996
27023
  } else {
26997
- let t = await q(e, {
27024
+ let t = await K(e, {
26998
27025
  sourceQuery: n,
26999
27026
  ref: r,
27000
27027
  targetParent: i,
@@ -27007,10 +27034,10 @@ async function J(e, t) {
27007
27034
  }
27008
27035
  let f = /* @__PURE__ */ new Map();
27009
27036
  if (a) {
27010
- let t = await er(n, r);
27037
+ let t = await sr(n, r);
27011
27038
  if (t.length > 0) {
27012
27039
  let r = typeof a == "object" ? a.keepNameFrom : void 0;
27013
- f = (await It(e, {
27040
+ f = (await Vt(e, {
27014
27041
  sourceQuery: n,
27015
27042
  records: t,
27016
27043
  cloneMappings: d,
@@ -27024,7 +27051,7 @@ async function J(e, t) {
27024
27051
  recordMappings: d
27025
27052
  };
27026
27053
  }
27027
- async function $n(e, t) {
27054
+ async function or(e, t) {
27028
27055
  let { sourceQuery: n, ref: r, targetParent: i } = t;
27029
27056
  if (r.tagName !== "Private") return;
27030
27057
  let a = (await n.any.getAttributes(r)).type;
@@ -27035,7 +27062,7 @@ async function $n(e, t) {
27035
27062
  id: t.id
27036
27063
  };
27037
27064
  }
27038
- async function er(e, t) {
27065
+ async function sr(e, t) {
27039
27066
  let { LNode: n = [], LN: r = [], LN0: i = [] } = await e.findDescendants(t, { collect: [
27040
27067
  "LNode",
27041
27068
  "LN",
@@ -27049,7 +27076,7 @@ async function er(e, t) {
27049
27076
  }
27050
27077
  //#endregion
27051
27078
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/primitives/clone-referenced.ts
27052
- async function tr(e, t) {
27079
+ async function cr(e, t) {
27053
27080
  let { sourceQuery: n, scopeRef: r, refTagName: i, targetTagName: a, alreadyCloned: o } = t, s = D[i][0].attribute.uuid, { [i]: c = [] } = await n.findDescendants(r, { collect: i }), l = /* @__PURE__ */ new Set();
27054
27081
  for (let e of c) {
27055
27082
  let t = e.attributes.find((e) => e.name === s)?.value;
@@ -27073,8 +27100,8 @@ async function tr(e, t) {
27073
27100
  }
27074
27101
  return u;
27075
27102
  }
27076
- async function nr(e, t) {
27077
- let { sourceQuery: n, scopeRef: r, refTagName: i, targetTagName: a, resolveTargetParent: o, alreadyCloned: s, omit: c } = t, l = await tr(e, {
27103
+ async function lr(e, t) {
27104
+ let { sourceQuery: n, scopeRef: r, refTagName: i, targetTagName: a, resolveTargetParent: o, alreadyCloned: s, omit: c } = t, l = await cr(e, {
27078
27105
  sourceQuery: n,
27079
27106
  scopeRef: r,
27080
27107
  refTagName: i,
@@ -27082,7 +27109,7 @@ async function nr(e, t) {
27082
27109
  alreadyCloned: s
27083
27110
  }), u = [];
27084
27111
  for (let t of l) {
27085
- let r = await q(e, {
27112
+ let r = await K(e, {
27086
27113
  sourceQuery: n,
27087
27114
  ref: t,
27088
27115
  targetParent: await o(t),
@@ -27092,8 +27119,8 @@ async function nr(e, t) {
27092
27119
  }
27093
27120
  return u;
27094
27121
  }
27095
- async function rr(e, t) {
27096
- let { sourceQuery: n, scopeTagName: r, scopeRef: i, resolveTargetParent: a, alreadyCloned: o, skip: s = /* @__PURE__ */ new Set(), omit: c } = t, l = (p[r] ?? []).filter((e) => e in D && !s.has(e)), u = nr, d = [];
27122
+ async function ur(e, t) {
27123
+ let { sourceQuery: n, scopeTagName: r, scopeRef: i, resolveTargetParent: a, alreadyCloned: o, skip: s = /* @__PURE__ */ new Set(), omit: c } = t, l = (p[r] ?? []).filter((e) => e in D && !s.has(e)), u = lr, d = [];
27097
27124
  for (let t of l) for (let r of D[t]) for (let s of r.target) {
27098
27125
  let r = await u(e, {
27099
27126
  sourceQuery: n,
@@ -27110,7 +27137,7 @@ async function rr(e, t) {
27110
27137
  }
27111
27138
  //#endregion
27112
27139
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/primitives/merge-children-into.ts
27113
- async function ir(e, t) {
27140
+ async function dr(e, t) {
27114
27141
  let { sourceQuery: n, source: r, target: i, strip: a } = t, o = await n.any.getRecord(r);
27115
27142
  if (!o) return [];
27116
27143
  let s = [];
@@ -27118,9 +27145,9 @@ async function ir(e, t) {
27118
27145
  let r = {
27119
27146
  tagName: t.tagName,
27120
27147
  id: t.id
27121
- }, o = await n.any.getAttribute(t, { name: "name" }), c = o ? await ar(e, i, t.tagName, o) : void 0;
27148
+ }, o = await n.any.getAttribute(t, { name: "name" }), c = o ? await fr(e, i, t.tagName, o) : void 0;
27122
27149
  if (c) {
27123
- s.push(...await ir(e, {
27150
+ s.push(...await dr(e, {
27124
27151
  sourceQuery: n,
27125
27152
  source: r,
27126
27153
  target: c,
@@ -27128,7 +27155,8 @@ async function ir(e, t) {
27128
27155
  }));
27129
27156
  continue;
27130
27157
  }
27131
- let l = await q(e, {
27158
+ if (await pr(e, i, n, r)) continue;
27159
+ let l = await K(e, {
27132
27160
  sourceQuery: n,
27133
27161
  ref: r,
27134
27162
  targetParent: i,
@@ -27138,7 +27166,7 @@ async function ir(e, t) {
27138
27166
  }
27139
27167
  return s;
27140
27168
  }
27141
- async function ar(e, t, n, r) {
27169
+ async function fr(e, t, n, r) {
27142
27170
  let i = await e.any.getRecord(t);
27143
27171
  if (i) {
27144
27172
  for (let t of i.children) if (t.tagName === n && await e.any.getAttribute(t, { name: "name" }) === r) return {
@@ -27147,9 +27175,19 @@ async function ar(e, t, n, r) {
27147
27175
  };
27148
27176
  }
27149
27177
  }
27178
+ async function pr(e, t, n, r) {
27179
+ let i = await e.any.getRecord(t);
27180
+ if (!i) return !1;
27181
+ let a = await z(n, { ref: r });
27182
+ for (let t of i.children) if (t.tagName === r.tagName && await z(e, { ref: {
27183
+ tagName: t.tagName,
27184
+ id: t.id
27185
+ } }) === a) return !0;
27186
+ return !1;
27187
+ }
27150
27188
  //#endregion
27151
27189
  //#region src/v2019C1/extensions/lifecycle/transplant/transaction/resolve-structure-ref.ts
27152
- async function Y(e, t, n) {
27190
+ async function q(e, t, n) {
27153
27191
  let r = (await e.findAncestors(t, { stopAtTagName: "Substation" })).find((e) => e.tagName in n);
27154
27192
  s(r, {
27155
27193
  key: "ELEMENT_NOT_FOUND",
@@ -27164,7 +27202,7 @@ async function Y(e, t, n) {
27164
27202
  id: i.id
27165
27203
  };
27166
27204
  }
27167
- function or(e) {
27205
+ function mr(e) {
27168
27206
  let { sourceQuery: t, structure: n, cloneIndex: r } = e;
27169
27207
  return async function(e) {
27170
27208
  let i = await t.findAncestors(e, { stopAtTagName: "Substation" });
@@ -27187,26 +27225,26 @@ function or(e) {
27187
27225
  }
27188
27226
  //#endregion
27189
27227
  //#region src/v2019C1/extensions/lifecycle/engine/reconcile.ts
27190
- async function sr(e, t) {
27228
+ async function hr(e, t) {
27191
27229
  let { sourceQuery: n, sourceRootRef: r, instanceRootRef: i, accepted: a, overrides: o, keepNameTypesFrom: s, matchKey: c = "templateUuid", identityMode: l = "stamp-template" } = t, u = await n.any.getTree(r), d = await e.any.getTree(i);
27192
27230
  if (!u || !d) return;
27193
27231
  let f = /* @__PURE__ */ new Map();
27194
- await fr(e, {
27232
+ await br(e, {
27195
27233
  node: d,
27196
27234
  index: f,
27197
27235
  matchKey: c
27198
27236
  });
27199
27237
  let p = /* @__PURE__ */ new Set();
27200
- await pr(n, {
27238
+ await xr(n, {
27201
27239
  node: u,
27202
27240
  out: p
27203
- }), await dr(e, {
27241
+ }), await yr(e, {
27204
27242
  sourceQuery: n,
27205
27243
  instanceRecord: d,
27206
27244
  sourceNode: u,
27207
27245
  accepted: a,
27208
27246
  overrides: o
27209
- }), await cr(e, {
27247
+ }), await gr(e, {
27210
27248
  sourceQuery: n,
27211
27249
  sourceNode: u,
27212
27250
  instanceParent: d,
@@ -27216,25 +27254,25 @@ async function sr(e, t) {
27216
27254
  keepNameTypesFrom: s,
27217
27255
  matchKey: c,
27218
27256
  identityMode: l
27219
- }), await lr(e, {
27257
+ }), await _r(e, {
27220
27258
  instanceNode: d,
27221
27259
  sourceUuids: p,
27222
27260
  accepted: a,
27223
27261
  matchKey: c
27224
27262
  });
27225
27263
  }
27226
- async function cr(e, t) {
27264
+ async function gr(e, t) {
27227
27265
  let { sourceQuery: n, sourceNode: r, instanceParent: i, index: o, accepted: s, overrides: c, keepNameTypesFrom: l, matchKey: u, identityMode: d } = t, f = /* @__PURE__ */ new Set();
27228
27266
  for (let t of r.tree) {
27229
27267
  let r = await n.any.getAttribute(t, { name: "uuid" }), p = (r ? o.get(r) : void 0) ?? (r ? void 0 : i.tree.find((e) => e.tagName === t.tagName && !f.has(e.id)));
27230
27268
  if (p) {
27231
- f.add(p.id), await dr(e, {
27269
+ f.add(p.id), await yr(e, {
27232
27270
  sourceQuery: n,
27233
27271
  instanceRecord: p,
27234
27272
  sourceNode: t,
27235
27273
  accepted: s,
27236
27274
  overrides: c
27237
- }), await cr(e, {
27275
+ }), await gr(e, {
27238
27276
  sourceQuery: n,
27239
27277
  sourceNode: t,
27240
27278
  instanceParent: p,
@@ -27248,34 +27286,34 @@ async function cr(e, t) {
27248
27286
  continue;
27249
27287
  }
27250
27288
  if (s && !s.sourceIds.has(t.id)) continue;
27251
- let { recordMappings: m } = await J(e, {
27289
+ let { recordMappings: m } = await ar(e, {
27252
27290
  sourceQuery: n,
27253
27291
  ref: a(t),
27254
27292
  targetParent: a(i),
27255
27293
  strip: !1,
27256
27294
  withTypes: { keepNameFrom: l }
27257
27295
  });
27258
- await H(e, {
27296
+ await U(e, {
27259
27297
  mappings: m,
27260
27298
  mode: d
27261
- }), d === "keep" && await on(e, { mappings: m });
27299
+ }), d === "keep" ? await W(e, { mappings: m }) : await I(e, { mappings: m });
27262
27300
  let h = m.find((e) => e.source.id === t.id);
27263
- h && d !== "keep" && await K(e, {
27301
+ h && d !== "keep" && await nr(e, {
27264
27302
  ref: h.target,
27265
27303
  parentRef: a(i),
27266
27304
  overrides: c?.get(t.id)
27267
27305
  });
27268
27306
  }
27269
27307
  for (let t of i.tree) if (!f.has(t.id) && !await e.any.getAttribute(t, { name: "templateUuid" })) {
27270
- if (A.has(t.tagName) && !O.has(t.tagName)) {
27308
+ if (k.has(t.tagName) && !O.has(t.tagName)) {
27271
27309
  if (s && !s.instanceIds.has(t.id)) continue;
27272
27310
  } else if (!s || !s.instanceIds.has(t.id)) continue;
27273
27311
  await e.any.getRecord(t) && await e.any.delete(t);
27274
27312
  }
27275
27313
  }
27276
- async function lr(e, t) {
27314
+ async function _r(e, t) {
27277
27315
  let { instanceNode: n, sourceUuids: r, accepted: i, matchKey: a } = t, o = [];
27278
- await ur(e, {
27316
+ await vr(e, {
27279
27317
  node: n,
27280
27318
  sourceUuids: r,
27281
27319
  accepted: i,
@@ -27284,13 +27322,13 @@ async function lr(e, t) {
27284
27322
  });
27285
27323
  for (let t of o) await e.any.getRecord(t) && await e.any.delete(t);
27286
27324
  }
27287
- async function ur(e, t) {
27325
+ async function vr(e, t) {
27288
27326
  let { node: n, sourceUuids: r, accepted: i, matchKey: a, out: o } = t, s = await e.any.getAttribute(n, { name: a });
27289
27327
  if (s && !r.has(s)) {
27290
27328
  (!i || i.instanceIds.has(n.id)) && o.push(n);
27291
27329
  return;
27292
27330
  }
27293
- for (let t of n.tree) await ur(e, {
27331
+ for (let t of n.tree) await vr(e, {
27294
27332
  node: t,
27295
27333
  sourceUuids: r,
27296
27334
  accepted: i,
@@ -27298,87 +27336,87 @@ async function ur(e, t) {
27298
27336
  out: o
27299
27337
  });
27300
27338
  }
27301
- async function dr(e, t) {
27339
+ async function yr(e, t) {
27302
27340
  let { sourceQuery: n, instanceRecord: r, sourceNode: i, accepted: a, overrides: o } = t;
27303
27341
  if (a && !a.sourceIds.has(i.id)) return;
27304
27342
  let s = {
27305
- ...hn(await n.any.getAttributes(i)),
27343
+ ...vn(await n.any.getAttributes(i)),
27306
27344
  ...o?.get(i.id)
27307
- }, c = hn(await e.any.getAttributes(r)), l = {};
27345
+ }, c = vn(await e.any.getAttributes(r)), l = {};
27308
27346
  for (let e of new Set([...Object.keys(s), ...Object.keys(c)])) {
27309
27347
  let t = e in s ? s[e] : void 0;
27310
27348
  c[e] !== t && (l[e] = t);
27311
27349
  }
27312
- if (r.tagName === "LNode" && Object.keys(l).some((e) => Ie.has(e)) && await te(e, r)) for (let e of Ie) delete l[e];
27350
+ if (r.tagName === "LNode" && Object.keys(l).some((e) => Be.has(e)) && await w(e, r)) for (let e of Be) delete l[e];
27313
27351
  Object.keys(l).length > 0 && await e.any.update(r, { attributes: l });
27314
27352
  }
27315
- async function fr(e, t) {
27353
+ async function br(e, t) {
27316
27354
  let { node: n, index: r, matchKey: i } = t, a = await e.any.getAttribute(n, { name: i });
27317
27355
  a && r.set(a, n);
27318
- for (let t of n.tree) await fr(e, {
27356
+ for (let t of n.tree) await br(e, {
27319
27357
  node: t,
27320
27358
  index: r,
27321
27359
  matchKey: i
27322
27360
  });
27323
27361
  }
27324
- async function pr(e, t) {
27362
+ async function xr(e, t) {
27325
27363
  let { node: n, out: r } = t, i = await e.any.getAttribute(n, { name: "uuid" });
27326
27364
  i && r.add(i);
27327
- for (let t of n.tree) await pr(e, {
27365
+ for (let t of n.tree) await xr(e, {
27328
27366
  node: t,
27329
27367
  out: r
27330
27368
  });
27331
27369
  }
27332
27370
  //#endregion
27333
27371
  //#region src/v2019C1/extensions/lifecycle/engine/decide.ts
27334
- function mr(e, t) {
27372
+ function Sr(e, t) {
27335
27373
  return e?.instances.find((e) => e.rootRef?.id === t)?.groups ?? [];
27336
27374
  }
27337
- function hr(e) {
27375
+ function Cr(e) {
27338
27376
  return e === void 0 ? "accept" : typeof e == "string" ? e : e.action;
27339
27377
  }
27340
- function gr(e) {
27378
+ function wr(e) {
27341
27379
  return typeof e == "object" ? e.values : void 0;
27342
27380
  }
27343
- function _r(e) {
27381
+ function Tr(e) {
27344
27382
  let t = e.decisions.get(e.group.id);
27345
- return t === void 0 ? e.group.suggestedAction : hr(t);
27383
+ return t === void 0 ? e.group.suggestedAction : Cr(t);
27346
27384
  }
27347
- function vr(e) {
27348
- return _r(e) !== "skip";
27385
+ function Er(e) {
27386
+ return Tr(e) !== "skip";
27349
27387
  }
27350
- function yr(e) {
27388
+ function Dr(e) {
27351
27389
  let { groups: t, decisions: n } = e, r = /* @__PURE__ */ new Map();
27352
27390
  for (let e of t) {
27353
27391
  let t = n.get(e.id);
27354
- if (_r({
27392
+ if (Tr({
27355
27393
  group: e,
27356
27394
  decisions: n
27357
27395
  }) === "skip") continue;
27358
- let i = gr(t), a = e.primary.sourceRef?.id;
27396
+ let i = wr(t), a = e.primary.sourceRef?.id;
27359
27397
  i && a && r.set(a, i);
27360
27398
  }
27361
27399
  return r;
27362
27400
  }
27363
- function br(e) {
27401
+ function Or(e) {
27364
27402
  let { groups: t, decisions: n } = e;
27365
- for (let e of t) if (vr({
27403
+ for (let e of t) if (Er({
27366
27404
  group: e,
27367
27405
  decisions: n
27368
- })) for (let r of e.dependsOn) s(vr({
27369
- group: xr(t, r) ?? e,
27406
+ })) for (let r of e.dependsOn) s(Er({
27407
+ group: kr(t, r) ?? e,
27370
27408
  decisions: n
27371
27409
  }), { detail: `decision accepts group "${e.id}" but its dependency "${r}" is skipped` });
27372
27410
  }
27373
- function xr(e, t) {
27411
+ function kr(e, t) {
27374
27412
  return e.find((e) => e.id === t);
27375
27413
  }
27376
- function Sr(e) {
27414
+ function Ar(e) {
27377
27415
  let { groups: t, decisions: n } = e, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
27378
- for (let e of t) if (vr({
27416
+ for (let e of t) if (Er({
27379
27417
  group: e,
27380
27418
  decisions: n
27381
- })) for (let t of [e.primary, ...e.companions]) Cr({
27419
+ })) for (let t of [e.primary, ...e.companions]) jr({
27382
27420
  node: t,
27383
27421
  sourceIds: r,
27384
27422
  instanceIds: i
@@ -27388,45 +27426,45 @@ function Sr(e) {
27388
27426
  instanceIds: i
27389
27427
  };
27390
27428
  }
27391
- function Cr(e) {
27429
+ function jr(e) {
27392
27430
  let { node: t, sourceIds: n, instanceIds: r } = e;
27393
- wr({
27431
+ Mr({
27394
27432
  node: t,
27395
27433
  sourceIds: n,
27396
27434
  instanceIds: r
27397
27435
  });
27398
- for (let e of t.children) Cr({
27436
+ for (let e of t.children) jr({
27399
27437
  node: e,
27400
27438
  sourceIds: n,
27401
27439
  instanceIds: r
27402
27440
  });
27403
27441
  }
27404
- function wr(e) {
27442
+ function Mr(e) {
27405
27443
  let { node: t, sourceIds: n, instanceIds: r } = e;
27406
27444
  t.change !== "unchanged" && (t.change === "removed" || t.change === "target-only" ? t.instanceRef?.id && r.add(t.instanceRef.id) : t.sourceRef?.id && n.add(t.sourceRef.id));
27407
27445
  }
27408
27446
  //#endregion
27409
27447
  //#region src/v2019C1/extensions/lifecycle/instance/composed-functions.ts
27410
- async function Tr(e, t) {
27448
+ async function Nr(e, t) {
27411
27449
  let n = /* @__PURE__ */ new Set(), r = await e.any.getTree(t);
27412
- return r && await Er(e, r, n), n;
27450
+ return r && await Pr(e, r, n), n;
27413
27451
  }
27414
- async function Er(e, t, n) {
27452
+ async function Pr(e, t, n) {
27415
27453
  if (t.tagName === "FunctionRef") {
27416
27454
  let r = await e.any.getAttribute(t, { name: "functionUuid" });
27417
27455
  r && n.add(r);
27418
27456
  }
27419
- for (let r of t.tree) await Er(e, r, n);
27457
+ for (let r of t.tree) await Pr(e, r, n);
27420
27458
  }
27421
27459
  //#endregion
27422
27460
  //#region src/v2019C1/extensions/lifecycle/instance/find-instance.ts
27423
- async function Dr(e, t) {
27461
+ async function Fr(e, t) {
27424
27462
  let { targetParent: n, tagName: r, sourceUuid: i, matchKey: a = "templateUuid" } = t;
27425
27463
  if (!i) return [];
27426
27464
  let o = await e.any.getTree(n);
27427
27465
  if (!o) return [];
27428
27466
  let s = [];
27429
- return await Or(e, {
27467
+ return await Ir(e, {
27430
27468
  node: o,
27431
27469
  tagName: r,
27432
27470
  sourceUuid: i,
@@ -27434,13 +27472,13 @@ async function Dr(e, t) {
27434
27472
  out: s
27435
27473
  }), s;
27436
27474
  }
27437
- async function Or(e, t) {
27475
+ async function Ir(e, t) {
27438
27476
  let { node: n, tagName: r, sourceUuid: i, matchKey: a, out: o } = t;
27439
27477
  if (n.tagName === r && await e.any.getAttribute(n, { name: a }) === i) {
27440
27478
  o.push(n);
27441
27479
  return;
27442
27480
  }
27443
- for (let t of n.tree) await Or(e, {
27481
+ for (let t of n.tree) await Ir(e, {
27444
27482
  node: t,
27445
27483
  tagName: r,
27446
27484
  sourceUuid: i,
@@ -27448,77 +27486,80 @@ async function Or(e, t) {
27448
27486
  out: o
27449
27487
  });
27450
27488
  }
27451
- async function kr(e, t) {
27452
- let [n] = await X(e, t);
27489
+ async function Lr(e, t) {
27490
+ let [n] = await J(e, t);
27453
27491
  return n;
27454
27492
  }
27455
- async function X(e, t) {
27456
- let { tagName: n, sourceUuid: r, sourceName: i } = t, a = await e.any.getRecordsByTagName(n), o = [];
27457
- if (r) for (let t of a) await e.any.getAttribute(t, { name: "templateUuid" }) === r && o.push(t);
27458
- if (o.length > 0) return o;
27493
+ async function J(e, t) {
27494
+ let { tagName: n, sourceUuid: r, sourceName: i, matchKey: a = "templateUuid" } = t, o = await e.any.getRecordsByTagName(n), s = [];
27495
+ if (r) for (let t of o) await e.any.getAttribute(t, { name: a }) === r && s.push(t);
27496
+ if (s.length > 0) return s;
27459
27497
  if (!i) return [];
27460
- let s = [];
27461
- for (let t of a) await e.any.getAttribute(t, { name: "name" }) === i && s.push(t);
27462
- return s.length === 1 ? s : [];
27498
+ let c = [];
27499
+ for (let t of o) await e.any.getAttribute(t, { name: "name" }) === i && c.push(t);
27500
+ return c.length === 1 ? c : [];
27463
27501
  }
27464
27502
  //#endregion
27465
27503
  //#region src/v2019C1/extensions/lifecycle/update/transaction/satellite-reconcile.ts
27466
- async function Ar(e, t) {
27467
- let { sourceQuery: n, satelliteRefs: r, instanceSatelliteRefs: i, structure: a, accepted: o } = t;
27504
+ async function Rr(e, t) {
27505
+ let { sourceQuery: n, satelliteRefs: r, instanceSatelliteRefs: i, structure: a, accepted: o, matchKey: s = "templateUuid", identityMode: c = "stamp-template" } = t;
27468
27506
  for (let t of r) {
27469
- let { uuid: r, name: i } = await n.any.getAttributes(t), s = await kr(e, {
27507
+ let { uuid: r, name: i } = await n.any.getAttributes(t), l = await Lr(e, {
27470
27508
  tagName: t.tagName,
27471
27509
  sourceUuid: r,
27472
- sourceName: i
27510
+ sourceName: i,
27511
+ matchKey: s
27473
27512
  });
27474
- if (s) {
27475
- await sr(e, {
27513
+ if (l) {
27514
+ await hr(e, {
27476
27515
  sourceQuery: n,
27477
27516
  sourceRootRef: t,
27478
- instanceRootRef: s,
27479
- accepted: o
27517
+ instanceRootRef: l,
27518
+ accepted: o,
27519
+ matchKey: s,
27520
+ identityMode: c
27480
27521
  });
27481
27522
  continue;
27482
27523
  }
27483
27524
  if (o && t.id && !o.sourceIds.has(t.id)) continue;
27484
- let c = await q(e, {
27525
+ let u = await K(e, {
27485
27526
  sourceQuery: n,
27486
27527
  ref: t,
27487
- targetParent: await Y(n, t, a),
27528
+ targetParent: await q(n, t, a),
27488
27529
  strip: !1
27489
27530
  });
27490
- c && await H(e, {
27491
- mappings: c.mappings,
27492
- mode: "stamp-template"
27493
- });
27531
+ u && (await U(e, {
27532
+ mappings: u.mappings,
27533
+ mode: c
27534
+ }), c === "keep" && await W(e, { mappings: u.mappings }));
27494
27535
  }
27495
27536
  for (let t of i ?? []) {
27496
- let { templateUuid: r } = await e.any.getAttributes(t);
27537
+ let r = await e.any.getAttribute(t, { name: s });
27497
27538
  if (!r) continue;
27498
27539
  let [i] = await n.any.findByAttributes({
27499
27540
  tagName: t.tagName,
27500
27541
  attributes: { uuid: r }
27501
27542
  });
27502
- i || o && t.id && !o.instanceIds.has(t.id) || (await I(e, { target: t })).length > 0 || await e.delete(t);
27543
+ i || o && t.id && !o.instanceIds.has(t.id) || (await F(e, { target: t })).length > 0 || await e.delete(t);
27503
27544
  }
27504
27545
  }
27505
27546
  //#endregion
27506
27547
  //#region src/v2019C1/extensions/lifecycle/cross-cutting/applied-satellites.constants.ts
27507
- var jr = ["Variable", "BehaviorDescription"];
27548
+ var zr = ["Variable", "BehaviorDescription"];
27508
27549
  //#endregion
27509
27550
  //#region src/v2019C1/extensions/lifecycle/cross-cutting/applied-satellites.ts
27510
- async function Z(e, t) {
27551
+ async function Y(e, t) {
27511
27552
  let { primaryRef: n } = t, r = await e.any.getTree(n);
27512
27553
  if (!r) return [];
27513
27554
  let i = /* @__PURE__ */ new Set(), o = [];
27514
- Mr({
27555
+ Br({
27515
27556
  node: r,
27516
27557
  subtreeIds: i,
27517
27558
  targets: o
27518
27559
  });
27519
27560
  let s = /* @__PURE__ */ new Set(), c = [];
27520
- for (let t of o) for (let n of jr) {
27521
- let r = await z.query.findRefsPointingTo(e, {
27561
+ for (let t of o) for (let n of zr) {
27562
+ let r = await L.query.findRefsPointingTo(e, {
27522
27563
  target: a(t),
27523
27564
  containerTagName: n
27524
27565
  });
@@ -27526,10 +27567,10 @@ async function Z(e, t) {
27526
27567
  }
27527
27568
  return c;
27528
27569
  }
27529
- function Mr(e) {
27570
+ function Br(e) {
27530
27571
  let { node: t, subtreeIds: n, targets: r } = e;
27531
27572
  n.add(t.id), t.attributes.some((e) => e.name === "uuid") && r.push(t);
27532
- for (let e of t.tree) Mr({
27573
+ for (let e of t.tree) Br({
27533
27574
  node: e,
27534
27575
  subtreeIds: n,
27535
27576
  targets: r
@@ -27537,19 +27578,21 @@ function Mr(e) {
27537
27578
  }
27538
27579
  //#endregion
27539
27580
  //#region src/v2019C1/extensions/lifecycle/update/transaction/cross-cutting-satellites.ts
27540
- async function Nr(e, t) {
27541
- let { sourceQuery: n, primaryRef: r, instancePrimaryRef: i, structure: a, accepted: o } = t;
27542
- await Ar(e, {
27581
+ async function Vr(e, t) {
27582
+ let { sourceQuery: n, primaryRef: r, instancePrimaryRef: i, structure: a, accepted: o, matchKey: s, identityMode: c } = t;
27583
+ await Rr(e, {
27543
27584
  sourceQuery: n,
27544
- satelliteRefs: await Z(n, { primaryRef: r }),
27545
- instanceSatelliteRefs: i ? await Z(e, { primaryRef: i }) : [],
27585
+ satelliteRefs: await Y(n, { primaryRef: r }),
27586
+ instanceSatelliteRefs: i ? await Y(e, { primaryRef: i }) : [],
27546
27587
  structure: a,
27547
- accepted: o
27588
+ accepted: o,
27589
+ matchKey: s,
27590
+ identityMode: c
27548
27591
  });
27549
27592
  }
27550
27593
  //#endregion
27551
27594
  //#region src/v2019C1/extensions/lifecycle/instantiate/transaction/resolve-target-structure.ts
27552
- async function Q(e, t) {
27595
+ async function X(e, t) {
27553
27596
  let n = await e.getRecord(t);
27554
27597
  s(n, {
27555
27598
  key: "ELEMENT_NOT_FOUND",
@@ -27560,12 +27603,12 @@ async function Q(e, t) {
27560
27603
  }
27561
27604
  //#endregion
27562
27605
  //#region src/v2019C1/extensions/lifecycle/cross-cutting/clone-applied-satellites.ts
27563
- async function Pr(e, t) {
27564
- let { sourceQuery: n, primaryRef: r, structure: i, strip: a = !0 } = t, o = await Z(n, { primaryRef: r }), s = [];
27606
+ async function Hr(e, t) {
27607
+ let { sourceQuery: n, primaryRef: r, structure: i, strip: a = !0 } = t, o = await Y(n, { primaryRef: r }), s = [];
27565
27608
  for (let t of o) {
27566
- let r = await Fr(e, n, t);
27609
+ let r = await Ur(e, n, t);
27567
27610
  if (r) {
27568
- let i = await ir(e, {
27611
+ let i = await dr(e, {
27569
27612
  sourceQuery: n,
27570
27613
  source: t,
27571
27614
  target: r,
@@ -27574,17 +27617,17 @@ async function Pr(e, t) {
27574
27617
  s.push(...i);
27575
27618
  continue;
27576
27619
  }
27577
- let o = await q(e, {
27620
+ let o = await K(e, {
27578
27621
  sourceQuery: n,
27579
27622
  ref: t,
27580
- targetParent: await Y(n, t, i),
27623
+ targetParent: await q(n, t, i),
27581
27624
  ...a ? {} : { strip: !1 }
27582
27625
  });
27583
27626
  o && s.push(...o.mappings);
27584
27627
  }
27585
27628
  return s;
27586
27629
  }
27587
- async function Fr(e, t, n) {
27630
+ async function Ur(e, t, n) {
27588
27631
  let r = await t.any.getRecord(n);
27589
27632
  if (!r) return;
27590
27633
  let i = await t.any.getAttribute(r, { name: "name" });
@@ -27600,8 +27643,8 @@ async function Fr(e, t, n) {
27600
27643
  }
27601
27644
  //#endregion
27602
27645
  //#region src/v2019C1/extensions/lifecycle/layers/function/clone-function.ts
27603
- async function Ir(e, t) {
27604
- let { sourceQuery: n, functionRef: r, targetParentRef: i, omit: a, stripRootAttributes: o, keepNameTypesFrom: s } = t, { recordMappings: c } = await J(e, {
27646
+ async function Wr(e, t) {
27647
+ let { sourceQuery: n, functionRef: r, targetParentRef: i, omit: a, stripRootAttributes: o, keepNameTypesFrom: s } = t, { recordMappings: c } = await ar(e, {
27605
27648
  sourceQuery: n,
27606
27649
  ref: r,
27607
27650
  targetParent: i,
@@ -27618,15 +27661,15 @@ async function Ir(e, t) {
27618
27661
  });
27619
27662
  return c;
27620
27663
  }
27621
- async function Lr(e, t) {
27622
- let { sourceQuery: n, functionRef: r, structure: i, stripCategoriesUuid: a = !0 } = t, o = await Rr(n, r), s = [];
27664
+ async function Z(e, t) {
27665
+ let { sourceQuery: n, functionRef: r, structure: i, stripCategoriesUuid: a = !0 } = t, o = await Gr(n, r), s = [];
27623
27666
  for (let t of o) {
27624
27667
  let r = {
27625
27668
  tagName: "FunctionCategory",
27626
27669
  id: t
27627
- }, o = await Br(e, n, t);
27670
+ }, o = await qr(e, n, t);
27628
27671
  if (o) {
27629
- let t = await ir(e, {
27672
+ let t = await dr(e, {
27630
27673
  sourceQuery: n,
27631
27674
  source: r,
27632
27675
  target: o,
@@ -27635,28 +27678,28 @@ async function Lr(e, t) {
27635
27678
  s.push(...t);
27636
27679
  continue;
27637
27680
  }
27638
- let c = await q(e, {
27681
+ let c = await K(e, {
27639
27682
  sourceQuery: n,
27640
27683
  ref: r,
27641
- targetParent: await Y(n, r, i),
27684
+ targetParent: await q(n, r, i),
27642
27685
  ...a ? {} : { strip: !1 }
27643
27686
  });
27644
27687
  c && s.push(...c.mappings);
27645
27688
  }
27646
27689
  return s;
27647
27690
  }
27648
- async function Rr(e, t) {
27649
- let n = await zr(e, t), r = /* @__PURE__ */ new Set();
27691
+ async function Gr(e, t) {
27692
+ let n = await Kr(e, t), r = /* @__PURE__ */ new Set();
27650
27693
  for (let { container: e } of n) e && r.add(e.id);
27651
27694
  return r;
27652
27695
  }
27653
- async function zr(e, t) {
27654
- let n = await z.query.findRefsPointingTo(e, {
27696
+ async function Kr(e, t) {
27697
+ let n = await L.query.findRefsPointingTo(e, {
27655
27698
  target: t,
27656
27699
  containerTagName: "FunctionCategory"
27657
27700
  }), { SubFunction: r = [] } = await e.findDescendants(t, { collect: "SubFunction" });
27658
27701
  for (let t of r) {
27659
- let r = await z.query.findRefsPointingTo(e, {
27702
+ let r = await L.query.findRefsPointingTo(e, {
27660
27703
  target: {
27661
27704
  tagName: "SubFunction",
27662
27705
  id: t.id
@@ -27667,7 +27710,7 @@ async function zr(e, t) {
27667
27710
  }
27668
27711
  return n;
27669
27712
  }
27670
- async function Br(e, t, n) {
27713
+ async function qr(e, t, n) {
27671
27714
  let r = await t.getRecord({
27672
27715
  tagName: "FunctionCategory",
27673
27716
  id: n
@@ -27686,18 +27729,18 @@ async function Br(e, t, n) {
27686
27729
  }
27687
27730
  //#endregion
27688
27731
  //#region src/v2019C1/extensions/lifecycle/layers/function/satellites.constants.ts
27689
- var Vr = ["FunctionCategory"];
27732
+ var Jr = ["FunctionCategory"];
27690
27733
  //#endregion
27691
27734
  //#region src/v2019C1/extensions/lifecycle/layers/function/satellites.ts
27692
- async function Hr(e, t) {
27735
+ async function Yr(e, t) {
27693
27736
  let { primaryRef: n } = t, r = [n], { SubFunction: i = [] } = await e.findDescendants(n, { collect: "SubFunction" });
27694
27737
  for (let e of i) r.push({
27695
27738
  tagName: "SubFunction",
27696
27739
  id: e.id
27697
27740
  });
27698
27741
  let o = /* @__PURE__ */ new Set(), s = [];
27699
- for (let t of r) for (let n of Vr) {
27700
- let r = await z.query.findRefsPointingTo(e, {
27742
+ for (let t of r) for (let n of Jr) {
27743
+ let r = await L.query.findRefsPointingTo(e, {
27701
27744
  target: t,
27702
27745
  containerTagName: n
27703
27746
  });
@@ -27707,8 +27750,8 @@ async function Hr(e, t) {
27707
27750
  }
27708
27751
  //#endregion
27709
27752
  //#region src/v2019C1/extensions/lifecycle/instantiate/transaction/fsd.ts
27710
- async function Ur(e, t) {
27711
- let { sourceQuery: n, functionRef: r, targetParent: i, overrides: a, keepNameTypesFrom: o } = t, { recordMappings: s } = await J(e, {
27753
+ async function Xr(e, t) {
27754
+ let { sourceQuery: n, functionRef: r, targetParent: i, overrides: a, keepNameTypesFrom: o } = t, { recordMappings: s } = await ar(e, {
27712
27755
  sourceQuery: n,
27713
27756
  ref: r,
27714
27757
  targetParent: i,
@@ -27718,12 +27761,12 @@ async function Ur(e, t) {
27718
27761
  to: "SubFunction"
27719
27762
  } : void 0,
27720
27763
  withTypes: { keepNameFrom: o }
27721
- }), c = await Q(e, i), l = await Lr(e, {
27764
+ }), c = await X(e, i), l = await Z(e, {
27722
27765
  sourceQuery: n,
27723
27766
  functionRef: r,
27724
27767
  structure: c,
27725
27768
  stripCategoriesUuid: !1
27726
- }), u = await Pr(e, {
27769
+ }), u = await Hr(e, {
27727
27770
  sourceQuery: n,
27728
27771
  primaryRef: r,
27729
27772
  structure: c,
@@ -27733,21 +27776,23 @@ async function Ur(e, t) {
27733
27776
  ...l,
27734
27777
  ...u
27735
27778
  ];
27736
- await R(e, { mappings: d }), await H(e, {
27779
+ await I(e, { mappings: d }), await U(e, {
27737
27780
  mappings: d,
27738
27781
  mode: "stamp-template"
27739
27782
  });
27740
27783
  let f = s.find((e) => e.source.id === r.id);
27741
27784
  if (!f) throw Error(`instantiate.fsd: cloned root not found for ${r.tagName}#${r.id}`);
27742
27785
  let p = f.target;
27743
- return await K(e, {
27786
+ return await nr(e, {
27744
27787
  ref: p,
27745
27788
  parentRef: i,
27746
27789
  overrides: a?.get(r.id)
27747
- }), await _t(e, {
27790
+ }), await St(e, {
27748
27791
  sourceQuery: n,
27749
- targetRoot: p,
27750
- fileType: "FSD"
27792
+ target: {
27793
+ anchor: "function",
27794
+ root: p
27795
+ }
27751
27796
  }), {
27752
27797
  functionRef: p,
27753
27798
  recordMappings: s
@@ -27755,18 +27800,18 @@ async function Ur(e, t) {
27755
27800
  }
27756
27801
  //#endregion
27757
27802
  //#region src/v2019C1/extensions/lifecycle/layers/application/clone-application.ts
27758
- async function Wr(e, t) {
27759
- let { sourceQuery: n, applicationRef: r, structure: i, omit: a, keepNameTypesFrom: o } = t, s = /* @__PURE__ */ new Map(), c = [], l = await tr(e, {
27803
+ async function Zr(e, t) {
27804
+ let { sourceQuery: n, applicationRef: r, structure: i, omit: a, keepNameTypesFrom: o } = t, s = /* @__PURE__ */ new Map(), c = [], l = await cr(e, {
27760
27805
  sourceQuery: n,
27761
27806
  scopeRef: r,
27762
27807
  refTagName: "FunctionRef",
27763
27808
  targetTagName: "Function"
27764
27809
  });
27765
27810
  for (let t of l) {
27766
- let r = await Ir(e, {
27811
+ let r = await Wr(e, {
27767
27812
  sourceQuery: n,
27768
27813
  functionRef: t,
27769
- targetParentRef: await Y(n, t, i),
27814
+ targetParentRef: await q(n, t, i),
27770
27815
  omit: a,
27771
27816
  keepNameTypesFrom: o
27772
27817
  });
@@ -27774,7 +27819,7 @@ async function Wr(e, t) {
27774
27819
  for (let e of r) e.source.id && s.set(e.source.id, e.target);
27775
27820
  }
27776
27821
  for (let t of l) {
27777
- let r = await Lr(e, {
27822
+ let r = await Z(e, {
27778
27823
  sourceQuery: n,
27779
27824
  functionRef: t,
27780
27825
  structure: i,
@@ -27782,16 +27827,16 @@ async function Wr(e, t) {
27782
27827
  });
27783
27828
  c.push(...r);
27784
27829
  }
27785
- let u = await Gr(e, {
27830
+ let u = await Qr(e, {
27786
27831
  sourceQuery: n,
27787
27832
  applicationRef: r
27788
27833
  });
27789
27834
  for (let e of u) s.set(e.sourceId, e.existingRef);
27790
- let d = new Set(["FunctionRef", "FunctionCategoryRef"]), f = await rr(e, {
27835
+ let d = new Set(["FunctionRef", "FunctionCategoryRef"]), f = await ur(e, {
27791
27836
  sourceQuery: n,
27792
27837
  scopeTagName: "Application",
27793
27838
  scopeRef: r,
27794
- resolveTargetParent: or({
27839
+ resolveTargetParent: mr({
27795
27840
  sourceQuery: n,
27796
27841
  structure: i,
27797
27842
  cloneIndex: s
@@ -27801,10 +27846,10 @@ async function Wr(e, t) {
27801
27846
  omit: a
27802
27847
  });
27803
27848
  c.push(...f);
27804
- let p = await q(e, {
27849
+ let p = await K(e, {
27805
27850
  sourceQuery: n,
27806
27851
  ref: r,
27807
- targetParent: await Y(n, r, i),
27852
+ targetParent: await q(n, r, i),
27808
27853
  omit: a
27809
27854
  });
27810
27855
  p && c.push(...p.mappings);
@@ -27820,7 +27865,7 @@ async function Wr(e, t) {
27820
27865
  }
27821
27866
  return c;
27822
27867
  }
27823
- async function Gr(e, t) {
27868
+ async function Qr(e, t) {
27824
27869
  let { sourceQuery: n, applicationRef: r } = t, { AllocationRoleRef: i = [] } = await n.findDescendants(r, { collect: "AllocationRoleRef" }), a = [], o = /* @__PURE__ */ new Set();
27825
27870
  for (let t of i) {
27826
27871
  let r = t.attributes.find((e) => e.name === "allocationRoleUuid")?.value;
@@ -27844,7 +27889,7 @@ async function Gr(e, t) {
27844
27889
  tagName: "AllocationRole",
27845
27890
  id: c.id
27846
27891
  };
27847
- await Qn(e, {
27892
+ await ir(e, {
27848
27893
  sourceQuery: n,
27849
27894
  source: {
27850
27895
  tagName: "AllocationRole",
@@ -27863,20 +27908,20 @@ async function Gr(e, t) {
27863
27908
  }
27864
27909
  //#endregion
27865
27910
  //#region src/v2019C1/extensions/lifecycle/layers/application/satellites.constants.ts
27866
- var Kr = [{
27911
+ var $r = [{
27867
27912
  refTag: "AllocationRoleRef",
27868
27913
  uuidAttr: "allocationRoleUuid",
27869
27914
  targetTag: "AllocationRole"
27870
27915
  }];
27871
27916
  //#endregion
27872
27917
  //#region src/v2019C1/extensions/lifecycle/layers/application/satellites.ts
27873
- async function qr(e, t) {
27918
+ async function ei(e, t) {
27874
27919
  let { applicationRef: n } = t, r = await e.any.getTree(n);
27875
27920
  if (!r) return [];
27876
27921
  let i = /* @__PURE__ */ new Set(), o = [];
27877
- for (let t of Kr) {
27922
+ for (let t of $r) {
27878
27923
  let n = /* @__PURE__ */ new Set();
27879
- await Jr(e, {
27924
+ await ti(e, {
27880
27925
  node: r,
27881
27926
  refTag: t.refTag,
27882
27927
  uuidAttr: t.uuidAttr,
@@ -27892,13 +27937,13 @@ async function qr(e, t) {
27892
27937
  }
27893
27938
  return o;
27894
27939
  }
27895
- async function Jr(e, t) {
27940
+ async function ti(e, t) {
27896
27941
  let { node: n, refTag: r, uuidAttr: i, out: a } = t;
27897
27942
  if (n.tagName === r) {
27898
27943
  let t = await e.any.getAttribute(n, { name: i });
27899
27944
  t && a.add(t);
27900
27945
  }
27901
- for (let t of n.tree) await Jr(e, {
27946
+ for (let t of n.tree) await ti(e, {
27902
27947
  node: t,
27903
27948
  refTag: r,
27904
27949
  uuidAttr: i,
@@ -27907,32 +27952,32 @@ async function Jr(e, t) {
27907
27952
  }
27908
27953
  //#endregion
27909
27954
  //#region src/v2019C1/extensions/lifecycle/instantiate/transaction/asd.ts
27910
- async function Yr(e, t) {
27911
- let { sourceQuery: n, applicationRef: r, targetParent: i, overrides: a, keepNameTypesFrom: o } = t, s = await Q(e, i), c = await tr(e, {
27955
+ async function ni(e, t) {
27956
+ let { sourceQuery: n, applicationRef: r, targetParent: i, overrides: a, keepNameTypesFrom: o } = t, s = await X(e, i), c = await cr(e, {
27912
27957
  sourceQuery: n,
27913
27958
  scopeRef: r,
27914
27959
  refTagName: "FunctionRef",
27915
27960
  targetTagName: "Function"
27916
- }), l = await Wr(e, {
27961
+ }), l = await Zr(e, {
27917
27962
  sourceQuery: n,
27918
27963
  applicationRef: r,
27919
27964
  structure: s,
27920
27965
  keepNameTypesFrom: o
27921
- }), u = await Pr(e, {
27966
+ }), u = await Hr(e, {
27922
27967
  sourceQuery: n,
27923
27968
  primaryRef: r,
27924
27969
  structure: s,
27925
27970
  strip: !1
27926
27971
  }), d = [...l, ...u];
27927
- await R(e, { mappings: d }), await H(e, {
27972
+ await I(e, { mappings: d }), await U(e, {
27928
27973
  mappings: d,
27929
27974
  mode: "stamp-template"
27930
27975
  });
27931
27976
  for (let t of c) {
27932
27977
  let r = l.find((e) => e.source.id === t.id);
27933
27978
  if (!r) continue;
27934
- let i = await Y(n, t, s);
27935
- await K(e, {
27979
+ let i = await q(n, t, s);
27980
+ await nr(e, {
27936
27981
  ref: r.target,
27937
27982
  parentRef: i,
27938
27983
  overrides: a?.get(t.id)
@@ -27940,15 +27985,17 @@ async function Yr(e, t) {
27940
27985
  }
27941
27986
  let f = l.find((e) => e.source.id === r.id);
27942
27987
  if (!f) throw Error(`instantiate.asd: cloned Application not found for ${r.id}`);
27943
- let p = await Y(n, r, s);
27944
- await K(e, {
27988
+ let p = await q(n, r, s);
27989
+ await nr(e, {
27945
27990
  ref: f.target,
27946
27991
  parentRef: p,
27947
27992
  overrides: a?.get(r.id)
27948
- }), await _t(e, {
27993
+ }), await St(e, {
27949
27994
  sourceQuery: n,
27950
- targetRoot: f.target,
27951
- fileType: "ASD"
27995
+ target: {
27996
+ anchor: "application",
27997
+ root: f.target
27998
+ }
27952
27999
  });
27953
28000
  let m = c.map((e) => l.find((t) => t.source.id === e.id)?.target).filter((e) => !!e);
27954
28001
  return {
@@ -27959,75 +28006,81 @@ async function Yr(e, t) {
27959
28006
  }
27960
28007
  //#endregion
27961
28008
  //#region src/v2019C1/extensions/lifecycle/update/transaction/function-satellites.ts
27962
- async function Xr(e, t) {
27963
- let { sourceQuery: n, functionRef: r, instanceRef: i, targetParent: a, accepted: o } = t, s = await Hr(n, { primaryRef: r }), c = !1;
27964
- for (let t of s) {
27965
- let { uuid: r, name: i } = await n.any.getAttributes(t), a = await kr(e, {
28009
+ async function ri(e, t) {
28010
+ let { sourceQuery: n, functionRef: r, instanceRef: i, targetParent: a, accepted: o, matchKey: s = "templateUuid", identityMode: c = "stamp-template" } = t, l = await Yr(n, { primaryRef: r }), u = !1;
28011
+ for (let t of l) {
28012
+ let { uuid: r, name: i } = await n.any.getAttributes(t), a = await Lr(e, {
27966
28013
  tagName: t.tagName,
27967
28014
  sourceUuid: r,
27968
- sourceName: i
28015
+ sourceName: i,
28016
+ matchKey: s
27969
28017
  });
27970
28018
  if (!a) {
27971
- c = !0;
28019
+ u = !0;
27972
28020
  continue;
27973
28021
  }
27974
- await sr(e, {
28022
+ await hr(e, {
27975
28023
  sourceQuery: n,
27976
28024
  sourceRootRef: t,
27977
28025
  instanceRootRef: a,
27978
- accepted: o
28026
+ accepted: o,
28027
+ matchKey: s,
28028
+ identityMode: c
27979
28029
  });
27980
28030
  }
27981
- c && (!o || o.sourceIds.has(r.id)) && await H(e, {
27982
- mappings: await Lr(e, {
28031
+ if (u && (!o || o.sourceIds.has(r.id))) {
28032
+ let t = await Z(e, {
27983
28033
  sourceQuery: n,
27984
28034
  functionRef: r,
27985
- structure: await Q(e, a),
28035
+ structure: await X(e, a),
27986
28036
  stripCategoriesUuid: !1
27987
- }),
27988
- mode: "stamp-template"
27989
- });
27990
- let l = await Hr(e, { primaryRef: {
28037
+ });
28038
+ await U(e, {
28039
+ mappings: t,
28040
+ mode: c
28041
+ }), c === "keep" && await W(e, { mappings: t });
28042
+ }
28043
+ let d = await Yr(e, { primaryRef: {
27991
28044
  tagName: "Function",
27992
28045
  id: i.id
27993
28046
  } });
27994
- for (let t of l) {
27995
- let { templateUuid: r } = await e.any.getAttributes(t);
28047
+ for (let t of d) {
28048
+ let r = await e.any.getAttribute(t, { name: s });
27996
28049
  if (!r) continue;
27997
28050
  let [i] = await n.any.findByAttributes({
27998
28051
  tagName: t.tagName,
27999
28052
  attributes: { uuid: r }
28000
28053
  });
28001
- i || o && t.id && !o.instanceIds.has(t.id) || (await I(e, { target: t })).length > 0 || await e.delete(t);
28054
+ i || o && t.id && !o.instanceIds.has(t.id) || (await F(e, { target: t })).length > 0 || await e.delete(t);
28002
28055
  }
28003
28056
  }
28004
28057
  //#endregion
28005
28058
  //#region src/v2019C1/extensions/lifecycle/scenario.ts
28006
- function Zr(e) {
28059
+ function Q(e) {
28007
28060
  return e === "fork" ? "uuid" : "templateUuid";
28008
28061
  }
28009
- function Qr(e) {
28062
+ function ii(e) {
28010
28063
  return e === "fork" ? "keep" : "stamp-template";
28011
28064
  }
28012
28065
  //#endregion
28013
28066
  //#region src/v2019C1/extensions/lifecycle/update/transaction/fsd.ts
28014
- async function $r(e, t) {
28015
- let { sourceQuery: n, functionRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, { uuid: l } = await n.getAttributes(r), u = Zr(a), d = Qr(a), f = a === "instantiate" ? [] : await Dr(e, {
28067
+ async function ai(e, t) {
28068
+ let { sourceQuery: n, functionRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, { uuid: l } = await n.getAttributes(r), u = Q(a), d = ii(a), f = a === "instantiate" ? [] : await Fr(e, {
28016
28069
  targetParent: i,
28017
28070
  tagName: "Function",
28018
28071
  sourceUuid: l,
28019
28072
  matchKey: u
28020
- }), p = o ? U(o) : [];
28073
+ }), p = o ? G(o) : [];
28021
28074
  if (f.length === 0) {
28022
- let t = s ? Sr({
28075
+ let t = s ? Ar({
28023
28076
  groups: p,
28024
28077
  decisions: s
28025
- }) : void 0, a = s ? yr({
28078
+ }) : void 0, a = s ? Dr({
28026
28079
  groups: p,
28027
28080
  decisions: s
28028
28081
  }) : void 0;
28029
28082
  if (t && !t.sourceIds.has(r.id)) return [];
28030
- let { functionRef: o } = await Ur(e, {
28083
+ let { functionRef: o } = await Xr(e, {
28031
28084
  sourceQuery: n,
28032
28085
  functionRef: r,
28033
28086
  targetParent: i,
@@ -28036,13 +28089,13 @@ async function $r(e, t) {
28036
28089
  });
28037
28090
  return [o];
28038
28091
  }
28039
- let m = await Q(e, i);
28092
+ let m = await X(e, i);
28040
28093
  for (let t of f) {
28041
- let { instanceAccepted: a, instanceOverrides: l } = ei({
28042
- instanceGroups: mr(o, t.id),
28094
+ let { instanceAccepted: a, instanceOverrides: l } = oi({
28095
+ instanceGroups: Sr(o, t.id),
28043
28096
  decisions: s
28044
28097
  });
28045
- await sr(e, {
28098
+ await hr(e, {
28046
28099
  sourceQuery: n,
28047
28100
  sourceRootRef: r,
28048
28101
  instanceRootRef: t,
@@ -28051,13 +28104,15 @@ async function $r(e, t) {
28051
28104
  keepNameTypesFrom: c,
28052
28105
  matchKey: u,
28053
28106
  identityMode: d
28054
- }), await Xr(e, {
28107
+ }), await ri(e, {
28055
28108
  sourceQuery: n,
28056
28109
  functionRef: r,
28057
28110
  instanceRef: t,
28058
28111
  targetParent: i,
28059
- accepted: a
28060
- }), await Nr(e, {
28112
+ accepted: a,
28113
+ matchKey: u,
28114
+ identityMode: d
28115
+ }), await Vr(e, {
28061
28116
  sourceQuery: n,
28062
28117
  primaryRef: r,
28063
28118
  instancePrimaryRef: {
@@ -28065,7 +28120,9 @@ async function $r(e, t) {
28065
28120
  id: t.id
28066
28121
  },
28067
28122
  structure: m,
28068
- accepted: a
28123
+ accepted: a,
28124
+ matchKey: u,
28125
+ identityMode: d
28069
28126
  });
28070
28127
  }
28071
28128
  return f.map((e) => ({
@@ -28073,14 +28130,14 @@ async function $r(e, t) {
28073
28130
  id: e.id
28074
28131
  }));
28075
28132
  }
28076
- function ei(e) {
28133
+ function oi(e) {
28077
28134
  let { instanceGroups: t, decisions: n } = e;
28078
28135
  return n ? {
28079
- instanceAccepted: Sr({
28136
+ instanceAccepted: Ar({
28080
28137
  groups: t,
28081
28138
  decisions: n
28082
28139
  }),
28083
- instanceOverrides: yr({
28140
+ instanceOverrides: Dr({
28084
28141
  groups: t,
28085
28142
  decisions: n
28086
28143
  })
@@ -28091,24 +28148,25 @@ function ei(e) {
28091
28148
  }
28092
28149
  //#endregion
28093
28150
  //#region src/v2019C1/extensions/lifecycle/update/transaction/asd.ts
28094
- async function ti(e, t) {
28095
- let { sourceQuery: n, applicationRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, { uuid: l } = await n.getAttributes(r), u = a === "instantiate" ? [] : await X(e, {
28151
+ async function si(e, t) {
28152
+ let { sourceQuery: n, applicationRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, { uuid: l } = await n.getAttributes(r), u = Q(a), d = ii(a), f = a === "instantiate" ? [] : await J(e, {
28096
28153
  tagName: "Application",
28097
- sourceUuid: l
28098
- }), d = o ? U(o) : [];
28099
- if (u.length === 0) {
28100
- let t = s ? Sr({
28101
- groups: d,
28154
+ sourceUuid: l,
28155
+ matchKey: u
28156
+ }), p = o ? G(o) : [];
28157
+ if (f.length === 0) {
28158
+ let t = s ? Ar({
28159
+ groups: p,
28102
28160
  decisions: s
28103
- }) : void 0, a = s ? yr({
28104
- groups: d,
28161
+ }) : void 0, a = s ? Dr({
28162
+ groups: p,
28105
28163
  decisions: s
28106
28164
  }) : void 0;
28107
28165
  if (t && !t.sourceIds.has(r.id)) return {
28108
28166
  applications: [],
28109
28167
  functions: []
28110
28168
  };
28111
- let { applicationRef: o, composedFunctionRefs: l } = await Yr(e, {
28169
+ let { applicationRef: o, composedFunctionRefs: l } = await ni(e, {
28112
28170
  sourceQuery: n,
28113
28171
  applicationRef: r,
28114
28172
  targetParent: i,
@@ -28120,50 +28178,56 @@ async function ti(e, t) {
28120
28178
  functions: l
28121
28179
  };
28122
28180
  }
28123
- let f = await Q(e, i), p = await qr(n, { applicationRef: r }), m = [];
28124
- for (let t of u) {
28125
- let i = mr(o, t.id), a = s ? Sr({
28181
+ let m = await X(e, i), h = await ei(n, { applicationRef: r }), g = [];
28182
+ for (let t of f) {
28183
+ let i = Sr(o, t.id), a = s ? Ar({
28126
28184
  groups: i,
28127
28185
  decisions: s
28128
- }) : void 0, l = s ? yr({
28186
+ }) : void 0, l = s ? Dr({
28129
28187
  groups: i,
28130
28188
  decisions: s
28131
28189
  }) : void 0;
28132
- (!a || a.sourceIds.size > 0 || a.instanceIds.size > 0) && m.push({
28190
+ (!a || a.sourceIds.size > 0 || a.instanceIds.size > 0) && g.push({
28133
28191
  tagName: "Application",
28134
28192
  id: t.id
28135
28193
  });
28136
- let u = await qr(e, { applicationRef: {
28194
+ let f = await ei(e, { applicationRef: {
28137
28195
  tagName: "Application",
28138
28196
  id: t.id
28139
28197
  } });
28140
- await sr(e, {
28198
+ await hr(e, {
28141
28199
  sourceQuery: n,
28142
28200
  sourceRootRef: r,
28143
28201
  instanceRootRef: t,
28144
28202
  accepted: a,
28145
28203
  overrides: l,
28146
- keepNameTypesFrom: c
28147
- }), await Ar(e, {
28204
+ keepNameTypesFrom: c,
28205
+ matchKey: u,
28206
+ identityMode: d
28207
+ }), await Rr(e, {
28148
28208
  sourceQuery: n,
28149
- satelliteRefs: p,
28150
- instanceSatelliteRefs: u,
28151
- structure: f,
28152
- accepted: a
28153
- }), await Nr(e, {
28209
+ satelliteRefs: h,
28210
+ instanceSatelliteRefs: f,
28211
+ structure: m,
28212
+ accepted: a,
28213
+ matchKey: u,
28214
+ identityMode: d
28215
+ }), await Vr(e, {
28154
28216
  sourceQuery: n,
28155
28217
  primaryRef: r,
28156
28218
  instancePrimaryRef: {
28157
28219
  tagName: "Application",
28158
28220
  id: t.id
28159
28221
  },
28160
- structure: f,
28161
- accepted: a
28222
+ structure: m,
28223
+ accepted: a,
28224
+ matchKey: u,
28225
+ identityMode: d
28162
28226
  });
28163
28227
  }
28164
28228
  return {
28165
- applications: m,
28166
- functions: await ni(e, {
28229
+ applications: g,
28230
+ functions: await ci(e, {
28167
28231
  sourceQuery: n,
28168
28232
  applicationRef: r,
28169
28233
  targetParent: i,
@@ -28174,10 +28238,10 @@ async function ti(e, t) {
28174
28238
  })
28175
28239
  };
28176
28240
  }
28177
- async function ni(e, t) {
28178
- let { sourceQuery: n, applicationRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, l = await Tr(n, r);
28241
+ async function ci(e, t) {
28242
+ let { sourceQuery: n, applicationRef: r, targetParent: i, scenario: a, report: o, decisions: s, keepNameTypesFrom: c } = t, l = await Nr(n, r);
28179
28243
  if (l.size === 0) return [];
28180
- let u = await Q(e, i), d = [];
28244
+ let u = await X(e, i), d = [];
28181
28245
  for (let t of l) {
28182
28246
  let [r] = await n.any.findByAttributes({
28183
28247
  tagName: "Function",
@@ -28187,10 +28251,10 @@ async function ni(e, t) {
28187
28251
  let i = {
28188
28252
  tagName: "Function",
28189
28253
  id: r.id
28190
- }, l = await $r(e, {
28254
+ }, l = await ai(e, {
28191
28255
  sourceQuery: n,
28192
28256
  functionRef: i,
28193
- targetParent: await Y(n, i, u),
28257
+ targetParent: await q(n, i, u),
28194
28258
  scenario: a,
28195
28259
  report: o,
28196
28260
  decisions: s,
@@ -28202,29 +28266,29 @@ async function ni(e, t) {
28202
28266
  }
28203
28267
  //#endregion
28204
28268
  //#region src/v2019C1/extensions/lifecycle/update/index.ts
28205
- var ri = /* @__PURE__ */ l({
28206
- asd: () => ti,
28207
- fsd: () => $r
28269
+ var li = /* @__PURE__ */ l({
28270
+ asd: () => si,
28271
+ fsd: () => ai
28208
28272
  });
28209
28273
  //#endregion
28210
28274
  //#region src/v2019C1/extensions/lifecycle/apply/apply.ts
28211
- async function ii(e, t) {
28275
+ async function ui(e, t) {
28212
28276
  let { report: n, decisions: r } = t;
28213
- return r ? (br({
28214
- groups: U(n),
28277
+ return r ? (Or({
28278
+ groups: G(n),
28215
28279
  decisions: r
28216
28280
  }), {
28217
28281
  report: n,
28218
- instances: await oi(e, t, n, r)
28282
+ instances: await fi(e, t, n, r)
28219
28283
  }) : n.needsDecisions ? {
28220
28284
  report: n,
28221
- instances: ai(t.verb)
28285
+ instances: di(t.verb)
28222
28286
  } : {
28223
28287
  report: n,
28224
- instances: await oi(e, t, n, void 0)
28288
+ instances: await fi(e, t, n, void 0)
28225
28289
  };
28226
28290
  }
28227
- function ai(e) {
28291
+ function di(e) {
28228
28292
  return e === "fsd" ? {
28229
28293
  verb: "fsd",
28230
28294
  functions: []
@@ -28234,10 +28298,10 @@ function ai(e) {
28234
28298
  functions: []
28235
28299
  };
28236
28300
  }
28237
- async function oi(e, t, n, r) {
28301
+ async function fi(e, t, n, r) {
28238
28302
  if (t.verb === "fsd") return {
28239
28303
  verb: "fsd",
28240
- functions: await $r(e, {
28304
+ functions: await ai(e, {
28241
28305
  sourceQuery: t.sourceQuery,
28242
28306
  functionRef: t.ref,
28243
28307
  targetParent: t.anchor,
@@ -28247,7 +28311,7 @@ async function oi(e, t, n, r) {
28247
28311
  keepNameTypesFrom: t.keepNameTypesFrom
28248
28312
  })
28249
28313
  };
28250
- let { applications: i, functions: a } = await ti(e, {
28314
+ let { applications: i, functions: a } = await si(e, {
28251
28315
  sourceQuery: t.sourceQuery,
28252
28316
  applicationRef: t.ref,
28253
28317
  targetParent: t.anchor,
@@ -28264,41 +28328,41 @@ async function oi(e, t, n, r) {
28264
28328
  }
28265
28329
  //#endregion
28266
28330
  //#region src/v2019C1/extensions/lifecycle/extract/transaction/ensure-substation-structure.ts
28267
- async function si(e) {
28331
+ async function pi(e) {
28268
28332
  let t = await e.getRoot(), n = await e.ensureChild(t, {
28269
28333
  tagName: "Substation",
28270
- attributes: { name: "TEMPLATE" }
28334
+ attributes: { name: he }
28271
28335
  }), r = await e.ensureChild(n, {
28272
28336
  tagName: "VoltageLevel",
28273
- attributes: { name: "TEMPLATE" }
28337
+ attributes: { name: he }
28274
28338
  });
28275
28339
  return {
28276
28340
  Substation: n,
28277
28341
  VoltageLevel: r,
28278
28342
  Bay: await e.ensureChild(r, {
28279
28343
  tagName: "Bay",
28280
- attributes: { name: "TEMPLATE" }
28344
+ attributes: { name: he }
28281
28345
  })
28282
28346
  };
28283
28347
  }
28284
28348
  //#endregion
28285
28349
  //#region src/v2019C1/extensions/lifecycle/extract/transaction/post-extraction-cleanup.ts
28286
- async function ci(e) {
28287
- await xt.transaction.orphanUuidRefs(e), await xt.transaction.resetLNode(e), await xt.transaction.pruneEmptyContainers(e);
28350
+ async function mi(e) {
28351
+ await R.transaction.orphanUuidRefs(e), await R.transaction.resetLNode(e), await R.transaction.pruneEmptyContainers(e);
28288
28352
  }
28289
28353
  //#endregion
28290
28354
  //#region src/v2019C1/extensions/lifecycle/layers/omit-filters.ts
28291
- var li = [
28355
+ var hi = [
28292
28356
  "FunctionSclRef",
28293
28357
  "ApplicationSclRef",
28294
28358
  "GeneralEquipment",
28295
28359
  "ConductingEquipment"
28296
- ];
28360
+ ], gi = ["FunctionSclRef", "ApplicationSclRef"];
28297
28361
  //#endregion
28298
28362
  //#region src/v2019C1/extensions/lifecycle/extract/transaction/asd.ts
28299
- async function ui(e, t) {
28300
- let { sourceQuery: n, applicationRef: r, tool: i, who: a, nameStructure: o } = t, s = await si(e), c = await e.getAttribute(r, { name: "name" }) || "Unnamed Application";
28301
- await en.transaction.addEntry(e, {
28363
+ async function _i(e, t) {
28364
+ let { sourceQuery: n, applicationRef: r, tool: i, who: a, nameStructure: o } = t, s = await pi(e), c = await e.getAttribute(r, { name: "name" }) || "Unnamed Application";
28365
+ await H.transaction.addEntry(e, {
28302
28366
  filename: `ASD_${c.replace(/\s+/g, "_")}`,
28303
28367
  header: {
28304
28368
  fileType: "ASD",
@@ -28311,17 +28375,17 @@ async function ui(e, t) {
28311
28375
  what: "ASD initialization",
28312
28376
  why: "Application was extracted from a previous file"
28313
28377
  }
28314
- }), await R(e, { mappings: await Wr(e, {
28378
+ }), await I(e, { mappings: await Zr(e, {
28315
28379
  sourceQuery: n,
28316
28380
  applicationRef: r,
28317
28381
  structure: s,
28318
- omit: li
28319
- }) }), await ci(e);
28382
+ omit: hi
28383
+ }) }), await mi(e);
28320
28384
  }
28321
28385
  //#endregion
28322
28386
  //#region src/v2019C1/extensions/lifecycle/extract/transaction/omit.ts
28323
- var di = [
28324
- ...li,
28387
+ var vi = [
28388
+ ...hi,
28325
28389
  "DOS",
28326
28390
  "Labels",
28327
28391
  "LNodeInputs",
@@ -28333,12 +28397,12 @@ var di = [
28333
28397
  ];
28334
28398
  //#endregion
28335
28399
  //#region src/v2019C1/extensions/lifecycle/extract/transaction/fsd.ts
28336
- async function fi(e, t) {
28337
- let { sourceQuery: n, functionRef: r, tool: i, who: a, nameStructure: o } = t, s = await si(e), c = {
28400
+ async function yi(e, t) {
28401
+ let { sourceQuery: n, functionRef: r, tool: i, who: a, nameStructure: o } = t, s = await pi(e), c = {
28338
28402
  tagName: s.Substation.tagName,
28339
28403
  id: s.Substation.id
28340
28404
  }, l = await n.getAttribute(r, { name: "name" }) || "Unnamed Function";
28341
- await en.transaction.addEntry(e, {
28405
+ await H.transaction.addEntry(e, {
28342
28406
  filename: `FSD_${l.replace(/\s+/g, "_")}`,
28343
28407
  header: {
28344
28408
  fileType: "FSD",
@@ -28352,40 +28416,142 @@ async function fi(e, t) {
28352
28416
  why: "Function was extracted from a previous file"
28353
28417
  }
28354
28418
  });
28355
- let u = await Ir(e, {
28419
+ let u = await Wr(e, {
28356
28420
  sourceQuery: n,
28357
28421
  functionRef: r,
28358
28422
  targetParentRef: c,
28359
- omit: di,
28423
+ omit: vi,
28360
28424
  stripRootAttributes: ["templateUuid"]
28361
- }), d = await Lr(e, {
28425
+ }), d = await Z(e, {
28362
28426
  sourceQuery: n,
28363
28427
  functionRef: r,
28364
28428
  structure: s
28365
28429
  });
28366
- await R(e, { mappings: [...u, ...d] }), await ci(e);
28430
+ await I(e, { mappings: [...u, ...d] }), await mi(e);
28431
+ }
28432
+ //#endregion
28433
+ //#region src/v2019C1/extensions/lifecycle/layers/topology/clone-topology-content.ts
28434
+ async function bi(e, t) {
28435
+ let { sourceQuery: n, scopeRef: r, structure: i, omit: a } = t, o = [], s = /* @__PURE__ */ new Set();
28436
+ function c(e) {
28437
+ for (let t of e) o.push(t), t.source.id && s.add(t.source.id);
28438
+ }
28439
+ for (let t of await xi(n, r)) c(await Zr(e, {
28440
+ sourceQuery: n,
28441
+ applicationRef: t,
28442
+ structure: i,
28443
+ omit: a
28444
+ }));
28445
+ for (let t of await Si(n, r)) s.has(t.id) || (c(await Wr(e, {
28446
+ sourceQuery: n,
28447
+ functionRef: t,
28448
+ targetParentRef: await q(n, t, i),
28449
+ omit: a
28450
+ })), c(await Z(e, {
28451
+ sourceQuery: n,
28452
+ functionRef: t,
28453
+ structure: i,
28454
+ stripCategoriesUuid: !1
28455
+ })));
28456
+ for (let t of await Ci(n, r)) {
28457
+ let r = await K(e, {
28458
+ sourceQuery: n,
28459
+ ref: t,
28460
+ targetParent: await q(n, t, i),
28461
+ omit: a
28462
+ });
28463
+ r && c(r.mappings);
28464
+ }
28465
+ return o;
28466
+ }
28467
+ async function xi(e, t) {
28468
+ let n = await e.getRecordsByTagName("Application"), r = [];
28469
+ for (let i of n) (await e.findAncestors(i, { stopAtTagName: "Substation" })).some((e) => e.id === t.id) && r.push({
28470
+ tagName: "Application",
28471
+ id: i.id
28472
+ });
28473
+ return r;
28474
+ }
28475
+ async function Si(e, t) {
28476
+ let n = await e.getRecordsByTagName("Function"), r = [];
28477
+ for (let i of n) (await e.findAncestors(i, { stopAtTagName: "Substation" })).some((e) => e.id === t.id) && r.push({
28478
+ tagName: "Function",
28479
+ id: i.id
28480
+ });
28481
+ return r;
28482
+ }
28483
+ async function Ci(e, t) {
28484
+ let n = [];
28485
+ for (let r of _e) {
28486
+ let i = await e.getRecordsByTagName(r);
28487
+ for (let a of i) {
28488
+ let i = await e.findAncestors(a, { stopAtTagName: "Substation" });
28489
+ i.some((e) => e.id === t.id) && i[0] && ge.includes(i[0].tagName) && n.push({
28490
+ tagName: r,
28491
+ id: a.id
28492
+ });
28493
+ }
28494
+ }
28495
+ return n;
28496
+ }
28497
+ //#endregion
28498
+ //#region src/v2019C1/extensions/lifecycle/extract/transaction/ssd.ts
28499
+ async function wi(e, t) {
28500
+ let { sourceQuery: n, scopeRef: r, tool: i, who: a, nameStructure: o } = t, s = await pi(e), c = await n.getAttribute(r, { name: "name" }) || "Unnamed", l = await Ti(n);
28501
+ await H.transaction.addEntry(e, {
28502
+ filename: `SSD_${c.replace(/\s+/g, "_")}`,
28503
+ header: {
28504
+ fileType: "SSD",
28505
+ version: "keep",
28506
+ tool: i,
28507
+ ...o ? { nameStructure: o } : {}
28508
+ },
28509
+ item: {
28510
+ who: a,
28511
+ what: "SSD initialization",
28512
+ why: "Process scope was extracted from a previous file"
28513
+ }
28514
+ });
28515
+ let u = await bi(e, {
28516
+ sourceQuery: n,
28517
+ scopeRef: r,
28518
+ structure: s,
28519
+ omit: gi
28520
+ }), d = s[r.tagName];
28521
+ return await e.update({
28522
+ tagName: r.tagName,
28523
+ id: d.id
28524
+ }, { attributes: {
28525
+ name: c,
28526
+ templateUuid: void 0
28527
+ } }), await I(e, { mappings: u }), await mi(e), { warnings: l };
28528
+ }
28529
+ async function Ti(e) {
28530
+ let t = await e.getRecordsByTagName("IED"), n = await e.getRecordsByTagName("Communication");
28531
+ return t.length === 0 && n.length === 0 ? [] : [`Skipped ${t.length} IED and ${n.length} Communication section(s): not yet carried into an SSD (available once the IED/ISD layer exists).`];
28367
28532
  }
28368
28533
  //#endregion
28369
28534
  //#region src/v2019C1/extensions/lifecycle/extract/index.ts
28370
- var pi = /* @__PURE__ */ l({
28371
- asd: () => ui,
28372
- ensureSubstationTemplateStructure: () => si,
28373
- fsd: () => fi
28374
- }), mi = /* @__PURE__ */ l({
28375
- asd: () => Yr,
28376
- fsd: () => Ur,
28377
- resolveTargetStructure: () => Q
28535
+ var Ei = /* @__PURE__ */ l({
28536
+ asd: () => _i,
28537
+ ensureSubstationTemplateStructure: () => pi,
28538
+ fsd: () => yi,
28539
+ ssd: () => wi
28540
+ }), Di = /* @__PURE__ */ l({
28541
+ asd: () => ni,
28542
+ fsd: () => Xr,
28543
+ resolveTargetStructure: () => X
28378
28544
  });
28379
28545
  //#endregion
28380
28546
  //#region src/v2019C1/extensions/lifecycle/report/mark-placement-conflicts.ts
28381
- async function hi(e, t, n) {
28382
- if (t.scenario === "instantiate") for (let r of U(n)) {
28547
+ async function Oi(e, t, n) {
28548
+ if (t.scenario === "instantiate") for (let r of G(n)) {
28383
28549
  if (r.change !== "added") continue;
28384
28550
  let i = r.primary.sourceRef;
28385
28551
  if (!i) continue;
28386
28552
  let a = await t.sourceQuery.getAttributes(i), o = a.uuid;
28387
28553
  if (!o) continue;
28388
- let s = r.primary.tagName, [c] = await X(e, {
28554
+ let s = r.primary.tagName, [c] = await J(e, {
28389
28555
  tagName: s,
28390
28556
  sourceUuid: o
28391
28557
  });
@@ -28398,7 +28564,7 @@ async function hi(e, t, n) {
28398
28564
  let n = {
28399
28565
  tagName: t.tagName,
28400
28566
  id: t.id
28401
- }, r = await G(e, {
28567
+ }, r = await Yn(e, {
28402
28568
  parentRef: n,
28403
28569
  childTag: s,
28404
28570
  candidate: a
@@ -28409,9 +28575,9 @@ async function hi(e, t, n) {
28409
28575
  }
28410
28576
  }
28411
28577
  if (!d || !u) continue;
28412
- let f = d.fields.find((e) => Bn(W(s, e)));
28578
+ let f = d.fields.find((e) => Wn(Un(s, e)));
28413
28579
  if (f) {
28414
- let t = await Xn(e, {
28580
+ let t = await tr(e, {
28415
28581
  parentRef: u,
28416
28582
  childTag: s,
28417
28583
  candidate: a,
@@ -28426,23 +28592,23 @@ async function hi(e, t, n) {
28426
28592
  }
28427
28593
  //#endregion
28428
28594
  //#region src/v2019C1/extensions/lifecycle/report/query/satellite-companions.ts
28429
- async function gi(e, t) {
28595
+ async function ki(e, t) {
28430
28596
  let { sourceQuery: n, primaryRef: r, satelliteRefs: i, instanceSatelliteRefs: a, report: o, instanceScopeId: s } = t, c = o.groups.find((e) => e.primary.sourceRef?.id === r.id);
28431
28597
  for (let r of i) {
28432
- let { uuid: i, name: a } = await n.any.getAttributes(r), l = await _n({
28598
+ let { uuid: i, name: a } = await n.any.getAttributes(r), l = await bn({
28433
28599
  sourceQuery: n,
28434
28600
  targetQuery: e,
28435
28601
  sourceRootRef: r,
28436
- instanceRootRef: await kr(e, {
28602
+ instanceRootRef: await Lr(e, {
28437
28603
  tagName: r.tagName,
28438
28604
  sourceUuid: i,
28439
28605
  sourceName: a
28440
28606
  }),
28441
28607
  keepLeftoverRefs: !0,
28442
- leftoverRefPolicy: await _i(e, n, r),
28608
+ leftoverRefPolicy: await Ai(e, n, r),
28443
28609
  refsAlwaysAdded: t.refsAlwaysAdded ?? !1
28444
28610
  });
28445
- l.summary.added + l.summary.removed + l.summary.modified > 0 && (c ? c.companions.push(l.root) : o.groups.push(...ln(l.root, s)));
28611
+ l.summary.added + l.summary.removed + l.summary.modified > 0 && (c ? c.companions.push(l.root) : o.groups.push(...fn(l.root, s)));
28446
28612
  }
28447
28613
  if (c) for (let t of a ?? []) {
28448
28614
  let { templateUuid: r } = await e.any.getAttributes(t);
@@ -28460,31 +28626,31 @@ async function gi(e, t) {
28460
28626
  }
28461
28627
  return o;
28462
28628
  }
28463
- async function _i(e, t, n) {
28629
+ async function Ai(e, t, n) {
28464
28630
  let r = await t.any.getTree(n), i = /* @__PURE__ */ new Set();
28465
- return r && await vi(t, r, i), async (n) => {
28631
+ return r && await ji(t, r, i), async (n) => {
28466
28632
  let r = D[n.tagName];
28467
28633
  if (!r) return "keep";
28468
28634
  for (let a of r) {
28469
28635
  let r = await e.any.getAttribute(n, { name: a.attribute.uuid });
28470
28636
  if (!r) continue;
28471
- let o = await yi(e, r, a.target);
28637
+ let o = await Mi(e, r, a.target);
28472
28638
  if (!o) continue;
28473
28639
  let s = await e.any.getAttribute(o, { name: "templateUuid" });
28474
- if (s && await yi(t, s, a.target) && !i.has(s)) return "removed";
28640
+ if (s && await Mi(t, s, a.target) && !i.has(s)) return "removed";
28475
28641
  }
28476
28642
  return "keep";
28477
28643
  };
28478
28644
  }
28479
- async function vi(e, t, n) {
28645
+ async function ji(e, t, n) {
28480
28646
  let r = D[t.tagName];
28481
28647
  if (r) for (let i of r) {
28482
28648
  let r = await e.any.getAttribute(t, { name: i.attribute.uuid });
28483
28649
  r && n.add(r);
28484
28650
  }
28485
- for (let r of t.tree) await vi(e, r, n);
28651
+ for (let r of t.tree) await ji(e, r, n);
28486
28652
  }
28487
- async function yi(e, t, n) {
28653
+ async function Mi(e, t, n) {
28488
28654
  for (let r of n) {
28489
28655
  let [n] = await e.any.findByAttributes({
28490
28656
  tagName: r,
@@ -28495,13 +28661,13 @@ async function yi(e, t, n) {
28495
28661
  }
28496
28662
  //#endregion
28497
28663
  //#region src/v2019C1/extensions/lifecycle/report/query/cross-cutting-satellites.ts
28498
- async function bi(e, t) {
28664
+ async function Ni(e, t) {
28499
28665
  let { sourceQuery: n, primaryRef: r, instancePrimaryRef: i, report: a } = t;
28500
- return gi(e, {
28666
+ return ki(e, {
28501
28667
  sourceQuery: n,
28502
28668
  primaryRef: r,
28503
- satelliteRefs: await Z(n, { primaryRef: r }),
28504
- instanceSatelliteRefs: i ? await Z(e, { primaryRef: i }) : [],
28669
+ satelliteRefs: await Y(n, { primaryRef: r }),
28670
+ instanceSatelliteRefs: i ? await Y(e, { primaryRef: i }) : [],
28505
28671
  report: a,
28506
28672
  instanceScopeId: i?.id,
28507
28673
  refsAlwaysAdded: t.refsAlwaysAdded ?? !1
@@ -28509,13 +28675,13 @@ async function bi(e, t) {
28509
28675
  }
28510
28676
  //#endregion
28511
28677
  //#region src/v2019C1/extensions/lifecycle/report/query/report-function-satellites.ts
28512
- async function xi(e, t) {
28678
+ async function Pi(e, t) {
28513
28679
  let { sourceQuery: n, functionRef: r, instance: i, report: a } = t;
28514
- return gi(e, {
28680
+ return ki(e, {
28515
28681
  sourceQuery: n,
28516
28682
  primaryRef: r,
28517
- satelliteRefs: await Hr(n, { primaryRef: r }),
28518
- instanceSatelliteRefs: i ? await Hr(e, { primaryRef: {
28683
+ satelliteRefs: await Yr(n, { primaryRef: r }),
28684
+ instanceSatelliteRefs: i ? await Yr(e, { primaryRef: {
28519
28685
  tagName: "Function",
28520
28686
  id: i.id
28521
28687
  } }) : [],
@@ -28526,12 +28692,12 @@ async function xi(e, t) {
28526
28692
  }
28527
28693
  //#endregion
28528
28694
  //#region src/v2019C1/extensions/lifecycle/report/query/report-function.ts
28529
- async function Si(e, t) {
28530
- let { sourceQuery: n, functionRef: r, instance: i } = t, a = t.refsAlwaysAdded ?? !1, o = await xi(e, {
28695
+ async function Fi(e, t) {
28696
+ let { sourceQuery: n, functionRef: r, instance: i } = t, a = t.refsAlwaysAdded ?? !1, o = await Pi(e, {
28531
28697
  sourceQuery: n,
28532
28698
  functionRef: r,
28533
28699
  instance: i,
28534
- report: await _n({
28700
+ report: await bn({
28535
28701
  sourceQuery: n,
28536
28702
  targetQuery: e,
28537
28703
  sourceRootRef: r,
@@ -28540,7 +28706,7 @@ async function Si(e, t) {
28540
28706
  }),
28541
28707
  refsAlwaysAdded: a
28542
28708
  });
28543
- return bi(e, {
28709
+ return Ni(e, {
28544
28710
  sourceQuery: n,
28545
28711
  primaryRef: r,
28546
28712
  instancePrimaryRef: i ? {
@@ -28553,7 +28719,7 @@ async function Si(e, t) {
28553
28719
  }
28554
28720
  //#endregion
28555
28721
  //#region src/v2019C1/extensions/presentation/constants/title.ts
28556
- var Ci = {
28722
+ var Ii = {
28557
28723
  LNode: {
28558
28724
  compact: [
28559
28725
  "prefix",
@@ -28650,29 +28816,29 @@ var Ci = {
28650
28816
  };
28651
28817
  //#endregion
28652
28818
  //#region src/v2019C1/extensions/presentation/query/extract-element-title.ts
28653
- async function wi(e, t, n = {}) {
28819
+ async function Li(e, t, n = {}) {
28654
28820
  let r = await e.getRecord(t);
28655
28821
  if (!r) return n.withLabels ? {
28656
28822
  title: "",
28657
28823
  labels: {}
28658
28824
  } : "";
28659
- let i = r.tagName, a = n.mode ?? "compact", o = await e.any.getAttributes(r), s = Ci[i], c = Ti({
28825
+ let i = r.tagName, a = n.mode ?? "compact", o = await e.any.getAttributes(r), s = Ii[i], c = Ri({
28660
28826
  tag: i,
28661
28827
  spec: s,
28662
28828
  mode: a,
28663
28829
  attributes: o,
28664
- specAttributes: s?.attributesFrom ? await Ei(e, r, s.attributesFrom) : o,
28830
+ specAttributes: s?.attributesFrom ? await zi(e, r, s.attributesFrom) : o,
28665
28831
  value: r.value
28666
28832
  });
28667
28833
  return n.withLabels ? {
28668
28834
  title: c,
28669
- labels: await Di(e, r)
28835
+ labels: await Bi(e, r)
28670
28836
  } : c;
28671
28837
  }
28672
- function Ti(e) {
28838
+ function Ri(e) {
28673
28839
  let { tag: t, spec: n, mode: r, attributes: i, specAttributes: a, value: o } = e;
28674
28840
  if (n) {
28675
- let e = Ai(n, a, r);
28841
+ let e = Ui(n, a, r);
28676
28842
  if (e) return e;
28677
28843
  }
28678
28844
  let s = (o ?? "").trim();
@@ -28680,14 +28846,14 @@ function Ti(e) {
28680
28846
  let c = _[t]?.attributes?.identityFields, l = c?.find((e) => e === "name" || e === "id") ?? c?.[0];
28681
28847
  return l && i[l] ? i[l] : i.name || t;
28682
28848
  }
28683
- async function Ei(e, t, n) {
28849
+ async function zi(e, t, n) {
28684
28850
  let [r] = await e.any.getChildren(t, n);
28685
28851
  return r ? e.any.getAttributes(r) : {};
28686
28852
  }
28687
- async function Di(e, t) {
28688
- return ki(await Oi(e, t));
28853
+ async function Bi(e, t) {
28854
+ return Hi(await Vi(e, t));
28689
28855
  }
28690
- async function Oi(e, t) {
28856
+ async function Vi(e, t) {
28691
28857
  let n = [], r = await e.any.getChildren(t, "Labels");
28692
28858
  for (let t of r) {
28693
28859
  let r = await e.any.getChildren(t, "Label");
@@ -28702,18 +28868,18 @@ async function Oi(e, t) {
28702
28868
  }
28703
28869
  return n;
28704
28870
  }
28705
- function ki(e) {
28871
+ function Hi(e) {
28706
28872
  let t = {};
28707
28873
  for (let { lang: n, id: r, text: i } of e) (t[n] ??= {})[r] = i;
28708
28874
  return t;
28709
28875
  }
28710
- function Ai(e, t, n) {
28876
+ function Ui(e, t, n) {
28711
28877
  let r = n === "full" && e.full !== void 0, i = r ? e.full : e.compact, a = r ? e.fullSeparator ?? e.separator ?? "" : e.separator ?? "";
28712
- if (typeof i == "string") return Mi(i, t);
28713
- if (ji(i)) {
28878
+ if (typeof i == "string") return Gi(i, t);
28879
+ if (Wi(i)) {
28714
28880
  for (let e of i) {
28715
28881
  if (e.whenPresent && !t[e.whenPresent]) continue;
28716
- let n = Mi(e.template, t);
28882
+ let n = Gi(e.template, t);
28717
28883
  if (n) return n;
28718
28884
  }
28719
28885
  return "";
@@ -28721,22 +28887,22 @@ function Ai(e, t, n) {
28721
28887
  let o = i.map((e) => t[e]).filter(Boolean);
28722
28888
  return o.length > 0 ? o.join(a) : "";
28723
28889
  }
28724
- function ji(e) {
28890
+ function Wi(e) {
28725
28891
  return typeof e[0] == "object";
28726
28892
  }
28727
- function Mi(e, t) {
28893
+ function Gi(e, t) {
28728
28894
  return e.replace(/\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g, (e, n) => t[n] ?? "").replace(/\[\]/g, "").replace(/\(\)/g, "").split("/").map((e) => e.split(".").filter((e) => e !== "").join(".")).filter((e) => e !== "").join("/");
28729
28895
  }
28730
28896
  //#endregion
28731
28897
  //#region src/v2019C1/extensions/presentation/query/index.ts
28732
- var Ni = /* @__PURE__ */ l({ extractElementTitle: () => wi });
28898
+ var Ki = /* @__PURE__ */ l({ extractElementTitle: () => Li });
28733
28899
  //#endregion
28734
28900
  //#region src/v2019C1/extensions/lifecycle/report/query/report-instance.ts
28735
28901
  async function $(e, t) {
28736
28902
  let { instanceDiff: n, instance: r, sourceQuery: i, sourceRef: o } = t, s = n.groups.length === 0;
28737
28903
  if (!r) return {
28738
28904
  rootRef: void 0,
28739
- title: await wi(i, o),
28905
+ title: await Li(i, o),
28740
28906
  linked: !1,
28741
28907
  upToDate: s,
28742
28908
  tree: n.root,
@@ -28745,7 +28911,7 @@ async function $(e, t) {
28745
28911
  let { templateUuid: c, originUuid: l } = await e.any.getAttributes(r), u = !!(c || l);
28746
28912
  return {
28747
28913
  rootRef: a(r),
28748
- title: await wi(e, r),
28914
+ title: await Li(e, r),
28749
28915
  linked: u,
28750
28916
  upToDate: s,
28751
28917
  tree: n.root,
@@ -28754,64 +28920,68 @@ async function $(e, t) {
28754
28920
  }
28755
28921
  //#endregion
28756
28922
  //#region src/v2019C1/extensions/lifecycle/report/query/report-asd.ts
28757
- async function Pi(e, t) {
28758
- let { sourceQuery: n, applicationRef: r, scenario: i } = t, { uuid: a } = await n.getAttributes(r), o = i === "instantiate" ? [] : await X(e, {
28923
+ async function qi(e, t) {
28924
+ let { sourceQuery: n, applicationRef: r, scenario: i } = t, { uuid: a } = await n.getAttributes(r), o = Q(i), s = i === "instantiate" ? [] : await J(e, {
28759
28925
  tagName: "Application",
28760
- sourceUuid: a
28761
- }), s = [];
28762
- if (o.length === 0) {
28763
- let t = await Fi(e, {
28926
+ sourceUuid: a,
28927
+ matchKey: o
28928
+ }), c = [];
28929
+ if (s.length === 0) {
28930
+ let t = await Ji(e, {
28764
28931
  sourceQuery: n,
28765
28932
  applicationRef: r,
28766
28933
  instance: void 0,
28767
- refsAlwaysAdded: i === "instantiate"
28934
+ refsAlwaysAdded: i === "instantiate",
28935
+ matchKey: o
28768
28936
  });
28769
- s.push(await $(e, {
28937
+ c.push(await $(e, {
28770
28938
  instanceDiff: t,
28771
28939
  instance: void 0,
28772
28940
  sourceQuery: n,
28773
28941
  sourceRef: r
28774
28942
  }));
28775
- } else for (let t of o) {
28776
- let a = await Fi(e, {
28943
+ } else for (let t of s) {
28944
+ let a = await Ji(e, {
28777
28945
  sourceQuery: n,
28778
28946
  applicationRef: r,
28779
28947
  instance: t,
28780
- refsAlwaysAdded: i === "instantiate"
28948
+ refsAlwaysAdded: i === "instantiate",
28949
+ matchKey: o
28781
28950
  });
28782
- s.push(await $(e, {
28951
+ c.push(await $(e, {
28783
28952
  instanceDiff: a,
28784
28953
  instance: t,
28785
28954
  sourceQuery: n,
28786
28955
  sourceRef: r
28787
28956
  }));
28788
28957
  }
28789
- let c = await Ii(e, {
28958
+ let l = await Yi(e, {
28790
28959
  sourceQuery: n,
28791
28960
  applicationRef: r,
28792
28961
  scenario: i
28793
28962
  });
28794
- return Pn([...s, ...c]);
28963
+ return Ln([...c, ...l]);
28795
28964
  }
28796
- async function Fi(e, t) {
28797
- let { sourceQuery: n, applicationRef: r, instance: i } = t, a = t.refsAlwaysAdded ?? !1, o = await _n({
28965
+ async function Ji(e, t) {
28966
+ let { sourceQuery: n, applicationRef: r, instance: i } = t, a = t.refsAlwaysAdded ?? !1, o = await bn({
28798
28967
  sourceQuery: n,
28799
28968
  targetQuery: e,
28800
28969
  sourceRootRef: r,
28801
- instanceRootRef: i
28970
+ instanceRootRef: i,
28971
+ matchKey: t.matchKey
28802
28972
  });
28803
- return await gi(e, {
28973
+ return await ki(e, {
28804
28974
  sourceQuery: n,
28805
28975
  primaryRef: r,
28806
- satelliteRefs: await qr(n, { applicationRef: r }),
28807
- instanceSatelliteRefs: i ? await qr(e, { applicationRef: {
28976
+ satelliteRefs: await ei(n, { applicationRef: r }),
28977
+ instanceSatelliteRefs: i ? await ei(e, { applicationRef: {
28808
28978
  tagName: "Application",
28809
28979
  id: i.id
28810
28980
  } }) : [],
28811
28981
  report: o,
28812
28982
  instanceScopeId: i?.id,
28813
28983
  refsAlwaysAdded: a
28814
- }), await bi(e, {
28984
+ }), await Ni(e, {
28815
28985
  sourceQuery: n,
28816
28986
  primaryRef: r,
28817
28987
  instancePrimaryRef: i ? {
@@ -28822,64 +28992,67 @@ async function Fi(e, t) {
28822
28992
  refsAlwaysAdded: a
28823
28993
  }), o;
28824
28994
  }
28825
- async function Ii(e, t) {
28826
- let { sourceQuery: n, applicationRef: r, scenario: i } = t, a = await Tr(n, r), o = [];
28827
- for (let t of a) {
28995
+ async function Yi(e, t) {
28996
+ let { sourceQuery: n, applicationRef: r, scenario: i } = t, a = Q(i), o = await Nr(n, r), s = [];
28997
+ for (let t of o) {
28828
28998
  let [r] = await n.any.findByAttributes({
28829
28999
  tagName: "Function",
28830
29000
  attributes: { uuid: t }
28831
29001
  });
28832
29002
  if (!r) continue;
28833
- let a = {
29003
+ let o = {
28834
29004
  tagName: "Function",
28835
29005
  id: r.id
28836
- }, s = i === "instantiate" ? [] : await X(e, {
29006
+ }, c = i === "instantiate" ? [] : await J(e, {
28837
29007
  tagName: "Function",
28838
- sourceUuid: t
29008
+ sourceUuid: t,
29009
+ matchKey: a
28839
29010
  });
28840
- if (s.length === 0) {
28841
- let t = await Si(e, {
29011
+ if (c.length === 0) {
29012
+ let t = await Fi(e, {
28842
29013
  sourceQuery: n,
28843
- functionRef: a,
29014
+ functionRef: o,
28844
29015
  instance: void 0,
28845
- refsAlwaysAdded: i === "instantiate"
29016
+ refsAlwaysAdded: i === "instantiate",
29017
+ matchKey: a
28846
29018
  });
28847
- o.push(await $(e, {
29019
+ s.push(await $(e, {
28848
29020
  instanceDiff: t,
28849
29021
  instance: void 0,
28850
29022
  sourceQuery: n,
28851
- sourceRef: a
29023
+ sourceRef: o
28852
29024
  }));
28853
29025
  continue;
28854
29026
  }
28855
- for (let t of s) {
28856
- let r = await Si(e, {
29027
+ for (let t of c) {
29028
+ let r = await Fi(e, {
28857
29029
  sourceQuery: n,
28858
- functionRef: a,
29030
+ functionRef: o,
28859
29031
  instance: t,
28860
- refsAlwaysAdded: i === "instantiate"
29032
+ refsAlwaysAdded: i === "instantiate",
29033
+ matchKey: a
28861
29034
  });
28862
- o.push(await $(e, {
29035
+ s.push(await $(e, {
28863
29036
  instanceDiff: r,
28864
29037
  instance: t,
28865
29038
  sourceQuery: n,
28866
- sourceRef: a
29039
+ sourceRef: o
28867
29040
  }));
28868
29041
  }
28869
29042
  }
28870
- return o;
29043
+ return s;
28871
29044
  }
28872
29045
  //#endregion
28873
29046
  //#region src/v2019C1/extensions/lifecycle/report/query/report-fsd.ts
28874
- async function Li(e, t) {
28875
- let { sourceQuery: n, functionRef: r, targetParent: i, scenario: a } = t, { uuid: o } = await n.getAttributes(r), s = Zr(a), c = a === "instantiate" ? [] : await Dr(e, {
29047
+ async function Xi(e, t) {
29048
+ let { sourceQuery: n, functionRef: r, targetParent: i, scenario: a } = t, { uuid: o } = await n.getAttributes(r), s = Q(a), c = a === "instantiate" ? [] : await Fr(e, {
28876
29049
  targetParent: i,
28877
29050
  tagName: "Function",
28878
29051
  sourceUuid: o,
28879
29052
  matchKey: s
28880
29053
  });
28881
- if (c.length === 0) return Pn([await $(e, {
28882
- instanceDiff: await Si(e, {
29054
+ if (c.length === 0) return Ln([await $(e, {
29055
+ instanceDiff: await Fi(e, {
28883
29056
  sourceQuery: n,
28884
29057
  functionRef: r,
28885
29058
  instance: void 0,
@@ -28892,7 +29065,7 @@ async function Li(e, t) {
28892
29065
  })]);
28893
29066
  let l = [];
28894
29067
  for (let t of c) {
28895
- let i = await Si(e, {
29068
+ let i = await Fi(e, {
28896
29069
  sourceQuery: n,
28897
29070
  functionRef: r,
28898
29071
  instance: t,
@@ -28906,27 +29079,27 @@ async function Li(e, t) {
28906
29079
  sourceRef: r
28907
29080
  }));
28908
29081
  }
28909
- return Pn(l);
29082
+ return Ln(l);
28910
29083
  }
28911
29084
  //#endregion
28912
29085
  //#region src/v2019C1/extensions/lifecycle/report/report.ts
28913
- async function Ri(e, t) {
28914
- let n = t.verb === "fsd" ? await Li(e, {
29086
+ async function Zi(e, t) {
29087
+ let n = t.verb === "fsd" ? await Xi(e, {
28915
29088
  sourceQuery: t.sourceQuery,
28916
29089
  functionRef: t.ref,
28917
29090
  targetParent: t.anchor,
28918
29091
  scenario: t.scenario
28919
- }) : await Pi(e, {
29092
+ }) : await qi(e, {
28920
29093
  sourceQuery: t.sourceQuery,
28921
29094
  applicationRef: t.ref,
28922
29095
  scenario: t.scenario
28923
29096
  });
28924
- for (let e of U(n)) e.editableAttributes = Vn(e.primary.tagName);
28925
- return await hi(e, t, n), n;
29097
+ for (let e of G(n)) e.editableAttributes = Gn(e.primary.tagName);
29098
+ return await Oi(e, t, n), n;
28926
29099
  }
28927
29100
  //#endregion
28928
29101
  //#region src/v2019C1/extensions/lifecycle/report/presentation-scope.ts
28929
- function zi(e) {
29102
+ function Qi(e) {
28930
29103
  switch (e.verb) {
28931
29104
  case "fsd":
28932
29105
  case "asd": return {
@@ -28938,9 +29111,9 @@ function zi(e) {
28938
29111
  }
28939
29112
  //#endregion
28940
29113
  //#region src/v2019C1/extensions/lifecycle/validate/template-uuid-check.ts
28941
- async function Bi(e) {
29114
+ async function $i(e) {
28942
29115
  let t = await e.any.getSnapshot({ as: "tree" }), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
28943
- await Vi(e, t, n, r);
29116
+ await ea(e, t, n, r);
28944
29117
  let i = [], a = /* @__PURE__ */ new Set();
28945
29118
  for (let [e, { tagNames: t, refs: r }] of n) {
28946
29119
  if (t.size < 2) continue;
@@ -28988,7 +29161,7 @@ async function Bi(e) {
28988
29161
  }
28989
29162
  return i;
28990
29163
  }
28991
- async function Vi(e, t, n, r) {
29164
+ async function ea(e, t, n, r) {
28992
29165
  let i = {
28993
29166
  tagName: t.tagName,
28994
29167
  id: t.id
@@ -29008,35 +29181,35 @@ async function Vi(e, t, n, r) {
29008
29181
  ref: i
29009
29182
  }), r.set(o, e);
29010
29183
  }
29011
- for (let i of t.tree) await Vi(e, i, n, r);
29184
+ for (let i of t.tree) await ea(e, i, n, r);
29012
29185
  }
29013
29186
  //#endregion
29014
29187
  //#region src/v2019C1/extensions/index.ts
29015
- var Hi = {
29016
- cleanUp: xt,
29017
- dataModel: Yt,
29018
- history: en,
29019
- identity: cn,
29188
+ var ta = {
29189
+ cleanUp: R,
29190
+ dataModel: en,
29191
+ history: H,
29192
+ identity: dn,
29020
29193
  lifecycle: {
29021
29194
  query: {
29022
- report: Ri,
29023
- checkTemplateUuids: Bi
29195
+ report: Zi,
29196
+ checkTemplateUuids: $i
29024
29197
  },
29025
29198
  transaction: {
29026
- extract: pi,
29027
- instantiate: mi,
29028
- transplant: { deep: J },
29029
- update: ri,
29030
- apply: ii
29199
+ extract: Ei,
29200
+ instantiate: Di,
29201
+ transplant: { deep: ar },
29202
+ update: li,
29203
+ apply: ui
29031
29204
  }
29032
29205
  },
29033
- reference: z,
29034
- signature: { query: Ft },
29035
- presentation: { query: Ni }
29206
+ reference: L,
29207
+ signature: { query: Bt },
29208
+ presentation: { query: Ki }
29036
29209
  };
29037
29210
  //#endregion
29038
29211
  //#region src/v2019C1/hooks/after-created/private-wrapper.ts
29039
- async function Ui(e) {
29212
+ async function na(e) {
29040
29213
  let { childRecord: t, parentRecord: n, query: r } = e;
29041
29214
  if (t.namespace.prefix === x.namespaces.default.prefix) return [];
29042
29215
  let i = n.tagName === "Private", a = n.namespace.prefix === x.namespaces.default.prefix;
@@ -29045,26 +29218,26 @@ async function Ui(e) {
29045
29218
  ...n,
29046
29219
  children: n.children.filter((e) => e.id !== t.id)
29047
29220
  };
29048
- return i ? Wi({
29221
+ return i ? ra({
29049
29222
  parentRecord: n,
29050
29223
  childRecord: t,
29051
29224
  query: r
29052
- }) : o ? Gi({
29225
+ }) : o ? ia({
29053
29226
  existingPrivateRef: o,
29054
29227
  parentRecord: n,
29055
29228
  updatedParentRecord: s,
29056
29229
  childRecord: t,
29057
29230
  query: r
29058
- }) : (await r.findAncestors(n)).some((e) => e.tagName === "Private" && e.attributes.some((e) => e.name === "type" && e.value === t.namespace.prefix)) ? [] : Ki({
29231
+ }) : (await r.findAncestors(n)).some((e) => e.tagName === "Private" && e.attributes.some((e) => e.name === "type" && e.value === t.namespace.prefix)) ? [] : aa({
29059
29232
  parentRecord: n,
29060
29233
  updatedParentRecord: s,
29061
29234
  childRecord: t
29062
29235
  });
29063
29236
  }
29064
- async function Wi(e) {
29237
+ async function ra(e) {
29065
29238
  let { parentRecord: t, childRecord: n, query: r } = e, a = t;
29066
29239
  if (n.parent?.id === a.id && n.parent?.tagName === "Private") return [];
29067
- let o = await qi({
29240
+ let o = await oa({
29068
29241
  privateId: a.id,
29069
29242
  query: r
29070
29243
  });
@@ -29072,7 +29245,7 @@ async function Wi(e) {
29072
29245
  detail: "Latest private record not found",
29073
29246
  key: "ELEMENT_NOT_FOUND"
29074
29247
  });
29075
- let { childRecord: c, privateRecord: l } = Ji({
29248
+ let { childRecord: c, privateRecord: l } = sa({
29076
29249
  privateRecord: o,
29077
29250
  childRecord: n
29078
29251
  });
@@ -29086,8 +29259,8 @@ async function Wi(e) {
29086
29259
  newRecord: i(l)
29087
29260
  }];
29088
29261
  }
29089
- async function Gi(e) {
29090
- let { existingPrivateRef: t, parentRecord: n, updatedParentRecord: r, childRecord: a, query: o } = e, c = await qi({
29262
+ async function ia(e) {
29263
+ let { existingPrivateRef: t, parentRecord: n, updatedParentRecord: r, childRecord: a, query: o } = e, c = await oa({
29091
29264
  privateId: t.id,
29092
29265
  query: o
29093
29266
  });
@@ -29095,7 +29268,7 @@ async function Gi(e) {
29095
29268
  detail: "Latest private record not found",
29096
29269
  key: "ELEMENT_NOT_FOUND"
29097
29270
  }), !c.attributes.some((e) => e.name === "type" && e.value === a.namespace.prefix)) return [];
29098
- let { childRecord: l, privateRecord: u } = Ji({
29271
+ let { childRecord: l, privateRecord: u } = sa({
29099
29272
  privateRecord: c,
29100
29273
  childRecord: a
29101
29274
  });
@@ -29117,7 +29290,7 @@ async function Gi(e) {
29117
29290
  }
29118
29291
  ];
29119
29292
  }
29120
- function Ki(e) {
29293
+ function aa(e) {
29121
29294
  let { parentRecord: t, updatedParentRecord: n, childRecord: r } = e, a = {
29122
29295
  id: crypto.randomUUID(),
29123
29296
  tagName: "Private",
@@ -29166,14 +29339,14 @@ function Ki(e) {
29166
29339
  }
29167
29340
  ];
29168
29341
  }
29169
- async function qi(e) {
29342
+ async function oa(e) {
29170
29343
  let { privateId: t, query: n } = e;
29171
29344
  return await n.getRecord({
29172
29345
  id: t,
29173
29346
  tagName: "Private"
29174
29347
  });
29175
29348
  }
29176
- function Ji(e) {
29349
+ function sa(e) {
29177
29350
  let { privateRecord: t, childRecord: n } = e;
29178
29351
  return {
29179
29352
  childRecord: {
@@ -29194,7 +29367,7 @@ function Ji(e) {
29194
29367
  }
29195
29368
  //#endregion
29196
29369
  //#region src/v2019C1/hooks/shared/ref-entry-ops.ts
29197
- async function Yi(e) {
29370
+ async function ca(e) {
29198
29371
  let { uuid: t, entry: r, target: a, query: o } = e;
29199
29372
  if (!n(r.refTagName, x)) return [];
29200
29373
  let s = await o.getRecordsByTagName(r.refTagName), c = [];
@@ -29203,7 +29376,7 @@ async function Yi(e) {
29203
29376
  let n = {
29204
29377
  tagName: e.tagName,
29205
29378
  id: e.id
29206
- }, s = await z.query.buildReferencePath(o, {
29379
+ }, s = await L.query.buildReferencePath(o, {
29207
29380
  reference: n,
29208
29381
  target: a
29209
29382
  });
@@ -29223,17 +29396,17 @@ async function Yi(e) {
29223
29396
  }
29224
29397
  return c;
29225
29398
  }
29226
- function Xi(e) {
29399
+ function la(e) {
29227
29400
  let t = [];
29228
- for (let n of je) {
29229
- let r = ke[n]?.get(e);
29401
+ for (let n of Pe) {
29402
+ let r = Me[n]?.get(e);
29230
29403
  r && t.push(...r);
29231
29404
  }
29232
29405
  return t;
29233
29406
  }
29234
29407
  //#endregion
29235
29408
  //#region src/v2019C1/hooks/shared/record-ops.ts
29236
- function Zi(e, t) {
29409
+ function ua(e, t) {
29237
29410
  return {
29238
29411
  status: "updated",
29239
29412
  oldRecord: e,
@@ -29243,7 +29416,7 @@ function Zi(e, t) {
29243
29416
  }
29244
29417
  };
29245
29418
  }
29246
- function Qi(e, t, n) {
29419
+ function da(e, t, n) {
29247
29420
  return e.some((e) => e.name === t) ? e.map((e) => e.name === t ? {
29248
29421
  ...e,
29249
29422
  value: n
@@ -29254,23 +29427,23 @@ function Qi(e, t, n) {
29254
29427
  }
29255
29428
  //#endregion
29256
29429
  //#region src/v2019C1/hooks/shared/mapped-name.ts
29257
- async function $i(e, t) {
29430
+ async function fa(e, t) {
29258
29431
  let n = P.get(t.tagName);
29259
29432
  if (!n || !t.attributes.find((e) => e.name === n.uuid)?.value) return null;
29260
- let r = await Re(e, t);
29261
- return r === t.attributes.find((e) => e.name === n.path)?.value ? null : Zi(t, r === void 0 ? t.attributes.filter((e) => e.name !== n.path) : Qi(t.attributes, n.path, r));
29433
+ let r = await He(e, t);
29434
+ return r === t.attributes.find((e) => e.name === n.path)?.value ? null : ua(t, r === void 0 ? t.attributes.filter((e) => e.name !== n.path) : da(t.attributes, n.path, r));
29262
29435
  }
29263
29436
  //#endregion
29264
29437
  //#region src/v2019C1/hooks/shared/ref-path-rebuild.ts
29265
- async function ea(e) {
29438
+ async function pa(e) {
29266
29439
  let { oldRecord: t, newRecord: n, query: r } = e;
29267
29440
  if (P.has(n.tagName)) return [];
29268
29441
  let i = D[n.tagName];
29269
29442
  if (!i) return [];
29270
29443
  let a = [];
29271
29444
  for (let e of i) {
29272
- if (e.resolution === M.unsupported || !ta(t, n, e)) continue;
29273
- let i = await na({
29445
+ if (e.resolution === M.unsupported || !ma(t, n, e)) continue;
29446
+ let i = await ha({
29274
29447
  newRecord: n,
29275
29448
  pair: e,
29276
29449
  query: r
@@ -29279,13 +29452,13 @@ async function ea(e) {
29279
29452
  }
29280
29453
  return a;
29281
29454
  }
29282
- function ta(e, t, n) {
29283
- return [n.attribute.uuid, ...n.companions.map((e) => e.name)].some((n) => ia(e, n) !== ia(t, n));
29455
+ function ma(e, t, n) {
29456
+ return [n.attribute.uuid, ...n.companions.map((e) => e.name)].some((n) => _a(e, n) !== _a(t, n));
29284
29457
  }
29285
- async function na(e) {
29286
- let { newRecord: t, pair: n, query: r } = e, i = ia(t, n.attribute.uuid);
29458
+ async function ha(e) {
29459
+ let { newRecord: t, pair: n, query: r } = e, i = _a(t, n.attribute.uuid);
29287
29460
  if (!i) return null;
29288
- let a = await ra({
29461
+ let a = await ga({
29289
29462
  uuidValue: i,
29290
29463
  targetTagNames: n.target,
29291
29464
  query: r
@@ -29298,9 +29471,9 @@ async function na(e) {
29298
29471
  },
29299
29472
  target: a
29300
29473
  });
29301
- return !o || ia(t, n.attribute.path) === o ? null : Zi(t, Qi(t.attributes, n.attribute.path, o));
29474
+ return !o || _a(t, n.attribute.path) === o ? null : ua(t, da(t.attributes, n.attribute.path, o));
29302
29475
  }
29303
- async function ra(e) {
29476
+ async function ga(e) {
29304
29477
  let { uuidValue: t, targetTagNames: r, query: i } = e;
29305
29478
  for (let e of r) {
29306
29479
  if (!n(e, x)) continue;
@@ -29312,22 +29485,22 @@ async function ra(e) {
29312
29485
  }
29313
29486
  return null;
29314
29487
  }
29315
- function ia(e, t) {
29488
+ function _a(e, t) {
29316
29489
  return e.attributes.find((e) => e.name === t)?.value;
29317
29490
  }
29318
29491
  //#endregion
29319
29492
  //#region src/v2019C1/hooks/shared/lnode-binding.ts
29320
- var aa = "None";
29321
- async function oa(e) {
29493
+ var va = "None";
29494
+ async function ya(e) {
29322
29495
  let { oldRecord: t, newRecord: n, query: r } = e;
29323
29496
  if (n.tagName !== "LNode") return null;
29324
- let i = da(t, "lnUuid"), a = da(n, "lnUuid");
29497
+ let i = wa(t, "lnUuid"), a = wa(n, "lnUuid");
29325
29498
  if (i === a) return null;
29326
- let o = a ? await sa(r, a) : await ca(r, n);
29327
- return o ? ua(n, o) : null;
29499
+ let o = a ? await ba(r, a) : await xa(r, n);
29500
+ return o ? Ca(n, o) : null;
29328
29501
  }
29329
- async function sa(e, t) {
29330
- let n = await la(e, t);
29502
+ async function ba(e, t) {
29503
+ let n = await Sa(e, t);
29331
29504
  if (!n) return null;
29332
29505
  let r = await e.getAttributes(n), i = await e.findAncestors(n), a = i.find((e) => e.tagName === "LDevice"), o = i.find((e) => e.tagName === "IED"), s = a ? await e.getAttributes({
29333
29506
  tagName: "LDevice",
@@ -29344,9 +29517,9 @@ async function sa(e, t) {
29344
29517
  lnInst: r.inst
29345
29518
  };
29346
29519
  }
29347
- async function ca(e, t) {
29520
+ async function xa(e, t) {
29348
29521
  let n = {
29349
- iedName: aa,
29522
+ iedName: va,
29350
29523
  ldInst: void 0
29351
29524
  }, r = await e.getChild({
29352
29525
  tagName: "LNode",
@@ -29361,7 +29534,7 @@ async function ca(e, t) {
29361
29534
  lnInst: i.sLnInst
29362
29535
  };
29363
29536
  }
29364
- async function la(e, t) {
29537
+ async function Sa(e, t) {
29365
29538
  for (let r of ["LN", "LN0"]) {
29366
29539
  if (!n(r, x)) continue;
29367
29540
  let i = (await e.getRecordsByTagName(r)).find((e) => e.attributes.find((e) => e.name === "uuid")?.value === t);
@@ -29372,7 +29545,7 @@ async function la(e, t) {
29372
29545
  }
29373
29546
  return null;
29374
29547
  }
29375
- function ua(e, t) {
29548
+ function Ca(e, t) {
29376
29549
  let n = [...e.attributes], r = !1;
29377
29550
  for (let [e, i] of Object.entries(t)) {
29378
29551
  let t = n.find((t) => t.name === e)?.value;
@@ -29381,35 +29554,35 @@ function ua(e, t) {
29381
29554
  n = n.filter((t) => t.name !== e), r = !0;
29382
29555
  continue;
29383
29556
  }
29384
- t !== i && (n = Qi(n, e, i), r = !0);
29557
+ t !== i && (n = da(n, e, i), r = !0);
29385
29558
  }
29386
- return r ? Zi(e, n) : null;
29559
+ return r ? ua(e, n) : null;
29387
29560
  }
29388
- function da(e, t) {
29561
+ function wa(e, t) {
29389
29562
  return e.attributes.find((e) => e.name === t)?.value;
29390
29563
  }
29391
29564
  //#endregion
29392
29565
  //#region src/v2019C1/hooks/after-created/ref-paths.ts
29393
- async function fa(e) {
29394
- let { childRecord: t, query: n } = e, r = await pa({
29566
+ async function Ta(e) {
29567
+ let { childRecord: t, query: n } = e, r = await Ea({
29395
29568
  childRecord: t,
29396
29569
  query: n
29397
- }), i = await ga({
29570
+ }), i = await ka({
29398
29571
  childRecord: t,
29399
29572
  query: n
29400
- }), a = await $i(n, o(t)), s = a ? [a] : [];
29573
+ }), a = await fa(n, o(t)), s = a ? [a] : [];
29401
29574
  return [
29402
29575
  ...r,
29403
29576
  ...i,
29404
29577
  ...s
29405
29578
  ];
29406
29579
  }
29407
- async function pa(e) {
29408
- let { childRecord: t, query: n } = e, r = Me.get(t.tagName);
29580
+ async function Ea(e) {
29581
+ let { childRecord: t, query: n } = e, r = Fe.get(t.tagName);
29409
29582
  if (!r?.length) return [];
29410
29583
  let i = [];
29411
29584
  for (let e of r) {
29412
- let r = await ma({
29585
+ let r = await Da({
29413
29586
  childRecord: t,
29414
29587
  pair: e,
29415
29588
  query: n
@@ -29418,10 +29591,10 @@ async function pa(e) {
29418
29591
  }
29419
29592
  return i;
29420
29593
  }
29421
- async function ma(e) {
29594
+ async function Da(e) {
29422
29595
  let { childRecord: t, pair: n, query: r } = e, i = t.attributes.find((e) => e.name === n.uuidAttr)?.value;
29423
29596
  if (!i) return null;
29424
- let a = await ha({
29597
+ let a = await Oa({
29425
29598
  uuidValue: i,
29426
29599
  targetTagNames: n.targetTagNames,
29427
29600
  query: r
@@ -29451,7 +29624,7 @@ async function ma(e) {
29451
29624
  }
29452
29625
  };
29453
29626
  }
29454
- async function ha(e) {
29627
+ async function Oa(e) {
29455
29628
  let { uuidValue: t, targetTagNames: r, query: i } = e;
29456
29629
  for (let e of r) {
29457
29630
  if (!n(e, x)) continue;
@@ -29463,17 +29636,17 @@ async function ha(e) {
29463
29636
  }
29464
29637
  return null;
29465
29638
  }
29466
- async function ga(e) {
29639
+ async function ka(e) {
29467
29640
  let { childRecord: t, query: n } = e, r = t.attributes.find((e) => e.name === "uuid")?.value;
29468
29641
  if (!r) return [];
29469
- let i = Xi(t.tagName);
29642
+ let i = la(t.tagName);
29470
29643
  if (i.length === 0) return [];
29471
29644
  let a = {
29472
29645
  tagName: t.tagName,
29473
29646
  id: t.id
29474
29647
  }, o = [];
29475
29648
  for (let e of i) {
29476
- let t = await Yi({
29649
+ let t = await ca({
29477
29650
  uuid: r,
29478
29651
  entry: e,
29479
29652
  target: a,
@@ -29485,12 +29658,12 @@ async function ga(e) {
29485
29658
  }
29486
29659
  //#endregion
29487
29660
  //#region src/v2019C1/hooks/after-created/after-created.ts
29488
- async function _a(e) {
29489
- let { childRecord: t, parentRecord: n, query: r } = e, i = await Ui({
29661
+ async function Aa(e) {
29662
+ let { childRecord: t, parentRecord: n, query: r } = e, i = await na({
29490
29663
  childRecord: t,
29491
29664
  parentRecord: n,
29492
29665
  query: r
29493
- }), a = await fa({
29666
+ }), a = await Ta({
29494
29667
  childRecord: t,
29495
29668
  query: r
29496
29669
  });
@@ -29498,7 +29671,7 @@ async function _a(e) {
29498
29671
  }
29499
29672
  //#endregion
29500
29673
  //#region src/v2019C1/hooks/after-standardized-record/uuid-attribute.ts
29501
- function va(e) {
29674
+ function ja(e) {
29502
29675
  let { record: t } = e, { tagName: n, attributes: r } = t, i = x.definition[n];
29503
29676
  if (!("uuid" in i.attributes.details) || r.find((e) => e.name === "uuid")?.value) return t;
29504
29677
  let a = i.attributes.details.uuid?.namespace, o = r.filter((e) => e.name !== "uuid");
@@ -29513,21 +29686,21 @@ function va(e) {
29513
29686
  }
29514
29687
  //#endregion
29515
29688
  //#region src/v2019C1/hooks/after-standardized-record/after-standardized-record.ts
29516
- function ya(e) {
29517
- return va(e);
29689
+ function Ma(e) {
29690
+ return ja(e);
29518
29691
  }
29519
29692
  //#endregion
29520
29693
  //#region src/v2019C1/hooks/after-updated/ref-paths.ts
29521
- async function ba(e) {
29522
- let { oldRecord: t, newRecord: n, query: r } = e, i = [], a = o(t), s = o(n), c = await $i(r, s);
29694
+ async function Na(e) {
29695
+ let { oldRecord: t, newRecord: n, query: r } = e, i = [], a = o(t), s = o(n), c = await fa(r, s);
29523
29696
  c && i.push(c);
29524
- let l = await oa({
29697
+ let l = await ya({
29525
29698
  oldRecord: a,
29526
29699
  newRecord: s,
29527
29700
  query: r
29528
29701
  });
29529
29702
  l && i.push(l);
29530
- let u = await ea({
29703
+ let u = await pa({
29531
29704
  oldRecord: a,
29532
29705
  newRecord: s,
29533
29706
  query: r
@@ -29535,12 +29708,12 @@ async function ba(e) {
29535
29708
  i.push(...u);
29536
29709
  let d = n.attributes.find((e) => e.name === "uuid")?.value;
29537
29710
  if (d) {
29538
- let e = Xi(n.tagName), t = {
29711
+ let e = la(n.tagName), t = {
29539
29712
  tagName: n.tagName,
29540
29713
  id: n.id
29541
29714
  };
29542
29715
  for (let n of e) {
29543
- let e = await Yi({
29716
+ let e = await ca({
29544
29717
  uuid: d,
29545
29718
  entry: n,
29546
29719
  target: t,
@@ -29549,8 +29722,8 @@ async function ba(e) {
29549
29722
  i.push(...e);
29550
29723
  }
29551
29724
  }
29552
- if (xa(t, n)) {
29553
- let e = await Sa({
29725
+ if (Pa(t, n)) {
29726
+ let e = await Fa({
29554
29727
  newRecord: n,
29555
29728
  query: r
29556
29729
  });
@@ -29558,11 +29731,11 @@ async function ba(e) {
29558
29731
  }
29559
29732
  return i;
29560
29733
  }
29561
- function xa(e, t) {
29734
+ function Pa(e, t) {
29562
29735
  for (let n of se) if (e.attributes.find((e) => e.name === n)?.value !== t.attributes.find((e) => e.name === n)?.value) return !0;
29563
29736
  return !1;
29564
29737
  }
29565
- async function Sa(e) {
29738
+ async function Fa(e) {
29566
29739
  let { newRecord: t, query: n } = e, r = {
29567
29740
  tagName: t.tagName,
29568
29741
  id: t.id
@@ -29571,14 +29744,14 @@ async function Sa(e) {
29571
29744
  if (r.id === t.id) continue;
29572
29745
  let e = await n.any.getAttribute(r, { name: "uuid" });
29573
29746
  if (!e) continue;
29574
- let i = Xi(r.tagName);
29747
+ let i = la(r.tagName);
29575
29748
  if (i.length === 0) continue;
29576
29749
  let o = {
29577
29750
  tagName: r.tagName,
29578
29751
  id: r.id
29579
29752
  };
29580
29753
  for (let t of i) {
29581
- let r = await Yi({
29754
+ let r = await ca({
29582
29755
  uuid: e,
29583
29756
  entry: t,
29584
29757
  target: o,
@@ -29591,18 +29764,18 @@ async function Sa(e) {
29591
29764
  }
29592
29765
  //#endregion
29593
29766
  //#region src/v2019C1/hooks/after-updated/after-updated.ts
29594
- async function Ca(e) {
29595
- return ba(e);
29767
+ async function Ia(e) {
29768
+ return Na(e);
29596
29769
  }
29597
29770
  //#endregion
29598
29771
  //#region src/v2019C1/hooks/before-clone/before-clone.ts
29599
- var wa = new Set(Object.values(b).map((e) => e.uri)), Ta = new Set(Object.values(b).map((e) => e.prefix).filter(Boolean));
29600
- function Ea(e) {
29601
- return wa.has(e.namespace.uri) && !n(e.tagName, x);
29772
+ var La = new Set(Object.values(b).map((e) => e.uri)), Ra = new Set(Object.values(b).map((e) => e.prefix).filter(Boolean));
29773
+ function za(e) {
29774
+ return La.has(e.namespace.uri) && !n(e.tagName, x);
29602
29775
  }
29603
- function Da(e) {
29776
+ function Ba(e) {
29604
29777
  let { record: t } = e, n = t, r = !0, i = !!t.value?.trim(), a = t.attributes.find((e) => e.name === "type")?.value, o = a !== void 0;
29605
- t.tagName === "Private" && !t.tree.length && !i && !o && (r = !1), t.tagName === "Private" && !t.tree.length && !i && a !== void 0 && Ta.has(a) && (r = !1), Ea(n) && (r = !1), t.tagName === "Private" && n.tree.length > 0 && n.tree.every(Ea) && (r = !1);
29778
+ t.tagName === "Private" && !t.tree.length && !i && !o && (r = !1), t.tagName === "Private" && !t.tree.length && !i && a !== void 0 && Ra.has(a) && (r = !1), za(n) && (r = !1), t.tagName === "Private" && n.tree.length > 0 && n.tree.every(za) && (r = !1);
29606
29779
  let s = t.attributes.filter((e) => e.name !== "uuid");
29607
29780
  return {
29608
29781
  shouldBeCloned: r,
@@ -29614,17 +29787,17 @@ function Da(e) {
29614
29787
  }
29615
29788
  //#endregion
29616
29789
  //#region src/v2019C1/hooks/before-delete/orphaned-refs.ts
29617
- async function Oa(e) {
29790
+ async function Va(e) {
29618
29791
  let { record: t, query: n } = e, r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
29619
- if (await Pa({
29792
+ if (await qa({
29620
29793
  record: t,
29621
29794
  query: n,
29622
29795
  ids: r,
29623
29796
  uuids: i
29624
29797
  }), i.size === 0) return [];
29625
29798
  let a = [];
29626
- for (let e of k) {
29627
- let t = await ka({
29799
+ for (let e of pe) {
29800
+ let t = await Ha({
29628
29801
  refTagName: e,
29629
29802
  subtreeIds: r,
29630
29803
  subtreeUuids: i,
@@ -29634,11 +29807,11 @@ async function Oa(e) {
29634
29807
  }
29635
29808
  return a;
29636
29809
  }
29637
- async function ka(e) {
29810
+ async function Ha(e) {
29638
29811
  let { refTagName: t, subtreeIds: n, subtreeUuids: r, query: i } = e, a = D[t], o = await i.getRecordsByTagName(t), s = [];
29639
29812
  for (let e of o) {
29640
29813
  if (n.has(e.id)) continue;
29641
- let o = await Aa({
29814
+ let o = await Ua({
29642
29815
  refTagName: t,
29643
29816
  refRecord: e,
29644
29817
  refPairs: a,
@@ -29649,15 +29822,15 @@ async function ka(e) {
29649
29822
  }
29650
29823
  return s;
29651
29824
  }
29652
- async function Aa(e) {
29653
- let { refTagName: t, refRecord: n, refPairs: r, subtreeUuids: i, query: a } = e, o = ja({
29825
+ async function Ua(e) {
29826
+ let { refTagName: t, refRecord: n, refPairs: r, subtreeUuids: i, query: a } = e, o = Wa({
29654
29827
  refPairs: r,
29655
29828
  refRecord: n,
29656
29829
  subtreeUuids: i
29657
29830
  });
29658
- return o.size === 0 ? [] : O.has(t) ? [Ma(n, o)] : Na(n, a);
29831
+ return o.size === 0 ? [] : O.has(t) ? [Ga(n, o)] : Ka(n, a);
29659
29832
  }
29660
- function ja(e) {
29833
+ function Wa(e) {
29661
29834
  let { refPairs: t, refRecord: n, subtreeUuids: r } = e, i = /* @__PURE__ */ new Set();
29662
29835
  for (let e of t) {
29663
29836
  let t = n.attributes.find((t) => t.name === e.attribute.uuid)?.value;
@@ -29668,7 +29841,7 @@ function ja(e) {
29668
29841
  }
29669
29842
  return i;
29670
29843
  }
29671
- function Ma(e, t) {
29844
+ function Ga(e, t) {
29672
29845
  let n = e.attributes.filter((e) => !t.has(e.name));
29673
29846
  return {
29674
29847
  status: "updated",
@@ -29679,7 +29852,7 @@ function Ma(e, t) {
29679
29852
  })
29680
29853
  };
29681
29854
  }
29682
- async function Na(e, t) {
29855
+ async function Ka(e, t) {
29683
29856
  let n = [{
29684
29857
  status: "deleted",
29685
29858
  oldRecord: i(e),
@@ -29701,14 +29874,14 @@ async function Na(e, t) {
29701
29874
  }
29702
29875
  return n;
29703
29876
  }
29704
- async function Pa(e) {
29877
+ async function qa(e) {
29705
29878
  let { record: t, query: n, ids: r, uuids: i } = e;
29706
29879
  r.add(t.id);
29707
29880
  let a = t.attributes.find((e) => e.name === "uuid")?.value;
29708
29881
  a && i.add(a);
29709
29882
  for (let e of t.children) {
29710
29883
  let t = await n.getRecord(e);
29711
- t && await Pa({
29884
+ t && await qa({
29712
29885
  record: t,
29713
29886
  query: n,
29714
29887
  ids: r,
@@ -29718,29 +29891,29 @@ async function Pa(e) {
29718
29891
  }
29719
29892
  //#endregion
29720
29893
  //#region src/v2019C1/hooks/before-delete/before-delete.ts
29721
- async function Fa(e) {
29722
- return Oa(e);
29894
+ async function Ja(e) {
29895
+ return Va(e);
29723
29896
  }
29724
29897
  //#endregion
29725
29898
  //#region src/v2019C1/hooks/io/io-hooks.ts
29726
- function Ia() {
29899
+ function Ya() {
29727
29900
  let e = /* @__PURE__ */ new Map(), t = [], n = [];
29728
29901
  return {
29729
29902
  beforeImportRecord: (r) => {
29730
29903
  let { record: i, ancestry: a } = r, { tagName: o } = i, s = i.attributes.find((e) => e.name === "uuid")?.value;
29731
- if (s && pe.has(o)) {
29904
+ if (s && me.has(o)) {
29732
29905
  let t = ue({
29733
29906
  record: i,
29734
29907
  ancestry: a
29735
29908
  });
29736
29909
  t && e.set(t.path, s);
29737
29910
  }
29738
- if (!A.has(o)) return;
29911
+ if (!k.has(o)) return;
29739
29912
  let c = D[o];
29740
29913
  for (let e of c) {
29741
29914
  let r = i.attributes.find((t) => t.name === e.attribute.path)?.value;
29742
29915
  if (!r || i.attributes.find((t) => t.name === e.attribute.uuid)?.value) continue;
29743
- let s = ge(e.resolution, e.attribute.path, r, a);
29916
+ let s = ye(e.resolution, e.attribute.path, r, a);
29744
29917
  if (!s) {
29745
29918
  e.resolution === M.unsupported && n.push({
29746
29919
  type: "unsupported-xpath-reference",
@@ -29798,12 +29971,12 @@ function Ia() {
29798
29971
  }
29799
29972
  //#endregion
29800
29973
  //#region src/v2019C1/hooks/index.ts
29801
- var La = {
29802
- beforeClone: Da,
29803
- afterStandardizedRecord: ya,
29804
- afterCreated: _a,
29805
- afterUpdated: Ca,
29806
- beforeDelete: Fa
29974
+ var Xa = {
29975
+ beforeClone: Ba,
29976
+ afterStandardizedRecord: Ma,
29977
+ afterCreated: Aa,
29978
+ afterUpdated: Ia,
29979
+ beforeDelete: Ja
29807
29980
  };
29808
29981
  //#endregion
29809
- export { b as A, pe as C, y as D, ae as E, x as O, A as S, se as T, Fe as _, St as a, O as b, Ne as c, P as d, Me as f, F as g, Pe as h, zi as i, v as k, je as l, Ae as m, Ia as n, at as o, ke as p, Hi as r, Le as s, La as t, Ie as u, N as v, D as w, k as x, M as y };
29982
+ export { y as A, O as C, D, me as E, v as M, b as N, se as O, he as S, k as T, ze as _, Ot as a, _e as b, Ie as c, P as d, Fe as f, Le as g, Re as h, Qi as i, x as j, ae as k, Pe as l, Ne as m, Ya as n, lt as o, Me as p, ta as r, Ve as s, Xa as t, Be as u, N as v, pe as w, ge as x, M as y };