base-screen 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +12 -5
  2. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-workbench-callbacks.d.ts +2 -0
  3. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-workbench-controller.d.ts +73 -16
  4. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-workbench-panel.d.ts +41 -0
  5. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-panel-controller.d.ts +62 -0
  6. package/dist/_internal/engine/browser/controllers/designer-size-tier-controller.d.ts +60 -0
  7. package/dist/_internal/engine/browser/controllers/panel/designer-material-group-navigation-controller.d.ts +2 -0
  8. package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller.d.ts +2 -0
  9. package/dist/_internal/engine/browser/controllers/panel/designer-panel-inspector-controller.d.ts +6 -0
  10. package/dist/_internal/engine/browser/controllers/panel/designer-panel-material-controller.d.ts +1 -0
  11. package/dist/_internal/engine/browser/controllers/workbench/designer-panel-layout-controller.d.ts +22 -1
  12. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-controller.d.ts +5 -0
  13. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-tabs-controller.d.ts +1 -0
  14. package/dist/_internal/engine/browser/dom/workspace/designer-workspace-markup.d.ts +2 -0
  15. package/dist/_internal/engine/browser/dom/workspace/designer-workspace-skeleton.d.ts +7 -0
  16. package/dist/_internal/engine/browser/dom/workspace/designer-workspace.d.ts +1 -1
  17. package/dist/_internal/engine/common/ui-text/designer-blueprint-ui-text.d.ts +1 -0
  18. package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +5 -1
  19. package/dist/_internal/engine/designer-blueprint-workbench-panel-C2MoZwKA.js +3548 -0
  20. package/dist/_internal/engine/designer-dataset-controller-CPytVNBK.js +4426 -0
  21. package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +7 -0
  22. package/dist/_internal/engine/designer-element/runtime/designer-element-skeleton.d.ts +14 -0
  23. package/dist/_internal/engine/designer-element/runtime/designer-element-state.d.ts +12 -2
  24. package/dist/_internal/engine/designer-left-panel-groups-dom-WMsH33zw.js +573 -0
  25. package/dist/_internal/engine/designer-ui-primitives-CH4RNiMa.js +2155 -0
  26. package/dist/_internal/engine/host-resource-selection-5Cf_gclK.js +2188 -0
  27. package/dist/_internal/engine/index.js +4944 -17147
  28. package/dist/_internal/renderer/index.js +266 -216
  29. package/dist/_internal/renderer/viewer/viewer-skeleton.d.ts +10 -0
  30. package/dist/_internal/renderer/viewer/viewer-variable-controller.d.ts +2 -0
  31. package/dist/_internal/renderer/viewer/viewer.d.ts +8 -0
  32. package/dist/_internal/sdk/auto-register.js +7 -7
  33. package/dist/_internal/sdk/designer-auto-register.js +2 -2
  34. package/dist/_internal/sdk/designer.d.ts +6 -0
  35. package/dist/_internal/sdk/designer.js +11 -1
  36. package/dist/_internal/sdk/index.d.ts +1 -1
  37. package/dist/_internal/sdk/index.js +6 -6
  38. package/dist/authoring-EcyK2YVN.js +103 -0
  39. package/dist/authoring-EcyK2YVN.js.map +1 -0
  40. package/dist/auto-register.js +12 -10
  41. package/dist/auto-register.js.map +1 -1
  42. package/dist/contracts.js +5 -4
  43. package/dist/contracts.js.map +1 -1
  44. package/dist/{contrast-B4TH-dvm.js → contrast-CZFqj1I5.js} +23 -23
  45. package/dist/{contrast-B4TH-dvm.js.map → contrast-CZFqj1I5.js.map} +1 -1
  46. package/dist/core.js +10 -8
  47. package/dist/core.js.map +1 -1
  48. package/dist/designer-Byw45cUM.js +21 -0
  49. package/dist/designer-Byw45cUM.js.map +1 -0
  50. package/dist/designer-auto-register.js +5 -3
  51. package/dist/designer-auto-register.js.map +1 -1
  52. package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js +3517 -0
  53. package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js.map +1 -0
  54. package/dist/designer-dataset-controller-CPytVNBK-DWL3SRTP.js +4354 -0
  55. package/dist/designer-dataset-controller-CPytVNBK-DWL3SRTP.js.map +1 -0
  56. package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js +557 -0
  57. package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js.map +1 -0
  58. package/dist/designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js +2146 -0
  59. package/dist/designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js.map +1 -0
  60. package/dist/designer.js +5 -3
  61. package/dist/{dist-CR13A2Yb.js → dist-BHTClwId.js} +4785 -16808
  62. package/dist/dist-BHTClwId.js.map +1 -0
  63. package/dist/{dist-CAdGDmU3.js → dist-DfAV2jGI.js} +277 -227
  64. package/dist/dist-DfAV2jGI.js.map +1 -0
  65. package/dist/editor-descriptor-schema-Be30Wv8w.js +190 -0
  66. package/dist/editor-descriptor-schema-Be30Wv8w.js.map +1 -0
  67. package/dist/engine.js +4 -2
  68. package/dist/hierarchy-BQZrZWbC.js +86 -0
  69. package/dist/hierarchy-BQZrZWbC.js.map +1 -0
  70. package/dist/host-resource-selection-5Cf_gclK-Sv4Z8UXS.js +2141 -0
  71. package/dist/host-resource-selection-5Cf_gclK-Sv4Z8UXS.js.map +1 -0
  72. package/dist/index.js +11 -9
  73. package/dist/{manager-Bhqi_KmD.js → manager-B2CZ2b5I.js} +2 -2
  74. package/dist/{manager-Bhqi_KmD.js.map → manager-B2CZ2b5I.js.map} +1 -1
  75. package/dist/material-BPlvEmDi.js +12 -0
  76. package/dist/material-BPlvEmDi.js.map +1 -0
  77. package/dist/material-auto-register.d.ts +1 -0
  78. package/dist/material-auto-register.js +16 -0
  79. package/dist/material-auto-register.js.map +1 -0
  80. package/dist/{material-definition-BJ4ujhuj.js → material-definition-B9xCZcD-.js} +2 -2
  81. package/dist/{material-definition-BJ4ujhuj.js.map → material-definition-B9xCZcD-.js.map} +1 -1
  82. package/dist/{material-manifest-LdgIkzgH.js → material-manifest-bsGl6vZZ.js} +70 -256
  83. package/dist/material-manifest-bsGl6vZZ.js.map +1 -0
  84. package/dist/material.js +3 -2
  85. package/dist/parse-B0hwp_yj.js +264 -0
  86. package/dist/parse-B0hwp_yj.js.map +1 -0
  87. package/dist/plugin-core.js +3 -2
  88. package/dist/plugin-manager.js +1 -1
  89. package/dist/{plugin-package-BfZLl3ru.js → plugin-package-BT-pCoTt.js} +3 -3
  90. package/dist/{plugin-package-BfZLl3ru.js.map → plugin-package-BT-pCoTt.js.map} +1 -1
  91. package/dist/{plugin-registration-CYtTqIxF.js → plugin-registration-BjS_CXJU.js} +2 -2
  92. package/dist/{plugin-registration-CYtTqIxF.js.map → plugin-registration-BjS_CXJU.js.map} +1 -1
  93. package/dist/plugin-sdk.js +3 -3
  94. package/dist/{plugins-DRaykV9c.js → plugins-B9bwk-t6.js} +2 -2
  95. package/dist/{plugins-DRaykV9c.js.map → plugins-B9bwk-t6.js.map} +1 -1
  96. package/dist/plugins.js +5 -5
  97. package/dist/renderer.js +1 -1
  98. package/dist/runtime-dispatch-Dt9fhcI5.js +360 -0
  99. package/dist/runtime-dispatch-Dt9fhcI5.js.map +1 -0
  100. package/dist/{src-Bm7u11mN-BPS5TRsq.js → src-Bm7u11mN-BMeb9fvV.js} +40 -39
  101. package/dist/{src-Bm7u11mN-BPS5TRsq.js.map → src-Bm7u11mN-BMeb9fvV.js.map} +1 -1
  102. package/dist/{material-2XmHe-aH.js → text-BVzTcUas.js} +44 -52
  103. package/dist/text-BVzTcUas.js.map +1 -0
  104. package/dist/value-ref-y4_YKUP5.js +278 -0
  105. package/dist/value-ref-y4_YKUP5.js.map +1 -0
  106. package/dist/{viewer-CrJupI8I-D2BtwLsA.js → viewer-CrJupI8I-DZZfdHXr.js} +5 -5
  107. package/dist/{viewer-CrJupI8I-D2BtwLsA.js.map → viewer-CrJupI8I-DZZfdHXr.js.map} +1 -1
  108. package/dist/viewer-auto-register.js +2 -2
  109. package/dist/viewer.js +2 -2
  110. package/package.json +17 -18
  111. package/dist/_internal/react/components.d.ts +0 -32
  112. package/dist/_internal/react/index.d.ts +0 -14
  113. package/dist/_internal/react/index.js +0 -215
  114. package/dist/_internal/vue/components.d.ts +0 -36
  115. package/dist/_internal/vue/global-styles.d.ts +0 -10
  116. package/dist/_internal/vue/index.d.ts +0 -14
  117. package/dist/_internal/vue/index.js +0 -290
  118. package/dist/designer-xtN0h7PL.js +0 -11
  119. package/dist/designer-xtN0h7PL.js.map +0 -1
  120. package/dist/dist-CAdGDmU3.js.map +0 -1
  121. package/dist/dist-CR13A2Yb.js.map +0 -1
  122. package/dist/material-2XmHe-aH.js.map +0 -1
  123. package/dist/material-manifest-LdgIkzgH.js.map +0 -1
  124. package/dist/parse-CYwxTDJU.js +0 -364
  125. package/dist/parse-CYwxTDJU.js.map +0 -1
  126. package/dist/react.d.ts +0 -1
  127. package/dist/react.js +0 -213
  128. package/dist/react.js.map +0 -1
  129. package/dist/value-ref-Z0o70Vy6.js +0 -716
  130. package/dist/value-ref-Z0o70Vy6.js.map +0 -1
  131. package/dist/vue.d.ts +0 -1
  132. package/dist/vue.js +0 -288
  133. package/dist/vue.js.map +0 -1
