@vscada/core 0.0.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.
- package/dist/.tsbuildinfo +1 -0
- package/dist/a11y/contrast.d.ts +11 -0
- package/dist/a11y/contrast.d.ts.map +1 -0
- package/dist/a11y/live-region.d.ts +42 -0
- package/dist/a11y/live-region.d.ts.map +1 -0
- package/dist/a11y/reduced-motion.d.ts +55 -0
- package/dist/a11y/reduced-motion.d.ts.map +1 -0
- package/dist/a11y/static-representation-registry.d.ts +20 -0
- package/dist/a11y/static-representation-registry.d.ts.map +1 -0
- package/dist/bindings/binding-fixture.d.ts +3 -0
- package/dist/bindings/binding-fixture.d.ts.map +1 -0
- package/dist/bindings/binding-types.d.ts +52 -0
- package/dist/bindings/binding-types.d.ts.map +1 -0
- package/dist/bindings/color-ramp.d.ts +9 -0
- package/dist/bindings/color-ramp.d.ts.map +1 -0
- package/dist/bindings/transforms.d.ts +103 -0
- package/dist/bindings/transforms.d.ts.map +1 -0
- package/dist/constants-DMdpoOyH.js +4 -0
- package/dist/contracts/connection-renderer.d.ts +16 -0
- package/dist/contracts/connection-renderer.d.ts.map +1 -0
- package/dist/contracts/connection-state.d.ts +8 -0
- package/dist/contracts/connection-state.d.ts.map +1 -0
- package/dist/contracts/handles.d.ts +83 -0
- package/dist/contracts/handles.d.ts.map +1 -0
- package/dist/contracts/primitive.d.ts +37 -0
- package/dist/contracts/primitive.d.ts.map +1 -0
- package/dist/contracts/renderer.d.ts +34 -0
- package/dist/contracts/renderer.d.ts.map +1 -0
- package/dist/contracts/tag-value.d.ts +33 -0
- package/dist/contracts/tag-value.d.ts.map +1 -0
- package/dist/contracts/time-source.d.ts +14 -0
- package/dist/contracts/time-source.d.ts.map +1 -0
- package/dist/custom-elements.json +1068 -0
- package/dist/export/svg-export.d.ts +24 -0
- package/dist/export/svg-export.d.ts.map +1 -0
- package/dist/fsm/fsm.d.ts +45 -0
- package/dist/fsm/fsm.d.ts.map +1 -0
- package/dist/fsm/tween.d.ts +39 -0
- package/dist/fsm/tween.d.ts.map +1 -0
- package/dist/import/load-svg-import.d.ts +22 -0
- package/dist/import/load-svg-import.d.ts.map +1 -0
- package/dist/import/svg-source-registry.d.ts +4 -0
- package/dist/import/svg-source-registry.d.ts.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4549 -0
- package/dist/interaction/gesture-arbiter.d.ts +20 -0
- package/dist/interaction/gesture-arbiter.d.ts.map +1 -0
- package/dist/interaction/hit-area.d.ts +44 -0
- package/dist/interaction/hit-area.d.ts.map +1 -0
- package/dist/interaction/pan-zoom-gestures.d.ts +43 -0
- package/dist/interaction/pan-zoom-gestures.d.ts.map +1 -0
- package/dist/interaction/pointer-pipeline.d.ts +38 -0
- package/dist/interaction/pointer-pipeline.d.ts.map +1 -0
- package/dist/license/console-notice.d.ts +15 -0
- package/dist/license/console-notice.d.ts.map +1 -0
- package/dist/license/format.d.ts +29 -0
- package/dist/license/format.d.ts.map +1 -0
- package/dist/license/state.d.ts +43 -0
- package/dist/license/state.d.ts.map +1 -0
- package/dist/license/vendor-keys.d.ts +12 -0
- package/dist/license/vendor-keys.d.ts.map +1 -0
- package/dist/license/verify-fallback.d.ts +31 -0
- package/dist/license/verify-fallback.d.ts.map +1 -0
- package/dist/license/verify-webcrypto.d.ts +4 -0
- package/dist/license/verify-webcrypto.d.ts.map +1 -0
- package/dist/license/watermark.d.ts +20 -0
- package/dist/license/watermark.d.ts.map +1 -0
- package/dist/media/registry.d.ts +97 -0
- package/dist/media/registry.d.ts.map +1 -0
- package/dist/registry/connection-registry.d.ts +5 -0
- package/dist/registry/connection-registry.d.ts.map +1 -0
- package/dist/registry/element-catalog.d.ts +805 -0
- package/dist/registry/element-catalog.d.ts.map +1 -0
- package/dist/registry/primitive-registry.d.ts +7 -0
- package/dist/registry/primitive-registry.d.ts.map +1 -0
- package/dist/registry/theme-registry.d.ts +6 -0
- package/dist/registry/theme-registry.d.ts.map +1 -0
- package/dist/registry.d.ts +8 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/scada-view.d.ts +322 -0
- package/dist/scada-view.d.ts.map +1 -0
- package/dist/scene/connection-geometry.d.ts +95 -0
- package/dist/scene/connection-geometry.d.ts.map +1 -0
- package/dist/scene/constants.d.ts +10 -0
- package/dist/scene/constants.d.ts.map +1 -0
- package/dist/scene/crossing-jumps.d.ts +85 -0
- package/dist/scene/crossing-jumps.d.ts.map +1 -0
- package/dist/scene/dev-validate.d.ts +24 -0
- package/dist/scene/dev-validate.d.ts.map +1 -0
- package/dist/scene/errors.d.ts +15 -0
- package/dist/scene/errors.d.ts.map +1 -0
- package/dist/scene/groups.d.ts +90 -0
- package/dist/scene/groups.d.ts.map +1 -0
- package/dist/scene/lane-offset.d.ts +69 -0
- package/dist/scene/lane-offset.d.ts.map +1 -0
- package/dist/scene/orthogonal-router.d.ts +63 -0
- package/dist/scene/orthogonal-router.d.ts.map +1 -0
- package/dist/scene/scene-schema.d.ts +881 -0
- package/dist/scene/scene-schema.d.ts.map +1 -0
- package/dist/scene/structural-validator.d.ts +25 -0
- package/dist/scene/structural-validator.d.ts.map +1 -0
- package/dist/scene/validate-scene.d.ts +26 -0
- package/dist/scene/validate-scene.d.ts.map +1 -0
- package/dist/scene-authoring.d.ts +12 -0
- package/dist/scene-authoring.d.ts.map +1 -0
- package/dist/scene-authoring.js +952 -0
- package/dist/scheduler/alarm-band.d.ts +33 -0
- package/dist/scheduler/alarm-band.d.ts.map +1 -0
- package/dist/scheduler/animation-registry.d.ts +38 -0
- package/dist/scheduler/animation-registry.d.ts.map +1 -0
- package/dist/scheduler/lod.d.ts +25 -0
- package/dist/scheduler/lod.d.ts.map +1 -0
- package/dist/scheduler/quality-overlay.d.ts +19 -0
- package/dist/scheduler/quality-overlay.d.ts.map +1 -0
- package/dist/scheduler/quality.d.ts +15 -0
- package/dist/scheduler/quality.d.ts.map +1 -0
- package/dist/scheduler/scheduler.d.ts +243 -0
- package/dist/scheduler/scheduler.d.ts.map +1 -0
- package/dist/scheduler/visual-state-resolver.d.ts +31 -0
- package/dist/scheduler/visual-state-resolver.d.ts.map +1 -0
- package/dist/store/value-store.d.ts +65 -0
- package/dist/store/value-store.d.ts.map +1 -0
- package/dist/tokens.d.ts +703 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/topology/graph.d.ts +33 -0
- package/dist/topology/graph.d.ts.map +1 -0
- package/dist/topology/group-collapse.d.ts +15 -0
- package/dist/topology/group-collapse.d.ts.map +1 -0
- package/dist/topology/inference.d.ts +71 -0
- package/dist/topology/inference.d.ts.map +1 -0
- package/dist/topology/traversal.d.ts +29 -0
- package/dist/topology/traversal.d.ts.map +1 -0
- package/dist/topology/upstream-highlight.d.ts +75 -0
- package/dist/topology/upstream-highlight.d.ts.map +1 -0
- package/dist/units/formatter.d.ts +22 -0
- package/dist/units/formatter.d.ts.map +1 -0
- package/dist/units/registry.d.ts +21 -0
- package/dist/units/registry.d.ts.map +1 -0
- package/dist/view/group-view-state.d.ts +77 -0
- package/dist/view/group-view-state.d.ts.map +1 -0
- package/dist/view/viewport-state.d.ts +112 -0
- package/dist/view/viewport-state.d.ts.map +1 -0
- package/dist/vscada.umd.cjs +45 -0
- package/package.json +37 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4549 @@
|
|
|
1
|
+
import { t as e } from "./constants-DMdpoOyH.js";
|
|
2
|
+
import { LitElement as t, css as n, html as r } from "lit";
|
|
3
|
+
//#region src/scene/errors.ts
|
|
4
|
+
var i = [
|
|
5
|
+
"MISSING_VERSION",
|
|
6
|
+
"UNSUPPORTED_VERSION",
|
|
7
|
+
"BAD_SHAPE",
|
|
8
|
+
"DUPLICATE_ID",
|
|
9
|
+
"UNKNOWN_TYPE",
|
|
10
|
+
"UNRESOLVED_PORT",
|
|
11
|
+
"UNRESOLVED_TOPOLOGY_REF",
|
|
12
|
+
"AMBIGUOUS_GROUP_PORT_MAP",
|
|
13
|
+
"UNRESOLVED_GROUP_PORT_MAP",
|
|
14
|
+
"AMBIGUOUS_GROUP_CHILD"
|
|
15
|
+
];
|
|
16
|
+
function a(e, t, n) {
|
|
17
|
+
return {
|
|
18
|
+
code: e,
|
|
19
|
+
message: t,
|
|
20
|
+
path: n
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/scene/structural-validator.ts
|
|
25
|
+
var o = new Set(e), s = /* @__PURE__ */ new Set(["off-page", "svg-import"]);
|
|
26
|
+
function c(e) {
|
|
27
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
28
|
+
}
|
|
29
|
+
function l(e) {
|
|
30
|
+
return c(e) && typeof e.x == "number" && Number.isFinite(e.x) && typeof e.y == "number" && Number.isFinite(e.y) && typeof e.dir == "string" && [
|
|
31
|
+
"up",
|
|
32
|
+
"down",
|
|
33
|
+
"left",
|
|
34
|
+
"right"
|
|
35
|
+
].includes(e.dir);
|
|
36
|
+
}
|
|
37
|
+
function u(e, t) {
|
|
38
|
+
if (e === void 0) return null;
|
|
39
|
+
if (!c(e)) return a("BAD_SHAPE", `${t}.ports must be an object of named ports`, `${t}.ports`);
|
|
40
|
+
for (let [n, r] of Object.entries(e)) if (!l(r)) return a("BAD_SHAPE", `${t}.ports.${n} must be { x: number, y: number, dir: 'up'|'down'|'left'|'right' }`, `${t}.ports.${n}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function d(e, t) {
|
|
44
|
+
if (!c(e)) return {
|
|
45
|
+
ok: !1,
|
|
46
|
+
error: a("BAD_SHAPE", "Scene must be an object", "")
|
|
47
|
+
};
|
|
48
|
+
if (e.version === void 0 || e.version === null || e.version === "") return {
|
|
49
|
+
ok: !1,
|
|
50
|
+
error: a("MISSING_VERSION", "Scene is missing required \"version\" field", "version")
|
|
51
|
+
};
|
|
52
|
+
if (typeof e.version != "string" || !o.has(e.version)) return {
|
|
53
|
+
ok: !1,
|
|
54
|
+
error: a("UNSUPPORTED_VERSION", `Scene version "${String(e.version)}" is not supported`, "version")
|
|
55
|
+
};
|
|
56
|
+
if (e.id === void 0 || typeof e.id != "string" || e.id.length === 0) return {
|
|
57
|
+
ok: !1,
|
|
58
|
+
error: a("BAD_SHAPE", "Scene is missing required string \"id\"", "id")
|
|
59
|
+
};
|
|
60
|
+
if (!c(e.canvas) || typeof e.canvas.width != "number" || !Number.isFinite(e.canvas.width) || typeof e.canvas.height != "number" || !Number.isFinite(e.canvas.height)) return {
|
|
61
|
+
ok: !1,
|
|
62
|
+
error: a("BAD_SHAPE", "Scene \"canvas\" must be { width: number, height: number }", "canvas")
|
|
63
|
+
};
|
|
64
|
+
let n = e.elements ?? [];
|
|
65
|
+
if (!Array.isArray(n)) return {
|
|
66
|
+
ok: !1,
|
|
67
|
+
error: a("BAD_SHAPE", "Scene \"elements\" must be an array", "elements")
|
|
68
|
+
};
|
|
69
|
+
let r = e.groups ?? [];
|
|
70
|
+
if (!Array.isArray(r)) return {
|
|
71
|
+
ok: !1,
|
|
72
|
+
error: a("BAD_SHAPE", "Scene \"groups\" must be an array", "groups")
|
|
73
|
+
};
|
|
74
|
+
let i = e.connections ?? [];
|
|
75
|
+
if (!Array.isArray(i)) return {
|
|
76
|
+
ok: !1,
|
|
77
|
+
error: a("BAD_SHAPE", "Scene \"connections\" must be an array", "connections")
|
|
78
|
+
};
|
|
79
|
+
let l = [];
|
|
80
|
+
for (let e = 0; e < n.length; e++) {
|
|
81
|
+
let t = n[e], r = `elements[${e}]`;
|
|
82
|
+
if (!c(t) || typeof t.id != "string" || t.id.length === 0) return {
|
|
83
|
+
ok: !1,
|
|
84
|
+
error: a("BAD_SHAPE", `${r} must be an object with a non-empty string "id"`, `${r}.id`)
|
|
85
|
+
};
|
|
86
|
+
if (typeof t.type != "string" || t.type.length === 0) return {
|
|
87
|
+
ok: !1,
|
|
88
|
+
error: a("BAD_SHAPE", `${r} must declare a non-empty string "type"`, `${r}.type`)
|
|
89
|
+
};
|
|
90
|
+
let i = u(t.ports, r);
|
|
91
|
+
if (i) return {
|
|
92
|
+
ok: !1,
|
|
93
|
+
error: i
|
|
94
|
+
};
|
|
95
|
+
l.push({
|
|
96
|
+
id: t.id,
|
|
97
|
+
type: t.type,
|
|
98
|
+
ports: c(t.ports) ? t.ports : {}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
for (let e = 0; e < r.length; e++) {
|
|
102
|
+
let t = r[e], n = `groups[${e}]`;
|
|
103
|
+
if (!c(t) || typeof t.id != "string" || t.id.length === 0) return {
|
|
104
|
+
ok: !1,
|
|
105
|
+
error: a("BAD_SHAPE", `${n} must be an object with a non-empty string "id"`, `${n}.id`)
|
|
106
|
+
};
|
|
107
|
+
if (t.children !== void 0 && !Array.isArray(t.children)) return {
|
|
108
|
+
ok: !1,
|
|
109
|
+
error: a("BAD_SHAPE", `${n}.children must be an array of element ids`, `${n}.children`)
|
|
110
|
+
};
|
|
111
|
+
let i = u(t.ports, n);
|
|
112
|
+
if (i) return {
|
|
113
|
+
ok: !1,
|
|
114
|
+
error: i
|
|
115
|
+
};
|
|
116
|
+
l.push({
|
|
117
|
+
id: t.id,
|
|
118
|
+
type: "group",
|
|
119
|
+
ports: c(t.ports) ? t.ports : {}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
let d = /* @__PURE__ */ new Map();
|
|
123
|
+
for (let e of l) {
|
|
124
|
+
if (d.get(e.id) !== void 0) return {
|
|
125
|
+
ok: !1,
|
|
126
|
+
error: a("DUPLICATE_ID", `Duplicate element/group id "${e.id}"`, `id:${e.id}`)
|
|
127
|
+
};
|
|
128
|
+
d.set(e.id, e.id);
|
|
129
|
+
}
|
|
130
|
+
let f = new Map(l.map((e) => [e.id, e])), p = /* @__PURE__ */ new Map();
|
|
131
|
+
for (let e = 0; e < r.length; e++) {
|
|
132
|
+
let t = r[e], n = `groups[${e}]`, i = t.id, o = Array.isArray(t.children) ? t.children.filter((e) => typeof e == "string") : [], s = c(t.ports) ? t.ports : {}, l = c(t.portMap) ? t.portMap : {};
|
|
133
|
+
for (let e of o) {
|
|
134
|
+
let t = p.get(e);
|
|
135
|
+
if (t !== void 0) return {
|
|
136
|
+
ok: !1,
|
|
137
|
+
error: a("AMBIGUOUS_GROUP_CHILD", `Child id "${e}" is declared under more than one group ("${t}" and "${i}")`, `${n}.children`)
|
|
138
|
+
};
|
|
139
|
+
p.set(e, i);
|
|
140
|
+
}
|
|
141
|
+
let u = /* @__PURE__ */ new Map();
|
|
142
|
+
for (let [e, t] of Object.entries(l)) {
|
|
143
|
+
let r = `${n}.portMap.${e}`;
|
|
144
|
+
if (typeof t != "string") continue;
|
|
145
|
+
if (!(e in s)) return {
|
|
146
|
+
ok: !1,
|
|
147
|
+
error: a("UNRESOLVED_GROUP_PORT_MAP", `Group "${i}" portMap key "${e}" does not match any port declared on the group itself`, r)
|
|
148
|
+
};
|
|
149
|
+
let c = t.indexOf("."), l = c < 0 ? t : t.slice(0, c), d = c < 0 ? "" : t.slice(c + 1), p = l.length > 0 ? f.get(l) : void 0;
|
|
150
|
+
if (c < 0 || l.length === 0 || d.length === 0 || !o.includes(l) || !p || !(d in p.ports)) return {
|
|
151
|
+
ok: !1,
|
|
152
|
+
error: a("UNRESOLVED_GROUP_PORT_MAP", `Group "${i}" portMap["${e}"]="${t}" does not resolve to a real port on a child declared in this group's "children"`, r)
|
|
153
|
+
};
|
|
154
|
+
let m = `${l}.${d}`, h = u.get(m);
|
|
155
|
+
if (h !== void 0) return {
|
|
156
|
+
ok: !1,
|
|
157
|
+
error: a("AMBIGUOUS_GROUP_PORT_MAP", `Group "${i}" maps both "${h}" and "${e}" to the same interior port "${m}"`, r)
|
|
158
|
+
};
|
|
159
|
+
u.set(m, e);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
for (let e = 0; e < n.length; e++) {
|
|
163
|
+
let r = n[e], i = r.type;
|
|
164
|
+
if (!s.has(i) && !t.has(i)) return {
|
|
165
|
+
ok: !1,
|
|
166
|
+
error: a("UNKNOWN_TYPE", `Element "${r.id}" has unknown type "${i}" — is its primitive group registered via registerPrimitives()?`, `elements[${e}].type`)
|
|
167
|
+
};
|
|
168
|
+
if (i === "off-page") {
|
|
169
|
+
let t = `elements[${e}]`, n = r.target;
|
|
170
|
+
if (!c(n) || typeof n.scene != "string" || typeof n.port != "string") return {
|
|
171
|
+
ok: !1,
|
|
172
|
+
error: a("BAD_SHAPE", `${t} (off-page) must declare "target": { scene: string, port: string }`, `${t}.target`)
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
for (let e = 0; e < i.length; e++) {
|
|
177
|
+
let t = i[e], n = `connections[${e}]`;
|
|
178
|
+
if (!c(t) || typeof t.id != "string" || t.id.length === 0) return {
|
|
179
|
+
ok: !1,
|
|
180
|
+
error: a("BAD_SHAPE", `${n} must be an object with a non-empty string "id"`, `${n}.id`)
|
|
181
|
+
};
|
|
182
|
+
for (let e of ["from", "to"]) {
|
|
183
|
+
let r = t[e], i = `${n}.${e}`;
|
|
184
|
+
if (typeof r != "string" || !r.includes(".")) return {
|
|
185
|
+
ok: !1,
|
|
186
|
+
error: a("BAD_SHAPE", `${i} must be an "ELEM.port" reference`, i)
|
|
187
|
+
};
|
|
188
|
+
let o = r.indexOf("."), s = r.slice(0, o), c = r.slice(o + 1);
|
|
189
|
+
if (s.length === 0 || c.length === 0) return {
|
|
190
|
+
ok: !1,
|
|
191
|
+
error: a("BAD_SHAPE", `${i} must be an "ELEM.port" reference`, i)
|
|
192
|
+
};
|
|
193
|
+
let l = f.get(s);
|
|
194
|
+
if (!l) return {
|
|
195
|
+
ok: !1,
|
|
196
|
+
error: a("UNRESOLVED_PORT", `Connection "${t.id}" ${e}="${r}" references element "${s}" but no such element or group exists`, i)
|
|
197
|
+
};
|
|
198
|
+
if (!(c in l.ports)) return {
|
|
199
|
+
ok: !1,
|
|
200
|
+
error: a("UNRESOLVED_PORT", `Connection "${t.id}" ${e}="${r}" references port "${c}" but "${s}" declares no such port`, i)
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
let m = c(e.topology) ? e.topology : {
|
|
205
|
+
nodes: [],
|
|
206
|
+
edges: []
|
|
207
|
+
}, h = Array.isArray(m.nodes) ? m.nodes : [], g = Array.isArray(m.edges) ? m.edges : [], _ = /* @__PURE__ */ new Set();
|
|
208
|
+
for (let e of i) c(e) && typeof e.id == "string" && _.add(e.id);
|
|
209
|
+
for (let e = 0; e < h.length; e++) {
|
|
210
|
+
let t = h[e], n = `topology.nodes[${e}]`;
|
|
211
|
+
if (typeof t != "string" || !f.has(t)) return {
|
|
212
|
+
ok: !1,
|
|
213
|
+
error: a("UNRESOLVED_TOPOLOGY_REF", `topology.nodes[${e}] references "${String(t)}" but no such element or group exists`, n)
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
for (let e = 0; e < g.length; e++) {
|
|
217
|
+
let t = g[e], n = `topology.edges[${e}]`;
|
|
218
|
+
if (!c(t) || typeof t.id != "string" || t.id.length === 0) return {
|
|
219
|
+
ok: !1,
|
|
220
|
+
error: a("BAD_SHAPE", `${n} must be an object with a non-empty string "id"`, `${n}.id`)
|
|
221
|
+
};
|
|
222
|
+
if (!_.has(t.id)) return {
|
|
223
|
+
ok: !1,
|
|
224
|
+
error: a("UNRESOLVED_TOPOLOGY_REF", `topology edge "${t.id}" does not reference any connection with that id`, `${n}.id`)
|
|
225
|
+
};
|
|
226
|
+
for (let e of ["from", "to"]) {
|
|
227
|
+
let r = t[e], i = `${n}.${e}`;
|
|
228
|
+
if (typeof r != "string" || !f.has(r)) return {
|
|
229
|
+
ok: !1,
|
|
230
|
+
error: a("UNRESOLVED_TOPOLOGY_REF", `topology edge "${t.id}" ${e}="${String(r)}" references an element/group that does not exist`, i)
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (m.sources !== void 0) {
|
|
235
|
+
if (!Array.isArray(m.sources)) return {
|
|
236
|
+
ok: !1,
|
|
237
|
+
error: a("BAD_SHAPE", "topology.sources must be an array of node ids", "topology.sources")
|
|
238
|
+
};
|
|
239
|
+
let e = new Set(h.filter((e) => typeof e == "string"));
|
|
240
|
+
for (let t = 0; t < m.sources.length; t++) {
|
|
241
|
+
let n = m.sources[t], r = `topology.sources[${t}]`;
|
|
242
|
+
if (typeof n != "string" || !e.has(n)) return {
|
|
243
|
+
ok: !1,
|
|
244
|
+
error: a("UNRESOLVED_TOPOLOGY_REF", `topology.sources[${t}] references "${String(n)}" but it is not declared in topology.nodes`, r)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
let v = n.map((e) => {
|
|
249
|
+
let t = e;
|
|
250
|
+
return {
|
|
251
|
+
...t,
|
|
252
|
+
bindings: Array.isArray(t.bindings) ? t.bindings : [],
|
|
253
|
+
thresholds: Array.isArray(t.thresholds) ? t.thresholds : []
|
|
254
|
+
};
|
|
255
|
+
}), y = i.map((e) => {
|
|
256
|
+
let t = e;
|
|
257
|
+
return {
|
|
258
|
+
...t,
|
|
259
|
+
bindings: Array.isArray(t.bindings) ? t.bindings : []
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
return {
|
|
263
|
+
ok: !0,
|
|
264
|
+
scene: {
|
|
265
|
+
...e,
|
|
266
|
+
elements: v,
|
|
267
|
+
groups: r,
|
|
268
|
+
connections: y,
|
|
269
|
+
topology: e.topology ?? {
|
|
270
|
+
nodes: [],
|
|
271
|
+
edges: []
|
|
272
|
+
},
|
|
273
|
+
media: e.media ?? {},
|
|
274
|
+
inferFlow: e.inferFlow === !0
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/scene/dev-validate.ts
|
|
280
|
+
async function f(e) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/registry/primitive-registry.ts
|
|
285
|
+
var p = /* @__PURE__ */ new Map();
|
|
286
|
+
function m(...e) {
|
|
287
|
+
for (let t of e) for (let [e, n] of Object.entries(t.primitives)) p.has(e) && p.get(e) !== n && console.warn(`registerPrimitives: element type "${e}" is already registered — the new registration will overwrite it.`), p.set(e, n);
|
|
288
|
+
}
|
|
289
|
+
function h(e) {
|
|
290
|
+
return p.get(e);
|
|
291
|
+
}
|
|
292
|
+
function g() {
|
|
293
|
+
return new Set(p.keys());
|
|
294
|
+
}
|
|
295
|
+
//#endregion
|
|
296
|
+
//#region src/registry.ts
|
|
297
|
+
function _() {
|
|
298
|
+
return g();
|
|
299
|
+
}
|
|
300
|
+
//#endregion
|
|
301
|
+
//#region src/registry/connection-registry.ts
|
|
302
|
+
var v;
|
|
303
|
+
function y(e) {
|
|
304
|
+
v = e;
|
|
305
|
+
}
|
|
306
|
+
function ee() {
|
|
307
|
+
return v;
|
|
308
|
+
}
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/registry/theme-registry.ts
|
|
311
|
+
var b = /* @__PURE__ */ new Map();
|
|
312
|
+
function x(...e) {
|
|
313
|
+
for (let t of e) b.set(t.name, t);
|
|
314
|
+
}
|
|
315
|
+
function S(e) {
|
|
316
|
+
return b.get(e) ?? {
|
|
317
|
+
name: e,
|
|
318
|
+
palette: {}
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
//#endregion
|
|
322
|
+
//#region src/contracts/time-source.ts
|
|
323
|
+
var C = {
|
|
324
|
+
now: () => performance.now(),
|
|
325
|
+
onTick(e) {
|
|
326
|
+
let t = requestAnimationFrame(function n(r) {
|
|
327
|
+
e(r), t = requestAnimationFrame(n);
|
|
328
|
+
});
|
|
329
|
+
return () => cancelAnimationFrame(t);
|
|
330
|
+
}
|
|
331
|
+
}, w = {
|
|
332
|
+
setTransform(e, t) {
|
|
333
|
+
e.style.transform = t;
|
|
334
|
+
},
|
|
335
|
+
setAttr(e, t, n) {
|
|
336
|
+
e.setAttribute(t, n);
|
|
337
|
+
},
|
|
338
|
+
setCssVar(e, t, n) {
|
|
339
|
+
e.style.setProperty(t, n);
|
|
340
|
+
},
|
|
341
|
+
setText(e, t) {
|
|
342
|
+
e.textContent = t;
|
|
343
|
+
},
|
|
344
|
+
animateTransform(e, t, n) {
|
|
345
|
+
let r = e.animate(t.map((e) => ({ transform: e })), {
|
|
346
|
+
duration: n,
|
|
347
|
+
iterations: Infinity,
|
|
348
|
+
easing: "linear"
|
|
349
|
+
});
|
|
350
|
+
return {
|
|
351
|
+
setPlaybackRate(e) {
|
|
352
|
+
r.playbackRate = e;
|
|
353
|
+
},
|
|
354
|
+
pause() {
|
|
355
|
+
r.pause();
|
|
356
|
+
},
|
|
357
|
+
resume() {
|
|
358
|
+
r.play();
|
|
359
|
+
},
|
|
360
|
+
seek(e) {
|
|
361
|
+
r.currentTime = e;
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
}, T = {
|
|
366
|
+
up: {
|
|
367
|
+
x: 0,
|
|
368
|
+
y: -1
|
|
369
|
+
},
|
|
370
|
+
down: {
|
|
371
|
+
x: 0,
|
|
372
|
+
y: 1
|
|
373
|
+
},
|
|
374
|
+
left: {
|
|
375
|
+
x: -1,
|
|
376
|
+
y: 0
|
|
377
|
+
},
|
|
378
|
+
right: {
|
|
379
|
+
x: 1,
|
|
380
|
+
y: 0
|
|
381
|
+
}
|
|
382
|
+
};
|
|
383
|
+
function E(e) {
|
|
384
|
+
return T[e];
|
|
385
|
+
}
|
|
386
|
+
function D(e) {
|
|
387
|
+
return e === "left" || e === "right" ? "h" : "v";
|
|
388
|
+
}
|
|
389
|
+
function te(e, t, n, r) {
|
|
390
|
+
let i = {
|
|
391
|
+
x: e.x + E(t).x * 24,
|
|
392
|
+
y: e.y + E(t).y * 24
|
|
393
|
+
}, a = {
|
|
394
|
+
x: n.x + E(r).x * 24,
|
|
395
|
+
y: n.y + E(r).y * 24
|
|
396
|
+
}, o = ne(t, r, i, a);
|
|
397
|
+
for (let t of o) {
|
|
398
|
+
let r = ie([
|
|
399
|
+
e,
|
|
400
|
+
i,
|
|
401
|
+
...t,
|
|
402
|
+
a,
|
|
403
|
+
n
|
|
404
|
+
]);
|
|
405
|
+
if (!re(r)) return r;
|
|
406
|
+
}
|
|
407
|
+
return ie([
|
|
408
|
+
e,
|
|
409
|
+
i,
|
|
410
|
+
...o[o.length - 1] ?? [],
|
|
411
|
+
a,
|
|
412
|
+
n
|
|
413
|
+
]);
|
|
414
|
+
}
|
|
415
|
+
function ne(e, t, n, r) {
|
|
416
|
+
if (D(e) !== D(t)) return D(e) === "v" ? [[{
|
|
417
|
+
x: n.x,
|
|
418
|
+
y: r.y
|
|
419
|
+
}], [{
|
|
420
|
+
x: r.x,
|
|
421
|
+
y: n.y
|
|
422
|
+
}]] : [[{
|
|
423
|
+
x: r.x,
|
|
424
|
+
y: n.y
|
|
425
|
+
}], [{
|
|
426
|
+
x: n.x,
|
|
427
|
+
y: r.y
|
|
428
|
+
}]];
|
|
429
|
+
let i = D(e) === "v", a = (e) => i ? e.y : e.x, o = (e) => i ? e.x : e.y, s = (e, t) => i ? {
|
|
430
|
+
x: t,
|
|
431
|
+
y: e
|
|
432
|
+
} : {
|
|
433
|
+
x: e,
|
|
434
|
+
y: t
|
|
435
|
+
}, c = a(n) === a(r) ? [] : [s(a(n), o(n) + 24), s(a(r), o(n) + 24)];
|
|
436
|
+
return [[{
|
|
437
|
+
x: r.x,
|
|
438
|
+
y: n.y
|
|
439
|
+
}], c];
|
|
440
|
+
}
|
|
441
|
+
function re(e) {
|
|
442
|
+
for (let t = 0; t < e.length - 1; t++) for (let n = t + 1; n < e.length - 1; n++) {
|
|
443
|
+
let r = e[t], i = e[t + 1], a = e[n], o = e[n + 1], s = r.x === i.x;
|
|
444
|
+
if (s === (a.x === o.x)) if (s) {
|
|
445
|
+
if (r.x !== a.x) continue;
|
|
446
|
+
let e = Math.min(r.y, i.y), t = Math.max(r.y, i.y), n = Math.min(a.y, o.y);
|
|
447
|
+
if (e < Math.max(a.y, o.y) && n < t) return !0;
|
|
448
|
+
} else {
|
|
449
|
+
if (r.y !== a.y) continue;
|
|
450
|
+
let e = Math.min(r.x, i.x), t = Math.max(r.x, i.x), n = Math.min(a.x, o.x);
|
|
451
|
+
if (e < Math.max(a.x, o.x) && n < t) return !0;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
return !1;
|
|
455
|
+
}
|
|
456
|
+
function ie(e) {
|
|
457
|
+
let t = e.slice(), n = !0;
|
|
458
|
+
for (; n;) {
|
|
459
|
+
n = !1;
|
|
460
|
+
for (let e = 1; e < t.length - 1; e++) {
|
|
461
|
+
let r = t[e - 1], i = t[e + 1], a = t[e];
|
|
462
|
+
if (a.x === r.x && a.y === r.y || a.x === i.x && a.y === i.y) {
|
|
463
|
+
t.splice(e, 1), n = !0;
|
|
464
|
+
break;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (!n) for (let e = 1; e < t.length - 1; e++) {
|
|
468
|
+
let r = t[e - 1], i = t[e], a = t[e + 1], o = i.x - r.x, s = i.y - r.y, c = a.x - i.x, l = a.y - i.y, u = o * l - s * c, d = o * c + s * l, f = o * o + s * s + c * c + l * l || 1;
|
|
469
|
+
if (Math.abs(u) < 1e-9 * f && d > 0) {
|
|
470
|
+
t.splice(e, 1), n = !0;
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return t;
|
|
476
|
+
}
|
|
477
|
+
//#endregion
|
|
478
|
+
//#region src/scene/lane-offset.ts
|
|
479
|
+
var ae = 24, oe = 24 * 1.5;
|
|
480
|
+
function se(e, t, n = 36) {
|
|
481
|
+
if (!t || e.length < 2) return e;
|
|
482
|
+
let r = e[0], i = e[e.length - 1], a = le(t * n, e);
|
|
483
|
+
if (a === 0) return e;
|
|
484
|
+
let o = e.length === 2 ? ce(r, i, a) : e;
|
|
485
|
+
if (o.length === 2) return e;
|
|
486
|
+
let s = fe(ue(o, a));
|
|
487
|
+
return s[0] = r, s[s.length - 1] = i, s;
|
|
488
|
+
}
|
|
489
|
+
function ce(e, t, n) {
|
|
490
|
+
let r = t.x - e.x, i = t.y - e.y, a = Math.hypot(r, i);
|
|
491
|
+
if (a < 1e-9) return [e, t];
|
|
492
|
+
let o = r / a, s = i / a, c = Math.min(Math.max(24, Math.abs(n)), a / 3);
|
|
493
|
+
return [
|
|
494
|
+
e,
|
|
495
|
+
{
|
|
496
|
+
x: e.x + o * c,
|
|
497
|
+
y: e.y + s * c
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
x: t.x - o * c,
|
|
501
|
+
y: t.y - s * c
|
|
502
|
+
},
|
|
503
|
+
t
|
|
504
|
+
];
|
|
505
|
+
}
|
|
506
|
+
function le(e, t) {
|
|
507
|
+
if (t.length < 3) return e;
|
|
508
|
+
let n = Infinity;
|
|
509
|
+
for (let e = 0; e < t.length - 1; e++) {
|
|
510
|
+
let r = Math.hypot(t[e + 1].x - t[e].x, t[e + 1].y - t[e].y);
|
|
511
|
+
r > 1e-9 && (n = Math.min(n, r));
|
|
512
|
+
}
|
|
513
|
+
if (!Number.isFinite(n)) return e;
|
|
514
|
+
let r = n / 2;
|
|
515
|
+
return Math.sign(e) * Math.min(Math.abs(e), r);
|
|
516
|
+
}
|
|
517
|
+
function ue(e, t) {
|
|
518
|
+
let n = [];
|
|
519
|
+
for (let t = 0; t < e.length - 1; t++) {
|
|
520
|
+
let r = e[t], i = e[t + 1], a = Math.hypot(i.x - r.x, i.y - r.y);
|
|
521
|
+
n.push(a > 1e-9 ? {
|
|
522
|
+
x: (i.x - r.x) / a,
|
|
523
|
+
y: (i.y - r.y) / a
|
|
524
|
+
} : null);
|
|
525
|
+
}
|
|
526
|
+
let r = de(n), i = [];
|
|
527
|
+
for (let n = 0; n < e.length - 1; n++) {
|
|
528
|
+
let a = e[n], o = e[n + 1], s = r[n], c = {
|
|
529
|
+
x: -s.y * t,
|
|
530
|
+
y: s.x * t
|
|
531
|
+
};
|
|
532
|
+
i.push({
|
|
533
|
+
from: {
|
|
534
|
+
x: a.x + c.x,
|
|
535
|
+
y: a.y + c.y
|
|
536
|
+
},
|
|
537
|
+
to: {
|
|
538
|
+
x: o.x + c.x,
|
|
539
|
+
y: o.y + c.y
|
|
540
|
+
},
|
|
541
|
+
dir: s
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
return i;
|
|
545
|
+
}
|
|
546
|
+
function de(e) {
|
|
547
|
+
let t = e.slice();
|
|
548
|
+
for (let e = 0; e < t.length; e++) {
|
|
549
|
+
if (t[e]) continue;
|
|
550
|
+
let n = null;
|
|
551
|
+
for (let r = e + 1; r < t.length && !n; r++) n = t[r];
|
|
552
|
+
if (!n) for (let r = e - 1; r >= 0 && !n; r--) n = t[r];
|
|
553
|
+
t[e] = n ?? {
|
|
554
|
+
x: 0,
|
|
555
|
+
y: 0
|
|
556
|
+
};
|
|
557
|
+
}
|
|
558
|
+
return t;
|
|
559
|
+
}
|
|
560
|
+
function fe(e) {
|
|
561
|
+
let t = [e[0].from];
|
|
562
|
+
for (let n = 0; n < e.length - 1; n++) {
|
|
563
|
+
let r = e[n], i = e[n + 1];
|
|
564
|
+
t.push(pe(r.from, r.dir, i.from, i.dir) ?? r.to);
|
|
565
|
+
}
|
|
566
|
+
return t.push(e[e.length - 1].to), t;
|
|
567
|
+
}
|
|
568
|
+
function pe(e, t, n, r) {
|
|
569
|
+
let i = t.x * r.y - t.y * r.x;
|
|
570
|
+
if (Math.abs(i) < 1e-9) return null;
|
|
571
|
+
let a = n.x - e.x, o = n.y - e.y, s = (a * r.y - o * r.x) / i;
|
|
572
|
+
return {
|
|
573
|
+
x: e.x + t.x * s,
|
|
574
|
+
y: e.y + t.y * s
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
//#endregion
|
|
578
|
+
//#region src/media/registry.ts
|
|
579
|
+
function me(e, t) {
|
|
580
|
+
if (e) {
|
|
581
|
+
if (t && e.styles[t]) return e.styles[t];
|
|
582
|
+
if (e.defaultMedium) return e.styles[e.defaultMedium];
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
var he = [
|
|
586
|
+
"animationSpeedFactor",
|
|
587
|
+
"opacity",
|
|
588
|
+
"waveAmplitude",
|
|
589
|
+
"wavePeriod",
|
|
590
|
+
"waveSpeed"
|
|
591
|
+
], ge = ["meniscus"], _e = [
|
|
592
|
+
"sharp",
|
|
593
|
+
"diffuse",
|
|
594
|
+
"none"
|
|
595
|
+
];
|
|
596
|
+
function ve(e) {
|
|
597
|
+
let t = {};
|
|
598
|
+
for (let n of he) {
|
|
599
|
+
let r = e[n];
|
|
600
|
+
typeof r == "number" && (t[n] = r);
|
|
601
|
+
}
|
|
602
|
+
for (let n of ge) {
|
|
603
|
+
let r = e[n];
|
|
604
|
+
typeof r == "boolean" && (t[n] = r);
|
|
605
|
+
}
|
|
606
|
+
return typeof e.color == "string" && (t.color = e.color), typeof e.specular == "string" && _e.includes(e.specular) && (t.specular = e.specular), t;
|
|
607
|
+
}
|
|
608
|
+
function ye(e, t, n) {
|
|
609
|
+
let r = me(e, t);
|
|
610
|
+
if (!r) return r;
|
|
611
|
+
let i = t ? n?.[t] : void 0;
|
|
612
|
+
return i ? {
|
|
613
|
+
...r,
|
|
614
|
+
...ve(i)
|
|
615
|
+
} : r;
|
|
616
|
+
}
|
|
617
|
+
function be(e, t) {
|
|
618
|
+
return e.medium === void 0 ? t.edgeById.get(e.id)?.medium : e.medium;
|
|
619
|
+
}
|
|
620
|
+
//#endregion
|
|
621
|
+
//#region src/scene/connection-geometry.ts
|
|
622
|
+
function xe(e, t, n) {
|
|
623
|
+
let r = we(e.from, t), i = we(e.to, t);
|
|
624
|
+
if (!r || !i) return null;
|
|
625
|
+
let a = {
|
|
626
|
+
x: r.x,
|
|
627
|
+
y: r.y
|
|
628
|
+
}, o = {
|
|
629
|
+
x: i.x,
|
|
630
|
+
y: i.y
|
|
631
|
+
}, s = Ce(e.bindings ?? []), c = e.laneOffset, l = n ? be(e, n) : e.medium, u = e.routing ?? "orthogonal", d = !!e.waypoints && e.waypoints.length > 0;
|
|
632
|
+
if ((u === "manual" || u === "orthogonal") && d) {
|
|
633
|
+
let t = e.cornerRadius ?? 0;
|
|
634
|
+
return Se(se([
|
|
635
|
+
a,
|
|
636
|
+
...e.waypoints ?? [],
|
|
637
|
+
o
|
|
638
|
+
], c), t, l, s);
|
|
639
|
+
}
|
|
640
|
+
if (u === "orthogonal") {
|
|
641
|
+
let t = e.cornerRadius ?? 12;
|
|
642
|
+
return Se(se(te(a, r.dir, o, i.dir), c), t, l, s);
|
|
643
|
+
}
|
|
644
|
+
return {
|
|
645
|
+
segments: Te(se([a, o], c)),
|
|
646
|
+
corners: [],
|
|
647
|
+
medium: l,
|
|
648
|
+
flowBinding: s
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
function Se(e, t, n, r) {
|
|
652
|
+
return e.length <= 2 || t <= 0 ? {
|
|
653
|
+
segments: Te(e),
|
|
654
|
+
corners: [],
|
|
655
|
+
medium: n,
|
|
656
|
+
flowBinding: r
|
|
657
|
+
} : De(e, t, n, r);
|
|
658
|
+
}
|
|
659
|
+
function Ce(e) {
|
|
660
|
+
let t = e.find((e) => e.type === "flow");
|
|
661
|
+
return t ? {
|
|
662
|
+
tag: t.tag,
|
|
663
|
+
min: t.min,
|
|
664
|
+
max: t.max
|
|
665
|
+
} : void 0;
|
|
666
|
+
}
|
|
667
|
+
function we(e, t) {
|
|
668
|
+
let n = e.indexOf(".");
|
|
669
|
+
if (n < 0) return null;
|
|
670
|
+
let r = e.slice(0, n), i = e.slice(n + 1), a = t.elements.find((e) => e.id === r);
|
|
671
|
+
if (!a) return null;
|
|
672
|
+
let o = a.ports[i];
|
|
673
|
+
return o ? {
|
|
674
|
+
x: a.x + o.x,
|
|
675
|
+
y: a.y + o.y,
|
|
676
|
+
dir: o.dir
|
|
677
|
+
} : null;
|
|
678
|
+
}
|
|
679
|
+
function Te(e) {
|
|
680
|
+
let t = [];
|
|
681
|
+
for (let n = 0; n < e.length - 1; n++) t.push({
|
|
682
|
+
from: e[n],
|
|
683
|
+
to: e[n + 1]
|
|
684
|
+
});
|
|
685
|
+
return t;
|
|
686
|
+
}
|
|
687
|
+
function Ee(e, t) {
|
|
688
|
+
let n = [], r = [], i = e[0];
|
|
689
|
+
for (let a = 1; a < e.length - 1; a++) {
|
|
690
|
+
let o = e[a - 1], s = e[a], c = e[a + 1], l = Oe(s, o), u = Oe(c, s), d = je(l), f = je(u), p = Math.min(t, d / 2, f / 2), m = Ae(l, 1 / d), h = Ae(u, 1 / f), g = Oe(s, Ae(m, p)), _ = ke(s, Ae(h, p));
|
|
691
|
+
n.push({
|
|
692
|
+
from: i,
|
|
693
|
+
to: g
|
|
694
|
+
});
|
|
695
|
+
let v = m.x * h.y - m.y * h.x;
|
|
696
|
+
r.push({
|
|
697
|
+
from: g,
|
|
698
|
+
to: _,
|
|
699
|
+
radius: p,
|
|
700
|
+
sweepFlag: v > 0 ? 0 : 1
|
|
701
|
+
}), i = _;
|
|
702
|
+
}
|
|
703
|
+
return n.push({
|
|
704
|
+
from: i,
|
|
705
|
+
to: e[e.length - 1]
|
|
706
|
+
}), {
|
|
707
|
+
segments: n,
|
|
708
|
+
corners: r
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
function De(e, t, n, r) {
|
|
712
|
+
let { segments: i, corners: a } = Ee(e, t);
|
|
713
|
+
return {
|
|
714
|
+
segments: i,
|
|
715
|
+
corners: a,
|
|
716
|
+
medium: n,
|
|
717
|
+
flowBinding: r
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
function Oe(e, t) {
|
|
721
|
+
return {
|
|
722
|
+
x: e.x - t.x,
|
|
723
|
+
y: e.y - t.y
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function ke(e, t) {
|
|
727
|
+
return {
|
|
728
|
+
x: e.x + t.x,
|
|
729
|
+
y: e.y + t.y
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
function Ae(e, t) {
|
|
733
|
+
return {
|
|
734
|
+
x: e.x * t,
|
|
735
|
+
y: e.y * t
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function je(e) {
|
|
739
|
+
return Math.sqrt(e.x * e.x + e.y * e.y);
|
|
740
|
+
}
|
|
741
|
+
function Me(e) {
|
|
742
|
+
if (e.segments.length === 0) return "";
|
|
743
|
+
let t = e.segments[0].from, n = [`M ${t.x} ${t.y}`];
|
|
744
|
+
for (let t = 0; t < e.segments.length; t++) {
|
|
745
|
+
let r = e.segments[t];
|
|
746
|
+
n.push(`L ${r.to.x} ${r.to.y}`);
|
|
747
|
+
let i = e.corners[t];
|
|
748
|
+
i && n.push(`A ${i.radius} ${i.radius} 0 0 ${i.sweepFlag} ${i.to.x} ${i.to.y}`);
|
|
749
|
+
}
|
|
750
|
+
return n.join(" ");
|
|
751
|
+
}
|
|
752
|
+
function Ne(e) {
|
|
753
|
+
return Math.atan2(e.to.y - e.from.y, e.to.x - e.from.x);
|
|
754
|
+
}
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/topology/group-collapse.ts
|
|
757
|
+
function Pe(e, t) {
|
|
758
|
+
let n = /* @__PURE__ */ new Map();
|
|
759
|
+
for (let r of e.groups) if (t.has(r.id)) for (let e of r.children) n.set(e, r.id);
|
|
760
|
+
return n;
|
|
761
|
+
}
|
|
762
|
+
function Fe(e, t, n) {
|
|
763
|
+
return Pe(e, t).get(n) ?? n;
|
|
764
|
+
}
|
|
765
|
+
function Ie(e, t, n) {
|
|
766
|
+
if (n.size === 0) return e;
|
|
767
|
+
let r = Pe(t, n), i = (e) => r.get(e) ?? e, a = /* @__PURE__ */ new Set();
|
|
768
|
+
for (let t of e.nodes) a.add(i(t));
|
|
769
|
+
let o = [];
|
|
770
|
+
for (let t of e.edges) {
|
|
771
|
+
let e = i(t.from), n = i(t.to);
|
|
772
|
+
e !== n && o.push({
|
|
773
|
+
id: t.id,
|
|
774
|
+
from: e,
|
|
775
|
+
to: n,
|
|
776
|
+
medium: t.medium
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
let s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
780
|
+
for (let e of o) {
|
|
781
|
+
l.set(e.id, e);
|
|
782
|
+
let t = s.get(e.from);
|
|
783
|
+
t ? t.push(e) : s.set(e.from, [e]);
|
|
784
|
+
let n = c.get(e.to);
|
|
785
|
+
n ? n.push(e) : c.set(e.to, [e]);
|
|
786
|
+
}
|
|
787
|
+
return {
|
|
788
|
+
nodes: a,
|
|
789
|
+
edges: o,
|
|
790
|
+
outgoing: s,
|
|
791
|
+
incoming: c,
|
|
792
|
+
edgeById: l
|
|
793
|
+
};
|
|
794
|
+
}
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/scheduler/quality.ts
|
|
797
|
+
var Le = {
|
|
798
|
+
good: 0,
|
|
799
|
+
uncertain: 1,
|
|
800
|
+
stale: 2,
|
|
801
|
+
bad: 3
|
|
802
|
+
};
|
|
803
|
+
function Re(e, t) {
|
|
804
|
+
return Le[e] >= Le[t] ? e : t;
|
|
805
|
+
}
|
|
806
|
+
function ze(e, t, n) {
|
|
807
|
+
return e.quality === "bad" ? "bad" : t - (e.timestamp ?? e.arrivalTime) > n ? "stale" : e.quality === "uncertain" ? "uncertain" : "good";
|
|
808
|
+
}
|
|
809
|
+
function Be(e) {
|
|
810
|
+
return e.reduce((e, t) => Re(e, t), "good");
|
|
811
|
+
}
|
|
812
|
+
function Ve(e) {
|
|
813
|
+
let t = Math.floor(e / 1e3);
|
|
814
|
+
return t < 60 ? `${t}s` : `${Math.floor(t / 60)}m`;
|
|
815
|
+
}
|
|
816
|
+
//#endregion
|
|
817
|
+
//#region src/scene/groups.ts
|
|
818
|
+
var O = "http://www.w3.org/2000/svg";
|
|
819
|
+
function He(e) {
|
|
820
|
+
return e.length === 0 ? "uncertain" : Be([...e]);
|
|
821
|
+
}
|
|
822
|
+
function Ue(e, t) {
|
|
823
|
+
let n = document.createElementNS(O, "g");
|
|
824
|
+
n.setAttribute("class", "vscada-group-summary"), n.setAttribute("data-group-id", e.id);
|
|
825
|
+
let r = t.tokens.panel;
|
|
826
|
+
if (!r) return {
|
|
827
|
+
svg: n,
|
|
828
|
+
setAlarmCondition: () => {},
|
|
829
|
+
setSummaryValue: () => {}
|
|
830
|
+
};
|
|
831
|
+
let i = document.createElementNS(O, "rect");
|
|
832
|
+
i.setAttribute("class", "vscada-group-face"), i.setAttribute("width", String(e.w)), i.setAttribute("height", String(e.h)), i.setAttribute("fill", r.raised.faceColor), n.appendChild(i);
|
|
833
|
+
let a = document.createElementNS(O, "path");
|
|
834
|
+
a.setAttribute("class", "vscada-group-bevel-highlight"), a.setAttribute("d", `M 0 ${e.h} L 0 0 L ${e.w} 0`), a.setAttribute("fill", "none"), a.setAttribute("stroke", r.raised.highlightColor), a.setAttribute("stroke-width", "2"), n.appendChild(a);
|
|
835
|
+
let o = document.createElementNS(O, "path");
|
|
836
|
+
o.setAttribute("class", "vscada-group-bevel-shadow"), o.setAttribute("d", `M ${e.w} 0 L ${e.w} ${e.h} L 0 ${e.h}`), o.setAttribute("fill", "none"), o.setAttribute("stroke", r.raised.shadowColor), o.setAttribute("stroke-width", "2"), n.appendChild(o);
|
|
837
|
+
let s = document.createElementNS(O, "text");
|
|
838
|
+
s.setAttribute("class", "vscada-group-label"), s.setAttribute("x", "6"), s.setAttribute("y", "14"), s.setAttribute("fill", r.labelColor), s.textContent = e.label ?? e.id, n.appendChild(s);
|
|
839
|
+
let c = /* @__PURE__ */ new Map();
|
|
840
|
+
e.summaryTags.forEach((e, t) => {
|
|
841
|
+
let i = document.createElementNS(O, "text");
|
|
842
|
+
i.setAttribute("class", "vscada-group-readout"), i.setAttribute("data-tag", e), i.setAttribute("x", "6"), i.setAttribute("y", String(28 + t * 14)), i.setAttribute("fill", r.readoutColor), n.appendChild(i), c.set(e, i);
|
|
843
|
+
});
|
|
844
|
+
let l = document.createElementNS(O, "circle");
|
|
845
|
+
l.setAttribute("class", "vscada-group-alarm"), l.setAttribute("cx", String(e.w - 8)), l.setAttribute("cy", "8"), l.setAttribute("r", "5"), l.setAttribute("fill", r.alarmIndicator.goodColor), n.appendChild(l);
|
|
846
|
+
let u = document.createElementNS(O, "text");
|
|
847
|
+
u.setAttribute("class", "vscada-group-alarm-label"), u.setAttribute("x", String(e.w - 8)), u.setAttribute("y", "20"), u.setAttribute("text-anchor", "middle"), u.setAttribute("font-size", "7"), u.setAttribute("fill", r.labelColor), u.textContent = "GOOD", n.appendChild(u);
|
|
848
|
+
let d = {
|
|
849
|
+
good: r.alarmIndicator.goodColor,
|
|
850
|
+
uncertain: r.alarmIndicator.uncertainColor,
|
|
851
|
+
stale: r.alarmIndicator.staleColor,
|
|
852
|
+
bad: r.alarmIndicator.badColor
|
|
853
|
+
};
|
|
854
|
+
function f(e, t) {
|
|
855
|
+
e.setAttr(l, "fill", d[t]), e.setText(u, t.toUpperCase());
|
|
856
|
+
}
|
|
857
|
+
function p(e, t, n) {
|
|
858
|
+
let r = c.get(t);
|
|
859
|
+
r && e.setText(r, n);
|
|
860
|
+
}
|
|
861
|
+
return {
|
|
862
|
+
svg: n,
|
|
863
|
+
setAlarmCondition: f,
|
|
864
|
+
setSummaryValue: p
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
function We(e, t) {
|
|
868
|
+
let n = document.createElementNS(O, "g");
|
|
869
|
+
n.setAttribute("class", "vscada-group-frame"), n.setAttribute("data-group-id", e.id);
|
|
870
|
+
let r = t.tokens.panel;
|
|
871
|
+
if (!r) return n;
|
|
872
|
+
let i = document.createElementNS(O, "rect");
|
|
873
|
+
i.setAttribute("class", "vscada-group-frame-outline"), i.setAttribute("width", String(e.w)), i.setAttribute("height", String(e.h)), i.setAttribute("fill", "none"), i.setAttribute("stroke", r.raised.highlightColor), i.setAttribute("stroke-dasharray", "4 3"), n.appendChild(i);
|
|
874
|
+
let a = document.createElementNS(O, "text");
|
|
875
|
+
return a.setAttribute("class", "vscada-group-frame-label"), a.setAttribute("x", "4"), a.setAttribute("y", "-4"), a.setAttribute("fill", r.labelColor), a.textContent = e.label ?? e.id, n.appendChild(a), n;
|
|
876
|
+
}
|
|
877
|
+
function Ge(e) {
|
|
878
|
+
return Object.entries(e.portMap).flatMap(([e, t]) => {
|
|
879
|
+
let n = t.indexOf(".");
|
|
880
|
+
return n < 0 ? [] : [{
|
|
881
|
+
groupPortName: e,
|
|
882
|
+
childElementId: t.slice(0, n),
|
|
883
|
+
childPortName: t.slice(n + 1)
|
|
884
|
+
}];
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
function Ke(e, t) {
|
|
888
|
+
let n = /* @__PURE__ */ new Map();
|
|
889
|
+
for (let r of e.groups) if (t.has(r.id)) for (let e of Ge(r)) n.set(`${e.childElementId}.${e.childPortName}`, `${r.id}.${e.groupPortName}`);
|
|
890
|
+
return n;
|
|
891
|
+
}
|
|
892
|
+
function qe(e) {
|
|
893
|
+
let t = e.indexOf(".");
|
|
894
|
+
return t < 0 ? e : e.slice(0, t);
|
|
895
|
+
}
|
|
896
|
+
function Je(e, t, n) {
|
|
897
|
+
let r = Fe(t, n, qe(e.from));
|
|
898
|
+
return r === Fe(t, n, qe(e.to)) && n.has(r);
|
|
899
|
+
}
|
|
900
|
+
function Ye(e, t) {
|
|
901
|
+
if (t.size === 0) return e;
|
|
902
|
+
let n = Ke(e, t), r = e.groups.filter((e) => t.has(e.id)).map((e) => ({
|
|
903
|
+
id: e.id,
|
|
904
|
+
type: "group",
|
|
905
|
+
x: e.x,
|
|
906
|
+
y: e.y,
|
|
907
|
+
w: e.w,
|
|
908
|
+
h: e.h,
|
|
909
|
+
label: e.label,
|
|
910
|
+
ports: e.ports,
|
|
911
|
+
bindings: [],
|
|
912
|
+
thresholds: [],
|
|
913
|
+
transitions: {}
|
|
914
|
+
})), i = (e) => n.get(e) ?? e, a = e.connections.filter((n) => !Je(n, e, t)).map((e) => ({
|
|
915
|
+
...e,
|
|
916
|
+
from: i(e.from),
|
|
917
|
+
to: i(e.to)
|
|
918
|
+
}));
|
|
919
|
+
return {
|
|
920
|
+
...e,
|
|
921
|
+
elements: [...e.elements, ...r],
|
|
922
|
+
connections: a
|
|
923
|
+
};
|
|
924
|
+
}
|
|
925
|
+
function Xe(e, t, n, r) {
|
|
926
|
+
if (Je(e, t, n)) return null;
|
|
927
|
+
let i = Ye(t, n), a = Ke(t, n);
|
|
928
|
+
return xe({
|
|
929
|
+
...e,
|
|
930
|
+
from: a.get(e.from) ?? e.from,
|
|
931
|
+
to: a.get(e.to) ?? e.to
|
|
932
|
+
}, i, r);
|
|
933
|
+
}
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/store/value-store.ts
|
|
936
|
+
var Ze = class {
|
|
937
|
+
constructor(e, t, n = "") {
|
|
938
|
+
this.timeSource = e, this.onWarning = t, this.buffer = /* @__PURE__ */ new Map(), this._tagPrefixVersion = 0, this._tagPrefix = n;
|
|
939
|
+
}
|
|
940
|
+
get tagPrefix() {
|
|
941
|
+
return this._tagPrefix;
|
|
942
|
+
}
|
|
943
|
+
set tagPrefix(e) {
|
|
944
|
+
e !== this._tagPrefix && (this._tagPrefix = e, this._tagPrefixVersion++);
|
|
945
|
+
}
|
|
946
|
+
get tagPrefixVersion() {
|
|
947
|
+
return this._tagPrefixVersion;
|
|
948
|
+
}
|
|
949
|
+
setValues(e) {
|
|
950
|
+
for (let t of e) this.ingestOne(t);
|
|
951
|
+
}
|
|
952
|
+
clearValues() {
|
|
953
|
+
this.buffer.clear();
|
|
954
|
+
}
|
|
955
|
+
get(e) {
|
|
956
|
+
return this.buffer.get(e);
|
|
957
|
+
}
|
|
958
|
+
resolve(e) {
|
|
959
|
+
return this.buffer.get(this._tagPrefix + e);
|
|
960
|
+
}
|
|
961
|
+
get size() {
|
|
962
|
+
return this.buffer.size;
|
|
963
|
+
}
|
|
964
|
+
tags() {
|
|
965
|
+
return this.buffer.keys();
|
|
966
|
+
}
|
|
967
|
+
ingestOne(e) {
|
|
968
|
+
let t = e.quality ?? "good", n = this.buffer.get(e.tag);
|
|
969
|
+
if (n && n.currentValue === e.value && n.quality === t && n.timestamp === e.timestamp) return;
|
|
970
|
+
this.checkTimestamp(e);
|
|
971
|
+
let r = this.timeSource.now();
|
|
972
|
+
this.buffer.set(e.tag, {
|
|
973
|
+
previousValue: n ? n.currentValue : e.value,
|
|
974
|
+
currentValue: e.value,
|
|
975
|
+
arrivalTime: r,
|
|
976
|
+
quality: t,
|
|
977
|
+
timestamp: e.timestamp
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
checkTimestamp(e) {}
|
|
981
|
+
}, Qe = {
|
|
982
|
+
"state-lamp": 0,
|
|
983
|
+
flow: 1,
|
|
984
|
+
rotation: 2,
|
|
985
|
+
wave: 3
|
|
986
|
+
}, $e = class {
|
|
987
|
+
constructor() {
|
|
988
|
+
this.entries = [];
|
|
989
|
+
}
|
|
990
|
+
register(e, t, n = "rotation") {
|
|
991
|
+
this.entries.push({
|
|
992
|
+
elementId: e,
|
|
993
|
+
handle: t,
|
|
994
|
+
paused: !1,
|
|
995
|
+
priority: n
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
registeredEntries() {
|
|
999
|
+
return this.entries.map((e) => ({
|
|
1000
|
+
elementId: e.elementId,
|
|
1001
|
+
priority: e.priority
|
|
1002
|
+
}));
|
|
1003
|
+
}
|
|
1004
|
+
unregisterElement(e) {
|
|
1005
|
+
this.entries = this.entries.filter((t) => t.elementId !== e);
|
|
1006
|
+
}
|
|
1007
|
+
pauseAll(e) {
|
|
1008
|
+
for (let t of this.entries) t.elementId === e && !t.paused && (t.handle.pause(), t.paused = !0);
|
|
1009
|
+
}
|
|
1010
|
+
resumeAll(e) {
|
|
1011
|
+
for (let t of this.entries) t.elementId === e && t.paused && (t.handle.resume(), t.paused = !1);
|
|
1012
|
+
}
|
|
1013
|
+
pauseScene() {
|
|
1014
|
+
for (let e of this.entries) e.paused || (e.handle.pause(), e.paused = !0);
|
|
1015
|
+
}
|
|
1016
|
+
resumeScene() {
|
|
1017
|
+
for (let e of this.entries) e.paused && (e.handle.resume(), e.paused = !1);
|
|
1018
|
+
}
|
|
1019
|
+
isPaused(e) {
|
|
1020
|
+
return this.entries.filter((t) => t.elementId === e).map((e) => e.paused);
|
|
1021
|
+
}
|
|
1022
|
+
seekAll(e) {
|
|
1023
|
+
for (let t of this.entries) t.handle.seek(e);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
//#endregion
|
|
1027
|
+
//#region src/scheduler/visual-state-resolver.ts
|
|
1028
|
+
function et(e) {
|
|
1029
|
+
return e.quality === "good" ? e.explicit === void 0 ? e.inferred === void 0 ? {
|
|
1030
|
+
tier: "default",
|
|
1031
|
+
value: e.defaultValue
|
|
1032
|
+
} : {
|
|
1033
|
+
tier: "inferred",
|
|
1034
|
+
value: e.inferred
|
|
1035
|
+
} : {
|
|
1036
|
+
tier: "explicit",
|
|
1037
|
+
value: e.explicit
|
|
1038
|
+
} : {
|
|
1039
|
+
tier: "quality",
|
|
1040
|
+
value: e.quality
|
|
1041
|
+
};
|
|
1042
|
+
}
|
|
1043
|
+
//#endregion
|
|
1044
|
+
//#region src/scheduler/lod.ts
|
|
1045
|
+
var tt = .5, nt = .1;
|
|
1046
|
+
function rt(e, t, n = tt, r = nt) {
|
|
1047
|
+
let i = n * r;
|
|
1048
|
+
return t ? e < n + i : e < n - i;
|
|
1049
|
+
}
|
|
1050
|
+
var it = 1e4, at = 1e3, ot = 100, st = 2e3, ct = 1e3, lt = 1e3, ut = 1e3 / 60, dt = 1.5;
|
|
1051
|
+
function k(e) {
|
|
1052
|
+
return e === "stale" || e === "bad";
|
|
1053
|
+
}
|
|
1054
|
+
var ft = class {
|
|
1055
|
+
constructor(e, t, n, r, i = {}) {
|
|
1056
|
+
this.timeSource = e, this.store = t, this.renderer = n, this.animationRegistry = r, this.registrations = [], this.tickables = [], this.overlays = /* @__PURE__ */ new Map(), this.elementQuality = /* @__PURE__ */ new Map(), this.stopTick = null, this.wasSceneFrozen = !1, this.flowFrozen = /* @__PURE__ */ new Map(), this.flowIsolatedOverlay = /* @__PURE__ */ new Map(), this.lodFrozen = /* @__PURE__ */ new Map(), this.lodActiveValue = !1, this.lodMaxActiveAnimations = 50, this.visibilityPaused = !1, this.offscreenTimerId = null, this.debugEnabled = !1, this.statsFrameCount = 0, this.statsDroppedFrames = 0, this.statsWindowStart = 0, this.lastTickTime = null, this.statsCallback = null, this.conditionCallback = null, this.stalenessTimeout = it, this.connectionState = "connected", this._mode = "live", this._animateEnabled = !0, this.snapThreshold = i.snapThreshold ?? 50, this.lastSeenTagPrefixVersion = t.tagPrefixVersion;
|
|
1057
|
+
}
|
|
1058
|
+
registerHandle(e, t, n) {
|
|
1059
|
+
if (n.kind !== "animation") {
|
|
1060
|
+
if (n.kind === "tween") {
|
|
1061
|
+
this.tickables.push({
|
|
1062
|
+
elementId: e,
|
|
1063
|
+
handle: n
|
|
1064
|
+
});
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
this.registrations.push({
|
|
1068
|
+
elementId: e,
|
|
1069
|
+
tag: t,
|
|
1070
|
+
handle: n,
|
|
1071
|
+
lastWritten: void 0,
|
|
1072
|
+
lastArrivalTimeSeen: void 0,
|
|
1073
|
+
tweenDurationMs: ot
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
registerQualityOverlay(e, t) {
|
|
1078
|
+
this.overlays.set(e, t);
|
|
1079
|
+
}
|
|
1080
|
+
registerFlowInference(e, t) {
|
|
1081
|
+
this.flowInference = {
|
|
1082
|
+
cache: e,
|
|
1083
|
+
ids: [...t]
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
unregisterElement(e) {
|
|
1087
|
+
this.registrations = this.registrations.filter((t) => t.elementId !== e), this.tickables = this.tickables.filter((t) => t.elementId !== e), this.overlays.delete(e), this.elementQuality.delete(e), this.flowFrozen.delete(e), this.flowIsolatedOverlay.delete(e), this.lodFrozen.delete(e);
|
|
1088
|
+
}
|
|
1089
|
+
get registrationCount() {
|
|
1090
|
+
return this.registrations.length;
|
|
1091
|
+
}
|
|
1092
|
+
get mode() {
|
|
1093
|
+
return this._mode;
|
|
1094
|
+
}
|
|
1095
|
+
set mode(e) {
|
|
1096
|
+
if (e === this._mode) return;
|
|
1097
|
+
let t = this._mode === "live";
|
|
1098
|
+
this._mode = e, e === "static" ? (t && this.snapToTargets(), this.stop()) : this.start();
|
|
1099
|
+
}
|
|
1100
|
+
get animate() {
|
|
1101
|
+
return this._animateEnabled;
|
|
1102
|
+
}
|
|
1103
|
+
set animate(e) {
|
|
1104
|
+
if (e === this._animateEnabled) return;
|
|
1105
|
+
if (this._animateEnabled = e, !e) {
|
|
1106
|
+
this.animationRegistry.pauseScene();
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
let t = new Set(this.animationRegistry.registeredEntries().map((e) => e.elementId));
|
|
1110
|
+
for (let e of t) this.visibilityPaused || this.isElementFrozen(e) || this.flowFrozen.get(e) || this.lodFrozen.get(e) || this.animationRegistry.resumeAll(e);
|
|
1111
|
+
}
|
|
1112
|
+
start() {
|
|
1113
|
+
this.stopTick || this._mode !== "static" && (this.stopTick = this.timeSource.onTick((e) => this.tick(e)));
|
|
1114
|
+
}
|
|
1115
|
+
stop() {
|
|
1116
|
+
this.stopTick?.(), this.stopTick = null, this.offscreenTimerId !== null && (clearInterval(this.offscreenTimerId), this.offscreenTimerId = null);
|
|
1117
|
+
}
|
|
1118
|
+
get isRunning() {
|
|
1119
|
+
return this.stopTick !== null;
|
|
1120
|
+
}
|
|
1121
|
+
get lodActive() {
|
|
1122
|
+
return this.lodActiveValue;
|
|
1123
|
+
}
|
|
1124
|
+
set lodActive(e) {
|
|
1125
|
+
this.lodActiveValue = e;
|
|
1126
|
+
}
|
|
1127
|
+
get debug() {
|
|
1128
|
+
return this.debugEnabled;
|
|
1129
|
+
}
|
|
1130
|
+
set debug(e) {
|
|
1131
|
+
let t = e && !this.debugEnabled;
|
|
1132
|
+
this.debugEnabled = e, t && (this.statsFrameCount = 0, this.statsDroppedFrames = 0, this.lastTickTime = null, this.statsWindowStart = this.timeSource.now());
|
|
1133
|
+
}
|
|
1134
|
+
onRenderStats(e) {
|
|
1135
|
+
return this.statsCallback = e, () => {
|
|
1136
|
+
this.statsCallback === e && (this.statsCallback = null);
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
onConditionTransition(e) {
|
|
1140
|
+
return this.conditionCallback = e, () => {
|
|
1141
|
+
this.conditionCallback === e && (this.conditionCallback = null);
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
get isPausedForOffscreen() {
|
|
1145
|
+
return this.visibilityPaused;
|
|
1146
|
+
}
|
|
1147
|
+
pauseForOffscreen() {
|
|
1148
|
+
this.visibilityPaused || (this.visibilityPaused = !0, this.stop(), this.animationRegistry.pauseScene(), this.offscreenTimerId = setInterval(() => this.offscreenTick(), ct));
|
|
1149
|
+
}
|
|
1150
|
+
resumeFromOffscreen() {
|
|
1151
|
+
if (!this.visibilityPaused) return;
|
|
1152
|
+
this.visibilityPaused = !1, this.offscreenTimerId !== null && (clearInterval(this.offscreenTimerId), this.offscreenTimerId = null);
|
|
1153
|
+
let e = new Set(this.animationRegistry.registeredEntries().map((e) => e.elementId));
|
|
1154
|
+
for (let t of e) this.isElementFrozen(t) || this.flowFrozen.get(t) || this.lodFrozen.get(t) || this.animationRegistry.resumeAll(t);
|
|
1155
|
+
this.start();
|
|
1156
|
+
}
|
|
1157
|
+
offscreenTick() {
|
|
1158
|
+
let e = this.timeSource.now(), t = this.connectionState === "disconnected";
|
|
1159
|
+
this.evaluateQuality(e, t), this.applyFlowInference();
|
|
1160
|
+
}
|
|
1161
|
+
snapToTargets() {
|
|
1162
|
+
this.syncTagPrefixIfChanged();
|
|
1163
|
+
let e = this.timeSource.now();
|
|
1164
|
+
for (let t of this.tickables) t.handle.snap(this.renderer, e);
|
|
1165
|
+
for (let t of this.registrations) {
|
|
1166
|
+
let n = this.store.resolve(t.tag);
|
|
1167
|
+
n && (t.tweenDurationMs = Math.max(e - n.arrivalTime, 1), t.lastArrivalTimeSeen = n.arrivalTime, !Object.is(n.currentValue, t.lastWritten) && (t.lastWritten = n.currentValue, mt(t.handle, this.renderer, n.currentValue, e)));
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
tick(e) {
|
|
1171
|
+
this.debugEnabled && this.accountFrame(e), this.syncTagPrefixIfChanged();
|
|
1172
|
+
let t = this.connectionState === "disconnected";
|
|
1173
|
+
t && !this.wasSceneFrozen && this.animationRegistry.pauseScene(), this.wasSceneFrozen = t, this.evaluateQuality(e, t), this.applyFlowInference();
|
|
1174
|
+
for (let n of this.tickables) t || this.isElementFrozen(n.elementId) || n.handle.tick(this.renderer, e);
|
|
1175
|
+
for (let n of this.registrations) {
|
|
1176
|
+
if (t || this.isElementFrozen(n.elementId)) continue;
|
|
1177
|
+
let r = this.store.resolve(n.tag);
|
|
1178
|
+
if (!r) continue;
|
|
1179
|
+
if (r.arrivalTime !== n.lastArrivalTimeSeen) {
|
|
1180
|
+
let e = n.lastArrivalTimeSeen === void 0 ? ot : r.arrivalTime - n.lastArrivalTimeSeen;
|
|
1181
|
+
n.tweenDurationMs = Math.min(Math.max(e, ot), st), n.lastArrivalTimeSeen = r.arrivalTime;
|
|
1182
|
+
}
|
|
1183
|
+
let i = n.handle.kind === "state" ? r.currentValue : pt(r, e, n.tweenDurationMs, this.snapThreshold);
|
|
1184
|
+
Object.is(i, n.lastWritten) || (n.lastWritten = i, mt(n.handle, this.renderer, i, e));
|
|
1185
|
+
}
|
|
1186
|
+
this.applyLod();
|
|
1187
|
+
}
|
|
1188
|
+
applyLod() {
|
|
1189
|
+
if (!this.lodActiveValue && this.lodFrozen.size === 0) return;
|
|
1190
|
+
if (!this.lodActiveValue) {
|
|
1191
|
+
for (let [e, t] of [...this.lodFrozen]) {
|
|
1192
|
+
if (!t) {
|
|
1193
|
+
this.lodFrozen.delete(e);
|
|
1194
|
+
continue;
|
|
1195
|
+
}
|
|
1196
|
+
this.isElementFrozen(e) || this.flowFrozen.get(e) || (this.animationRegistry.resumeAll(e), this.lodFrozen.delete(e));
|
|
1197
|
+
}
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
let e = this.animationRegistry.registeredEntries(), t = [...e].sort((e, t) => Qe[e.priority] - Qe[t.priority]), n = new Set(t.slice(0, this.lodMaxActiveAnimations).map((e) => e.elementId));
|
|
1201
|
+
for (let { elementId: t } of e) {
|
|
1202
|
+
let e = !n.has(t), r = this.lodFrozen.get(t) ?? !1;
|
|
1203
|
+
if (e && !r) this.animationRegistry.pauseAll(t), this.lodFrozen.set(t, !0);
|
|
1204
|
+
else if (!e && r) {
|
|
1205
|
+
if (this.isElementFrozen(t) || this.flowFrozen.get(t)) continue;
|
|
1206
|
+
this.animationRegistry.resumeAll(t), this.lodFrozen.set(t, !1);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
accountFrame(e) {
|
|
1211
|
+
this.lastTickTime !== null && e - this.lastTickTime > ut * dt && this.statsDroppedFrames++, this.lastTickTime = e, this.statsFrameCount++;
|
|
1212
|
+
let t = e - this.statsWindowStart;
|
|
1213
|
+
if (t < lt) return;
|
|
1214
|
+
let n = t / 1e3, r = n > 0 ? this.statsFrameCount / n : 0;
|
|
1215
|
+
this.statsCallback?.({
|
|
1216
|
+
fps: Math.round(r),
|
|
1217
|
+
elementCount: this.countDistinctElements(),
|
|
1218
|
+
droppedFrames: this.statsDroppedFrames
|
|
1219
|
+
}), this.statsFrameCount = 0, this.statsDroppedFrames = 0, this.statsWindowStart = e;
|
|
1220
|
+
}
|
|
1221
|
+
countDistinctElements() {
|
|
1222
|
+
let e = /* @__PURE__ */ new Set();
|
|
1223
|
+
for (let t of this.registrations) e.add(t.elementId);
|
|
1224
|
+
for (let t of this.tickables) e.add(t.elementId);
|
|
1225
|
+
for (let t of this.overlays.keys()) e.add(t);
|
|
1226
|
+
for (let t of this.animationRegistry.registeredEntries()) e.add(t.elementId);
|
|
1227
|
+
return e.size;
|
|
1228
|
+
}
|
|
1229
|
+
syncTagPrefixIfChanged() {
|
|
1230
|
+
let e = this.store.tagPrefixVersion;
|
|
1231
|
+
if (e !== this.lastSeenTagPrefixVersion) {
|
|
1232
|
+
this.lastSeenTagPrefixVersion = e;
|
|
1233
|
+
for (let e of this.registrations) e.lastWritten = void 0, e.lastArrivalTimeSeen = void 0, e.tweenDurationMs = ot;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
isElementFrozen(e) {
|
|
1237
|
+
let t = this.elementQuality.get(e);
|
|
1238
|
+
return t !== void 0 && k(t.condition);
|
|
1239
|
+
}
|
|
1240
|
+
evaluateQuality(e, t) {
|
|
1241
|
+
let n = /* @__PURE__ */ new Map();
|
|
1242
|
+
for (let e of this.registrations) {
|
|
1243
|
+
let t = n.get(e.elementId) ?? [];
|
|
1244
|
+
t.push(e.tag), n.set(e.elementId, t);
|
|
1245
|
+
}
|
|
1246
|
+
let r = /* @__PURE__ */ new Set([...n.keys(), ...this.overlays.keys()]);
|
|
1247
|
+
for (let i of r) {
|
|
1248
|
+
let r = n.get(i) ?? [], a = "good", o = 0;
|
|
1249
|
+
for (let t of r) {
|
|
1250
|
+
let n = this.store.resolve(t);
|
|
1251
|
+
n && (a = Be([a, ze(n, e, this.stalenessTimeout)]), o = Math.max(o, e - (n.timestamp ?? n.arrivalTime)));
|
|
1252
|
+
}
|
|
1253
|
+
t && (a = Be([a, "stale"]));
|
|
1254
|
+
let s = this.elementQuality.get(i), c = s?.condition ?? "good", l = this.overlays.get(i);
|
|
1255
|
+
a !== c && (l?.setCondition(this.renderer, a), this.handleConditionTransition(i, c, a, e), this.conditionCallback?.(i, c, a));
|
|
1256
|
+
let u = s?.lastBadgeUpdate ?? -Infinity;
|
|
1257
|
+
l && (a === "stale" && e - u >= at ? (l.setAgeBadge(this.renderer, Ve(o)), u = e) : a !== "stale" && l.setAgeBadge(this.renderer, null)), this.elementQuality.set(i, {
|
|
1258
|
+
condition: a,
|
|
1259
|
+
lastBadgeUpdate: u
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
applyFlowInference() {
|
|
1264
|
+
if (!this.flowInference) return;
|
|
1265
|
+
let { cache: e, ids: t } = this.flowInference;
|
|
1266
|
+
for (let n of t) {
|
|
1267
|
+
let t = e.getState(n), r = this.elementQuality.get(n)?.condition ?? "good", i = et({
|
|
1268
|
+
quality: r,
|
|
1269
|
+
inferred: t,
|
|
1270
|
+
defaultValue: "flowing"
|
|
1271
|
+
}), a = i.tier === "quality", o = !a && (i.value === "no-flow" || i.value === "isolated");
|
|
1272
|
+
o ? this.animationRegistry.pauseAll(n) : a || this.flowFrozen.get(n) && this.animationRegistry.resumeAll(n), this.flowFrozen.set(n, o);
|
|
1273
|
+
let s = this.overlays.get(n), c = i.tier === "inferred" && i.value === "isolated", l = this.flowIsolatedOverlay.get(n) ?? !1;
|
|
1274
|
+
s && r === "good" && c !== l && s.setCondition(this.renderer, c ? "stale" : "good"), this.flowIsolatedOverlay.set(n, c);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
handleConditionTransition(e, t, n, r) {
|
|
1278
|
+
let i = k(n) && !k(t), a = k(t) && !k(n);
|
|
1279
|
+
if (i) {
|
|
1280
|
+
if (this.animationRegistry.pauseAll(e), n === "bad") for (let t of this.registrations) t.elementId === e && t.handle.kind === "text" && (t.handle.write(this.renderer, "----", r), t.lastWritten = "----");
|
|
1281
|
+
} else a && this.animationRegistry.resumeAll(e);
|
|
1282
|
+
}
|
|
1283
|
+
};
|
|
1284
|
+
function pt(e, t, n, r) {
|
|
1285
|
+
let { previousValue: i, currentValue: a, arrivalTime: o } = e;
|
|
1286
|
+
if (typeof i != "number" || typeof a != "number" || i === a || Math.abs(a - i) > r) return a;
|
|
1287
|
+
let s = Math.min(Math.max((t - o) / n, 0), 1);
|
|
1288
|
+
return i + (a - i) * s;
|
|
1289
|
+
}
|
|
1290
|
+
function mt(e, t, n, r) {
|
|
1291
|
+
if (e.kind === "numeric") {
|
|
1292
|
+
typeof n == "number" && e.write(t, n, r);
|
|
1293
|
+
return;
|
|
1294
|
+
}
|
|
1295
|
+
(e.kind === "text" || e.kind === "state") && e.write(t, n, r);
|
|
1296
|
+
}
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region src/scheduler/quality-overlay.ts
|
|
1299
|
+
var A = "http://www.w3.org/2000/svg", ht = "vscada-quality-hatch";
|
|
1300
|
+
function gt(e, t, n) {
|
|
1301
|
+
let r = n.tokens.quality, i = document.createElementNS(A, "g");
|
|
1302
|
+
if (i.setAttribute("class", "vscada-quality-overlay"), i.setAttribute("display", "none"), !r) return {
|
|
1303
|
+
group: i,
|
|
1304
|
+
setCondition: () => {},
|
|
1305
|
+
setAgeBadge: () => {}
|
|
1306
|
+
};
|
|
1307
|
+
let a = document.createElementNS(A, "rect");
|
|
1308
|
+
if (a.setAttribute("class", "vscada-quality-dash"), a.setAttribute("width", String(e)), a.setAttribute("height", String(t)), a.setAttribute("fill", "none"), a.setAttribute("stroke", r.uncertainDashColor), a.setAttribute("stroke-dasharray", "4 3"), a.setAttribute("display", "none"), i.appendChild(a), !n.defs.querySelector(`#${ht}`)) {
|
|
1309
|
+
let e = document.createElementNS(A, "pattern");
|
|
1310
|
+
e.setAttribute("id", ht), e.setAttribute("width", "8"), e.setAttribute("height", "8"), e.setAttribute("patternUnits", "userSpaceOnUse"), e.setAttribute("patternTransform", "rotate(45)");
|
|
1311
|
+
let t = document.createElementNS(A, "line");
|
|
1312
|
+
t.setAttribute("x1", "0"), t.setAttribute("y1", "0"), t.setAttribute("x2", "0"), t.setAttribute("y2", "8"), t.setAttribute("stroke", r.badHatchColor), t.setAttribute("stroke-width", "4"), e.appendChild(t), n.defs.appendChild(e);
|
|
1313
|
+
}
|
|
1314
|
+
let o = document.createElementNS(A, "rect");
|
|
1315
|
+
o.setAttribute("class", "vscada-quality-hatch"), o.setAttribute("width", String(e)), o.setAttribute("height", String(t)), o.setAttribute("fill", `url(#${ht})`), o.setAttribute("opacity", String(r.badHatchOpacity)), o.setAttribute("display", "none"), i.appendChild(o);
|
|
1316
|
+
let s = document.createElementNS(A, "rect");
|
|
1317
|
+
s.setAttribute("class", "vscada-quality-stale"), s.setAttribute("width", String(e)), s.setAttribute("height", String(t)), s.setAttribute("fill", r.staleOverlayColor), s.setAttribute("opacity", String(r.staleOverlayOpacity)), s.setAttribute("display", "none"), i.appendChild(s);
|
|
1318
|
+
let c = document.createElementNS(A, "g");
|
|
1319
|
+
c.setAttribute("class", "vscada-quality-badge"), c.setAttribute("display", "none");
|
|
1320
|
+
let l = document.createElementNS(A, "rect");
|
|
1321
|
+
l.setAttribute("x", String(e - 24)), l.setAttribute("y", "-14"), l.setAttribute("width", "24"), l.setAttribute("height", "12"), l.setAttribute("fill", r.badgeBackgroundColor), c.appendChild(l);
|
|
1322
|
+
let u = document.createElementNS(A, "text");
|
|
1323
|
+
u.setAttribute("class", "vscada-quality-badge-text"), u.setAttribute("x", String(e - 12)), u.setAttribute("y", "-5"), u.setAttribute("font-size", "8"), u.setAttribute("text-anchor", "middle"), u.setAttribute("fill", r.badgeTextColor), c.appendChild(u), i.appendChild(c);
|
|
1324
|
+
function d(e, t) {
|
|
1325
|
+
e.setAttr(i, "display", t === "good" ? "none" : "inline"), e.setAttr(a, "display", t === "uncertain" ? "inline" : "none"), e.setAttr(o, "display", t === "bad" ? "inline" : "none"), e.setAttr(s, "display", t === "stale" ? "inline" : "none"), e.setAttr(c, "display", t === "stale" ? "inline" : "none");
|
|
1326
|
+
}
|
|
1327
|
+
function f(e, t) {
|
|
1328
|
+
e.setText(u, t ?? "");
|
|
1329
|
+
}
|
|
1330
|
+
return {
|
|
1331
|
+
group: i,
|
|
1332
|
+
setCondition: d,
|
|
1333
|
+
setAgeBadge: f
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
//#endregion
|
|
1337
|
+
//#region src/bindings/transforms.ts
|
|
1338
|
+
function _t(e) {
|
|
1339
|
+
return Number.isNaN(e) ? 0 : Math.min(Math.max(e, 0), 1);
|
|
1340
|
+
}
|
|
1341
|
+
function vt(e, t, n) {
|
|
1342
|
+
return Math.min(Math.max(e, t), n);
|
|
1343
|
+
}
|
|
1344
|
+
function j(e, t, n) {
|
|
1345
|
+
let r = t - e;
|
|
1346
|
+
return r === 0 ? 0 : _t((n - e) / r);
|
|
1347
|
+
}
|
|
1348
|
+
function yt(e, t) {
|
|
1349
|
+
return j(e.min, e.max, t);
|
|
1350
|
+
}
|
|
1351
|
+
function bt(e, t) {
|
|
1352
|
+
return j(e.min, e.max, t);
|
|
1353
|
+
}
|
|
1354
|
+
var xt = 4;
|
|
1355
|
+
function St(e, t) {
|
|
1356
|
+
return vt(t, 0, e.max ?? 4);
|
|
1357
|
+
}
|
|
1358
|
+
var Ct = {
|
|
1359
|
+
minAngleDeg: -135,
|
|
1360
|
+
maxAngleDeg: 135
|
|
1361
|
+
};
|
|
1362
|
+
function wt(e, t, n = Ct) {
|
|
1363
|
+
let r = j(e.min, e.max, t);
|
|
1364
|
+
return n.minAngleDeg + r * (n.maxAngleDeg - n.minAngleDeg);
|
|
1365
|
+
}
|
|
1366
|
+
function Tt(e, t) {
|
|
1367
|
+
if (typeof t != "number") return String(t);
|
|
1368
|
+
let n = t.toFixed(e.decimals);
|
|
1369
|
+
return e.unit.length > 0 ? `${n} ${e.unit}` : n;
|
|
1370
|
+
}
|
|
1371
|
+
function Et(e, t) {
|
|
1372
|
+
if (e.map) {
|
|
1373
|
+
let n = e.map[String(t)];
|
|
1374
|
+
if (n !== void 0) return n;
|
|
1375
|
+
}
|
|
1376
|
+
return !!t;
|
|
1377
|
+
}
|
|
1378
|
+
function Dt(e, t) {
|
|
1379
|
+
let n = String(t), r = e.map[n];
|
|
1380
|
+
return r === void 0 ? {
|
|
1381
|
+
ok: !1,
|
|
1382
|
+
fault: {
|
|
1383
|
+
code: "UNMAPPED_STATE_VALUE",
|
|
1384
|
+
message: `Tag "${e.tag}": value "${n}" has no entry in this binding's state map`,
|
|
1385
|
+
tag: e.tag
|
|
1386
|
+
}
|
|
1387
|
+
} : {
|
|
1388
|
+
ok: !0,
|
|
1389
|
+
state: r
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region src/bindings/color-ramp.ts
|
|
1394
|
+
function Ot(e) {
|
|
1395
|
+
return Math.min(Math.max(e, 0), 1);
|
|
1396
|
+
}
|
|
1397
|
+
function kt(e) {
|
|
1398
|
+
let t = /^#([0-9a-fA-F]{3})$/.exec(e);
|
|
1399
|
+
if (t) {
|
|
1400
|
+
let [e, n, r] = t[1].split("").map((e) => parseInt(e + e, 16));
|
|
1401
|
+
return [
|
|
1402
|
+
e,
|
|
1403
|
+
n,
|
|
1404
|
+
r
|
|
1405
|
+
];
|
|
1406
|
+
}
|
|
1407
|
+
let n = /^#([0-9a-fA-F]{6})$/.exec(e);
|
|
1408
|
+
if (n) {
|
|
1409
|
+
let e = n[1];
|
|
1410
|
+
return [
|
|
1411
|
+
parseInt(e.slice(0, 2), 16),
|
|
1412
|
+
parseInt(e.slice(2, 4), 16),
|
|
1413
|
+
parseInt(e.slice(4, 6), 16)
|
|
1414
|
+
];
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
function At(e) {
|
|
1418
|
+
return Math.round(Ot(e / 255) * 255).toString(16).padStart(2, "0").toUpperCase();
|
|
1419
|
+
}
|
|
1420
|
+
function jt(e, t, n) {
|
|
1421
|
+
let r = kt(e), i = kt(t);
|
|
1422
|
+
if (!r || !i) return e;
|
|
1423
|
+
let a = Ot(n), o = r[0] + (i[0] - r[0]) * a, s = r[1] + (i[1] - r[1]) * a, c = r[2] + (i[2] - r[2]) * a;
|
|
1424
|
+
return `#${At(o)}${At(s)}${At(c)}`;
|
|
1425
|
+
}
|
|
1426
|
+
function Mt(e, t) {
|
|
1427
|
+
let n = [...e].sort((e, t) => e.offset - t.offset);
|
|
1428
|
+
if (n.length === 0) return "#000000";
|
|
1429
|
+
if (n.length === 1) return n[0].color;
|
|
1430
|
+
let r = Ot(t);
|
|
1431
|
+
if (r <= n[0].offset) return n[0].color;
|
|
1432
|
+
if (r >= n[n.length - 1].offset) return n[n.length - 1].color;
|
|
1433
|
+
for (let e = 0; e < n.length - 1; e++) {
|
|
1434
|
+
let t = n[e], i = n[e + 1];
|
|
1435
|
+
if (r >= t.offset && r <= i.offset) {
|
|
1436
|
+
let e = i.offset - t.offset, n = e === 0 ? 0 : (r - t.offset) / e;
|
|
1437
|
+
return jt(t.color, i.color, n);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
return n[n.length - 1].color;
|
|
1441
|
+
}
|
|
1442
|
+
function Nt(e, t) {
|
|
1443
|
+
let n = e.colors;
|
|
1444
|
+
if (!n || n.length === 0) return t.default;
|
|
1445
|
+
let r = [];
|
|
1446
|
+
for (let e = 0; e < n.length; e++) {
|
|
1447
|
+
let i = t.stops[n[e]];
|
|
1448
|
+
if (!i) continue;
|
|
1449
|
+
let a = n.length === 1 ? 0 : e / (n.length - 1);
|
|
1450
|
+
r.push({
|
|
1451
|
+
offset: a,
|
|
1452
|
+
color: i
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
return r.length >= 2 ? r : t.default;
|
|
1456
|
+
}
|
|
1457
|
+
function Pt(e, t, n) {
|
|
1458
|
+
if (n) return Mt(Nt(e, n), j(e.min, e.max, t));
|
|
1459
|
+
}
|
|
1460
|
+
//#endregion
|
|
1461
|
+
//#region src/import/svg-source-registry.ts
|
|
1462
|
+
var Ft = /* @__PURE__ */ new Map();
|
|
1463
|
+
function It(e) {
|
|
1464
|
+
for (let [t, n] of Object.entries(e)) Ft.set(t, n);
|
|
1465
|
+
}
|
|
1466
|
+
function Lt(e) {
|
|
1467
|
+
return Ft.get(e);
|
|
1468
|
+
}
|
|
1469
|
+
//#endregion
|
|
1470
|
+
//#region src/import/load-svg-import.ts
|
|
1471
|
+
var Rt = "http://www.w3.org/2000/svg", zt = /* @__PURE__ */ new Set([
|
|
1472
|
+
"readout",
|
|
1473
|
+
"state",
|
|
1474
|
+
"visibility",
|
|
1475
|
+
"blink",
|
|
1476
|
+
"color-ramp"
|
|
1477
|
+
]), Bt = [
|
|
1478
|
+
"scale(1)",
|
|
1479
|
+
"scale(0.3)",
|
|
1480
|
+
"scale(1)"
|
|
1481
|
+
], Vt = 800;
|
|
1482
|
+
function Ht(e, t, n, r) {
|
|
1483
|
+
let i = document.createElementNS(Rt, "g");
|
|
1484
|
+
i.setAttribute("class", "vscada-svg-import"), i.setAttribute("data-element-id", e.id);
|
|
1485
|
+
let a = gt(e.w, e.h, t);
|
|
1486
|
+
i.appendChild(a.group);
|
|
1487
|
+
let o = {}, s = /* @__PURE__ */ new Set();
|
|
1488
|
+
function c(e, t) {
|
|
1489
|
+
s.add(e), a.setCondition(n, "bad");
|
|
1490
|
+
}
|
|
1491
|
+
function l(e) {
|
|
1492
|
+
s.has(e) && (s.delete(e), s.size === 0 && a.setCondition(n, "good"));
|
|
1493
|
+
}
|
|
1494
|
+
let u = Lt(e.svgRef);
|
|
1495
|
+
if (u === void 0) return c(`svgRef:${e.svgRef}`, {
|
|
1496
|
+
code: "MISSING_SVG_SOURCE",
|
|
1497
|
+
message: `svg-import "${e.id}" references svgRef "${e.svgRef}" but no source is registered — call registerSvgSources() before assigning the scene`,
|
|
1498
|
+
tag: e.svgRef
|
|
1499
|
+
}), {
|
|
1500
|
+
svg: i,
|
|
1501
|
+
handles: o
|
|
1502
|
+
};
|
|
1503
|
+
let d = new DOMParser().parseFromString(u, "image/svg+xml"), f = d.documentElement;
|
|
1504
|
+
if (d.querySelector("parsererror") || f.nodeName.toLowerCase() !== "svg") return c(`svgRef:${e.svgRef}`, {
|
|
1505
|
+
code: "INVALID_SVG_SOURCE",
|
|
1506
|
+
message: `svg-import "${e.id}"'s svgRef "${e.svgRef}" did not parse as SVG`,
|
|
1507
|
+
tag: e.svgRef
|
|
1508
|
+
}), {
|
|
1509
|
+
svg: i,
|
|
1510
|
+
handles: o
|
|
1511
|
+
};
|
|
1512
|
+
let p = document.createElementNS(Rt, "svg"), m = f.getAttribute("viewBox");
|
|
1513
|
+
for (m && p.setAttribute("viewBox", m), p.setAttribute("width", String(e.w)), p.setAttribute("height", String(e.h)), p.setAttribute("preserveAspectRatio", "xMidYMid meet"); f.firstChild;) p.appendChild(document.adoptNode(f.firstChild));
|
|
1514
|
+
i.appendChild(p);
|
|
1515
|
+
for (let r of e.bindings) {
|
|
1516
|
+
if (!zt.has(r.type)) {
|
|
1517
|
+
c(`type:${r.tag}`, {
|
|
1518
|
+
code: "UNSUPPORTED_IMPORT_BINDING_TYPE",
|
|
1519
|
+
message: `svg-import "${e.id}" binding for tag "${r.tag}" has unsupported type "${r.type}" — imported art supports readout/state/visibility/blink/color-ramp only`,
|
|
1520
|
+
tag: r.tag
|
|
1521
|
+
});
|
|
1522
|
+
continue;
|
|
1523
|
+
}
|
|
1524
|
+
let i = p.querySelector(`#${CSS.escape(r.svgId)}`);
|
|
1525
|
+
if (!i) {
|
|
1526
|
+
c(`id:${r.svgId}`, {
|
|
1527
|
+
code: "MISSING_SVG_ID",
|
|
1528
|
+
message: `svg-import "${e.id}" binding for tag "${r.tag}" references svgId "${r.svgId}" but no matching element exists in the imported SVG`,
|
|
1529
|
+
tag: r.tag
|
|
1530
|
+
});
|
|
1531
|
+
continue;
|
|
1532
|
+
}
|
|
1533
|
+
switch (r.type) {
|
|
1534
|
+
case "readout":
|
|
1535
|
+
o[r.tag] = {
|
|
1536
|
+
kind: "text",
|
|
1537
|
+
write(e, t) {
|
|
1538
|
+
e.setText(i, Tt(r, t));
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
break;
|
|
1542
|
+
case "state": {
|
|
1543
|
+
let e = `state:${r.tag}`;
|
|
1544
|
+
o[r.tag] = {
|
|
1545
|
+
kind: "state",
|
|
1546
|
+
write(t, n) {
|
|
1547
|
+
let a = Dt(r, n);
|
|
1548
|
+
if (a.ok) {
|
|
1549
|
+
l(e), t.setAttr(i, "class", a.state);
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
c(e, a.fault);
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
break;
|
|
1556
|
+
}
|
|
1557
|
+
case "visibility":
|
|
1558
|
+
o[r.tag] = {
|
|
1559
|
+
kind: "state",
|
|
1560
|
+
write(e, t) {
|
|
1561
|
+
e.setAttr(i, "display", Et(r, t) ? "inline" : "none");
|
|
1562
|
+
}
|
|
1563
|
+
};
|
|
1564
|
+
break;
|
|
1565
|
+
case "color-ramp":
|
|
1566
|
+
o[r.tag] = {
|
|
1567
|
+
kind: "numeric",
|
|
1568
|
+
write(e, n) {
|
|
1569
|
+
if (typeof n != "number") return;
|
|
1570
|
+
let a = Pt(r, n, t.tokens.colorRamp);
|
|
1571
|
+
a !== void 0 && e.setAttr(i, "fill", a);
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
break;
|
|
1575
|
+
case "blink": {
|
|
1576
|
+
let t = n.animateTransform(i, Bt, Vt), a = {
|
|
1577
|
+
kind: "animation",
|
|
1578
|
+
pause: () => t.pause(),
|
|
1579
|
+
resume: () => t.resume(),
|
|
1580
|
+
seek: (e) => t.seek(e)
|
|
1581
|
+
};
|
|
1582
|
+
o[`__svg-import-blink-animation-${e.id}-${r.tag}`] = a, o[r.tag] = {
|
|
1583
|
+
kind: "numeric",
|
|
1584
|
+
write(e, n) {
|
|
1585
|
+
typeof n == "number" && t.setPlaybackRate(St(r, n));
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
break;
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
return {
|
|
1593
|
+
svg: i,
|
|
1594
|
+
handles: o
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
//#endregion
|
|
1598
|
+
//#region src/topology/graph.ts
|
|
1599
|
+
function Ut(e) {
|
|
1600
|
+
let t = new Set(e.topology.nodes), n = e.topology.edges.map((e) => ({
|
|
1601
|
+
id: e.id,
|
|
1602
|
+
from: e.from,
|
|
1603
|
+
to: e.to,
|
|
1604
|
+
medium: e.medium
|
|
1605
|
+
})), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
1606
|
+
for (let e of n) {
|
|
1607
|
+
a.set(e.id, e);
|
|
1608
|
+
let t = r.get(e.from);
|
|
1609
|
+
t ? t.push(e) : r.set(e.from, [e]);
|
|
1610
|
+
let n = i.get(e.to);
|
|
1611
|
+
n ? n.push(e) : i.set(e.to, [e]);
|
|
1612
|
+
}
|
|
1613
|
+
return {
|
|
1614
|
+
nodes: t,
|
|
1615
|
+
edges: n,
|
|
1616
|
+
outgoing: r,
|
|
1617
|
+
incoming: i,
|
|
1618
|
+
edgeById: a
|
|
1619
|
+
};
|
|
1620
|
+
}
|
|
1621
|
+
//#endregion
|
|
1622
|
+
//#region src/topology/traversal.ts
|
|
1623
|
+
function Wt(e, t, n) {
|
|
1624
|
+
let r = n === "downstream" ? e.outgoing : e.incoming, i = (e) => n === "downstream" ? e.to : e.from, a = /* @__PURE__ */ new Set([t]), o = [t], s = e.nodes.size + 1, c = 0;
|
|
1625
|
+
for (; o.length > 0;) {
|
|
1626
|
+
if (c += 1, c > s) throw Error("reachableSet exceeded its node-count iteration bound — cycle guard invariant violated");
|
|
1627
|
+
let e = o.shift(), t = r.get(e) ?? [];
|
|
1628
|
+
for (let e of t) {
|
|
1629
|
+
let t = i(e);
|
|
1630
|
+
a.has(t) || (a.add(t), o.push(t));
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
return a;
|
|
1634
|
+
}
|
|
1635
|
+
function Gt(e, t) {
|
|
1636
|
+
return Wt(e, t, "upstream");
|
|
1637
|
+
}
|
|
1638
|
+
function Kt(e, t) {
|
|
1639
|
+
return Wt(e, t, "downstream");
|
|
1640
|
+
}
|
|
1641
|
+
//#endregion
|
|
1642
|
+
//#region src/topology/inference.ts
|
|
1643
|
+
function qt(e, t) {
|
|
1644
|
+
let n = /* @__PURE__ */ new Map();
|
|
1645
|
+
for (let r of e.nodes) n.set(r, t.has(r) ? [] : e.outgoing.get(r) ?? []);
|
|
1646
|
+
return {
|
|
1647
|
+
...e,
|
|
1648
|
+
outgoing: n
|
|
1649
|
+
};
|
|
1650
|
+
}
|
|
1651
|
+
function Jt(e, t) {
|
|
1652
|
+
let n = /* @__PURE__ */ new Set();
|
|
1653
|
+
for (let r of t) for (let t of Kt(e, r)) n.add(t);
|
|
1654
|
+
return n;
|
|
1655
|
+
}
|
|
1656
|
+
function Yt(e) {
|
|
1657
|
+
let { graph: t, sourceNodeIds: n, stoppedSourceNodeIds: r, closedNodeIds: i } = e, a = qt(t, i), o = [...n].filter((e) => !r.has(e)), s = Jt(t, n), c = Jt(a, n), l = Jt(a, o), u = /* @__PURE__ */ new Map();
|
|
1658
|
+
for (let e of t.nodes) if (s.has(e)) {
|
|
1659
|
+
if (!c.has(e)) {
|
|
1660
|
+
u.set(e, "isolated");
|
|
1661
|
+
continue;
|
|
1662
|
+
}
|
|
1663
|
+
u.set(e, l.has(e) ? "flowing" : "no-flow");
|
|
1664
|
+
}
|
|
1665
|
+
let d = /* @__PURE__ */ new Map();
|
|
1666
|
+
for (let e of t.edges) if (s.has(e.from)) {
|
|
1667
|
+
if (!c.has(e.from)) {
|
|
1668
|
+
d.set(e.id, "isolated");
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
if (i.has(e.from)) {
|
|
1672
|
+
d.set(e.id, c.has(e.to) ? "no-flow" : "isolated");
|
|
1673
|
+
continue;
|
|
1674
|
+
}
|
|
1675
|
+
d.set(e.id, l.has(e.from) ? "flowing" : "no-flow");
|
|
1676
|
+
}
|
|
1677
|
+
return {
|
|
1678
|
+
edgeStates: d,
|
|
1679
|
+
nodeStates: u
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
function Xt(e, t) {
|
|
1683
|
+
return JSON.stringify([[...e].sort(), [...t].sort()]);
|
|
1684
|
+
}
|
|
1685
|
+
var Zt = class {
|
|
1686
|
+
constructor(e, t) {
|
|
1687
|
+
this.graph = e, this.sourceNodeIds = t, this.result = {
|
|
1688
|
+
edgeStates: /* @__PURE__ */ new Map(),
|
|
1689
|
+
nodeStates: /* @__PURE__ */ new Map()
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
update(e, t) {
|
|
1693
|
+
let n = Xt(e, t);
|
|
1694
|
+
return n !== this.lastSignature && (this.result = Yt({
|
|
1695
|
+
graph: this.graph,
|
|
1696
|
+
sourceNodeIds: this.sourceNodeIds,
|
|
1697
|
+
stoppedSourceNodeIds: e,
|
|
1698
|
+
closedNodeIds: t
|
|
1699
|
+
}), this.lastSignature = n), this.result;
|
|
1700
|
+
}
|
|
1701
|
+
getEdgeState(e) {
|
|
1702
|
+
return this.result.edgeStates.get(e);
|
|
1703
|
+
}
|
|
1704
|
+
getNodeState(e) {
|
|
1705
|
+
return this.result.nodeStates.get(e);
|
|
1706
|
+
}
|
|
1707
|
+
getState(e) {
|
|
1708
|
+
return this.result.edgeStates.get(e) ?? this.result.nodeStates.get(e);
|
|
1709
|
+
}
|
|
1710
|
+
reset() {
|
|
1711
|
+
this.result = {
|
|
1712
|
+
edgeStates: /* @__PURE__ */ new Map(),
|
|
1713
|
+
nodeStates: /* @__PURE__ */ new Map()
|
|
1714
|
+
}, this.lastSignature = void 0;
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
1717
|
+
//#endregion
|
|
1718
|
+
//#region src/topology/upstream-highlight.ts
|
|
1719
|
+
function Qt(e, t) {
|
|
1720
|
+
let n = e.edgeById.get(t);
|
|
1721
|
+
if (!n) return;
|
|
1722
|
+
let r = /* @__PURE__ */ new Set([n.to]), i = /* @__PURE__ */ new Set([n.id]), a = [n];
|
|
1723
|
+
for (; a.length > 0;) {
|
|
1724
|
+
let t = a.shift();
|
|
1725
|
+
r.add(t.from);
|
|
1726
|
+
let o = e.incoming.get(t.from) ?? [];
|
|
1727
|
+
for (let e of o) e.medium === n.medium && (i.has(e.id) || (i.add(e.id), a.push(e)));
|
|
1728
|
+
}
|
|
1729
|
+
return {
|
|
1730
|
+
nodes: r,
|
|
1731
|
+
edges: i
|
|
1732
|
+
};
|
|
1733
|
+
}
|
|
1734
|
+
function $t(e) {
|
|
1735
|
+
return e === "mouse";
|
|
1736
|
+
}
|
|
1737
|
+
var en = "data-vscada-highlight";
|
|
1738
|
+
function tn(e, t, n) {
|
|
1739
|
+
let r = n.highlightAttr ?? en, i;
|
|
1740
|
+
function a(e, n) {
|
|
1741
|
+
e && t.setAttr(e, r, n ? "true" : "false");
|
|
1742
|
+
}
|
|
1743
|
+
function o() {
|
|
1744
|
+
if (i) {
|
|
1745
|
+
for (let e of i.nodes) a(n.getNodeElement(e), !1);
|
|
1746
|
+
for (let e of i.edges) a(n.getEdgeElement(e), !1);
|
|
1747
|
+
i = void 0;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return {
|
|
1751
|
+
onPointerEnter(t, r) {
|
|
1752
|
+
if (!$t(r.pointerType)) return;
|
|
1753
|
+
let s = Qt(e, t);
|
|
1754
|
+
if (s) {
|
|
1755
|
+
o(), i = s;
|
|
1756
|
+
for (let e of s.nodes) a(n.getNodeElement(e), !0);
|
|
1757
|
+
for (let e of s.edges) a(n.getEdgeElement(e), !0);
|
|
1758
|
+
}
|
|
1759
|
+
},
|
|
1760
|
+
onPointerLeave() {
|
|
1761
|
+
o();
|
|
1762
|
+
}
|
|
1763
|
+
};
|
|
1764
|
+
}
|
|
1765
|
+
//#endregion
|
|
1766
|
+
//#region src/view/group-view-state.ts
|
|
1767
|
+
var nn = class {
|
|
1768
|
+
constructor(e, t) {
|
|
1769
|
+
this.animationRegistry = t, this.collapsed = /* @__PURE__ */ new Map(), this.scene = e, this.seedFromScene(e);
|
|
1770
|
+
}
|
|
1771
|
+
seedFromScene(e) {
|
|
1772
|
+
this.collapsed = new Map(e.groups.map((e) => [e.id, e.collapsed]));
|
|
1773
|
+
}
|
|
1774
|
+
reset(e) {
|
|
1775
|
+
this.scene = e, this.seedFromScene(e);
|
|
1776
|
+
}
|
|
1777
|
+
isCollapsed(e) {
|
|
1778
|
+
return this.collapsed.get(e) ?? !1;
|
|
1779
|
+
}
|
|
1780
|
+
collapsedGroupIds() {
|
|
1781
|
+
let e = /* @__PURE__ */ new Set();
|
|
1782
|
+
for (let [t, n] of this.collapsed) n && e.add(t);
|
|
1783
|
+
return e;
|
|
1784
|
+
}
|
|
1785
|
+
toggleGroup(e) {
|
|
1786
|
+
return this.setCollapsed(e, !this.isCollapsed(e));
|
|
1787
|
+
}
|
|
1788
|
+
setCollapsed(e, t) {
|
|
1789
|
+
let n = this.scene.groups.find((t) => t.id === e);
|
|
1790
|
+
if (!n) return this.isCollapsed(e);
|
|
1791
|
+
let r = this.isCollapsed(e);
|
|
1792
|
+
return this.collapsed.set(e, t), t && !r && this.deregisterChildren(n), t;
|
|
1793
|
+
}
|
|
1794
|
+
deregisterChildren(e) {
|
|
1795
|
+
if (this.animationRegistry) for (let t of e.children) this.animationRegistry.pauseAll(t), this.animationRegistry.unregisterElement(t);
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
function rn(e, t) {
|
|
1799
|
+
return new nn(e, t);
|
|
1800
|
+
}
|
|
1801
|
+
//#endregion
|
|
1802
|
+
//#region src/fsm/fsm.ts
|
|
1803
|
+
var an = "unknown", on = class {
|
|
1804
|
+
constructor(e, t, n, r) {
|
|
1805
|
+
this.map = e, this.transitions = t, this.defaultTransition = n, this.onWarning = r;
|
|
1806
|
+
}
|
|
1807
|
+
resolve(e, t) {
|
|
1808
|
+
let n = String(e), r = this.map[n], i = this.currentState;
|
|
1809
|
+
if (r === void 0) {
|
|
1810
|
+
this.onWarning?.({
|
|
1811
|
+
code: "UNMAPPED_STATE_VALUE",
|
|
1812
|
+
message: `Tag "${t}": value "${n}" has no entry in this binding's state map`,
|
|
1813
|
+
tag: t
|
|
1814
|
+
});
|
|
1815
|
+
let e = i ?? "unknown";
|
|
1816
|
+
return {
|
|
1817
|
+
state: e,
|
|
1818
|
+
previousState: i,
|
|
1819
|
+
transition: this.resolveDefault(i, e),
|
|
1820
|
+
changed: !1
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
if (this.currentState = r, i === void 0 || i === r) return {
|
|
1824
|
+
state: r,
|
|
1825
|
+
previousState: i,
|
|
1826
|
+
transition: this.resolveDefault(i, r),
|
|
1827
|
+
changed: !1
|
|
1828
|
+
};
|
|
1829
|
+
let a = `${i}→${r}`;
|
|
1830
|
+
return {
|
|
1831
|
+
state: r,
|
|
1832
|
+
previousState: i,
|
|
1833
|
+
transition: this.transitions[a] ?? this.resolveDefault(i, r),
|
|
1834
|
+
changed: !0
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
resolveDefault(e, t) {
|
|
1838
|
+
return typeof this.defaultTransition == "function" ? this.defaultTransition(e, t) : this.defaultTransition;
|
|
1839
|
+
}
|
|
1840
|
+
};
|
|
1841
|
+
function sn(e, t, n, r = 44) {
|
|
1842
|
+
let i = r / n, a = Math.max(e, i), o = Math.max(t, i);
|
|
1843
|
+
return {
|
|
1844
|
+
x: (e - a) / 2,
|
|
1845
|
+
y: (t - o) / 2,
|
|
1846
|
+
w: a,
|
|
1847
|
+
h: o
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
var cn = "http://www.w3.org/2000/svg";
|
|
1851
|
+
function ln(e, t, n, r = {
|
|
1852
|
+
x: 0,
|
|
1853
|
+
y: 0
|
|
1854
|
+
}) {
|
|
1855
|
+
let i = sn(e, t, n), a = document.createElementNS(cn, "rect");
|
|
1856
|
+
return a.setAttribute("x", String(i.x + r.x)), a.setAttribute("y", String(i.y + r.y)), a.setAttribute("width", String(i.w)), a.setAttribute("height", String(i.h)), a.setAttribute("fill", "transparent"), a.setAttribute("class", "vscada-hit-area"), a.style.pointerEvents = "all", a.style.cursor = "pointer", a.setAttribute("tabindex", "0"), a.setAttribute("role", "button"), a;
|
|
1857
|
+
}
|
|
1858
|
+
function un(e, t, n, r, i = {
|
|
1859
|
+
x: 0,
|
|
1860
|
+
y: 0
|
|
1861
|
+
}) {
|
|
1862
|
+
let a = sn(t, n, r);
|
|
1863
|
+
e.setAttribute("x", String(a.x + i.x)), e.setAttribute("y", String(a.y + i.y)), e.setAttribute("width", String(a.w)), e.setAttribute("height", String(a.h));
|
|
1864
|
+
}
|
|
1865
|
+
function dn(e = 10) {
|
|
1866
|
+
let t = /* @__PURE__ */ new Map();
|
|
1867
|
+
return {
|
|
1868
|
+
onPointerDown(e, n, r) {
|
|
1869
|
+
t.set(e, {
|
|
1870
|
+
x: n,
|
|
1871
|
+
y: r
|
|
1872
|
+
});
|
|
1873
|
+
},
|
|
1874
|
+
onPointerUp(n, r, i) {
|
|
1875
|
+
let a = t.get(n);
|
|
1876
|
+
return t.delete(n), a && Math.hypot(r - a.x, i - a.y) <= e ? "tap" : "drag";
|
|
1877
|
+
},
|
|
1878
|
+
onPointerCancel(e) {
|
|
1879
|
+
t.delete(e);
|
|
1880
|
+
}
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
//#endregion
|
|
1884
|
+
//#region src/interaction/pointer-pipeline.ts
|
|
1885
|
+
function fn(e, t) {
|
|
1886
|
+
let { elementId: n, elementType: r, tags: i, arbiter: a, isInteractive: o, onClick: s, onHoverChange: c } = t;
|
|
1887
|
+
e.addEventListener("pointerdown", (e) => {
|
|
1888
|
+
let t = e;
|
|
1889
|
+
a.onPointerDown(t.pointerId, t.clientX, t.clientY);
|
|
1890
|
+
}), e.addEventListener("pointerup", (e) => {
|
|
1891
|
+
let t = e;
|
|
1892
|
+
a.onPointerUp(t.pointerId, t.clientX, t.clientY) !== "tap" || !o() || s({
|
|
1893
|
+
elementId: n,
|
|
1894
|
+
tags: i,
|
|
1895
|
+
elementType: r
|
|
1896
|
+
});
|
|
1897
|
+
}), e.addEventListener("pointercancel", (e) => {
|
|
1898
|
+
a.onPointerCancel(e.pointerId);
|
|
1899
|
+
}), e.addEventListener("keydown", (e) => {
|
|
1900
|
+
let t = e;
|
|
1901
|
+
t.key !== "Enter" && t.key !== " " || o() && (t.preventDefault(), s({
|
|
1902
|
+
elementId: n,
|
|
1903
|
+
tags: i,
|
|
1904
|
+
elementType: r
|
|
1905
|
+
}));
|
|
1906
|
+
}), c && (e.addEventListener("pointerenter", (e) => {
|
|
1907
|
+
e.pointerType === "mouse" && c(!0);
|
|
1908
|
+
}), e.addEventListener("pointerleave", (e) => {
|
|
1909
|
+
e.pointerType === "mouse" && c(!1);
|
|
1910
|
+
}));
|
|
1911
|
+
}
|
|
1912
|
+
//#endregion
|
|
1913
|
+
//#region src/interaction/pan-zoom-gestures.ts
|
|
1914
|
+
var pn = .0015;
|
|
1915
|
+
function mn(e, t) {
|
|
1916
|
+
return Math.hypot(e.x - t.x, e.y - t.y);
|
|
1917
|
+
}
|
|
1918
|
+
function hn(e, t) {
|
|
1919
|
+
return {
|
|
1920
|
+
x: (e.x + t.x) / 2,
|
|
1921
|
+
y: (e.y + t.y) / 2
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
function gn(e, t = 10) {
|
|
1925
|
+
let n = /* @__PURE__ */ new Map(), r = null, i = null;
|
|
1926
|
+
function a() {
|
|
1927
|
+
if (n.size < 2) return null;
|
|
1928
|
+
let e = [...n.values()];
|
|
1929
|
+
return [e[0], e[1]];
|
|
1930
|
+
}
|
|
1931
|
+
return {
|
|
1932
|
+
onPointerDown(e, t, o) {
|
|
1933
|
+
if (n.set(e, {
|
|
1934
|
+
originX: t,
|
|
1935
|
+
originY: o,
|
|
1936
|
+
x: t,
|
|
1937
|
+
y: o
|
|
1938
|
+
}), n.size >= 2) {
|
|
1939
|
+
r = null;
|
|
1940
|
+
let e = a();
|
|
1941
|
+
i = e ? mn(e[0], e[1]) : null;
|
|
1942
|
+
}
|
|
1943
|
+
},
|
|
1944
|
+
onPointerMove(o, s, c) {
|
|
1945
|
+
let l = n.get(o);
|
|
1946
|
+
if (!l) return;
|
|
1947
|
+
if (l.x = s, l.y = c, n.size >= 2) {
|
|
1948
|
+
let t = a();
|
|
1949
|
+
if (!t || i === null || i < 1) return;
|
|
1950
|
+
let n = mn(t[0], t[1]), r = n / i;
|
|
1951
|
+
i = n;
|
|
1952
|
+
let o = hn(t[0], t[1]);
|
|
1953
|
+
e.onZoomAboutPoint(e.getZoom() * r, o.x, o.y);
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
if (r === null) {
|
|
1957
|
+
if (Math.hypot(s - l.originX, c - l.originY) <= t) return;
|
|
1958
|
+
r = o, l.originX = s, l.originY = c;
|
|
1959
|
+
return;
|
|
1960
|
+
}
|
|
1961
|
+
if (o !== r) return;
|
|
1962
|
+
let u = s - l.originX, d = c - l.originY;
|
|
1963
|
+
l.originX = s, l.originY = c, e.onPan(u, d);
|
|
1964
|
+
},
|
|
1965
|
+
onPointerUp(e) {
|
|
1966
|
+
n.delete(e), r === e && (r = null), n.size < 2 && (i = null);
|
|
1967
|
+
},
|
|
1968
|
+
onPointerCancel(e) {
|
|
1969
|
+
n.delete(e), r === e && (r = null), n.size < 2 && (i = null);
|
|
1970
|
+
},
|
|
1971
|
+
onWheel(t, n, r) {
|
|
1972
|
+
let i = Math.exp(-t * pn);
|
|
1973
|
+
e.onZoomAboutPoint(e.getZoom() * i, n, r);
|
|
1974
|
+
}
|
|
1975
|
+
};
|
|
1976
|
+
}
|
|
1977
|
+
//#endregion
|
|
1978
|
+
//#region src/fsm/tween.ts
|
|
1979
|
+
var _n = .6, vn = 10;
|
|
1980
|
+
function yn(e) {
|
|
1981
|
+
if (e >= 1) return 1;
|
|
1982
|
+
let t = 10 * Math.sqrt(1 - _n * _n), n = Math.exp(-.6 * 10 * e), r = _n * 10 / t;
|
|
1983
|
+
return 1 - n * (Math.cos(t * e) + r * Math.sin(t * e));
|
|
1984
|
+
}
|
|
1985
|
+
var bn = {
|
|
1986
|
+
linear: (e) => e,
|
|
1987
|
+
"ease-in": (e) => e * e,
|
|
1988
|
+
"ease-out": (e) => 1 - (1 - e) * (1 - e),
|
|
1989
|
+
"critically-damped-overshoot": yn
|
|
1990
|
+
};
|
|
1991
|
+
function xn(e) {
|
|
1992
|
+
return bn[e] ?? bn.linear;
|
|
1993
|
+
}
|
|
1994
|
+
var Sn = class {
|
|
1995
|
+
constructor(e) {
|
|
1996
|
+
this.startTime = 0, this.durationMs = 1, this.easing = bn.linear, this.startValue = e, this.targetValue = e;
|
|
1997
|
+
}
|
|
1998
|
+
retarget(e, t, n, r) {
|
|
1999
|
+
this.startValue = this.valueAt(e), this.targetValue = t, this.startTime = e, this.durationMs = Math.max(n, 1), this.easing = xn(r);
|
|
2000
|
+
}
|
|
2001
|
+
valueAt(e) {
|
|
2002
|
+
let t = Math.min(Math.max((e - this.startTime) / this.durationMs, 0), 1);
|
|
2003
|
+
return this.startValue + (this.targetValue - this.startValue) * this.easing(t);
|
|
2004
|
+
}
|
|
2005
|
+
isSettled(e) {
|
|
2006
|
+
return e - this.startTime >= this.durationMs;
|
|
2007
|
+
}
|
|
2008
|
+
snap(e) {
|
|
2009
|
+
this.startValue = this.targetValue, this.startTime = e, this.durationMs = 1;
|
|
2010
|
+
}
|
|
2011
|
+
};
|
|
2012
|
+
function Cn(e, t, n) {
|
|
2013
|
+
return Math.min(Math.max(e, t), n);
|
|
2014
|
+
}
|
|
2015
|
+
function wn(e, t, n, r) {
|
|
2016
|
+
let i = t - r - t * n, a = r;
|
|
2017
|
+
return i > a ? (i + a) / 2 : Cn(e, i, a);
|
|
2018
|
+
}
|
|
2019
|
+
var Tn = class {
|
|
2020
|
+
constructor(e, t, n = {}) {
|
|
2021
|
+
this.timeSource = e, this.onFrame = t, this.canvasWidth = 0, this.canvasHeight = 0, this.zoomValue = 1, this.panXValue = 0, this.panYValue = 0, this.tween = null, this.stopTick = null, this.minZoom = n.minZoom ?? .25, this.maxZoom = n.maxZoom ?? 4, this.panMarginPx = n.panMarginPx ?? 100, this.zoomTweenDurationMs = n.zoomTweenDurationMs ?? 300;
|
|
2022
|
+
}
|
|
2023
|
+
get zoom() {
|
|
2024
|
+
return this.zoomValue;
|
|
2025
|
+
}
|
|
2026
|
+
get pan() {
|
|
2027
|
+
return {
|
|
2028
|
+
x: this.panXValue,
|
|
2029
|
+
y: this.panYValue
|
|
2030
|
+
};
|
|
2031
|
+
}
|
|
2032
|
+
reset(e, t) {
|
|
2033
|
+
this.canvasWidth = e, this.canvasHeight = t, this.tween = null, this.stopTick?.(), this.stopTick = null, this.zoomValue = 1, this.panXValue = 0, this.panYValue = 0, this.onFrame(this.currentTransform());
|
|
2034
|
+
}
|
|
2035
|
+
currentTransform() {
|
|
2036
|
+
return {
|
|
2037
|
+
zoom: this.zoomValue,
|
|
2038
|
+
panX: this.panXValue,
|
|
2039
|
+
panY: this.panYValue
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
clampZoom(e) {
|
|
2043
|
+
return Cn(e, this.minZoom, this.maxZoom);
|
|
2044
|
+
}
|
|
2045
|
+
applyPanClamp() {
|
|
2046
|
+
this.panXValue = wn(this.panXValue, this.canvasWidth, this.zoomValue, this.panMarginPx), this.panYValue = wn(this.panYValue, this.canvasHeight, this.zoomValue, this.panMarginPx);
|
|
2047
|
+
}
|
|
2048
|
+
setZoomImmediate(e) {
|
|
2049
|
+
this.tween = null, this.stopTick?.(), this.stopTick = null, this.zoomValue = this.clampZoom(e), this.applyPanClamp(), this.onFrame(this.currentTransform());
|
|
2050
|
+
}
|
|
2051
|
+
setZoomAnimated(e, t = this.zoomTweenDurationMs) {
|
|
2052
|
+
let n = this.clampZoom(e), r = this.timeSource.now(), i = new Sn(this.zoomValue);
|
|
2053
|
+
i.retarget(r, n, t, "ease-out"), this.tween = i, this.ensureAnimating();
|
|
2054
|
+
}
|
|
2055
|
+
panBy(e, t) {
|
|
2056
|
+
this.panXValue += e, this.panYValue += t, this.applyPanClamp(), this.onFrame(this.currentTransform());
|
|
2057
|
+
}
|
|
2058
|
+
zoomAboutPoint(e, t, n) {
|
|
2059
|
+
this.tween = null, this.stopTick?.(), this.stopTick = null;
|
|
2060
|
+
let r = this.zoomValue, i = this.clampZoom(e), a = i / r;
|
|
2061
|
+
this.panXValue = t - (t - this.panXValue) * a, this.panYValue = n - (n - this.panYValue) * a, this.zoomValue = i, this.applyPanClamp(), this.onFrame(this.currentTransform());
|
|
2062
|
+
}
|
|
2063
|
+
ensureAnimating() {
|
|
2064
|
+
this.stopTick || (this.stopTick = this.timeSource.onTick((e) => this.tickTween(e)));
|
|
2065
|
+
}
|
|
2066
|
+
tickTween(e) {
|
|
2067
|
+
let t = this.tween;
|
|
2068
|
+
if (!t) {
|
|
2069
|
+
this.stopTick?.(), this.stopTick = null;
|
|
2070
|
+
return;
|
|
2071
|
+
}
|
|
2072
|
+
this.zoomValue = t.valueAt(e), this.applyPanClamp(), this.onFrame(this.currentTransform()), t.isSettled(e) && (this.tween = null, this.stopTick?.(), this.stopTick = null);
|
|
2073
|
+
}
|
|
2074
|
+
snap() {
|
|
2075
|
+
if (!this.tween) return;
|
|
2076
|
+
let e = this.timeSource.now();
|
|
2077
|
+
this.tween.snap(e), this.zoomValue = this.tween.valueAt(e), this.tween = null, this.stopTick?.(), this.stopTick = null, this.applyPanClamp(), this.onFrame(this.currentTransform());
|
|
2078
|
+
}
|
|
2079
|
+
destroy() {
|
|
2080
|
+
this.stopTick?.(), this.stopTick = null, this.tween = null;
|
|
2081
|
+
}
|
|
2082
|
+
};
|
|
2083
|
+
function En(e, t, n) {
|
|
2084
|
+
return new Tn(e, t, n);
|
|
2085
|
+
}
|
|
2086
|
+
//#endregion
|
|
2087
|
+
//#region src/license/format.ts
|
|
2088
|
+
var Dn = "VSCADA";
|
|
2089
|
+
function On(e) {
|
|
2090
|
+
try {
|
|
2091
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
|
|
2092
|
+
for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
|
|
2093
|
+
return i;
|
|
2094
|
+
} catch {
|
|
2095
|
+
return null;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
function kn(e) {
|
|
2099
|
+
return typeof e == "object" && !!e && typeof e.company == "string" && typeof e.expiry == "string" && typeof e.tier == "string" && typeof e.keyId == "string";
|
|
2100
|
+
}
|
|
2101
|
+
function An(e) {
|
|
2102
|
+
let t = e.split(".");
|
|
2103
|
+
if (t.length !== 4 || t[0] !== Dn) return null;
|
|
2104
|
+
let [, n, r, i] = t, a = On(r);
|
|
2105
|
+
if (!a) return null;
|
|
2106
|
+
let o;
|
|
2107
|
+
try {
|
|
2108
|
+
o = JSON.parse(new TextDecoder().decode(a));
|
|
2109
|
+
} catch {
|
|
2110
|
+
return null;
|
|
2111
|
+
}
|
|
2112
|
+
if (!kn(o)) return null;
|
|
2113
|
+
let s = On(i);
|
|
2114
|
+
return s ? {
|
|
2115
|
+
version: n,
|
|
2116
|
+
encodedPayload: r,
|
|
2117
|
+
payload: o,
|
|
2118
|
+
signature: s
|
|
2119
|
+
} : null;
|
|
2120
|
+
}
|
|
2121
|
+
function jn(e, t) {
|
|
2122
|
+
return new TextEncoder().encode(`${e}.${t}`);
|
|
2123
|
+
}
|
|
2124
|
+
//#endregion
|
|
2125
|
+
//#region src/license/vendor-keys.ts
|
|
2126
|
+
var Mn = {};
|
|
2127
|
+
//#endregion
|
|
2128
|
+
//#region src/license/verify-webcrypto.ts
|
|
2129
|
+
function Nn() {
|
|
2130
|
+
return globalThis.crypto?.subtle !== void 0;
|
|
2131
|
+
}
|
|
2132
|
+
async function Pn(e, t, n) {
|
|
2133
|
+
let r = globalThis.crypto?.subtle;
|
|
2134
|
+
if (!r) return !1;
|
|
2135
|
+
try {
|
|
2136
|
+
let i = await r.importKey("jwk", n, {
|
|
2137
|
+
name: "ECDSA",
|
|
2138
|
+
namedCurve: "P-256"
|
|
2139
|
+
}, !1, ["verify"]);
|
|
2140
|
+
return await r.verify({
|
|
2141
|
+
name: "ECDSA",
|
|
2142
|
+
hash: "SHA-256"
|
|
2143
|
+
}, i, t, e);
|
|
2144
|
+
} catch {
|
|
2145
|
+
return !1;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
//#endregion
|
|
2149
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
|
|
2150
|
+
function Fn(e) {
|
|
2151
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
|
|
2152
|
+
}
|
|
2153
|
+
function M(e, t = "") {
|
|
2154
|
+
if (typeof e != "number") {
|
|
2155
|
+
let n = t && `"${t}" `;
|
|
2156
|
+
throw TypeError(`${n}expected number, got ${typeof e}`);
|
|
2157
|
+
}
|
|
2158
|
+
if (!Number.isSafeInteger(e) || e < 0) {
|
|
2159
|
+
let n = t && `"${t}" `;
|
|
2160
|
+
throw RangeError(`${n}expected integer >= 0, got ${e}`);
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
function N(e, t, n = "") {
|
|
2164
|
+
let r = Fn(e), i = e?.length, a = t !== void 0;
|
|
2165
|
+
if (!r || a && i !== t) {
|
|
2166
|
+
let o = n && `"${n}" `, s = a ? ` of length ${t}` : "", c = r ? `length=${i}` : `type=${typeof e}`, l = o + "expected Uint8Array" + s + ", got " + c;
|
|
2167
|
+
throw r ? RangeError(l) : TypeError(l);
|
|
2168
|
+
}
|
|
2169
|
+
return e;
|
|
2170
|
+
}
|
|
2171
|
+
function In(e) {
|
|
2172
|
+
if (typeof e != "function" || typeof e.create != "function") throw TypeError("Hash must wrapped by utils.createHasher");
|
|
2173
|
+
if (M(e.outputLen), M(e.blockLen), e.outputLen < 1) throw Error("\"outputLen\" must be >= 1");
|
|
2174
|
+
if (e.blockLen < 1) throw Error("\"blockLen\" must be >= 1");
|
|
2175
|
+
}
|
|
2176
|
+
function Ln(e, t = !0) {
|
|
2177
|
+
if (e.destroyed) throw Error("Hash instance has been destroyed");
|
|
2178
|
+
if (t && e.finished) throw Error("Hash#digest() has already been called");
|
|
2179
|
+
}
|
|
2180
|
+
function Rn(e, t) {
|
|
2181
|
+
N(e, void 0, "digestInto() output");
|
|
2182
|
+
let n = t.outputLen;
|
|
2183
|
+
if (e.length < n) throw RangeError("\"digestInto() output\" expected to be of length >=" + n);
|
|
2184
|
+
}
|
|
2185
|
+
function zn(...e) {
|
|
2186
|
+
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
2187
|
+
}
|
|
2188
|
+
function Bn(e) {
|
|
2189
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
2190
|
+
}
|
|
2191
|
+
function P(e, t) {
|
|
2192
|
+
return e << 32 - t | e >>> t;
|
|
2193
|
+
}
|
|
2194
|
+
var Vn = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Hn = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
2195
|
+
function Un(e) {
|
|
2196
|
+
if (N(e), Vn) return e.toHex();
|
|
2197
|
+
let t = "";
|
|
2198
|
+
for (let n = 0; n < e.length; n++) t += Hn[e[n]];
|
|
2199
|
+
return t;
|
|
2200
|
+
}
|
|
2201
|
+
var F = {
|
|
2202
|
+
_0: 48,
|
|
2203
|
+
_9: 57,
|
|
2204
|
+
A: 65,
|
|
2205
|
+
F: 70,
|
|
2206
|
+
a: 97,
|
|
2207
|
+
f: 102
|
|
2208
|
+
};
|
|
2209
|
+
function Wn(e) {
|
|
2210
|
+
if (e >= F._0 && e <= F._9) return e - F._0;
|
|
2211
|
+
if (e >= F.A && e <= F.F) return e - (F.A - 10);
|
|
2212
|
+
if (e >= F.a && e <= F.f) return e - (F.a - 10);
|
|
2213
|
+
}
|
|
2214
|
+
function Gn(e) {
|
|
2215
|
+
if (typeof e != "string") throw TypeError("hex string expected, got " + typeof e);
|
|
2216
|
+
if (Vn) try {
|
|
2217
|
+
return Uint8Array.fromHex(e);
|
|
2218
|
+
} catch (e) {
|
|
2219
|
+
throw e instanceof SyntaxError ? RangeError(e.message) : e;
|
|
2220
|
+
}
|
|
2221
|
+
let t = e.length, n = t / 2;
|
|
2222
|
+
if (t % 2) throw RangeError("hex string expected, got unpadded hex of length " + t);
|
|
2223
|
+
let r = new Uint8Array(n);
|
|
2224
|
+
for (let t = 0, i = 0; t < n; t++, i += 2) {
|
|
2225
|
+
let n = Wn(e.charCodeAt(i)), a = Wn(e.charCodeAt(i + 1));
|
|
2226
|
+
if (n === void 0 || a === void 0) {
|
|
2227
|
+
let t = e[i] + e[i + 1];
|
|
2228
|
+
throw RangeError("hex string expected, got non-hex character \"" + t + "\" at index " + i);
|
|
2229
|
+
}
|
|
2230
|
+
r[t] = n * 16 + a;
|
|
2231
|
+
}
|
|
2232
|
+
return r;
|
|
2233
|
+
}
|
|
2234
|
+
function Kn(...e) {
|
|
2235
|
+
let t = 0;
|
|
2236
|
+
for (let n = 0; n < e.length; n++) {
|
|
2237
|
+
let r = e[n];
|
|
2238
|
+
N(r), t += r.length;
|
|
2239
|
+
}
|
|
2240
|
+
let n = new Uint8Array(t);
|
|
2241
|
+
for (let t = 0, r = 0; t < e.length; t++) {
|
|
2242
|
+
let i = e[t];
|
|
2243
|
+
n.set(i, r), r += i.length;
|
|
2244
|
+
}
|
|
2245
|
+
return n;
|
|
2246
|
+
}
|
|
2247
|
+
function qn(e, t = {}) {
|
|
2248
|
+
let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
|
|
2249
|
+
return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
|
|
2250
|
+
}
|
|
2251
|
+
function Jn(e = 32) {
|
|
2252
|
+
M(e, "bytesLength");
|
|
2253
|
+
let t = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
2254
|
+
if (typeof t?.getRandomValues != "function") throw Error("crypto.getRandomValues must be defined");
|
|
2255
|
+
if (e > 65536) throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);
|
|
2256
|
+
return t.getRandomValues(new Uint8Array(e));
|
|
2257
|
+
}
|
|
2258
|
+
var Yn = (e) => ({ oid: Uint8Array.from([
|
|
2259
|
+
6,
|
|
2260
|
+
9,
|
|
2261
|
+
96,
|
|
2262
|
+
134,
|
|
2263
|
+
72,
|
|
2264
|
+
1,
|
|
2265
|
+
101,
|
|
2266
|
+
3,
|
|
2267
|
+
4,
|
|
2268
|
+
2,
|
|
2269
|
+
e
|
|
2270
|
+
]) });
|
|
2271
|
+
//#endregion
|
|
2272
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
2273
|
+
function I(e) {
|
|
2274
|
+
"@babel/helpers - typeof";
|
|
2275
|
+
return I = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
2276
|
+
return typeof e;
|
|
2277
|
+
} : function(e) {
|
|
2278
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
2279
|
+
}, I(e);
|
|
2280
|
+
}
|
|
2281
|
+
//#endregion
|
|
2282
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
2283
|
+
function Xn(e, t) {
|
|
2284
|
+
if (I(e) != "object" || !e) return e;
|
|
2285
|
+
var n = e[Symbol.toPrimitive];
|
|
2286
|
+
if (n !== void 0) {
|
|
2287
|
+
var r = n.call(e, t || "default");
|
|
2288
|
+
if (I(r) != "object") return r;
|
|
2289
|
+
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
2290
|
+
}
|
|
2291
|
+
return (t === "string" ? String : Number)(e);
|
|
2292
|
+
}
|
|
2293
|
+
//#endregion
|
|
2294
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
2295
|
+
function Zn(e) {
|
|
2296
|
+
var t = Xn(e, "string");
|
|
2297
|
+
return I(t) == "symbol" ? t : t + "";
|
|
2298
|
+
}
|
|
2299
|
+
//#endregion
|
|
2300
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
2301
|
+
function L(e, t, n) {
|
|
2302
|
+
return (t = Zn(t)) in e ? Object.defineProperty(e, t, {
|
|
2303
|
+
value: n,
|
|
2304
|
+
enumerable: !0,
|
|
2305
|
+
configurable: !0,
|
|
2306
|
+
writable: !0
|
|
2307
|
+
}) : e[t] = n, e;
|
|
2308
|
+
}
|
|
2309
|
+
//#endregion
|
|
2310
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
|
|
2311
|
+
function Qn(e, t, n) {
|
|
2312
|
+
return e & t ^ ~e & n;
|
|
2313
|
+
}
|
|
2314
|
+
function $n(e, t, n) {
|
|
2315
|
+
return e & t ^ e & n ^ t & n;
|
|
2316
|
+
}
|
|
2317
|
+
var er = class {
|
|
2318
|
+
constructor(e, t, n, r) {
|
|
2319
|
+
L(this, "blockLen", void 0), L(this, "outputLen", void 0), L(this, "canXOF", !1), L(this, "padOffset", void 0), L(this, "isLE", void 0), L(this, "buffer", void 0), L(this, "view", void 0), L(this, "finished", !1), L(this, "length", 0), L(this, "pos", 0), L(this, "destroyed", !1), this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = Bn(this.buffer);
|
|
2320
|
+
}
|
|
2321
|
+
update(e) {
|
|
2322
|
+
Ln(this), N(e);
|
|
2323
|
+
let { view: t, buffer: n, blockLen: r } = this, i = e.length;
|
|
2324
|
+
for (let a = 0; a < i;) {
|
|
2325
|
+
let o = Math.min(r - this.pos, i - a);
|
|
2326
|
+
if (o === r) {
|
|
2327
|
+
let t = Bn(e);
|
|
2328
|
+
for (; r <= i - a; a += r) this.process(t, a);
|
|
2329
|
+
continue;
|
|
2330
|
+
}
|
|
2331
|
+
n.set(e.subarray(a, a + o), this.pos), this.pos += o, a += o, this.pos === r && (this.process(t, 0), this.pos = 0);
|
|
2332
|
+
}
|
|
2333
|
+
return this.length += e.length, this.roundClean(), this;
|
|
2334
|
+
}
|
|
2335
|
+
digestInto(e) {
|
|
2336
|
+
Ln(this), Rn(e, this), this.finished = !0;
|
|
2337
|
+
let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
|
|
2338
|
+
t[a++] = 128, zn(this.buffer.subarray(a)), this.padOffset > r - a && (this.process(n, 0), a = 0);
|
|
2339
|
+
for (let e = a; e < r; e++) t[e] = 0;
|
|
2340
|
+
n.setBigUint64(r - 8, BigInt(this.length * 8), i), this.process(n, 0);
|
|
2341
|
+
let o = Bn(e), s = this.outputLen;
|
|
2342
|
+
if (s % 4) throw Error("_sha2: outputLen must be aligned to 32bit");
|
|
2343
|
+
let c = s / 4, l = this.get();
|
|
2344
|
+
if (c > l.length) throw Error("_sha2: outputLen bigger than state");
|
|
2345
|
+
for (let e = 0; e < c; e++) o.setUint32(4 * e, l[e], i);
|
|
2346
|
+
}
|
|
2347
|
+
digest() {
|
|
2348
|
+
let { buffer: e, outputLen: t } = this;
|
|
2349
|
+
this.digestInto(e);
|
|
2350
|
+
let n = e.slice(0, t);
|
|
2351
|
+
return this.destroy(), n;
|
|
2352
|
+
}
|
|
2353
|
+
_cloneInto(e) {
|
|
2354
|
+
e || (e = new this.constructor()), e.set(...this.get());
|
|
2355
|
+
let { blockLen: t, buffer: n, length: r, finished: i, destroyed: a, pos: o } = this;
|
|
2356
|
+
return e.destroyed = a, e.finished = i, e.length = r, e.pos = o, r % t && e.buffer.set(n), e;
|
|
2357
|
+
}
|
|
2358
|
+
clone() {
|
|
2359
|
+
return this._cloneInto();
|
|
2360
|
+
}
|
|
2361
|
+
}, R = /* @__PURE__ */ Uint32Array.from([
|
|
2362
|
+
1779033703,
|
|
2363
|
+
3144134277,
|
|
2364
|
+
1013904242,
|
|
2365
|
+
2773480762,
|
|
2366
|
+
1359893119,
|
|
2367
|
+
2600822924,
|
|
2368
|
+
528734635,
|
|
2369
|
+
1541459225
|
|
2370
|
+
]), tr = /* @__PURE__ */ Uint32Array.from([
|
|
2371
|
+
1116352408,
|
|
2372
|
+
1899447441,
|
|
2373
|
+
3049323471,
|
|
2374
|
+
3921009573,
|
|
2375
|
+
961987163,
|
|
2376
|
+
1508970993,
|
|
2377
|
+
2453635748,
|
|
2378
|
+
2870763221,
|
|
2379
|
+
3624381080,
|
|
2380
|
+
310598401,
|
|
2381
|
+
607225278,
|
|
2382
|
+
1426881987,
|
|
2383
|
+
1925078388,
|
|
2384
|
+
2162078206,
|
|
2385
|
+
2614888103,
|
|
2386
|
+
3248222580,
|
|
2387
|
+
3835390401,
|
|
2388
|
+
4022224774,
|
|
2389
|
+
264347078,
|
|
2390
|
+
604807628,
|
|
2391
|
+
770255983,
|
|
2392
|
+
1249150122,
|
|
2393
|
+
1555081692,
|
|
2394
|
+
1996064986,
|
|
2395
|
+
2554220882,
|
|
2396
|
+
2821834349,
|
|
2397
|
+
2952996808,
|
|
2398
|
+
3210313671,
|
|
2399
|
+
3336571891,
|
|
2400
|
+
3584528711,
|
|
2401
|
+
113926993,
|
|
2402
|
+
338241895,
|
|
2403
|
+
666307205,
|
|
2404
|
+
773529912,
|
|
2405
|
+
1294757372,
|
|
2406
|
+
1396182291,
|
|
2407
|
+
1695183700,
|
|
2408
|
+
1986661051,
|
|
2409
|
+
2177026350,
|
|
2410
|
+
2456956037,
|
|
2411
|
+
2730485921,
|
|
2412
|
+
2820302411,
|
|
2413
|
+
3259730800,
|
|
2414
|
+
3345764771,
|
|
2415
|
+
3516065817,
|
|
2416
|
+
3600352804,
|
|
2417
|
+
4094571909,
|
|
2418
|
+
275423344,
|
|
2419
|
+
430227734,
|
|
2420
|
+
506948616,
|
|
2421
|
+
659060556,
|
|
2422
|
+
883997877,
|
|
2423
|
+
958139571,
|
|
2424
|
+
1322822218,
|
|
2425
|
+
1537002063,
|
|
2426
|
+
1747873779,
|
|
2427
|
+
1955562222,
|
|
2428
|
+
2024104815,
|
|
2429
|
+
2227730452,
|
|
2430
|
+
2361852424,
|
|
2431
|
+
2428436474,
|
|
2432
|
+
2756734187,
|
|
2433
|
+
3204031479,
|
|
2434
|
+
3329325298
|
|
2435
|
+
]), z = /* @__PURE__ */ new Uint32Array(64), nr = class extends er {
|
|
2436
|
+
constructor(e) {
|
|
2437
|
+
super(64, e, 8, !1);
|
|
2438
|
+
}
|
|
2439
|
+
get() {
|
|
2440
|
+
let { A: e, B: t, C: n, D: r, E: i, F: a, G: o, H: s } = this;
|
|
2441
|
+
return [
|
|
2442
|
+
e,
|
|
2443
|
+
t,
|
|
2444
|
+
n,
|
|
2445
|
+
r,
|
|
2446
|
+
i,
|
|
2447
|
+
a,
|
|
2448
|
+
o,
|
|
2449
|
+
s
|
|
2450
|
+
];
|
|
2451
|
+
}
|
|
2452
|
+
set(e, t, n, r, i, a, o, s) {
|
|
2453
|
+
this.A = e | 0, this.B = t | 0, this.C = n | 0, this.D = r | 0, this.E = i | 0, this.F = a | 0, this.G = o | 0, this.H = s | 0;
|
|
2454
|
+
}
|
|
2455
|
+
process(e, t) {
|
|
2456
|
+
for (let n = 0; n < 16; n++, t += 4) z[n] = e.getUint32(t, !1);
|
|
2457
|
+
for (let e = 16; e < 64; e++) {
|
|
2458
|
+
let t = z[e - 15], n = z[e - 2], r = P(t, 7) ^ P(t, 18) ^ t >>> 3;
|
|
2459
|
+
z[e] = (P(n, 17) ^ P(n, 19) ^ n >>> 10) + z[e - 7] + r + z[e - 16] | 0;
|
|
2460
|
+
}
|
|
2461
|
+
let { A: n, B: r, C: i, D: a, E: o, F: s, G: c, H: l } = this;
|
|
2462
|
+
for (let e = 0; e < 64; e++) {
|
|
2463
|
+
let t = P(o, 6) ^ P(o, 11) ^ P(o, 25), u = l + t + Qn(o, s, c) + tr[e] + z[e] | 0, d = (P(n, 2) ^ P(n, 13) ^ P(n, 22)) + $n(n, r, i) | 0;
|
|
2464
|
+
l = c, c = s, s = o, o = a + u | 0, a = i, i = r, r = n, n = u + d | 0;
|
|
2465
|
+
}
|
|
2466
|
+
n = n + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, a = a + this.D | 0, o = o + this.E | 0, s = s + this.F | 0, c = c + this.G | 0, l = l + this.H | 0, this.set(n, r, i, a, o, s, c, l);
|
|
2467
|
+
}
|
|
2468
|
+
roundClean() {
|
|
2469
|
+
zn(z);
|
|
2470
|
+
}
|
|
2471
|
+
destroy() {
|
|
2472
|
+
this.destroyed = !0, this.set(0, 0, 0, 0, 0, 0, 0, 0), zn(this.buffer);
|
|
2473
|
+
}
|
|
2474
|
+
}, rr = class extends nr {
|
|
2475
|
+
constructor() {
|
|
2476
|
+
super(32), L(this, "A", R[0] | 0), L(this, "B", R[1] | 0), L(this, "C", R[2] | 0), L(this, "D", R[3] | 0), L(this, "E", R[4] | 0), L(this, "F", R[5] | 0), L(this, "G", R[6] | 0), L(this, "H", R[7] | 0);
|
|
2477
|
+
}
|
|
2478
|
+
}, ir = /* @__PURE__ */ qn(() => new rr(), /* @__PURE__ */ Yn(1)), B = (e, t, n) => N(e, t, n), ar = M, or = Un, V = (...e) => Kn(...e), sr = (e) => Gn(e), cr = Fn, lr = (e) => Jn(e), ur = /* @__PURE__ */ BigInt(0), dr = /* @__PURE__ */ BigInt(1);
|
|
2479
|
+
function H(e, t = "") {
|
|
2480
|
+
if (typeof e != "boolean") {
|
|
2481
|
+
let n = t && `"${t}" `;
|
|
2482
|
+
throw TypeError(n + "expected boolean, got type=" + typeof e);
|
|
2483
|
+
}
|
|
2484
|
+
return e;
|
|
2485
|
+
}
|
|
2486
|
+
function fr(e) {
|
|
2487
|
+
if (typeof e == "bigint") {
|
|
2488
|
+
if (!xr(e)) throw RangeError("positive bigint expected, got " + e);
|
|
2489
|
+
} else ar(e);
|
|
2490
|
+
return e;
|
|
2491
|
+
}
|
|
2492
|
+
function pr(e, t = "") {
|
|
2493
|
+
if (typeof e != "number") {
|
|
2494
|
+
let n = t && `"${t}" `;
|
|
2495
|
+
throw TypeError(n + "expected number, got type=" + typeof e);
|
|
2496
|
+
}
|
|
2497
|
+
if (!Number.isSafeInteger(e)) {
|
|
2498
|
+
let n = t && `"${t}" `;
|
|
2499
|
+
throw RangeError(n + "expected safe integer, got " + e);
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
function mr(e) {
|
|
2503
|
+
let t = fr(e).toString(16);
|
|
2504
|
+
return t.length & 1 ? "0" + t : t;
|
|
2505
|
+
}
|
|
2506
|
+
function hr(e) {
|
|
2507
|
+
if (typeof e != "string") throw TypeError("hex string expected, got " + typeof e);
|
|
2508
|
+
return e === "" ? ur : BigInt("0x" + e);
|
|
2509
|
+
}
|
|
2510
|
+
function gr(e) {
|
|
2511
|
+
return hr(Un(e));
|
|
2512
|
+
}
|
|
2513
|
+
function _r(e) {
|
|
2514
|
+
return hr(Un(br(N(e)).reverse()));
|
|
2515
|
+
}
|
|
2516
|
+
function vr(e, t) {
|
|
2517
|
+
if (M(t), t === 0) throw RangeError("zero length");
|
|
2518
|
+
e = fr(e);
|
|
2519
|
+
let n = e.toString(16);
|
|
2520
|
+
if (n.length > t * 2) throw RangeError("number too large");
|
|
2521
|
+
return Gn(n.padStart(t * 2, "0"));
|
|
2522
|
+
}
|
|
2523
|
+
function yr(e, t) {
|
|
2524
|
+
return vr(e, t).reverse();
|
|
2525
|
+
}
|
|
2526
|
+
function br(e) {
|
|
2527
|
+
return Uint8Array.from(B(e));
|
|
2528
|
+
}
|
|
2529
|
+
var xr = (e) => typeof e == "bigint" && ur <= e;
|
|
2530
|
+
function Sr(e, t, n) {
|
|
2531
|
+
return xr(e) && xr(t) && xr(n) && t <= e && e < n;
|
|
2532
|
+
}
|
|
2533
|
+
function Cr(e, t, n, r) {
|
|
2534
|
+
if (!Sr(t, n, r)) throw RangeError("expected valid " + e + ": " + n + " <= n < " + r + ", got " + t);
|
|
2535
|
+
}
|
|
2536
|
+
function wr(e) {
|
|
2537
|
+
if (e < ur) throw Error("expected non-negative bigint, got " + e);
|
|
2538
|
+
let t;
|
|
2539
|
+
for (t = 0; e > ur; e >>= dr, t += 1);
|
|
2540
|
+
return t;
|
|
2541
|
+
}
|
|
2542
|
+
var Tr = (e) => (dr << BigInt(e)) - dr;
|
|
2543
|
+
function Er(e, t, n) {
|
|
2544
|
+
if (M(e, "hashLen"), M(t, "qByteLen"), typeof n != "function") throw TypeError("hmacFn must be a function");
|
|
2545
|
+
let r = (e) => new Uint8Array(e), i = Uint8Array.of(), a = Uint8Array.of(0), o = Uint8Array.of(1), s = r(e), c = r(e), l = 0, u = () => {
|
|
2546
|
+
s.fill(1), c.fill(0), l = 0;
|
|
2547
|
+
}, d = (...e) => n(c, V(s, ...e)), f = (e = i) => {
|
|
2548
|
+
c = d(a, e), s = d(), e.length !== 0 && (c = d(o, e), s = d());
|
|
2549
|
+
}, p = () => {
|
|
2550
|
+
if (l++ >= 1e3) throw Error("drbg: tried max amount of iterations");
|
|
2551
|
+
let e = 0, n = [];
|
|
2552
|
+
for (; e < t;) {
|
|
2553
|
+
s = d();
|
|
2554
|
+
let t = s.slice();
|
|
2555
|
+
n.push(t), e += s.length;
|
|
2556
|
+
}
|
|
2557
|
+
return V(...n);
|
|
2558
|
+
};
|
|
2559
|
+
return (e, t) => {
|
|
2560
|
+
u(), f(e);
|
|
2561
|
+
let n;
|
|
2562
|
+
for (; (n = t(p())) === void 0;) f();
|
|
2563
|
+
return u(), n;
|
|
2564
|
+
};
|
|
2565
|
+
}
|
|
2566
|
+
function Dr(e, t = {}, n = {}) {
|
|
2567
|
+
if (Object.prototype.toString.call(e) !== "[object Object]") throw TypeError("expected valid options object");
|
|
2568
|
+
function r(t, n, r) {
|
|
2569
|
+
if (!r && n !== "function" && !Object.hasOwn(e, t)) throw TypeError(`param "${t}" is invalid: expected own property`);
|
|
2570
|
+
let i = e[t];
|
|
2571
|
+
if (r && i === void 0) return;
|
|
2572
|
+
let a = typeof i;
|
|
2573
|
+
if (a !== n || i === null) throw TypeError(`param "${t}" is invalid: expected ${n}, got ${a}`);
|
|
2574
|
+
}
|
|
2575
|
+
let i = (e, t) => Object.entries(e).forEach(([e, n]) => r(e, n, t));
|
|
2576
|
+
i(t, !1), i(n, !0);
|
|
2577
|
+
}
|
|
2578
|
+
//#endregion
|
|
2579
|
+
//#region ../../node_modules/.pnpm/@noble+curves@2.2.0/node_modules/@noble/curves/abstract/modular.js
|
|
2580
|
+
var U = /* @__PURE__ */ BigInt(0), W = /* @__PURE__ */ BigInt(1), G = /* @__PURE__ */ BigInt(2), Or = /* @__PURE__ */ BigInt(3), kr = /* @__PURE__ */ BigInt(4), Ar = /* @__PURE__ */ BigInt(5), jr = /* @__PURE__ */ BigInt(7), Mr = /* @__PURE__ */ BigInt(8), Nr = /* @__PURE__ */ BigInt(9), Pr = /* @__PURE__ */ BigInt(16);
|
|
2581
|
+
function K(e, t) {
|
|
2582
|
+
if (t <= U) throw Error("mod: expected positive modulus, got " + t);
|
|
2583
|
+
let n = e % t;
|
|
2584
|
+
return n >= U ? n : t + n;
|
|
2585
|
+
}
|
|
2586
|
+
function Fr(e, t) {
|
|
2587
|
+
if (e === U) throw Error("invert: expected non-zero number");
|
|
2588
|
+
if (t <= U) throw Error("invert: expected positive modulus, got " + t);
|
|
2589
|
+
let n = K(e, t), r = t, i = U, a = W, o = W, s = U;
|
|
2590
|
+
for (; n !== U;) {
|
|
2591
|
+
let e = r / n, t = r - n * e, c = i - o * e, l = a - s * e;
|
|
2592
|
+
r = n, n = t, i = o, a = s, o = c, s = l;
|
|
2593
|
+
}
|
|
2594
|
+
if (r !== W) throw Error("invert: does not exist");
|
|
2595
|
+
return K(i, t);
|
|
2596
|
+
}
|
|
2597
|
+
function Ir(e, t, n) {
|
|
2598
|
+
let r = e;
|
|
2599
|
+
if (!r.eql(r.sqr(t), n)) throw Error("Cannot find square root");
|
|
2600
|
+
}
|
|
2601
|
+
function Lr(e, t) {
|
|
2602
|
+
let n = e, r = (n.ORDER + W) / kr, i = n.pow(t, r);
|
|
2603
|
+
return Ir(n, i, t), i;
|
|
2604
|
+
}
|
|
2605
|
+
function Rr(e, t) {
|
|
2606
|
+
let n = e, r = (n.ORDER - Ar) / Mr, i = n.mul(t, G), a = n.pow(i, r), o = n.mul(t, a), s = n.mul(n.mul(o, G), a), c = n.mul(o, n.sub(s, n.ONE));
|
|
2607
|
+
return Ir(n, c, t), c;
|
|
2608
|
+
}
|
|
2609
|
+
function zr(e) {
|
|
2610
|
+
let t = Xr(e), n = Br(e), r = n(t, t.neg(t.ONE)), i = n(t, r), a = n(t, t.neg(r)), o = (e + jr) / Pr;
|
|
2611
|
+
return ((e, t) => {
|
|
2612
|
+
let n = e, s = n.pow(t, o), c = n.mul(s, r), l = n.mul(s, i), u = n.mul(s, a), d = n.eql(n.sqr(c), t), f = n.eql(n.sqr(l), t);
|
|
2613
|
+
s = n.cmov(s, c, d), c = n.cmov(u, l, f);
|
|
2614
|
+
let p = n.eql(n.sqr(c), t), m = n.cmov(s, c, p);
|
|
2615
|
+
return Ir(n, m, t), m;
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
function Br(e) {
|
|
2619
|
+
if (e < Or) throw Error("sqrt is not defined for small field");
|
|
2620
|
+
let t = e - W, n = 0;
|
|
2621
|
+
for (; t % G === U;) t /= G, n++;
|
|
2622
|
+
let r = G, i = Xr(e);
|
|
2623
|
+
for (; Kr(i, r) === 1;) if (r++ > 1e3) throw Error("Cannot find square root: probably non-prime P");
|
|
2624
|
+
if (n === 1) return Lr;
|
|
2625
|
+
let a = i.pow(r, t), o = (t + W) / G;
|
|
2626
|
+
return function(e, r) {
|
|
2627
|
+
let i = e;
|
|
2628
|
+
if (i.is0(r)) return r;
|
|
2629
|
+
if (Kr(i, r) !== 1) throw Error("Cannot find square root");
|
|
2630
|
+
let s = n, c = i.mul(i.ONE, a), l = i.pow(r, t), u = i.pow(r, o);
|
|
2631
|
+
for (; !i.eql(l, i.ONE);) {
|
|
2632
|
+
if (i.is0(l)) return i.ZERO;
|
|
2633
|
+
let e = 1, t = i.sqr(l);
|
|
2634
|
+
for (; !i.eql(t, i.ONE);) if (e++, t = i.sqr(t), e === s) throw Error("Cannot find square root");
|
|
2635
|
+
let n = W << BigInt(s - e - 1), r = i.pow(c, n);
|
|
2636
|
+
s = e, c = i.sqr(r), l = i.mul(l, c), u = i.mul(u, r);
|
|
2637
|
+
}
|
|
2638
|
+
return u;
|
|
2639
|
+
};
|
|
2640
|
+
}
|
|
2641
|
+
function Vr(e) {
|
|
2642
|
+
return e % kr === Or ? Lr : e % Mr === Ar ? Rr : e % Pr === Nr ? zr(e) : Br(e);
|
|
2643
|
+
}
|
|
2644
|
+
var Hr = [
|
|
2645
|
+
"create",
|
|
2646
|
+
"isValid",
|
|
2647
|
+
"is0",
|
|
2648
|
+
"neg",
|
|
2649
|
+
"inv",
|
|
2650
|
+
"sqrt",
|
|
2651
|
+
"sqr",
|
|
2652
|
+
"eql",
|
|
2653
|
+
"add",
|
|
2654
|
+
"sub",
|
|
2655
|
+
"mul",
|
|
2656
|
+
"pow",
|
|
2657
|
+
"div",
|
|
2658
|
+
"addN",
|
|
2659
|
+
"subN",
|
|
2660
|
+
"mulN",
|
|
2661
|
+
"sqrN"
|
|
2662
|
+
];
|
|
2663
|
+
function Ur(e) {
|
|
2664
|
+
if (Dr(e, Hr.reduce((e, t) => (e[t] = "function", e), {
|
|
2665
|
+
ORDER: "bigint",
|
|
2666
|
+
BYTES: "number",
|
|
2667
|
+
BITS: "number"
|
|
2668
|
+
})), pr(e.BYTES, "BYTES"), pr(e.BITS, "BITS"), e.BYTES < 1 || e.BITS < 1) throw Error("invalid field: expected BYTES/BITS > 0");
|
|
2669
|
+
if (e.ORDER <= W) throw Error("invalid field: expected ORDER > 1, got " + e.ORDER);
|
|
2670
|
+
return e;
|
|
2671
|
+
}
|
|
2672
|
+
function Wr(e, t, n) {
|
|
2673
|
+
let r = e;
|
|
2674
|
+
if (n < U) throw Error("invalid exponent, negatives unsupported");
|
|
2675
|
+
if (n === U) return r.ONE;
|
|
2676
|
+
if (n === W) return t;
|
|
2677
|
+
let i = r.ONE, a = t;
|
|
2678
|
+
for (; n > U;) n & W && (i = r.mul(i, a)), a = r.sqr(a), n >>= W;
|
|
2679
|
+
return i;
|
|
2680
|
+
}
|
|
2681
|
+
function Gr(e, t, n = !1) {
|
|
2682
|
+
let r = e, i = Array(t.length).fill(n ? r.ZERO : void 0), a = t.reduce((e, t, n) => r.is0(t) ? e : (i[n] = e, r.mul(e, t)), r.ONE), o = r.inv(a);
|
|
2683
|
+
return t.reduceRight((e, t, n) => r.is0(t) ? e : (i[n] = r.mul(e, i[n]), r.mul(e, t)), o), i;
|
|
2684
|
+
}
|
|
2685
|
+
function Kr(e, t) {
|
|
2686
|
+
let n = e, r = (n.ORDER - W) / G, i = n.pow(t, r), a = n.eql(i, n.ONE), o = n.eql(i, n.ZERO), s = n.eql(i, n.neg(n.ONE));
|
|
2687
|
+
if (!a && !o && !s) throw Error("invalid Legendre symbol result");
|
|
2688
|
+
return a ? 1 : o ? 0 : -1;
|
|
2689
|
+
}
|
|
2690
|
+
function qr(e, t) {
|
|
2691
|
+
if (t !== void 0 && ar(t), e <= U) throw Error("invalid n length: expected positive n, got " + e);
|
|
2692
|
+
if (t !== void 0 && t < 1) throw Error("invalid n length: expected positive bit length, got " + t);
|
|
2693
|
+
let n = wr(e);
|
|
2694
|
+
if (t !== void 0 && t < n) throw Error(`invalid n length: expected bit length (${n}) >= n.length (${t})`);
|
|
2695
|
+
let r = t === void 0 ? n : t;
|
|
2696
|
+
return {
|
|
2697
|
+
nBitLength: r,
|
|
2698
|
+
nByteLength: Math.ceil(r / 8)
|
|
2699
|
+
};
|
|
2700
|
+
}
|
|
2701
|
+
var Jr = /* @__PURE__ */ new WeakMap(), Yr = class {
|
|
2702
|
+
constructor(e, t = {}) {
|
|
2703
|
+
if (L(this, "ORDER", void 0), L(this, "BITS", void 0), L(this, "BYTES", void 0), L(this, "isLE", void 0), L(this, "ZERO", U), L(this, "ONE", W), L(this, "_lengths", void 0), L(this, "_mod", void 0), e <= W) throw Error("invalid field: expected ORDER > 1, got " + e);
|
|
2704
|
+
let n;
|
|
2705
|
+
this.isLE = !1, typeof t == "object" && t && (typeof t.BITS == "number" && (n = t.BITS), typeof t.sqrt == "function" && Object.defineProperty(this, "sqrt", {
|
|
2706
|
+
value: t.sqrt,
|
|
2707
|
+
enumerable: !0
|
|
2708
|
+
}), typeof t.isLE == "boolean" && (this.isLE = t.isLE), t.allowedLengths && (this._lengths = Object.freeze(t.allowedLengths.slice())), typeof t.modFromBytes == "boolean" && (this._mod = t.modFromBytes));
|
|
2709
|
+
let { nBitLength: r, nByteLength: i } = qr(e, n);
|
|
2710
|
+
if (i > 2048) throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
2711
|
+
this.ORDER = e, this.BITS = r, this.BYTES = i, Object.freeze(this);
|
|
2712
|
+
}
|
|
2713
|
+
create(e) {
|
|
2714
|
+
return K(e, this.ORDER);
|
|
2715
|
+
}
|
|
2716
|
+
isValid(e) {
|
|
2717
|
+
if (typeof e != "bigint") throw TypeError("invalid field element: expected bigint, got " + typeof e);
|
|
2718
|
+
return U <= e && e < this.ORDER;
|
|
2719
|
+
}
|
|
2720
|
+
is0(e) {
|
|
2721
|
+
return e === U;
|
|
2722
|
+
}
|
|
2723
|
+
isValidNot0(e) {
|
|
2724
|
+
return !this.is0(e) && this.isValid(e);
|
|
2725
|
+
}
|
|
2726
|
+
isOdd(e) {
|
|
2727
|
+
return (e & W) === W;
|
|
2728
|
+
}
|
|
2729
|
+
neg(e) {
|
|
2730
|
+
return K(-e, this.ORDER);
|
|
2731
|
+
}
|
|
2732
|
+
eql(e, t) {
|
|
2733
|
+
return e === t;
|
|
2734
|
+
}
|
|
2735
|
+
sqr(e) {
|
|
2736
|
+
return K(e * e, this.ORDER);
|
|
2737
|
+
}
|
|
2738
|
+
add(e, t) {
|
|
2739
|
+
return K(e + t, this.ORDER);
|
|
2740
|
+
}
|
|
2741
|
+
sub(e, t) {
|
|
2742
|
+
return K(e - t, this.ORDER);
|
|
2743
|
+
}
|
|
2744
|
+
mul(e, t) {
|
|
2745
|
+
return K(e * t, this.ORDER);
|
|
2746
|
+
}
|
|
2747
|
+
pow(e, t) {
|
|
2748
|
+
return Wr(this, e, t);
|
|
2749
|
+
}
|
|
2750
|
+
div(e, t) {
|
|
2751
|
+
return K(e * Fr(t, this.ORDER), this.ORDER);
|
|
2752
|
+
}
|
|
2753
|
+
sqrN(e) {
|
|
2754
|
+
return e * e;
|
|
2755
|
+
}
|
|
2756
|
+
addN(e, t) {
|
|
2757
|
+
return e + t;
|
|
2758
|
+
}
|
|
2759
|
+
subN(e, t) {
|
|
2760
|
+
return e - t;
|
|
2761
|
+
}
|
|
2762
|
+
mulN(e, t) {
|
|
2763
|
+
return e * t;
|
|
2764
|
+
}
|
|
2765
|
+
inv(e) {
|
|
2766
|
+
return Fr(e, this.ORDER);
|
|
2767
|
+
}
|
|
2768
|
+
sqrt(e) {
|
|
2769
|
+
let t = Jr.get(this);
|
|
2770
|
+
return t || Jr.set(this, t = Vr(this.ORDER)), t(this, e);
|
|
2771
|
+
}
|
|
2772
|
+
toBytes(e) {
|
|
2773
|
+
return this.isLE ? yr(e, this.BYTES) : vr(e, this.BYTES);
|
|
2774
|
+
}
|
|
2775
|
+
fromBytes(e, t = !1) {
|
|
2776
|
+
B(e);
|
|
2777
|
+
let { _lengths: n, BYTES: r, isLE: i, ORDER: a, _mod: o } = this;
|
|
2778
|
+
if (n) {
|
|
2779
|
+
if (e.length < 1 || !n.includes(e.length) || e.length > r) throw Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
2780
|
+
let t = new Uint8Array(r);
|
|
2781
|
+
t.set(e, i ? 0 : t.length - e.length), e = t;
|
|
2782
|
+
}
|
|
2783
|
+
if (e.length !== r) throw Error("Field.fromBytes: expected " + r + " bytes, got " + e.length);
|
|
2784
|
+
let s = i ? _r(e) : gr(e);
|
|
2785
|
+
if (o && (s = K(s, a)), !t && !this.isValid(s)) throw Error("invalid field element: outside of range 0..ORDER");
|
|
2786
|
+
return s;
|
|
2787
|
+
}
|
|
2788
|
+
invertBatch(e) {
|
|
2789
|
+
return Gr(this, e);
|
|
2790
|
+
}
|
|
2791
|
+
cmov(e, t, n) {
|
|
2792
|
+
return H(n, "condition"), n ? t : e;
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
Object.freeze(Yr.prototype);
|
|
2796
|
+
function Xr(e, t = {}) {
|
|
2797
|
+
return new Yr(e, t);
|
|
2798
|
+
}
|
|
2799
|
+
function Zr(e) {
|
|
2800
|
+
if (typeof e != "bigint") throw Error("field order must be bigint");
|
|
2801
|
+
if (e <= W) throw Error("field order must be greater than 1");
|
|
2802
|
+
let t = wr(e - W);
|
|
2803
|
+
return Math.ceil(t / 8);
|
|
2804
|
+
}
|
|
2805
|
+
function Qr(e) {
|
|
2806
|
+
let t = Zr(e);
|
|
2807
|
+
return t + Math.ceil(t / 2);
|
|
2808
|
+
}
|
|
2809
|
+
function $r(e, t, n = !1) {
|
|
2810
|
+
B(e);
|
|
2811
|
+
let r = e.length, i = Zr(t), a = Math.max(Qr(t), 16);
|
|
2812
|
+
if (r < a || r > 1024) throw Error("expected " + a + "-1024 bytes of input, got " + r);
|
|
2813
|
+
let o = K(n ? _r(e) : gr(e), t - W) + W;
|
|
2814
|
+
return n ? yr(o, i) : vr(o, i);
|
|
2815
|
+
}
|
|
2816
|
+
//#endregion
|
|
2817
|
+
//#region ../../node_modules/.pnpm/@noble+curves@2.2.0/node_modules/@noble/curves/abstract/curve.js
|
|
2818
|
+
var q = /* @__PURE__ */ BigInt(0), J = /* @__PURE__ */ BigInt(1);
|
|
2819
|
+
function ei(e, t) {
|
|
2820
|
+
let n = t.negate();
|
|
2821
|
+
return e ? n : t;
|
|
2822
|
+
}
|
|
2823
|
+
function ti(e, t) {
|
|
2824
|
+
let n = Gr(e.Fp, t.map((e) => e.Z));
|
|
2825
|
+
return t.map((t, r) => e.fromAffine(t.toAffine(n[r])));
|
|
2826
|
+
}
|
|
2827
|
+
function ni(e, t) {
|
|
2828
|
+
if (!Number.isSafeInteger(e) || e <= 0 || e > t) throw Error("invalid window size, expected [1.." + t + "], got W=" + e);
|
|
2829
|
+
}
|
|
2830
|
+
function ri(e, t) {
|
|
2831
|
+
ni(e, t);
|
|
2832
|
+
let n = Math.ceil(t / e) + 1, r = 2 ** (e - 1), i = 2 ** e;
|
|
2833
|
+
return {
|
|
2834
|
+
windows: n,
|
|
2835
|
+
windowSize: r,
|
|
2836
|
+
mask: Tr(e),
|
|
2837
|
+
maxNumber: i,
|
|
2838
|
+
shiftBy: BigInt(e)
|
|
2839
|
+
};
|
|
2840
|
+
}
|
|
2841
|
+
function ii(e, t, n) {
|
|
2842
|
+
let { windowSize: r, mask: i, maxNumber: a, shiftBy: o } = n, s = Number(e & i), c = e >> o;
|
|
2843
|
+
s > r && (s -= a, c += J);
|
|
2844
|
+
let l = t * r, u = l + Math.abs(s) - 1, d = s === 0, f = s < 0, p = t % 2 != 0;
|
|
2845
|
+
return {
|
|
2846
|
+
nextN: c,
|
|
2847
|
+
offset: u,
|
|
2848
|
+
isZero: d,
|
|
2849
|
+
isNeg: f,
|
|
2850
|
+
isNegF: p,
|
|
2851
|
+
offsetF: l
|
|
2852
|
+
};
|
|
2853
|
+
}
|
|
2854
|
+
var ai = /* @__PURE__ */ new WeakMap(), oi = /* @__PURE__ */ new WeakMap();
|
|
2855
|
+
function si(e) {
|
|
2856
|
+
return oi.get(e) || 1;
|
|
2857
|
+
}
|
|
2858
|
+
function ci(e) {
|
|
2859
|
+
if (e !== q) throw Error("invalid wNAF");
|
|
2860
|
+
}
|
|
2861
|
+
var li = class {
|
|
2862
|
+
constructor(e, t) {
|
|
2863
|
+
L(this, "BASE", void 0), L(this, "ZERO", void 0), L(this, "Fn", void 0), L(this, "bits", void 0), this.BASE = e.BASE, this.ZERO = e.ZERO, this.Fn = e.Fn, this.bits = t;
|
|
2864
|
+
}
|
|
2865
|
+
_unsafeLadder(e, t, n = this.ZERO) {
|
|
2866
|
+
let r = e;
|
|
2867
|
+
for (; t > q;) t & J && (n = n.add(r)), r = r.double(), t >>= J;
|
|
2868
|
+
return n;
|
|
2869
|
+
}
|
|
2870
|
+
precomputeWindow(e, t) {
|
|
2871
|
+
let { windows: n, windowSize: r } = ri(t, this.bits), i = [], a = e, o = a;
|
|
2872
|
+
for (let e = 0; e < n; e++) {
|
|
2873
|
+
o = a, i.push(o);
|
|
2874
|
+
for (let e = 1; e < r; e++) o = o.add(a), i.push(o);
|
|
2875
|
+
a = o.double();
|
|
2876
|
+
}
|
|
2877
|
+
return i;
|
|
2878
|
+
}
|
|
2879
|
+
wNAF(e, t, n) {
|
|
2880
|
+
if (!this.Fn.isValid(n)) throw Error("invalid scalar");
|
|
2881
|
+
let r = this.ZERO, i = this.BASE, a = ri(e, this.bits);
|
|
2882
|
+
for (let e = 0; e < a.windows; e++) {
|
|
2883
|
+
let { nextN: o, offset: s, isZero: c, isNeg: l, isNegF: u, offsetF: d } = ii(n, e, a);
|
|
2884
|
+
n = o, c ? i = i.add(ei(u, t[d])) : r = r.add(ei(l, t[s]));
|
|
2885
|
+
}
|
|
2886
|
+
return ci(n), {
|
|
2887
|
+
p: r,
|
|
2888
|
+
f: i
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
wNAFUnsafe(e, t, n, r = this.ZERO) {
|
|
2892
|
+
let i = ri(e, this.bits);
|
|
2893
|
+
for (let e = 0; e < i.windows && n !== q; e++) {
|
|
2894
|
+
let { nextN: a, offset: o, isZero: s, isNeg: c } = ii(n, e, i);
|
|
2895
|
+
if (n = a, !s) {
|
|
2896
|
+
let e = t[o];
|
|
2897
|
+
r = r.add(c ? e.negate() : e);
|
|
2898
|
+
}
|
|
2899
|
+
}
|
|
2900
|
+
return ci(n), r;
|
|
2901
|
+
}
|
|
2902
|
+
getPrecomputes(e, t, n) {
|
|
2903
|
+
let r = ai.get(t);
|
|
2904
|
+
return r || (r = this.precomputeWindow(t, e), e !== 1 && (typeof n == "function" && (r = n(r)), ai.set(t, r))), r;
|
|
2905
|
+
}
|
|
2906
|
+
cached(e, t, n) {
|
|
2907
|
+
let r = si(e);
|
|
2908
|
+
return this.wNAF(r, this.getPrecomputes(r, e, n), t);
|
|
2909
|
+
}
|
|
2910
|
+
unsafe(e, t, n, r) {
|
|
2911
|
+
let i = si(e);
|
|
2912
|
+
return i === 1 ? this._unsafeLadder(e, t, r) : this.wNAFUnsafe(i, this.getPrecomputes(i, e, n), t, r);
|
|
2913
|
+
}
|
|
2914
|
+
createCache(e, t) {
|
|
2915
|
+
ni(t, this.bits), oi.set(e, t), ai.delete(e);
|
|
2916
|
+
}
|
|
2917
|
+
hasCache(e) {
|
|
2918
|
+
return si(e) !== 1;
|
|
2919
|
+
}
|
|
2920
|
+
};
|
|
2921
|
+
function ui(e, t, n, r) {
|
|
2922
|
+
let i = t, a = e.ZERO, o = e.ZERO;
|
|
2923
|
+
for (; n > q || r > q;) n & J && (a = a.add(i)), r & J && (o = o.add(i)), i = i.double(), n >>= J, r >>= J;
|
|
2924
|
+
return {
|
|
2925
|
+
p1: a,
|
|
2926
|
+
p2: o
|
|
2927
|
+
};
|
|
2928
|
+
}
|
|
2929
|
+
function di(e, t, n) {
|
|
2930
|
+
if (t) {
|
|
2931
|
+
if (t.ORDER !== e) throw Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
2932
|
+
return Ur(t), t;
|
|
2933
|
+
} else return Xr(e, { isLE: n });
|
|
2934
|
+
}
|
|
2935
|
+
function fi(e, t, n = {}, r) {
|
|
2936
|
+
if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object") throw Error(`expected valid ${e} CURVE object`);
|
|
2937
|
+
for (let e of [
|
|
2938
|
+
"p",
|
|
2939
|
+
"n",
|
|
2940
|
+
"h"
|
|
2941
|
+
]) {
|
|
2942
|
+
let n = t[e];
|
|
2943
|
+
if (!(typeof n == "bigint" && n > q)) throw Error(`CURVE.${e} must be positive bigint`);
|
|
2944
|
+
}
|
|
2945
|
+
let i = di(t.p, n.Fp, r), a = di(t.n, n.Fn, r), o = [
|
|
2946
|
+
"Gx",
|
|
2947
|
+
"Gy",
|
|
2948
|
+
"a",
|
|
2949
|
+
e === "weierstrass" ? "b" : "d"
|
|
2950
|
+
];
|
|
2951
|
+
for (let e of o) if (!i.isValid(t[e])) throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);
|
|
2952
|
+
return t = Object.freeze(Object.assign({}, t)), {
|
|
2953
|
+
CURVE: t,
|
|
2954
|
+
Fp: i,
|
|
2955
|
+
Fn: a
|
|
2956
|
+
};
|
|
2957
|
+
}
|
|
2958
|
+
function pi(e, t) {
|
|
2959
|
+
return function(n) {
|
|
2960
|
+
let r = e(n);
|
|
2961
|
+
return {
|
|
2962
|
+
secretKey: r,
|
|
2963
|
+
publicKey: t(r)
|
|
2964
|
+
};
|
|
2965
|
+
};
|
|
2966
|
+
}
|
|
2967
|
+
//#endregion
|
|
2968
|
+
//#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/hmac.js
|
|
2969
|
+
var mi = class {
|
|
2970
|
+
constructor(e, t) {
|
|
2971
|
+
if (L(this, "oHash", void 0), L(this, "iHash", void 0), L(this, "blockLen", void 0), L(this, "outputLen", void 0), L(this, "canXOF", !1), L(this, "finished", !1), L(this, "destroyed", !1), In(e), N(t, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function") throw Error("Expected instance of class which extends utils.Hash");
|
|
2972
|
+
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
2973
|
+
let n = this.blockLen, r = new Uint8Array(n);
|
|
2974
|
+
r.set(t.length > n ? e.create().update(t).digest() : t);
|
|
2975
|
+
for (let e = 0; e < r.length; e++) r[e] ^= 54;
|
|
2976
|
+
this.iHash.update(r), this.oHash = e.create();
|
|
2977
|
+
for (let e = 0; e < r.length; e++) r[e] ^= 106;
|
|
2978
|
+
this.oHash.update(r), zn(r);
|
|
2979
|
+
}
|
|
2980
|
+
update(e) {
|
|
2981
|
+
return Ln(this), this.iHash.update(e), this;
|
|
2982
|
+
}
|
|
2983
|
+
digestInto(e) {
|
|
2984
|
+
Ln(this), Rn(e, this), this.finished = !0;
|
|
2985
|
+
let t = e.subarray(0, this.outputLen);
|
|
2986
|
+
this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
|
|
2987
|
+
}
|
|
2988
|
+
digest() {
|
|
2989
|
+
let e = new Uint8Array(this.oHash.outputLen);
|
|
2990
|
+
return this.digestInto(e), e;
|
|
2991
|
+
}
|
|
2992
|
+
_cloneInto(e) {
|
|
2993
|
+
e || (e = Object.create(Object.getPrototypeOf(this), {}));
|
|
2994
|
+
let { oHash: t, iHash: n, finished: r, destroyed: i, blockLen: a, outputLen: o } = this;
|
|
2995
|
+
return e = e, e.finished = r, e.destroyed = i, e.blockLen = a, e.outputLen = o, e.oHash = t._cloneInto(e.oHash), e.iHash = n._cloneInto(e.iHash), e;
|
|
2996
|
+
}
|
|
2997
|
+
clone() {
|
|
2998
|
+
return this._cloneInto();
|
|
2999
|
+
}
|
|
3000
|
+
destroy() {
|
|
3001
|
+
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
3002
|
+
}
|
|
3003
|
+
}, hi = /* @__PURE__ */ (() => {
|
|
3004
|
+
let e = ((e, t, n) => new mi(e, t).update(n).digest());
|
|
3005
|
+
return e.create = (e, t) => new mi(e, t), e;
|
|
3006
|
+
})(), gi = (e, t) => (e + (e >= 0 ? t : -t) / bi) / t;
|
|
3007
|
+
function _i(e, t, n) {
|
|
3008
|
+
Cr("scalar", e, X, n);
|
|
3009
|
+
let [[r, i], [a, o]] = t, s = gi(o * e, n), c = gi(-i * e, n), l = e - s * r - c * a, u = -s * i - c * o, d = l < X, f = u < X;
|
|
3010
|
+
d && (l = -l), f && (u = -u);
|
|
3011
|
+
let p = Tr(Math.ceil(wr(n) / 2)) + Z;
|
|
3012
|
+
if (l < X || l >= p || u < X || u >= p) throw Error("splitScalar (endomorphism): failed for k");
|
|
3013
|
+
return {
|
|
3014
|
+
k1neg: d,
|
|
3015
|
+
k1: l,
|
|
3016
|
+
k2neg: f,
|
|
3017
|
+
k2: u
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
function vi(e) {
|
|
3021
|
+
if (![
|
|
3022
|
+
"compact",
|
|
3023
|
+
"recovered",
|
|
3024
|
+
"der"
|
|
3025
|
+
].includes(e)) throw Error("Signature format must be \"compact\", \"recovered\", or \"der\"");
|
|
3026
|
+
return e;
|
|
3027
|
+
}
|
|
3028
|
+
function yi(e, t) {
|
|
3029
|
+
Dr(e);
|
|
3030
|
+
let n = {};
|
|
3031
|
+
for (let r of Object.keys(t)) n[r] = e[r] === void 0 ? t[r] : e[r];
|
|
3032
|
+
return H(n.lowS, "lowS"), H(n.prehash, "prehash"), n.format !== void 0 && vi(n.format), n;
|
|
3033
|
+
}
|
|
3034
|
+
var Y = {
|
|
3035
|
+
Err: class extends Error {
|
|
3036
|
+
constructor(e = "") {
|
|
3037
|
+
super(e);
|
|
3038
|
+
}
|
|
3039
|
+
},
|
|
3040
|
+
_tlv: {
|
|
3041
|
+
encode: (e, t) => {
|
|
3042
|
+
let { Err: n } = Y;
|
|
3043
|
+
if (pr(e, "tag"), e < 0 || e > 255) throw new n("tlv.encode: wrong tag");
|
|
3044
|
+
if (typeof t != "string") throw TypeError("\"data\" expected string, got type=" + typeof t);
|
|
3045
|
+
if (t.length & 1) throw new n("tlv.encode: unpadded data");
|
|
3046
|
+
let r = t.length / 2, i = mr(r);
|
|
3047
|
+
if (i.length / 2 & 128) throw new n("tlv.encode: long form length too big");
|
|
3048
|
+
let a = r > 127 ? mr(i.length / 2 | 128) : "";
|
|
3049
|
+
return mr(e) + a + i + t;
|
|
3050
|
+
},
|
|
3051
|
+
decode(e, t) {
|
|
3052
|
+
let { Err: n } = Y;
|
|
3053
|
+
t = B(t, void 0, "DER data");
|
|
3054
|
+
let r = 0;
|
|
3055
|
+
if (e < 0 || e > 255) throw new n("tlv.encode: wrong tag");
|
|
3056
|
+
if (t.length < 2 || t[r++] !== e) throw new n("tlv.decode: wrong tlv");
|
|
3057
|
+
let i = t[r++], a = !!(i & 128), o = 0;
|
|
3058
|
+
if (!a) o = i;
|
|
3059
|
+
else {
|
|
3060
|
+
let e = i & 127;
|
|
3061
|
+
if (!e) throw new n("tlv.decode(long): indefinite length not supported");
|
|
3062
|
+
if (e > 4) throw new n("tlv.decode(long): byte length is too big");
|
|
3063
|
+
let a = t.subarray(r, r + e);
|
|
3064
|
+
if (a.length !== e) throw new n("tlv.decode: length bytes not complete");
|
|
3065
|
+
if (a[0] === 0) throw new n("tlv.decode(long): zero leftmost byte");
|
|
3066
|
+
for (let e of a) o = o << 8 | e;
|
|
3067
|
+
if (r += e, o < 128) throw new n("tlv.decode(long): not minimal encoding");
|
|
3068
|
+
}
|
|
3069
|
+
let s = t.subarray(r, r + o);
|
|
3070
|
+
if (s.length !== o) throw new n("tlv.decode: wrong value length");
|
|
3071
|
+
return {
|
|
3072
|
+
v: s,
|
|
3073
|
+
l: t.subarray(r + o)
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
},
|
|
3077
|
+
_int: {
|
|
3078
|
+
encode(e) {
|
|
3079
|
+
let { Err: t } = Y;
|
|
3080
|
+
if (fr(e), e < X) throw new t("integer: negative integers are not allowed");
|
|
3081
|
+
let n = mr(e);
|
|
3082
|
+
if (Number.parseInt(n[0], 16) & 8 && (n = "00" + n), n.length & 1) throw new t("unexpected DER parsing assertion: unpadded hex");
|
|
3083
|
+
return n;
|
|
3084
|
+
},
|
|
3085
|
+
decode(e) {
|
|
3086
|
+
let { Err: t } = Y;
|
|
3087
|
+
if (e.length < 1) throw new t("invalid signature integer: empty");
|
|
3088
|
+
if (e[0] & 128) throw new t("invalid signature integer: negative");
|
|
3089
|
+
if (e.length > 1 && e[0] === 0 && !(e[1] & 128)) throw new t("invalid signature integer: unnecessary leading zero");
|
|
3090
|
+
return gr(e);
|
|
3091
|
+
}
|
|
3092
|
+
},
|
|
3093
|
+
toSig(e) {
|
|
3094
|
+
let { Err: t, _int: n, _tlv: r } = Y, i = B(e, void 0, "signature"), { v: a, l: o } = r.decode(48, i);
|
|
3095
|
+
if (o.length) throw new t("invalid signature: left bytes after parsing");
|
|
3096
|
+
let { v: s, l: c } = r.decode(2, a), { v: l, l: u } = r.decode(2, c);
|
|
3097
|
+
if (u.length) throw new t("invalid signature: left bytes after parsing");
|
|
3098
|
+
return {
|
|
3099
|
+
r: n.decode(s),
|
|
3100
|
+
s: n.decode(l)
|
|
3101
|
+
};
|
|
3102
|
+
},
|
|
3103
|
+
hexFromSig(e) {
|
|
3104
|
+
let { _tlv: t, _int: n } = Y, r = t.encode(2, n.encode(e.r)) + t.encode(2, n.encode(e.s));
|
|
3105
|
+
return t.encode(48, r);
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
Object.freeze(Y._tlv), Object.freeze(Y._int), Object.freeze(Y);
|
|
3109
|
+
var X = /* @__PURE__ */ BigInt(0), Z = /* @__PURE__ */ BigInt(1), bi = /* @__PURE__ */ BigInt(2), xi = /* @__PURE__ */ BigInt(3), Si = /* @__PURE__ */ BigInt(4);
|
|
3110
|
+
function Ci(e, t = {}) {
|
|
3111
|
+
var n;
|
|
3112
|
+
let r = fi("weierstrass", e, t), i = r.Fp, a = r.Fn, o = r.CURVE, { h: s, n: c } = o;
|
|
3113
|
+
Dr(t, {}, {
|
|
3114
|
+
allowInfinityPoint: "boolean",
|
|
3115
|
+
clearCofactor: "function",
|
|
3116
|
+
isTorsionFree: "function",
|
|
3117
|
+
fromBytes: "function",
|
|
3118
|
+
toBytes: "function",
|
|
3119
|
+
endo: "object"
|
|
3120
|
+
});
|
|
3121
|
+
let { endo: l, allowInfinityPoint: u } = t;
|
|
3122
|
+
if (l && (!i.is0(o.a) || typeof l.beta != "bigint" || !Array.isArray(l.basises))) throw Error("invalid endo: expected \"beta\": bigint and \"basises\": array");
|
|
3123
|
+
let d = Ti(i, a);
|
|
3124
|
+
function f() {
|
|
3125
|
+
if (!i.isOdd) throw Error("compression is not supported: Field does not have .isOdd()");
|
|
3126
|
+
}
|
|
3127
|
+
function p(e, t, n) {
|
|
3128
|
+
if (u && t.is0()) return Uint8Array.of(0);
|
|
3129
|
+
let { x: r, y: a } = t.toAffine(), o = i.toBytes(r);
|
|
3130
|
+
return H(n, "isCompressed"), n ? (f(), V(wi(!i.isOdd(a)), o)) : V(Uint8Array.of(4), o, i.toBytes(a));
|
|
3131
|
+
}
|
|
3132
|
+
function m(e) {
|
|
3133
|
+
B(e, void 0, "Point");
|
|
3134
|
+
let { publicKey: t, publicKeyUncompressed: n } = d, r = e.length, a = e[0], o = e.subarray(1);
|
|
3135
|
+
if (u && r === 1 && a === 0) return {
|
|
3136
|
+
x: i.ZERO,
|
|
3137
|
+
y: i.ZERO
|
|
3138
|
+
};
|
|
3139
|
+
if (r === t && (a === 2 || a === 3)) {
|
|
3140
|
+
let e = i.fromBytes(o);
|
|
3141
|
+
if (!i.isValid(e)) throw Error("bad point: is not on curve, wrong x");
|
|
3142
|
+
let t = _(e), n;
|
|
3143
|
+
try {
|
|
3144
|
+
n = i.sqrt(t);
|
|
3145
|
+
} catch (e) {
|
|
3146
|
+
let t = e instanceof Error ? ": " + e.message : "";
|
|
3147
|
+
throw Error("bad point: is not on curve, sqrt error" + t);
|
|
3148
|
+
}
|
|
3149
|
+
f();
|
|
3150
|
+
let r = i.isOdd(n);
|
|
3151
|
+
return (a & 1) == 1 !== r && (n = i.neg(n)), {
|
|
3152
|
+
x: e,
|
|
3153
|
+
y: n
|
|
3154
|
+
};
|
|
3155
|
+
} else if (r === n && a === 4) {
|
|
3156
|
+
let e = i.BYTES, t = i.fromBytes(o.subarray(0, e)), n = i.fromBytes(o.subarray(e, e * 2));
|
|
3157
|
+
if (!v(t, n)) throw Error("bad point: is not on curve");
|
|
3158
|
+
return {
|
|
3159
|
+
x: t,
|
|
3160
|
+
y: n
|
|
3161
|
+
};
|
|
3162
|
+
} else throw Error(`bad point: got length ${r}, expected compressed=${t} or uncompressed=${n}`);
|
|
3163
|
+
}
|
|
3164
|
+
let h = t.toBytes === void 0 ? p : t.toBytes, g = t.fromBytes === void 0 ? m : t.fromBytes;
|
|
3165
|
+
function _(e) {
|
|
3166
|
+
let t = i.sqr(e), n = i.mul(t, e);
|
|
3167
|
+
return i.add(i.add(n, i.mul(e, o.a)), o.b);
|
|
3168
|
+
}
|
|
3169
|
+
function v(e, t) {
|
|
3170
|
+
let n = i.sqr(t), r = _(e);
|
|
3171
|
+
return i.eql(n, r);
|
|
3172
|
+
}
|
|
3173
|
+
if (!v(o.Gx, o.Gy)) throw Error("bad curve params: generator point");
|
|
3174
|
+
let y = i.mul(i.pow(o.a, xi), Si), ee = i.mul(i.sqr(o.b), BigInt(27));
|
|
3175
|
+
if (i.is0(i.add(y, ee))) throw Error("bad curve params: a or b");
|
|
3176
|
+
function b(e, t, n = !1) {
|
|
3177
|
+
if (!i.isValid(t) || n && i.is0(t)) throw Error(`bad point coordinate ${e}`);
|
|
3178
|
+
return t;
|
|
3179
|
+
}
|
|
3180
|
+
function x(e) {
|
|
3181
|
+
if (!(e instanceof w)) throw Error("Weierstrass Point expected");
|
|
3182
|
+
}
|
|
3183
|
+
function S(e) {
|
|
3184
|
+
if (!l || !l.basises) throw Error("no endo");
|
|
3185
|
+
return _i(e, l.basises, a.ORDER);
|
|
3186
|
+
}
|
|
3187
|
+
function C(e, t, n, r, a) {
|
|
3188
|
+
return n = new w(i.mul(n.X, e), n.Y, n.Z), t = ei(r, t), n = ei(a, n), t.add(n);
|
|
3189
|
+
}
|
|
3190
|
+
class w {
|
|
3191
|
+
constructor(e, t, n) {
|
|
3192
|
+
L(this, "X", void 0), L(this, "Y", void 0), L(this, "Z", void 0), this.X = b("x", e), this.Y = b("y", t, !0), this.Z = b("z", n), Object.freeze(this);
|
|
3193
|
+
}
|
|
3194
|
+
static CURVE() {
|
|
3195
|
+
return o;
|
|
3196
|
+
}
|
|
3197
|
+
static fromAffine(e) {
|
|
3198
|
+
let { x: t, y: n } = e || {};
|
|
3199
|
+
if (!e || !i.isValid(t) || !i.isValid(n)) throw Error("invalid affine point");
|
|
3200
|
+
if (e instanceof w) throw Error("projective point not allowed");
|
|
3201
|
+
return i.is0(t) && i.is0(n) ? w.ZERO : new w(t, n, i.ONE);
|
|
3202
|
+
}
|
|
3203
|
+
static fromBytes(e) {
|
|
3204
|
+
let t = w.fromAffine(g(B(e, void 0, "point")));
|
|
3205
|
+
return t.assertValidity(), t;
|
|
3206
|
+
}
|
|
3207
|
+
static fromHex(e) {
|
|
3208
|
+
return w.fromBytes(sr(e));
|
|
3209
|
+
}
|
|
3210
|
+
get x() {
|
|
3211
|
+
return this.toAffine().x;
|
|
3212
|
+
}
|
|
3213
|
+
get y() {
|
|
3214
|
+
return this.toAffine().y;
|
|
3215
|
+
}
|
|
3216
|
+
precompute(e = 8, t = !0) {
|
|
3217
|
+
return E.createCache(this, e), t || this.multiply(xi), this;
|
|
3218
|
+
}
|
|
3219
|
+
assertValidity() {
|
|
3220
|
+
let e = this;
|
|
3221
|
+
if (e.is0()) {
|
|
3222
|
+
if (t.allowInfinityPoint && i.is0(e.X) && i.eql(e.Y, i.ONE) && i.is0(e.Z)) return;
|
|
3223
|
+
throw Error("bad point: ZERO");
|
|
3224
|
+
}
|
|
3225
|
+
let { x: n, y: r } = e.toAffine();
|
|
3226
|
+
if (!i.isValid(n) || !i.isValid(r)) throw Error("bad point: x or y not field elements");
|
|
3227
|
+
if (!v(n, r)) throw Error("bad point: equation left != right");
|
|
3228
|
+
if (!e.isTorsionFree()) throw Error("bad point: not in prime-order subgroup");
|
|
3229
|
+
}
|
|
3230
|
+
hasEvenY() {
|
|
3231
|
+
let { y: e } = this.toAffine();
|
|
3232
|
+
if (!i.isOdd) throw Error("Field doesn't support isOdd");
|
|
3233
|
+
return !i.isOdd(e);
|
|
3234
|
+
}
|
|
3235
|
+
equals(e) {
|
|
3236
|
+
x(e);
|
|
3237
|
+
let { X: t, Y: n, Z: r } = this, { X: a, Y: o, Z: s } = e, c = i.eql(i.mul(t, s), i.mul(a, r)), l = i.eql(i.mul(n, s), i.mul(o, r));
|
|
3238
|
+
return c && l;
|
|
3239
|
+
}
|
|
3240
|
+
negate() {
|
|
3241
|
+
return new w(this.X, i.neg(this.Y), this.Z);
|
|
3242
|
+
}
|
|
3243
|
+
double() {
|
|
3244
|
+
let { a: e, b: t } = o, n = i.mul(t, xi), { X: r, Y: a, Z: s } = this, c = i.ZERO, l = i.ZERO, u = i.ZERO, d = i.mul(r, r), f = i.mul(a, a), p = i.mul(s, s), m = i.mul(r, a);
|
|
3245
|
+
return m = i.add(m, m), u = i.mul(r, s), u = i.add(u, u), c = i.mul(e, u), l = i.mul(n, p), l = i.add(c, l), c = i.sub(f, l), l = i.add(f, l), l = i.mul(c, l), c = i.mul(m, c), u = i.mul(n, u), p = i.mul(e, p), m = i.sub(d, p), m = i.mul(e, m), m = i.add(m, u), u = i.add(d, d), d = i.add(u, d), d = i.add(d, p), d = i.mul(d, m), l = i.add(l, d), p = i.mul(a, s), p = i.add(p, p), d = i.mul(p, m), c = i.sub(c, d), u = i.mul(p, f), u = i.add(u, u), u = i.add(u, u), new w(c, l, u);
|
|
3246
|
+
}
|
|
3247
|
+
add(e) {
|
|
3248
|
+
x(e);
|
|
3249
|
+
let { X: t, Y: n, Z: r } = this, { X: a, Y: s, Z: c } = e, l = i.ZERO, u = i.ZERO, d = i.ZERO, f = o.a, p = i.mul(o.b, xi), m = i.mul(t, a), h = i.mul(n, s), g = i.mul(r, c), _ = i.add(t, n), v = i.add(a, s);
|
|
3250
|
+
_ = i.mul(_, v), v = i.add(m, h), _ = i.sub(_, v), v = i.add(t, r);
|
|
3251
|
+
let y = i.add(a, c);
|
|
3252
|
+
return v = i.mul(v, y), y = i.add(m, g), v = i.sub(v, y), y = i.add(n, r), l = i.add(s, c), y = i.mul(y, l), l = i.add(h, g), y = i.sub(y, l), d = i.mul(f, v), l = i.mul(p, g), d = i.add(l, d), l = i.sub(h, d), d = i.add(h, d), u = i.mul(l, d), h = i.add(m, m), h = i.add(h, m), g = i.mul(f, g), v = i.mul(p, v), h = i.add(h, g), g = i.sub(m, g), g = i.mul(f, g), v = i.add(v, g), m = i.mul(h, v), u = i.add(u, m), m = i.mul(y, v), l = i.mul(_, l), l = i.sub(l, m), m = i.mul(_, h), d = i.mul(y, d), d = i.add(d, m), new w(l, u, d);
|
|
3253
|
+
}
|
|
3254
|
+
subtract(e) {
|
|
3255
|
+
return x(e), this.add(e.negate());
|
|
3256
|
+
}
|
|
3257
|
+
is0() {
|
|
3258
|
+
return this.equals(w.ZERO);
|
|
3259
|
+
}
|
|
3260
|
+
multiply(e) {
|
|
3261
|
+
let { endo: n } = t;
|
|
3262
|
+
if (!a.isValidNot0(e)) throw RangeError("invalid scalar: out of range");
|
|
3263
|
+
let r, i, o = (e) => E.cached(this, e, (e) => ti(w, e));
|
|
3264
|
+
if (n) {
|
|
3265
|
+
let { k1neg: t, k1: a, k2neg: s, k2: c } = S(e), { p: l, f: u } = o(a), { p: d, f } = o(c);
|
|
3266
|
+
i = u.add(f), r = C(n.beta, l, d, t, s);
|
|
3267
|
+
} else {
|
|
3268
|
+
let { p: t, f: n } = o(e);
|
|
3269
|
+
r = t, i = n;
|
|
3270
|
+
}
|
|
3271
|
+
return ti(w, [r, i])[0];
|
|
3272
|
+
}
|
|
3273
|
+
multiplyUnsafe(e) {
|
|
3274
|
+
let { endo: n } = t, r = this, i = e;
|
|
3275
|
+
if (!a.isValid(i)) throw RangeError("invalid scalar: out of range");
|
|
3276
|
+
if (i === X || r.is0()) return w.ZERO;
|
|
3277
|
+
if (i === Z) return r;
|
|
3278
|
+
if (E.hasCache(this)) return this.multiply(i);
|
|
3279
|
+
if (n) {
|
|
3280
|
+
let { k1neg: e, k1: t, k2neg: a, k2: o } = S(i), { p1: s, p2: c } = ui(w, r, t, o);
|
|
3281
|
+
return C(n.beta, s, c, e, a);
|
|
3282
|
+
} else return E.unsafe(r, i);
|
|
3283
|
+
}
|
|
3284
|
+
toAffine(e) {
|
|
3285
|
+
let t = this, n = e, { X: r, Y: a, Z: o } = t;
|
|
3286
|
+
if (i.eql(o, i.ONE)) return {
|
|
3287
|
+
x: r,
|
|
3288
|
+
y: a
|
|
3289
|
+
};
|
|
3290
|
+
let s = t.is0();
|
|
3291
|
+
n ?? (n = s ? i.ONE : i.inv(o));
|
|
3292
|
+
let c = i.mul(r, n), l = i.mul(a, n), u = i.mul(o, n);
|
|
3293
|
+
if (s) return {
|
|
3294
|
+
x: i.ZERO,
|
|
3295
|
+
y: i.ZERO
|
|
3296
|
+
};
|
|
3297
|
+
if (!i.eql(u, i.ONE)) throw Error("invZ was invalid");
|
|
3298
|
+
return {
|
|
3299
|
+
x: c,
|
|
3300
|
+
y: l
|
|
3301
|
+
};
|
|
3302
|
+
}
|
|
3303
|
+
isTorsionFree() {
|
|
3304
|
+
let { isTorsionFree: e } = t;
|
|
3305
|
+
return s === Z ? !0 : e ? e(w, this) : E.unsafe(this, c).is0();
|
|
3306
|
+
}
|
|
3307
|
+
clearCofactor() {
|
|
3308
|
+
let { clearCofactor: e } = t;
|
|
3309
|
+
return s === Z ? this : e ? e(w, this) : this.multiplyUnsafe(s);
|
|
3310
|
+
}
|
|
3311
|
+
isSmallOrder() {
|
|
3312
|
+
return s === Z ? this.is0() : this.clearCofactor().is0();
|
|
3313
|
+
}
|
|
3314
|
+
toBytes(e = !0) {
|
|
3315
|
+
return H(e, "isCompressed"), this.assertValidity(), h(w, this, e);
|
|
3316
|
+
}
|
|
3317
|
+
toHex(e = !0) {
|
|
3318
|
+
return or(this.toBytes(e));
|
|
3319
|
+
}
|
|
3320
|
+
toString() {
|
|
3321
|
+
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
n = w, L(w, "BASE", new n(o.Gx, o.Gy, i.ONE)), L(w, "ZERO", new n(i.ZERO, i.ONE, i.ZERO)), L(w, "Fp", i), L(w, "Fn", a);
|
|
3325
|
+
let T = a.BITS, E = new li(w, t.endo ? Math.ceil(T / 2) : T);
|
|
3326
|
+
return T >= 8 && w.BASE.precompute(8), Object.freeze(w.prototype), Object.freeze(w), w;
|
|
3327
|
+
}
|
|
3328
|
+
function wi(e) {
|
|
3329
|
+
return Uint8Array.of(e ? 2 : 3);
|
|
3330
|
+
}
|
|
3331
|
+
function Ti(e, t) {
|
|
3332
|
+
return {
|
|
3333
|
+
secretKey: t.BYTES,
|
|
3334
|
+
publicKey: 1 + e.BYTES,
|
|
3335
|
+
publicKeyUncompressed: 1 + 2 * e.BYTES,
|
|
3336
|
+
publicKeyHasPrefix: !0,
|
|
3337
|
+
signature: 2 * t.BYTES
|
|
3338
|
+
};
|
|
3339
|
+
}
|
|
3340
|
+
function Ei(e, t = {}) {
|
|
3341
|
+
let { Fn: n } = e, r = t.randomBytes === void 0 ? lr : t.randomBytes, i = Object.assign(Ti(e.Fp, n), { seed: Math.max(Qr(n.ORDER), 16) });
|
|
3342
|
+
function a(e) {
|
|
3343
|
+
try {
|
|
3344
|
+
let t = n.fromBytes(e);
|
|
3345
|
+
return n.isValidNot0(t);
|
|
3346
|
+
} catch {
|
|
3347
|
+
return !1;
|
|
3348
|
+
}
|
|
3349
|
+
}
|
|
3350
|
+
function o(t, n) {
|
|
3351
|
+
let { publicKey: r, publicKeyUncompressed: a } = i;
|
|
3352
|
+
try {
|
|
3353
|
+
let i = t.length;
|
|
3354
|
+
return n === !0 && i !== r || n === !1 && i !== a ? !1 : !!e.fromBytes(t);
|
|
3355
|
+
} catch {
|
|
3356
|
+
return !1;
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
function s(e) {
|
|
3360
|
+
return e = e === void 0 ? r(i.seed) : e, $r(B(e, i.seed, "seed"), n.ORDER);
|
|
3361
|
+
}
|
|
3362
|
+
function c(t, r = !0) {
|
|
3363
|
+
return e.BASE.multiply(n.fromBytes(t)).toBytes(r);
|
|
3364
|
+
}
|
|
3365
|
+
function l(e) {
|
|
3366
|
+
let { secretKey: t, publicKey: r, publicKeyUncompressed: a } = i, o = n._lengths;
|
|
3367
|
+
if (!cr(e)) return;
|
|
3368
|
+
let s = B(e, void 0, "key").length, c = s === r || s === a, l = s === t || !!o?.includes(s);
|
|
3369
|
+
if (!(c && l)) return c;
|
|
3370
|
+
}
|
|
3371
|
+
function u(t, r, i = !0) {
|
|
3372
|
+
if (l(t) === !0) throw Error("first arg must be private key");
|
|
3373
|
+
if (l(r) === !1) throw Error("second arg must be public key");
|
|
3374
|
+
let a = n.fromBytes(t);
|
|
3375
|
+
return e.fromBytes(r).multiply(a).toBytes(i);
|
|
3376
|
+
}
|
|
3377
|
+
let d = {
|
|
3378
|
+
isValidSecretKey: a,
|
|
3379
|
+
isValidPublicKey: o,
|
|
3380
|
+
randomSecretKey: s
|
|
3381
|
+
}, f = pi(s, c);
|
|
3382
|
+
return Object.freeze(d), Object.freeze(i), Object.freeze({
|
|
3383
|
+
getPublicKey: c,
|
|
3384
|
+
getSharedSecret: u,
|
|
3385
|
+
keygen: f,
|
|
3386
|
+
Point: e,
|
|
3387
|
+
utils: d,
|
|
3388
|
+
lengths: i
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3391
|
+
function Di(e, t, n = {}) {
|
|
3392
|
+
let r = t;
|
|
3393
|
+
In(r), Dr(n, {}, {
|
|
3394
|
+
hmac: "function",
|
|
3395
|
+
lowS: "boolean",
|
|
3396
|
+
randomBytes: "function",
|
|
3397
|
+
bits2int: "function",
|
|
3398
|
+
bits2int_modN: "function"
|
|
3399
|
+
}), n = Object.assign({}, n);
|
|
3400
|
+
let i = n.randomBytes === void 0 ? lr : n.randomBytes, a = n.hmac === void 0 ? (e, t) => hi(r, e, t) : n.hmac, { Fp: o, Fn: s } = e, { ORDER: c, BITS: l } = s, { keygen: u, getPublicKey: d, getSharedSecret: f, utils: p, lengths: m } = Ei(e, n), h = {
|
|
3401
|
+
prehash: !0,
|
|
3402
|
+
lowS: typeof n.lowS != "boolean" || n.lowS,
|
|
3403
|
+
format: "compact",
|
|
3404
|
+
extraEntropy: !1
|
|
3405
|
+
}, g = c * bi + Z < o.ORDER;
|
|
3406
|
+
function _(e) {
|
|
3407
|
+
return e > c >> Z;
|
|
3408
|
+
}
|
|
3409
|
+
function v(e, t) {
|
|
3410
|
+
if (!s.isValidNot0(t)) throw Error(`invalid signature ${e}: out of range 1..Point.Fn.ORDER`);
|
|
3411
|
+
return t;
|
|
3412
|
+
}
|
|
3413
|
+
function y() {
|
|
3414
|
+
if (g) throw Error("\"recovered\" sig type is not supported for cofactor >2 curves");
|
|
3415
|
+
}
|
|
3416
|
+
function ee(e, t) {
|
|
3417
|
+
vi(t);
|
|
3418
|
+
let n = m.signature;
|
|
3419
|
+
return B(e, t === "compact" ? n : t === "recovered" ? n + 1 : void 0);
|
|
3420
|
+
}
|
|
3421
|
+
class b {
|
|
3422
|
+
constructor(e, t, n) {
|
|
3423
|
+
if (L(this, "r", void 0), L(this, "s", void 0), L(this, "recovery", void 0), this.r = v("r", e), this.s = v("s", t), n != null) {
|
|
3424
|
+
if (y(), ![
|
|
3425
|
+
0,
|
|
3426
|
+
1,
|
|
3427
|
+
2,
|
|
3428
|
+
3
|
|
3429
|
+
].includes(n)) throw Error("invalid recovery id");
|
|
3430
|
+
this.recovery = n;
|
|
3431
|
+
}
|
|
3432
|
+
Object.freeze(this);
|
|
3433
|
+
}
|
|
3434
|
+
static fromBytes(e, t = h.format) {
|
|
3435
|
+
ee(e, t);
|
|
3436
|
+
let n;
|
|
3437
|
+
if (t === "der") {
|
|
3438
|
+
let { r: t, s: n } = Y.toSig(B(e));
|
|
3439
|
+
return new b(t, n);
|
|
3440
|
+
}
|
|
3441
|
+
t === "recovered" && (n = e[0], t = "compact", e = e.subarray(1));
|
|
3442
|
+
let r = m.signature / 2, i = e.subarray(0, r), a = e.subarray(r, r * 2);
|
|
3443
|
+
return new b(s.fromBytes(i), s.fromBytes(a), n);
|
|
3444
|
+
}
|
|
3445
|
+
static fromHex(e, t) {
|
|
3446
|
+
return this.fromBytes(sr(e), t);
|
|
3447
|
+
}
|
|
3448
|
+
assertRecovery() {
|
|
3449
|
+
let { recovery: e } = this;
|
|
3450
|
+
if (e == null) throw Error("invalid recovery id: must be present");
|
|
3451
|
+
return e;
|
|
3452
|
+
}
|
|
3453
|
+
addRecoveryBit(e) {
|
|
3454
|
+
return new b(this.r, this.s, e);
|
|
3455
|
+
}
|
|
3456
|
+
recoverPublicKey(t) {
|
|
3457
|
+
let { r: n, s: r } = this, i = this.assertRecovery(), a = i === 2 || i === 3 ? n + c : n;
|
|
3458
|
+
if (!o.isValid(a)) throw Error("invalid recovery id: sig.r+curve.n != R.x");
|
|
3459
|
+
let l = o.toBytes(a), u = e.fromBytes(V(wi((i & 1) == 0), l)), d = s.inv(a), f = S(B(t, void 0, "msgHash")), p = s.create(-f * d), m = s.create(r * d), h = e.BASE.multiplyUnsafe(p).add(u.multiplyUnsafe(m));
|
|
3460
|
+
if (h.is0()) throw Error("invalid recovery: point at infinify");
|
|
3461
|
+
return h.assertValidity(), h;
|
|
3462
|
+
}
|
|
3463
|
+
hasHighS() {
|
|
3464
|
+
return _(this.s);
|
|
3465
|
+
}
|
|
3466
|
+
toBytes(e = h.format) {
|
|
3467
|
+
if (vi(e), e === "der") return sr(Y.hexFromSig(this));
|
|
3468
|
+
let { r: t, s: n } = this, r = s.toBytes(t), i = s.toBytes(n);
|
|
3469
|
+
return e === "recovered" ? (y(), V(Uint8Array.of(this.assertRecovery()), r, i)) : V(r, i);
|
|
3470
|
+
}
|
|
3471
|
+
toHex(e) {
|
|
3472
|
+
return or(this.toBytes(e));
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
Object.freeze(b.prototype), Object.freeze(b);
|
|
3476
|
+
let x = n.bits2int === void 0 ? function(e) {
|
|
3477
|
+
if (e.length > 8192) throw Error("input is too large");
|
|
3478
|
+
let t = gr(e), n = e.length * 8 - l;
|
|
3479
|
+
return n > 0 ? t >> BigInt(n) : t;
|
|
3480
|
+
} : n.bits2int, S = n.bits2int_modN === void 0 ? function(e) {
|
|
3481
|
+
return s.create(x(e));
|
|
3482
|
+
} : n.bits2int_modN, C = Tr(l);
|
|
3483
|
+
function w(e) {
|
|
3484
|
+
return Cr("num < 2^" + l, e, X, C), s.toBytes(e);
|
|
3485
|
+
}
|
|
3486
|
+
function T(e, t) {
|
|
3487
|
+
return B(e, void 0, "message"), t ? B(r(e), void 0, "prehashed message") : e;
|
|
3488
|
+
}
|
|
3489
|
+
function E(t, n, r) {
|
|
3490
|
+
let { lowS: a, prehash: o, extraEntropy: c } = yi(r, h);
|
|
3491
|
+
t = T(t, o);
|
|
3492
|
+
let l = S(t), u = s.fromBytes(n);
|
|
3493
|
+
if (!s.isValidNot0(u)) throw Error("invalid private key");
|
|
3494
|
+
let d = [w(u), w(l)];
|
|
3495
|
+
if (c != null && c !== !1) {
|
|
3496
|
+
let e = c === !0 ? i(m.secretKey) : c;
|
|
3497
|
+
d.push(B(e, void 0, "extraEntropy"));
|
|
3498
|
+
}
|
|
3499
|
+
let f = V(...d), p = l;
|
|
3500
|
+
function v(t) {
|
|
3501
|
+
let n = x(t);
|
|
3502
|
+
if (!s.isValidNot0(n)) return;
|
|
3503
|
+
let r = s.inv(n), i = e.BASE.multiply(n).toAffine(), o = s.create(i.x);
|
|
3504
|
+
if (o === X) return;
|
|
3505
|
+
let c = s.create(r * s.create(p + o * u));
|
|
3506
|
+
if (c === X) return;
|
|
3507
|
+
let l = (i.x === o ? 0 : 2) | Number(i.y & Z), d = c;
|
|
3508
|
+
return a && _(c) && (d = s.neg(c), l ^= 1), new b(o, d, g ? void 0 : l);
|
|
3509
|
+
}
|
|
3510
|
+
return {
|
|
3511
|
+
seed: f,
|
|
3512
|
+
k2sig: v
|
|
3513
|
+
};
|
|
3514
|
+
}
|
|
3515
|
+
function D(e, t, n = {}) {
|
|
3516
|
+
let { seed: i, k2sig: o } = E(e, t, n);
|
|
3517
|
+
return Er(r.outputLen, s.BYTES, a)(i, o).toBytes(n.format);
|
|
3518
|
+
}
|
|
3519
|
+
function te(t, n, r, i = {}) {
|
|
3520
|
+
let { lowS: a, prehash: o, format: c } = yi(i, h);
|
|
3521
|
+
if (r = B(r, void 0, "publicKey"), n = T(n, o), !cr(t)) {
|
|
3522
|
+
let e = t instanceof b ? ", use sig.toBytes()" : "";
|
|
3523
|
+
throw Error("verify expects Uint8Array signature" + e);
|
|
3524
|
+
}
|
|
3525
|
+
ee(t, c);
|
|
3526
|
+
try {
|
|
3527
|
+
let i = b.fromBytes(t, c), o = e.fromBytes(r);
|
|
3528
|
+
if (a && i.hasHighS()) return !1;
|
|
3529
|
+
let { r: l, s: u } = i, d = S(n), f = s.inv(u), p = s.create(d * f), m = s.create(l * f), h = e.BASE.multiplyUnsafe(p).add(o.multiplyUnsafe(m));
|
|
3530
|
+
return !h.is0() && s.create(h.x) === l;
|
|
3531
|
+
} catch {
|
|
3532
|
+
return !1;
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
function ne(e, t, n = {}) {
|
|
3536
|
+
let { prehash: r } = yi(n, h);
|
|
3537
|
+
return t = T(t, r), b.fromBytes(e, "recovered").recoverPublicKey(t).toBytes();
|
|
3538
|
+
}
|
|
3539
|
+
return Object.freeze({
|
|
3540
|
+
keygen: u,
|
|
3541
|
+
getPublicKey: d,
|
|
3542
|
+
getSharedSecret: f,
|
|
3543
|
+
utils: p,
|
|
3544
|
+
lengths: m,
|
|
3545
|
+
Point: e,
|
|
3546
|
+
sign: D,
|
|
3547
|
+
verify: te,
|
|
3548
|
+
recoverPublicKey: ne,
|
|
3549
|
+
Signature: b,
|
|
3550
|
+
hash: r
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
var Oi = /* @__PURE__ */ Di(/* @__PURE__ */ Ci({
|
|
3554
|
+
p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
|
|
3555
|
+
n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
|
|
3556
|
+
h: BigInt(1),
|
|
3557
|
+
a: BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),
|
|
3558
|
+
b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
|
|
3559
|
+
Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
|
|
3560
|
+
Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
|
|
3561
|
+
}), ir);
|
|
3562
|
+
//#endregion
|
|
3563
|
+
//#region src/license/verify-fallback.ts
|
|
3564
|
+
function ki(e, t, n) {
|
|
3565
|
+
let r = Ai(n);
|
|
3566
|
+
if (!r) return !1;
|
|
3567
|
+
try {
|
|
3568
|
+
return Oi.verify(t, e, r, { lowS: !1 });
|
|
3569
|
+
} catch {
|
|
3570
|
+
return !1;
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
function Ai(e) {
|
|
3574
|
+
if (e.kty !== "EC" || e.crv !== "P-256" || !e.x || !e.y) return null;
|
|
3575
|
+
let t = On(e.x), n = On(e.y);
|
|
3576
|
+
if (!t || !n || t.length !== 32 || n.length !== 32) return null;
|
|
3577
|
+
let r = /* @__PURE__ */ new Uint8Array(65);
|
|
3578
|
+
return r[0] = 4, r.set(t, 1), r.set(n, 33), r;
|
|
3579
|
+
}
|
|
3580
|
+
//#endregion
|
|
3581
|
+
//#region src/license/state.ts
|
|
3582
|
+
var ji = { status: "unlicensed" }, Mi = { status: "pending" };
|
|
3583
|
+
function Ni(e, t, n) {
|
|
3584
|
+
let r = Date.parse(e);
|
|
3585
|
+
return Number.isNaN(r) ? !1 : r >= t || !Number.isNaN(n) && r >= n;
|
|
3586
|
+
}
|
|
3587
|
+
async function Pi(e, t, n, r) {
|
|
3588
|
+
let i = An(e);
|
|
3589
|
+
if (!i) return ji;
|
|
3590
|
+
let a = t[i.payload.keyId];
|
|
3591
|
+
if (!a) return {
|
|
3592
|
+
status: "unlicensed",
|
|
3593
|
+
payload: i.payload
|
|
3594
|
+
};
|
|
3595
|
+
let o = jn(i.version, i.encodedPayload);
|
|
3596
|
+
if (!(Nn() ? await Pn(o, i.signature, a) : ki(o, i.signature, a))) return {
|
|
3597
|
+
status: "unlicensed",
|
|
3598
|
+
payload: i.payload
|
|
3599
|
+
};
|
|
3600
|
+
let s = Date.parse(r);
|
|
3601
|
+
return Ni(i.payload.expiry, n, s) ? {
|
|
3602
|
+
status: "licensed",
|
|
3603
|
+
payload: i.payload
|
|
3604
|
+
} : {
|
|
3605
|
+
status: "unlicensed",
|
|
3606
|
+
payload: i.payload
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3609
|
+
var Fi = null, Ii = ji, Li = /* @__PURE__ */ new Map(), Ri = /* @__PURE__ */ new Set(), zi = 0;
|
|
3610
|
+
function Bi() {
|
|
3611
|
+
zi++;
|
|
3612
|
+
}
|
|
3613
|
+
function Vi() {
|
|
3614
|
+
zi--;
|
|
3615
|
+
}
|
|
3616
|
+
function Hi() {
|
|
3617
|
+
return zi;
|
|
3618
|
+
}
|
|
3619
|
+
function Ui(e) {
|
|
3620
|
+
Ii = e;
|
|
3621
|
+
for (let t of Ri) t(e);
|
|
3622
|
+
}
|
|
3623
|
+
function Wi(e) {
|
|
3624
|
+
if (e === Fi) return;
|
|
3625
|
+
Fi = e;
|
|
3626
|
+
let t = Li.get(e);
|
|
3627
|
+
if (t) {
|
|
3628
|
+
Ui(t);
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
Ui(Mi), Pi(e, Mn, Date.now(), "2026-09-09").then((t) => {
|
|
3632
|
+
Li.set(e, t), Fi === e && Ui(t);
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
function Gi() {
|
|
3636
|
+
return Ii;
|
|
3637
|
+
}
|
|
3638
|
+
function Ki(e) {
|
|
3639
|
+
return Ri.add(e), e(Ii), () => Ri.delete(e);
|
|
3640
|
+
}
|
|
3641
|
+
//#endregion
|
|
3642
|
+
//#region src/license/console-notice.ts
|
|
3643
|
+
var qi = "docs/LICENSING.md", Ji = !1;
|
|
3644
|
+
function Yi(e) {
|
|
3645
|
+
if (Ji) return;
|
|
3646
|
+
Ji = !0;
|
|
3647
|
+
let t = e > 1 ? ` (${e} instances on this page)` : "";
|
|
3648
|
+
console.info(`[VScada] Running in unlicensed/evaluation mode${t} — full functionality, watermarked. See ${qi} to apply a license key.`);
|
|
3649
|
+
}
|
|
3650
|
+
//#endregion
|
|
3651
|
+
//#region src/license/watermark.ts
|
|
3652
|
+
var Q = "http://www.w3.org/2000/svg", Xi = "vscada-watermark-pattern", Zi = "#808080";
|
|
3653
|
+
function Qi(e, t, n) {
|
|
3654
|
+
if (!n.querySelector(`#${Xi}`)) {
|
|
3655
|
+
let e = document.createElementNS(Q, "pattern");
|
|
3656
|
+
e.setAttribute("id", Xi), e.setAttribute("width", "320"), e.setAttribute("height", "200"), e.setAttribute("patternUnits", "userSpaceOnUse"), e.setAttribute("patternTransform", "rotate(-30)");
|
|
3657
|
+
let t = document.createElementNS(Q, "text");
|
|
3658
|
+
t.setAttribute("x", "10"), t.setAttribute("y", "100"), t.setAttribute("font-size", "20"), t.setAttribute("fill", Zi), t.textContent = "VScada — unlicensed", e.appendChild(t), n.appendChild(e);
|
|
3659
|
+
}
|
|
3660
|
+
let r = document.createElementNS(Q, "g");
|
|
3661
|
+
r.setAttribute("class", "vscada-watermark-repeat"), r.setAttribute("pointer-events", "none"), r.setAttribute("display", "none");
|
|
3662
|
+
let i = document.createElementNS(Q, "rect");
|
|
3663
|
+
i.setAttribute("width", String(e)), i.setAttribute("height", String(t)), i.setAttribute("fill", `url(#${Xi})`), i.setAttribute("opacity", "0.12"), r.appendChild(i);
|
|
3664
|
+
let a = document.createElementNS(Q, "g");
|
|
3665
|
+
a.setAttribute("class", "vscada-watermark-badge"), a.setAttribute("pointer-events", "none"), a.setAttribute("display", "none");
|
|
3666
|
+
let o = document.createElementNS(Q, "text");
|
|
3667
|
+
o.setAttribute("x", String(e - 8)), o.setAttribute("y", String(t - 8)), o.setAttribute("text-anchor", "end"), o.setAttribute("font-size", "12"), o.setAttribute("fill", Zi), o.setAttribute("opacity", "0.7"), o.textContent = "VScada — unlicensed", a.appendChild(o);
|
|
3668
|
+
function s(e) {
|
|
3669
|
+
let t = e ? "inline" : "none";
|
|
3670
|
+
r.setAttribute("display", t), a.setAttribute("display", t);
|
|
3671
|
+
}
|
|
3672
|
+
return {
|
|
3673
|
+
repeat: r,
|
|
3674
|
+
badge: a,
|
|
3675
|
+
setVisible: s
|
|
3676
|
+
};
|
|
3677
|
+
}
|
|
3678
|
+
//#endregion
|
|
3679
|
+
//#region src/export/svg-export.ts
|
|
3680
|
+
var $i = "http://www.w3.org/2000/svg";
|
|
3681
|
+
function ea(e) {
|
|
3682
|
+
let t = e.cloneNode(!0);
|
|
3683
|
+
return ta(e, t), t.getAttribute("xmlns") || t.setAttribute("xmlns", $i), new XMLSerializer().serializeToString(t);
|
|
3684
|
+
}
|
|
3685
|
+
function ta(e, t) {
|
|
3686
|
+
na(e, t);
|
|
3687
|
+
let n = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT), r = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT), i = n.nextNode(), a = r.nextNode();
|
|
3688
|
+
for (; i && a;) na(i, a), i = n.nextNode(), a = r.nextNode();
|
|
3689
|
+
}
|
|
3690
|
+
function na(e, t) {
|
|
3691
|
+
let n = getComputedStyle(e), r = n.transform;
|
|
3692
|
+
r && r !== "none" && (t.style.transform = r), ra(n, t), ia(n, t);
|
|
3693
|
+
}
|
|
3694
|
+
function ra(e, t) {
|
|
3695
|
+
let n = t.getAttribute("style");
|
|
3696
|
+
if (!n || !n.includes("var(")) return;
|
|
3697
|
+
let r = n.split(";").map((e) => e.trim()).filter(Boolean).map((t) => {
|
|
3698
|
+
let n = t.indexOf(":");
|
|
3699
|
+
if (n === -1) return t;
|
|
3700
|
+
let r = t.slice(0, n).trim(), i = t.slice(n + 1).trim();
|
|
3701
|
+
return i.includes("var(") ? `${r}: ${e.getPropertyValue(r).trim() || i}` : `${r}: ${i}`;
|
|
3702
|
+
}).join("; ");
|
|
3703
|
+
t.setAttribute("style", r);
|
|
3704
|
+
}
|
|
3705
|
+
function ia(e, t) {
|
|
3706
|
+
for (let n of [...t.attributes]) {
|
|
3707
|
+
if (n.name === "style" || !n.value.includes("var(")) continue;
|
|
3708
|
+
let r = e.getPropertyValue(n.name).trim();
|
|
3709
|
+
r && t.setAttribute(n.name, r);
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
//#endregion
|
|
3713
|
+
//#region src/a11y/reduced-motion.ts
|
|
3714
|
+
var aa = "(prefers-reduced-motion: reduce)", oa = class {
|
|
3715
|
+
constructor(e, t, n) {
|
|
3716
|
+
this.target = e, this.staticRepresentations = t, this.matchMedia = n, this.mql = null, this.onChange = (e) => this.apply(e.matches), this.priorAnimated = null;
|
|
3717
|
+
}
|
|
3718
|
+
connect() {
|
|
3719
|
+
!this.matchMedia || this.mql || (this.mql = this.matchMedia(aa), this.mql.addEventListener("change", this.onChange), this.apply(this.mql.matches));
|
|
3720
|
+
}
|
|
3721
|
+
disconnect() {
|
|
3722
|
+
this.mql?.removeEventListener("change", this.onChange), this.mql = null;
|
|
3723
|
+
}
|
|
3724
|
+
get active() {
|
|
3725
|
+
return this.mql?.matches ?? !1;
|
|
3726
|
+
}
|
|
3727
|
+
apply(e) {
|
|
3728
|
+
e ? (this.priorAnimated === null && (this.priorAnimated = this.target.animated), this.staticRepresentations.activateAll(), this.target.animated = !1) : (this.priorAnimated !== null && (this.target.animated = this.priorAnimated, this.priorAnimated = null), this.staticRepresentations.deactivateAll());
|
|
3729
|
+
}
|
|
3730
|
+
}, sa = class {
|
|
3731
|
+
constructor() {
|
|
3732
|
+
this.entries = [], this.active = !1;
|
|
3733
|
+
}
|
|
3734
|
+
register(e, t) {
|
|
3735
|
+
this.entries.push({
|
|
3736
|
+
elementId: e,
|
|
3737
|
+
handle: t
|
|
3738
|
+
}), this.active && t.activate();
|
|
3739
|
+
}
|
|
3740
|
+
unregisterElement(e) {
|
|
3741
|
+
this.entries = this.entries.filter((t) => t.elementId !== e);
|
|
3742
|
+
}
|
|
3743
|
+
activateAll() {
|
|
3744
|
+
this.active = !0;
|
|
3745
|
+
for (let e of this.entries) e.handle.activate();
|
|
3746
|
+
}
|
|
3747
|
+
deactivateAll() {
|
|
3748
|
+
this.active = !1;
|
|
3749
|
+
for (let e of this.entries) e.handle.deactivate();
|
|
3750
|
+
}
|
|
3751
|
+
get isActive() {
|
|
3752
|
+
return this.active;
|
|
3753
|
+
}
|
|
3754
|
+
}, ca = class {
|
|
3755
|
+
constructor() {
|
|
3756
|
+
this.target = null, this.pending = [], this.flushScheduled = !1, this.sawDisconnect = !1;
|
|
3757
|
+
}
|
|
3758
|
+
attach(e) {
|
|
3759
|
+
this.target = e;
|
|
3760
|
+
}
|
|
3761
|
+
announceConditionTransition(e, t, n) {
|
|
3762
|
+
if (!(t !== "bad" && t !== "stale")) {
|
|
3763
|
+
if (t === "stale" && n) {
|
|
3764
|
+
if (this.sawDisconnect) return;
|
|
3765
|
+
this.sawDisconnect = !0, this.enqueue("Scene disconnected");
|
|
3766
|
+
return;
|
|
3767
|
+
}
|
|
3768
|
+
this.enqueue(t === "bad" ? `${e} quality bad` : `${e} stale`);
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
announceThresholdCrossing(e, t, n) {
|
|
3772
|
+
n !== "normal" && this.enqueue(`${e} ${t} ${n} alarm`);
|
|
3773
|
+
}
|
|
3774
|
+
enqueue(e) {
|
|
3775
|
+
this.pending.push(e), !this.flushScheduled && (this.flushScheduled = !0, queueMicrotask(() => this.flush()));
|
|
3776
|
+
}
|
|
3777
|
+
flush() {
|
|
3778
|
+
this.flushScheduled = !1, this.sawDisconnect = !1;
|
|
3779
|
+
let e = this.pending.join("; ");
|
|
3780
|
+
this.pending = [], this.target && (this.target.textContent = e);
|
|
3781
|
+
}
|
|
3782
|
+
};
|
|
3783
|
+
//#endregion
|
|
3784
|
+
//#region src/scheduler/alarm-band.ts
|
|
3785
|
+
function la(e, t) {
|
|
3786
|
+
let n = /* @__PURE__ */ new Set();
|
|
3787
|
+
for (let r of t) (r.direction === "below" ? e <= r.value : e >= r.value) && n.add(r.level);
|
|
3788
|
+
return n.has("low-low") ? "low-low" : n.has("high-high") ? "high-high" : n.has("low") ? "low" : n.has("high") ? "high" : "normal";
|
|
3789
|
+
}
|
|
3790
|
+
function ua(e, t, n) {
|
|
3791
|
+
if (!e) return n;
|
|
3792
|
+
switch (t) {
|
|
3793
|
+
case "low-low": return e.lowLowColor;
|
|
3794
|
+
case "low": return e.lowColor;
|
|
3795
|
+
case "high": return e.highColor;
|
|
3796
|
+
case "high-high": return e.highHighColor;
|
|
3797
|
+
default: return e.normalColor;
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
//#endregion
|
|
3801
|
+
//#region src/scada-view.ts
|
|
3802
|
+
var da, fa = "http://www.w3.org/2000/svg";
|
|
3803
|
+
function pa(e) {
|
|
3804
|
+
return e.type === "off-page";
|
|
3805
|
+
}
|
|
3806
|
+
function ma(e) {
|
|
3807
|
+
return e.type === "svg-import";
|
|
3808
|
+
}
|
|
3809
|
+
function ha(e) {
|
|
3810
|
+
return e.startsWith("__vessel-wave-animation-") || e.startsWith("__vapor-drift-animation-") ? "wave" : e.startsWith("pipe-flow-animation") ? "flow" : e.startsWith("__rotating-animations-") ? "rotation" : e.startsWith("__indicator-lamp-animation-") ? "state-lamp" : "rotation";
|
|
3811
|
+
}
|
|
3812
|
+
var ga = class extends t {
|
|
3813
|
+
constructor(e = C, t = w, n = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia.bind(window) : void 0) {
|
|
3814
|
+
super(), this._scene = null, this._lastError = null, this._pendingDevValidation = null, this._sceneGeneration = 0, this._staticRepresentations = new sa(), this._liveRegion = new ca(), this._unsubscribeConditionTransition = null, this._builtElements = [], this._builtDefs = null, this._watermark = null, this._licenseVerdict = { status: "unlicensed" }, this._needsStructureInsert = !1, this._schedulerStarted = !1, this._unsubscribeLicense = null, this._interactive = !0, this._gestureArbiter = dn(), this._hitLayerGroup = null, this._hitAreaEntries = [], this._viewportGroup = null, this._lodActive = !1, this._listenersAttached = !1, this._isIntersecting = !0, this._intersectionObserver = null, this._boundVisibilityChange = null, this._unsubscribeRenderStats = null, this._groupViewState = null, this._flowInferenceCache = null, this._flowStoppedSourceIds = /* @__PURE__ */ new Set(), this._flowClosedNodeIds = /* @__PURE__ */ new Set(), this._flowTrackedElementIds = [], this._renderer = t, this._store = new Ze(e, (e) => this._dispatchValueWarning(e)), this._animations = new $e(), this._scheduler = new ft(e, this._store, t, this._animations), this._reducedMotion = new oa(this, this._staticRepresentations, n), this._unsubscribeConditionTransition = this._scheduler.onConditionTransition((e, t, n) => this._handleConditionTransition(e, n)), this._viewportState = En(e, (e) => this._onViewportFrame(e)), this._panZoomGestures = gn({
|
|
3815
|
+
onPan: (e, t) => {
|
|
3816
|
+
let n = this._viewBoxScale();
|
|
3817
|
+
this._viewportState.panBy(e * n, t * n);
|
|
3818
|
+
},
|
|
3819
|
+
onZoomAboutPoint: (e, t, n) => {
|
|
3820
|
+
let r = this._toCanvasPoint(t, n);
|
|
3821
|
+
this._viewportState.zoomAboutPoint(e, r.x, r.y);
|
|
3822
|
+
},
|
|
3823
|
+
getZoom: () => this._viewportState.zoom
|
|
3824
|
+
});
|
|
3825
|
+
}
|
|
3826
|
+
get stalenessTimeout() {
|
|
3827
|
+
return this._scheduler.stalenessTimeout;
|
|
3828
|
+
}
|
|
3829
|
+
set stalenessTimeout(e) {
|
|
3830
|
+
this._scheduler.stalenessTimeout = e;
|
|
3831
|
+
}
|
|
3832
|
+
get snapThreshold() {
|
|
3833
|
+
return this._scheduler.snapThreshold;
|
|
3834
|
+
}
|
|
3835
|
+
set snapThreshold(e) {
|
|
3836
|
+
this._scheduler.snapThreshold = e;
|
|
3837
|
+
}
|
|
3838
|
+
get connectionState() {
|
|
3839
|
+
return this._scheduler.connectionState;
|
|
3840
|
+
}
|
|
3841
|
+
set connectionState(e) {
|
|
3842
|
+
this._scheduler.connectionState = e;
|
|
3843
|
+
}
|
|
3844
|
+
get mode() {
|
|
3845
|
+
return this._scheduler.mode;
|
|
3846
|
+
}
|
|
3847
|
+
set mode(e) {
|
|
3848
|
+
this._scheduler.mode = e;
|
|
3849
|
+
}
|
|
3850
|
+
get animated() {
|
|
3851
|
+
return this._scheduler.animate;
|
|
3852
|
+
}
|
|
3853
|
+
set animated(e) {
|
|
3854
|
+
this._scheduler.animate = e;
|
|
3855
|
+
}
|
|
3856
|
+
get reducedMotionActive() {
|
|
3857
|
+
return this._reducedMotion.active;
|
|
3858
|
+
}
|
|
3859
|
+
snapToTargets() {
|
|
3860
|
+
this._scheduler.snapToTargets(), this._viewportState.snap();
|
|
3861
|
+
}
|
|
3862
|
+
get interactive() {
|
|
3863
|
+
return this._interactive;
|
|
3864
|
+
}
|
|
3865
|
+
set interactive(e) {
|
|
3866
|
+
this._interactive = e;
|
|
3867
|
+
}
|
|
3868
|
+
get zoom() {
|
|
3869
|
+
return this._viewportState.zoom;
|
|
3870
|
+
}
|
|
3871
|
+
set zoom(e) {
|
|
3872
|
+
this._viewportState.setZoomAnimated(e);
|
|
3873
|
+
}
|
|
3874
|
+
get debug() {
|
|
3875
|
+
return this._scheduler.debug;
|
|
3876
|
+
}
|
|
3877
|
+
set debug(e) {
|
|
3878
|
+
this._scheduler.debug = e, e && !this._unsubscribeRenderStats ? this._unsubscribeRenderStats = this._scheduler.onRenderStats((e) => this._dispatchRenderStats(e)) : !e && this._unsubscribeRenderStats && (this._unsubscribeRenderStats(), this._unsubscribeRenderStats = null);
|
|
3879
|
+
}
|
|
3880
|
+
seekAll(e) {
|
|
3881
|
+
this._animations.seekAll(e);
|
|
3882
|
+
}
|
|
3883
|
+
exportSVG() {
|
|
3884
|
+
let e = this.renderRoot?.querySelector("svg");
|
|
3885
|
+
return e ? ea(e) : "";
|
|
3886
|
+
}
|
|
3887
|
+
static get observedAttributes() {
|
|
3888
|
+
return [
|
|
3889
|
+
...super.observedAttributes,
|
|
3890
|
+
"license-key",
|
|
3891
|
+
"tag-prefix",
|
|
3892
|
+
"interactive",
|
|
3893
|
+
"mode",
|
|
3894
|
+
"animated"
|
|
3895
|
+
];
|
|
3896
|
+
}
|
|
3897
|
+
attributeChangedCallback(e, t, n) {
|
|
3898
|
+
super.attributeChangedCallback(e, t, n), e === "license-key" && n !== null && n !== t && Wi(n), e === "tag-prefix" && n !== t && (this.tagPrefix = n ?? ""), e === "interactive" && n !== t && (this.interactive = n !== "false"), e === "mode" && n !== t && (this.mode = n === "static" ? "static" : "live"), e === "animated" && n !== t && (this.animated = n !== "false");
|
|
3899
|
+
}
|
|
3900
|
+
get tagPrefix() {
|
|
3901
|
+
return this._store.tagPrefix;
|
|
3902
|
+
}
|
|
3903
|
+
set tagPrefix(e) {
|
|
3904
|
+
this._store.tagPrefix = e;
|
|
3905
|
+
}
|
|
3906
|
+
get scene() {
|
|
3907
|
+
return this._scene;
|
|
3908
|
+
}
|
|
3909
|
+
set scene(e) {
|
|
3910
|
+
if (e === this._scene) return;
|
|
3911
|
+
let t = ++this._sceneGeneration;
|
|
3912
|
+
this._teardownBuiltElements();
|
|
3913
|
+
let n = d(e, _());
|
|
3914
|
+
if (!n.ok) {
|
|
3915
|
+
this._scene = null, this._lastError = n.error, this._pendingDevValidation = null, this.dispatchEvent(new CustomEvent("scene-error", {
|
|
3916
|
+
detail: n.error,
|
|
3917
|
+
bubbles: !0,
|
|
3918
|
+
composed: !0
|
|
3919
|
+
})), this.requestUpdate();
|
|
3920
|
+
return;
|
|
3921
|
+
}
|
|
3922
|
+
this._scene = n.scene, this._lastError = null, this._groupViewState ? this._groupViewState.reset(this._scene) : this._groupViewState = new nn(this._scene, this._animations), this._viewportState.reset(this._scene.canvas.width, this._scene.canvas.height), this._buildElements(this._scene), this.requestUpdate(), this._pendingDevValidation = f(e).then((e) => {
|
|
3923
|
+
if (t === this._sceneGeneration && !(!e || e.length === 0)) {
|
|
3924
|
+
for (let t of e) console.warn(`[vscada] scene diagnostic at "${t.path}": ${t.message}`);
|
|
3925
|
+
this.dispatchEvent(new CustomEvent("scene-error", {
|
|
3926
|
+
detail: {
|
|
3927
|
+
code: "BAD_SHAPE",
|
|
3928
|
+
message: `${e.length} dev-only Zod diagnostic(s); see console`,
|
|
3929
|
+
path: e[0].path
|
|
3930
|
+
},
|
|
3931
|
+
bubbles: !0,
|
|
3932
|
+
composed: !0
|
|
3933
|
+
}));
|
|
3934
|
+
}
|
|
3935
|
+
}).catch((e) => {
|
|
3936
|
+
console.error("[vscada] dev-only scene validation failed", e);
|
|
3937
|
+
});
|
|
3938
|
+
}
|
|
3939
|
+
get pendingDevValidation() {
|
|
3940
|
+
return this._pendingDevValidation;
|
|
3941
|
+
}
|
|
3942
|
+
get values() {
|
|
3943
|
+
return Array.from(this._store.tags()).map((e) => {
|
|
3944
|
+
let t = this._store.get(e), n = {
|
|
3945
|
+
tag: e,
|
|
3946
|
+
value: t.currentValue,
|
|
3947
|
+
quality: t.quality
|
|
3948
|
+
};
|
|
3949
|
+
return t.timestamp !== void 0 && (n.timestamp = t.timestamp), n;
|
|
3950
|
+
});
|
|
3951
|
+
}
|
|
3952
|
+
set values(e) {
|
|
3953
|
+
this.setValues(e);
|
|
3954
|
+
}
|
|
3955
|
+
setValues(e) {
|
|
3956
|
+
this._store.setValues(e), this._scheduler.mode === "static" ? this._scheduler.snapToTargets() : this._maybeStartScheduler();
|
|
3957
|
+
}
|
|
3958
|
+
clearValues() {
|
|
3959
|
+
this._store.clearValues();
|
|
3960
|
+
}
|
|
3961
|
+
connectedCallback() {
|
|
3962
|
+
super.connectedCallback(), Bi();
|
|
3963
|
+
let e = !0;
|
|
3964
|
+
this._unsubscribeLicense = Ki((t) => {
|
|
3965
|
+
if (e) {
|
|
3966
|
+
e = !1, queueMicrotask(() => this._onLicenseVerdict(Gi()));
|
|
3967
|
+
return;
|
|
3968
|
+
}
|
|
3969
|
+
this._onLicenseVerdict(t);
|
|
3970
|
+
}), this._maybeStartScheduler(), this._reducedMotion.connect(), typeof IntersectionObserver < "u" && (this._intersectionObserver = new IntersectionObserver((e) => {
|
|
3971
|
+
let t = e[e.length - 1];
|
|
3972
|
+
t && (this._isIntersecting = t.isIntersecting, this._syncVisibilityPause());
|
|
3973
|
+
}), this._intersectionObserver.observe(this)), typeof document < "u" && (this._boundVisibilityChange = () => this._syncVisibilityPause(), document.addEventListener("visibilitychange", this._boundVisibilityChange));
|
|
3974
|
+
}
|
|
3975
|
+
disconnectedCallback() {
|
|
3976
|
+
super.disconnectedCallback(), Vi(), this._reducedMotion.disconnect(), this._unsubscribeConditionTransition?.(), this._unsubscribeLicense?.(), this._unsubscribeLicense = null, this._intersectionObserver?.disconnect(), this._intersectionObserver = null, this._boundVisibilityChange && (document.removeEventListener("visibilitychange", this._boundVisibilityChange), this._boundVisibilityChange = null), this._viewportState.destroy(), this._scheduler.stop(), this._schedulerStarted = !1;
|
|
3977
|
+
}
|
|
3978
|
+
_onLicenseVerdict(e) {
|
|
3979
|
+
this._licenseVerdict = e, this._watermark?.setVisible(e.status === "unlicensed"), e.status === "unlicensed" && Yi(Hi());
|
|
3980
|
+
}
|
|
3981
|
+
firstUpdated() {
|
|
3982
|
+
let e = this.renderRoot.querySelector(".vscada-live-region");
|
|
3983
|
+
e && this._liveRegion.attach(e);
|
|
3984
|
+
let t = this.renderRoot.querySelector("svg");
|
|
3985
|
+
!t || this._listenersAttached || (this._listenersAttached = !0, this._attachPanZoomListeners(t));
|
|
3986
|
+
}
|
|
3987
|
+
updated(e) {
|
|
3988
|
+
if (super.updated(e), !this._needsStructureInsert) return;
|
|
3989
|
+
this._needsStructureInsert = !1;
|
|
3990
|
+
let t = this.renderRoot.querySelector("svg");
|
|
3991
|
+
if (t) {
|
|
3992
|
+
for (; t.firstChild;) t.removeChild(t.firstChild);
|
|
3993
|
+
this._builtDefs && t.appendChild(this._builtDefs), this._watermark && t.appendChild(this._watermark.repeat), this._viewportGroup = document.createElementNS(fa, "g"), this._viewportGroup.setAttribute("class", "vscada-viewport");
|
|
3994
|
+
for (let e of this._builtElements) this._viewportGroup.appendChild(e.svg);
|
|
3995
|
+
this._hitLayerGroup && this._viewportGroup.appendChild(this._hitLayerGroup), t.appendChild(this._viewportGroup), this._applyViewportTransform({
|
|
3996
|
+
zoom: this._viewportState.zoom,
|
|
3997
|
+
panX: this._viewportState.pan.x,
|
|
3998
|
+
panY: this._viewportState.pan.y
|
|
3999
|
+
}), this._watermark && t.appendChild(this._watermark.badge);
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
render() {
|
|
4003
|
+
let e = r`<div class="vscada-live-region" aria-live="assertive" aria-atomic="true"></div>`;
|
|
4004
|
+
if (this._lastError) return r`${e}`;
|
|
4005
|
+
let t = this._scene?.canvas.width ?? 100, n = this._scene?.canvas.height ?? 100;
|
|
4006
|
+
return r`<svg part="canvas" role="graphics-document" aria-label=${this._scene ? `SCADA diagram: ${this._scene.id}` : "SCADA diagram"} viewBox="0 0 ${t} ${n}"></svg>${e}`;
|
|
4007
|
+
}
|
|
4008
|
+
_buildElements(e) {
|
|
4009
|
+
this._builtDefs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
4010
|
+
let t = {
|
|
4011
|
+
tokens: S(e.theme ?? "classic-hmi"),
|
|
4012
|
+
defs: this._builtDefs
|
|
4013
|
+
};
|
|
4014
|
+
t.tokens.focusRing && (this.style.setProperty("--vscada-focus-ring-color", t.tokens.focusRing.color), this.style.setProperty("--vscada-focus-ring-width", `${t.tokens.focusRing.widthPx}px`), this.style.setProperty("--vscada-focus-ring-offset", `${t.tokens.focusRing.offsetPx}px`)), this._watermark = Qi(e.canvas.width, e.canvas.height, this._builtDefs), this._watermark.setVisible(this._licenseVerdict.status === "unlicensed");
|
|
4015
|
+
let n = Ut(e), r = this._groupViewState?.collapsedGroupIds() ?? /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
|
|
4016
|
+
for (let t of e.groups) if (r.has(t.id)) for (let e of t.children) i.add(e);
|
|
4017
|
+
let a = e.topology.sources, o = new Zt(n, e.inferFlow ? new Set(a === void 0 ? [...n.nodes].filter((e) => (n.incoming.get(e)?.length ?? 0) === 0 && (n.outgoing.get(e)?.length ?? 0) > 0) : a.filter((e) => n.nodes.has(e))) : /* @__PURE__ */ new Set());
|
|
4018
|
+
this._flowInferenceCache = o, this._flowStoppedSourceIds = /* @__PURE__ */ new Set(), this._flowClosedNodeIds = /* @__PURE__ */ new Set();
|
|
4019
|
+
let s = e.inferFlow ? [...n.nodes, ...n.edges.map((e) => e.id)] : [];
|
|
4020
|
+
this._scheduler.registerFlowInference(o, s);
|
|
4021
|
+
let c = /* @__PURE__ */ new Map(), l = [], u = 1;
|
|
4022
|
+
for (let r of e.elements) {
|
|
4023
|
+
if (e.inferFlow && !pa(r) && !ma(r) && n.nodes.has(r.id) && this._registerFlowStateTracking(r), i.has(r.id)) continue;
|
|
4024
|
+
let a, o;
|
|
4025
|
+
if (ma(r)) {
|
|
4026
|
+
let e = Ht(r, t, this._renderer, (e) => this._dispatchValueWarning(e));
|
|
4027
|
+
a = e.svg, o = e.handles;
|
|
4028
|
+
} else {
|
|
4029
|
+
let e = h(r.type);
|
|
4030
|
+
if (!e) continue;
|
|
4031
|
+
let n = (pa(r), r), i = e.build(n, t, this._renderer);
|
|
4032
|
+
a = i.svg, o = i.handles;
|
|
4033
|
+
}
|
|
4034
|
+
let s = pa(r) || ma(r) ? o : this._wrapHandlesForLiveRegion(r, o);
|
|
4035
|
+
this._registerHandles(r.id, s);
|
|
4036
|
+
let d = document.createElementNS(fa, "g");
|
|
4037
|
+
if (d.setAttribute("transform", `translate(${r.x} ${r.y})`), d.appendChild(a), !pa(r)) {
|
|
4038
|
+
let e = gt(r.w, r.h, t);
|
|
4039
|
+
d.appendChild(e.group), this._scheduler.registerQualityOverlay(r.id, e);
|
|
4040
|
+
let n = [...new Set(r.bindings.map((e) => e.tag))], i = {
|
|
4041
|
+
x: r.x,
|
|
4042
|
+
y: r.y
|
|
4043
|
+
}, a = ln(r.w, r.h, this._viewportState.zoom, i);
|
|
4044
|
+
a.setAttribute("tabindex", String(u++)), a.setAttribute("aria-label", r.label ?? r.id), this._hitAreaEntries.push({
|
|
4045
|
+
rect: a,
|
|
4046
|
+
w: r.w,
|
|
4047
|
+
h: r.h,
|
|
4048
|
+
origin: i
|
|
4049
|
+
}), fn(a, {
|
|
4050
|
+
elementId: r.id,
|
|
4051
|
+
elementType: r.type,
|
|
4052
|
+
tags: n,
|
|
4053
|
+
arbiter: this._gestureArbiter,
|
|
4054
|
+
isInteractive: () => this._interactive,
|
|
4055
|
+
onClick: (e) => this._dispatchElementClick(e),
|
|
4056
|
+
onHoverChange: (e) => {
|
|
4057
|
+
e && this._dispatchElementHover(r.id, n);
|
|
4058
|
+
}
|
|
4059
|
+
}), l.push({
|
|
4060
|
+
area: r.w * r.h,
|
|
4061
|
+
rect: a
|
|
4062
|
+
});
|
|
4063
|
+
}
|
|
4064
|
+
c.set(r.id, d), this._builtElements.push({
|
|
4065
|
+
elementId: r.id,
|
|
4066
|
+
svg: d
|
|
4067
|
+
});
|
|
4068
|
+
}
|
|
4069
|
+
if (l.length > 0) {
|
|
4070
|
+
this._hitLayerGroup = document.createElementNS(fa, "g"), this._hitLayerGroup.setAttribute("class", "vscada-hit-layer");
|
|
4071
|
+
for (let e of [...l].sort((e, t) => t.area - e.area)) this._hitLayerGroup.appendChild(e.rect);
|
|
4072
|
+
}
|
|
4073
|
+
for (let n of e.groups) {
|
|
4074
|
+
let e = document.createElementNS(fa, "g");
|
|
4075
|
+
if (e.setAttribute("transform", `translate(${n.x} ${n.y})`), e.setAttribute("class", "vscada-group"), r.has(n.id)) {
|
|
4076
|
+
let r = Ue(n, t);
|
|
4077
|
+
r.svg.style.cursor = "pointer", r.svg.addEventListener("click", () => this._toggleGroup(n.id)), e.appendChild(r.svg);
|
|
4078
|
+
} else e.appendChild(We(n, t));
|
|
4079
|
+
c.set(n.id, e), this._builtElements.push({
|
|
4080
|
+
elementId: n.id,
|
|
4081
|
+
svg: e
|
|
4082
|
+
});
|
|
4083
|
+
}
|
|
4084
|
+
let d = tn(n, this._renderer, {
|
|
4085
|
+
getNodeElement: (e) => c.get(e),
|
|
4086
|
+
getEdgeElement: (e) => c.get(e)
|
|
4087
|
+
}), f = ee();
|
|
4088
|
+
if (f) for (let i of e.connections) {
|
|
4089
|
+
let a = Xe(i, e, r, n);
|
|
4090
|
+
if (!a) continue;
|
|
4091
|
+
let { svg: o, handles: s } = f.build(a, t, this._renderer);
|
|
4092
|
+
this._registerHandles(i.id, s), o.addEventListener("pointerenter", (e) => {
|
|
4093
|
+
d.onPointerEnter(i.id, { pointerType: e.pointerType });
|
|
4094
|
+
}), o.addEventListener("pointerleave", () => d.onPointerLeave()), c.set(i.id, o), this._builtElements.push({
|
|
4095
|
+
elementId: i.id,
|
|
4096
|
+
svg: o
|
|
4097
|
+
});
|
|
4098
|
+
}
|
|
4099
|
+
this._needsStructureInsert = !0;
|
|
4100
|
+
}
|
|
4101
|
+
_registerFlowStateTracking(e) {
|
|
4102
|
+
let t = e.bindings.find((e) => e.type === "state");
|
|
4103
|
+
if (!t) return;
|
|
4104
|
+
let n = e.id, r = new on(t.map, e.transitions ?? {}, {
|
|
4105
|
+
duration: 0,
|
|
4106
|
+
easing: "linear"
|
|
4107
|
+
}, (e) => {});
|
|
4108
|
+
this._scheduler.registerHandle(n, t.tag, {
|
|
4109
|
+
kind: "state",
|
|
4110
|
+
write: (e, i) => {
|
|
4111
|
+
let a = r.resolve(i, t.tag);
|
|
4112
|
+
a.state === "stopped" ? this._flowStoppedSourceIds.add(n) : this._flowStoppedSourceIds.delete(n), a.state === "closed" ? this._flowClosedNodeIds.add(n) : this._flowClosedNodeIds.delete(n), this._flowInferenceCache?.update(this._flowStoppedSourceIds, this._flowClosedNodeIds);
|
|
4113
|
+
}
|
|
4114
|
+
}), this._flowTrackedElementIds.push(n);
|
|
4115
|
+
}
|
|
4116
|
+
_toggleGroup(e) {
|
|
4117
|
+
!this._scene || !this._groupViewState || this._interactive && (this._groupViewState.toggleGroup(e), this.dispatchEvent(new CustomEvent("element-click", {
|
|
4118
|
+
detail: {
|
|
4119
|
+
elementId: e,
|
|
4120
|
+
elementType: "group"
|
|
4121
|
+
},
|
|
4122
|
+
bubbles: !0,
|
|
4123
|
+
composed: !0
|
|
4124
|
+
})), this._teardownBuiltElements(), this._buildElements(this._scene), this.requestUpdate());
|
|
4125
|
+
}
|
|
4126
|
+
_handleConditionTransition(e, t) {
|
|
4127
|
+
let n = this._scene?.elements.find((t) => t.id === e)?.label ?? e;
|
|
4128
|
+
this._liveRegion.announceConditionTransition(n, t, this._scheduler.connectionState === "disconnected");
|
|
4129
|
+
}
|
|
4130
|
+
_wrapHandlesForLiveRegion(e, t) {
|
|
4131
|
+
let n = e.thresholds ?? [];
|
|
4132
|
+
if (n.length === 0) return t;
|
|
4133
|
+
let r = e.label ?? e.id, i = {};
|
|
4134
|
+
for (let [a, o] of Object.entries(t)) {
|
|
4135
|
+
let t = o.kind === "numeric" ? n.filter((e) => e.tag === a) : [];
|
|
4136
|
+
if (o.kind !== "numeric" || t.length === 0) {
|
|
4137
|
+
i[a] = o;
|
|
4138
|
+
continue;
|
|
4139
|
+
}
|
|
4140
|
+
let s = e.bindings.find((e) => e.tag === a)?.type ?? "value", c = "normal";
|
|
4141
|
+
i[a] = {
|
|
4142
|
+
kind: "numeric",
|
|
4143
|
+
write: (e, n, i) => {
|
|
4144
|
+
let a = la(n, t);
|
|
4145
|
+
a !== c && (this._liveRegion.announceThresholdCrossing(r, s, a), c = a), o.write(e, n, i);
|
|
4146
|
+
}
|
|
4147
|
+
};
|
|
4148
|
+
}
|
|
4149
|
+
return i;
|
|
4150
|
+
}
|
|
4151
|
+
_registerHandles(e, t) {
|
|
4152
|
+
for (let [n, r] of Object.entries(t)) r.kind === "animation" ? this._animations.register(e, r, ha(n)) : r.kind === "static-representation" ? this._staticRepresentations.register(e, r) : this._scheduler.registerHandle(e, n, r);
|
|
4153
|
+
}
|
|
4154
|
+
_teardownBuiltElements() {
|
|
4155
|
+
for (let e of this._builtElements) this._scheduler.unregisterElement(e.elementId), this._animations.unregisterElement(e.elementId), this._staticRepresentations.unregisterElement(e.elementId);
|
|
4156
|
+
for (let e of this._flowTrackedElementIds) this._scheduler.unregisterElement(e);
|
|
4157
|
+
this._builtElements = [], this._flowTrackedElementIds = [], this._builtDefs = null, this._watermark = null, this._hitLayerGroup = null, this._hitAreaEntries = [], this._viewportGroup = null;
|
|
4158
|
+
}
|
|
4159
|
+
_maybeStartScheduler() {
|
|
4160
|
+
this._schedulerStarted || !this.isConnected || this._store.size === 0 || (this._scheduler.start(), this._schedulerStarted = !0);
|
|
4161
|
+
}
|
|
4162
|
+
_dispatchValueWarning(e) {
|
|
4163
|
+
this.dispatchEvent(new CustomEvent("value-warning", {
|
|
4164
|
+
detail: e,
|
|
4165
|
+
bubbles: !0,
|
|
4166
|
+
composed: !0
|
|
4167
|
+
}));
|
|
4168
|
+
}
|
|
4169
|
+
_dispatchElementClick(e) {
|
|
4170
|
+
this.dispatchEvent(new CustomEvent("element-click", {
|
|
4171
|
+
detail: e,
|
|
4172
|
+
bubbles: !0,
|
|
4173
|
+
composed: !0
|
|
4174
|
+
}));
|
|
4175
|
+
}
|
|
4176
|
+
_dispatchElementHover(e, t) {
|
|
4177
|
+
let n = {
|
|
4178
|
+
elementId: e,
|
|
4179
|
+
tags: t
|
|
4180
|
+
};
|
|
4181
|
+
this.dispatchEvent(new CustomEvent("element-hover", {
|
|
4182
|
+
detail: n,
|
|
4183
|
+
bubbles: !0,
|
|
4184
|
+
composed: !0
|
|
4185
|
+
}));
|
|
4186
|
+
}
|
|
4187
|
+
_dispatchRenderStats(e) {
|
|
4188
|
+
this.dispatchEvent(new CustomEvent("render-stats", {
|
|
4189
|
+
detail: e,
|
|
4190
|
+
bubbles: !0,
|
|
4191
|
+
composed: !0
|
|
4192
|
+
}));
|
|
4193
|
+
}
|
|
4194
|
+
_onViewportFrame(e) {
|
|
4195
|
+
this._applyViewportTransform(e);
|
|
4196
|
+
for (let t of this._hitAreaEntries) un(t.rect, t.w, t.h, e.zoom, t.origin);
|
|
4197
|
+
let t = rt(e.zoom, this._lodActive);
|
|
4198
|
+
this._lodActive = t, this._scheduler.lodActive = t, this._viewportGroup?.classList.toggle("vscada-lod-active", t);
|
|
4199
|
+
}
|
|
4200
|
+
_applyViewportTransform(e) {
|
|
4201
|
+
this._viewportGroup && this._renderer.setAttr(this._viewportGroup, "transform", `translate(${e.panX} ${e.panY}) scale(${e.zoom})`);
|
|
4202
|
+
}
|
|
4203
|
+
_viewBoxScale() {
|
|
4204
|
+
if (!this._scene) return 1;
|
|
4205
|
+
let e = this.renderRoot.querySelector("svg");
|
|
4206
|
+
if (!e) return 1;
|
|
4207
|
+
let t = e.getBoundingClientRect();
|
|
4208
|
+
return t.width === 0 ? 1 : this._scene.canvas.width / t.width;
|
|
4209
|
+
}
|
|
4210
|
+
_toCanvasPoint(e, t) {
|
|
4211
|
+
let n = this.renderRoot.querySelector("svg");
|
|
4212
|
+
if (!n || !this._scene) return {
|
|
4213
|
+
x: e,
|
|
4214
|
+
y: t
|
|
4215
|
+
};
|
|
4216
|
+
let r = n.getBoundingClientRect(), i = this._viewBoxScale();
|
|
4217
|
+
return {
|
|
4218
|
+
x: (e - r.left) * i,
|
|
4219
|
+
y: (t - r.top) * i
|
|
4220
|
+
};
|
|
4221
|
+
}
|
|
4222
|
+
_attachPanZoomListeners(e) {
|
|
4223
|
+
e.addEventListener("pointerdown", (e) => {
|
|
4224
|
+
let t = e;
|
|
4225
|
+
this._panZoomGestures.onPointerDown(t.pointerId, t.clientX, t.clientY);
|
|
4226
|
+
}), e.addEventListener("pointermove", (e) => {
|
|
4227
|
+
let t = e;
|
|
4228
|
+
this._panZoomGestures.onPointerMove(t.pointerId, t.clientX, t.clientY);
|
|
4229
|
+
}), e.addEventListener("pointerup", (e) => {
|
|
4230
|
+
this._panZoomGestures.onPointerUp(e.pointerId);
|
|
4231
|
+
}), e.addEventListener("pointercancel", (e) => {
|
|
4232
|
+
this._panZoomGestures.onPointerCancel(e.pointerId);
|
|
4233
|
+
}), e.addEventListener("wheel", (e) => {
|
|
4234
|
+
e.preventDefault();
|
|
4235
|
+
let t = e;
|
|
4236
|
+
this._panZoomGestures.onWheel(t.deltaY, t.clientX, t.clientY);
|
|
4237
|
+
}, { passive: !1 });
|
|
4238
|
+
}
|
|
4239
|
+
_syncVisibilityPause() {
|
|
4240
|
+
!this._isIntersecting || document.hidden ? this._scheduler.pauseForOffscreen() : this._scheduler.resumeFromOffscreen();
|
|
4241
|
+
}
|
|
4242
|
+
};
|
|
4243
|
+
da = ga, da.styles = n`
|
|
4244
|
+
:host {
|
|
4245
|
+
display: block;
|
|
4246
|
+
}
|
|
4247
|
+
svg {
|
|
4248
|
+
display: block;
|
|
4249
|
+
width: 100%;
|
|
4250
|
+
height: 100%;
|
|
4251
|
+
touch-action: none;
|
|
4252
|
+
}
|
|
4253
|
+
/**
|
|
4254
|
+
* Story 4.3 Task 2 — LOD's "text labels below legibility → hidden".
|
|
4255
|
+
* One core-owned CSS toggle on the viewport group covers every
|
|
4256
|
+
* primitive's text uniformly (labels, readouts, the quality overlay's
|
|
4257
|
+
* age badge) — no per-primitive change needed.
|
|
4258
|
+
*/
|
|
4259
|
+
.vscada-viewport.vscada-lod-active text {
|
|
4260
|
+
display: none;
|
|
4261
|
+
}
|
|
4262
|
+
/* Story 4.4 Task 3 — §11 ARIA live region: present in the accessibility
|
|
4263
|
+
tree (never display:none/visibility:hidden, which would strip it
|
|
4264
|
+
from screen readers too) but invisible on screen. Standard
|
|
4265
|
+
visually-hidden recipe. */
|
|
4266
|
+
.vscada-live-region {
|
|
4267
|
+
position: absolute;
|
|
4268
|
+
width: 1px;
|
|
4269
|
+
height: 1px;
|
|
4270
|
+
overflow: hidden;
|
|
4271
|
+
clip-path: inset(50%);
|
|
4272
|
+
white-space: nowrap;
|
|
4273
|
+
}
|
|
4274
|
+
/* Story 4.4 Task 4 — §11 keyboard focus ring. Custom properties are
|
|
4275
|
+
resolved from the theme's focusRing token at scene-build time
|
|
4276
|
+
(_buildElements, on the host element) and inherit through the
|
|
4277
|
+
shadow boundary by construction; the fallback values here are the
|
|
4278
|
+
ONLY thing that ever renders if a theme declares no focusRing token
|
|
4279
|
+
at all — a missing focus ring is an accessibility regression, unlike
|
|
4280
|
+
a primitive's own graceful color degrade (AD-7), so this default is
|
|
4281
|
+
deliberate, not a banned literal-color fallback. */
|
|
4282
|
+
.vscada-hit-area:focus-visible {
|
|
4283
|
+
outline: var(--vscada-focus-ring-width, 2px) solid var(--vscada-focus-ring-color, #2c7be5);
|
|
4284
|
+
outline-offset: var(--vscada-focus-ring-offset, 2px);
|
|
4285
|
+
}
|
|
4286
|
+
`;
|
|
4287
|
+
function _a(e = "scada-view") {
|
|
4288
|
+
let t = customElements.get(e);
|
|
4289
|
+
t ? t !== ga && console.warn(`defineScadaView: "${e}" is already registered to a different class — ScadaView will not be used for this tag.`) : customElements.define(e, ga);
|
|
4290
|
+
}
|
|
4291
|
+
//#endregion
|
|
4292
|
+
//#region src/scene/crossing-jumps.ts
|
|
4293
|
+
var va = 24 * .8, ya = 1e-6, ba = 1e-9;
|
|
4294
|
+
function xa(e) {
|
|
4295
|
+
let t = /* @__PURE__ */ new Map();
|
|
4296
|
+
for (let n = 0; n < e.length; n++) {
|
|
4297
|
+
let r = e[n];
|
|
4298
|
+
if (r) for (let i = n + 1; i < e.length; i++) {
|
|
4299
|
+
let n = e[i];
|
|
4300
|
+
if (n) for (let e of r.segments) for (let r = 0; r < n.segments.length; r++) {
|
|
4301
|
+
let a = Sa(e, n.segments[r]);
|
|
4302
|
+
if (!a) continue;
|
|
4303
|
+
let o = t.get(i) ?? [];
|
|
4304
|
+
o.push({
|
|
4305
|
+
point: a.point,
|
|
4306
|
+
segmentIndex: r,
|
|
4307
|
+
t: a.u
|
|
4308
|
+
}), t.set(i, o);
|
|
4309
|
+
}
|
|
4310
|
+
}
|
|
4311
|
+
}
|
|
4312
|
+
return t;
|
|
4313
|
+
}
|
|
4314
|
+
function Sa(e, t) {
|
|
4315
|
+
let n = e.to.x - e.from.x, r = e.to.y - e.from.y, i = t.to.x - t.from.x, a = t.to.y - t.from.y, o = n * a - r * i, s = n * n + r * r + i * i + a * a || 1;
|
|
4316
|
+
if (Math.abs(o) < ba * s) return null;
|
|
4317
|
+
let c = t.from.x - e.from.x, l = t.from.y - e.from.y, u = (c * a - l * i) / o, d = (c * r - l * n) / o;
|
|
4318
|
+
return u <= ya || u >= 1 - ya || d <= ya || d >= 1 - ya ? null : {
|
|
4319
|
+
point: {
|
|
4320
|
+
x: e.from.x + u * n,
|
|
4321
|
+
y: e.from.y + u * r
|
|
4322
|
+
},
|
|
4323
|
+
t: u,
|
|
4324
|
+
u: d
|
|
4325
|
+
};
|
|
4326
|
+
}
|
|
4327
|
+
function Ca(e, t, n = va) {
|
|
4328
|
+
if (t.length === 0) return e;
|
|
4329
|
+
let r = /* @__PURE__ */ new Map();
|
|
4330
|
+
for (let e of t) {
|
|
4331
|
+
let t = r.get(e.segmentIndex) ?? [];
|
|
4332
|
+
t.push(e), r.set(e.segmentIndex, t);
|
|
4333
|
+
}
|
|
4334
|
+
let i = [...r.keys()].sort((e, t) => t - e), a = e.segments, o = e.corners;
|
|
4335
|
+
for (let e of i) {
|
|
4336
|
+
let t = [...r.get(e)].sort((e, t) => e.t - t.t), i = wa(a, o, e, t, n);
|
|
4337
|
+
i && (a = i.segments, o = i.corners);
|
|
4338
|
+
}
|
|
4339
|
+
return {
|
|
4340
|
+
...e,
|
|
4341
|
+
segments: a,
|
|
4342
|
+
corners: o
|
|
4343
|
+
};
|
|
4344
|
+
}
|
|
4345
|
+
function wa(e, t, n, r, i) {
|
|
4346
|
+
let a = e[n];
|
|
4347
|
+
if (!a) return null;
|
|
4348
|
+
let o = a.to.x - a.from.x, s = a.to.y - a.from.y, c = Math.hypot(o, s);
|
|
4349
|
+
if (c < 1e-9) return null;
|
|
4350
|
+
let l = o / c, u = s / c, d = r.map((e) => Math.hypot(e.point.x - a.from.x, e.point.y - a.from.y)), f = d.map((e, t) => {
|
|
4351
|
+
let n = t === 0 ? e : e - d[t - 1], r = t === d.length - 1 ? c - e : d[t + 1] - e;
|
|
4352
|
+
return Math.min(i, n / 2, r / 2);
|
|
4353
|
+
}), p = [], m = [], h = a.from, g = !1;
|
|
4354
|
+
for (let e = 0; e < r.length; e++) {
|
|
4355
|
+
let t = f[e];
|
|
4356
|
+
if (t <= 1e-6) continue;
|
|
4357
|
+
let n = r[e].point, i = {
|
|
4358
|
+
x: n.x - l * t,
|
|
4359
|
+
y: n.y - u * t
|
|
4360
|
+
}, a = {
|
|
4361
|
+
x: n.x + l * t,
|
|
4362
|
+
y: n.y + u * t
|
|
4363
|
+
};
|
|
4364
|
+
p.push({
|
|
4365
|
+
from: h,
|
|
4366
|
+
to: i
|
|
4367
|
+
}), m.push({
|
|
4368
|
+
from: i,
|
|
4369
|
+
to: a,
|
|
4370
|
+
radius: t,
|
|
4371
|
+
sweepFlag: 0
|
|
4372
|
+
}), h = a, g = !0;
|
|
4373
|
+
}
|
|
4374
|
+
return g ? (p.push({
|
|
4375
|
+
from: h,
|
|
4376
|
+
to: a.to
|
|
4377
|
+
}), {
|
|
4378
|
+
segments: [
|
|
4379
|
+
...e.slice(0, n),
|
|
4380
|
+
...p,
|
|
4381
|
+
...e.slice(n + 1)
|
|
4382
|
+
],
|
|
4383
|
+
corners: Ta(t, n, m)
|
|
4384
|
+
}) : null;
|
|
4385
|
+
}
|
|
4386
|
+
function Ta(e, t, n) {
|
|
4387
|
+
if (n.length === 0) return e.slice();
|
|
4388
|
+
if (e.length === 0) {
|
|
4389
|
+
let e = [];
|
|
4390
|
+
for (let r = 0; r < n.length; r++) e[t + r] = n[r];
|
|
4391
|
+
return e;
|
|
4392
|
+
}
|
|
4393
|
+
return [
|
|
4394
|
+
...e.slice(0, t),
|
|
4395
|
+
...n,
|
|
4396
|
+
...e.slice(t)
|
|
4397
|
+
];
|
|
4398
|
+
}
|
|
4399
|
+
function Ea(e) {
|
|
4400
|
+
let t = e.connections.map((t) => ({
|
|
4401
|
+
connection: t,
|
|
4402
|
+
route: xe(t, e)
|
|
4403
|
+
})), n = xa(t.map((e) => e.route));
|
|
4404
|
+
return n.size === 0 ? t : t.map(({ connection: e, route: t }, r) => {
|
|
4405
|
+
if (!t) return {
|
|
4406
|
+
connection: e,
|
|
4407
|
+
route: t
|
|
4408
|
+
};
|
|
4409
|
+
let i = n.get(r);
|
|
4410
|
+
return !i || i.length === 0 ? {
|
|
4411
|
+
connection: e,
|
|
4412
|
+
route: t
|
|
4413
|
+
} : {
|
|
4414
|
+
connection: e,
|
|
4415
|
+
route: Ca(t, i)
|
|
4416
|
+
};
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4419
|
+
//#endregion
|
|
4420
|
+
//#region src/a11y/contrast.ts
|
|
4421
|
+
function Da(e) {
|
|
4422
|
+
let t = e / 255;
|
|
4423
|
+
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
4424
|
+
}
|
|
4425
|
+
function Oa(e) {
|
|
4426
|
+
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
|
|
4427
|
+
return {
|
|
4428
|
+
r: parseInt(n.slice(0, 2), 16),
|
|
4429
|
+
g: parseInt(n.slice(2, 4), 16),
|
|
4430
|
+
b: parseInt(n.slice(4, 6), 16)
|
|
4431
|
+
};
|
|
4432
|
+
}
|
|
4433
|
+
function ka(e) {
|
|
4434
|
+
let { r: t, g: n, b: r } = Oa(e);
|
|
4435
|
+
return .2126 * Da(t) + .7152 * Da(n) + .0722 * Da(r);
|
|
4436
|
+
}
|
|
4437
|
+
function Aa(e, t) {
|
|
4438
|
+
let n = ka(e), r = ka(t), i = Math.max(n, r), a = Math.min(n, r);
|
|
4439
|
+
return (i + .05) / (a + .05);
|
|
4440
|
+
}
|
|
4441
|
+
//#endregion
|
|
4442
|
+
//#region src/units/registry.ts
|
|
4443
|
+
function $(e) {
|
|
4444
|
+
return {
|
|
4445
|
+
toCanonical: (t) => t * e,
|
|
4446
|
+
fromCanonical: (t) => t / e
|
|
4447
|
+
};
|
|
4448
|
+
}
|
|
4449
|
+
var ja = {
|
|
4450
|
+
Pa: {
|
|
4451
|
+
family: "pressure",
|
|
4452
|
+
...$(1)
|
|
4453
|
+
},
|
|
4454
|
+
kPa: {
|
|
4455
|
+
family: "pressure",
|
|
4456
|
+
...$(1e3)
|
|
4457
|
+
},
|
|
4458
|
+
bar: {
|
|
4459
|
+
family: "pressure",
|
|
4460
|
+
...$(1e5)
|
|
4461
|
+
},
|
|
4462
|
+
psi: {
|
|
4463
|
+
family: "pressure",
|
|
4464
|
+
...$(6894.757293168361)
|
|
4465
|
+
},
|
|
4466
|
+
K: {
|
|
4467
|
+
family: "temperature",
|
|
4468
|
+
toCanonical: (e) => e,
|
|
4469
|
+
fromCanonical: (e) => e
|
|
4470
|
+
},
|
|
4471
|
+
degC: {
|
|
4472
|
+
family: "temperature",
|
|
4473
|
+
toCanonical: (e) => e + 273.15,
|
|
4474
|
+
fromCanonical: (e) => e - 273.15
|
|
4475
|
+
},
|
|
4476
|
+
degF: {
|
|
4477
|
+
family: "temperature",
|
|
4478
|
+
toCanonical: (e) => (e - 32) * 5 / 9 + 273.15,
|
|
4479
|
+
fromCanonical: (e) => (e - 273.15) * 9 / 5 + 32
|
|
4480
|
+
},
|
|
4481
|
+
m3s: {
|
|
4482
|
+
family: "flow",
|
|
4483
|
+
...$(1)
|
|
4484
|
+
},
|
|
4485
|
+
m3h: {
|
|
4486
|
+
family: "flow",
|
|
4487
|
+
...$(1 / 3600)
|
|
4488
|
+
},
|
|
4489
|
+
lpm: {
|
|
4490
|
+
family: "flow",
|
|
4491
|
+
...$(1 / 6e4)
|
|
4492
|
+
},
|
|
4493
|
+
gpm: {
|
|
4494
|
+
family: "flow",
|
|
4495
|
+
...$(.003785411784 / 60)
|
|
4496
|
+
},
|
|
4497
|
+
m: {
|
|
4498
|
+
family: "level",
|
|
4499
|
+
...$(1)
|
|
4500
|
+
},
|
|
4501
|
+
mm: {
|
|
4502
|
+
family: "level",
|
|
4503
|
+
...$(.001)
|
|
4504
|
+
},
|
|
4505
|
+
W: {
|
|
4506
|
+
family: "power",
|
|
4507
|
+
...$(1)
|
|
4508
|
+
},
|
|
4509
|
+
kW: {
|
|
4510
|
+
family: "power",
|
|
4511
|
+
...$(1e3)
|
|
4512
|
+
},
|
|
4513
|
+
MW: {
|
|
4514
|
+
family: "power",
|
|
4515
|
+
...$(1e6)
|
|
4516
|
+
},
|
|
4517
|
+
kg: {
|
|
4518
|
+
family: "mass",
|
|
4519
|
+
...$(1)
|
|
4520
|
+
},
|
|
4521
|
+
t: {
|
|
4522
|
+
family: "mass",
|
|
4523
|
+
...$(1e3)
|
|
4524
|
+
},
|
|
4525
|
+
lb: {
|
|
4526
|
+
family: "mass",
|
|
4527
|
+
...$(.45359237)
|
|
4528
|
+
}
|
|
4529
|
+
};
|
|
4530
|
+
function Ma(e) {
|
|
4531
|
+
return ja[e]?.family;
|
|
4532
|
+
}
|
|
4533
|
+
function Na(e, t, n) {
|
|
4534
|
+
if (t === n) return e;
|
|
4535
|
+
let r = ja[t], i = ja[n];
|
|
4536
|
+
if (!(!r || !i || r.family !== i.family)) return i.fromCanonical(r.toCanonical(e));
|
|
4537
|
+
}
|
|
4538
|
+
//#endregion
|
|
4539
|
+
//#region src/units/formatter.ts
|
|
4540
|
+
function Pa(e, t) {
|
|
4541
|
+
if (typeof e != "number" || !Number.isFinite(e)) return String(e);
|
|
4542
|
+
let n = t.displayUnit ?? t.unit, r = Na(e, t.unit, n), i = r ?? e, a = r === void 0 ? t.unit : n, o = i.toFixed(t.decimals);
|
|
4543
|
+
return a.length > 0 ? `${o} ${a}` : o;
|
|
4544
|
+
}
|
|
4545
|
+
//#endregion
|
|
4546
|
+
//#region src/index.ts
|
|
4547
|
+
var Fa = "0.0.0";
|
|
4548
|
+
//#endregion
|
|
4549
|
+
export { vn as DAMPED_OVERSHOOT_OMEGA, _n as DAMPED_OVERSHOOT_ZETA, Ct as DEFAULT_NEEDLE_SCALE, Zt as FlowInferenceCache, on as Fsm, nn as GroupViewStateController, va as JUMP_ARC_RADIUS, oe as LANE_WIDTH, xt as MAX_BINDING_PLAYBACK_RATE, ae as PIPE_WIDTH_REFERENCE, i as SCENE_ERROR_CODES, e as SUPPORTED_SCENE_VERSIONS, ga as ScadaView, Sn as Tween, an as UNKNOWN_STATE, Fa as VERSION, se as applyLaneOffset, Ke as buildBoundaryReferenceIndex, Ie as buildCollapsedGraphView, We as buildGroupExpandedFrame, Ue as buildGroupSummaryBlock, Ye as buildPresentationScene, Ut as buildTopologyGraph, Yt as computeFlowInference, Qt as computeUpstreamHighlight, Aa as contrastRatio, Na as convertUnit, rn as createGroupViewState, tn as createUpstreamHoverController, C as defaultTimeSource, _a as defineScadaView, xa as detectCrossings, w as domRenderer, Kt as downstreamOf, Pa as formatDisplayValue, Gi as getLicenseVerdict, $t as isFinePointerHover, Ki as onLicenseVerdict, Fe as presentationNodeId, j as rangeFraction, Wt as reachableSet, y as registerConnectionRenderer, m as registerPrimitives, It as registerSvgSources, x as registerThemes, ka as relativeLuminance, la as resolveAlarmBand, ua as resolveAlarmColor, St as resolveBlinkRate, Pt as resolveColorRampColor, be as resolveEffectiveMedium, ye as resolveEffectiveMediumStyle, bt as resolveEmissionIntensity, Xe as resolveGroupAwareConnectionGeometry, yt as resolveLevelFraction, me as resolveMediumStyle, wt as resolveNeedleAngle, Ea as resolveSceneRoutes, et as resolveVisualState, He as rollUpGroupCondition, Me as routeToPathData, Ne as segmentAngle, Wi as setLicenseKey, Ca as spliceJumpOvers, Ma as unitFamily, Gt as upstreamOf, d as validateSceneStructure };
|