@dialecte/scl 0.1.20 → 0.2.1

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 (32) hide show
  1. package/dist/{index-uvKv9uth.js → dialecte.config-BkqCz0VE.js} +765 -757
  2. package/dist/v2019C1/config/dialecte.config.d.ts +14 -0
  3. package/dist/v2019C1/config/dialecte.config.d.ts.map +1 -1
  4. package/dist/v2019C1/config/hydrated.types.d.ts +1 -0
  5. package/dist/v2019C1/config/hydrated.types.d.ts.map +1 -1
  6. package/dist/v2019C1/dialecte.d.ts +9 -50
  7. package/dist/v2019C1/dialecte.d.ts.map +1 -1
  8. package/dist/v2019C1/extensions/template/transaction/shared/clone-function.d.ts.map +1 -1
  9. package/dist/v2019C1/hooks/index.d.ts +2 -0
  10. package/dist/v2019C1/hooks/index.d.ts.map +1 -1
  11. package/dist/v2019C1/hooks/io/index.d.ts.map +1 -0
  12. package/dist/v2019C1/{io/hooks → hooks/io}/io-hooks.d.ts.map +1 -1
  13. package/dist/v2019C1/{io/hooks → hooks/io}/io-hooks.types.d.ts.map +1 -1
  14. package/dist/v2019C1/index.d.ts +0 -1
  15. package/dist/v2019C1/index.d.ts.map +1 -1
  16. package/dist/v2019C1/index.js +138 -164
  17. package/dist/v2019C1/test/hydrated-test.d.ts +4 -14
  18. package/dist/v2019C1/test/hydrated-test.d.ts.map +1 -1
  19. package/dist/v2019C1/test/hydrated-test.types.d.ts +3 -1
  20. package/dist/v2019C1/test/hydrated-test.types.d.ts.map +1 -1
  21. package/dist/v2019C1/test.js +20 -19
  22. package/package.json +2 -2
  23. package/dist/v2019C1/io/export.d.ts +0 -11
  24. package/dist/v2019C1/io/export.d.ts.map +0 -1
  25. package/dist/v2019C1/io/hooks/index.d.ts.map +0 -1
  26. package/dist/v2019C1/io/import.d.ts +0 -5
  27. package/dist/v2019C1/io/import.d.ts.map +0 -1
  28. package/dist/v2019C1/io/index.d.ts +0 -3
  29. package/dist/v2019C1/io/index.d.ts.map +0 -1
  30. /package/dist/v2019C1/{io/hooks → hooks/io}/index.d.ts +0 -0
  31. /package/dist/v2019C1/{io/hooks → hooks/io}/io-hooks.d.ts +0 -0
  32. /package/dist/v2019C1/{io/hooks → hooks/io}/io-hooks.types.d.ts +0 -0
@@ -21144,352 +21144,134 @@ const H = [
21144
21144
  }
21145
21145
  ]
21146
21146
  }