@@ -0,0 +1,3517 @@
1
+ import { i as e } from "./image-url-D6mUcjY1.js";
2
+ import { B as t, I as n, L as r, n as i, z as a } from "./schema-C38FI_z2.js";
3
+ import { n as o } from "./parse-BQw3u9_4.js";
4
+ import { i as s, r as c } from "./read-data-value-WmMKWshv.js";
5
+ import { d as l, f as u, g as d, i as f, l as p, m, p as h, t as g, u as _ } from "./designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js";
6
+ import { C as v, a as y, b as ee, d as b, f as te, l as ne, m as re, n as ie, o as ae, p as oe, r as se, s as ce, t as x, u as S, v as C, w } from "./designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js";
7
+ import { n as le, r as ue } from "./runtime-dispatch-Dt9fhcI5.js";
8
+ //#region ../engine/dist/designer-blueprint-workbench-panel-C2MoZwKA.js
9
+ var T = "host";
10
+ function E(e) {
11
+ return `component:${e}`;
12
+ }
13
+ function D(e) {
14
+ return `variable:${e}`;
15
+ }
16
+ function de(e, t) {
17
+ if (!t.startsWith("component:")) return;
18
+ let n = t.slice(10);
19
+ return e.components.some((e) => e.id === n) ? n : void 0;
20
+ }
21
+ function fe(e, t) {
22
+ if (!t.startsWith("variable:")) return;
23
+ let n = t.slice(9);
24
+ return e.variables.some((e) => e.id === n) ? n : void 0;
25
+ }
26
+ function pe(e, t, n) {
27
+ return e.relations.some((e) => e.id === t) ? {
28
+ ...e,
29
+ relations: e.relations.map((e) => e.id === t ? n(e) : e)
30
+ } : null;
31
+ }
32
+ function me(e, t) {
33
+ return {
34
+ ...e,
35
+ relations: e.relations.filter((e) => e.id !== t)
36
+ };
37
+ }
38
+ function he(e, t, n) {
39
+ return pe(e, t, (e) => e.type === "behavior" ? {
40
+ ...e,
41
+ condition: n
42
+ } : e);
43
+ }
44
+ function ge(e, t) {
45
+ return pe(e, t, (e) => {
46
+ if (e.type !== "behavior") return e;
47
+ let { condition: t, ...n } = e;
48
+ return n;
49
+ });
50
+ }
51
+ function _e(e, t, n) {
52
+ let r = e.relations.find((e) => e.id === t);
53
+ return r === void 0 || r.type !== "behavior" || r.target.kind !== a(n) ? null : pe(e, t, (e) => ({
54
+ ...e,
55
+ effect: n
56
+ }));
57
+ }
58
+ function ve(e, t, n) {
59
+ let r = e.relations.find((e) => e.id === t);
60
+ if (r === void 0 || r.type !== "behavior") return null;
61
+ if (r.source.kind === "variable") {
62
+ if (n !== "data-updated" && n !== "request-state") return null;
63
+ let r = n;
64
+ return pe(e, t, (e) => e.type !== "behavior" || e.source.kind !== "variable" ? e : {
65
+ ...e,
66
+ source: {
67
+ ...e.source,
68
+ event: {
69
+ type: "variable-event",
70
+ eventName: r
71
+ }
72
+ }
73
+ });
74
+ }
75
+ return pe(e, t, (e) => e.type !== "behavior" || e.source.kind !== "component" ? e : {
76
+ ...e,
77
+ source: {
78
+ ...e.source,
79
+ event: {
80
+ type: "material-event",
81
+ eventName: n
82
+ }
83
+ }
84
+ });
85
+ }
86
+ function ye(e, t, n) {
87
+ return pe(e, t, (e) => e.type === "semantic" ? {
88
+ ...e,
89
+ role: n
90
+ } : e);
91
+ }
92
+ function O(e) {
93
+ return e.startsWith("relation:") ? {
94
+ kind: "relation",
95
+ relationId: e.slice(9)
96
+ } : e.startsWith("semantic:") ? {
97
+ kind: "semantic",
98
+ relationId: e.slice(9)
99
+ } : null;
100
+ }
101
+ function be(e, t) {
102
+ return e.type === "semantic" ? e.source.componentId === t || e.target.componentId === t : e.source.kind === "component" && e.source.componentId === t || e.target.kind === "component" && e.target.componentId === t;
103
+ }
104
+ function xe(e, t) {
105
+ if (e.type === "semantic") return !1;
106
+ if (e.source.kind === "variable" && e.source.variableId === t || e.target.kind === "variable" && e.target.variableId === t || e.condition !== void 0 && (Te(e.condition.left).includes(t) || e.condition.right !== void 0 && Te(e.condition.right).includes(t))) return !0;
107
+ let n = e.effect;
108
+ return n.type === "set-variable" ? Te(n.value).includes(t) : n.type === "emit-host-event" || n.type === "host-action" ? Te(n.payload).includes(t) : !1;
109
+ }
110
+ function Se(e) {
111
+ return e.type === "behavior" && e.target.kind === "host";
112
+ }
113
+ function Ce(e, t, n) {
114
+ let r = e.layout?.nodes ?? [], i = De(n) ? n : Ee(r);
115
+ return {
116
+ ...e,
117
+ layout: {
118
+ nodes: [...r.filter((e) => e.id !== t), {
119
+ id: t,
120
+ x: Oe(i.x),
121
+ y: Oe(i.y)
122
+ }],
123
+ ...e.layout?.viewport === void 0 ? {} : { viewport: e.layout.viewport }
124
+ }
125
+ };
126
+ }
127
+ function k(e, t) {
128
+ if (e.layout === void 0) return e;
129
+ let n = e.layout.nodes.filter((e) => !t.has(e.id));
130
+ return {
131
+ ...e,
132
+ layout: {
133
+ nodes: n,
134
+ ...e.layout.viewport === void 0 ? {} : { viewport: e.layout.viewport }
135
+ }
136
+ };
137
+ }
138
+ function we(e, t) {
139
+ let n = new Set(e.relations.map((e) => e.id)), r = t.toLowerCase().replace(/[^a-z0-9_-]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 56) || "relation", i = 1, a = `${r}-${i}`;
140
+ for (; n.has(a);) a = `${r}-${++i}`;
141
+ return a;
142
+ }
143
+ function Te(e) {
144
+ return e.kind === "variable" ? [e.variableId] : e.kind === "array" ? e.items.flatMap(Te) : e.kind === "object" ? Object.values(e.properties).flatMap(Te) : [];
145
+ }
146
+ function Ee(e) {
147
+ let t = e.length;
148
+ return {
149
+ x: 72 + t % 3 * 264,
150
+ y: 72 + Math.floor(t / 3) * 224
151
+ };
152
+ }
153
+ function De(e) {
154
+ return e !== void 0 && Number.isFinite(e.x) && Number.isFinite(e.y) && Math.abs(e.x) <= 1e6 && Math.abs(e.y) <= 1e6;
155
+ }
156
+ function Oe(e) {
157
+ return Math.round(e * 100) / 100;
158
+ }
159
+ function ke(e, t, n) {
160
+ return e.components.some((e) => e.id === t) ? Ce(e.blueprint, E(t), n) : null;
161
+ }
162
+ function Ae(e, t, n) {
163
+ return e.variables.some((e) => e.id === t) ? Ce(e.blueprint, D(t), n) : null;
164
+ }
165
+ function A(e, t) {
166
+ return Ce(e, T, t);
167
+ }
168
+ function je(e, t) {
169
+ if (t.kind === "edge") {
170
+ let n = O(t.id);
171
+ return n === null ? null : me(e, n.relationId);
172
+ }
173
+ if (t.id === "host") {
174
+ let t = e;
175
+ for (let n of e.relations) Se(n) && (t = me(t, n.id));
176
+ return k(t, /* @__PURE__ */ new Set([T]));
177
+ }
178
+ if (t.id.startsWith("component:")) {
179
+ let n = t.id.slice(10), r = e;
180
+ for (let t of e.relations) be(t, n) && (r = me(r, t.id));
181
+ return k(r, /* @__PURE__ */ new Set([t.id]));
182
+ }
183
+ if (t.id.startsWith("variable:")) {
184
+ let n = t.id.slice(9), r = e;
185
+ for (let t of e.relations) xe(t, n) && (r = me(r, t.id));
186
+ return k(r, /* @__PURE__ */ new Set([t.id]));
187
+ }
188
+ return null;
189
+ }
190
+ function Me(e, t, n) {
191
+ let r = n ?? e.layout?.viewport;
192
+ return {
193
+ ...e,
194
+ layout: {
195
+ nodes: t,
196
+ ...r === void 0 ? {} : { viewport: r }
197
+ }
198
+ };
199
+ }
200
+ function Ne(e, t) {
201
+ return e.layout === void 0 || e.layout.nodes.length === 0 ? e : {
202
+ ...e,
203
+ layout: {
204
+ nodes: e.layout.nodes,
205
+ viewport: t
206
+ }
207
+ };
208
+ }
209
+ function Pe(e, t, n) {
210
+ return he(e, t, n);
211
+ }
212
+ function Fe(e, t) {
213
+ return ge(e, t);
214
+ }
215
+ function j(e, t, n) {
216
+ return _e(e, t, n);
217
+ }
218
+ function Ie(e, t, n) {
219
+ return ve(e, t, n);
220
+ }
221
+ function Le(e, t, n) {
222
+ return ye(e, t, n);
223
+ }
224
+ var Re = 200, ze = 264, Be = 252, M = 196;
225
+ function Ve(e, n, r) {
226
+ let i = S(r, t.materialEvent);
227
+ return e.components.flatMap((e) => {
228
+ let t = n?.get(e.type)?.manifest, a = new Map((t?.editorDescriptor?.events ?? []).map((e) => [e.name, e]));
229
+ return (t?.events ?? []).map((t) => {
230
+ let n = a.get(t), o = n?.requiredCapability, s = n?.triggerContexts === void 0 || n.triggerContexts.includes("blueprint");
231
+ return {
232
+ componentId: e.id,
233
+ componentName: e.name,
234
+ materialType: e.type,
235
+ name: t,
236
+ label: n?.label ?? t,
237
+ available: s && i && (o === void 0 || S(r, o)),
238
+ ...o === void 0 ? {} : { requiredCapability: o }
239
+ };
240
+ });
241
+ });
242
+ }
243
+ function He(e, t, n) {
244
+ let r = new Map(e.blueprint.layout?.nodes.map((e) => [e.id, e])), i = Ve(e, t, n), a = /* @__PURE__ */ new Map();
245
+ for (let e of i) {
246
+ let t = a.get(e.componentId) ?? [];
247
+ t.push(e), a.set(e.componentId, t);
248
+ }
249
+ let o = /* @__PURE__ */ new Map();
250
+ for (let t of e.components) {
251
+ if (t.parentId === null) continue;
252
+ let e = o.get(t.parentId) ?? [];
253
+ e.push(t.id), o.set(t.parentId, e);
254
+ }
255
+ let s = z(e), c = /* @__PURE__ */ new Map();
256
+ return e.components.map((e) => {
257
+ let t = s.get(e.id) ?? 0, n = c.get(t) ?? 0;
258
+ c.set(t, n + 1);
259
+ let i = o.get(e.id) ?? [];
260
+ return B({
261
+ id: E(e.id),
262
+ kind: "component",
263
+ x: 72 + t * ze,
264
+ y: 72 + n * Be,
265
+ componentId: e.id,
266
+ componentName: e.name,
267
+ materialType: e.type,
268
+ hidden: e.status.hidden,
269
+ ...e.parentId === null ? {} : { parentId: e.parentId },
270
+ ...i.length === 0 ? {} : {
271
+ childCount: i.length,
272
+ isContainer: !0
273
+ },
274
+ events: a.get(e.id) ?? []
275
+ }, r);
276
+ });
277
+ }
278
+ function N(e) {
279
+ let t = new Map(e.blueprint.layout?.nodes.map((e) => [e.id, e])), n = Math.max(0, ...z(e).values());
280
+ return _(e).map((e, r) => B({
281
+ id: D(e.id),
282
+ kind: "variable",
283
+ x: 72 + (n + 1) * ze,
284
+ y: 72 + r * M,
285
+ variableId: e.id,
286
+ variableName: e.name,
287
+ variableType: e.type,
288
+ ...e.description === void 0 ? {} : { variableDescription: e.description },
289
+ variableInitialValue: e.initialValue,
290
+ events: [{
291
+ name: "data-updated",
292
+ label: "data-updated",
293
+ available: !0
294
+ }, {
295
+ name: "request-state",
296
+ label: "request-state",
297
+ available: !0
298
+ }]
299
+ }, t));
300
+ }
301
+ function P(e, t, n) {
302
+ let r = new Map(e.blueprint.layout?.nodes.map((e) => [e.id, e])), i = He(e, t, n), a = N(e), o = I(e), s = /* @__PURE__ */ new Set();
303
+ for (let t of e.blueprint.relations) if (t.type === "behavior") {
304
+ t.source.kind === "variable" && s.add(t.source.variableId), t.target.kind === "variable" && s.add(t.target.variableId);
305
+ for (let e of R(t)) s.add(e);
306
+ }
307
+ let c = new Set(r.keys()), l = Ke(e, i, o, s, c), u = i.filter((e) => e.componentId !== void 0 && l.has(e.componentId)), d = new Set(u.map((e) => e.id)), f = new Set(s);
308
+ for (let e of l) for (let t of o.get(e) ?? []) f.add(t);
309
+ let p = a.filter((e) => {
310
+ let t = e.variableId;
311
+ return t === void 0 ? !1 : f.has(t) || c.has(e.id);
312
+ });
313
+ for (let e of p) d.add(e.id);
314
+ let m = e.blueprint.relations.some((e) => e.type === "behavior" && e.target.kind === "host"), h = c.has(T), g = m || h ? B({
315
+ id: T,
316
+ kind: "host",
317
+ x: 72 + (Math.max(0, ...z(e).values()) + 2) * ze,
318
+ y: 72
319
+ }, r) : void 0;
320
+ g !== void 0 && d.add(g.id);
321
+ let _ = [
322
+ ...u,
323
+ ...p,
324
+ ...g === void 0 ? [] : [g]
325
+ ], v = [];
326
+ for (let t of e.blueprint.relations) Ue(v, d, t);
327
+ for (let t of e.components) {
328
+ if (!l.has(t.id) || t.parentId === null) continue;
329
+ let e = E(t.parentId), n = E(t.id);
330
+ !d.has(e) || !d.has(n) || v.push({
331
+ id: `containment:${t.parentId}:${t.id}`,
332
+ source: e,
333
+ target: n,
334
+ sourceHandle: "containment:out",
335
+ targetHandle: "containment:in",
336
+ kind: "containment",
337
+ locked: !0,
338
+ deletable: !1
339
+ });
340
+ }
341
+ for (let [e, t] of o) {
342
+ if (!l.has(e)) continue;
343
+ let n = E(e);
344
+ for (let r of t) {
345
+ let t = D(r);
346
+ !d.has(t) || !d.has(n) || v.push({
347
+ id: `dependency:read:${r}:${e}`,
348
+ source: t,
349
+ target: n,
350
+ sourceHandle: "dependency:out",
351
+ targetHandle: "dependency:in",
352
+ kind: "dependency",
353
+ locked: !0,
354
+ deletable: !1
355
+ });
356
+ }
357
+ }
358
+ for (let t of e.blueprint.relations) {
359
+ if (t.type !== "behavior" || t.condition === void 0) continue;
360
+ let e = Ge(t);
361
+ if (d.has(e)) for (let n of R(t)) {
362
+ let r = D(n);
363
+ d.has(r) && v.push({
364
+ id: `dependency:condition:${t.id}:${n}`,
365
+ source: r,
366
+ target: e,
367
+ sourceHandle: "dependency:out",
368
+ targetHandle: "dependency:in",
369
+ kind: "dependency",
370
+ locked: !0,
371
+ deletable: !1,
372
+ relationId: t.id
373
+ });
374
+ }
375
+ }
376
+ let y = F(_, v);
377
+ return {
378
+ nodes: _.map((e) => {
379
+ let t = y.get(e.id);
380
+ return t === void 0 ? e : {
381
+ ...e,
382
+ inboundCount: t.inbound,
383
+ outboundCount: t.outbound,
384
+ relationCount: t.inbound + t.outbound,
385
+ ...e.kind === "variable" ? {
386
+ readCount: t.read,
387
+ writeCount: t.write
388
+ } : e.kind === "host" ? { exitCount: t.exit } : {}
389
+ };
390
+ }),
391
+ edges: v,
392
+ ...e.blueprint.layout?.viewport === void 0 ? {} : { viewport: e.blueprint.layout.viewport }
393
+ };
394
+ }
395
+ function Ue(e, t, n) {
396
+ let r = We(n), i = Ge(n);
397
+ if (!t.has(r) || !t.has(i)) return;
398
+ if (n.type === "semantic") {
399
+ e.push({
400
+ id: `semantic:${n.id}`,
401
+ source: r,
402
+ target: i,
403
+ sourceHandle: "semantic:out",
404
+ targetHandle: "relation:in",
405
+ kind: "semantic",
406
+ relationId: n.id,
407
+ relationKind: "semantic",
408
+ semanticRole: n.role,
409
+ deletable: !0
410
+ });
411
+ return;
412
+ }
413
+ let a = n.effect;
414
+ e.push({
415
+ id: `relation:${n.id}`,
416
+ source: r,
417
+ target: i,
418
+ sourceHandle: `event:${n.source.event.eventName}`,
419
+ targetHandle: "relation:in",
420
+ kind: "relation",
421
+ relationId: n.id,
422
+ relationKind: "behavior",
423
+ effectType: a.type,
424
+ eventName: n.source.event.eventName,
425
+ ...a.type === "component-visibility" ? { operation: a.operation } : {},
426
+ ...a.type === "host-action" ? { actionId: a.actionId } : {},
427
+ ...n.target.kind === "variable" ? { variableId: n.target.variableId } : {},
428
+ deletable: !0
429
+ });
430
+ }
431
+ function We(e) {
432
+ return e.type === "semantic" || e.source.kind === "component" ? E(e.source.componentId) : D(e.source.variableId);
433
+ }
434
+ function Ge(e) {
435
+ if (e.type === "semantic") return E(e.target.componentId);
436
+ let t = e.target;
437
+ return t.kind === "component" ? E(t.componentId) : t.kind === "variable" ? D(t.variableId) : T;
438
+ }
439
+ function F(e, t) {
440
+ let n = /* @__PURE__ */ new Map();
441
+ for (let t of e) n.set(t.id, {
442
+ inbound: 0,
443
+ outbound: 0,
444
+ read: 0,
445
+ write: 0,
446
+ exit: 0
447
+ });
448
+ for (let e of t) {
449
+ let t = n.get(e.source), r = n.get(e.target);
450
+ if (t !== void 0) {
451
+ let r = {
452
+ ...t,
453
+ outbound: t.outbound + 1
454
+ };
455
+ n.set(e.source, {
456
+ ...r,
457
+ ...e.kind === "dependency" ? { read: r.read + 1 } : {}
458
+ });
459
+ }
460
+ if (r !== void 0) {
461
+ let t = {
462
+ ...r,
463
+ inbound: r.inbound + 1
464
+ }, i = e.kind === "relation" && (e.effectType === "set-variable" || e.effectType === "request-variable"), a = e.kind === "relation" && (e.effectType === "emit-host-event" || e.effectType === "host-action");
465
+ n.set(e.target, {
466
+ ...t,
467
+ ...i ? { write: t.write + 1 } : {},
468
+ ...a ? { exit: t.exit + 1 } : {}
469
+ });
470
+ }
471
+ }
472
+ return n;
473
+ }
474
+ function Ke(e, t, n, r, i) {
475
+ if (e.components.length <= Re) return new Set(e.components.map((e) => e.id));
476
+ let a = /* @__PURE__ */ new Set(), o = new Map(e.components.map((e) => [e.id, e]));
477
+ for (let t of e.blueprint.relations) t.type === "semantic" ? (a.add(t.source.componentId), a.add(t.target.componentId)) : (t.source.kind === "component" && a.add(t.source.componentId), t.target.kind === "component" && a.add(t.target.componentId));
478
+ for (let e of t) e.componentId !== void 0 && i.has(e.id) && a.add(e.componentId);
479
+ for (let [e, t] of n) t.some((e) => r.has(e)) && a.add(e);
480
+ let s = (t) => {
481
+ let n = o.get(t);
482
+ if (!(n === void 0 || a.has(n.id))) {
483
+ a.add(n.id), n.parentId !== null && s(n.parentId);
484
+ for (let t of e.components) t.parentId === n.id && s(t.id);
485
+ }
486
+ };
487
+ for (let e of [...a]) s(e);
488
+ return a;
489
+ }
490
+ function I(e) {
491
+ let t = new Map(s(e).map((e) => [e.id, e])), n = /* @__PURE__ */ new Map();
492
+ for (let r of e.components) {
493
+ let e = /* @__PURE__ */ new Set(), i = c(r);
494
+ i !== null && L(i, t, e), n.set(r.id, [...e]);
495
+ }
496
+ return n;
497
+ }
498
+ function L(e, t, n) {
499
+ if (e.kind === "variable") {
500
+ n.add(e.variableId);
501
+ return;
502
+ }
503
+ if (e.kind !== "data-source-field") return;
504
+ let r = t.get(e.dataSourceId);
505
+ if (r !== void 0) for (let e of Object.values(r.params)) e.kind === "variable" && n.add(e.variableId);
506
+ }
507
+ function R(e) {
508
+ if (e.condition === void 0) return [];
509
+ let t = /* @__PURE__ */ new Set();
510
+ return qe(e.condition.left, t), e.condition.right !== void 0 && qe(e.condition.right, t), [...t];
511
+ }
512
+ function qe(e, t) {
513
+ if (e.kind === "variable") t.add(e.variableId);
514
+ else if (e.kind === "array") for (let n of e.items) qe(n, t);
515
+ else if (e.kind === "object") for (let n of Object.values(e.properties)) qe(n, t);
516
+ }
517
+ function z(e) {
518
+ let t = new Map(e.components.map((e) => [e.id, e])), n = /* @__PURE__ */ new Map();
519
+ for (let r of e.components) {
520
+ let e = 0, i = r.parentId, a = /* @__PURE__ */ new Set([r.id]);
521
+ for (; i !== null && !a.has(i);) a.add(i), e += 1, i = t.get(i)?.parentId ?? null;
522
+ n.set(r.id, e);
523
+ }
524
+ return n;
525
+ }
526
+ function B(e, t) {
527
+ let n = t.get(e.id);
528
+ return n === void 0 ? e : {
529
+ ...e,
530
+ x: n.x,
531
+ y: n.y,
532
+ ...n.collapsed === !0 ? { collapsed: !0 } : {}
533
+ };
534
+ }
535
+ var Je = 208, Ye = 28, Xe = 40, Ze = 32, Qe = 8, $e = 96, V = 72, et = 256, tt = 8, nt = 150, rt = 48, it = .1, at = 2, ot = [
536
+ .1,
537
+ .2,
538
+ .3,
539
+ .4,
540
+ .5,
541
+ .6,
542
+ .7,
543
+ .84,
544
+ 1,
545
+ 1.25,
546
+ 1.5,
547
+ 2
548
+ ], st = "http://www.w3.org/2000/svg", ct = .62, lt = 2, H = d.blueprint.canvasSurface, U = d.blueprint;
549
+ function ut(e) {
550
+ let t = e.defaultView, n = e.createElement("div");
551
+ n.className = "designer-blueprint-canvas", n.dataset.designerBlueprintCanvas = "true";
552
+ let r = e.createElement("div");
553
+ r.className = "designer-blueprint-canvas-bar", r.setAttribute("role", "toolbar"), r.setAttribute("aria-label", H.toolbar);
554
+ let i = e.createElement("span");
555
+ i.className = "designer-blueprint-canvas-menu-anchor";
556
+ let a = wt(e, "plus", H.addNode, "add-node");
557
+ a.setAttribute("aria-haspopup", "menu"), a.setAttribute("aria-expanded", "false");
558
+ let o = e.createElement("span");
559
+ o.className = "designer-blueprint-canvas-bar-chevron", o.setAttribute("aria-hidden", "true"), o.innerHTML = u("arrow-down"), a.append(o);
560
+ let s = e.createElement("div");
561
+ s.className = "designer-blueprint-canvas-menu", s.dataset.canvasMenu = "add-node", s.setAttribute("role", "menu"), s.setAttribute("aria-label", H.addNodeMenu), s.hidden = !0;
562
+ for (let [t, n] of [["host", U.relationList.addHost]]) {
563
+ let r = p(e, {
564
+ className: "designer-blueprint-canvas-menu-item",
565
+ text: n,
566
+ variant: "canvas-tool"
567
+ });
568
+ r.dataset.canvasInsert = t, r.setAttribute("role", "menuitem"), s.append(r);
569
+ }
570
+ i.append(a, s);
571
+ let c = wt(e, "grid", U.autoLayout, "auto-layout"), d = p(e, {
572
+ className: "designer-blueprint-canvas-problems-button",
573
+ variant: "canvas-tool"
574
+ });
575
+ d.dataset.canvasAction = "problems", d.dataset.state = "ok", d.setAttribute("aria-haspopup", "dialog"), d.setAttribute("aria-expanded", "false");
576
+ let h = e.createElement("span");
577
+ h.className = "designer-blueprint-canvas-problems-dot", h.setAttribute("aria-hidden", "true");
578
+ let _ = e.createElement("span");
579
+ _.className = "designer-blueprint-canvas-bar-label", _.dataset.canvasProblemsLabel = "true", d.append(h, _);
580
+ let v = wt(e, "activity", H.traceToggle, "trace");
581
+ v.setAttribute("aria-pressed", "true");
582
+ let y = e.createElement("span");
583
+ y.className = "designer-blueprint-canvas-bar-spacer";
584
+ let b = e.createElement("span");
585
+ b.className = "designer-blueprint-canvas-bar-separator", b.setAttribute("aria-hidden", "true");
586
+ let te = e.createElement("span");
587
+ te.className = "designer-blueprint-canvas-bar-separator", te.setAttribute("aria-hidden", "true");
588
+ let ne = Tt(e, "minus", H.zoomOut, "zoom-out"), re = e.createElement("span");
589
+ re.className = "designer-blueprint-canvas-zoom", re.dataset.canvasZoom = "true", re.setAttribute("role", "status");
590
+ let oe = Tt(e, "plus", H.zoomIn, "zoom-in"), se = Tt(e, "fit", U.fit, "fit"), ce = wt(e, "play", H.simulatePanel, "simulate");
591
+ ce.setAttribute("aria-expanded", "false"), r.append(i, c, d, v, y, b, ne, re, oe, se, te, ce);
592
+ let x = e.createElement("div");
593
+ x.className = "designer-blueprint-canvas-problems", x.dataset.canvasProblems = "true", x.setAttribute("role", "dialog"), x.setAttribute("aria-label", U.problemsTitle), x.hidden = !0;
594
+ let S = e.createElement("div");
595
+ S.className = "designer-blueprint-canvas-viewport", S.dataset.canvasViewport = "true", S.tabIndex = 0;
596
+ let C = e.createElement("div");
597
+ C.className = "designer-blueprint-canvas-layers", C.style.setProperty("zoom", String(lt));
598
+ let w = e.createElementNS(st, "svg");
599
+ w.classList.add("designer-blueprint-canvas-edges");
600
+ let le = e.createElement("div");
601
+ le.className = "designer-blueprint-canvas-edge-labels", C.append(w, le);
602
+ let ue = e.createElementNS(st, "svg");
603
+ ue.classList.add("designer-blueprint-canvas-overlay");
604
+ let T = e.createElementNS(st, "path");
605
+ T.classList.add("designer-blueprint-canvas-link-preview"), T.setAttribute("visibility", "hidden"), ue.append(T);
606
+ let E = e.createElement("div");
607
+ E.className = "designer-blueprint-canvas-marquee", E.hidden = !0;
608
+ let D = e.createElement("section");
609
+ D.className = "designer-blueprint-canvas-empty", D.dataset.canvasEmpty = "true", D.hidden = !0;
610
+ let de = e.createElement("h3");
611
+ de.textContent = H.emptyTitle;
612
+ let fe = e.createElement("p");
613
+ fe.textContent = H.emptyDescription;
614
+ let pe = e.createElement("ol");
615
+ for (let t of [
616
+ H.emptyStepTrigger,
617
+ H.emptyStepConnect,
618
+ H.emptyStepExit
619
+ ]) {
620
+ let n = e.createElement("li");
621
+ n.textContent = t, pe.append(n);
622
+ }
623
+ let me = e.createElement("div");
624
+ me.className = "designer-blueprint-canvas-empty-actions";
625
+ let he = p(e, {
626
+ className: "designer-blueprint-canvas-empty-primary",
627
+ text: U.relationList.addHost,
628
+ variant: "primary"
629
+ });
630
+ he.dataset.canvasInsert = "host";
631
+ let ge = e.createElement("span");
632
+ ge.className = "designer-blueprint-canvas-empty-hint", ge.textContent = H.emptyLibraryHint, me.append(he, ge), D.append(de, fe, pe, me);
633
+ let _e = e.createElement("div");
634
+ _e.className = "designer-blueprint-canvas-no-events", _e.dataset.canvasNoEvents = "true", _e.hidden = !0, _e.setAttribute("role", "status");
635
+ let ve = e.createElement("strong");
636
+ ve.textContent = H.noEventsTitle;
637
+ let ye = e.createElement("span");
638
+ ye.textContent = H.noEventsBody, _e.append(ve, ye);
639
+ let O = e.createElement("div");
640
+ O.className = "designer-blueprint-canvas-status", O.dataset.canvasStatus = "true", O.setAttribute("role", "status"), O.setAttribute("aria-live", "polite"), O.hidden = !0;
641
+ let be = e.createElement("div");
642
+ be.className = "designer-blueprint-canvas-simulation-bar", be.dataset.canvasSimulationBar = "true";
643
+ let xe = e.createElement("span");
644
+ xe.className = "designer-blueprint-canvas-simulation-bar-icon", xe.setAttribute("aria-hidden", "true"), xe.innerHTML = u("play");
645
+ let Se = e.createElement("span");
646
+ Se.className = "designer-blueprint-canvas-simulation-bar-label";
647
+ let Ce = wt(e, "arrow-up", H.expandSimulation, "simulation-expand");
648
+ Ce.dataset.density = "tight", be.append(xe, Se, Ce);
649
+ let k = e.createElement("section");
650
+ k.className = "designer-blueprint-canvas-simulation", k.dataset.canvasSimulation = "true", k.hidden = !0, k.setAttribute("aria-label", U.simulate);
651
+ let we = e.createElement("header");
652
+ we.className = "designer-blueprint-canvas-simulation-header";
653
+ let Te = e.createElement("strong");
654
+ Te.textContent = H.simulationTitle;
655
+ let Ee = Et(e, "close", H.collapseSimulation, "simulation-close");
656
+ we.append(Te, Ee);
657
+ let De = e.createElement("div");
658
+ De.className = "designer-blueprint-canvas-simulation-content";
659
+ let Oe = e.createElement("div");
660
+ Oe.className = "designer-blueprint-canvas-simulation-controls";
661
+ let ke = e.createElement("div");
662
+ ke.className = "designer-blueprint-canvas-simulation-field";
663
+ let Ae = e.createElement("span");
664
+ Ae.textContent = H.simulationEventLabel;
665
+ let A = g(e, {
666
+ ariaLabel: H.simulationEventLabel,
667
+ className: "designer-blueprint-canvas-simulation-select"
668
+ });
669
+ A.dataset.canvasSimulationEvent = "true";
670
+ let je = l(A);
671
+ je.trigger.dataset.density = "compact", ke.append(Ae, je.element);
672
+ let Me = e.createElement("label");
673
+ Me.className = "designer-blueprint-canvas-simulation-field";
674
+ let Ne = e.createElement("span");
675
+ Ne.textContent = H.simulationPayloadLabel;
676
+ let Pe = m(e, {
677
+ ariaLabel: H.simulationPayloadAria,
678
+ className: "designer-blueprint-canvas-simulation-payload",
679
+ value: "{}"
680
+ });
681
+ Pe.dataset.canvasSimulationPayload = "true", Pe.spellcheck = !1, Me.append(Ne, Pe);
682
+ let Fe = e.createElement("div");
683
+ Fe.className = "designer-blueprint-canvas-simulation-footer";
684
+ let j = e.createElement("span");
685
+ j.className = "designer-blueprint-canvas-simulation-status", j.dataset.canvasSimulationStatus = "true", j.setAttribute("role", "status");
686
+ let Ie = p(e, {
687
+ className: "designer-blueprint-canvas-simulation-run",
688
+ text: H.simulationRun,
689
+ variant: "primary"
690
+ });
691
+ Ie.dataset.canvasAction = "simulation-run", Fe.append(j, Ie), Oe.append(ke, Me, Fe);
692
+ let Le = e.createElement("div");
693
+ Le.className = "designer-blueprint-canvas-simulation-trace";
694
+ let Re = e.createElement("h4");
695
+ Re.textContent = H.simulationTraceTitle;
696
+ let ze = e.createElement("ol");
697
+ ze.dataset.canvasTrace = "true";
698
+ let Be = e.createElement("p");
699
+ Be.className = "designer-blueprint-canvas-simulation-trace-empty", Be.textContent = H.simulationNoTrace, Le.append(Re, ze, Be), De.append(Oe, Le), k.append(we, De), S.append(C, ue, E, D, _e, x, be, k, O), n.append(r, S);
700
+ let M = null, Ve = -1, He = !1, N = /* @__PURE__ */ new Map(), P = {
701
+ x: 0,
702
+ y: 0,
703
+ zoom: 1
704
+ }, Ue = "", We = "", Ge = !1, F, Ke, I = null, L = null, R = null, qe = !1, z = null, B = null, ut = 0, ft, pt = !1, mt = !1, ht = /* @__PURE__ */ new Map(), gt = !1, _t = !1, vt = !1, yt = !0, W = !1, bt = !1, G = !1, xt = "", St = !1, Ct = typeof t?.ResizeObserver == "function" ? new t.ResizeObserver(() => {
705
+ gt && Gn();
706
+ }) : void 0;
707
+ Ct?.observe(S);
708
+ function wt(e, t, n, r) {
709
+ let i = p(e, {
710
+ ariaLabel: n,
711
+ className: "designer-blueprint-canvas-bar-button",
712
+ tip: n,
713
+ variant: "canvas-tool"
714
+ });
715
+ i.dataset.canvasAction = r, i.insertAdjacentHTML("afterbegin", u(t));
716
+ let a = e.createElement("span");
717
+ return a.className = "designer-blueprint-canvas-bar-label", a.textContent = n, i.append(a), i;
718
+ }
719
+ function Tt(e, t, n, r) {
720
+ let i = f(e, {
721
+ className: "designer-blueprint-canvas-bar-button",
722
+ icon: t,
723
+ label: n,
724
+ variant: "canvas-tool"
725
+ });
726
+ return i.dataset.canvasAction = r, i;
727
+ }
728
+ function Et(e, t, n, r) {
729
+ let i = f(e, {
730
+ className: "designer-blueprint-canvas-panel-icon",
731
+ icon: t,
732
+ label: n
733
+ });
734
+ return i.dataset.canvasAction = r, i;
735
+ }
736
+ function K() {
737
+ return M?.graph ?? null;
738
+ }
739
+ function q(e) {
740
+ let t = tn(e) === "" ? 0 : Ze;
741
+ if (e.kind === "component" || e.kind === "variable") {
742
+ let n = 65 + (e.kind === "variable" ? Xe : 0), r = e.events ?? [], i = Math.max(1, r.length), a = r.map((e, t) => ({
743
+ handle: `event:${e.name}`,
744
+ label: e.label === "" ? e.name : e.label,
745
+ y: n + t * Ye + Ye / 2,
746
+ available: e.available,
747
+ ...e.requiredCapability === void 0 ? {} : { requiredCapability: e.requiredCapability }
748
+ })), o = i;
749
+ e.kind === "component" && (a.push({
750
+ handle: "semantic:out",
751
+ label: U.relationCategories.semantic,
752
+ y: n + o * Ye + Ye / 2,
753
+ available: !0,
754
+ semantic: !0
755
+ }), o += 1, e.isContainer === !0 && (a.push({
756
+ handle: "containment:out",
757
+ label: U.relationList.containment,
758
+ y: n + o * Ye + Ye / 2,
759
+ available: !0,
760
+ containment: !0
761
+ }), o += 1));
762
+ let s = n + o * Ye + (t === 0 ? Qe : t);
763
+ return {
764
+ width: Je,
765
+ height: s,
766
+ portStart: n,
767
+ inputY: s / 2,
768
+ inputHandle: "relation:in",
769
+ outputs: a,
770
+ dependency: e.kind === "variable"
771
+ };
772
+ }
773
+ let n = $e;
774
+ return {
775
+ width: Je,
776
+ height: n,
777
+ portStart: 65,
778
+ inputY: n / 2,
779
+ inputHandle: "relation:in",
780
+ outputs: [],
781
+ dependency: !1
782
+ };
783
+ }
784
+ function J(e) {
785
+ return N.get(e.id) ?? {
786
+ x: e.x,
787
+ y: e.y
788
+ };
789
+ }
790
+ function Dt(e) {
791
+ return Math.round(e / tt) * tt;
792
+ }
793
+ function Ot(e, t) {
794
+ let n = q(e);
795
+ return n.outputs.find((e) => e.handle === t)?.y ?? n.height / 2;
796
+ }
797
+ function kt(e) {
798
+ return q(e).inputY;
799
+ }
800
+ function At(e) {
801
+ return K()?.nodes.find((t) => t.id === e);
802
+ }
803
+ function jt(e) {
804
+ if (M === null) return;
805
+ ut += 1;
806
+ let t = {
807
+ ...e,
808
+ commandId: `designer-blueprint-${Date.now()}-${ut}`,
809
+ generation: M.generation,
810
+ documentRevision: M.documentRevision
811
+ };
812
+ return n.dispatchEvent(new CustomEvent(ee, {
813
+ bubbles: !0,
814
+ composed: !0,
815
+ detail: { command: t }
816
+ })), t;
817
+ }
818
+ function Y(e, t = "info") {
819
+ O.textContent = e, O.dataset.tone = t, O.hidden = !1, Ke !== void 0 && clearTimeout(Ke), Ke = setTimeout(() => {
820
+ O.hidden = !0, Ke = void 0;
821
+ }, 3200);
822
+ }
823
+ function Mt(e) {
824
+ return `${e.x.toFixed(1)}:${e.y.toFixed(1)}:${e.zoom.toFixed(3)}`;
825
+ }
826
+ function X() {
827
+ let e = P.zoom / lt;
828
+ C.style.transform = `translate(${P.x / lt}px, ${P.y / lt}px) scale(${e})`, S.dataset.zoomFar = String(P.zoom < ct);
829
+ let t = Math.round(P.zoom * 100);
830
+ re.textContent = H.zoomValue(t), re.setAttribute("aria-label", H.zoomAria(t));
831
+ }
832
+ function Nt() {
833
+ Ge = !0, F !== void 0 && clearTimeout(F), F = setTimeout(() => {
834
+ F = void 0, Pt();
835
+ }, 280);
836
+ }
837
+ function Pt() {
838
+ if (F !== void 0 && clearTimeout(F), F = void 0, Ge = !1, pt) return;
839
+ let e = {
840
+ x: Math.round(P.x),
841
+ y: Math.round(P.y),
842
+ zoom: Math.round(P.zoom * 1e3) / 1e3
843
+ };
844
+ Ue = Mt(e), jt({
845
+ type: "commit-viewport",
846
+ viewport: e
847
+ });
848
+ }
849
+ function Ft(e) {
850
+ if (e === void 0) return;
851
+ let t = Mt(e);
852
+ if (t !== We && !(Ge || I !== null || L !== null || z !== null)) {
853
+ if (t !== Mt(P) && t !== Ue) {
854
+ P = {
855
+ x: e.x,
856
+ y: e.y,
857
+ zoom: e.zoom
858
+ }, We = t, X();
859
+ return;
860
+ }
861
+ We = t;
862
+ }
863
+ }
864
+ function It(e, t) {
865
+ let n = S.getBoundingClientRect();
866
+ return {
867
+ x: (e - n.left - P.x) / P.zoom,
868
+ y: (t - n.top - P.y) / P.zoom
869
+ };
870
+ }
871
+ function Lt(e) {
872
+ let t = At(e.source), n = At(e.target);
873
+ if (t === void 0 || n === void 0) return null;
874
+ let r = q(t), i = J(t), a = J(n), o = i.x + r.width, s = i.y + Ot(t, e.sourceHandle), c = a.x, l = a.y + kt(n), u = Math.max(i.y + r.height, a.y + q(n).height), d = Rt(e.id, o, s, c, l, u);
875
+ return {
876
+ path: zt(d, 12),
877
+ start: d[0],
878
+ end: d[d.length - 1],
879
+ beforeEnd: d[d.length - 2],
880
+ label: Ut(d, e.id)
881
+ };
882
+ }
883
+ function Rt(e, t, n, r, i, a) {
884
+ let o = r - t, s = Ht(e);
885
+ if (o >= 48) {
886
+ let e = s % 4 * 6, a = Math.min(r - 16, t + Math.min(120, Math.max(28, o * .42)) + e);
887
+ return [
888
+ {
889
+ x: t,
890
+ y: n
891
+ },
892
+ {
893
+ x: a,
894
+ y: n
895
+ },
896
+ {
897
+ x: a,
898
+ y: i
899
+ },
900
+ {
901
+ x: r,
902
+ y: i
903
+ }
904
+ ];
905
+ }
906
+ let c = a + 28 + s % 4 * 14;
907
+ return [
908
+ {
909
+ x: t,
910
+ y: n
911
+ },
912
+ {
913
+ x: t + 24,
914
+ y: n
915
+ },
916
+ {
917
+ x: t + 24,
918
+ y: c
919
+ },
920
+ {
921
+ x: r - 24,
922
+ y: c
923
+ },
924
+ {
925
+ x: r - 24,
926
+ y: i
927
+ },
928
+ {
929
+ x: r,
930
+ y: i
931
+ }
932
+ ];
933
+ }
934
+ function zt(e, t) {
935
+ let n = e[0], r = `M ${n.x} ${n.y}`;
936
+ for (let n = 1; n < e.length - 1; n += 1) {
937
+ let i = e[n - 1], a = e[n], o = e[n + 1], s = Vt(i, a), c = Vt(a, o), l = Math.min(t, s / 2, c / 2), u = l === 0 ? a : {
938
+ x: a.x - (a.x - i.x) / s * l,
939
+ y: a.y - (a.y - i.y) / s * l
940
+ }, d = l === 0 ? a : {
941
+ x: a.x + (o.x - a.x) / c * l,
942
+ y: a.y + (o.y - a.y) / c * l
943
+ };
944
+ r += ` L ${u.x} ${u.y} Q ${a.x} ${a.y} ${d.x} ${d.y}`;
945
+ }
946
+ let i = e[e.length - 1];
947
+ return `${r} L ${i.x} ${i.y}`;
948
+ }
949
+ function Bt(e, t) {
950
+ let n = Math.atan2(e.y - t.y, e.x - t.x), r = 3.4, i = {
951
+ x: e.x - 7 * Math.cos(n) + r * Math.sin(n),
952
+ y: e.y - 7 * Math.sin(n) - r * Math.cos(n)
953
+ }, a = {
954
+ x: e.x - 7 * Math.cos(n) - r * Math.sin(n),
955
+ y: e.y - 7 * Math.sin(n) + r * Math.cos(n)
956
+ };
957
+ return `M ${e.x} ${e.y} L ${i.x} ${i.y} L ${a.x} ${a.y} Z`;
958
+ }
959
+ function Vt(e, t) {
960
+ return Math.hypot(t.x - e.x, t.y - e.y);
961
+ }
962
+ function Ht(e) {
963
+ let t = 0;
964
+ for (let n = 0; n < e.length; n += 1) t = t * 31 + e.charCodeAt(n) >>> 0;
965
+ return t;
966
+ }
967
+ function Ut(e, t) {
968
+ let n = Ht(t);
969
+ if (e.length < 3) {
970
+ let t = e[0], r = e[e.length - 1];
971
+ return {
972
+ x: (t.x + r.x) / 2,
973
+ y: (t.y + r.y) / 2 - 12 - n % 4 * 3
974
+ };
975
+ }
976
+ if (e.length === 4) {
977
+ let t = e[0], r = e[1], i = e[2], a = e[3];
978
+ return Math.abs(r.x - t.x) >= Math.abs(a.x - i.x) ? {
979
+ x: (t.x + r.x) / 2,
980
+ y: t.y - 11 - n % 4 * 3
981
+ } : {
982
+ x: (i.x + a.x) / 2,
983
+ y: a.y - 11 - n % 4 * 3
984
+ };
985
+ }
986
+ let r = e[0], i = e[2], a = e[e.length - 1];
987
+ return {
988
+ x: (r.x + a.x) / 2,
989
+ y: i.y + 12 + n % 3 * 3
990
+ };
991
+ }
992
+ function Wt(e) {
993
+ return e.kind === "dependency" ? "eye" : e.kind === "semantic" ? "link" : e.kind === "containment" ? "group" : "activity";
994
+ }
995
+ function Z(e) {
996
+ if (e.kind === "dependency") {
997
+ let t = At(e.source);
998
+ return H.edgeDependency(t?.variableName ?? t?.variableId ?? "");
999
+ }
1000
+ return e.kind === "containment" ? U.relationList.containment : e.kind === "semantic" ? U.semanticRoles[e.semanticRole ?? "related"] : e.kind === "relation" ? e.effectType === "component-visibility" ? `${e.eventName ?? ""} · ${U.visibilityOperation[e.operation ?? "toggle"]}` : e.effectType === "set-variable" ? U.setVariableAction(e.variableId ?? "") : e.effectType === "request-variable" ? `${U.relationEffects["request-variable"]} ${e.variableId ?? ""}` : e.effectType === "request-component-data" ? `${e.eventName ?? ""} · ${U.relationEffects["request-component-data"]}` : e.effectType === "emit-host-event" ? `${U.relationEffects["emit-host-event"]} ${e.eventName ?? ""}` : e.effectType === "host-action" ? `${U.relationEffects["host-action"]} ${e.actionId ?? ""}` : e.eventName ?? "" : e.operation === void 0 ? e.sourceHandle.startsWith("event:") ? e.sourceHandle.slice(6) : "true" : U.visibilityOperation[e.operation];
1001
+ }
1002
+ function Q(e) {
1003
+ let t = 28;
1004
+ for (let n of e) t += /[\x00-\x7f]/.test(n) ? 6 : 10;
1005
+ return Math.min(168, t);
1006
+ }
1007
+ function Gt(e, t, n) {
1008
+ let r = Q(t) / 2;
1009
+ return [
1010
+ e,
1011
+ {
1012
+ x: e.x,
1013
+ y: e.y - 24
1014
+ },
1015
+ {
1016
+ x: e.x,
1017
+ y: e.y - 46
1018
+ },
1019
+ {
1020
+ x: e.x,
1021
+ y: e.y + 24
1022
+ },
1023
+ {
1024
+ x: e.x,
1025
+ y: e.y + 46
1026
+ },
1027
+ {
1028
+ x: e.x - 72,
1029
+ y: e.y
1030
+ },
1031
+ {
1032
+ x: e.x + 72,
1033
+ y: e.y
1034
+ },
1035
+ {
1036
+ x: e.x - 72,
1037
+ y: e.y - 24
1038
+ },
1039
+ {
1040
+ x: e.x + 72,
1041
+ y: e.y - 24
1042
+ }
1043
+ ].find((e) => !n.some((t) => e.x - r < t.right + 2 && e.x + r > t.left - 2 && e.y - 11 < t.bottom + 2 && e.y + 11 > t.top - 2)) ?? e;
1044
+ }
1045
+ function Kt() {
1046
+ let t = K();
1047
+ if (w.replaceChildren(), le.replaceChildren(), t === null) return;
1048
+ let n = new Set(yt ? M?.trace?.executedEdgeIds ?? [] : []), r = new Set(yt ? M?.trace?.failedRelationIds ?? [] : []), i = n.size > 0, a = [], o = t.nodes.map((e) => {
1049
+ let t = q(e), n = J(e);
1050
+ return {
1051
+ left: n.x,
1052
+ top: n.y,
1053
+ right: n.x + t.width,
1054
+ bottom: n.y + t.height
1055
+ };
1056
+ });
1057
+ for (let s of t.edges) {
1058
+ let t = Lt(s);
1059
+ if (t === null) continue;
1060
+ let c = M?.selection?.kind === "edge" && M.selection.id === s.id, l = e.createElementNS(st, "g");
1061
+ l.classList.add("designer-blueprint-canvas-edge-group"), l.dataset.kind = s.kind, i && n.has(s.id) && (l.dataset.traced = "true"), i && s.relationId !== void 0 && r.has(s.relationId) && (l.dataset.failed = "true"), c && (l.dataset.selected = "true");
1062
+ let d = e.createElementNS(st, "path");
1063
+ d.classList.add("designer-blueprint-canvas-edge-line"), d.setAttribute("d", t.path), l.append(d);
1064
+ let f = e.createElementNS(st, "g");
1065
+ if (f.classList.add("designer-blueprint-canvas-edge-caps"), s.kind === "semantic") f.append(qt(t.start, 2.6), qt(t.end, 2.6));
1066
+ else if (s.kind === "dependency") f.append(qt(t.end, 2.6));
1067
+ else if (s.kind === "relation") {
1068
+ let n = e.createElementNS(st, "path");
1069
+ n.setAttribute("d", Bt(t.end, t.beforeEnd)), f.append(n);
1070
+ }
1071
+ l.append(f);
1072
+ let p = e.createElementNS(st, "path");
1073
+ p.classList.add("designer-blueprint-canvas-edge-hit"), p.setAttribute("d", t.path), p.dataset.edgeId = s.id, p.setAttribute("tabindex", "0"), p.setAttribute("role", "button");
1074
+ let m = Z(s);
1075
+ if (p.setAttribute("aria-label", H.edgeAria(m)), p.addEventListener("pointerdown", (e) => {
1076
+ e.stopPropagation(), fn({
1077
+ kind: "edge",
1078
+ id: s.id
1079
+ }, e);
1080
+ }), p.addEventListener("keydown", (e) => {
1081
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), fn({
1082
+ kind: "edge",
1083
+ id: s.id
1084
+ }, e));
1085
+ }), l.append(p), w.append(l), m !== "" && (s.kind !== "dependency" || c || i && n.has(s.id))) {
1086
+ let r = e.createElement("span");
1087
+ r.className = "designer-blueprint-canvas-edge-label", r.dataset.edgeLabel = s.id, r.dataset.kind = s.kind, r.setAttribute("role", "button"), r.setAttribute("tabindex", "0"), r.setAttribute("aria-label", H.edgeAria(m)), c && (r.dataset.selected = "true", r.setAttribute("aria-current", "true")), i && n.has(s.id) && (r.dataset.traced = "true");
1088
+ let l = e.createElement("span");
1089
+ l.className = "designer-blueprint-canvas-edge-label-icon", l.innerHTML = u(Wt(s));
1090
+ let d = e.createElement("span");
1091
+ d.className = "designer-blueprint-canvas-edge-label-text", d.textContent = m, r.append(l, d);
1092
+ let f = Gt(t.label, m, o);
1093
+ for (; a.some((e) => Math.abs(e.x - f.x) < 96 && Math.abs(e.y - f.y) < 16);) f = {
1094
+ x: f.x,
1095
+ y: f.y + 22
1096
+ };
1097
+ a.push(f), r.style.left = `${f.x}px`, r.style.top = `${f.y}px`, r.addEventListener("pointerdown", (e) => {
1098
+ e.stopPropagation(), fn({
1099
+ kind: "edge",
1100
+ id: s.id
1101
+ }, e);
1102
+ }), r.addEventListener("keydown", (e) => {
1103
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), fn({
1104
+ kind: "edge",
1105
+ id: s.id
1106
+ }, e));
1107
+ }), le.append(r);
1108
+ }
1109
+ }
1110
+ }
1111
+ function qt(t, n) {
1112
+ let r = e.createElementNS(st, "circle");
1113
+ return r.setAttribute("cx", String(t.x)), r.setAttribute("cy", String(t.y)), r.setAttribute("r", String(n)), r;
1114
+ }
1115
+ function Jt() {
1116
+ let t = K();
1117
+ for (let e of C.querySelectorAll(".designer-blueprint-canvas-node")) e.remove();
1118
+ if (Kt(), t === null) return;
1119
+ let n = yt ? M?.trace : null, r = new Set(n?.executedEdgeIds ?? []), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
1120
+ for (let e of t.edges) r.has(e.id) && (i.add(e.source), i.add(e.target)), e.relationId !== void 0 && (n?.failedRelationIds ?? []).includes(e.relationId) && a.add(e.target);
1121
+ for (let n of t.nodes) {
1122
+ let t = q(n), o = J(n), s = e.createElement("div");
1123
+ s.className = "designer-blueprint-canvas-node", s.dataset.nodeId = n.id, s.dataset.kind = n.kind, s.style.left = `${o.x}px`, s.style.top = `${o.y}px`, s.style.width = `${t.width}px`, s.style.height = `${t.height}px`, s.tabIndex = 0, s.setAttribute("role", "button");
1124
+ let c = H.nodeKind[n.kind], l = Zt(n);
1125
+ s.setAttribute("aria-label", `${c} ${l}`), M?.selection?.kind === "node" && M.selection.id === n.id && (s.dataset.selected = "true"), r.size > 0 && i.has(n.id) && (s.dataset.traced = "true"), a.has(n.id) && (s.dataset.failed = "true");
1126
+ let d = e.createElement("div");
1127
+ d.className = "designer-blueprint-canvas-node-header";
1128
+ let f = e.createElement("span");
1129
+ f.className = "designer-blueprint-canvas-node-icon", f.innerHTML = u($t(n));
1130
+ let p = e.createElement("div");
1131
+ p.className = "designer-blueprint-canvas-node-copy";
1132
+ let m = e.createElement("span");
1133
+ m.className = "designer-blueprint-canvas-node-kind", m.textContent = Qt(n);
1134
+ let h = e.createElement("span");
1135
+ if (h.className = "designer-blueprint-canvas-node-title", h.textContent = l, p.append(m, h), d.append(f, p), n.kind !== "variable") {
1136
+ let t = n.outboundCount ?? 0, r = n.inboundCount ?? 0, i = e.createElement("span");
1137
+ i.className = "designer-blueprint-canvas-node-relcount", i.title = H.relationCountTitle(t, r);
1138
+ let a = e.createElement("span");
1139
+ a.textContent = `${H.relationCounts.out} `;
1140
+ let o = e.createElement("b");
1141
+ o.textContent = String(t);
1142
+ let s = e.createElement("span");
1143
+ s.textContent = ` ${H.relationCounts.in} `;
1144
+ let c = e.createElement("b");
1145
+ c.textContent = String(r), i.append(a, o, s, c), d.append(i);
1146
+ }
1147
+ let g = e.createElement("div");
1148
+ g.className = "designer-blueprint-canvas-node-subtitle", g.textContent = en(n);
1149
+ let _;
1150
+ if (n.kind === "variable") {
1151
+ _ = e.createElement("div"), _.className = "designer-blueprint-canvas-node-value";
1152
+ let t = e.createElement("span");
1153
+ t.textContent = `${H.variableValueLabel} `;
1154
+ let r = e.createElement("b");
1155
+ r.textContent = n.variableInitialValue === void 0 ? H.variableValueEmpty : nn(n.variableInitialValue);
1156
+ let i = e.createElement("span");
1157
+ i.textContent = H.variableCounts(n.writeCount ?? 0, n.readCount ?? 0), _.append(t, r, i);
1158
+ }
1159
+ let v = tn(n), y;
1160
+ v !== "" && (y = e.createElement("div"), y.className = "designer-blueprint-canvas-node-summary", y.textContent = v, y.style.bottom = "0", y.style.height = `${Ze}px`);
1161
+ let ee = e.createElement("div");
1162
+ if (ee.className = "designer-blueprint-canvas-ports", ee.style.top = `${t.portStart}px`, n.kind === "component" || n.kind === "variable") {
1163
+ let n = t.outputs.filter((e) => e.semantic !== !0 && e.containment !== !0);
1164
+ if (n.length === 0) {
1165
+ let t = e.createElement("div");
1166
+ t.className = "designer-blueprint-canvas-port-row", t.dataset.available = "false", t.textContent = H.nodeNoEvents, ee.append(t);
1167
+ }
1168
+ for (let e of n) ee.append(Yt(e));
1169
+ for (let e of t.outputs.filter((e) => e.semantic === !0 || e.containment === !0)) ee.append(Yt(e));
1170
+ }
1171
+ let b = e.createElement("span");
1172
+ b.className = "designer-blueprint-canvas-port designer-blueprint-canvas-port-in", b.dataset.nodeId = n.id, b.dataset.armed = String(B !== null && Xt(B)), b.style.top = `${t.inputY}px`, b.setAttribute("role", "button"), b.setAttribute("tabindex", "0"), b.setAttribute("aria-label", H.inputPort), b.addEventListener("pointerdown", (e) => bn(e)), b.addEventListener("keydown", (e) => {
1173
+ (e.key === "Enter" || e.key === " ") && B !== null && (e.preventDefault(), e.stopPropagation(), xn(B.nodeId, B.handle, b), B = null);
1174
+ }), s.append(d, g), _ !== void 0 && s.append(_), s.append(ee), t.inputHandle !== void 0 && (b.dataset.inputHandle = t.inputHandle, s.append(b));
1175
+ for (let r of t.outputs) {
1176
+ let t = e.createElement("span");
1177
+ t.className = "designer-blueprint-canvas-port designer-blueprint-canvas-port-out", t.dataset.outputHandle = r.handle, t.dataset.nodeId = n.id, t.dataset.available = String(r.available), r.dependency === !0 && (t.dataset.dependency = "true"), r.semantic === !0 && (t.dataset.semantic = "true"), r.containment === !0 && (t.dataset.containment = "true"), t.style.top = `${r.y}px`, t.setAttribute("role", "button"), t.setAttribute("tabindex", "0");
1178
+ let i = `${r.label}`;
1179
+ t.setAttribute("aria-label", r.available ? i : H.portUnavailableAria(i)), r.available || (t.setAttribute("aria-disabled", "true"), t.setAttribute("data-tip", r.requiredCapability === void 0 ? H.portUnavailable : H.portUnavailableCapability(r.requiredCapability))), r.dependency === !0 || r.containment === !0 ? (t.setAttribute("aria-disabled", "true"), r.containment === !0 && t.setAttribute("data-tip", U.relationList.containmentHint)) : (t.addEventListener("pointerdown", (e) => _n(e, n, r)), t.addEventListener("keydown", (e) => {
1180
+ if (e.key === "Enter" || e.key === " ") {
1181
+ if (e.preventDefault(), e.stopPropagation(), !r.available) {
1182
+ Y(H.statusPortUnavailable, "error");
1183
+ return;
1184
+ }
1185
+ B = {
1186
+ nodeId: n.id,
1187
+ handle: r.handle
1188
+ }, Jt();
1189
+ }
1190
+ })), s.append(t);
1191
+ }
1192
+ y !== void 0 && s.append(y), s.addEventListener("pointerdown", (e) => pn(e, n)), s.addEventListener("keydown", (e) => {
1193
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), dn({
1194
+ kind: "node",
1195
+ id: n.id
1196
+ }));
1197
+ }), C.append(s);
1198
+ }
1199
+ }
1200
+ function Yt(t) {
1201
+ let n = e.createElement("div");
1202
+ n.className = "designer-blueprint-canvas-port-row", n.dataset.available = String(t.available), t.dependency === !0 && (n.dataset.dependency = "true"), t.semantic === !0 && (n.dataset.semantic = "true"), t.containment === !0 && (n.dataset.containment = "true");
1203
+ let r = e.createElement("span");
1204
+ r.className = "designer-blueprint-canvas-port-name", r.textContent = t.label;
1205
+ let i = e.createElement("span");
1206
+ if (i.className = "designer-blueprint-canvas-port-tag", i.textContent = t.semantic === !0 ? H.portTags.semantic : t.containment === !0 ? H.portTags.structure : t.available ? H.portTags.event : H.portTags.unavailable, n.append(r, i), t.available !== !0) {
1207
+ let t = e.createElement("span");
1208
+ t.className = "designer-blueprint-canvas-port-lock", t.innerHTML = u("lock"), n.append(t);
1209
+ }
1210
+ return n;
1211
+ }
1212
+ function Xt(e) {
1213
+ return At(e.nodeId) !== void 0;
1214
+ }
1215
+ function Zt(e) {
1216
+ return e.kind === "component" ? e.componentName ?? e.componentId ?? e.id : e.kind === "variable" ? e.variableName ?? e.variableId ?? e.id : e.kind === "host" ? U.hostNode : e.id;
1217
+ }
1218
+ function Qt(e) {
1219
+ return e.kind === "component" ? H.nodeKindLine.component(e.materialType ?? H.nodeKind.component) : e.kind === "variable" ? H.nodeKindLine.variable : e.kind === "host" ? H.nodeKindLine.host : H.nodeKind[e.kind];
1220
+ }
1221
+ function $t(e) {
1222
+ if (e.kind === "variable") return "variable";
1223
+ if (e.kind === "host") return "terminal";
1224
+ if (e.isContainer === !0) return "group";
1225
+ let t = e.materialType ?? "";
1226
+ return t.includes("chart") ? "chart-line" : t.includes("table") || t.includes("ranking") ? "table" : t.includes("text") || t.includes("title") ? "type" : t.includes("image") ? "image" : "shapes";
1227
+ }
1228
+ function en(e) {
1229
+ return e.kind === "component" ? H.nodeSubtitle.component(e.materialType ?? H.nodeKind.component, e.componentId ?? e.id) : e.kind === "variable" ? H.nodeSubtitle.variable(e.variableType ?? H.nodeKind.variable, e.variableId ?? e.id) : e.kind === "host" ? H.nodeSubtitle.host(e.exitCount ?? 0) : e.id;
1230
+ }
1231
+ function tn(e) {
1232
+ return e.kind === "component" && (e.childCount ?? 0) > 0 ? `${U.structureTitle} · ${U.structure.children} ${e.childCount}` : "";
1233
+ }
1234
+ function nn(e) {
1235
+ try {
1236
+ let t = JSON.stringify(e);
1237
+ return t !== void 0 && t.length > 22 ? `${t.slice(0, 21)}…` : t ?? "…";
1238
+ } catch {
1239
+ return "…";
1240
+ }
1241
+ }
1242
+ function rn() {
1243
+ let e = K(), t = (M?.diagnostics ?? []).filter((e) => e.severity === "error");
1244
+ d.dataset.state = t.length === 0 ? "ok" : "error", _.textContent = t.length === 0 ? H.validationPassed : H.validationFailed(t.length), d.setAttribute("aria-label", H.validationAria(t.length)), d.setAttribute("aria-expanded", String(G)), c.disabled = (e?.nodes.length ?? 0) === 0, v.setAttribute("aria-pressed", String(yt)), v.dataset.active = String(yt), ce.setAttribute("aria-expanded", String(W)), ce.dataset.active = String(W), be.hidden = W, k.hidden = !W, n.dataset.simulation = W ? "open" : "closed";
1245
+ let r = M?.trace?.lines ?? [], i = r.length > 0 ? r.at(-1) ?? H.simulationIdle : H.simulationIdle;
1246
+ Se.textContent = `${H.simulationTitle} · ${i}`;
1247
+ }
1248
+ function an() {
1249
+ let e = (K()?.nodes.length ?? 0) === 0;
1250
+ D.hidden = !e, e && (c.disabled = !0);
1251
+ }
1252
+ function on() {
1253
+ let e = K(), t = e?.nodes.some((e) => e.kind === "component" || e.kind === "variable") ?? !1, n = e?.nodes.some((e) => (e.events ?? []).some((e) => e.available)) ?? !1;
1254
+ _e.hidden = !(t && !n);
1255
+ }
1256
+ function sn() {
1257
+ let t = M?.diagnostics ?? [];
1258
+ x.replaceChildren();
1259
+ let n = e.createElement("header"), r = e.createElement("strong");
1260
+ r.textContent = U.problemsTitle;
1261
+ let i = Et(e, "close", U.problemsTitle, "problems-close");
1262
+ n.append(r, i);
1263
+ let a = e.createElement("ul");
1264
+ if (t.length === 0) {
1265
+ let t = e.createElement("li");
1266
+ t.textContent = H.problemsEmpty, a.append(t);
1267
+ } else for (let n of t) {
1268
+ let t = e.createElement("li");
1269
+ t.dataset.severity = n.severity;
1270
+ let r = e.createElement("span");
1271
+ r.textContent = n.message;
1272
+ let i = e.createElement("code");
1273
+ i.textContent = n.code, t.append(r, i), a.append(t);
1274
+ }
1275
+ x.append(n, a), x.hidden = !G, d.setAttribute("aria-expanded", String(G));
1276
+ }
1277
+ function cn() {
1278
+ let t = A.value, n = [];
1279
+ for (let e of K()?.nodes ?? []) if (e.kind === "component" || e.kind === "variable") for (let t of e.events ?? []) t.available && n.push({
1280
+ value: JSON.stringify({
1281
+ componentId: e.componentId ?? e.variableId ?? e.id,
1282
+ eventName: t.name
1283
+ }),
1284
+ label: `${Zt(e)} · ${t.name}`
1285
+ });
1286
+ if (A.replaceChildren(), n.length === 0) {
1287
+ let t = e.createElement("option");
1288
+ t.textContent = H.simulationNoEvent, t.value = "", A.append(t), A.disabled = !0, je.refresh(), Ie.disabled = !0;
1289
+ return;
1290
+ }
1291
+ for (let t of n) {
1292
+ let n = e.createElement("option");
1293
+ n.value = t.value, n.textContent = t.label, A.append(n);
1294
+ }
1295
+ A.disabled = !1, n.some((e) => e.value === t) ? A.value = t : t !== "" && (A.value = n[0]?.value ?? ""), je.refresh(), Ie.disabled = A.value === "";
1296
+ }
1297
+ function ln() {
1298
+ cn();
1299
+ let t = M?.trace, n = (t?.failedRuleIds.length ?? 0) > 0, r = M?.lastCommand?.commandId === xt && M.lastCommand.status === "rejected";
1300
+ t === null || (t?.lines.length ?? 0) === 0 ? (j.textContent = r ? `${H.simulationRejected} · ${M?.lastCommand?.diagnostics.map((e) => e.message).join(";") || U.invalidCommand}` : H.simulationIdle, j.dataset.tone = "idle") : (j.textContent = n ? H.simulationFailed : H.simulationSuccess, j.dataset.tone = n ? "error" : "success"), ze.replaceChildren(), Be.hidden = (t?.lines.length ?? 0) > 0;
1301
+ for (let n of t?.lines ?? []) {
1302
+ let t = e.createElement("li");
1303
+ t.textContent = n, ze.append(t);
1304
+ }
1305
+ }
1306
+ function un() {
1307
+ rn(), an(), on(), sn(), ln(), X(), Jt();
1308
+ }
1309
+ function dn(e) {
1310
+ jt({
1311
+ type: "select",
1312
+ selection: e
1313
+ });
1314
+ }
1315
+ function fn(e, t) {
1316
+ let n = M?.selection;
1317
+ if ((t.ctrlKey || t.metaKey) && n != null && n.kind === e.kind && n.id === e.id) {
1318
+ dn(null);
1319
+ return;
1320
+ }
1321
+ dn(e);
1322
+ }
1323
+ function pn(e, n) {
1324
+ if (e.button !== 0 || (e.target instanceof Element ? e.target : null)?.closest("[data-output-handle], [data-input-handle], [data-canvas-menu]") != null) return;
1325
+ e.stopPropagation();
1326
+ let r = J(n);
1327
+ I = {
1328
+ nodeId: n.id,
1329
+ pointerId: e.pointerId,
1330
+ startClientX: e.clientX,
1331
+ startClientY: e.clientY,
1332
+ startX: r.x,
1333
+ startY: r.y,
1334
+ moved: !1
1335
+ }, e.currentTarget.setPointerCapture(e.pointerId), t?.addEventListener("pointermove", mn), t?.addEventListener("pointerup", hn), t?.addEventListener("pointercancel", hn);
1336
+ }
1337
+ function mn(e) {
1338
+ if (I === null || e.pointerId !== I.pointerId) return;
1339
+ let t = (e.clientX - I.startClientX) / P.zoom, n = (e.clientY - I.startClientY) / P.zoom;
1340
+ if (!I.moved && Math.abs(t) + Math.abs(n) < 3) return;
1341
+ I.moved = !0;
1342
+ let r = {
1343
+ x: Dt(I.startX + t),
1344
+ y: Dt(I.startY + n)
1345
+ };
1346
+ N.set(I.nodeId, r);
1347
+ let i = C.querySelector(`[data-node-id="${dt(I.nodeId)}"]`);
1348
+ i !== null && (i.style.left = `${r.x}px`, i.style.top = `${r.y}px`), gn();
1349
+ }
1350
+ function hn(e) {
1351
+ if (I === null || e.pointerId !== I.pointerId) return;
1352
+ let n = I;
1353
+ if (I = null, t?.removeEventListener("pointermove", mn), t?.removeEventListener("pointerup", hn), t?.removeEventListener("pointercancel", hn), !n.moved) {
1354
+ fn({
1355
+ kind: "node",
1356
+ id: n.nodeId
1357
+ }, e);
1358
+ return;
1359
+ }
1360
+ Cn();
1361
+ }
1362
+ function gn() {
1363
+ Kt();
1364
+ }
1365
+ function _n(e, n, r) {
1366
+ if (e.stopPropagation(), e.preventDefault(), !r.available) {
1367
+ Y(H.statusPortUnavailable, "error");
1368
+ return;
1369
+ }
1370
+ z = {
1371
+ nodeId: n.id,
1372
+ handle: r.handle,
1373
+ pointerId: e.pointerId,
1374
+ target: null
1375
+ };
1376
+ let i = S.getBoundingClientRect(), a = {
1377
+ x: e.clientX - i.left,
1378
+ y: e.clientY - i.top
1379
+ };
1380
+ T.setAttribute("d", `M ${a.x} ${a.y} L ${a.x} ${a.y}`), T.setAttribute("visibility", "visible"), T.dataset.startX = String(a.x), T.dataset.startY = String(a.y), S.dataset.linking = "true", t?.addEventListener("pointermove", vn), t?.addEventListener("pointerup", yn), t?.addEventListener("pointercancel", yn);
1381
+ }
1382
+ function vn(e) {
1383
+ if (z === null || e.pointerId !== z.pointerId) return;
1384
+ let t = Number(T.dataset.startX ?? "0"), n = Number(T.dataset.startY ?? "0"), r = S.getBoundingClientRect(), i = {
1385
+ x: e.clientX - r.left,
1386
+ y: e.clientY - r.top
1387
+ };
1388
+ T.setAttribute("d", `M ${t} ${n} L ${i.x} ${i.y}`);
1389
+ let a = Sn(e.clientX, e.clientY);
1390
+ z = {
1391
+ ...z,
1392
+ target: a
1393
+ };
1394
+ for (let e of S.querySelectorAll("[data-input-handle]")) e.dataset.hover = String(a !== null && e === a);
1395
+ }
1396
+ function yn(e) {
1397
+ if (z === null || e.pointerId !== z.pointerId) return;
1398
+ let n = z;
1399
+ z = null, T.setAttribute("visibility", "hidden"), S.dataset.linking = "false", t?.removeEventListener("pointermove", vn), t?.removeEventListener("pointerup", yn), t?.removeEventListener("pointercancel", yn);
1400
+ for (let e of S.querySelectorAll("[data-input-handle]")) e.dataset.hover = "false";
1401
+ let r = Sn(e.clientX, e.clientY) ?? n.target;
1402
+ if (r !== null) {
1403
+ xn(n.nodeId, n.handle, r);
1404
+ return;
1405
+ }
1406
+ B = {
1407
+ nodeId: n.nodeId,
1408
+ handle: n.handle
1409
+ }, Y(H.statusArmed), Jt();
1410
+ }
1411
+ function bn(e) {
1412
+ e.stopPropagation(), B !== null && (e.preventDefault(), xn(B.nodeId, B.handle, e.currentTarget), B = null);
1413
+ }
1414
+ function xn(e, t, n) {
1415
+ let r = n.closest("[data-input-handle]");
1416
+ if (r === null) return;
1417
+ let i = r.dataset.nodeId, a = r.dataset.inputHandle;
1418
+ if (i !== void 0 && a !== void 0) {
1419
+ if (i === e) {
1420
+ Y(H.statusSameNode, "error");
1421
+ return;
1422
+ }
1423
+ jt({
1424
+ type: "connect",
1425
+ sourceNodeId: e,
1426
+ sourceHandle: t,
1427
+ targetNodeId: i,
1428
+ targetHandle: a
1429
+ }), B = null, Jt();
1430
+ }
1431
+ }
1432
+ function Sn(e, t) {
1433
+ let r = n.getRootNode(), i = r.elementFromPoint?.bind(r);
1434
+ return (i?.(e, t) ?? null)?.closest("[data-input-handle]") ?? null;
1435
+ }
1436
+ function Cn() {
1437
+ let e = K();
1438
+ if (e === null) return;
1439
+ let t = e.nodes.map((e) => {
1440
+ let t = J(e);
1441
+ return {
1442
+ id: e.id,
1443
+ x: Math.round(t.x),
1444
+ y: Math.round(t.y),
1445
+ ...e.collapsed === !0 ? { collapsed: !0 } : {}
1446
+ };
1447
+ });
1448
+ pt = !1, Ue = Mt(P), jt({
1449
+ type: "commit-layout",
1450
+ nodes: t,
1451
+ viewport: {
1452
+ x: Math.round(P.x),
1453
+ y: Math.round(P.y),
1454
+ zoom: Math.round(P.zoom * 1e3) / 1e3
1455
+ }
1456
+ });
1457
+ }
1458
+ function wn(e) {
1459
+ if (e.button !== 0 || (e.target instanceof Element ? e.target : null)?.closest(".designer-blueprint-canvas-node, [data-edge-id], [data-canvas-empty], [data-canvas-simulation], [data-canvas-simulation-bar], [data-canvas-problems], [data-canvas-no-events]") != null) return;
1460
+ B = null;
1461
+ let n = S.getBoundingClientRect();
1462
+ R = {
1463
+ pointerId: e.pointerId,
1464
+ startClientX: e.clientX,
1465
+ startClientY: e.clientY,
1466
+ startLeft: e.clientX - n.left,
1467
+ startTop: e.clientY - n.top,
1468
+ moved: !1
1469
+ }, S.setPointerCapture(e.pointerId), t?.addEventListener("pointermove", Tn), t?.addEventListener("pointerup", En), t?.addEventListener("pointercancel", En);
1470
+ }
1471
+ function Tn(e) {
1472
+ if (R === null || e.pointerId !== R.pointerId) return;
1473
+ let t = S.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top, i = Math.min(R.startLeft, n), a = Math.min(R.startTop, r), o = Math.abs(n - R.startLeft), s = Math.abs(r - R.startTop);
1474
+ !R.moved && o + s < 3 || (R = {
1475
+ ...R,
1476
+ moved: !0
1477
+ }, E.hidden = !1, E.style.left = `${i}px`, E.style.top = `${a}px`, E.style.width = `${o}px`, E.style.height = `${s}px`);
1478
+ }
1479
+ function En(e) {
1480
+ if (R === null || e.pointerId !== R.pointerId) return;
1481
+ let n = R;
1482
+ if (R = null, t?.removeEventListener("pointermove", Tn), t?.removeEventListener("pointerup", En), t?.removeEventListener("pointercancel", En), E.hidden = !0, !n.moved) {
1483
+ dn(null);
1484
+ return;
1485
+ }
1486
+ let r = S.getBoundingClientRect(), i = Dn(Math.min(n.startClientX, e.clientX) - r.left, Math.min(n.startClientY, e.clientY) - r.top, Math.max(n.startClientX, e.clientX) - r.left, Math.max(n.startClientY, e.clientY) - r.top);
1487
+ if (i === void 0) {
1488
+ dn(null);
1489
+ return;
1490
+ }
1491
+ fn({
1492
+ kind: "node",
1493
+ id: i
1494
+ }, e);
1495
+ }
1496
+ function Dn(e, t, n, r) {
1497
+ let i, a = 0, o = S.getBoundingClientRect();
1498
+ for (let s of C.querySelectorAll(".designer-blueprint-canvas-node")) {
1499
+ let c = s.getBoundingClientRect(), l = c.left - o.left, u = c.top - o.top, d = Math.max(0, Math.min(l + c.width, n) - Math.max(l, e)) * Math.max(0, Math.min(u + c.height, r) - Math.max(u, t));
1500
+ d > a && s.dataset.nodeId !== void 0 && (a = d, i = s.dataset.nodeId);
1501
+ }
1502
+ return i;
1503
+ }
1504
+ function $(e) {
1505
+ L = {
1506
+ pointerId: e.pointerId,
1507
+ startClientX: e.clientX,
1508
+ startClientY: e.clientY,
1509
+ startX: P.x,
1510
+ startY: P.y,
1511
+ moved: !1
1512
+ }, S.dataset.panning = "true", S.setPointerCapture(e.pointerId), t?.addEventListener("pointermove", kn), t?.addEventListener("pointerup", An), t?.addEventListener("pointercancel", An);
1513
+ }
1514
+ function On(e) {
1515
+ e.button !== 0 || !qe || ((e.target instanceof Element ? e.target : null)?.closest("[data-canvas-empty], [data-canvas-simulation], [data-canvas-simulation-bar], [data-canvas-problems], [data-canvas-no-events], [data-canvas-menu], [data-canvas-status]") ?? (e.preventDefault(), e.stopPropagation(), B = null, $(e)));
1516
+ }
1517
+ function kn(e) {
1518
+ if (L === null || e.pointerId !== L.pointerId) return;
1519
+ let t = e.clientX - L.startClientX, n = e.clientY - L.startClientY;
1520
+ !L.moved && Math.abs(t) + Math.abs(n) < 3 || (L = {
1521
+ ...L,
1522
+ moved: !0
1523
+ }, P = {
1524
+ ...P,
1525
+ x: L.startX + t,
1526
+ y: L.startY + n
1527
+ }, Ge = !0, X());
1528
+ }
1529
+ function An(e) {
1530
+ if (L === null || e.pointerId !== L.pointerId) return;
1531
+ let n = L;
1532
+ L = null, S.dataset.panning = "false", t?.removeEventListener("pointermove", kn), t?.removeEventListener("pointerup", An), t?.removeEventListener("pointercancel", An), n.moved && Pt();
1533
+ }
1534
+ function jn(e) {
1535
+ let t = e.composedPath()[0];
1536
+ return t instanceof HTMLElement ? t.isContentEditable || t.closest("input, textarea, select, button, a, [contenteditable=\"true\"]") !== null : !1;
1537
+ }
1538
+ function Mn(e) {
1539
+ e.code !== "Space" || jn(e) || M?.active === !0 && n.getClientRects().length !== 0 && (e.preventDefault(), e.stopPropagation(), qe = !0, S.dataset.hand = "true");
1540
+ }
1541
+ function Nn(e) {
1542
+ e.code !== "Space" || !qe || (qe = !1, S.dataset.hand = "false");
1543
+ }
1544
+ function Pn() {
1545
+ qe = !1, S.dataset.hand = "false", L !== null && (S.dataset.panning = "false", L = null, t?.removeEventListener("pointermove", kn), t?.removeEventListener("pointerup", An), t?.removeEventListener("pointercancel", An), Ge = !0);
1546
+ }
1547
+ function Fn(e) {
1548
+ if (e.preventDefault(), e.ctrlKey || e.metaKey) {
1549
+ let t = e.deltaY < 0 ? 1.1 : 1 / 1.1, n = In(P.zoom * t), r = It(e.clientX, e.clientY), i = S.getBoundingClientRect();
1550
+ P = {
1551
+ zoom: n,
1552
+ x: e.clientX - i.left - r.x * n,
1553
+ y: e.clientY - i.top - r.y * n
1554
+ };
1555
+ } else {
1556
+ let t = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? 512 : 1, n = (e.shiftKey ? e.deltaY : e.deltaX) * t, r = (e.shiftKey ? e.deltaX : e.deltaY) * t;
1557
+ P = {
1558
+ ...P,
1559
+ x: P.x - n,
1560
+ y: P.y - r
1561
+ };
1562
+ }
1563
+ X(), Nt();
1564
+ }
1565
+ function In(e) {
1566
+ return Math.min(at, Math.max(it, Math.round(e * 1e3) / 1e3));
1567
+ }
1568
+ function Ln(e) {
1569
+ let t = P.zoom;
1570
+ Rn(In(e > 0 ? ot.find((e) => e > t + .001) ?? at : [...ot].reverse().find((e) => e < t - .001) ?? it));
1571
+ }
1572
+ function Rn(e) {
1573
+ let t = S.getBoundingClientRect(), n = (t.width / 2 - P.x) / P.zoom, r = (t.height / 2 - P.y) / P.zoom;
1574
+ P = {
1575
+ zoom: e,
1576
+ x: t.width / 2 - n * e,
1577
+ y: t.height / 2 - r * e
1578
+ }, X(), Pt();
1579
+ }
1580
+ function zn(e, t = !0, n = 0) {
1581
+ let r = K();
1582
+ if (r === null) return;
1583
+ let i = e ?? r.nodes;
1584
+ if (i.length === 0) {
1585
+ P = {
1586
+ x: 0,
1587
+ y: 0,
1588
+ zoom: 1
1589
+ }, X(), t && Pt();
1590
+ return;
1591
+ }
1592
+ let a = Infinity, o = Infinity, s = -Infinity, c = -Infinity;
1593
+ for (let e of i) {
1594
+ let t = J(e), n = q(e);
1595
+ a = Math.min(a, t.x), o = Math.min(o, t.y), s = Math.max(s, t.x + n.width), c = Math.max(c, t.y + n.height);
1596
+ }
1597
+ let l = S.getBoundingClientRect(), u = Math.max(1, s - a), d = Math.max(1, c - o), f = Math.max(1, l.width - 56), p = Math.max(1, l.height - 56 - n), m = In(Math.min(1.15, f / u, p / d));
1598
+ P = {
1599
+ zoom: m,
1600
+ x: (l.width - u * m) / 2 - a * m,
1601
+ y: (l.height - n - d * m) / 2 - o * m
1602
+ }, X(), t && Pt();
1603
+ }
1604
+ function Bn() {
1605
+ let e = K();
1606
+ e !== null && e.nodes.length !== 0 && (N = Vn(e.nodes), pt = !1, Jt(), zn(void 0, !1, W ? nt : rt), Cn(), Y(H.statusLayoutApplied));
1607
+ }
1608
+ function Vn(e) {
1609
+ let t = /* @__PURE__ */ new Map(), n = e.filter((e) => e.kind === "component"), r = e.filter((e) => e.kind === "variable"), i = e.filter((e) => e.kind === "host"), a = K()?.edges ?? [], o = r.filter((e) => !a.some((t) => t.target === e.id && t.kind === "relation")), s = r.length > 0 && o.length === r.length, c = S.clientWidth >= 900 ? 3 : 2, l = Math.max(1, Math.min(n.length, c)), u = Math.max(0, ...n.map((e) => q(e).height)) + 28, d = Hn(e), f = [...n].sort((e, t) => {
1610
+ let n = (d.get(e.id) ?? 0) - (d.get(t.id) ?? 0);
1611
+ return n === 0 ? 0 : n;
1612
+ }), p = V + (s ? et : 0), m = Math.max(1, Math.ceil(f.length / l));
1613
+ f.forEach((e, n) => {
1614
+ let r = Math.floor(n / m), i = n % m;
1615
+ t.set(e.id, {
1616
+ x: p + r * et,
1617
+ y: V + i * u
1618
+ });
1619
+ });
1620
+ let h = p + Math.max(0, l - 1) * et, g = (e) => f.reduce((n, r) => {
1621
+ let i = t.get(r.id);
1622
+ return i !== void 0 && i.x === e ? Math.max(n, i.y + q(r).height) : n;
1623
+ }, V), _ = V;
1624
+ if (s) {
1625
+ let e = V;
1626
+ for (let n of o) t.set(n.id, {
1627
+ x: V,
1628
+ y: e
1629
+ }), e += q(n).height + 20;
1630
+ } else {
1631
+ let e = p + l * et;
1632
+ for (let n of r) t.set(n.id, {
1633
+ x: e,
1634
+ y: _
1635
+ }), _ += q(n).height + 20;
1636
+ }
1637
+ let v = p + l * et, y = s ? V : _;
1638
+ s && i.length > 0 && (y = Math.max(V, g(h)));
1639
+ for (let e of i) t.set(e.id, {
1640
+ x: v,
1641
+ y
1642
+ }), y += q(e).height + 24;
1643
+ return t;
1644
+ }
1645
+ function Hn(e) {
1646
+ let t = new Map(e.map((e) => [e.id, 0])), n = (K()?.edges ?? []).filter((e) => e.kind === "relation" || e.kind === "semantic"), r = Math.min(e.length, 8);
1647
+ for (let e = 0; e < r; e += 1) {
1648
+ let e = !1;
1649
+ for (let i of n) {
1650
+ let n = t.get(i.source), a = t.get(i.target);
1651
+ if (n === void 0 || a === void 0) continue;
1652
+ let o = n + 1;
1653
+ o > a && o < r && (t.set(i.target, o), e = !0);
1654
+ }
1655
+ if (!e) break;
1656
+ }
1657
+ return t;
1658
+ }
1659
+ function Un(e) {
1660
+ return e === void 0 ? 0 : e.kind === "host" ? 2 : 0;
1661
+ }
1662
+ function Wn(e) {
1663
+ let t = V + Un(e) * et, n = 0;
1664
+ for (let r of K()?.nodes ?? []) {
1665
+ if (r.id === e?.id) continue;
1666
+ let i = J(r);
1667
+ Math.abs(i.x - t) > et / 2 || (n = Math.max(n, i.y + q(r).height));
1668
+ }
1669
+ return {
1670
+ x: t,
1671
+ y: n === 0 ? V : n + 48
1672
+ };
1673
+ }
1674
+ function Gn() {
1675
+ gt = !0, (t?.requestAnimationFrame ?? ((e) => setTimeout(() => e(Date.now()), 0)))(() => {
1676
+ if (!gt || St) return;
1677
+ let e = K();
1678
+ if (e === null || e.nodes.length === 0) return;
1679
+ let t = S.getBoundingClientRect();
1680
+ t.width !== 0 && t.height !== 0 && (gt = !1, _t = !0, zn(e.nodes, !1, W ? nt : rt));
1681
+ });
1682
+ }
1683
+ function Kn() {
1684
+ jt({
1685
+ type: "insert-node",
1686
+ kind: "host"
1687
+ }), Qn();
1688
+ }
1689
+ function qn() {
1690
+ if (A.value === "") {
1691
+ Y(H.statusNoSimulationEvent, "error");
1692
+ return;
1693
+ }
1694
+ let e;
1695
+ try {
1696
+ e = JSON.parse(A.value);
1697
+ } catch {
1698
+ Y(H.statusSimulationEventStale, "error");
1699
+ return;
1700
+ }
1701
+ if (typeof e.componentId != "string" || typeof e.eventName != "string") return;
1702
+ let t;
1703
+ try {
1704
+ t = JSON.parse(Pe.value);
1705
+ } catch {
1706
+ Y(H.statusSimulationPayloadInvalid, "error");
1707
+ return;
1708
+ }
1709
+ let n = jt({
1710
+ type: "run-simulation",
1711
+ componentId: e.componentId,
1712
+ eventName: e.eventName,
1713
+ payload: t
1714
+ });
1715
+ n !== void 0 && (xt = n.commandId);
1716
+ }
1717
+ function Jn(e) {
1718
+ let t = e.dataTransfer;
1719
+ if (t === null) return;
1720
+ let n = t.getData(ae);
1721
+ if (n === "") return;
1722
+ e.preventDefault();
1723
+ let r;
1724
+ try {
1725
+ r = JSON.parse(n);
1726
+ } catch {
1727
+ Y(H.statusDropInvalid, "error");
1728
+ return;
1729
+ }
1730
+ let i = It(e.clientX, e.clientY);
1731
+ jt({
1732
+ ...r,
1733
+ type: "insert-node",
1734
+ position: {
1735
+ x: Dt(i.x),
1736
+ y: Dt(i.y)
1737
+ }
1738
+ });
1739
+ }
1740
+ function Yn(e) {
1741
+ if (e.key === "Escape") {
1742
+ if (bt) {
1743
+ Qn();
1744
+ return;
1745
+ }
1746
+ if (G) {
1747
+ G = !1, sn();
1748
+ return;
1749
+ }
1750
+ if (W) {
1751
+ tr(), zn(void 0, !1);
1752
+ return;
1753
+ }
1754
+ if (B !== null) {
1755
+ B = null, Jt();
1756
+ return;
1757
+ }
1758
+ if (M?.selection !== null && M?.selection !== void 0) {
1759
+ dn(null);
1760
+ return;
1761
+ }
1762
+ return;
1763
+ }
1764
+ if (e.key === "0" && (e.ctrlKey || e.metaKey)) {
1765
+ e.preventDefault(), zn(void 0, !0, W ? nt : rt);
1766
+ return;
1767
+ }
1768
+ if (e.key !== "Delete" && e.key !== "Backspace" || M?.selection === null || M?.selection === void 0) return;
1769
+ let t = e.target;
1770
+ t instanceof HTMLInputElement || t instanceof HTMLSelectElement || t instanceof HTMLTextAreaElement || (e.preventDefault(), jt({
1771
+ type: "delete-selection",
1772
+ selection: M.selection
1773
+ }));
1774
+ }
1775
+ function Xn(e) {
1776
+ let t = e.detail;
1777
+ if (typeof t != "object" || !t || t.state === void 0) return;
1778
+ let n = t.state, r = n.generation !== Ve;
1779
+ if (M = n, r && (Ve = n.generation, He = !1, B = null, P = n.graph.viewport ?? {
1780
+ x: 0,
1781
+ y: 0,
1782
+ zoom: 1
1783
+ }, We = Mt(P), Ue = "", Ge = !1, ht = new Map(n.graph.nodes.map((e) => [e.id, {
1784
+ x: e.x,
1785
+ y: e.y
1786
+ }])), pt = n.graph.viewport === void 0, N = pt ? Vn(n.graph.nodes) : new Map(ht), mt = n.graph.nodes.length > 0, _t = !1, gt = !1, xt = "", tr(!1), Gn()), !r) {
1787
+ let e = new Map(n.graph.nodes.map((e) => [e.id, {
1788
+ x: e.x,
1789
+ y: e.y
1790
+ }]));
1791
+ if (I === null) {
1792
+ if (!mt && e.size > 0) pt = n.graph.viewport === void 0, N = pt ? Vn(n.graph.nodes) : new Map(e), mt = !0, Gn();
1793
+ else if (mt) {
1794
+ for (let [t, r] of e) {
1795
+ let e = ht.get(t);
1796
+ e === void 0 && pt ? N.set(t, Wn(At(t) ?? n.graph.nodes.find((e) => e.id === t))) : (e === void 0 || e.x !== r.x || e.y !== r.y) && N.set(t, r);
1797
+ }
1798
+ for (let t of [...N.keys()]) e.has(t) || N.delete(t);
1799
+ }
1800
+ }
1801
+ ht = e, n.graph.nodes.length === 0 && (mt = !1);
1802
+ }
1803
+ r || Ft(n.graph.viewport), n.active && !vt && !_t && Gn(), vt = n.active, un(), He || (He = !0, jt({ type: "ready" })), n.viewRequest !== void 0 && n.viewRequest.id !== ft && (ft = n.viewRequest.id, Zn(n.viewRequest.targetId));
1804
+ }
1805
+ function Zn(e) {
1806
+ let t = At(e);
1807
+ if (t === void 0) return;
1808
+ let n = J(t), r = q(t), i = S.getBoundingClientRect();
1809
+ P = {
1810
+ ...P,
1811
+ x: i.width / 2 - (n.x + r.width / 2) * P.zoom,
1812
+ y: i.height / 2 - (W ? nt : rt) / 2 - (n.y + r.height / 2) * P.zoom
1813
+ }, X();
1814
+ }
1815
+ function Qn() {
1816
+ bt && (bt = !1, s.hidden = !0, a.setAttribute("aria-expanded", "false"), i.classList.remove("is-open"));
1817
+ }
1818
+ function $n() {
1819
+ bt = !0, s.hidden = !1, a.setAttribute("aria-expanded", "true"), i.classList.add("is-open"), s.querySelector("button")?.focus();
1820
+ }
1821
+ function er() {
1822
+ W || (W = !0, rn(), ln(), A.focus());
1823
+ }
1824
+ function tr(e = !0) {
1825
+ W && (W = !1, rn(), ln(), e && ce.focus());
1826
+ }
1827
+ function nr() {
1828
+ G = !G, sn();
1829
+ }
1830
+ return a.addEventListener("click", () => {
1831
+ bt ? Qn() : $n();
1832
+ }), r.addEventListener("click", (e) => {
1833
+ let t = e.target instanceof Element ? e.target : null;
1834
+ if (t === null) return;
1835
+ if (t.closest("[data-canvas-insert]")?.dataset.canvasInsert === "host") {
1836
+ Kn();
1837
+ return;
1838
+ }
1839
+ let n = t.closest("[data-canvas-action]")?.dataset.canvasAction;
1840
+ if (n !== void 0) {
1841
+ if (n === "auto-layout") {
1842
+ Bn();
1843
+ return;
1844
+ }
1845
+ if (n === "problems") {
1846
+ nr();
1847
+ return;
1848
+ }
1849
+ if (n === "trace") {
1850
+ if (M?.trace === null || M?.trace === void 0) {
1851
+ Y(H.statusTraceUnavailable);
1852
+ return;
1853
+ }
1854
+ yt = !yt, rn(), Jt();
1855
+ return;
1856
+ }
1857
+ if (n === "zoom-in") {
1858
+ Ln(1);
1859
+ return;
1860
+ }
1861
+ if (n === "zoom-out") {
1862
+ Ln(-1);
1863
+ return;
1864
+ }
1865
+ if (n === "fit") {
1866
+ zn(void 0, !0, W ? nt : rt);
1867
+ return;
1868
+ }
1869
+ n === "simulate" && (W ? tr() : er());
1870
+ }
1871
+ }), D.addEventListener("click", (e) => {
1872
+ (e.target instanceof Element ? e.target : null)?.closest("[data-canvas-insert]")?.dataset.canvasInsert === "host" && Kn();
1873
+ }), x.addEventListener("click", (e) => {
1874
+ (e.target instanceof Element ? e.target : null)?.closest("[data-canvas-action=\"problems-close\"]") !== null && (G = !1, sn());
1875
+ }), k.addEventListener("click", (e) => {
1876
+ let t = e.target instanceof Element ? e.target : null;
1877
+ if (t?.closest("[data-canvas-action=\"simulation-run\"]") !== null) {
1878
+ qn();
1879
+ return;
1880
+ }
1881
+ t?.closest("[data-canvas-action=\"simulation-close\"]") !== null && tr();
1882
+ }), Ce.addEventListener("click", er), A.addEventListener("change", () => {
1883
+ Ie.disabled = A.value === "";
1884
+ }), n.addEventListener("pointerdown", (e) => {
1885
+ let t = e.target instanceof Element ? e.target : null;
1886
+ bt && t?.closest("[data-canvas-menu]") === null && t?.closest("[data-canvas-action=\"add-node\"]") === null && Qn(), G && t?.closest("[data-canvas-problems]") === null && t?.closest("[data-canvas-action=\"problems\"]") === null && (G = !1, sn());
1887
+ }), S.addEventListener("pointerdown", On, !0), S.addEventListener("pointerdown", wn), S.addEventListener("wheel", Fn, { passive: !1 }), S.addEventListener("dragover", (e) => {
1888
+ Array.from(e.dataTransfer?.types ?? []).includes("application/x-base-screen-blueprint-node") && (e.preventDefault(), e.dataTransfer !== null && (e.dataTransfer.dropEffect = "copy"));
1889
+ }), S.addEventListener("drop", Jn), n.addEventListener("keydown", Yn), n.addEventListener(ie, Xn), t?.addEventListener("keydown", Mn, !0), t?.addEventListener("keyup", Nn, !0), t?.addEventListener("blur", Pn), X(), rn(), {
1890
+ element: n,
1891
+ destroy() {
1892
+ St = !0, Ct?.disconnect(), F !== void 0 && clearTimeout(F), Ke !== void 0 && clearTimeout(Ke), t?.removeEventListener("pointermove", mn), t?.removeEventListener("pointerup", hn), t?.removeEventListener("pointercancel", hn), t?.removeEventListener("pointermove", vn), t?.removeEventListener("pointerup", yn), t?.removeEventListener("pointercancel", yn), t?.removeEventListener("pointermove", kn), t?.removeEventListener("pointerup", An), t?.removeEventListener("pointercancel", An), t?.removeEventListener("pointermove", Tn), t?.removeEventListener("pointerup", En), t?.removeEventListener("pointercancel", En), t?.removeEventListener("keydown", Mn, !0), t?.removeEventListener("keyup", Nn, !0), t?.removeEventListener("blur", Pn);
1893
+ }
1894
+ };
1895
+ }
1896
+ function dt(e) {
1897
+ let t = globalThis.CSS?.escape;
1898
+ return typeof t == "function" ? t(e) : e.replace(/["\\]/g, "\\$&");
1899
+ }
1900
+ function ft(e, t, n, r) {
1901
+ let i = e.querySelector(".designer");
1902
+ i !== null && (i.dataset.authoringMode = t);
1903
+ let a = e.querySelector("[data-blueprint-surface]");
1904
+ a !== null && (a.hidden = t !== "blueprint" || !n, a.dataset.slotReady = String(n));
1905
+ for (let r of e.querySelectorAll("[data-workbench-mode-tab]")) {
1906
+ let e = r.dataset.workbenchModeTab, i = e === t, a = e === "blueprint" && !n;
1907
+ r.disabled = a, r.dataset.active = String(i), r.setAttribute("aria-selected", String(i)), r.tabIndex = i ? 0 : -1;
1908
+ let o = a ? d.interactionWorkspaceUnavailable : e === "blueprint" ? d.interactionWorkspaceHint : d.canvasWorkspace;
1909
+ r.setAttribute("data-tip", o), r.ariaLabel = o;
1910
+ }
1911
+ let o = t === "blueprint" ? d.commandPalette.blueprintTrigger : d.commandPalette.trigger, s = e.querySelector("[data-command-palette-trigger-label]");
1912
+ s !== null && (s.textContent = o);
1913
+ let c = e.querySelector("[data-command-palette-toggle]");
1914
+ if (c !== null && (c.ariaLabel = o, c.setAttribute("data-tip", o)), pt(e, t, r.nodes), t !== "blueprint") return;
1915
+ let l = e.querySelector("[data-status-selection]");
1916
+ l !== null && (l.textContent = d.blueprint.workbench);
1917
+ let u = e.querySelector("[data-status-canvas]");
1918
+ u !== null && (u.textContent = d.blueprint.status(r.nodes, r.relations, r.semantic, r.structural, r.problems));
1919
+ }
1920
+ function pt(e, t, n) {
1921
+ let r = t === "blueprint", i = e.querySelector("[data-blueprint-library]"), a = e.querySelector("[data-blueprint-inspector]");
1922
+ i !== null && (i.hidden = !r), a !== null && (a.hidden = !r), mt(e, "left", r, d.blueprint.library, n), mt(e, "right", r, d.blueprint.inspector);
1923
+ }
1924
+ function mt(e, t, n, r, i) {
1925
+ let a = e.querySelector(`[data-${t}-panel-title]`), o = e.querySelector(`[data-${t}-panel-count]`);
1926
+ a !== null && (n ? (a.dataset.canvasTitle ??= a.textContent ?? "", a.textContent = r) : a.dataset.canvasTitle !== void 0 && (a.textContent = a.dataset.canvasTitle, delete a.dataset.canvasTitle)), o !== null && (n ? (o.dataset.canvasCount ??= o.textContent ?? "", o.dataset.canvasAriaLabel ??= o.getAttribute("aria-label") ?? "", o.textContent = String(i ?? 0), o.setAttribute("aria-label", d.blueprint.panelCount(r, i ?? 0))) : o.dataset.canvasCount !== void 0 && (o.textContent = o.dataset.canvasCount, o.setAttribute("aria-label", o.dataset.canvasAriaLabel ?? ""), delete o.dataset.canvasCount, delete o.dataset.canvasAriaLabel));
1927
+ }
1928
+ function ht(e, t, n, r, i, a) {
1929
+ let o = de(e, t), s = fe(e, t), c = de(e, r), l = fe(e, r);
1930
+ if (o === void 0 && s === void 0 || c === void 0 && l === void 0 && r !== T) return {
1931
+ ok: !1,
1932
+ reason: "invalid"
1933
+ };
1934
+ if (n === "semantic:out") {
1935
+ if (o === void 0 || c === void 0 || o === c || i !== "relation:in") return {
1936
+ ok: !1,
1937
+ reason: "invalid"
1938
+ };
1939
+ if (e.blueprint.relations.some((e) => e.type === "semantic" && e.source.componentId === o && e.target.componentId === c)) return {
1940
+ ok: !1,
1941
+ reason: "duplicate"
1942
+ };
1943
+ let t = we(e.blueprint, `${o}-${c}-semantic`);
1944
+ return {
1945
+ ok: !0,
1946
+ blueprint: {
1947
+ ...e.blueprint,
1948
+ relations: [...e.blueprint.relations, {
1949
+ type: "semantic",
1950
+ id: t,
1951
+ source: {
1952
+ kind: "component",
1953
+ componentId: o
1954
+ },
1955
+ target: {
1956
+ kind: "component",
1957
+ componentId: c
1958
+ },
1959
+ role: "related"
1960
+ }]
1961
+ },
1962
+ selection: {
1963
+ kind: "edge",
1964
+ id: `semantic:${t}`
1965
+ }
1966
+ };
1967
+ }
1968
+ let u = gt(n, "event:"), d;
1969
+ if (o !== void 0 && u !== void 0) {
1970
+ if (!a.some((e) => e.componentId === o && e.name === u && e.available)) return {
1971
+ ok: !1,
1972
+ reason: "invalid"
1973
+ };
1974
+ d = {
1975
+ kind: "component",
1976
+ componentId: o,
1977
+ event: {
1978
+ type: "material-event",
1979
+ eventName: u
1980
+ }
1981
+ };
1982
+ } else if (s !== void 0 && (u === "data-updated" || u === "request-state")) d = {
1983
+ kind: "variable",
1984
+ variableId: s,
1985
+ event: {
1986
+ type: "variable-event",
1987
+ eventName: u
1988
+ }
1989
+ };
1990
+ else return {
1991
+ ok: !1,
1992
+ reason: "invalid"
1993
+ };
1994
+ let f, p;
1995
+ if (c !== void 0) {
1996
+ let e = gt(i, "visibility:");
1997
+ if (i !== "relation:in" && i !== "dependency:in" && e !== "show" && e !== "hide" && e !== "toggle") return {
1998
+ ok: !1,
1999
+ reason: "invalid"
2000
+ };
2001
+ f = {
2002
+ kind: "component",
2003
+ componentId: c
2004
+ }, p = {
2005
+ type: "component-visibility",
2006
+ operation: e === "hide" || e === "toggle" ? e : "show",
2007
+ transition: {
2008
+ effect: "fade",
2009
+ durationMs: 200,
2010
+ easing: "ease-in-out-quad"
2011
+ }
2012
+ };
2013
+ } else if (l !== void 0) {
2014
+ if (i !== "relation:in" && i !== "dependency:in") return {
2015
+ ok: !1,
2016
+ reason: "invalid"
2017
+ };
2018
+ f = {
2019
+ kind: "variable",
2020
+ variableId: l
2021
+ }, p = {
2022
+ type: "set-variable",
2023
+ value: {
2024
+ kind: "literal",
2025
+ value: null
2026
+ }
2027
+ };
2028
+ } else {
2029
+ if (i !== "relation:in" && i !== "dependency:in") return {
2030
+ ok: !1,
2031
+ reason: "invalid"
2032
+ };
2033
+ f = { kind: "host" }, p = {
2034
+ type: "emit-host-event",
2035
+ eventName: "host_event",
2036
+ payload: {
2037
+ kind: "event-payload",
2038
+ path: []
2039
+ }
2040
+ };
2041
+ }
2042
+ if (e.blueprint.relations.some((e) => e.type === "behavior" && e.condition === void 0 && vt(e.source, d) && yt(e.target, f) && W(e.effect, p))) return {
2043
+ ok: !1,
2044
+ reason: "duplicate"
2045
+ };
2046
+ let m = f.kind === "component" ? f.componentId : f.kind === "variable" ? f.variableId : "host", h = we(e.blueprint, `${_t(d)}-${u}-${m}`), g = {
2047
+ type: "behavior",
2048
+ id: h,
2049
+ source: d,
2050
+ target: f,
2051
+ effect: p
2052
+ };
2053
+ return {
2054
+ ok: !0,
2055
+ blueprint: {
2056
+ ...e.blueprint,
2057
+ relations: [...e.blueprint.relations, g]
2058
+ },
2059
+ selection: {
2060
+ kind: "edge",
2061
+ id: `relation:${h}`
2062
+ }
2063
+ };
2064
+ }
2065
+ function gt(e, t) {
2066
+ return e.startsWith(t) && e.length > t.length ? e.slice(t.length) : void 0;
2067
+ }
2068
+ function _t(e) {
2069
+ return e.kind === "component" ? e.componentId : e.variableId;
2070
+ }
2071
+ function vt(e, t) {
2072
+ return e.kind === t.kind ? e.kind === "component" && t.kind === "component" ? e.componentId === t.componentId && e.event.type === t.event.type && e.event.eventName === t.event.eventName : e.kind === "variable" && t.kind === "variable" && e.variableId === t.variableId && e.event.type === t.event.type && e.event.eventName === t.event.eventName : !1;
2073
+ }
2074
+ function yt(e, t) {
2075
+ return e.kind === t.kind ? e.kind === "component" && t.kind === "component" ? e.componentId === t.componentId : e.kind === "variable" && t.kind === "variable" ? e.variableId === t.variableId : e.kind === "host" && t.kind === "host" : !1;
2076
+ }
2077
+ function W(e, t) {
2078
+ return e.type === t.type ? e.type === "component-visibility" && t.type === "component-visibility" ? e.operation === t.operation : e.type === "emit-host-event" && t.type === "emit-host-event" ? e.eventName === t.eventName : e.type === "host-action" && t.type === "host-action" ? e.actionId === t.actionId : !0 : !1;
2079
+ }
2080
+ function bt(e) {
2081
+ return typeof e == "object" && !!e && !Array.isArray(e);
2082
+ }
2083
+ function G(e, t) {
2084
+ return {
2085
+ severity: "error",
2086
+ code: e,
2087
+ path: [],
2088
+ message: t
2089
+ };
2090
+ }
2091
+ function xt(e, t) {
2092
+ return {
2093
+ ok: !1,
2094
+ diagnostics: [G(e, t)]
2095
+ };
2096
+ }
2097
+ function St(e, t) {
2098
+ let n = bt(e) && typeof e.commandId == "string" ? e.commandId.slice(0, 128) : "invalid-command";
2099
+ return re({
2100
+ commandId: n,
2101
+ status: "rejected",
2102
+ diagnostics: t
2103
+ });
2104
+ }
2105
+ function Ct(e) {
2106
+ return { hasBlueprintCapability: (t) => {
2107
+ try {
2108
+ return e()?.hasBlueprintCapability(t) === !0;
2109
+ } catch {
2110
+ return !1;
2111
+ }
2112
+ } };
2113
+ }
2114
+ function wt(e) {
2115
+ return e === "duplicate" ? d.blueprint.duplicateConnection : e === "source-unconnected" ? d.blueprint.sourceNodeUnconnected : e === "unconfigured" ? d.blueprint.nodeNeedsConfiguration : d.blueprint.invalidConnection;
2116
+ }
2117
+ var Tt = 256, Et = class {
2118
+ callbacks;
2119
+ #e;
2120
+ #t;
2121
+ #n = null;
2122
+ #r;
2123
+ #i = 0;
2124
+ #a = /* @__PURE__ */ new Map();
2125
+ #o = (e) => this.receive(e);
2126
+ constructor(e) {
2127
+ this.callbacks = e;
2128
+ }
2129
+ get canvas() {
2130
+ return this.#t;
2131
+ }
2132
+ get trace() {
2133
+ return this.#n;
2134
+ }
2135
+ connect(e) {
2136
+ this.#e !== e && (this.disconnect(), this.#e = e, e.addEventListener("base-screen-blueprint-canvas-command", this.#o));
2137
+ }
2138
+ disconnect() {
2139
+ this.#e?.removeEventListener(ee, this.#o), this.#e = void 0;
2140
+ }
2141
+ setCanvas(e) {
2142
+ return e !== this.#t && (this.#t = e, this.#i++, this.#a.clear(), this.#r = void 0, !0);
2143
+ }
2144
+ reset() {
2145
+ this.#n = null, this.#r = void 0, this.#a.clear();
2146
+ }
2147
+ dispatchState(e = this.callbacks.getGraph()) {
2148
+ let t = this.#t;
2149
+ if (t === void 0) return;
2150
+ let n = this.callbacks.getViewRequest(), r = re({
2151
+ generation: this.#i,
2152
+ documentRevision: this.callbacks.getDocumentRevision(),
2153
+ projectRevision: this.callbacks.getProjectRevision(),
2154
+ active: this.callbacks.getMode() === "blueprint",
2155
+ canUndo: this.callbacks.canUndo(),
2156
+ canRedo: this.callbacks.canRedo(),
2157
+ graph: e,
2158
+ selection: this.callbacks.getSelection(),
2159
+ diagnostics: this.stateDiagnostics(),
2160
+ trace: this.#n,
2161
+ ...n === void 0 ? {} : { viewRequest: n },
2162
+ ...this.#r === void 0 ? {} : { lastCommand: this.#r }
2163
+ });
2164
+ t.dispatchEvent(new CustomEvent(ie, { detail: { state: r } }));
2165
+ }
2166
+ commitBlueprint(e) {
2167
+ let t = this.callbacks.getDocument();
2168
+ if (t === void 0) return xt("AUTHORING_EXPIRED", d.lifecycle.unloaded);
2169
+ if (e === null) return xt("AUTHORING_REQUEST_INVALID", d.blueprint.invalidCommand);
2170
+ if (JSON.stringify(e) === JSON.stringify(t.blueprint)) return {
2171
+ ok: !0,
2172
+ value: t,
2173
+ diagnostics: []
2174
+ };
2175
+ let n = o({
2176
+ ...t,
2177
+ blueprint: e
2178
+ });
2179
+ if (!n.ok) return n;
2180
+ let r = ue(n.value, this.capabilities);
2181
+ return r.ok ? this.callbacks.executeCommand({
2182
+ type: "replace-blueprint",
2183
+ blueprint: n.value.blueprint
2184
+ }) : {
2185
+ ok: !1,
2186
+ diagnostics: r.diagnostics
2187
+ };
2188
+ }
2189
+ stateDiagnostics() {
2190
+ let e = this.callbacks.getDocument(), t = e === void 0 ? void 0 : ue(e, this.capabilities);
2191
+ return [...t !== void 0 && !t.ok ? t.diagnostics : [], ...this.#r?.diagnostics ?? []];
2192
+ }
2193
+ receive(e) {
2194
+ if (this.#t === void 0 || !e.composedPath().includes(this.#t)) return;
2195
+ let t = e.detail, n = bt(t) && Object.keys(t).length === 1 && "command" in t ? t.command : void 0, r = ne(n);
2196
+ if (!r.ok) {
2197
+ this.rejectUnknown(n, r.diagnostics);
2198
+ return;
2199
+ }
2200
+ let i = r.value, a = this.#a.get(i.commandId);
2201
+ if (a !== void 0) {
2202
+ this.#r = a, this.dispatchState();
2203
+ return;
2204
+ }
2205
+ if (i.generation !== this.#i || i.documentRevision !== this.callbacks.getDocumentRevision()) {
2206
+ this.finish(i.commandId, "rejected", [G("AUTHORING_EXPIRED", d.blueprint.staleCommand)]);
2207
+ return;
2208
+ }
2209
+ this.execute(i);
2210
+ }
2211
+ execute(e) {
2212
+ if (e.type === "ready") {
2213
+ this.finish(e.commandId, "accepted", []);
2214
+ return;
2215
+ }
2216
+ let t = this.callbacks.getDocument();
2217
+ if (t === void 0) {
2218
+ this.finish(e.commandId, "rejected", [G("AUTHORING_EXPIRED", d.lifecycle.unloaded)]);
2219
+ return;
2220
+ }
2221
+ let n = {
2222
+ ok: !0,
2223
+ value: null,
2224
+ diagnostics: []
2225
+ };
2226
+ switch (e.type) {
2227
+ case "select":
2228
+ n = this.callbacks.select(e.selection, !1);
2229
+ break;
2230
+ case "connect": {
2231
+ let r = ht(t, e.sourceNodeId, e.sourceHandle, e.targetNodeId, e.targetHandle, Ve(t, this.callbacks.getCatalog(), this.callbacks.getRuntimeContributions()));
2232
+ n = r.ok ? this.commitBlueprint(r.blueprint) : xt("AUTHORING_REQUEST_INVALID", wt(r.reason)), n.ok && r.ok && (n = this.callbacks.select(r.selection, !1));
2233
+ break;
2234
+ }
2235
+ case "delete-selection":
2236
+ n = this.commitBlueprint(je(t.blueprint, e.selection)), n.ok && this.callbacks.select(null, !1);
2237
+ break;
2238
+ case "insert-node": {
2239
+ let r = e.kind === "component" ? E(e.componentId) : e.kind === "variable" ? D(e.variableId) : T, i = e.kind === "component" ? ke(t, e.componentId, e.position) : e.kind === "variable" ? Ae(t, e.variableId, e.position) : A(t.blueprint, e.position);
2240
+ n = this.commitBlueprint(i), n.ok && (n = this.callbacks.select({
2241
+ kind: "node",
2242
+ id: r
2243
+ }, !1));
2244
+ break;
2245
+ }
2246
+ case "commit-layout": {
2247
+ let r = new Set(this.callbacks.getGraph().nodes.map((e) => e.id)), i = new Set(e.nodes.map((e) => e.id));
2248
+ n = r.size !== i.size || [...r].some((e) => !i.has(e)) ? xt("AUTHORING_REQUEST_INVALID", d.blueprint.staleCommand) : this.commitBlueprint(Me(t.blueprint, e.nodes, e.viewport));
2249
+ break;
2250
+ }
2251
+ case "commit-viewport":
2252
+ if ((t.blueprint.layout?.nodes.length ?? 0) === 0) break;
2253
+ n = this.commitBlueprint(Ne(t.blueprint, e.viewport));
2254
+ break;
2255
+ case "history-undo":
2256
+ n = this.callbacks.undo();
2257
+ break;
2258
+ case "history-redo":
2259
+ n = this.callbacks.redo();
2260
+ break;
2261
+ case "run-simulation": n = this.runSimulation(e.componentId, e.eventName, e.payload);
2262
+ }
2263
+ this.finish(e.commandId, n.ok ? "accepted" : "rejected", n.diagnostics);
2264
+ }
2265
+ runSimulation(e, t, r) {
2266
+ let i = this.callbacks.getDocument();
2267
+ if (i === void 0) return xt("AUTHORING_EXPIRED", d.lifecycle.unloaded);
2268
+ let a = ue(i, this.capabilities);
2269
+ if (!a.ok) return a;
2270
+ let o = le(a.value, a.value.initialVariables, {
2271
+ componentId: e,
2272
+ name: t,
2273
+ payload: r
2274
+ });
2275
+ if (!o.ok) return o;
2276
+ let s = [], c = [], l = [], u = [], f = n(i.blueprint);
2277
+ for (let e of o.value.ruleTraces) {
2278
+ if (!e.triggerMatched) continue;
2279
+ let t = f.find((t) => t.id === e.ruleId);
2280
+ if (e.condition === "failed") c.push(e.ruleId), t !== void 0 && l.push(...t.relationIds);
2281
+ else if (t !== void 0) for (let n of e.actions) {
2282
+ let e = t.relationIds[n.actionIndex];
2283
+ e !== void 0 && s.push(`relation:${e}`);
2284
+ }
2285
+ let n = e.condition === "failed" ? d.blueprint.conditionStates.failed : e.condition === "passed" ? d.blueprint.conditionStates.passed : d.blueprint.conditionStates.none;
2286
+ u.push(d.blueprint.simulationLine(e.ruleId, n, e.actions.length));
2287
+ }
2288
+ return u.length === 0 && u.push(d.blueprint.simulationEmpty), this.#n = {
2289
+ executedEdgeIds: s,
2290
+ failedRuleIds: c,
2291
+ failedRelationIds: l,
2292
+ lines: u
2293
+ }, {
2294
+ ok: !0,
2295
+ value: null,
2296
+ diagnostics: []
2297
+ };
2298
+ }
2299
+ finish(e, t, n) {
2300
+ let r = re({
2301
+ commandId: e,
2302
+ status: t,
2303
+ diagnostics: n
2304
+ });
2305
+ this.#r = r, this.#a.set(e, r), this.#a.size > Tt && this.#a.delete(this.#a.keys().next().value), this.callbacks.render(), t === "rejected" && this.callbacks.emitDiagnostics(n);
2306
+ }
2307
+ rejectUnknown(e, t) {
2308
+ this.#r = St(e, t), this.callbacks.render(), this.callbacks.emitDiagnostics(t);
2309
+ }
2310
+ get capabilities() {
2311
+ return Ct(this.callbacks.getRuntimeContributions);
2312
+ }
2313
+ };
2314
+ function K(e, t, n) {
2315
+ for (let n of e.querySelectorAll(".host-left-panel-view[data-host-left-panel-group]")) {
2316
+ let e = n.dataset.hostLeftPanelGroup === t?.id;
2317
+ n.hidden = !e, e && t !== void 0 && n.setAttribute("aria-labelledby", te(t.id));
2318
+ }
2319
+ let r = e.querySelector("[data-left-panel-count]");
2320
+ r !== null && (r.hidden = t !== void 0, t === void 0 ? (r.textContent = String(n), r.setAttribute("aria-label", d.blueprint.panelCount(d.blueprint.library, n))) : (r.textContent = "", r.removeAttribute("aria-label")));
2321
+ let i = e.querySelector("[data-left-panel-title]");
2322
+ i !== null && (i.textContent = t?.label ?? d.blueprint.library);
2323
+ let a = e.querySelector("[data-left-panel-scope]");
2324
+ a !== null && (a.textContent = t === void 0 ? d.panelScope.builtin : d.panelScope.host);
2325
+ }
2326
+ var q = new RegExp(i);
2327
+ function J(e, t) {
2328
+ let n = e.blueprint.relations.find((e) => e.id === t);
2329
+ return n?.type === "behavior" && n.source.kind === "component";
2330
+ }
2331
+ function Dt(e) {
2332
+ let t = e.split(".").map((e) => e.trim());
2333
+ return t.length === 0 || t.length > 8 || t.some((e) => e === "" || !q.test(e)) ? null : t;
2334
+ }
2335
+ function Ot(e) {
2336
+ return e.kind === "literal" ? "literal" : e.kind === "event-payload" ? e.path.length === 0 ? "event" : "event-field" : e.kind === "variable" ? "variable" : "advanced";
2337
+ }
2338
+ function kt(e, t, n) {
2339
+ let r = e.blueprint.relations.find((e) => e.id === t);
2340
+ if (r?.type !== "behavior" || r.source.kind !== "component") return [];
2341
+ let i = r.source, a = e.components.find((e) => e.id === i.componentId), o = n?.get(a?.type ?? "")?.manifest.editorDescriptor?.events?.find((e) => e.name === i.event.eventName)?.payloadSchema;
2342
+ return o === void 0 ? [] : At(o);
2343
+ }
2344
+ function At(e, t = []) {
2345
+ return Object.entries(e.properties).flatMap(([e, n]) => {
2346
+ let r = [...t, e];
2347
+ return n.kind === "object" ? [r, ...At(n, r)] : [r];
2348
+ });
2349
+ }
2350
+ var jt = [
2351
+ "eq",
2352
+ "neq",
2353
+ "gt",
2354
+ "gte",
2355
+ "lt",
2356
+ "lte",
2357
+ "contains",
2358
+ "exists"
2359
+ ];
2360
+ function Y(e, t, n, r) {
2361
+ if (e === void 0 || n === null) return Qt();
2362
+ if (n.kind === "node") {
2363
+ let r = t.nodes.find((e) => e.id === n.id);
2364
+ return r === void 0 ? Qt() : r.kind === "component" ? Mt(e, t, r) : r.kind === "variable" ? X(e, t, r) : r.kind === "host" ? Nt(e, t, r) : Qt();
2365
+ }
2366
+ let i = t.edges.find((e) => e.id === n.id);
2367
+ if (i === void 0) return Qt();
2368
+ let a = i.relationId === void 0 ? void 0 : e.blueprint.relations.find((e) => e.id === i.relationId);
2369
+ return i.kind === "semantic" && a?.type === "semantic" ? Ft(e, a) : i.kind === "relation" && a?.type === "behavior" ? Pt(e, t, a, i, r) : It(e, i);
2370
+ }
2371
+ function Mt(e, t, n) {
2372
+ let r = n.componentId ?? "", i = e.components.find((e) => e.id === r), a = t.edges.filter((e) => e.target === n.id), o = t.edges.filter((e) => e.source === n.id), s = t.edges.filter((e) => e.kind === "dependency" && e.target === n.id), c = i?.parentId ?? null, l = e.components.filter((e) => e.parentId === r), f = (n.events ?? []).map((e) => `<span data-available="${String(e.available)}"><i aria-hidden="true"></i><strong>${y(e.label)}</strong><small>${y(e.name)}</small></span>`).join("");
2373
+ return `${Wt(r, n.materialType ?? "")}
2374
+ ${Z(d.blueprint.nodeInformation, `<dl class="blueprint-inspector-facts">
2375
+ ${Q(d.blueprint.sourceComponent, i?.name ?? r)}
2376
+ ${Q(d.blueprint.nodeIdentifier, r)}
2377
+ ${Q(d.blueprint.relationCategories.structure, d.blueprint.relationCounts(n.outboundCount ?? o.length, n.inboundCount ?? a.length))}
2378
+ </dl>`)}
2379
+ ${Z(d.blueprint.outputEvents, `<div class="blueprint-port-list">${f || `<p>${d.blueprint.noEvents}</p>`}</div>`)}
2380
+ ${Z(d.blueprint.structureTitle, `<dl class="blueprint-inspector-facts">
2381
+ ${Q(d.blueprint.structure.parent, c === null ? "—" : Yt(e, c))}
2382
+ ${Q(d.blueprint.structure.children, l.length === 0 ? "—" : l.map((e) => e.name).join("、"))}
2383
+ </dl>`)}
2384
+ ${Z(d.blueprint.inputActions, Ut(e, a))}
2385
+ ${Z(d.blueprint.outputEvents, Ut(e, o))}
2386
+ ${Z(d.blueprint.linkedVariablesTitle, s.length === 0 ? `<p>${d.blueprint.linkedVariablesEmpty(0)}</p>` : `<div class="blueprint-action-summary-list">${s.map((t) => `<button type="button" class="blueprint-action-summary" data-blueprint-select-relation="${w(t.id)}"><em>${u("variable")}</em><strong>${y(Zt(e, t.source))}</strong><small>${d.blueprint.readLabel}</small></button>`).join("")}</div>`)}
2387
+ ${qt()}`;
2388
+ }
2389
+ function X(e, t, n) {
2390
+ let r = e.variables.find((e) => e.id === n.variableId);
2391
+ if (r === void 0) return Qt();
2392
+ let i = h(e, r), a = t.edges.filter((e) => e.target === n.id && e.kind === "relation"), o = t.edges.filter((e) => e.source === n.id && e.kind === "dependency"), s = i.type === "static" ? i.type : i.sourceId;
2393
+ return `${Wt(i.id, d.blueprint.variableKind[i.type])}
2394
+ ${Z(d.blueprint.variableValueTitle, `<dl class="blueprint-inspector-facts">
2395
+ ${Q(d.variables.name, i.name)}
2396
+ ${Q(d.variables.sourceId, s)}
2397
+ ${Q(d.variables.initialValue, JSON.stringify(i.initialValue))}
2398
+ ${Q(d.blueprint.variableCounts(n.writeCount ?? 0, n.readCount ?? 0), d.blueprint.relationCategories.data)}
2399
+ </dl>`)}
2400
+ ${Z(d.blueprint.inputActions, Ut(e, a))}
2401
+ ${Z(d.blueprint.linkedVariablesTitle, Ut(e, o))}
2402
+ ${Z(d.blueprint.directNodeHint, `<p>${d.blueprint.setVariableHint}</p>`)}
2403
+ ${qt()}`;
2404
+ }
2405
+ function Nt(e, t, n) {
2406
+ let r = t.edges.filter((e) => e.target === n.id && e.kind === "relation");
2407
+ return `${Wt(n.id, d.blueprint.hostNode)}
2408
+ ${Z(d.blueprint.hostNode, `<p>${d.blueprint.hostNodeHint}</p>`)}
2409
+ ${Z(d.blueprint.exitRelations, Ut(e, r))}
2410
+ ${qt()}`;
2411
+ }
2412
+ function Pt(e, t, n, i, a) {
2413
+ let o = t.nodes.find((e) => e.id === i.source), s = Zt(e, i.source), c = Zt(e, i.target);
2414
+ return `${Wt(n.id, `${d.blueprint.relationCategories[r(n)]} · ${d.blueprint.relationEffects[n.effect.type]}`)}
2415
+ ${Z(d.blueprint.relationNode.source, `<dl class="blueprint-inspector-facts">
2416
+ ${Q(d.blueprint.relationNode.sourceComponent, s)}
2417
+ ${Q(d.blueprint.relationNode.target, c)}
2418
+ </dl>
2419
+ <label class="blueprint-inspector-field"><span>${d.blueprint.relationNode.event}</span>
2420
+ <select class="designer-control designer-select" data-relation-id="${w(n.id)}" data-blueprint-source-event="true">
2421
+ ${Ht(n, o).join("")}
2422
+ </select>
2423
+ </label>`)}
2424
+ ${Lt(n)}
2425
+ ${Rt(e, n, a)}
2426
+ ${qt()}`;
2427
+ }
2428
+ function Ft(e, t) {
2429
+ return `${Wt(t.id, d.blueprint.relationCategories.semantic)}
2430
+ ${Z(d.blueprint.semanticRoleTitle, `<div class="blueprint-action-summary-list">
2431
+ <span><em>1</em><strong>${y(Yt(e, t.source.componentId))} → ${y(Yt(e, t.target.componentId))}</strong><small>${d.blueprint.selectionType.edge}</small></span>
2432
+ </div>
2433
+ <div class="blueprint-inspector-role-list" role="group" aria-label="${d.blueprint.semanticRoleTitle}">
2434
+ ${[
2435
+ "related",
2436
+ "detail",
2437
+ "group",
2438
+ "drill-down"
2439
+ ].map((e) => `<button type="button" class="designer-control designer-button" data-relation-id="${w(t.id)}" data-blueprint-semantic-role="${e}" data-active="${String(t.role === e)}">${d.blueprint.semanticRoles[e]}</button>`).join("")}
2440
+ </div>`)}
2441
+ ${Z(d.blueprint.semanticHintTitle, `<p>${d.blueprint.semanticHint}</p>`)}
2442
+ ${qt()}`;
2443
+ }
2444
+ function It(e, t) {
2445
+ let n = Zt(e, t.source), r = Zt(e, t.target), i = t.kind === "containment" ? d.blueprint.relationCategories.structure : d.blueprint.lockedDependency, a = t.kind === "containment" ? d.blueprint.relationList.containmentHint : d.blueprint.lockedDependency;
2446
+ return `${Wt(t.id, i)}
2447
+ ${Z(d.blueprint.nodeConnectionState, `<dl class="blueprint-inspector-facts">
2448
+ ${Q(d.blueprint.relationNode.source, n)}
2449
+ ${Q(d.blueprint.relationNode.target, r)}
2450
+ </dl><p>${y(a)}</p>`)}`;
2451
+ }
2452
+ function Lt(e) {
2453
+ return e.condition === void 0 ? Z(d.blueprint.conditionExpression, `<p>${d.blueprint.relationNode.noCondition}</p>
2454
+ <button type="button" class="designer-control designer-button" data-relation-id="${w(e.id)}" data-blueprint-add-condition>${d.blueprint.relationNode.addCondition}</button>`) : Z(d.blueprint.conditionExpression, `<div class="blueprint-expression-grid">
2455
+ ${Gt(d.blueprint.conditionLeft, e.condition.left)}
2456
+ ${Gt(d.blueprint.conditionRight, e.condition.right, d.blueprint.noConditionRight)}
2457
+ </div>
2458
+ <label class="blueprint-inspector-field"><span>${d.blueprint.conditionOperatorLabel}</span>
2459
+ <select class="designer-control designer-select" data-relation-id="${w(e.id)}" data-blueprint-condition-operator>
2460
+ ${jt.map((t) => `<option value="${t}"${t === e.condition?.operator ? " selected" : ""}>${d.blueprint.conditionOperator(t)}</option>`).join("")}
2461
+ </select>
2462
+ </label>
2463
+ <button type="button" class="designer-control designer-button" data-relation-id="${w(e.id)}" data-blueprint-remove-condition>${d.blueprint.relationNode.removeCondition}</button>`);
2464
+ }
2465
+ function Rt(e, t, n) {
2466
+ let r = t.effect, i = t.target.kind, a = i === "component" ? [{
2467
+ type: "component-visibility",
2468
+ label: d.blueprint.relationEffects["component-visibility"]
2469
+ }, {
2470
+ type: "request-component-data",
2471
+ label: d.blueprint.relationEffects["request-component-data"]
2472
+ }] : i === "variable" ? [{
2473
+ type: "set-variable",
2474
+ label: d.blueprint.relationEffects["set-variable"]
2475
+ }, {
2476
+ type: "request-variable",
2477
+ label: d.blueprint.relationEffects["request-variable"]
2478
+ }] : [{
2479
+ type: "emit-host-event",
2480
+ label: d.blueprint.relationEffects["emit-host-event"]
2481
+ }, ...r.type === "host-action" ? [{
2482
+ type: "host-action",
2483
+ label: d.blueprint.relationEffects["host-action"]
2484
+ }] : []];
2485
+ return Z(d.blueprint.relationNode.effect, `<div class="blueprint-inspector-role-list" role="group" aria-label="${d.blueprint.relationNode.effect}">
2486
+ ${a.map((e) => `<button type="button" class="designer-control designer-button" data-relation-id="${w(t.id)}" data-blueprint-effect-type="${e.type}" data-active="${String(r.type === e.type)}">${e.label}</button>`).join("")}
2487
+ </div>
2488
+ ${zt(e, t, n)}`);
2489
+ }
2490
+ function zt(e, t, n) {
2491
+ let r = t.effect, i = `data-relation-id="${w(t.id)}"`;
2492
+ if (r.type === "component-visibility") return `<label class="blueprint-inspector-field"><span>${d.blueprint.operation}</span>
2493
+ <select class="designer-control designer-select" data-blueprint-visibility-operation ${i}>
2494
+ ${[
2495
+ "show",
2496
+ "hide",
2497
+ "toggle"
2498
+ ].map((e) => `<option value="${e}"${e === r.operation ? " selected" : ""}>${Jt(e)}</option>`).join("")}
2499
+ </select>
2500
+ </label>
2501
+ <label class="blueprint-inspector-field"><span>${d.blueprint.transitionDuration}</span>
2502
+ <input type="number" class="designer-control designer-input" min="0" max="60000" step="10" value="${r.transition?.durationMs ?? 0}" data-blueprint-transition-duration ${i}>
2503
+ </label>`;
2504
+ if (r.type === "request-component-data" || r.type === "request-variable") {
2505
+ let n = t.target.kind === "component" ? Yt(e, t.target.componentId) : t.target.kind === "variable" ? Xt(e, t.target.variableId) : d.blueprint.hostNode;
2506
+ return `<p>${d.blueprint.relationNode.target}:${y(n)}</p>`;
2507
+ }
2508
+ if (r.type === "set-variable") {
2509
+ let a = Ot(r.value), o = kt(e, t.id, n), s = e.variables.filter((e) => t.target.kind !== "variable" || e.id !== t.target.variableId), c = J(e, t.id);
2510
+ return `<label class="blueprint-inspector-field"><span>${d.blueprint.variableId}</span>
2511
+ <input type="text" class="designer-control designer-input" value="${w(t.target.kind === "variable" ? t.target.variableId : "")}" readonly>
2512
+ </label>
2513
+ <label class="blueprint-inspector-field"><span>${d.blueprint.valueSource}</span>
2514
+ <select class="designer-control designer-select" data-blueprint-action-value-source ${i}>
2515
+ ${Bt(a, c, s.length > 0)}
2516
+ </select>
2517
+ </label>
2518
+ ${Vt(r.value, a, o, s, i)}`;
2519
+ }
2520
+ return r.type === "emit-host-event" ? `<label class="blueprint-inspector-field"><span>${d.blueprint.eventName}</span>
2521
+ <input type="text" class="designer-control designer-input" value="${w(r.eventName)}" data-blueprint-action-event ${i}>
2522
+ </label>
2523
+ <p>${d.blueprint.eventPayloadValue("")}</p>` : `<p>${y(r.actionId)}</p>`;
2524
+ }
2525
+ function Bt(e, t, n) {
2526
+ return [
2527
+ {
2528
+ value: "literal",
2529
+ label: d.blueprint.valueSources.literal
2530
+ },
2531
+ {
2532
+ value: "event",
2533
+ label: d.blueprint.valueSources.event
2534
+ },
2535
+ {
2536
+ value: "event-field",
2537
+ label: d.blueprint.valueSources.eventField,
2538
+ disabled: !t
2539
+ },
2540
+ {
2541
+ value: "variable",
2542
+ label: d.blueprint.valueSources.variable,
2543
+ disabled: !n
2544
+ }
2545
+ ].map((t) => `<option value="${t.value}"${t.value === e ? " selected" : ""}${t.disabled === !0 ? " disabled" : ""}>${t.label}</option>`).join("");
2546
+ }
2547
+ function Vt(e, t, n, r, i) {
2548
+ if (t === "literal") return `<label class="blueprint-inspector-field"><span>${d.blueprint.literalJson}</span>
2549
+ <input type="text" class="designer-control designer-input" value="${w(e.kind === "literal" ? JSON.stringify(e.value) ?? "null" : "")}" data-blueprint-action-value ${i}>
2550
+ </label>`;
2551
+ if (t === "event-field") {
2552
+ let t = e.kind === "event-payload" ? e.path : [], r = `blueprint-event-field-${i.replace(/[^A-Za-z0-9]+/g, "-")}`;
2553
+ return `<label class="blueprint-inspector-field"><span>${d.blueprint.eventField}</span>
2554
+ <input type="text" class="designer-control designer-input" value="${w(t.join("."))}" placeholder="row.city" list="${w(r)}" spellcheck="false" data-blueprint-action-event-path ${i}>
2555
+ <datalist id="${w(r)}">${n.map((e) => `<option value="${w(e.join("."))}"></option>`).join("")}</datalist>
2556
+ </label>`;
2557
+ }
2558
+ if (t === "variable") {
2559
+ let t = e.kind === "variable" ? e.variableId : "";
2560
+ return `<label class="blueprint-inspector-field"><span>${d.blueprint.sourceVariable}</span>
2561
+ <select class="designer-control designer-select" data-blueprint-action-source-variable ${i}>
2562
+ ${r.map((e) => `<option value="${w(e.id)}"${e.id === t ? " selected" : ""}>${y(e.name)}</option>`).join("")}
2563
+ </select>
2564
+ </label>`;
2565
+ }
2566
+ return "";
2567
+ }
2568
+ function Ht(e, t) {
2569
+ return e.source.kind === "variable" ? ["data-updated", "request-state"].map((t) => `<option value="${t}"${e.source.event.eventName === t ? " selected" : ""}>${t}</option>`) : (t?.events ?? []).map((t) => `<option value="${w(t.name)}"${e.source.event.eventName === t.name ? " selected" : ""}${t.available ? "" : " disabled"}>${y(t.label)}${t.available ? "" : ` · ${d.blueprint.relationNode.sourceEventUnavailable}`}</option>`);
2570
+ }
2571
+ function Ut(e, t) {
2572
+ return t.length === 0 ? `<p>${d.blueprint.noActions}</p>` : `<div class="blueprint-action-summary-list">${t.map((t) => {
2573
+ let n = Zt(e, t.source), r = Zt(e, t.target), i = t.kind === "containment" ? d.blueprint.relationList.containment : t.kind === "dependency" ? d.blueprint.readLabel : t.effectType === void 0 ? t.kind : d.blueprint.relationEffects[t.effectType];
2574
+ return `<button type="button" class="blueprint-action-summary" data-blueprint-select-relation="${w(t.id)}"><em>${u(t.kind === "containment" ? "group" : t.kind === "dependency" ? "variable" : "link")}</em><strong>${y(n)} → ${y(r)}</strong><small>${y(i)}</small></button>`;
2575
+ }).join("")}</div>`;
2576
+ }
2577
+ function Wt(e, t) {
2578
+ return Z(d.blueprint.nodeInformation, `<dl class="blueprint-inspector-facts">
2579
+ ${Q(d.blueprint.nodeIdentifier, e)}
2580
+ ${Q(d.blueprint.nodeType, t)}
2581
+ </dl>`);
2582
+ }
2583
+ function Z(e, t) {
2584
+ return `<section class="designer-panel-section blueprint-inspector-section" data-variant="header"><header><h3 class="designer-panel-section-title">${y(e)}</h3><span class="designer-panel-section-disclosure" aria-hidden="true">${u("chevron-down")}</span></header><div class="blueprint-inspector-section-content">${t}</div></section>`;
2585
+ }
2586
+ function Q(e, t) {
2587
+ return `<div><dt>${y(e)}</dt><dd>${y(t)}</dd></div>`;
2588
+ }
2589
+ function Gt(e, t, n = "") {
2590
+ return `<span><small>${y(e)}</small><strong>${y(t === void 0 ? n : Kt(t))}</strong></span>`;
2591
+ }
2592
+ function Kt(e) {
2593
+ return e.kind === "literal" ? d.blueprint.literalValue(JSON.stringify(e.value) ?? "null") : e.kind === "event-payload" ? d.blueprint.eventPayloadValue(e.path.join(".")) : e.kind === "variable" ? d.blueprint.variableValue(e.variableId) : e.kind === "array" ? d.blueprint.arrayValue(e.items.length) : d.blueprint.objectValue(Object.keys(e.properties).length);
2594
+ }
2595
+ function qt() {
2596
+ return `<button type="button" class="designer-control designer-button blueprint-delete-button" data-variant="danger" data-blueprint-delete>${d.blueprint.deleteSelection}</button>`;
2597
+ }
2598
+ function Jt(e) {
2599
+ return e === "show" ? d.blueprint.visibilityOperation.show : e === "hide" ? d.blueprint.visibilityOperation.hide : d.blueprint.visibilityOperation.toggle;
2600
+ }
2601
+ function Yt(e, t) {
2602
+ return e.components.find((e) => e.id === t)?.name ?? t;
2603
+ }
2604
+ function Xt(e, t) {
2605
+ return e.variables.find((e) => e.id === t)?.name ?? t;
2606
+ }
2607
+ function Zt(e, t) {
2608
+ if (t === "host") return d.blueprint.hostNode;
2609
+ if (t.startsWith("component:")) return Yt(e, t.slice(10));
2610
+ if (t.startsWith("variable:")) {
2611
+ let n = t.slice(9);
2612
+ return e.variables.find((e) => e.id === n)?.name ?? n;
2613
+ }
2614
+ return t;
2615
+ }
2616
+ function Qt() {
2617
+ return `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${u("sliders")}</span><p class="designer-empty-title">${d.blueprint.inspectorEmpty}</p><p class="designer-empty-hint">${d.blueprint.inspectorEmptyHint}</p></div>`;
2618
+ }
2619
+ var $t = [
2620
+ "configuration",
2621
+ "problems",
2622
+ "trace"
2623
+ ];
2624
+ function en(e, t, n, r, i, a, o, s) {
2625
+ if (e === void 0) return;
2626
+ let c = {
2627
+ configuration: r === null ? 0 : 1,
2628
+ problems: a.length,
2629
+ trace: o?.executedEdgeIds.length ?? 0
2630
+ }, l = an(t, n, r, i);
2631
+ e.innerHTML = `<div class="blueprint-inspector-shell">
2632
+ <header class="blueprint-inspector-topbar">
2633
+ <span><strong>${y(l.title)}</strong><small>${y(l.detail)}</small></span>
2634
+ <div class="blueprint-inspector-modes" role="tablist" aria-label="${d.blueprint.inspector}">
2635
+ ${$t.map((e) => on(e, i, c[e])).join("")}
2636
+ </div>
2637
+ </header>
2638
+ <div class="blueprint-panel-scroll" id="designer-blueprint-inspector-${i}-panel" role="tabpanel" aria-labelledby="designer-blueprint-inspector-${i}-tab" tabindex="0" aria-live="polite">
2639
+ ${tn(i, t, n, r, a, o, s)}
2640
+ </div>
2641
+ </div>`;
2642
+ }
2643
+ function tn(e, t, n, r, i, a, o) {
2644
+ return e === "problems" ? nn(i) : e === "trace" ? rn(a) : Y(t, n, r, o);
2645
+ }
2646
+ function nn(e) {
2647
+ let t = e.slice(0, 8);
2648
+ return t.length === 0 ? `<div class="designer-empty" data-tone="success"><span class="designer-empty-icon" aria-hidden="true">${u("check")}</span><p class="designer-empty-title">${d.blueprint.problemsHealthy}</p><p class="designer-empty-hint">${d.blueprint.problemsHealthyHint}</p></div>` : `<section class="blueprint-inspector-status" data-blueprint-problems><ul>${t.map((e) => `<li data-severity="${e.severity}"><strong>${y(e.code)}</strong><span>${y(e.message)}</span><small>${y(e.path.join(".") || "—")}</small></li>`).join("")}</ul></section>`;
2649
+ }
2650
+ function rn(e) {
2651
+ return e === null ? `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${u("terminal")}</span><p class="designer-empty-title">${d.blueprint.noTrace}</p><p class="designer-empty-hint">${d.blueprint.noTraceHint}</p></div>` : `<section class="blueprint-inspector-status" data-blueprint-trace>
2652
+ <div class="blueprint-trace-summary">${d.blueprint.traceSummary(e.executedEdgeIds.length, e.failedRuleIds.length)}</div>
2653
+ <ol>${e.lines.slice(-20).map((e) => `<li>${y(e)}</li>`).join("")}</ol>
2654
+ </section>`;
2655
+ }
2656
+ function an(e, t, n, r) {
2657
+ if (r === "problems") return {
2658
+ title: d.blueprint.problemsTitle,
2659
+ detail: d.blueprint.inspector
2660
+ };
2661
+ if (r === "trace") return {
2662
+ title: d.blueprint.traceTitle,
2663
+ detail: d.blueprint.inspector
2664
+ };
2665
+ if (n === null) return {
2666
+ title: d.blueprint.inspector,
2667
+ detail: d.blueprint.inspectorEmpty
2668
+ };
2669
+ let i = n.kind === "node" ? t.nodes.find((e) => e.id === n.id) : void 0;
2670
+ if (i?.kind === "component") return {
2671
+ title: i.componentName ?? i.componentId ?? d.blueprint.layers,
2672
+ detail: i.materialType ?? d.blueprint.selectionType.component
2673
+ };
2674
+ if (i?.kind === "host") return {
2675
+ title: d.blueprint.hostNode,
2676
+ detail: d.blueprint.hostNodeHint
2677
+ };
2678
+ if (i?.kind === "variable") return {
2679
+ title: i.variableName ?? i.variableId ?? d.blueprint.globalVariables,
2680
+ detail: i.variableType === void 0 ? d.blueprint.globalVariables : d.blueprint.variableKind[i.variableType]
2681
+ };
2682
+ let a = t.edges.find((e) => e.id === n.id);
2683
+ return {
2684
+ title: (a?.relationId === void 0 ? void 0 : e?.blueprint.relations.find((e) => e.id === a.relationId))?.id ?? a?.id ?? d.blueprint.selectionType.edge,
2685
+ detail: a?.kind === "semantic" ? d.blueprint.semanticRoles[a.semanticRole ?? "related"] : a?.kind === "containment" ? d.blueprint.relationCategories.structure : a?.kind === "dependency" ? d.blueprint.readLabel : a?.effectType === void 0 ? d.blueprint.selectionType.edge : d.blueprint.relationEffects[a.effectType]
2686
+ };
2687
+ }
2688
+ function on(e, t, n) {
2689
+ let r = d.blueprint.inspectorTabs[e];
2690
+ return `<button type="button" class="blueprint-inspector-mode" id="designer-blueprint-inspector-${e}-tab" role="tab" aria-controls="designer-blueprint-inspector-${e}-panel" aria-selected="${String(e === t)}" tabindex="${e === t ? 0 : -1}" data-blueprint-inspector-tab="${e}" data-tip="${r}" aria-label="${r}"><span aria-hidden="true">${u(e === "configuration" ? "sliders" : e === "problems" ? "check" : "terminal")}</span>${n === 0 ? "" : `<em>${n}</em>`}</button>`;
2691
+ }
2692
+ var sn = [
2693
+ "components",
2694
+ "relations",
2695
+ "variables"
2696
+ ];
2697
+ function cn(e, t, n, r, i, a, o, s) {
2698
+ if (e === void 0) return;
2699
+ let c = (s ?? []).filter((e) => oe(e, "blueprint")), l = se(o), f = c.some((e) => e.id === l) ? l : void 0, p = yn(o) ? o : "components", m = f === void 0 ? p : b(f);
2700
+ e.innerHTML = `<div class="blueprint-library-shell">
2701
+ <nav class="rail-tabs blueprint-library-rail" role="tablist" aria-orientation="vertical" aria-label="${d.blueprint.library}">
2702
+ ${sn.map((e) => _n(e, m)).join("")}
2703
+ ${c.map((e) => vn(e, f)).join("")}
2704
+ </nav>
2705
+ <section class="rail-view blueprint-library-main"${f === void 0 ? "" : " hidden"}>
2706
+ <div class="layer-panel-controls blueprint-library-controls">
2707
+ <label class="designer-field layer-search blueprint-library-search">
2708
+ <span class="layer-search-glyph" aria-hidden="true">${u("search")}</span>
2709
+ <input type="search" class="designer-control designer-input" data-blueprint-library-search value="${w(a)}" placeholder="${p === "relations" ? d.blueprint.relationList.search : d.blueprint.librarySearch}" aria-label="${p === "relations" ? d.blueprint.relationList.search : d.blueprint.librarySearch}">
2710
+ </label>
2711
+ </div>
2712
+ <div class="blueprint-panel-scroll" id="designer-blueprint-library-${p}-panel" role="tabpanel" aria-labelledby="designer-blueprint-library-${p}-tab" tabindex="0">
2713
+ ${ln(p, t, n, r, i, a)}
2714
+ </div>
2715
+ </section>
2716
+ </div>`;
2717
+ }
2718
+ function ln(e, t, n, r, i, a) {
2719
+ let o = a.trim().toLocaleLowerCase();
2720
+ return e === "components" ? un(n, r, i, o) : e === "relations" ? fn(t, n, i, o) : hn(t, n, i, o);
2721
+ }
2722
+ function un(e, t, n, r) {
2723
+ let i = new Set(e.nodes.filter((e) => e.kind === "component").map((e) => e.id)), a = t.filter((e) => e.kind === "component" && (r.length === 0 || `${e.componentName ?? ""} ${e.componentId ?? ""} ${e.materialType ?? ""}`.toLocaleLowerCase().includes(r)));
2724
+ if (a.length === 0) return Cn(d.blueprint.noComponentNodes);
2725
+ let o = new Map(a.map((e) => [e.componentId ?? "", e])), s = new Map(e.nodes.filter((e) => e.componentId !== void 0).map((e) => [e.componentId ?? "", e])), c = (e) => {
2726
+ let t = 0, n = e.parentId, r = /* @__PURE__ */ new Set();
2727
+ for (; n !== void 0 && !r.has(n);) r.add(n), t += 1, n = o.get(n)?.parentId;
2728
+ return t;
2729
+ };
2730
+ return `<section class="blueprint-palette-group" aria-label="${d.blueprint.layers}">
2731
+ <header><strong>${d.blueprint.currentCanvas}</strong><span>${a.length}</span></header>
2732
+ <div class="blueprint-palette-list">
2733
+ ${a.map((e) => dn(e, i.has(e.id), n?.kind === "node" && n.id === e.id, c(e), s.get(e.componentId ?? ""))).join("")}
2734
+ </div>
2735
+ <p class="blueprint-library-hint">${d.blueprint.componentNodeHint}</p>
2736
+ </section>`;
2737
+ }
2738
+ function dn(e, t, n, r = 0, i) {
2739
+ let a = e.componentId ?? "", o = e.componentName ?? a, s = (e.events ?? []).filter((e) => e.available).length, c = t ? `data-blueprint-select-node="${w(e.id)}"` : `data-blueprint-add-component="${w(a)}"`, l = t ? d.blueprint.locateComponent(o) : d.blueprint.addComponent(o), f = e.childCount === void 0 ? "" : ` · ${d.blueprint.structure.children} ${e.childCount}`, p = t && i !== void 0 ? `<em class="blueprint-palette-counts">${y(d.blueprint.relationCounts(i.outboundCount ?? 0, i.inboundCount ?? 0))}</em>` : "";
2740
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-depth="${r}" style="--bp-indent: ${r * 16}px" data-placed="${String(t)}" data-selected="${String(n)}"${t ? "" : ` draggable="true" data-blueprint-drag-kind="component" data-component-id="${w(a)}" data-blueprint-drag-label="${w(o)}"`}>
2741
+ <button type="button" class="blueprint-palette-primary" ${c} aria-label="${w(l)}">
2742
+ <span class="blueprint-palette-glyph" aria-hidden="true">${u("layers")}</span>
2743
+ <span><strong>${y(o)}</strong><small>${y(e.materialType ?? "")} · ${d.blueprint.componentEventCount(s)}${y(f)}</small></span>
2744
+ ${p}
2745
+ </button>
2746
+ <button type="button" class="blueprint-palette-action" ${c} data-tip="${w(l)}" aria-label="${w(l)}">${u(t ? "locate" : "plus")}</button>
2747
+ </div>`;
2748
+ }
2749
+ function fn(e, t, n, i) {
2750
+ if (e === void 0) return Cn(d.blueprint.relationList.noRelations);
2751
+ let a = /* @__PURE__ */ new Map(), o = (e, t) => {
2752
+ let n = a.get(e) ?? [];
2753
+ n.push(t), a.set(e, n);
2754
+ };
2755
+ for (let a of e.blueprint.relations) {
2756
+ let s = pn(e, t, a, n, i);
2757
+ s !== null && o(r(a), s);
2758
+ }
2759
+ for (let r of t.edges) {
2760
+ if (r.kind !== "containment") continue;
2761
+ let t = mn(e, r, n, i);
2762
+ t !== null && o("structure", t);
2763
+ }
2764
+ let s = t.nodes.find((e) => e.id === "host"), c = s === void 0 ? `<div class="designer-list-row blueprint-palette-item" data-density="default"><button type="button" class="blueprint-palette-primary" data-blueprint-insert-host aria-label="${d.blueprint.relationList.addHost}"><span class="blueprint-palette-glyph" aria-hidden="true">${u("activity")}</span><span><strong>${d.blueprint.hostNode}</strong><small>${d.blueprint.hostNodeHint}</small></span><span class="blueprint-palette-inline-add" aria-hidden="true">${u("plus")}</span></button></div>` : `<div class="designer-list-row blueprint-palette-item" data-density="default" data-placed="true" data-selected="${String(n?.kind === "node" && n.id === s.id)}"><button type="button" class="blueprint-palette-primary" data-blueprint-select-node="${s.id}" aria-label="${d.blueprint.hostNode}"><span class="blueprint-palette-glyph" aria-hidden="true">${u("activity")}</span><span><strong>${d.blueprint.hostNode}</strong><small>${d.blueprint.hostNodeHint}</small></span><em>${d.blueprint.placed}</em></button></div>`, l = `${[
2765
+ "structure",
2766
+ "interaction",
2767
+ "data",
2768
+ "exit",
2769
+ "semantic"
2770
+ ].map((e) => {
2771
+ let t = a.get(e);
2772
+ return t === void 0 || t.length === 0 ? "" : `<section class="blueprint-palette-group" aria-label="${d.blueprint.relationCategories[e]}"><header><strong>${d.blueprint.relationCategories[e]}</strong><span>${t.length}</span></header><div class="blueprint-palette-list">${t.join("")}</div></section>`;
2773
+ }).join("")}${`<section class="blueprint-palette-group" aria-label="${d.blueprint.hostNode}"><header><strong>${d.blueprint.hostNode}</strong><span>${s === void 0 ? 0 : 1}</span></header><div class="blueprint-palette-list">${c}</div></section>`}`;
2774
+ return l === "" ? Cn(d.blueprint.relationList.noRelations) : l;
2775
+ }
2776
+ function pn(e, t, n, r, i) {
2777
+ let a = n.type === "semantic" ? `semantic:${n.id}` : `relation:${n.id}`;
2778
+ if (t.edges.find((e) => e.id === a) === void 0) return null;
2779
+ let o = Sn(e, bn(n)), s = Sn(e, xn(n)), c = n.type === "semantic" ? d.blueprint.semanticRoles[n.role] : `${n.source.event.eventName} · ${d.blueprint.relationEffects[n.effect.type]}`, l = `${o} ${s} ${c} ${n.type === "behavior" && n.condition !== void 0 ? d.blueprint.conditionExpression : d.blueprint.relationNode.noCondition}`.toLocaleLowerCase();
2780
+ if (i.length > 0 && !l.includes(i)) return null;
2781
+ let f = r?.kind === "edge" && r.id === a;
2782
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-kind="relation" data-selected="${String(f)}">
2783
+ <button type="button" class="blueprint-palette-primary" data-blueprint-select-relation="${w(a)}" aria-label="${w(`${o} → ${s}`)}">
2784
+ <span class="blueprint-palette-glyph" aria-hidden="true">${u(n.type === "semantic" ? "link" : "activity")}</span>
2785
+ <span><strong>${y(o)} → ${y(s)}</strong><small>${y(c)}</small></span>
2786
+ </button>
2787
+ </div>`;
2788
+ }
2789
+ function mn(e, t, n, r) {
2790
+ let i = Sn(e, t.source), a = Sn(e, t.target), o = d.blueprint.relationList.containment, s = `${i} ${a} ${o}`.toLocaleLowerCase();
2791
+ if (r.length > 0 && !s.includes(r)) return null;
2792
+ let c = n?.kind === "edge" && n.id === t.id;
2793
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-kind="structure" data-selected="${String(c)}">
2794
+ <button type="button" class="blueprint-palette-primary" data-blueprint-select-relation="${w(t.id)}" aria-label="${w(`${i} → ${a}`)}" data-tip="${w(d.blueprint.relationList.containmentHint)}">
2795
+ <span class="blueprint-palette-glyph" aria-hidden="true">${u("group")}</span>
2796
+ <span><strong>${y(i)} → ${y(a)}</strong><small>${o}</small></span>
2797
+ <em>${d.blueprint.relationList.readOnly}</em>
2798
+ </button>
2799
+ </div>`;
2800
+ }
2801
+ function hn(e, t, n, r) {
2802
+ let i = new Set(t.nodes.filter((e) => e.kind === "variable").map((e) => e.id)), a = _(e).filter((e) => `${e.name} ${e.type} ${e.type === "static" ? JSON.stringify(e.initialValue) : e.sourceId}`.toLocaleLowerCase().includes(r));
2803
+ return a.length === 0 ? Cn(d.blueprint.noVariables) : `<div class="blueprint-palette-list">
2804
+ ${a.map((e) => gn(e, i.has(`variable:${e.id}`), n?.kind === "node" && n.id === `variable:${e.id}`)).join("")}
2805
+ </div>`;
2806
+ }
2807
+ function gn(e, t, n) {
2808
+ let r = e.type === "static" ? JSON.stringify(e.initialValue) : e.sourceId, i = t ? `data-blueprint-select-node="variable:${w(e.id)}"` : `data-blueprint-add-variable="${w(e.id)}"`, a = t ? d.blueprint.locateVariable(e.name) : d.blueprint.addVariableNode(e.name);
2809
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-kind="variable" data-placed="${String(t)}" data-selected="${String(n)}"${t ? "" : ` draggable="true" data-blueprint-drag-kind="variable" data-variable-id="${w(e.id)}" data-blueprint-drag-label="${w(e.name)}"`}>
2810
+ <button type="button" class="blueprint-palette-primary" ${i} aria-label="${w(a)}">
2811
+ <span class="blueprint-palette-glyph" aria-hidden="true">${u("variable")}</span>
2812
+ <span><strong>${y(e.name)}</strong><small>${y(d.blueprint.variableKind[e.type])} · ${y(r)}</small></span>${t ? `<em>${d.blueprint.placed}</em>` : `<span class="blueprint-palette-inline-add" aria-hidden="true">${u("plus")}</span>`}
2813
+ </button>
2814
+ </div>`;
2815
+ }
2816
+ function _n(e, t) {
2817
+ let n = d.blueprint.libraryTabs[e], r = e === "components" ? d.blueprint.layers : e === "relations" ? d.blueprint.library : d.blueprint.globalVariables;
2818
+ return `<button type="button" class="designer-tab blueprint-library-rail-tab" id="designer-blueprint-library-${e}-tab" role="tab" aria-controls="designer-blueprint-library-${e}-panel" aria-selected="${String(e === t)}" tabindex="${e === t ? 0 : -1}" data-blueprint-library-tab="${e}" data-tip="${r}" aria-label="${r}"><span class="rail-tab-glyph" aria-hidden="true">${u(e === "components" ? "layers" : e === "relations" ? "link" : "variable")}</span><span class="rail-tab-label">${n}</span></button>`;
2819
+ }
2820
+ function vn(e, t) {
2821
+ let n = e.id === t, r = b(e.id), i = w(e.label);
2822
+ return `<button type="button" class="designer-tab blueprint-library-rail-tab" id="${te(e.id)}" role="tab" aria-controls="${x(e.id)}" aria-selected="${String(n)}" tabindex="${n ? 0 : -1}" data-blueprint-library-tab="${r}" data-host-left-panel-group="${w(e.id)}" data-host-left-panel-mode="blueprint" data-tip="${i}" aria-label="${i}"><span class="rail-tab-glyph" aria-hidden="true">${u(e.icon ?? "shapes")}</span><span class="rail-tab-label">${y(e.label)}</span></button>`;
2823
+ }
2824
+ function yn(e) {
2825
+ return e === "components" || e === "relations" || e === "variables";
2826
+ }
2827
+ function bn(e) {
2828
+ return e.type === "semantic" || e.source.kind === "component" ? `component:${e.source.componentId}` : `variable:${e.source.variableId}`;
2829
+ }
2830
+ function xn(e) {
2831
+ return e.type === "semantic" || e.target.kind === "component" ? `component:${e.target.componentId}` : e.target.kind === "variable" ? `variable:${e.target.variableId}` : "host";
2832
+ }
2833
+ function Sn(e, t) {
2834
+ if (t === "host") return d.blueprint.hostNode;
2835
+ if (t.startsWith("component:")) {
2836
+ let n = t.slice(10);
2837
+ return e.components.find((e) => e.id === n)?.name ?? n;
2838
+ }
2839
+ if (t.startsWith("variable:")) {
2840
+ let n = t.slice(9);
2841
+ return e.variables.find((e) => e.id === n)?.name ?? n;
2842
+ }
2843
+ return t;
2844
+ }
2845
+ function Cn(e) {
2846
+ return `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${u("search")}</span><p class="designer-empty-title">${e}</p></div>`;
2847
+ }
2848
+ var wn = /* @__PURE__ */ new Set([
2849
+ "eq",
2850
+ "neq",
2851
+ "gt",
2852
+ "gte",
2853
+ "lt",
2854
+ "lte",
2855
+ "contains",
2856
+ "exists"
2857
+ ]);
2858
+ function Tn(e) {
2859
+ return wn.has(e);
2860
+ }
2861
+ function En(t, n, r, i) {
2862
+ let a = r.effect;
2863
+ if (t.matches("[data-blueprint-visibility-operation]")) {
2864
+ let e = t.value;
2865
+ return a.type === "component-visibility" && (e === "show" || e === "hide" || e === "toggle") ? $({
2866
+ ...a,
2867
+ operation: e
2868
+ }) : $(null);
2869
+ }
2870
+ if (t.matches("[data-blueprint-transition-duration]")) {
2871
+ let e = Number(t.value);
2872
+ return a.type !== "component-visibility" || !Number.isInteger(e) || e < 0 || e > 6e4 ? On() : $({
2873
+ ...a,
2874
+ transition: {
2875
+ effect: a.transition?.effect ?? "fade",
2876
+ durationMs: e,
2877
+ easing: a.transition?.easing ?? "ease-in-out-quad"
2878
+ }
2879
+ });
2880
+ }
2881
+ if (t.matches("[data-blueprint-action-value]")) {
2882
+ if (a.type !== "set-variable") return $(null);
2883
+ try {
2884
+ let n = e(JSON.parse(t.value));
2885
+ return n.ok ? $({
2886
+ ...a,
2887
+ value: {
2888
+ kind: "literal",
2889
+ value: n.value
2890
+ }
2891
+ }) : {
2892
+ ok: !1,
2893
+ diagnostics: n.diagnostics
2894
+ };
2895
+ } catch {
2896
+ return On("AUTHORING_SOURCE_INVALID");
2897
+ }
2898
+ }
2899
+ if (t.matches("[data-blueprint-action-value-source]")) return a.type === "set-variable" ? Dn(t.value, n, a, i, r.id) : $(null);
2900
+ if (t.matches("[data-blueprint-action-event-path]")) {
2901
+ if (a.type !== "set-variable") return $(null);
2902
+ let e = Dt(t.value);
2903
+ return e === null ? kn(d.blueprint.eventFieldInvalid) : $({
2904
+ ...a,
2905
+ value: {
2906
+ kind: "event-payload",
2907
+ path: e
2908
+ }
2909
+ });
2910
+ }
2911
+ if (t.matches("[data-blueprint-action-source-variable]")) {
2912
+ if (a.type !== "set-variable") return $(null);
2913
+ let e = t.value;
2914
+ return e !== (r.target.kind === "variable" ? r.target.variableId : void 0) && n.variables.some((t) => t.id === e) ? $({
2915
+ ...a,
2916
+ value: {
2917
+ kind: "variable",
2918
+ variableId: e
2919
+ }
2920
+ }) : On();
2921
+ }
2922
+ if (t.matches("[data-blueprint-action-event]")) {
2923
+ let e = t.value.trim();
2924
+ return a.type === "emit-host-event" && e.length > 0 && e.length <= 256 ? $({
2925
+ ...a,
2926
+ eventName: e
2927
+ }) : $(null);
2928
+ }
2929
+ return $(null);
2930
+ }
2931
+ function Dn(e, t, n, r, i) {
2932
+ if (e === "literal") return $({
2933
+ ...n,
2934
+ value: n.value.kind === "literal" ? n.value : {
2935
+ kind: "literal",
2936
+ value: null
2937
+ }
2938
+ });
2939
+ if (e === "event") return $({
2940
+ ...n,
2941
+ value: {
2942
+ kind: "event-payload",
2943
+ path: []
2944
+ }
2945
+ });
2946
+ if (e === "event-field") {
2947
+ if (n.value.kind === "event-payload" && n.value.path.length > 0) return $({
2948
+ ...n,
2949
+ value: n.value
2950
+ });
2951
+ let e = kt(t, i, r)[0];
2952
+ return $({
2953
+ ...n,
2954
+ value: {
2955
+ kind: "event-payload",
2956
+ path: e ?? ["row"]
2957
+ }
2958
+ });
2959
+ }
2960
+ if (e === "variable") {
2961
+ let e = t.blueprint.relations.find((e) => e.id === i), r = e?.type === "behavior" && e.target.kind === "variable" ? e.target.variableId : void 0, a = t.variables.find((e) => e.id !== r);
2962
+ return a === void 0 ? On() : $({
2963
+ ...n,
2964
+ value: {
2965
+ kind: "variable",
2966
+ variableId: a.id
2967
+ }
2968
+ });
2969
+ }
2970
+ return On();
2971
+ }
2972
+ function $(e) {
2973
+ return {
2974
+ ok: !0,
2975
+ value: e,
2976
+ diagnostics: []
2977
+ };
2978
+ }
2979
+ function On(e = "AUTHORING_REQUEST_INVALID") {
2980
+ return {
2981
+ ok: !1,
2982
+ diagnostics: [{
2983
+ severity: "error",
2984
+ code: e,
2985
+ path: [],
2986
+ message: d.blueprint.invalidCommand
2987
+ }]
2988
+ };
2989
+ }
2990
+ function kn(e) {
2991
+ return {
2992
+ ok: !1,
2993
+ diagnostics: [{
2994
+ severity: "error",
2995
+ code: "AUTHORING_REQUEST_INVALID",
2996
+ path: [],
2997
+ message: e
2998
+ }]
2999
+ };
3000
+ }
3001
+ function An(e, t) {
3002
+ if (e === void 0) return !1;
3003
+ if (yn(e)) return !0;
3004
+ let n = se(e);
3005
+ return n !== void 0 && t?.some((e) => e.id === n && oe(e, "blueprint")) === !0;
3006
+ }
3007
+ function jn(e) {
3008
+ return e === "configuration" || e === "problems" || e === "trace";
3009
+ }
3010
+ var Mn = class {
3011
+ callbacks;
3012
+ #e;
3013
+ #t;
3014
+ #n = "";
3015
+ #r = "components";
3016
+ #i = "configuration";
3017
+ constructor(e) {
3018
+ this.callbacks = e;
3019
+ }
3020
+ connect(e) {
3021
+ this.#e = e.querySelector("[data-blueprint-library]") ?? void 0, this.#t = e.querySelector("[data-blueprint-inspector]") ?? void 0;
3022
+ }
3023
+ release() {
3024
+ this.#e = void 0, this.#t = void 0;
3025
+ }
3026
+ reset() {
3027
+ this.#n = "", this.#r = "components", this.#i = "configuration";
3028
+ }
3029
+ get selectedLeftPanelGroupId() {
3030
+ return se(this.#r);
3031
+ }
3032
+ selectLeftPanelGroup(e) {
3033
+ let t = this.blueprintHostGroup(e);
3034
+ return t !== void 0 && (this.#r = b(t.id), this.callbacks.expandLeftPanel(), this.render(), !0);
3035
+ }
3036
+ refreshLeftPanelGroups() {
3037
+ this.reconcileLibraryTab();
3038
+ }
3039
+ render() {
3040
+ let e = this.hasLibraryTabFocus();
3041
+ this.reconcileLibraryTab();
3042
+ let t = this.callbacks.getDocument(), n = this.callbacks.getGraph(), r = this.callbacks.getComponentLibrary(), i = this.callbacks.getSelection();
3043
+ cn(this.#e, t, n, r, i, this.#n, this.#r, this.callbacks.getLeftPanelGroups()), en(this.#t, t, n, i, this.#i, this.callbacks.getDiagnostics(), this.callbacks.getTrace(), this.callbacks.getCatalog()), this.#e !== void 0 && v(this.#e), this.#t !== void 0 && v(this.#t), this.callbacks.getMode() === "blueprint" && this.#e !== void 0 && (K(this.#e.getRootNode(), this.blueprintHostGroup(this.selectedLeftPanelGroupId), r.length), this.callbacks.onActiveLeftPanelGroupChange()), e && this.#e?.querySelector(`[data-blueprint-library-tab="${this.#r}"]`)?.focus();
3044
+ }
3045
+ onClick(e) {
3046
+ let t = e.closest("[data-blueprint-library-tab]")?.dataset.blueprintLibraryTab;
3047
+ if (An(t, this.callbacks.getLeftPanelGroups())) return this.#r = t, this.callbacks.expandLeftPanel(), this.render(), this.#e?.querySelector(`[data-blueprint-library-tab="${t}"]`)?.focus(), !0;
3048
+ let n = e.closest("[data-blueprint-inspector-tab]")?.dataset.blueprintInspectorTab;
3049
+ if (jn(n)) return this.#i = n, this.render(), this.#t?.querySelector(`[data-blueprint-inspector-tab="${n}"]`)?.focus(), !0;
3050
+ let r = e.closest("[data-blueprint-select-node]")?.dataset.blueprintSelectNode;
3051
+ if (r !== void 0) return this.callbacks.select({
3052
+ kind: "node",
3053
+ id: r
3054
+ }, !0), !0;
3055
+ let i = e.closest("[data-blueprint-add-component]")?.dataset.blueprintAddComponent;
3056
+ if (i !== void 0) {
3057
+ let e = this.callbacks.getDocument(), t = E(i);
3058
+ if (this.callbacks.getGraph().nodes.some((e) => e.id === t)) return this.callbacks.select({
3059
+ kind: "node",
3060
+ id: t
3061
+ }, !0), !0;
3062
+ let n = this.callbacks.commitBlueprint(e === void 0 ? null : ke(e, i));
3063
+ return n.ok && this.callbacks.select({
3064
+ kind: "node",
3065
+ id: t
3066
+ }, !0), this.report(n), !0;
3067
+ }
3068
+ let a = e.closest("[data-blueprint-add-variable]")?.dataset.blueprintAddVariable;
3069
+ if (a !== void 0) {
3070
+ let e = this.callbacks.getDocument(), t = D(a);
3071
+ if (this.callbacks.getGraph().nodes.some((e) => e.id === t)) return this.callbacks.select({
3072
+ kind: "node",
3073
+ id: t
3074
+ }, !0), !0;
3075
+ let n = this.callbacks.commitBlueprint(e === void 0 ? null : Ae(e, a));
3076
+ return n.ok && this.callbacks.select({
3077
+ kind: "node",
3078
+ id: t
3079
+ }, !0), this.report(n), !0;
3080
+ }
3081
+ if (e.closest("[data-blueprint-insert-host]") !== null) {
3082
+ let e = this.callbacks.getDocument();
3083
+ if (e !== void 0) {
3084
+ let t = this.callbacks.commitBlueprint(A(e.blueprint));
3085
+ t.ok && this.callbacks.select({
3086
+ kind: "node",
3087
+ id: T
3088
+ }, !0), this.report(t);
3089
+ }
3090
+ return !0;
3091
+ }
3092
+ let o = e.closest("[data-blueprint-effect-type]");
3093
+ if (o !== null) {
3094
+ let e = o.dataset.relationId, t = this.callbacks.getDocument();
3095
+ if (e !== void 0 && t !== void 0) {
3096
+ let n = t.blueprint.relations.find((t) => t.id === e);
3097
+ if (n?.type === "behavior") {
3098
+ let r = Nn(o.dataset.blueprintEffectType, n.target.kind);
3099
+ r !== null && this.report(this.callbacks.commitBlueprint(j(t.blueprint, e, r)));
3100
+ }
3101
+ }
3102
+ return !0;
3103
+ }
3104
+ let s = e.closest("[data-blueprint-semantic-role]");
3105
+ if (s !== null) {
3106
+ let e = s.dataset.relationId, t = s.dataset.blueprintSemanticRole, n = this.callbacks.getDocument();
3107
+ return e !== void 0 && n !== void 0 && (t === "related" || t === "detail" || t === "group" || t === "drill-down") && this.report(this.callbacks.commitBlueprint(Le(n.blueprint, e, t))), !0;
3108
+ }
3109
+ let c = e.closest("[data-blueprint-add-condition]");
3110
+ if (c !== null) {
3111
+ let e = c.dataset.relationId, t = this.callbacks.getDocument();
3112
+ return e !== void 0 && t !== void 0 && this.report(this.callbacks.commitBlueprint(Pe(t.blueprint, e, {
3113
+ left: {
3114
+ kind: "event-payload",
3115
+ path: []
3116
+ },
3117
+ operator: "exists"
3118
+ }))), !0;
3119
+ }
3120
+ let l = e.closest("[data-blueprint-remove-condition]");
3121
+ if (l !== null) {
3122
+ let e = l.dataset.relationId, t = this.callbacks.getDocument();
3123
+ return e !== void 0 && t !== void 0 && this.report(this.callbacks.commitBlueprint(Fe(t.blueprint, e))), !0;
3124
+ }
3125
+ let u = e.closest("[data-blueprint-select-relation]");
3126
+ if (u !== null) {
3127
+ let e = u.dataset.blueprintSelectRelation;
3128
+ return e !== void 0 && this.callbacks.select({
3129
+ kind: "edge",
3130
+ id: e
3131
+ }, !0), !0;
3132
+ }
3133
+ if (e.closest("[data-blueprint-delete]") !== null) {
3134
+ let e = this.callbacks.getDocument(), t = this.callbacks.getSelection(), n = this.callbacks.commitBlueprint(e === void 0 || t === null ? null : je(e.blueprint, t));
3135
+ return n.ok && this.callbacks.select(null, !1), this.report(n), !0;
3136
+ }
3137
+ return !1;
3138
+ }
3139
+ onDragStart(e) {
3140
+ let t = (e.target instanceof Element ? e.target : null)?.closest("[data-blueprint-drag-kind]"), n = e.dataTransfer;
3141
+ if (t == null || n === null) return !1;
3142
+ let r = t.dataset.blueprintDragKind, i;
3143
+ return r === "component" && t.dataset.componentId !== void 0 ? i = {
3144
+ kind: r,
3145
+ componentId: t.dataset.componentId
3146
+ } : r === "variable" && t.dataset.variableId !== void 0 && (i = {
3147
+ kind: r,
3148
+ variableId: t.dataset.variableId
3149
+ }), i !== void 0 && (n.effectAllowed = "copy", n.setData("application/x-base-screen-blueprint-node", JSON.stringify(i)), n.setData("text/plain", t.dataset.blueprintDragLabel ?? i.kind), !0);
3150
+ }
3151
+ onKeyDown(e) {
3152
+ let t = e.target?.closest("[data-blueprint-library-tab], [data-blueprint-inspector-tab]");
3153
+ if (t == null || ![
3154
+ "ArrowLeft",
3155
+ "ArrowRight",
3156
+ "ArrowUp",
3157
+ "ArrowDown",
3158
+ "Home",
3159
+ "End"
3160
+ ].includes(e.key)) return !1;
3161
+ e.preventDefault();
3162
+ let n = t.dataset.blueprintLibraryTab === void 0 ? "[data-blueprint-inspector-tab]" : "[data-blueprint-library-tab]", r = [...(t.dataset.blueprintLibraryTab === void 0 ? this.#t : this.#e)?.querySelectorAll(n) ?? []];
3163
+ if (r.length === 0) return !0;
3164
+ let i = r.indexOf(t);
3165
+ return (e.key === "Home" ? r[0] : e.key === "End" ? r.at(-1) : r[(i + (e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : -1) + r.length) % r.length])?.click(), !0;
3166
+ }
3167
+ onInput(e) {
3168
+ let t = e.closest("[data-blueprint-library-search]");
3169
+ if (t === null) return !1;
3170
+ this.#n = t.value, this.render();
3171
+ let n = this.#e?.querySelector("[data-blueprint-library-search]");
3172
+ return n?.focus(), n?.setSelectionRange(n.value.length, n.value.length), !0;
3173
+ }
3174
+ onChange(e) {
3175
+ let t = e.dataset.relationId;
3176
+ if (t === void 0) return !1;
3177
+ let n = this.callbacks.getDocument();
3178
+ if (n === void 0) return !0;
3179
+ let r = n.blueprint.relations.find((e) => e.id === t);
3180
+ if (r === void 0) return !0;
3181
+ if (e.dataset.blueprintSourceEvent !== void 0) return this.report(this.callbacks.commitBlueprint(Ie(n.blueprint, t, e.value))), !0;
3182
+ if (e.matches("[data-blueprint-condition-operator]")) {
3183
+ let i = e.value;
3184
+ return this.report(this.callbacks.commitBlueprint(r.type !== "behavior" || r.condition === void 0 || !Tn(i) ? null : Pe(n.blueprint, t, {
3185
+ ...r.condition,
3186
+ operator: i
3187
+ }))), !0;
3188
+ }
3189
+ if (r.type !== "behavior") return !0;
3190
+ let i = En(e, n, r, this.callbacks.getCatalog());
3191
+ return i.ok ? (i.value !== null && this.report(this.callbacks.commitBlueprint(j(n.blueprint, t, i.value))), !0) : (this.callbacks.emitDiagnostics(i.diagnostics), !0);
3192
+ }
3193
+ report(e) {
3194
+ e.ok || this.callbacks.emitDiagnostics(e.diagnostics);
3195
+ }
3196
+ reconcileLibraryTab() {
3197
+ let e = this.selectedLeftPanelGroupId;
3198
+ e !== void 0 && this.blueprintHostGroup(e) === void 0 && (this.#r = "components");
3199
+ }
3200
+ hasLibraryTabFocus() {
3201
+ return (this.#e?.getRootNode())?.activeElement?.closest("[data-blueprint-library-tab]") != null;
3202
+ }
3203
+ blueprintHostGroup(e) {
3204
+ if (e !== void 0) return this.callbacks.getLeftPanelGroups()?.find((t) => t.id === e && oe(t, "blueprint"));
3205
+ }
3206
+ };
3207
+ function Nn(e, t) {
3208
+ return e === void 0 ? null : t === "component" ? e === "component-visibility" ? {
3209
+ type: "component-visibility",
3210
+ operation: "show",
3211
+ transition: {
3212
+ effect: "fade",
3213
+ durationMs: 200,
3214
+ easing: "ease-in-out-quad"
3215
+ }
3216
+ } : e === "request-component-data" ? { type: "request-component-data" } : null : t === "variable" ? e === "set-variable" ? {
3217
+ type: "set-variable",
3218
+ value: {
3219
+ kind: "literal",
3220
+ value: null
3221
+ }
3222
+ } : e === "request-variable" ? { type: "request-variable" } : null : e === "emit-host-event" ? {
3223
+ type: "emit-host-event",
3224
+ eventName: "host_event",
3225
+ payload: {
3226
+ kind: "event-payload",
3227
+ path: []
3228
+ }
3229
+ } : null;
3230
+ }
3231
+ var Pn = class {
3232
+ callbacks;
3233
+ #e;
3234
+ #t;
3235
+ #n;
3236
+ #r;
3237
+ #i = "canvas";
3238
+ #a = null;
3239
+ #o;
3240
+ #s = 0;
3241
+ #c;
3242
+ #l;
3243
+ #u = () => this.resolveCanvas();
3244
+ constructor(e) {
3245
+ this.callbacks = e, this.#c = new Et({
3246
+ getDocument: e.getDocument,
3247
+ getGraph: () => this.graph,
3248
+ getMode: () => this.#i,
3249
+ getSelection: () => this.#a,
3250
+ getViewRequest: () => this.#o,
3251
+ getCatalog: e.getCatalog,
3252
+ getRuntimeContributions: e.getRuntimeContributions,
3253
+ getDocumentRevision: e.getDocumentRevision,
3254
+ getProjectRevision: e.getProjectRevision,
3255
+ canUndo: e.canUndo,
3256
+ canRedo: e.canRedo,
3257
+ select: (e, t) => this.select(e, t),
3258
+ executeCommand: e.executeCommand,
3259
+ undo: e.undo,
3260
+ redo: e.redo,
3261
+ render: () => this.render(),
3262
+ emitDiagnostics: e.emitDiagnostics
3263
+ }), this.#l = new Mn({
3264
+ getDocument: e.getDocument,
3265
+ getGraph: () => this.graph,
3266
+ getCatalog: e.getCatalog,
3267
+ getComponentLibrary: () => this.componentLibrary,
3268
+ getSelection: () => this.#a,
3269
+ getDiagnostics: () => this.#c.stateDiagnostics(),
3270
+ getTrace: () => this.#c.trace,
3271
+ getLeftPanelGroups: e.getLeftPanelGroups,
3272
+ getMode: () => this.#i,
3273
+ select: (t, n) => {
3274
+ let r = this.select(t, n);
3275
+ r.ok || e.emitDiagnostics(r.diagnostics);
3276
+ },
3277
+ commitBlueprint: (e) => this.#c.commitBlueprint(e),
3278
+ expandLeftPanel: e.expandLeftPanel,
3279
+ onActiveLeftPanelGroupChange: e.onActiveLeftPanelGroupChange,
3280
+ emitDiagnostics: e.emitDiagnostics
3281
+ });
3282
+ }
3283
+ get mode() {
3284
+ return this.#i;
3285
+ }
3286
+ get available() {
3287
+ return this.#c.canvas !== void 0;
3288
+ }
3289
+ get selectedLeftPanelGroupId() {
3290
+ return this.#l.selectedLeftPanelGroupId;
3291
+ }
3292
+ setInitialMode(e) {
3293
+ this.#i = e;
3294
+ }
3295
+ connect(e) {
3296
+ if (this.#e === e) {
3297
+ this.bindSlot(e.querySelector("[data-blueprint-canvas-slot]") ?? void 0), this.#n = e.querySelector("[data-blueprint-default-canvas]") ?? void 0, this.mountDefaultCanvas(), this.#l.connect(e), this.resolveCanvas(), this.render();
3298
+ return;
3299
+ }
3300
+ this.disconnect(), this.#e = e, this.bindSlot(e.querySelector("[data-blueprint-canvas-slot]") ?? void 0), this.#n = e.querySelector("[data-blueprint-default-canvas]") ?? void 0, this.mountDefaultCanvas(), this.#l.connect(e), this.#c.connect(this.callbacks.getHost()), this.resolveCanvas(), this.render();
3301
+ }
3302
+ bindSlot(e) {
3303
+ this.#t !== e && (this.#t?.removeEventListener("slotchange", this.#u), this.#t = e, this.#t?.addEventListener("slotchange", this.#u));
3304
+ }
3305
+ disconnect() {
3306
+ this.#t?.removeEventListener("slotchange", this.#u), this.#c.disconnect(), this.#l.release(), this.#r?.destroy(), this.#r?.element.remove(), this.#r = void 0, this.#n = void 0, this.#e = void 0, this.#t = void 0;
3307
+ }
3308
+ addVariableNode(e) {
3309
+ let t = this.callbacks.getDocument();
3310
+ if (t === void 0) return;
3311
+ let n = Ae(t, e);
3312
+ if (n !== null) {
3313
+ let e = this.callbacks.executeCommand({
3314
+ type: "replace-blueprint",
3315
+ blueprint: n
3316
+ });
3317
+ if (!e.ok) {
3318
+ this.callbacks.emitDiagnostics(e.diagnostics);
3319
+ return;
3320
+ }
3321
+ }
3322
+ this.setMode("blueprint", { focus: {
3323
+ kind: "variable",
3324
+ id: e
3325
+ } });
3326
+ }
3327
+ resetSession() {
3328
+ this.#a = null, this.#o = void 0, this.#l.reset(), this.#c.reset(), this.render();
3329
+ }
3330
+ selectLeftPanelGroup(e) {
3331
+ return this.#i === "blueprint" && this.#l.selectLeftPanelGroup(e);
3332
+ }
3333
+ refreshLeftPanelGroups() {
3334
+ this.#l.refreshLeftPanelGroups(), this.render();
3335
+ }
3336
+ setMode(e, t = {}, n = "api") {
3337
+ let r = C(e, t);
3338
+ if (!r.ok) return r;
3339
+ if (e === "blueprint" && !this.available) return Ln("BLUEPRINT_CAPABILITY_UNAVAILABLE", d.blueprint.noHostCanvas);
3340
+ if (t.focus !== void 0) {
3341
+ let e = this.resolveFocus(t.focus);
3342
+ if (e === void 0) return Ln("AUTHORING_REQUEST_INVALID", d.blueprint.invalidSelection);
3343
+ this.#a = {
3344
+ kind: this.graphHasEdge(e) ? "edge" : "node",
3345
+ id: e
3346
+ }, this.#o = {
3347
+ id: ++this.#s,
3348
+ type: "focus",
3349
+ targetId: e
3350
+ };
3351
+ }
3352
+ let i = this.#i;
3353
+ return this.#i = e, this.render(), i !== e && this.emitModeChange(i, e, n), In(null);
3354
+ }
3355
+ render() {
3356
+ let e = this.graph;
3357
+ this.reconcileSelection(e), this.renderChrome(), this.callbacks.setWorkbenchAuthoringMode(this.#i), this.#l.render(), this.#c.dispatchState(e), this.callbacks.onActiveLeftPanelGroupChange();
3358
+ }
3359
+ dispatchState() {
3360
+ this.#c.dispatchState();
3361
+ }
3362
+ onClick(e) {
3363
+ let t = e.closest("[data-workbench-mode-tab]");
3364
+ if (t !== null) {
3365
+ let e = t.dataset.workbenchModeTab;
3366
+ if (e === "canvas" || e === "blueprint") {
3367
+ let t = this.setMode(e, {}, "user");
3368
+ t.ok || this.callbacks.emitDiagnostics(t.diagnostics);
3369
+ }
3370
+ return !0;
3371
+ }
3372
+ let n = e.closest("[data-blueprint-search-id]")?.dataset.blueprintSearchId;
3373
+ if (n !== void 0) {
3374
+ let e = this.select({
3375
+ kind: this.graphHasEdge(n) ? "edge" : "node",
3376
+ id: n
3377
+ }, !0);
3378
+ e.ok || this.callbacks.emitDiagnostics(e.diagnostics);
3379
+ let t = this.setMode("blueprint", {}, "user");
3380
+ return t.ok || this.callbacks.emitDiagnostics(t.diagnostics), !0;
3381
+ }
3382
+ return this.#l.onClick(e);
3383
+ }
3384
+ onInput(e) {
3385
+ return this.#l.onInput(e);
3386
+ }
3387
+ onChange(e) {
3388
+ return this.#l.onChange(e);
3389
+ }
3390
+ onDragStart(e) {
3391
+ return this.#l.onDragStart(e);
3392
+ }
3393
+ onKeyDown(e) {
3394
+ if (this.#l.onKeyDown(e)) return !0;
3395
+ let t = e.target?.closest("[data-workbench-mode-tab]");
3396
+ if (t == null || ![
3397
+ "ArrowLeft",
3398
+ "ArrowRight",
3399
+ "Home",
3400
+ "End"
3401
+ ].includes(e.key)) return !1;
3402
+ e.preventDefault();
3403
+ let n = [...this.#e?.querySelectorAll("[data-workbench-mode-tab]:not(:disabled)") ?? []];
3404
+ if (n.length === 0) return !0;
3405
+ let r = n.indexOf(t), i = e.key === "Home" ? n[0] : e.key === "End" ? n.at(-1) : n[(r + (e.key === "ArrowRight" ? 1 : -1) + n.length) % n.length];
3406
+ return i?.focus(), i?.click(), !0;
3407
+ }
3408
+ get graph() {
3409
+ let e = this.callbacks.getDocument();
3410
+ return e === void 0 ? {
3411
+ nodes: [],
3412
+ edges: []
3413
+ } : P(e, this.callbacks.getCatalog(), this.callbacks.getRuntimeContributions());
3414
+ }
3415
+ get componentLibrary() {
3416
+ let e = this.callbacks.getDocument();
3417
+ return e === void 0 ? [] : He(e, this.callbacks.getCatalog(), this.callbacks.getRuntimeContributions());
3418
+ }
3419
+ mountDefaultCanvas() {
3420
+ if (this.#r !== void 0 || this.#n === void 0) return;
3421
+ let e = ut(this.#n.ownerDocument);
3422
+ this.#n.append(e.element), this.#r = e;
3423
+ }
3424
+ resolveCanvas() {
3425
+ let e = this.#t?.assignedElements({ flatten: !0 })[0], t = this.#r?.element;
3426
+ t !== void 0 && (t.hidden = e !== void 0), this.#n !== void 0 && (this.#n.hidden = e !== void 0);
3427
+ let n = e ?? t, r = this.#c.canvas;
3428
+ if (!this.#c.setCanvas(n)) {
3429
+ n === void 0 && this.#i === "blueprint" ? this.fallbackToCanvas(!1) : (this.renderChrome(), this.#c.dispatchState());
3430
+ return;
3431
+ }
3432
+ if (n === void 0 && this.#i === "blueprint") {
3433
+ this.fallbackToCanvas(r !== void 0);
3434
+ return;
3435
+ }
3436
+ this.render();
3437
+ }
3438
+ fallbackToCanvas(e) {
3439
+ let t = this.#i;
3440
+ this.#i = "canvas", this.render(), this.emitModeChange(t, "canvas", "fallback"), e && this.callbacks.emitDiagnostics([Fn("BLUEPRINT_CAPABILITY_UNAVAILABLE", d.blueprint.noHostCanvas)]);
3441
+ }
3442
+ select(e, t) {
3443
+ return e !== null && !(e.kind === "node" ? this.graph.nodes.some((t) => t.id === e.id) : this.graph.edges.some((t) => t.id === e.id)) ? Ln("AUTHORING_REQUEST_INVALID", d.blueprint.invalidSelection) : (this.#a = e, t && e !== null && (this.#o = {
3444
+ id: ++this.#s,
3445
+ type: "focus",
3446
+ targetId: e.id
3447
+ }), this.render(), In(null));
3448
+ }
3449
+ reconcileSelection(e) {
3450
+ this.#a !== null && ((this.#a.kind === "node" ? e.nodes.some((e) => e.id === this.#a?.id) : e.edges.some((e) => e.id === this.#a?.id)) || (this.#a = null));
3451
+ }
3452
+ resolveFocus(e) {
3453
+ let t = this.graph;
3454
+ if (e.kind === "component") {
3455
+ let n = `component:${e.id}`;
3456
+ return t.nodes.some((e) => e.id === n) ? n : void 0;
3457
+ }
3458
+ if (e.kind === "variable") {
3459
+ let n = `variable:${e.id}`;
3460
+ return t.nodes.some((e) => e.id === n) ? n : void 0;
3461
+ }
3462
+ if (e.kind === "relation") return t.edges.find((t) => t.relationId === e.id)?.id ?? (this.graphHasEdge(e.id) ? e.id : void 0);
3463
+ if (e.kind === "rule") return t.edges.find((t) => t.relationId === e.id)?.id;
3464
+ if (t.nodes.some((t) => t.id === e.id) || this.graphHasEdge(e.id)) return e.id;
3465
+ }
3466
+ graphHasEdge(e) {
3467
+ return this.graph.edges.some((t) => t.id === e);
3468
+ }
3469
+ renderChrome() {
3470
+ let e = this.#e;
3471
+ if (e === void 0) return;
3472
+ let t = this.callbacks.getDocument(), n = this.#c.stateDiagnostics().filter((e) => e.severity === "error").length, r = t?.blueprint.relations ?? [];
3473
+ ft(e, this.#i, this.available, {
3474
+ nodes: this.componentLibrary.length,
3475
+ relations: r.length,
3476
+ semantic: r.filter((e) => e.type === "semantic").length,
3477
+ structural: t?.components.filter((e) => e.parentId !== null).length ?? 0,
3478
+ problems: n
3479
+ });
3480
+ }
3481
+ emitModeChange(e, t, n) {
3482
+ this.callbacks.getHost().dispatchEvent(new CustomEvent(ce, {
3483
+ bubbles: !0,
3484
+ composed: !0,
3485
+ detail: {
3486
+ previousMode: e,
3487
+ mode: t,
3488
+ reason: n
3489
+ }
3490
+ }));
3491
+ }
3492
+ };
3493
+ function Fn(e, t) {
3494
+ return {
3495
+ severity: "error",
3496
+ code: e,
3497
+ path: [],
3498
+ message: t
3499
+ };
3500
+ }
3501
+ function In(e) {
3502
+ return {
3503
+ ok: !0,
3504
+ value: e,
3505
+ diagnostics: []
3506
+ };
3507
+ }
3508
+ function Ln(e, t) {
3509
+ return {
3510
+ ok: !1,
3511
+ diagnostics: [Fn(e, t)]
3512
+ };
3513
+ }
3514
+ //#endregion
3515
+ export { Pn as DesignerBlueprintWorkbenchPanel };
3516
+
3517
+ //# sourceMappingURL=designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js.map