21147
- }, f = {
21148
- direct: "direct",
21149
- lnode: "lnode",
21150
- iedAddress: "ied-address",
21151
- behaviorDescription: "behavior-description",
21152
- unsupported: "unsupported"
21153
- }, m = {
21154
- AllocationRoleRef: [
21155
- {
21156
- attribute: { path: "allocationRole", uuid: "allocationRoleUuid" },
21157
- resolution: "direct",
21158
- target: ["AllocationRole"],
21159
- companions: []
21160
- }
21161
- ],
21162
- BehaviorDescriptionRef: [
21163
- {
21164
- attribute: { path: "behaviorDescription", uuid: "behaviorDescriptionUuid" },
21165
- resolution: "direct",
21166
- target: ["BehaviorDescription"],
21167
- companions: []
21168
- }
21169
- ],
21170
- BehaviorReference: [
21171
- {
21172
- attribute: { path: "behaviorReference", uuid: "behaviorUuid" },
21173
- resolution: "direct",
21174
- target: ["BehaviorDescription"],
21175
- companions: []
21176
- }
21177
- ],
21178
- ControllingLNode: [
21179
- {
21180
- attribute: { path: "resourceName", uuid: "resourceUuid" },
21181
- resolution: "direct",
21182
- target: ["ProcessResource"],
21183
- companions: []
21184
- }
21185
- ],
21186
- ControlRef: [
21187
- {
21188
- attribute: { path: "controlled", uuid: "controlledLNodeUuid" },
21189
- resolution: "lnode",
21190
- target: ["LNode"],
21191
- companions: [{ name: "controlledDoName", required: !0 }]
21192
- },
21147
+ };
21148
+ async function $(a) {
21149
+ const { childRecord: e, parentRecord: t, query: i } = a;
21150
+ if (e.namespace.prefix === P.namespaces.default.prefix)
21151
+ return [];
21152
+ const n = t.tagName === "Private", u = t.namespace.prefix === P.namespaces.default.prefix;
21153
+ if (!n && !u)
21154
+ return [];
21155
+ const r = t.children.find((o) => o.tagName === "Private"), s = {
21156
+ ...t,
21157
+ children: t.children.filter((o) => o.id !== e.id)
21158
+ };
21159
+ return n ? J({ parentRecord: t, childRecord: e, query: i }) : r ? ee({
21160
+ existingPrivateRef: r,
21161
+ parentRecord: t,
21162
+ updatedParentRecord: s,
21163
+ childRecord: e,
21164
+ query: i
21165
+ }) : (await i.findAncestors(t)).some(
21166
+ (o) => o.tagName === "Private" && o.attributes.some(
21167
+ (p) => p.name === "type" && p.value === e.namespace.prefix
21168
+ )
21169
+ ) ? [] : te({ parentRecord: t, updatedParentRecord: s, childRecord: e });
21170
+ }
21171
+ async function J(a) {
21172
+ const { parentRecord: e, childRecord: t, query: i } = a, n = e;
21173
+ if (t.parent?.id === n.id && t.parent?.tagName === "Private")
21174
+ return [];
21175
+ const u = await F({ privateId: n.id, query: i });
21176
+ I(u, {
21177
+ detail: "Latest private record not found",
21178
+ key: "ELEMENT_NOT_FOUND"
21179
+ });
21180
+ const { childRecord: r, privateRecord: s } = q({
21181
+ privateRecord: u,
21182
+ childRecord: t
21183
+ });
21184
+ return [
21193
21185
  {
21194
- attribute: { path: "extCtrlAddr", uuid: "extCtrlUuid" },
21195
- resolution: "ied-address",
21196
- target: ["ExtCtrl"],
21197
- companions: []
21186
+ status: "updated",
21187
+ oldRecord: d(t),
21188
+ newRecord: d(r)
21198
21189
  },
21199
21190
  {
21200
- attribute: { path: "resourceName", uuid: "resourceUuid" },
21201
- resolution: "direct",
21202
- target: ["ProcessResource"],
21203
- companions: []
21204
- }
21205
- ],
21206
- DAS: [
21207
- {
21208
- attribute: { path: "mappedDaName", uuid: "mappedLnUuid" },
21209
- resolution: "lnode",
21210
- target: ["LN", "LN0"],
21211
- companions: []
21212
- }
21213
- ],
21214
- DOS: [
21215
- {
21216
- attribute: { path: "mappedDoName", uuid: "mappedLnUuid" },
21217
- resolution: "lnode",
21218
- target: ["LN", "LN0"],
21219
- companions: []
21220
- }
21221
- ],
21222
- FunctionCategoryRef: [
21223
- {
21224
- attribute: { path: "functionCategory", uuid: "functionCategoryUuid" },
21225
- resolution: "direct",
21226
- target: ["FunctionCategory", "SubCategory"],
21227
- companions: []
21228
- }
21229
- ],
21230
- FunctionCatRef: [
21231
- {
21232
- attribute: { path: "function", uuid: "functionUuid" },
21233
- resolution: "direct",
21234
- target: ["Function", "SubFunction"],
21235
- companions: []
21236
- }
21237
- ],
21238
- FunctionRef: [
21239
- {
21240
- attribute: { path: "function", uuid: "functionUuid" },
21241
- resolution: "direct",
21242
- target: ["Function", "SubFunction", "EqFunction", "EqSubFunction"],
21243
- companions: []
21244
- }
21245
- ],
21246
- FunctionalVariantRef: [
21247
- {
21248
- attribute: { path: "functionalVariant", uuid: "functionalVariantUuid" },
21249
- resolution: "direct",
21250
- target: ["FunctionalVariant", "FunctionalSubVariant"],
21251
- companions: []
21191
+ status: "updated",
21192
+ oldRecord: d(u),
21193
+ newRecord: d(s)
21252
21194
  }
21253
- ],
21254
- InputVar: [
21195
+ ];
21196
+ }
21197
+ async function ee(a) {
21198
+ const { existingPrivateRef: e, parentRecord: t, updatedParentRecord: i, childRecord: n, query: u } = a, r = await F({
21199
+ privateId: e.id,
21200
+ query: u
21201
+ });
21202
+ if (I(r, {
21203
+ detail: "Latest private record not found",
21204
+ key: "ELEMENT_NOT_FOUND"
21205
+ }), !r.attributes.some(
21206
+ (o) => o.name === "type" && o.value === n.namespace.prefix
21207
+ )) return [];
21208
+ const { childRecord: c, privateRecord: l } = q({
21209
+ privateRecord: r,
21210
+ childRecord: n
21211
+ });
21212
+ return [
21255
21213
  {
21256
- attribute: { path: "dataName", uuid: "lnodeUuid" },
21257
- resolution: "behavior-description",
21258
- target: ["LNode"],
21259
- companions: [
21260
- { name: "doName", required: !0 },
21261
- { name: "daName", required: !1 }
21262
- ]
21214
+ status: "updated",
21215
+ oldRecord: d(n),
21216
+ newRecord: d(c)
21263
21217
  },
21264
21218
  {
21265
- attribute: { path: "inputName", uuid: "inputUuid" },
21266
- resolution: "behavior-description",
21267
- target: ["SourceRef"],
21268
- companions: []
21269
- }
21270
- ],
21271
- LNodeDataRef: [
21272
- {
21273
- attribute: { path: "data", uuid: "lnodeUuid" },
21274
- resolution: "lnode",
21275
- target: ["LNode"],
21276
- companions: [
21277
- { name: "doName", required: !0 },
21278
- { name: "daName", required: !1 }
21279
- ]
21280
- }
21281
- ],
21282
- LNodeInputRef: [
21283
- {
21284
- attribute: { path: "sourceRef", uuid: "sourceRefUuid" },
21285
- resolution: "direct",
21286
- target: ["SourceRef"],
21287
- companions: []
21288
- }
21289
- ],
21290
- LNodeOutputRef: [
21219
+ status: "updated",
21220
+ oldRecord: d(r),
21221
+ newRecord: d(l)
21222
+ },
21291
21223
  {
21292
- attribute: { path: "controlRef", uuid: "controlRefUuid" },
21293
- resolution: "direct",
21294
- target: ["ControlRef"],
21295
- companions: []
21224
+ status: "updated",
21225
+ oldRecord: d(t),
21226
+ newRecord: d(i)
21296
21227
  }
21297
- ],
21298
- OutputVar: [
21228
+ ];
21229
+ }
21230
+ function te(a) {
21231
+ const { parentRecord: e, updatedParentRecord: t, childRecord: i } = a, n = {
21232
+ id: crypto.randomUUID(),
21233
+ tagName: "Private",
21234
+ namespace: P.namespaces.default,
21235
+ attributes: [{ name: "type", value: i.namespace.prefix }],
21236
+ value: "",
21237
+ parent: { id: e.id, tagName: e.tagName },
21238
+ children: [{ id: i.id, tagName: i.tagName }]
21239
+ }, u = {
21240
+ ...i,
21241
+ parent: { id: n.id, tagName: "Private" }
21242
+ }, r = {
21243
+ ...t,
21244
+ children: [...t.children, { id: n.id, tagName: "Private" }]
21245
+ };
21246
+ return [
21247
+ { status: "created", oldRecord: void 0, newRecord: d(n) },
21299
21248
  {
21300
- attribute: { path: "dataName", uuid: "lnodeUuid" },
21301
- resolution: "behavior-description",
21302
- target: ["LNode"],
21303
- companions: [
21304
- { name: "doName", required: !0 },
21305
- { name: "daName", required: !1 }
21306
- ]
21249
+ status: "updated",
21250
+ oldRecord: d(i),
21251
+ newRecord: d(u)
21307
21252
  },
21308
21253
  {
21309
- attribute: { path: "outputName", uuid: "outputUuid" },
21310
- resolution: "behavior-description",
21311
- target: ["ControlRef"],
21312
- companions: []
21313
- }
21314
- ],
21315
- PowerSystemRelation: [
21316
- {
21317
- attribute: { path: "relation", uuid: "relationUuid" },
21318
- resolution: "direct",
21319
- target: [
21320
- "ConductingEquipment",
21321
- "PowerTransformer",
21322
- "TransformerWinding",
21323
- "GeneralEquipment",
21324
- "SubEquipment"
21325
- ],
21326
- companions: []
21254
+ status: "updated",
21255
+ oldRecord: d(e),
21256
+ newRecord: d(r)
21327
21257
  }
21328
- ],
21329
- PowerSystemRelationRef: [
21330
- {
21331
- attribute: { path: "powerSystemRelation", uuid: "powerSystemRelationUuid" },
21332
- resolution: "direct",
21333
- target: ["PowerSystemRelation"],
21334
- companions: []
21335
- }
21336
- ],
21337
- ProcessEcho: [
21338
- {
21339
- attribute: { path: "source", uuid: "sourceLNodeUuid" },
21340
- resolution: "lnode",
21341
- target: ["LNode"],
21342
- companions: [
21343
- { name: "sourceDoName", required: !0 },
21344
- { name: "sourceDaName", required: !0 }
21345
- ]
21346
- }
21347
- ],
21348
- ProcessResourceRef: [
21349
- {
21350
- attribute: { path: "processResource", uuid: "processResourceUuid" },
21351
- resolution: "direct",
21352
- target: ["ProcessResource"],
21353
- companions: []
21354
- }
21355
- ],
21356
- ProjectProcessReference: [
21357
- {
21358
- attribute: { path: "processReference", uuid: "processUuid" },
21359
- resolution: "direct",
21360
- target: ["Process"],
21361
- companions: []
21362
- }
21363
- ],
21364
- Resource: [
21365
- {
21366
- attribute: { path: "source", uuid: "sourceUuid" },
21367
- resolution: "direct",
21368
- target: [
21369
- "Substation",
21370
- "VoltageLevel",
21371
- "Bay",
21372
- "ConductingEquipment",
21373
- "PowerTransformer",
21374
- "TransformerWinding",
21375
- "GeneralEquipment",
21376
- "Function",
21377
- "SubFunction",
21378
- "EqFunction",
21379
- "EqSubFunction",
21380
- "LNode"
21381
- ],
21382
- companions: []
21383
- }
21384
- ],
21385
- SDS: [
21386
- {
21387
- attribute: { path: "mappedDoName", uuid: "mappedLnUuid" },
21388
- resolution: "lnode",
21389
- target: ["LN", "LN0"],
21390
- companions: []
21391
- }
21392
- ],
21393
- SourceRef: [
21394
- {
21395
- attribute: { path: "source", uuid: "sourceLNodeUuid" },
21396
- resolution: "lnode",
21397
- target: ["LNode"],
21398
- companions: [
21399
- { name: "sourceDoName", required: !0 },
21400
- { name: "sourceDaName", required: !0 }
21401
- ]
21402
- },
21403
- {
21404
- attribute: { path: "extRefAddr", uuid: "extRefUuid" },
21405
- resolution: "ied-address",
21406
- target: ["ExtRef"],
21407
- companions: []
21408
- },
21409
- {
21410
- attribute: { path: "resourceName", uuid: "resourceUuid" },
21411
- resolution: "direct",
21412
- target: ["ProcessResource"],
21413
- companions: []
21414
- }
21415
- ],
21416
- SubscriberLNode: [
21417
- {
21418
- attribute: { path: "resourceName", uuid: "resourceUuid" },
21419
- resolution: "direct",
21420
- target: ["ProcessResource"],
21421
- companions: []
21422
- }
21423
- ],
21424
- VariableApplyTo: [
21425
- {
21426
- attribute: { path: "element", uuid: "elementUuid" },
21427
- resolution: "unsupported",
21428
- target: ["LNode", "Function", "SubFunction", "EqFunction", "EqSubFunction"],
21429
- companions: [
21430
- { name: "doName", required: !1 },
21431
- { name: "daName", required: !1 }
21432
- ]
21433
- }
21434
- ],
21435
- VariableRef: [
21436
- {
21437
- attribute: { path: "variable", uuid: "variableUuid" },
21438
- resolution: "direct",
21439
- target: ["Variable"],
21440
- companions: []
21441
- }
21442
- ]
21443
- };
21444
- function $(a) {
21445
- const e = {};
21446
- for (const [t, i] of Object.entries(a))
21447
- for (const n of i) {
21448
- const u = e[n.resolution] ??= /* @__PURE__ */ new Map();
21449
- for (const r of n.target) {
21450
- const s = u.get(r) ?? [];
21451
- s.push({
21452
- refTagName: t,
21453
- uuidAttr: n.attribute.uuid,
21454
- pathAttr: n.attribute.path
21455
- }), u.set(r, s);
21456
- }
21457
- }
21458
- return e;
21258
+ ];
21459
21259
  }
21460
- function J(a) {
21461
- const e = /* @__PURE__ */ new Map();
21462
- for (const [t, i] of Object.entries(a))
21463
- e.set(
21464
- t,
21465
- i.map((n) => ({
21466
- uuidAttr: n.attribute.uuid,
21467
- pathAttr: n.attribute.path,
21468
- resolution: n.resolution,
21469
- targetTagNames: n.target
21470
- }))
21471
- );
21472
- return e;
21260
+ async function F(a) {
21261
+ const { privateId: e, query: t } = a;
21262
+ return await t.getRecord({ id: e, tagName: "Private" });
21473
21263
  }
21474
- const F = $(m), q = [
21475
- f.direct,
21476
- f.lnode,
21477
- f.iedAddress,
21478
- f.behaviorDescription
21479
- ], ee = J(m);
21480
- [
21481
- ...new Set(
21482
- Object.values(m).flatMap(
21483
- (a) => a.map((e) => e.attribute.uuid)
21484
- )
21485
- )
21486
- ];
21487
- const te = /* @__PURE__ */ new Set(["SourceRef", "ControlRef", "DOS", "SDS", "DAS", "InputVar", "OutputVar", "ProcessEcho"]), mt = {
21488
- FunctionCatRef: ["SubCategory", "FunctionCategory"],
21489
- PowerSystemRelation: ["PowerSystemRelations"],
21490
- Resource: ["ProcessResource", "ProcessResources"],
21491
- VariableApplyTo: ["Variable"]
21492
- }, y = {
21264
+ function q(a) {
21265
+ const { privateRecord: e, childRecord: t } = a, i = {
21266
+ ...t,
21267
+ parent: { id: e.id, tagName: "Private" }
21268
+ }, n = {
21269
+ ...e,
21270
+ children: [...e.children, { id: t.id, tagName: t.tagName }]
21271
+ };
21272
+ return { childRecord: i, privateRecord: n };
21273
+ }
21274
+ const y = {
21493
21275
  // Transparent - do not contribute a path segment
21494
21276
  AccessPoint: { type: "transparent" },
21495
21277
  Server: { type: "transparent" },
@@ -21642,8 +21424,74 @@ async function E(a, e) {
21642
21424
  ancestry: i.map(d)
21643
21425
  });
21644
21426
  }
21645
- async function k(a, e) {
21646
- const { reference: t, target: i } = e, n = ue(t.tagName, i.tagName);
21427
+ function k(a) {
21428
+ if (!a) return [];
21429
+ const e = [];
21430
+ let t = "", i = "/";
21431
+ for (const n of a)
21432
+ n === "/" || n === "." ? (t && e.push({ segment: t, separator: i }), i = n, t = "") : t += n;
21433
+ return t && e.push({ segment: t, separator: i }), e;
21434
+ }
21435
+ function V(a) {
21436
+ const e = a.split("/"), t = e[e.length - 1], i = t.indexOf(".");
21437
+ if (i === -1) return { path: a };
21438
+ const n = t.substring(0, i), u = t.substring(i + 1);
21439
+ return { path: [...e.slice(0, -1), n].join("/"), qualifier: u || void 0 };
21440
+ }
21441
+ function Z(a, e, t, i) {
21442
+ return !a || a === f.unsupported ? null : a === f.direct ? { lookupKey: t } : a === f.iedAddress ? se(t, i) : a === f.lnode ? ue(t) : a === f.behaviorDescription ? ce(e, t, i) : null;
21443
+ }
21444
+ function ue(a) {
21445
+ const { path: e, qualifier: t } = V(a);
21446
+ return { lookupKey: e, qualifier: t };
21447
+ }
21448
+ function se(a, e) {
21449
+ if (e) {
21450
+ const t = de(e);
21451
+ if (t)
21452
+ return { lookupKey: a, fallbackLookupKey: `${t}/${a}` };
21453
+ }
21454
+ return { lookupKey: a };
21455
+ }
21456
+ function ce(a, e, t) {
21457
+ if (!t) return null;
21458
+ const i = oe(t);
21459
+ if (!i) return null;
21460
+ if (a === "dataName")
21461
+ return { lookupKey: i, qualifier: e };
21462
+ if (a === "inputName" || a === "outputName") {
21463
+ const n = le(e);
21464
+ return { lookupKey: `${i}.${n}` };
21465
+ }
21466
+ return null;
21467
+ }
21468
+ function oe(a) {
21469
+ let e = -1;
21470
+ for (let i = a.length - 1; i >= 0; i--)
21471
+ if (a[i].tagName === "BehaviorDescription") {
21472
+ e = i;
21473
+ break;
21474
+ }
21475
+ if (e === -1) return null;
21476
+ const t = [];
21477
+ for (let i = 0; i < e; i++) {
21478
+ const n = L(a[i]);
21479
+ n && t.push(n);
21480
+ }
21481
+ return t.length === 0 ? null : O(t);
21482
+ }
21483
+ function le(a) {
21484
+ const e = a.indexOf("("), t = a.indexOf(".");
21485
+ return e !== -1 ? a.substring(0, e) : t !== -1 ? a.substring(0, t) : a;
21486
+ }
21487
+ function de(a) {
21488
+ for (let e = a.length - 1; e >= 0; e--)
21489
+ if (a[e].tagName === "LNode")
21490
+ return a[e].attributes.find((t) => t.name === "iedName")?.value ?? null;
21491
+ return null;
21492
+ }
21493
+ async function M(a, e) {
21494
+ const { reference: t, target: i } = e, n = pe(t.tagName, i.tagName);
21647
21495
  if (!n) return null;
21648
21496
  const u = n.resolution;
21649
21497
  if (u === f.unsupported) return null;
@@ -21659,32 +21507,32 @@ async function k(a, e) {
21659
21507
  if (!c) return s;
21660
21508
  const l = c.attributes.find((p) => p.name === n.attribute.path)?.value;
21661
21509
  if (!l) return s;
21662
- const { qualifier: o } = G(l);
21510
+ const { qualifier: o } = V(l);
21663
21511
  return o ? `${s}.${o}` : s;
21664
21512
  }
21665
21513
  return s;
21666
21514
  }
21667
- function ue(a, e) {
21515
+ function pe(a, e) {
21668
21516
  const t = m[a];
21669
21517
  return t ? t.find((i) => i.target.includes(e)) ?? null : null;
21670
21518
  }
21671
- async function se(a, e, t) {
21672
- const i = ce(e.tagName, t);
21519
+ async function Se(a, e, t) {
21520
+ const i = fe(e.tagName, t);
21673
21521
  if (!i) return;
21674
21522
  const n = e.attributes.find((p) => p.name === t)?.value;
21675
21523
  if (!n) return;
21676
21524
  let u;
21677
21525
  (i.resolution === f.behaviorDescription || i.resolution === f.iedAddress) && (u = (await a.findAncestors(e, { order: "top-down" })).map((R) => d(R)));
21678
- const r = B(
21526
+ const r = Z(
21679
21527
  i.resolution,
21680
21528
  t,
21681
21529
  n,
21682
21530
  u
21683
21531
  );
21684
21532
  if (!r) return;
21685
- const s = M(r.lookupKey);
21533
+ const s = k(r.lookupKey);
21686
21534
  if (s.length === 0) return;
21687
- const c = s[s.length - 1], l = s.slice(0, -1), o = await pe({
21535
+ const c = s[s.length - 1], l = s.slice(0, -1), o = await Le({
21688
21536
  query: a,
21689
21537
  targets: i.target,
21690
21538
  segment: c,
@@ -21693,22 +21541,22 @@ async function se(a, e, t) {
21693
21541
  if (o)
21694
21542
  return { record: o, qualifier: r.qualifier };
21695
21543
  }
21696
- function ce(a, e) {
21544
+ function fe(a, e) {
21697
21545
  const t = m[a];
21698
21546
  if (t)
21699
21547
  return t.find((i) => i.attribute.path === e);
21700
21548
  }
21701
- const oe = new Set(
21549
+ const me = new Set(
21702
21550
  D.LNode.attributes.details.lnClass.facets.enumeration
21703
- ), le = {
21551
+ ), be = {
21704
21552
  LNode: "lnInst",
21705
21553
  LN: "inst",
21706
21554
  LN0: "inst"
21707
21555
  };
21708
- function de(a) {
21556
+ function Re(a) {
21709
21557
  for (let e = 0; e <= a.length - 4; e++) {
21710
21558
  const t = a.substring(e, e + 4);
21711
- if (oe.has(t))
21559
+ if (me.has(t))
21712
21560
  return {
21713
21561
  prefix: a.substring(0, e),
21714
21562
  lnClass: t,
@@ -21717,12 +21565,12 @@ function de(a) {
21717
21565
  }
21718
21566
  return null;
21719
21567
  }
21720
- async function pe(a) {
21568
+ async function Le(a) {
21721
21569
  const { query: e, targets: t, segment: i, expectedAncestry: n } = a;
21722
21570
  for (const u of t) {
21723
- const r = le[u];
21571
+ const r = be[u];
21724
21572
  if (r) {
21725
- const s = await Se({
21573
+ const s = await Pe({
21726
21574
  query: e,
21727
21575
  tagName: u,
21728
21576
  segment: i,
@@ -21731,7 +21579,7 @@ async function pe(a) {
21731
21579
  });
21732
21580
  if (s) return s;
21733
21581
  } else {
21734
- const s = await fe({
21582
+ const s = await Ce({
21735
21583
  query: e,
21736
21584
  tagName: u,
21737
21585
  segment: i,
@@ -21741,8 +21589,8 @@ async function pe(a) {
21741
21589
  }
21742
21590
  }
21743
21591
  }
21744
- async function Se(a) {
21745
- const { query: e, tagName: t, segment: i, instAttr: n, expectedAncestry: u } = a, r = de(i.segment);
21592
+ async function Pe(a) {
21593
+ const { query: e, tagName: t, segment: i, instAttr: n, expectedAncestry: u } = a, r = Re(i.segment);
21746
21594
  if (!r) return;
21747
21595
  const s = await e.findByAttributes({
21748
21596
  tagName: t,
@@ -21750,19 +21598,19 @@ async function Se(a) {
21750
21598
  });
21751
21599
  for (const c of s) {
21752
21600
  const l = c.attributes.find((p) => p.name === "prefix")?.value ?? "", o = c.attributes.find((p) => p.name === n)?.value ?? "";
21753
- if (!(l !== r.prefix || o !== r.inst) && await V(e, c, u))
21601
+ if (!(l !== r.prefix || o !== r.inst) && await G(e, c, u))
21754
21602
  return c;
21755
21603
  }
21756
21604
  }
21757
- async function fe(a) {
21605
+ async function Ce(a) {
21758
21606
  const { query: e, tagName: t, segment: i, expectedAncestry: n } = a, u = await e.getRecordsByTagName(t);
21759
21607
  for (const r of u) {
21760
21608
  const s = L(d(r));
21761
- if (!(!s || s.segment !== i.segment) && await V(e, r, n))
21609
+ if (!(!s || s.segment !== i.segment) && await G(e, r, n))
21762
21610
  return r;
21763
21611
  }
21764
21612
  }
21765
- async function V(a, e, t) {
21613
+ async function G(a, e, t) {
21766
21614
  if (t.length === 0) return !0;
21767
21615
  const i = await a.findAncestors(e), n = [];
21768
21616
  for (let u = i.length - 1; u >= 0; u--) {
@@ -21771,8 +21619,8 @@ async function V(a, e, t) {
21771
21619
  }
21772
21620
  return n.length !== t.length ? !1 : n.every((u, r) => u.segment === t[r].segment);
21773
21621
  }
21774
- async function me(a, e) {
21775
- const t = M(e);
21622
+ async function Ae(a, e) {
21623
+ const t = k(e);
21776
21624
  if (t.length === 0) return;
21777
21625
  const i = await a.getRoot();
21778
21626
  return v({
@@ -21800,359 +21648,394 @@ async function v(a) {
21800
21648
  return v({ query: e, current: c, segments: i, index: n + 1 });
21801
21649
  }
21802
21650
  }
21803
- async function be(a, e) {
21804
- const { target: t, containerTagName: i } = e, n = await a.getRecord(t);
21805
- if (!n) return [];
21806
- const u = n.attributes.find((c) => c.name === "uuid")?.value;
21807
- if (!u) return [];
21808
- const r = Re(n.tagName);
21809
- if (r.length === 0) return [];
21810
- const s = [];
21811
- for (const c of r) {
21812
- if (!T(c.refTagName, P)) continue;
21813
- const l = await a.findByAttributes({
21814
- tagName: c.refTagName,
21815
- attributes: { [c.uuidAttr]: u }
21816
- });
21817
- for (const o of l) {
21818
- const p = i ? await Le(a, o, i) : void 0;
21819
- s.push({ ref: o, container: p });
21651
+ const f = {
21652
+ direct: "direct",
21653
+ lnode: "lnode",
21654
+ iedAddress: "ied-address",
21655
+ behaviorDescription: "behavior-description",
21656
+ unsupported: "unsupported"
21657
+ }, m = {
21658
+ AllocationRoleRef: [
21659
+ {
21660
+ attribute: { path: "allocationRole", uuid: "allocationRoleUuid" },
21661
+ resolution: "direct",
21662
+ target: ["AllocationRole"],
21663
+ companions: []
21820
21664
  }
21821
- }
21822
- return s;
21823
- }
21824
- function Re(a) {
21825
- const e = [];
21826
- for (const t of q) {
21827
- const i = F[t].get(a);
21828
- i && e.push(...i);
21829
- }
21830
- return e;
21831
- }
21832
- async function Le(a, e, t) {
21833
- return (await a.findAncestors(e, { stopAtTagName: t })).find((n) => n.tagName === t);
21834
- }
21835
- const Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
21836
- __proto__: null,
21837
- buildElementPath: E,
21838
- buildReferencePath: k,
21839
- findRefsPointingTo: be,
21840
- resolveElementPath: me,
21841
- resolveReferencePath: se
21842
- }, Symbol.toStringTag, { value: "Module" })), Z = {
21843
- query: Pe
21844
- };
21845
- function M(a) {
21846
- if (!a) return [];
21847
- const e = [];
21848
- let t = "", i = "/";
21849
- for (const n of a)
21850
- n === "/" || n === "." ? (t && e.push({ segment: t, separator: i }), i = n, t = "") : t += n;
21851
- return t && e.push({ segment: t, separator: i }), e;
21852
- }
21853
- function G(a) {
21854
- const e = a.split("/"), t = e[e.length - 1], i = t.indexOf(".");
21855
- if (i === -1) return { path: a };
21856
- const n = t.substring(0, i), u = t.substring(i + 1);
21857
- return { path: [...e.slice(0, -1), n].join("/"), qualifier: u || void 0 };
21858
- }
21859
- function B(a, e, t, i) {
21860
- return !a || a === f.unsupported ? null : a === f.direct ? { lookupKey: t } : a === f.iedAddress ? Ae(t, i) : a === f.lnode ? Ce(t) : a === f.behaviorDescription ? ge(e, t, i) : null;
21861
- }
21862
- function Ce(a) {
21863
- const { path: e, qualifier: t } = G(a);
21864
- return { lookupKey: e, qualifier: t };
21865
- }
21866
- function Ae(a, e) {
21867
- if (e) {
21868
- const t = he(e);
21869
- if (t)
21870
- return { lookupKey: a, fallbackLookupKey: `${t}/${a}` };
21871
- }
21872
- return { lookupKey: a };
21873
- }
21874
- function ge(a, e, t) {
21875
- if (!t) return null;
21876
- const i = ve(t);
21877
- if (!i) return null;
21878
- if (a === "dataName")
21879
- return { lookupKey: i, qualifier: e };
21880
- if (a === "inputName" || a === "outputName") {
21881
- const n = Te(e);
21882
- return { lookupKey: `${i}.${n}` };
21883
- }
21884
- return null;
21885
- }
21886
- function ve(a) {
21887
- let e = -1;
21888
- for (let i = a.length - 1; i >= 0; i--)
21889
- if (a[i].tagName === "BehaviorDescription") {
21890
- e = i;
21891
- break;
21665
+ ],
21666
+ BehaviorDescriptionRef: [
21667
+ {
21668
+ attribute: { path: "behaviorDescription", uuid: "behaviorDescriptionUuid" },
21669
+ resolution: "direct",
21670
+ target: ["BehaviorDescription"],
21671
+ companions: []
21892
21672
  }
21893
- if (e === -1) return null;
21894
- const t = [];
21895
- for (let i = 0; i < e; i++) {
21896
- const n = L(a[i]);
21897
- n && t.push(n);
21898
- }
21899
- return t.length === 0 ? null : O(t);
21900
- }
21901
- function Te(a) {
21902
- const e = a.indexOf("("), t = a.indexOf(".");
21903
- return e !== -1 ? a.substring(0, e) : t !== -1 ? a.substring(0, t) : a;
21904
- }
21905
- function he(a) {
21906
- for (let e = a.length - 1; e >= 0; e--)
21907
- if (a[e].tagName === "LNode")
21908
- return a[e].attributes.find((t) => t.name === "iedName")?.value ?? null;
21909
- return null;
21910
- }
21911
- function Ne() {
21912
- const a = /* @__PURE__ */ new Map(), e = [], t = [];
21913
- return {
21914
- beforeImportRecord: (u) => {
21915
- const { record: r, ancestry: s } = u, { tagName: c } = r, l = Fe(r);
21916
- if (l && De.has(c)) {
21917
- const S = x({ record: r, ancestry: s });
21918
- S && a.set(S.path, l);
21919
- }
21920
- if (!we.has(c)) return;
21921
- const R = m[c];
21922
- for (const S of R) {
21923
- const C = r.attributes.find(
21924
- (g) => g.name === S.attribute.path
21925
- )?.value;
21926
- if (!C || r.attributes.find(
21927
- (g) => g.name === S.attribute.uuid
21928
- )?.value) continue;
21929
- const A = B(S.resolution, S.attribute.path, C, s);
21930
- if (!A) {
21931
- S.resolution === f.unsupported && t.push({
21932
- type: "unsupported-xpath-reference",
21933
- recordId: r.id,
21934
- details: {
21935
- elementTag: c,
21936
- pathAttribute: S.attribute.path,
21937
- uuidAttribute: S.attribute.uuid,
21938
- pathValue: C
21939
- }
21940
- });
21941
- continue;
21942
- }
21943
- e.push({
21944
- recordId: r.id,
21945
- elementTag: c,
21946
- uuidAttributeName: S.attribute.uuid,
21947
- pathValue: C,
21948
- lookupKey: A.lookupKey,
21949
- fallbackLookupKey: A.fallbackLookupKey
21950
- });
21951
- }
21952
- },
21953
- afterImport: async () => {
21954
- const u = [], r = [...t];
21955
- for (const s of e) {
21956
- const c = a.get(s.lookupKey) ?? (s.fallbackLookupKey ? a.get(s.fallbackLookupKey) : void 0);
21957
- if (!c) {
21958
- r.push({
21959
- type: "unresolved-reference",
21960
- recordId: s.recordId,
21961
- details: {
21962
- elementTag: s.elementTag,
21963
- uuidAttribute: s.uuidAttributeName,
21964
- pathValue: s.pathValue,
21965
- triedKeys: s.fallbackLookupKey ? [s.lookupKey, s.fallbackLookupKey] : [s.lookupKey]
21966
- }
21967
- });
21968
- continue;
21969
- }
21970
- u.push({
21971
- recordId: s.recordId,
21972
- attributes: [{ name: s.uuidAttributeName, value: c }]
21973
- });
21974
- }
21975
- return a.clear(), e.length = 0, t.length = 0, {
21976
- updates: u,
21977
- warnings: r.length > 0 ? r : void 0
21978
- };
21673
+ ],
21674
+ BehaviorReference: [
21675
+ {
21676
+ attribute: { path: "behaviorReference", uuid: "behaviorUuid" },
21677
+ resolution: "direct",
21678
+ target: ["BehaviorDescription"],
21679
+ companions: []
21979
21680
  }
21980
- };
21981
- }
21982
- const Ie = new Set(
21983
- Object.entries(w).filter(([, a]) => "uuid" in a).map(([a]) => a)
21984
- ), we = new Set(Object.keys(m)), De = new Set(
21985
- Object.values(m).flatMap((a) => a.flatMap((e) => e.target))
21986
- );
21987
- function Fe(a) {
21988
- if (!Ie.has(a.tagName)) return;
21989
- const e = a.attributes.find((i) => i.name === "uuid");
21990
- if (e) return e.value;
21991
- const t = crypto.randomUUID();
21992
- return a.attributes.push({ name: "uuid", value: t }), t;
21993
- }
21994
- const qe = {
21995
- supportedFileExtensions: [".fsd", ".asd", ".ssd", ".scd", ".isd", ".xml"],
21996
- hooks: Ne()
21997
- }, ye = {
21998
- tables: {
21999
- xmlElements: {
22000
- name: "sclElements",
22001
- schema: "id, tagName, [id+tagName], parent.id, parent.tagName, *children.id, *children.tagName"
22002
- },
22003
- additionalTables: {
22004
- attachedFiles: {
22005
- schema: "id, filename, file"
22006
- }
21681
+ ],
21682
+ ControllingLNode: [
21683
+ {
21684
+ attribute: { path: "resourceName", uuid: "resourceUuid" },
21685
+ resolution: "direct",
21686
+ target: ["ProcessResource"],
21687
+ companions: []
22007
21688
  }
22008
- }
22009
- }, xe = {
22010
- default: { uri: "http://www.iec.ch/61850/2003/SCL", prefix: "" },
22011
- v2019C1: {
22012
- uri: "http://www.iec.ch/61850/2019/SCL/6-100",
22013
- prefix: "eIEC61850-6-100"
22014
- }
22015
- }, P = {
22016
- rootElementName: Y,
22017
- singletonElements: j,
22018
- transparentElements: ["Private"],
22019
- elements: H,
22020
- namespaces: xe,
22021
- attributes: w,
22022
- children: W,
22023
- parents: K,
22024
- descendants: X,
22025
- ancestors: Q,
22026
- database: ye,
22027
- io: qe,
22028
- definition: D
22029
- };
22030
- async function Oe(a) {
22031
- const { childRecord: e, parentRecord: t, query: i } = a;
22032
- if (e.namespace.prefix === P.namespaces.default.prefix)
22033
- return [];
22034
- const n = t.tagName === "Private", u = t.namespace.prefix === P.namespaces.default.prefix;
22035
- if (!n && !u)
22036
- return [];
22037
- const r = t.children.find((o) => o.tagName === "Private"), s = {
22038
- ...t,
22039
- children: t.children.filter((o) => o.id !== e.id)
22040
- };
22041
- return n ? Ee({ parentRecord: t, childRecord: e, query: i }) : r ? ke({
22042
- existingPrivateRef: r,
22043
- parentRecord: t,
22044
- updatedParentRecord: s,
22045
- childRecord: e,
22046
- query: i
22047
- }) : (await i.findAncestors(t)).some(
22048
- (o) => o.tagName === "Private" && o.attributes.some(
22049
- (p) => p.name === "type" && p.value === e.namespace.prefix
22050
- )
22051
- ) ? [] : Ve({ parentRecord: t, updatedParentRecord: s, childRecord: e });
22052
- }
22053
- async function Ee(a) {
22054
- const { parentRecord: e, childRecord: t, query: i } = a, n = e;
22055
- if (t.parent?.id === n.id && t.parent?.tagName === "Private")
22056
- return [];
22057
- const u = await U({ privateId: n.id, query: i });
22058
- I(u, {
22059
- detail: "Latest private record not found",
22060
- key: "ELEMENT_NOT_FOUND"
22061
- });
22062
- const { childRecord: r, privateRecord: s } = z({
22063
- privateRecord: u,
22064
- childRecord: t
22065
- });
22066
- return [
21689
+ ],
21690
+ ControlRef: [
22067
21691
  {
22068
- status: "updated",
22069
- oldRecord: d(t),
22070
- newRecord: d(r)
21692
+ attribute: { path: "controlled", uuid: "controlledLNodeUuid" },
21693
+ resolution: "lnode",
21694
+ target: ["LNode"],
21695
+ companions: [{ name: "controlledDoName", required: !0 }]
22071
21696
  },
22072
21697
  {
22073
- status: "updated",
22074
- oldRecord: d(u),
22075
- newRecord: d(s)
21698
+ attribute: { path: "extCtrlAddr", uuid: "extCtrlUuid" },
21699
+ resolution: "ied-address",
21700
+ target: ["ExtCtrl"],
21701
+ companions: []
21702
+ },
21703
+ {
21704
+ attribute: { path: "resourceName", uuid: "resourceUuid" },
21705
+ resolution: "direct",
21706
+ target: ["ProcessResource"],
21707
+ companions: []
22076
21708
  }
22077
- ];
22078
- }
22079
- async function ke(a) {
22080
- const { existingPrivateRef: e, parentRecord: t, updatedParentRecord: i, childRecord: n, query: u } = a, r = await U({
22081
- privateId: e.id,
22082
- query: u
22083
- });
22084
- if (I(r, {
22085
- detail: "Latest private record not found",
22086
- key: "ELEMENT_NOT_FOUND"
22087
- }), !r.attributes.some(
22088
- (o) => o.name === "type" && o.value === n.namespace.prefix
22089
- )) return [];
22090
- const { childRecord: c, privateRecord: l } = z({
22091
- privateRecord: r,
22092
- childRecord: n
22093
- });
22094
- return [
21709
+ ],
21710
+ DAS: [
22095
21711
  {
22096
- status: "updated",
22097
- oldRecord: d(n),
22098
- newRecord: d(c)
21712
+ attribute: { path: "mappedDaName", uuid: "mappedLnUuid" },
21713
+ resolution: "lnode",
21714
+ target: ["LN", "LN0"],
21715
+ companions: []
21716
+ }
21717
+ ],
21718
+ DOS: [
21719
+ {
21720
+ attribute: { path: "mappedDoName", uuid: "mappedLnUuid" },
21721
+ resolution: "lnode",
21722
+ target: ["LN", "LN0"],
21723
+ companions: []
21724
+ }
21725
+ ],
21726
+ FunctionCategoryRef: [
21727
+ {
21728
+ attribute: { path: "functionCategory", uuid: "functionCategoryUuid" },
21729
+ resolution: "direct",
21730
+ target: ["FunctionCategory", "SubCategory"],
21731
+ companions: []
21732
+ }
21733
+ ],
21734
+ FunctionCatRef: [
21735
+ {
21736
+ attribute: { path: "function", uuid: "functionUuid" },
21737
+ resolution: "direct",
21738
+ target: ["Function", "SubFunction"],
21739
+ companions: []
21740
+ }
21741
+ ],
21742
+ FunctionRef: [
21743
+ {
21744
+ attribute: { path: "function", uuid: "functionUuid" },
21745
+ resolution: "direct",
21746
+ target: ["Function", "SubFunction", "EqFunction", "EqSubFunction"],
21747
+ companions: []
21748
+ }
21749
+ ],
21750
+ FunctionalVariantRef: [
21751
+ {
21752
+ attribute: { path: "functionalVariant", uuid: "functionalVariantUuid" },
21753
+ resolution: "direct",
21754
+ target: ["FunctionalVariant", "FunctionalSubVariant"],
21755
+ companions: []
21756
+ }
21757
+ ],
21758
+ InputVar: [
21759
+ {
21760
+ attribute: { path: "dataName", uuid: "lnodeUuid" },
21761
+ resolution: "behavior-description",
21762
+ target: ["LNode"],
21763
+ companions: [
21764
+ { name: "doName", required: !0 },
21765
+ { name: "daName", required: !1 }
21766
+ ]
22099
21767
  },
22100
21768
  {
22101
- status: "updated",
22102
- oldRecord: d(r),
22103
- newRecord: d(l)
21769
+ attribute: { path: "inputName", uuid: "inputUuid" },
21770
+ resolution: "behavior-description",
21771
+ target: ["SourceRef"],
21772
+ companions: []
21773
+ }
21774
+ ],
21775
+ LNodeDataRef: [
21776
+ {
21777
+ attribute: { path: "data", uuid: "lnodeUuid" },
21778
+ resolution: "lnode",
21779
+ target: ["LNode"],
21780
+ companions: [
21781
+ { name: "doName", required: !0 },
21782
+ { name: "daName", required: !1 }
21783
+ ]
21784
+ }
21785
+ ],
21786
+ LNodeInputRef: [
21787
+ {
21788
+ attribute: { path: "sourceRef", uuid: "sourceRefUuid" },
21789
+ resolution: "direct",
21790
+ target: ["SourceRef"],
21791
+ companions: []
21792
+ }
21793
+ ],
21794
+ LNodeOutputRef: [
21795
+ {
21796
+ attribute: { path: "controlRef", uuid: "controlRefUuid" },
21797
+ resolution: "direct",
21798
+ target: ["ControlRef"],
21799
+ companions: []
21800
+ }
21801
+ ],
21802
+ OutputVar: [
21803
+ {
21804
+ attribute: { path: "dataName", uuid: "lnodeUuid" },
21805
+ resolution: "behavior-description",
21806
+ target: ["LNode"],
21807
+ companions: [
21808
+ { name: "doName", required: !0 },
21809
+ { name: "daName", required: !1 }
21810
+ ]
22104
21811
  },
22105
21812
  {
22106
- status: "updated",
22107
- oldRecord: d(t),
22108
- newRecord: d(i)
21813
+ attribute: { path: "outputName", uuid: "outputUuid" },
21814
+ resolution: "behavior-description",
21815
+ target: ["ControlRef"],
21816
+ companions: []
22109
21817
  }
22110
- ];
22111
- }
22112
- function Ve(a) {
22113
- const { parentRecord: e, updatedParentRecord: t, childRecord: i } = a, n = {
22114
- id: crypto.randomUUID(),
22115
- tagName: "Private",
22116
- namespace: P.namespaces.default,
22117
- attributes: [{ name: "type", value: i.namespace.prefix }],
22118
- value: "",
22119
- parent: { id: e.id, tagName: e.tagName },
22120
- children: [{ id: i.id, tagName: i.tagName }]
22121
- }, u = {
22122
- ...i,
22123
- parent: { id: n.id, tagName: "Private" }
22124
- }, r = {
22125
- ...t,
22126
- children: [...t.children, { id: n.id, tagName: "Private" }]
22127
- };
22128
- return [
22129
- { status: "created", oldRecord: void 0, newRecord: d(n) },
21818
+ ],
21819
+ PowerSystemRelation: [
21820
+ {
21821
+ attribute: { path: "relation", uuid: "relationUuid" },
21822
+ resolution: "direct",
21823
+ target: [
21824
+ "ConductingEquipment",
21825
+ "PowerTransformer",
21826
+ "TransformerWinding",
21827
+ "GeneralEquipment",
21828
+ "SubEquipment"
21829
+ ],
21830
+ companions: []
21831
+ }
21832
+ ],
21833
+ PowerSystemRelationRef: [
21834
+ {
21835
+ attribute: { path: "powerSystemRelation", uuid: "powerSystemRelationUuid" },
21836
+ resolution: "direct",
21837
+ target: ["PowerSystemRelation"],
21838
+ companions: []
21839
+ }
21840
+ ],
21841
+ ProcessEcho: [
21842
+ {
21843
+ attribute: { path: "source", uuid: "sourceLNodeUuid" },
21844
+ resolution: "lnode",
21845
+ target: ["LNode"],
21846
+ companions: [
21847
+ { name: "sourceDoName", required: !0 },
21848
+ { name: "sourceDaName", required: !0 }
21849
+ ]
21850
+ }
21851
+ ],
21852
+ ProcessResourceRef: [
21853
+ {
21854
+ attribute: { path: "processResource", uuid: "processResourceUuid" },
21855
+ resolution: "direct",
21856
+ target: ["ProcessResource"],
21857
+ companions: []
21858
+ }
21859
+ ],
21860
+ ProjectProcessReference: [
21861
+ {
21862
+ attribute: { path: "processReference", uuid: "processUuid" },
21863
+ resolution: "direct",
21864
+ target: ["Process"],
21865
+ companions: []
21866
+ }
21867
+ ],
21868
+ Resource: [
21869
+ {
21870
+ attribute: { path: "source", uuid: "sourceUuid" },
21871
+ resolution: "direct",
21872
+ target: [
21873
+ "Substation",
21874
+ "VoltageLevel",
21875
+ "Bay",
21876
+ "ConductingEquipment",
21877
+ "PowerTransformer",
21878
+ "TransformerWinding",
21879
+ "GeneralEquipment",
21880
+ "Function",
21881
+ "SubFunction",
21882
+ "EqFunction",
21883
+ "EqSubFunction",
21884
+ "LNode"
21885
+ ],
21886
+ companions: []
21887
+ }
21888
+ ],
21889
+ SDS: [
21890
+ {
21891
+ attribute: { path: "mappedDoName", uuid: "mappedLnUuid" },
21892
+ resolution: "lnode",
21893
+ target: ["LN", "LN0"],
21894
+ companions: []
21895
+ }
21896
+ ],
21897
+ SourceRef: [
21898
+ {
21899
+ attribute: { path: "source", uuid: "sourceLNodeUuid" },
21900
+ resolution: "lnode",
21901
+ target: ["LNode"],
21902
+ companions: [
21903
+ { name: "sourceDoName", required: !0 },
21904
+ { name: "sourceDaName", required: !0 }
21905
+ ]
21906
+ },
22130
21907
  {
22131
- status: "updated",
22132
- oldRecord: d(i),
22133
- newRecord: d(u)
21908
+ attribute: { path: "extRefAddr", uuid: "extRefUuid" },
21909
+ resolution: "ied-address",
21910
+ target: ["ExtRef"],
21911
+ companions: []
22134
21912
  },
22135
21913
  {
22136
- status: "updated",
22137
- oldRecord: d(e),
22138
- newRecord: d(r)
21914
+ attribute: { path: "resourceName", uuid: "resourceUuid" },
21915
+ resolution: "direct",
21916
+ target: ["ProcessResource"],
21917
+ companions: []
22139
21918
  }
22140
- ];
21919
+ ],
21920
+ SubscriberLNode: [
21921
+ {
21922
+ attribute: { path: "resourceName", uuid: "resourceUuid" },
21923
+ resolution: "direct",
21924
+ target: ["ProcessResource"],
21925
+ companions: []
21926
+ }
21927
+ ],
21928
+ VariableApplyTo: [
21929
+ {
21930
+ attribute: { path: "element", uuid: "elementUuid" },
21931
+ resolution: "unsupported",
21932
+ target: ["LNode", "Function", "SubFunction", "EqFunction", "EqSubFunction"],
21933
+ companions: [
21934
+ { name: "doName", required: !1 },
21935
+ { name: "daName", required: !1 }
21936
+ ]
21937
+ }
21938
+ ],
21939
+ VariableRef: [
21940
+ {
21941
+ attribute: { path: "variable", uuid: "variableUuid" },
21942
+ resolution: "direct",
21943
+ target: ["Variable"],
21944
+ companions: []
21945
+ }
21946
+ ]
21947
+ };
21948
+ function ge(a) {
21949
+ const e = {};
21950
+ for (const [t, i] of Object.entries(a))
21951
+ for (const n of i) {
21952
+ const u = e[n.resolution] ??= /* @__PURE__ */ new Map();
21953
+ for (const r of n.target) {
21954
+ const s = u.get(r) ?? [];
21955
+ s.push({
21956
+ refTagName: t,
21957
+ uuidAttr: n.attribute.uuid,
21958
+ pathAttr: n.attribute.path
21959
+ }), u.set(r, s);
21960
+ }
21961
+ }
21962
+ return e;
22141
21963
  }
22142
- async function U(a) {
22143
- const { privateId: e, query: t } = a;
22144
- return await t.getRecord({ id: e, tagName: "Private" });
21964
+ function ve(a) {
21965
+ const e = /* @__PURE__ */ new Map();
21966
+ for (const [t, i] of Object.entries(a))
21967
+ e.set(
21968
+ t,
21969
+ i.map((n) => ({
21970
+ uuidAttr: n.attribute.uuid,
21971
+ pathAttr: n.attribute.path,
21972
+ resolution: n.resolution,
21973
+ targetTagNames: n.target
21974
+ }))
21975
+ );
21976
+ return e;
22145
21977
  }
22146
- function z(a) {
22147
- const { privateRecord: e, childRecord: t } = a, i = {
22148
- ...t,
22149
- parent: { id: e.id, tagName: "Private" }
22150
- }, n = {
22151
- ...e,
22152
- children: [...e.children, { id: t.id, tagName: t.tagName }]
22153
- };
22154
- return { childRecord: i, privateRecord: n };
21978
+ const B = ge(m), U = [
21979
+ f.direct,
21980
+ f.lnode,
21981
+ f.iedAddress,
21982
+ f.behaviorDescription
21983
+ ], Te = ve(m);
21984
+ [
21985
+ ...new Set(
21986
+ Object.values(m).flatMap(
21987
+ (a) => a.map((e) => e.attribute.uuid)
21988
+ )
21989
+ )
21990
+ ];
21991
+ const he = /* @__PURE__ */ new Set(["SourceRef", "ControlRef", "DOS", "SDS", "DAS", "InputVar", "OutputVar", "ProcessEcho"]), bt = {
21992
+ FunctionCatRef: ["SubCategory", "FunctionCategory"],
21993
+ PowerSystemRelation: ["PowerSystemRelations"],
21994
+ Resource: ["ProcessResource", "ProcessResources"],
21995
+ VariableApplyTo: ["Variable"]
21996
+ };
21997
+ async function Ne(a, e) {
21998
+ const { target: t, containerTagName: i } = e, n = await a.getRecord(t);
21999
+ if (!n) return [];
22000
+ const u = n.attributes.find((c) => c.name === "uuid")?.value;
22001
+ if (!u) return [];
22002
+ const r = Ie(n.tagName);
22003
+ if (r.length === 0) return [];
22004
+ const s = [];
22005
+ for (const c of r) {
22006
+ if (!T(c.refTagName, P)) continue;
22007
+ const l = await a.findByAttributes({
22008
+ tagName: c.refTagName,
22009
+ attributes: { [c.uuidAttr]: u }
22010
+ });
22011
+ for (const o of l) {
22012
+ const p = i ? await we(a, o, i) : void 0;
22013
+ s.push({ ref: o, container: p });
22014
+ }
22015
+ }
22016
+ return s;
22017
+ }
22018
+ function Ie(a) {
22019
+ const e = [];
22020
+ for (const t of U) {
22021
+ const i = B[t].get(a);
22022
+ i && e.push(...i);
22023
+ }
22024
+ return e;
22025
+ }
22026
+ async function we(a, e, t) {
22027
+ return (await a.findAncestors(e, { stopAtTagName: t })).find((n) => n.tagName === t);
22155
22028
  }
22029
+ const De = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
22030
+ __proto__: null,
22031
+ buildElementPath: E,
22032
+ buildReferencePath: M,
22033
+ findRefsPointingTo: Ne,
22034
+ resolveElementPath: Ae,
22035
+ resolveReferencePath: Se
22036
+ }, Symbol.toStringTag, { value: "Module" })), z = {
22037
+ query: De
22038
+ };
22156
22039
  async function h(a) {
22157
22040
  const { uuid: e, entry: t, target: i, query: n } = a;
22158
22041
  if (!T(t.refTagName, P)) return [];
@@ -22161,7 +22044,7 @@ async function h(a) {
22161
22044
  if (s.attributes.find(
22162
22045
  (S) => S.name === t.uuidAttr
22163
22046
  )?.value !== e) continue;
22164
- const l = { tagName: s.tagName, id: s.id }, o = await Z.query.buildReferencePath(n, { reference: l, target: i });
22047
+ const l = { tagName: s.tagName, id: s.id }, o = await z.query.buildReferencePath(n, { reference: l, target: i });
22165
22048
  if (!o || s.attributes.find(
22166
22049
  (S) => S.name === t.pathAttr
22167
22050
  )?.value === o) continue;
@@ -22178,36 +22061,36 @@ async function h(a) {
22178
22061
  }
22179
22062
  function N(a) {
22180
22063
  const e = [];
22181
- for (const t of q) {
22182
- const i = F[t].get(a);
22064
+ for (const t of U) {
22065
+ const i = B[t].get(a);
22183
22066
  i && e.push(...i);
22184
22067
  }
22185
22068
  return e;
22186
22069
  }
22187
- async function Ze(a) {
22188
- const { childRecord: e, query: t } = a, i = await Me({ childRecord: e, query: t }), n = await Ue({ childRecord: e, query: t });
22070
+ async function Fe(a) {
22071
+ const { childRecord: e, query: t } = a, i = await qe({ childRecord: e, query: t }), n = await Oe({ childRecord: e, query: t });
22189
22072
  return [...i, ...n];
22190
22073
  }
22191
- async function Me(a) {
22192
- const { childRecord: e, query: t } = a, i = ee.get(e.tagName);
22074
+ async function qe(a) {
22075
+ const { childRecord: e, query: t } = a, i = Te.get(e.tagName);
22193
22076
  if (!i?.length) return [];
22194
22077
  const n = [];
22195
22078
  for (const u of i) {
22196
- const r = await Ge({ childRecord: e, pair: u, query: t });
22079
+ const r = await ye({ childRecord: e, pair: u, query: t });
22197
22080
  r && n.push(r);
22198
22081
  }
22199
22082
  return n;
22200
22083
  }
22201
- async function Ge(a) {
22084
+ async function ye(a) {
22202
22085
  const { childRecord: e, pair: t, query: i } = a, n = e.attributes.find((o) => o.name === t.uuidAttr)?.value;
22203
22086
  if (!n) return null;
22204
- const u = await Be({
22087
+ const u = await xe({
22205
22088
  uuidValue: n,
22206
22089
  targetTagNames: t.targetTagNames,
22207
22090
  query: i
22208
22091
  });
22209
22092
  if (!u) return null;
22210
- const r = { tagName: e.tagName, id: e.id }, s = { tagName: u.tagName, id: u.id }, c = await k(i, { reference: r, target: s });
22093
+ const r = { tagName: e.tagName, id: e.id }, s = { tagName: u.tagName, id: u.id }, c = await M(i, { reference: r, target: s });
22211
22094
  if (!c) return null;
22212
22095
  const l = e.attributes.map(
22213
22096
  (o) => o.name === t.pathAttr ? { ...o, value: c } : o
@@ -22221,7 +22104,7 @@ async function Ge(a) {
22221
22104
  }
22222
22105
  };
22223
22106
  }
22224
- async function Be(a) {
22107
+ async function xe(a) {
22225
22108
  const { uuidValue: e, targetTagNames: t, query: i } = a;
22226
22109
  for (const n of t) {
22227
22110
  if (!T(n, P)) continue;
@@ -22232,7 +22115,7 @@ async function Be(a) {
22232
22115
  }
22233
22116
  return null;
22234
22117
  }
22235
- async function Ue(a) {
22118
+ async function Oe(a) {
22236
22119
  const { childRecord: e, query: t } = a, i = e.attributes.find((s) => s.name === "uuid")?.value;
22237
22120
  if (!i) return [];
22238
22121
  const n = N(e.tagName);
@@ -22244,33 +22127,33 @@ async function Ue(a) {
22244
22127
  }
22245
22128
  return r;
22246
22129
  }
22247
- async function ze(a) {
22248
- const { childRecord: e, parentRecord: t, query: i } = a, n = await Oe({ childRecord: e, parentRecord: t, query: i }), u = await Ze({ childRecord: e, query: i });
22130
+ async function Ee(a) {
22131
+ const { childRecord: e, parentRecord: t, query: i } = a, n = await $({ childRecord: e, parentRecord: t, query: i }), u = await Fe({ childRecord: e, query: i });
22249
22132
  return [...n, ...u];
22250
22133
  }
22251
- async function _e(a) {
22252
- const { cumulativeCloneMappings: e, query: t } = a, { uuidMap: i, uuidToRef: n } = await He(e, t);
22134
+ async function ke(a) {
22135
+ const { cumulativeCloneMappings: e, query: t } = a, { uuidMap: i, uuidToRef: n } = await Ve(e, t);
22253
22136
  if (i.size === 0) return [];
22254
22137
  const u = [];
22255
22138
  for (const { target: r } of e) {
22256
- const s = await Ke({ target: r, uuidMap: i, uuidToRef: n, query: t });
22139
+ const s = await Me({ target: r, uuidMap: i, uuidToRef: n, query: t });
22257
22140
  s && u.push(s);
22258
22141
  }
22259
22142
  return u;
22260
22143
  }
22261
- async function He(a, e) {
22144
+ async function Ve(a, e) {
22262
22145
  const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
22263
22146
  for (const { source: n, target: u } of a)
22264
- await We({ source: n, target: u, query: e, uuidMap: t, uuidToRef: i });
22147
+ await Ze({ source: n, target: u, query: e, uuidMap: t, uuidToRef: i });
22265
22148
  return { uuidMap: t, uuidToRef: i };
22266
22149
  }
22267
- async function We(a) {
22150
+ async function Ze(a) {
22268
22151
  const { source: e, target: t, query: i, uuidMap: n, uuidToRef: u } = a, r = await i.getRecord(t);
22269
22152
  if (!r) return;
22270
22153
  const s = e.attributes.find((l) => l.name === "uuid")?.value, c = r.attributes.find((l) => l.name === "uuid")?.value;
22271
22154
  !s || !c || (n.set(s, c), u.set(c, { tagName: r.tagName, id: r.id }));
22272
22155
  }
22273
- async function Ke(a) {
22156
+ async function Me(a) {
22274
22157
  const { target: e, uuidMap: t, uuidToRef: i, query: n } = a, u = e.tagName;
22275
22158
  if (!(u in m)) return null;
22276
22159
  const r = await n.getRecord(e);
@@ -22278,7 +22161,7 @@ async function Ke(a) {
22278
22161
  const s = m[u];
22279
22162
  let c = [...r.attributes], l = !1;
22280
22163
  for (const o of s) {
22281
- const p = await Xe({
22164
+ const p = await Ge({
22282
22165
  pair: o,
22283
22166
  tagName: u,
22284
22167
  refId: r.id,
@@ -22295,7 +22178,7 @@ async function Ke(a) {
22295
22178
  newRecord: d({ ...r, attributes: c })
22296
22179
  } : null;
22297
22180
  }
22298
- async function Xe(a) {
22181
+ async function Ge(a) {
22299
22182
  const { pair: e, tagName: t, refId: i, uuidMap: n, uuidToRef: u, query: r } = a;
22300
22183
  let s = [...a.updatedAttributes];
22301
22184
  const c = s.find((S) => S.name === e.attribute.uuid)?.value;
@@ -22303,9 +22186,9 @@ async function Xe(a) {
22303
22186
  const l = n.get(c);
22304
22187
  if (!l) return null;
22305
22188
  let o = !1;
22306
- const p = Qe(s, e.attribute.uuid, c, l);
22189
+ const p = Be(s, e.attribute.uuid, c, l);
22307
22190
  p && (s = p, o = !0);
22308
- const R = await Ye({
22191
+ const R = await Ue({
22309
22192
  attributes: s,
22310
22193
  pathAttrName: e.attribute.path,
22311
22194
  newUuid: l,
@@ -22316,22 +22199,22 @@ async function Xe(a) {
22316
22199
  });
22317
22200
  return R && (s = R, o = !0), o ? s : null;
22318
22201
  }
22319
- function Qe(a, e, t, i) {
22202
+ function Be(a, e, t, i) {
22320
22203
  return i === t ? null : a.map((n) => n.name === e ? { ...n, value: i } : n);
22321
22204
  }
22322
- async function Ye(a) {
22205
+ async function Ue(a) {
22323
22206
  const { attributes: e, pathAttrName: t, newUuid: i, uuidToRef: n, tagName: u, refId: r, query: s } = a, c = n.get(i);
22324
22207
  if (!c) return null;
22325
- const l = await Z.query.buildReferencePath(s, {
22208
+ const l = await z.query.buildReferencePath(s, {
22326
22209
  reference: { tagName: u, id: r },
22327
22210
  target: { tagName: c.tagName, id: c.id }
22328
22211
  });
22329
22212
  return !l || e.find((p) => p.name === t)?.value === l ? null : e.map((p) => p.name === t ? { ...p, value: l } : p);
22330
22213
  }
22331
- async function je(a) {
22332
- return _e(a);
22214
+ async function ze(a) {
22215
+ return ke(a);
22333
22216
  }
22334
- function $e(a) {
22217
+ function _e(a) {
22335
22218
  const { record: e } = a, { tagName: t, attributes: i } = e, n = P.definition[t];
22336
22219
  if (!("uuid" in n.attributes.details) || i.find((o) => o.name === "uuid")?.value) return e;
22337
22220
  const c = n.attributes.details.uuid?.namespace, l = i.filter((o) => o.name !== "uuid");
@@ -22347,10 +22230,10 @@ function $e(a) {
22347
22230
  ]
22348
22231
  };
22349
22232
  }
22350
- function Je(a) {
22351
- return $e(a);
22233
+ function He(a) {
22234
+ return _e(a);
22352
22235
  }
22353
- async function et(a) {
22236
+ async function We(a) {
22354
22237
  const { oldRecord: e, newRecord: t, query: i } = a, n = [], u = t.attributes.find((r) => r.name === "uuid")?.value;
22355
22238
  if (u) {
22356
22239
  const r = N(t.tagName), s = { tagName: t.tagName, id: t.id };
@@ -22359,20 +22242,20 @@ async function et(a) {
22359
22242
  n.push(...l);
22360
22243
  }
22361
22244
  }
22362
- if (tt(e, t)) {
22363
- const r = await at({ newRecord: t, query: i });
22245
+ if (Ke(e, t)) {
22246
+ const r = await Xe({ newRecord: t, query: i });
22364
22247
  n.push(...r);
22365
22248
  }
22366
22249
  return n;
22367
22250
  }
22368
- function tt(a, e) {
22251
+ function Ke(a, e) {
22369
22252
  for (const t of ie) {
22370
22253
  const i = a.attributes.find((u) => u.name === t)?.value, n = e.attributes.find((u) => u.name === t)?.value;
22371
22254
  if (i !== n) return !0;
22372
22255
  }
22373
22256
  return !1;
22374
22257
  }
22375
- async function at(a) {
22258
+ async function Xe(a) {
22376
22259
  const { newRecord: e, query: t } = a, i = { tagName: e.tagName, id: e.id }, n = await t.findDescendants(i), u = [];
22377
22260
  for (const r of Object.values(n))
22378
22261
  for (const s of r) {
@@ -22389,10 +22272,10 @@ async function at(a) {
22389
22272
  }
22390
22273
  return u;
22391
22274
  }
22392
- async function it(a) {
22393
- return et(a);
22275
+ async function Qe(a) {
22276
+ return We(a);
22394
22277
  }
22395
- function nt(a) {
22278
+ function Ye(a) {
22396
22279
  const { record: e } = a;
22397
22280
  let t = !0;
22398
22281
  e.tagName === "Private" && !e.tree.length && (t = !1);
@@ -22407,30 +22290,30 @@ function nt(a) {
22407
22290
  }
22408
22291
  };
22409
22292
  }
22410
- async function rt(a) {
22293
+ async function je(a) {
22411
22294
  const { record: e, query: t } = a, i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
22412
22295
  if (await _({ record: e, query: t, ids: i, uuids: n }), n.size === 0) return [];
22413
22296
  const u = [], r = Object.keys(m);
22414
22297
  for (const s of r) {
22415
- const c = await ut({ refTagName: s, subtreeIds: i, subtreeUuids: n, query: t });
22298
+ const c = await $e({ refTagName: s, subtreeIds: i, subtreeUuids: n, query: t });
22416
22299
  u.push(...c);
22417
22300
  }
22418
22301
  return u;
22419
22302
  }
22420
- async function ut(a) {
22303
+ async function $e(a) {
22421
22304
  const { refTagName: e, subtreeIds: t, subtreeUuids: i, query: n } = a, u = m[e], r = await n.getRecordsByTagName(e), s = [];
22422
22305
  for (const c of r) {
22423
22306
  if (t.has(c.id)) continue;
22424
- const l = await st({ refTagName: e, refRecord: c, refPairs: u, subtreeUuids: i, query: n });
22307
+ const l = await Je({ refTagName: e, refRecord: c, refPairs: u, subtreeUuids: i, query: n });
22425
22308
  s.push(...l);
22426
22309
  }
22427
22310
  return s;
22428
22311
  }
22429
- async function st(a) {
22430
- const { refTagName: e, refRecord: t, refPairs: i, subtreeUuids: n, query: u } = a, r = ct({ refPairs: i, refRecord: t, subtreeUuids: n });
22431
- return r.size === 0 ? [] : te.has(e) ? [ot(t, r)] : lt(t, u);
22312
+ async function Je(a) {
22313
+ const { refTagName: e, refRecord: t, refPairs: i, subtreeUuids: n, query: u } = a, r = et({ refPairs: i, refRecord: t, subtreeUuids: n });
22314
+ return r.size === 0 ? [] : he.has(e) ? [tt(t, r)] : at(t, u);
22432
22315
  }
22433
- function ct(a) {
22316
+ function et(a) {
22434
22317
  const { refPairs: e, refRecord: t, subtreeUuids: i } = a, n = /* @__PURE__ */ new Set();
22435
22318
  for (const u of e) {
22436
22319
  const r = t.attributes.find(
@@ -22444,7 +22327,7 @@ function ct(a) {
22444
22327
  }
22445
22328
  return n;
22446
22329
  }
22447
- function ot(a, e) {
22330
+ function tt(a, e) {
22448
22331
  const t = a.attributes.filter(
22449
22332
  (i) => !e.has(i.name)
22450
22333
  );
@@ -22454,7 +22337,7 @@ function ot(a, e) {
22454
22337
  newRecord: d({ ...a, attributes: t })
22455
22338
  };
22456
22339
  }
22457
- async function lt(a, e) {
22340
+ async function at(a, e) {
22458
22341
  const t = [
22459
22342
  { status: "deleted", oldRecord: d(a), newRecord: void 0 }
22460
22343
  ];
@@ -22484,27 +22367,152 @@ async function _(a) {
22484
22367
  s && await _({ record: s, query: t, ids: i, uuids: n });
22485
22368
  }
22486
22369
  }
22487
- async function dt(a) {
22488
- return rt(a);
22370
+ async function it(a) {
22371
+ return je(a);
22372
+ }
22373
+ function nt() {
22374
+ const a = /* @__PURE__ */ new Map(), e = [], t = [];
22375
+ return {
22376
+ beforeImportRecord: (u) => {
22377
+ const { record: r, ancestry: s } = u, { tagName: c } = r, l = ct(r);
22378
+ if (l && st.has(c)) {
22379
+ const S = x({ record: r, ancestry: s });
22380
+ S && a.set(S.path, l);
22381
+ }
22382
+ if (!ut.has(c)) return;
22383
+ const R = m[c];
22384
+ for (const S of R) {
22385
+ const C = r.attributes.find(
22386
+ (g) => g.name === S.attribute.path
22387
+ )?.value;
22388
+ if (!C || r.attributes.find(
22389
+ (g) => g.name === S.attribute.uuid
22390
+ )?.value) continue;
22391
+ const A = Z(S.resolution, S.attribute.path, C, s);
22392
+ if (!A) {
22393
+ S.resolution === f.unsupported && t.push({
22394
+ type: "unsupported-xpath-reference",
22395
+ recordId: r.id,
22396
+ details: {
22397
+ elementTag: c,
22398
+ pathAttribute: S.attribute.path,
22399
+ uuidAttribute: S.attribute.uuid,
22400
+ pathValue: C
22401
+ }
22402
+ });
22403
+ continue;
22404
+ }
22405
+ e.push({
22406
+ recordId: r.id,
22407
+ elementTag: c,
22408
+ uuidAttributeName: S.attribute.uuid,
22409
+ pathValue: C,
22410
+ lookupKey: A.lookupKey,
22411
+ fallbackLookupKey: A.fallbackLookupKey
22412
+ });
22413
+ }
22414
+ },
22415
+ afterImport: async () => {
22416
+ const u = [], r = [...t];
22417
+ for (const s of e) {
22418
+ const c = a.get(s.lookupKey) ?? (s.fallbackLookupKey ? a.get(s.fallbackLookupKey) : void 0);
22419
+ if (!c) {
22420
+ r.push({
22421
+ type: "unresolved-reference",
22422
+ recordId: s.recordId,
22423
+ details: {
22424
+ elementTag: s.elementTag,
22425
+ uuidAttribute: s.uuidAttributeName,
22426
+ pathValue: s.pathValue,
22427
+ triedKeys: s.fallbackLookupKey ? [s.lookupKey, s.fallbackLookupKey] : [s.lookupKey]
22428
+ }
22429
+ });
22430
+ continue;
22431
+ }
22432
+ u.push({
22433
+ recordId: s.recordId,
22434
+ attributes: [{ name: s.uuidAttributeName, value: c }]
22435
+ });
22436
+ }
22437
+ return a.clear(), e.length = 0, t.length = 0, {
22438
+ updates: u,
22439
+ warnings: r.length > 0 ? r : void 0
22440
+ };
22441
+ }
22442
+ };
22443
+ }
22444
+ const rt = new Set(
22445
+ Object.entries(w).filter(([, a]) => "uuid" in a).map(([a]) => a)
22446
+ ), ut = new Set(Object.keys(m)), st = new Set(
22447
+ Object.values(m).flatMap((a) => a.flatMap((e) => e.target))
22448
+ );
22449
+ function ct(a) {
22450
+ if (!rt.has(a.tagName)) return;
22451
+ const e = a.attributes.find((i) => i.name === "uuid");
22452
+ if (e) return e.value;
22453
+ const t = crypto.randomUUID();
22454
+ return a.attributes.push({ name: "uuid", value: t }), t;
22489
22455
  }
22490
- const bt = {
22491
- beforeClone: nt,
22492
- afterStandardizedRecord: Je,
22493
- afterCreated: ze,
22494
- afterDeepClone: je,
22495
- afterUpdated: it,
22496
- beforeDelete: dt
22456
+ const Rt = {
22457
+ beforeClone: Ye,
22458
+ afterStandardizedRecord: He,
22459
+ afterCreated: Ee,
22460
+ afterDeepClone: ze,
22461
+ afterUpdated: Qe,
22462
+ beforeDelete: it
22463
+ }, ot = nt(), lt = {
22464
+ supportedFileExtensions: [".fsd", ".asd", ".ssd", ".scd", ".isd", ".xml"],
22465
+ hooks: ot
22466
+ }, dt = {
22467
+ recordSchema: {
22468
+ primaryKey: "id",
22469
+ indexes: ["tagName", "parent.id", "parent.tagName"],
22470
+ compoundIndexes: [["id", "tagName"]],
22471
+ arrayIndexes: ["children.id", "children.tagName"]
22472
+ },
22473
+ /** @deprecated - kept for old io/ pipeline until Phase 5 removes it */
22474
+ tables: {
22475
+ xmlElements: {
22476
+ name: "sclElements",
22477
+ schema: "id, tagName, [id+tagName], parent.id, parent.tagName, *children.id, *children.tagName"
22478
+ },
22479
+ additionalTables: {
22480
+ attachedFiles: {
22481
+ schema: "id, filename, file"
22482
+ }
22483
+ }
22484
+ }
22485
+ }, pt = {
22486
+ default: { uri: "http://www.iec.ch/61850/2003/SCL", prefix: "" },
22487
+ v2019C1: {
22488
+ uri: "http://www.iec.ch/61850/2019/SCL/6-100",
22489
+ prefix: "eIEC61850-6-100"
22490
+ }
22491
+ }, P = {
22492
+ rootElementName: Y,
22493
+ singletonElements: j,
22494
+ transparentElements: ["Private"],
22495
+ elements: H,
22496
+ namespaces: pt,
22497
+ attributes: w,
22498
+ children: W,
22499
+ parents: K,
22500
+ descendants: X,
22501
+ ancestors: Q,
22502
+ database: dt,
22503
+ io: lt,
22504
+ definition: D
22497
22505
  };
22498
22506
  export {
22499
22507
  D,
22500
- bt as H,
22501
- te as K,
22502
- mt as R,
22508
+ Rt as H,
22509
+ he as K,
22510
+ bt as R,
22503
22511
  P as S,
22504
22512
  m as U,
22505
22513
  X as a,
22506
- ye as b,
22507
- qe as c,
22508
- xe as d,
22509
- Z as r
22514
+ dt as b,
22515
+ lt as c,
22516
+ pt as d,
22517
+ z as r
22510
22518
  };