@nodish/core 0.0.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 (61) hide show
  1. package/dist/pack.d.ts +326 -0
  2. package/dist/pack.js +43 -0
  3. package/dist/src/components/AddNodePanel.vue.d.ts +20 -0
  4. package/dist/src/components/GraphInterfacePanel.vue.d.ts +13 -0
  5. package/dist/src/components/GraphNode.vue.d.ts +26 -0
  6. package/dist/src/components/GroupPanel.vue.d.ts +13 -0
  7. package/dist/src/components/InspectorPanel.vue.d.ts +43 -0
  8. package/dist/src/components/NodePanel.vue.d.ts +18 -0
  9. package/dist/src/components/NodePort.vue.d.ts +21 -0
  10. package/dist/src/components/NodeViewer.vue.d.ts +14 -0
  11. package/dist/src/components/WireLayer.vue.d.ts +8 -0
  12. package/dist/src/components/inspector/InspectorCheckboxField.vue.d.ts +10 -0
  13. package/dist/src/components/inspector/InspectorColorField.vue.d.ts +12 -0
  14. package/dist/src/components/inspector/InspectorError.vue.d.ts +5 -0
  15. package/dist/src/components/inspector/InspectorPositionField.vue.d.ts +12 -0
  16. package/dist/src/components/inspector/InspectorSection.vue.d.ts +24 -0
  17. package/dist/src/components/inspector/InspectorWidthField.vue.d.ts +12 -0
  18. package/dist/src/components/layout.d.ts +26 -0
  19. package/dist/src/components/types/NumberWidget.vue.d.ts +15 -0
  20. package/dist/src/components/types/PortValueWidget.vue.d.ts +17 -0
  21. package/dist/src/components/types/ReadonlyWidget.vue.d.ts +9 -0
  22. package/dist/src/components/types/TextWidget.vue.d.ts +15 -0
  23. package/dist/src/components/types/registerDefaultTypeWidgets.d.ts +6 -0
  24. package/dist/src/components/types/registry.d.ts +13 -0
  25. package/dist/src/pack/index.d.ts +5 -0
  26. package/dist/src/store/composite/editContext.d.ts +14 -0
  27. package/dist/src/store/composite/guards.d.ts +7 -0
  28. package/dist/src/store/composite/index.d.ts +12 -0
  29. package/dist/src/store/graph/connect.d.ts +8 -0
  30. package/dist/src/store/graph/createNodeMap.d.ts +22 -0
  31. package/dist/src/store/graph/document.d.ts +25 -0
  32. package/dist/src/store/graph/dynamicPorts.d.ts +9 -0
  33. package/dist/src/store/graph/evaluate.d.ts +18 -0
  34. package/dist/src/store/graph/expandIO.d.ts +2 -0
  35. package/dist/src/store/graph/instance.d.ts +7 -0
  36. package/dist/src/store/graph/pruneConnections.d.ts +2 -0
  37. package/dist/src/store/graph/removeNode.d.ts +3 -0
  38. package/dist/src/store/graph/stacking.d.ts +5 -0
  39. package/dist/src/store/graph/validateGraphTypes.d.ts +2 -0
  40. package/dist/src/store/interface/editor.d.ts +5 -0
  41. package/dist/src/store/interface/graphInterface.d.ts +20 -0
  42. package/dist/src/store/model.d.ts +241 -0
  43. package/dist/src/store/nodes/index.d.ts +2 -0
  44. package/dist/src/store/nodes/io.d.ts +46 -0
  45. package/dist/src/store/nodes/math.d.ts +4 -0
  46. package/dist/src/store/packs/core.d.ts +3 -0
  47. package/dist/src/store/packs/installPack.d.ts +4 -0
  48. package/dist/src/store/registry/defineNode.d.ts +50 -0
  49. package/dist/src/store/registry/defineType.d.ts +31 -0
  50. package/dist/src/store/registry/groups.d.ts +9 -0
  51. package/dist/src/store/registry/index.d.ts +39 -0
  52. package/dist/src/store/types/effectiveWidget.d.ts +4 -0
  53. package/dist/src/store/types/index.d.ts +4 -0
  54. package/dist/src/store/utils/clonePlain.d.ts +1 -0
  55. package/dist/src/vue/attachLoadPack.d.ts +2 -0
  56. package/dist/src/vue/createNodeMap.d.ts +11 -0
  57. package/dist/src/vue/index.d.ts +10 -0
  58. package/dist/vue.css +1 -0
  59. package/dist/vue.js +2487 -0
  60. package/package.json +43 -0
  61. package/readme.md +14 -0
package/dist/vue.js ADDED
@@ -0,0 +1,2487 @@
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, nextTick as c, normalizeClass as l, normalizeStyle as u, onMounted as d, onUnmounted as f, openBlock as p, ref as m, renderList as h, renderSlot as g, resolveDynamicComponent as _, toDisplayString as v, unref as y, useCssVars as b, vModelText as x, watch as ee, withCtx as S, withDirectives as C, withModifiers as w } from "vue";
2
+ import './vue.css';//#region src/store/graph/pruneConnections.ts
3
+ function T(e, t) {
4
+ e.graph.connections = e.graph.connections.filter((e) => !(e.from.node === t.id && !t.outputs[e.from.port] || e.to.node === t.id && !t.inputs[e.to.port]));
5
+ }
6
+ //#endregion
7
+ //#region src/store/graph/dynamicPorts.ts
8
+ function E(e, t) {
9
+ return e.resolvePorts ? e.resolvePorts(t) : {
10
+ inputs: e.inputs,
11
+ outputs: e.outputs
12
+ };
13
+ }
14
+ function D(e) {
15
+ let t = {};
16
+ for (let n of Object.values(e.inputs)) n.userOnly && (t[n.name] = n.value);
17
+ return t;
18
+ }
19
+ function O(e) {
20
+ let t = {};
21
+ for (let n of Object.values(e.inputs)) n.userOnly && (t[n.name] = n.defaultValue);
22
+ return t;
23
+ }
24
+ function k(e, t, n) {
25
+ let r = {};
26
+ for (let t of Object.values(e)) r[t.name] = t;
27
+ let i = {};
28
+ for (let e of Object.values(t)) {
29
+ let t = r[e.name];
30
+ if (t) t.type = e.type, t.userOnly = e.userOnly, t.multi = e.multi, t.customProps = e.customProps, i[t.id] = t;
31
+ else {
32
+ let t = crypto.randomUUID();
33
+ i[t] = {
34
+ id: t,
35
+ name: e.name,
36
+ type: e.type,
37
+ direction: n,
38
+ value: void 0,
39
+ userOnly: e.userOnly,
40
+ multi: e.multi,
41
+ customProps: e.customProps
42
+ };
43
+ }
44
+ }
45
+ return i;
46
+ }
47
+ function A(e, t) {
48
+ let n = e.nodeTypes[t.typeId];
49
+ if (!n?.resolvePorts) return;
50
+ let r = E(n, D(t));
51
+ t.inputs = k(t.inputs, r.inputs, "input"), t.outputs = k(t.outputs, r.outputs, "output"), T(e, t);
52
+ }
53
+ //#endregion
54
+ //#region src/store/graph/expandIO.ts
55
+ function j(e) {
56
+ let t = {};
57
+ for (let [n, r] of Object.entries(e ?? {})) t[n] = {
58
+ name: n,
59
+ ...r
60
+ };
61
+ return t;
62
+ }
63
+ //#endregion
64
+ //#region src/store/model.ts
65
+ var M = {
66
+ parameters: {
67
+ a: {
68
+ type: "number",
69
+ defaultValue: 0
70
+ },
71
+ b: {
72
+ type: "number",
73
+ defaultValue: 0
74
+ }
75
+ },
76
+ returns: { result: { type: "number" } }
77
+ };
78
+ //#endregion
79
+ //#region src/store/registry/defineNode.ts
80
+ function N(e) {
81
+ return {
82
+ typeId: e.typeId,
83
+ displayName: e.displayName,
84
+ color: e.color ?? "#3a3f4b",
85
+ description: e.description ?? "",
86
+ group: e.group ?? [],
87
+ inputs: j(e.inputs),
88
+ outputs: j(e.outputs),
89
+ execute: e.execute,
90
+ graph: e.graph,
91
+ resolvePorts: e.resolvePorts ? (t) => {
92
+ let n = e.resolvePorts(t);
93
+ return {
94
+ inputs: j(n.inputs),
95
+ outputs: j(n.outputs)
96
+ };
97
+ } : void 0
98
+ };
99
+ }
100
+ //#endregion
101
+ //#region src/store/registry/index.ts
102
+ function P(e, t) {
103
+ Object.assign(e.types, t);
104
+ }
105
+ function F(e, t) {
106
+ for (let [n, r] of Object.entries(t)) e.nodeTypes[n] = N(r);
107
+ }
108
+ function I(e, t) {
109
+ t.types && P(e, t.types), t.nodeTypes && F(e, t.nodeTypes), e.extensions.includes(t.id) || e.extensions.push(t.id);
110
+ }
111
+ //#endregion
112
+ //#region src/store/graph/instance.ts
113
+ function L(e, t) {
114
+ let n = {};
115
+ for (let r of Object.values(e)) {
116
+ let e = crypto.randomUUID();
117
+ n[e] = {
118
+ id: e,
119
+ name: r.name,
120
+ type: r.type,
121
+ direction: t,
122
+ value: r.userOnly ? r.defaultValue : void 0,
123
+ userOnly: r.userOnly,
124
+ multi: r.multi,
125
+ customProps: r.customProps
126
+ };
127
+ }
128
+ return n;
129
+ }
130
+ function R(e, t) {
131
+ let { inputs: n, outputs: r } = E(e, O(e));
132
+ return {
133
+ id: crypto.randomUUID(),
134
+ typeId: e.typeId,
135
+ location: t,
136
+ inputs: L(n, "input"),
137
+ outputs: L(r, "output")
138
+ };
139
+ }
140
+ //#endregion
141
+ //#region src/store/utils/clonePlain.ts
142
+ function z(e) {
143
+ return JSON.parse(JSON.stringify(e));
144
+ }
145
+ //#endregion
146
+ //#region src/store/interface/graphInterface.ts
147
+ var te = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
148
+ function B(e, t) {
149
+ let n = [], r = (t, r) => {
150
+ let i = /* @__PURE__ */ new Set();
151
+ for (let [a, o] of Object.entries(t ?? {})) te.test(a) || n.push(`${r}: invalid port name "${a}"`), i.has(a) && n.push(`${r}: duplicate port name "${a}"`), i.add(a), e.types[o.type] || n.push(`${r}: unknown type "${o.type}" on port "${a}"`);
152
+ };
153
+ return r(t.parameters, "parameters"), r(t.returns, "returns"), n;
154
+ }
155
+ //#endregion
156
+ //#region src/store/nodes/io.ts
157
+ var V = "io/input", H = "io/output", ne = {
158
+ input: {
159
+ x: 40,
160
+ y: 120
161
+ },
162
+ output: {
163
+ x: 480,
164
+ y: 130
165
+ }
166
+ };
167
+ function re(e = {}) {
168
+ return {
169
+ input: {
170
+ typeId: V,
171
+ displayName: "Input",
172
+ color: "#7a5a3a",
173
+ description: "Graph inputs (function parameters).",
174
+ group: ["graph"],
175
+ outputs: e.parameters
176
+ },
177
+ output: {
178
+ typeId: H,
179
+ displayName: "Output",
180
+ color: "#7a3a5a",
181
+ description: "Graph outputs (function return values).",
182
+ group: ["graph"],
183
+ inputs: e.returns
184
+ }
185
+ };
186
+ }
187
+ function ie(e, t) {
188
+ e.graphInterface = t;
189
+ let n = re(t);
190
+ F(e, {
191
+ [n.input.typeId]: n.input,
192
+ [n.output.typeId]: n.output
193
+ });
194
+ }
195
+ function ae(e) {
196
+ let t = e.graph.nodes.filter((e) => e.typeId === V), n = e.graph.nodes.filter((e) => e.typeId === H);
197
+ if (t.length !== 1 || n.length !== 1) throw Error(`graph must have exactly one Input and one Output node (found ${t.length} input, ${n.length} output)`);
198
+ return {
199
+ input: t[0],
200
+ output: n[0]
201
+ };
202
+ }
203
+ function oe(e, t = ne) {
204
+ let n = e.graph.nodes.filter((e) => e.typeId === V), r = e.graph.nodes.filter((e) => e.typeId === H);
205
+ if (n.length > 1 || r.length > 1) throw Error(`graph must have exactly one Input and one Output node (found ${n.length} input, ${r.length} output)`);
206
+ let i = n[0], a = r[0], o = re(e.graphInterface);
207
+ return i || (i = R(N(o.input), t.input), e.graph.nodes.push(i)), a || (a = R(N(o.output), t.output), e.graph.nodes.push(a)), {
208
+ input: i,
209
+ output: a
210
+ };
211
+ }
212
+ function U(e, t) {
213
+ let n = B(e, t);
214
+ if (n.length) return n;
215
+ ie(e, t);
216
+ let { input: r, output: i } = ae(e);
217
+ r.outputs = k(r.outputs, j(t.parameters), "output");
218
+ for (let n of Object.values(r.outputs)) {
219
+ let r = t.parameters?.[n.name];
220
+ if (!r) continue;
221
+ let i = e.types[r.type];
222
+ r.defaultValue === void 0 ? i && !i.validate(n.value) && (n.value = i.defaultValue) : n.value = r.defaultValue;
223
+ }
224
+ return i.inputs = k(i.inputs, j(t.returns), "input"), T(e, r), T(e, i), [];
225
+ }
226
+ function se(e) {
227
+ let t = [], n = e.graph.nodes.filter((e) => e.typeId === V).length, r = e.graph.nodes.filter((e) => e.typeId === H).length;
228
+ return n === 0 ? t.push("graph has no Input node") : n > 1 && t.push("graph has multiple Input nodes"), r === 0 ? t.push("graph has no Output node") : r > 1 && t.push("graph has multiple Output nodes"), t;
229
+ }
230
+ //#endregion
231
+ //#region src/store/composite/index.ts
232
+ var W = "composite/group", ce = {
233
+ typeId: W,
234
+ displayName: "Group",
235
+ color: "#4a5a6a",
236
+ description: "A nested subgraph with its own inputs and outputs.",
237
+ group: ["Custom nodes"]
238
+ };
239
+ function G(e, t) {
240
+ let n = t.composite;
241
+ if (!n) throw Error("node has no composite state");
242
+ let r = {
243
+ graph: n.graph,
244
+ graphInterface: n.interface,
245
+ types: e.types,
246
+ nodeTypes: { ...e.nodeTypes },
247
+ extensions: e.extensions,
248
+ loadPack: (t) => e.loadPack(t)
249
+ };
250
+ return ie(r, n.interface), r;
251
+ }
252
+ function le(e, t) {
253
+ let n = t.composite?.interface ?? M;
254
+ t.inputs = k(t.inputs, j(n.parameters), "input"), t.outputs = k(t.outputs, j(n.returns), "output"), T(e, t);
255
+ }
256
+ function ue(e, t, n = {}) {
257
+ let r = U(e, t);
258
+ if (r.length) return r;
259
+ let i = n.ownerComposite;
260
+ return i?.composite && n.parentMap ? (i.composite.interface = t, le(n.parentMap, i)) : e.graphInterface = t, [];
261
+ }
262
+ function de(e) {
263
+ let t = {};
264
+ return {
265
+ inputs: k(t, j(e.parameters), "input"),
266
+ outputs: k(t, j(e.returns), "output")
267
+ };
268
+ }
269
+ function fe(e, t) {
270
+ let n = {
271
+ graph: {
272
+ nodes: [],
273
+ connections: []
274
+ },
275
+ graphInterface: z(t),
276
+ types: e.types,
277
+ nodeTypes: { ...e.nodeTypes },
278
+ extensions: e.extensions,
279
+ loadPack: (t) => e.loadPack(t)
280
+ };
281
+ return ie(n, n.graphInterface), oe(n, ne), {
282
+ graph: z(n.graph),
283
+ interface: z(n.graphInterface)
284
+ };
285
+ }
286
+ function pe(e, t) {
287
+ e.nodeTypes["composite/group"] || F(e, { [W]: ce });
288
+ let n = z(M), r = fe(e, n), { inputs: i, outputs: a } = de(n);
289
+ return {
290
+ id: crypto.randomUUID(),
291
+ typeId: W,
292
+ location: t,
293
+ inputs: i,
294
+ outputs: a,
295
+ composite: r
296
+ };
297
+ }
298
+ function me(e) {
299
+ return e.typeId === "composite/group" && !!e.composite;
300
+ }
301
+ //#endregion
302
+ //#region src/store/graph/evaluate.ts
303
+ function K(e) {
304
+ return e instanceof Error ? e.message : String(e);
305
+ }
306
+ function he(e, t = {}) {
307
+ let n = {};
308
+ for (let t of e.graph.nodes) n[t.id] = t;
309
+ let r = /* @__PURE__ */ new Map();
310
+ for (let t of e.graph.connections) {
311
+ let e = `${t.to.node}:${t.to.port}`, n = r.get(e);
312
+ n ? n.push(t.from) : r.set(e, [t.from]);
313
+ }
314
+ let i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = {};
315
+ function s(e, t) {
316
+ e.id in o || (o[e.id] = K(t));
317
+ }
318
+ function c(e) {
319
+ let t = n[e.node], r = t?.outputs[e.port];
320
+ return r ? u(t)[r.name] : void 0;
321
+ }
322
+ function l(t, n = {}) {
323
+ let i = n.useDefaults !== !1, a = {};
324
+ for (let n of Object.values(t.inputs)) {
325
+ let o = r.get(`${t.id}:${n.id}`) ?? [];
326
+ if (n.multi) a[n.name] = o.map(c);
327
+ else if (o.length) a[n.name] = c(o[0]);
328
+ else {
329
+ let t = n.value;
330
+ t === void 0 && i && (t = e.types[n.type]?.defaultValue);
331
+ let r = e.types[n.type];
332
+ t !== void 0 && r?.coerce && (t = r.coerce(t)), a[n.name] = t;
333
+ }
334
+ }
335
+ return a;
336
+ }
337
+ function u(n) {
338
+ let r = i.get(n.id);
339
+ if (r) return r;
340
+ if (a.has(n.id)) return s(n, /* @__PURE__ */ Error("Cycle detected")), {};
341
+ a.add(n.id);
342
+ let o;
343
+ if (n.typeId === "io/input") {
344
+ o = {};
345
+ for (let e of Object.values(n.outputs)) o[e.name] = e.name in t ? t[e.name] : e.value;
346
+ } else if (me(n)) {
347
+ let t = he(G(e, n), l(n));
348
+ for (let e of Object.values(t.errors)) {
349
+ s(n, Error(e));
350
+ break;
351
+ }
352
+ o = t.values;
353
+ } else {
354
+ let t = e.nodeTypes[n.typeId];
355
+ if (t?.execute) try {
356
+ o = t.execute(l(n));
357
+ } catch (e) {
358
+ s(n, e), o = {};
359
+ }
360
+ else o = {};
361
+ }
362
+ return a.delete(n.id), i.set(n.id, o), o;
363
+ }
364
+ let d = e.graph.nodes.find((e) => e.typeId === H);
365
+ return {
366
+ values: d ? l(d, { useDefaults: !1 }) : {},
367
+ errors: o
368
+ };
369
+ }
370
+ //#endregion
371
+ //#region src/store/graph/connect.ts
372
+ function ge(e, t, n) {
373
+ let r = e.types[n];
374
+ return r && r.accepts ? r.accepts(t) : t === n;
375
+ }
376
+ function _e(e, t) {
377
+ let n = /* @__PURE__ */ new Map();
378
+ for (let t of e.graph.connections) {
379
+ let e = n.get(t.to.node) ?? [];
380
+ e.push(t.from.node), n.set(t.to.node, e);
381
+ }
382
+ let r = /* @__PURE__ */ new Set(), i = [...n.get(t) ?? []];
383
+ for (; i.length;) {
384
+ let e = i.pop();
385
+ if (!r.has(e)) {
386
+ r.add(e);
387
+ for (let t of n.get(e) ?? []) i.push(t);
388
+ }
389
+ }
390
+ return [...r];
391
+ }
392
+ function ve(e, t) {
393
+ let n = /* @__PURE__ */ new Map();
394
+ for (let t of e.graph.connections) {
395
+ let e = n.get(t.from.node) ?? [];
396
+ e.push(t.to.node), n.set(t.from.node, e);
397
+ }
398
+ let r = /* @__PURE__ */ new Set(), i = [...n.get(t) ?? []];
399
+ for (; i.length;) {
400
+ let e = i.pop();
401
+ if (!r.has(e)) {
402
+ r.add(e);
403
+ for (let t of n.get(e) ?? []) i.push(t);
404
+ }
405
+ }
406
+ return [...r];
407
+ }
408
+ function q(e, t, n) {
409
+ return ve(e, n.node).includes(t.node);
410
+ }
411
+ function ye(e, t, n) {
412
+ if (t.node === n.node) return !1;
413
+ let r = e.graph.nodes.find((e) => e.id === t.node), i = e.graph.nodes.find((e) => e.id === n.node), a = r?.outputs[t.port], o = i?.inputs[n.port];
414
+ return !a || !o || o.userOnly || q(e, t, n) ? !1 : ge(e, a.type, o.type);
415
+ }
416
+ function be(e, t, n) {
417
+ if (!ye(e, t, n)) return null;
418
+ let r = e.graph.connections.find((e) => e.from.node === t.node && e.from.port === t.port && e.to.node === n.node && e.to.port === n.port);
419
+ if (r) return r;
420
+ e.graph.nodes.find((e) => e.id === n.node)?.inputs[n.port]?.multi || (e.graph.connections = e.graph.connections.filter((e) => !(e.to.node === n.node && e.to.port === n.port)));
421
+ let i = {
422
+ id: crypto.randomUUID(),
423
+ from: t,
424
+ to: n
425
+ };
426
+ return e.graph.connections.push(i), i;
427
+ }
428
+ function xe(e, t) {
429
+ e.graph.connections = e.graph.connections.filter((e) => e.id !== t);
430
+ }
431
+ //#endregion
432
+ //#region src/store/graph/removeNode.ts
433
+ function Se(e, t) {
434
+ let n = e.graph.nodes.find((e) => e.id === t);
435
+ return n ? n.typeId !== "io/input" && n.typeId !== "io/output" : !1;
436
+ }
437
+ function Ce(e, t) {
438
+ Se(e, t) && (e.graph.nodes = e.graph.nodes.filter((e) => e.id !== t), e.graph.connections = e.graph.connections.filter((e) => e.from.node !== t && e.to.node !== t));
439
+ }
440
+ //#endregion
441
+ //#region src/store/graph/stacking.ts
442
+ function we(e) {
443
+ let t = 0;
444
+ for (let n of e.graph.nodes) t = Math.max(t, n.z ?? 0);
445
+ return t;
446
+ }
447
+ function Te(e) {
448
+ e.graph.nodes.map((e, t) => ({
449
+ n: e,
450
+ i: t
451
+ })).sort((e, t) => (e.n.z ?? 0) - (t.n.z ?? 0) || e.i - t.i).forEach((e, t) => {
452
+ e.n.z = t + 1;
453
+ });
454
+ }
455
+ function Ee(e) {
456
+ if (e.graph.nodes.length === 0) return;
457
+ let t = !1;
458
+ for (let n of e.graph.nodes) n.z === void 0 && (n.z = Math.random(), t = !0);
459
+ t && Te(e);
460
+ }
461
+ function De(e, t) {
462
+ let n = e.graph.nodes.find((e) => e.id === t);
463
+ if (!n) return;
464
+ let r = we(e);
465
+ (n.z ?? 0) >= r || (n.z = r + 1);
466
+ }
467
+ //#endregion
468
+ //#region src/store/composite/editContext.ts
469
+ function J(e, t, n) {
470
+ let r = e;
471
+ for (let i = 0; i <= n; i++) {
472
+ let a = t[i];
473
+ if (!a) return null;
474
+ let o = r.graph.nodes.find((e) => e.id === a.compositeNodeId);
475
+ if (!o) return null;
476
+ if (i === n) return o;
477
+ if (!o.composite) return null;
478
+ r = G(e, o);
479
+ }
480
+ return null;
481
+ }
482
+ function Oe(e, t) {
483
+ return t.length ? J(e, t, t.length - 1) : null;
484
+ }
485
+ function ke(e, t) {
486
+ if (!t.length) return { activeMap: e };
487
+ let n = e, r;
488
+ for (let i = 0; i < t.length; i++) {
489
+ let a = t[i];
490
+ if (r = n.graph.nodes.find((e) => e.id === a.compositeNodeId), !r?.composite) return { activeMap: e };
491
+ i < t.length - 1 && (n = G(e, r));
492
+ }
493
+ return {
494
+ activeMap: G(e, r),
495
+ interfaceOptions: {
496
+ ownerComposite: r,
497
+ parentMap: n
498
+ }
499
+ };
500
+ }
501
+ //#endregion
502
+ //#region src/store/interface/editor.ts
503
+ function Ae(e, t) {
504
+ if (!t.length) return e.graphInterface;
505
+ let n = Oe(e, t);
506
+ return n?.composite ? n.composite.interface : e.graphInterface;
507
+ }
508
+ function je(e, t, n) {
509
+ let r = Ae(e, t);
510
+ n(r);
511
+ let i = ke(e, t);
512
+ return ue(i.activeMap, r, i.interfaceOptions ?? {});
513
+ }
514
+ //#endregion
515
+ //#region src/store/composite/guards.ts
516
+ function Y(e, t, n) {
517
+ for (let r of e.nodes) if (r.id === t || n && r.composite?.graph && Y(r.composite.graph, t, !0)) return !0;
518
+ return !1;
519
+ }
520
+ function Me(e) {
521
+ return e.map((e) => e.compositeNodeId);
522
+ }
523
+ function Ne(e, t) {
524
+ let n = new Set(Me(t)), r = Oe(e, t);
525
+ return r && n.add(r.id), n;
526
+ }
527
+ function Pe(e, t, n) {
528
+ for (let r of Ne(e, t)) if (Y(n, r, !0)) return "A group cannot be placed inside itself";
529
+ return null;
530
+ }
531
+ function Fe(e, t, n) {
532
+ if (!me(n)) return "Not a group node";
533
+ if (t.some((e) => e.compositeNodeId === n.id)) return "Already editing this group";
534
+ let r = Ne(e, t);
535
+ if (r.add(n.id), n.composite?.graph) {
536
+ for (let e of r) if (Y(n.composite.graph, e, !0)) return "Cannot open a group that contains an ancestor";
537
+ }
538
+ return null;
539
+ }
540
+ function Ie(e, t, n, r) {
541
+ if (!me(n) || !n.composite) return null;
542
+ let i = Ne(e, t);
543
+ if (i.has(n.id)) return "A group cannot be placed inside itself";
544
+ for (let e of i) if (Y(r, e, !1)) return "A group cannot be placed inside itself";
545
+ for (let r = 0; r < t.length; r++) {
546
+ let i = J(e, t, r);
547
+ if (i?.composite?.graph === n.composite.graph) return "A group cannot share the same interior as an ancestor";
548
+ if (i && n.composite.graph === i.composite?.graph) return "A group cannot be placed inside itself";
549
+ }
550
+ if (Y(n.composite.graph, n.id, !0)) return "A group cannot contain itself";
551
+ for (let e of i) if (Y(n.composite.graph, e, !0)) return "A group cannot contain an ancestor";
552
+ let a = Oe(e, t);
553
+ return a?.composite && n.composite.graph === a.composite.graph ? "A group cannot be placed inside itself" : Pe(e, t, r);
554
+ }
555
+ //#endregion
556
+ //#region src/store/types/effectiveWidget.ts
557
+ function X(e, t) {
558
+ let n = e?.[t];
559
+ return typeof n == "number" ? n : void 0;
560
+ }
561
+ function Le(e, t) {
562
+ let n = e?.widget, r = t.customProps;
563
+ if (!(!n && !r)) return n ? n.kind === "number" ? {
564
+ kind: "number",
565
+ min: X(r, "min") ?? n.min,
566
+ max: X(r, "max") ?? n.max,
567
+ step: X(r, "step") ?? n.step,
568
+ rowHeight: X(r, "rowHeight") ?? n.rowHeight
569
+ } : n.kind === "text" ? {
570
+ kind: "text",
571
+ rows: X(r, "rows") ?? n.rows,
572
+ rowHeight: X(r, "rowHeight") ?? n.rowHeight
573
+ } : {
574
+ kind: "custom",
575
+ componentId: n.componentId,
576
+ rowHeight: X(r, "rowHeight") ?? n.rowHeight
577
+ } : r?.min !== void 0 || r?.max !== void 0 || X(r, "rowHeight") !== void 0 ? {
578
+ kind: "number",
579
+ min: X(r, "min"),
580
+ max: X(r, "max"),
581
+ step: X(r, "step"),
582
+ rowHeight: X(r, "rowHeight")
583
+ } : X(r, "rows") !== void 0 || X(r, "rowHeight") !== void 0 ? {
584
+ kind: "text",
585
+ rows: X(r, "rows"),
586
+ rowHeight: X(r, "rowHeight")
587
+ } : void 0;
588
+ }
589
+ function Re(e, t) {
590
+ return e ? e.rowHeight === void 0 ? e.kind === "text" ? (e.rows ?? 1) * t : t : e.rowHeight : t;
591
+ }
592
+ //#endregion
593
+ //#region src/components/types/NumberWidget.vue?vue&type=script&setup=true&lang.ts
594
+ var ze = [
595
+ "value",
596
+ "placeholder",
597
+ "title",
598
+ "min",
599
+ "max",
600
+ "step"
601
+ ], Be = /*@__PURE__*/ s({
602
+ __name: "NumberWidget",
603
+ props: {
604
+ port: {},
605
+ typeDef: {},
606
+ effectiveWidget: {},
607
+ placeholder: {}
608
+ },
609
+ emits: ["update:value", "commit"],
610
+ setup(e, { emit: n }) {
611
+ let r = e, a = n, o = r.effectiveWidget?.kind === "number" ? r.effectiveWidget : { kind: "number" }, s = t(() => {
612
+ let e = r.port.value;
613
+ return e != null && e !== "" ? e : "";
614
+ });
615
+ function c(e) {
616
+ let t = e.target.value;
617
+ a("update:value", r.typeDef?.parse?.(t) ?? Number(t));
618
+ }
619
+ function l(e) {
620
+ let t = e.target.value, n = r.typeDef?.parse?.(t) ?? Number(t);
621
+ if (r.typeDef?.coerce) n = r.typeDef.coerce(n);
622
+ else if (o.kind === "number") {
623
+ let e = o.min, t = o.max, r = Number(n);
624
+ Number.isNaN(r) && (r = 0), e !== void 0 && (r = Math.max(e, r)), t !== void 0 && (r = Math.min(t, r)), n = r;
625
+ }
626
+ a("update:value", n), a("commit");
627
+ }
628
+ return (t, n) => (p(), i("input", {
629
+ class: "field",
630
+ type: "number",
631
+ value: s.value,
632
+ placeholder: e.placeholder,
633
+ title: e.port.name,
634
+ min: y(o).kind === "number" ? y(o).min : void 0,
635
+ max: y(o).kind === "number" ? y(o).max : void 0,
636
+ step: y(o).kind === "number" ? y(o).step : void 0,
637
+ onInput: c,
638
+ onChange: l,
639
+ onPointerdown: n[0] ||= w(() => {}, ["stop"])
640
+ }, null, 40, ze));
641
+ }
642
+ }), Z = (e, t) => {
643
+ let n = e.__vccOpts || e;
644
+ for (let [e, r] of t) n[e] = r;
645
+ return n;
646
+ }, Q = /*#__PURE__*/ Z(Be, [["__scopeId", "data-v-4459e34d"]]), Ve = ["title"], He = /*#__PURE__*/ Z(/* @__PURE__ */ s({
647
+ __name: "ReadonlyWidget",
648
+ props: {
649
+ port: {},
650
+ typeDef: {},
651
+ effectiveWidget: {},
652
+ displayValue: {}
653
+ },
654
+ setup(e) {
655
+ let n = e, r = t(() => {
656
+ let e = n.displayValue === void 0 ? n.port.value : n.displayValue;
657
+ return e == null || e === "" ? "—" : n.typeDef?.format ? n.typeDef.format(e) : String(e);
658
+ });
659
+ return (t, n) => (p(), i("span", {
660
+ class: "field readonly",
661
+ title: e.port.name
662
+ }, v(r.value), 9, Ve));
663
+ }
664
+ }), [["__scopeId", "data-v-0d93d0ea"]]), Ue = [
665
+ "value",
666
+ "placeholder",
667
+ "title",
668
+ "rows"
669
+ ], We = [
670
+ "value",
671
+ "placeholder",
672
+ "title"
673
+ ], $ = /*#__PURE__*/ Z(/* @__PURE__ */ s({
674
+ __name: "TextWidget",
675
+ props: {
676
+ port: {},
677
+ typeDef: {},
678
+ effectiveWidget: {},
679
+ placeholder: {}
680
+ },
681
+ emits: ["update:value", "commit"],
682
+ setup(e, { emit: n }) {
683
+ let r = e, a = n, o = t(() => {
684
+ let e = r.port.value;
685
+ return e != null && e !== "" ? String(e) : "";
686
+ }), s = t(() => r.effectiveWidget?.kind === "text" && (r.effectiveWidget.rows ?? 1) > 1), c = t(() => r.effectiveWidget?.kind === "text" ? r.effectiveWidget.rows ?? 1 : 1);
687
+ function l(e) {
688
+ let t = e.target.value;
689
+ a("update:value", r.typeDef?.parse?.(t) ?? t);
690
+ }
691
+ function u(e) {
692
+ l(e), a("commit");
693
+ }
694
+ return (t, n) => s.value ? (p(), i("textarea", {
695
+ key: 0,
696
+ class: "field multiline",
697
+ value: o.value,
698
+ placeholder: e.placeholder,
699
+ title: e.port.name,
700
+ rows: c.value,
701
+ onInput: l,
702
+ onChange: u,
703
+ onPointerdown: n[0] ||= w(() => {}, ["stop"])
704
+ }, null, 40, Ue)) : (p(), i("input", {
705
+ key: 1,
706
+ class: "field",
707
+ type: "text",
708
+ value: o.value,
709
+ placeholder: e.placeholder,
710
+ title: e.port.name,
711
+ onInput: l,
712
+ onChange: u,
713
+ onPointerdown: n[1] ||= w(() => {}, ["stop"])
714
+ }, null, 40, We));
715
+ }
716
+ }), [["__scopeId", "data-v-bf7ff881"]]), Ge = /* @__PURE__ */ new Map(), Ke = /* @__PURE__ */ new Map(), qe = {
717
+ number: Q,
718
+ text: $,
719
+ custom: $
720
+ };
721
+ function Je(e, t) {
722
+ Ge.set(e, t);
723
+ }
724
+ function Ye(e, t) {
725
+ Ke.set(e, t);
726
+ }
727
+ function Xe(e, t, n) {
728
+ return n === "readonly" ? He : e && Ge.has(e.id) ? Ge.get(e.id) : t?.kind === "custom" ? Ke.get(t.componentId) ?? $ : t?.kind ? qe[t.kind] ?? $ : $;
729
+ }
730
+ //#endregion
731
+ //#region src/components/types/PortValueWidget.vue
732
+ var Ze = /*#__PURE__*/ Z(/* @__PURE__ */ s({
733
+ __name: "PortValueWidget",
734
+ props: {
735
+ port: {},
736
+ typeDef: {},
737
+ effectiveWidget: {},
738
+ mode: {},
739
+ displayValue: {},
740
+ placeholder: {}
741
+ },
742
+ emits: ["update:value", "commit"],
743
+ setup(e, { emit: t }) {
744
+ let r = e, i = t, a = Xe(r.typeDef, r.effectiveWidget, r.mode);
745
+ return (t, r) => (p(), n(_(y(a)), {
746
+ class: "field-widget",
747
+ port: e.port,
748
+ "type-def": e.typeDef,
749
+ "effective-widget": e.effectiveWidget,
750
+ "display-value": e.displayValue,
751
+ placeholder: e.placeholder,
752
+ "onUpdate:value": r[0] ||= (e) => i("update:value", e),
753
+ onCommit: r[1] ||= (e) => i("commit")
754
+ }, null, 40, [
755
+ "port",
756
+ "type-def",
757
+ "effective-widget",
758
+ "display-value",
759
+ "placeholder"
760
+ ]));
761
+ }
762
+ }), [["__scopeId", "data-v-975cb236"]]);
763
+ function Qe(e) {
764
+ return Math.max(20, Math.min(240, e));
765
+ }
766
+ function $e(e, t) {
767
+ let n = e.customProps?.rowHeight;
768
+ return Qe(typeof n == "number" && n > 0 ? n : Re(Le(t, e), 20));
769
+ }
770
+ function et(e, t) {
771
+ let n = 0;
772
+ for (let r of e) n += $e(r, t?.(r));
773
+ return n;
774
+ }
775
+ function tt(e) {
776
+ return e.width ?? 100;
777
+ }
778
+ function nt(e, t) {
779
+ let n = et(Object.values(e.inputs), t), r = et(Object.values(e.outputs), t);
780
+ return 20 + Math.max(n, r);
781
+ }
782
+ function rt(e, t, n) {
783
+ let r = 20;
784
+ for (let i of e) {
785
+ let e = $e(i, n?.(i));
786
+ if (i.id === t) return r + e / 2;
787
+ r += e;
788
+ }
789
+ return null;
790
+ }
791
+ function it(e, t, n) {
792
+ let r = rt(Object.values(e.inputs), t, n);
793
+ if (r !== null) return {
794
+ x: e.location.x,
795
+ y: e.location.y + r
796
+ };
797
+ let i = rt(Object.values(e.outputs), t, n);
798
+ return i === null ? null : {
799
+ x: e.location.x + tt(e),
800
+ y: e.location.y + i
801
+ };
802
+ }
803
+ function at(e, t) {
804
+ let n = Math.max(40, Math.abs(t.x - e.x) * .5);
805
+ return [{
806
+ x: e.x + n,
807
+ y: e.y
808
+ }, {
809
+ x: t.x - n,
810
+ y: t.y
811
+ }];
812
+ }
813
+ function ot(e, t) {
814
+ let [n, r] = at(e, t);
815
+ return `M ${e.x} ${e.y} C ${n.x} ${n.y}, ${r.x} ${r.y}, ${t.x} ${t.y}`;
816
+ }
817
+ function st(e, t, n = 16) {
818
+ let [r, i] = at(e, t), a = [];
819
+ for (let o = 0; o <= n; o++) {
820
+ let s = o / n, c = 1 - s, l = c * c * c * e.x + 3 * c * c * s * r.x + 3 * c * s * s * i.x + s * s * s * t.x, u = c * c * c * e.y + 3 * c * c * s * r.y + 3 * c * s * s * i.y + s * s * s * t.y;
821
+ a.push({
822
+ x: l,
823
+ y: u
824
+ });
825
+ }
826
+ return a;
827
+ }
828
+ function ct(e, t, n, r) {
829
+ let i = t.x - e.x, a = t.y - e.y, o = r.x - n.x, s = r.y - n.y, c = i * s - a * o;
830
+ if (c === 0) return !1;
831
+ let l = n.x - e.x, u = n.y - e.y, d = (l * s - u * o) / c, f = (l * a - u * i) / c;
832
+ return d >= 0 && d <= 1 && f >= 0 && f <= 1;
833
+ }
834
+ //#endregion
835
+ //#region src/components/NodePort.vue?vue&type=script&setup=true&lang.ts
836
+ var lt = ["title"], ut = {
837
+ key: 2,
838
+ class: "label"
839
+ }, dt = /*#__PURE__*/ Z(/* @__PURE__ */ s({
840
+ __name: "NodePort",
841
+ props: {
842
+ port: {},
843
+ typeDef: {},
844
+ color: {},
845
+ side: {},
846
+ connected: {
847
+ type: Boolean,
848
+ default: !1
849
+ },
850
+ widgetMode: { default: "auto" },
851
+ displayValue: {}
852
+ },
853
+ emits: ["connectStart", "valueChange"],
854
+ setup(e, { emit: a }) {
855
+ b((e) => ({ v7cc4cde0: o }));
856
+ let o = "11px", s = e, c = a;
857
+ function d(e) {
858
+ e.button === 0 && c("connectStart", s.port, e);
859
+ }
860
+ let f = t(() => $e(s.port, s.typeDef)), m = t(() => Le(s.typeDef, s.port)), h = t(() => {
861
+ let e = s.typeDef?.label ?? s.port.type;
862
+ return `${s.port.name} (${e})`;
863
+ }), g = t(() => s.widgetMode === "editable" || s.side === "in" && !!s.port.userOnly || s.widgetMode === "auto" && s.side === "in" && !s.connected && !s.port.multi), _ = t(() => s.widgetMode === "readonly"), y = t(() => s.side === "in" && !s.port.userOnly), x = t(() => g.value || _.value), ee = t(() => _.value ? "readonly" : "editable");
864
+ function S(e) {
865
+ s.port.value = e, c("valueChange", s.port);
866
+ }
867
+ function C() {
868
+ s.typeDef?.coerce && (s.port.value = s.typeDef.coerce(s.port.value), c("valueChange", s.port));
869
+ }
870
+ return (t, a) => (p(), i("div", {
871
+ class: l(["port", [e.side, {
872
+ hasWidget: x.value,
873
+ "no-socket": e.side === "in" && !y.value
874
+ }]]),
875
+ style: u({ height: f.value + "px" })
876
+ }, [
877
+ y.value ? (p(), i("span", {
878
+ key: 0,
879
+ class: l(["socket", { multi: e.port.multi }]),
880
+ style: u({ background: e.color }),
881
+ title: e.port.multi ? `${e.port.name} (accepts many)` : e.port.name,
882
+ onPointerdown: w(d, ["stop"])
883
+ }, null, 46, lt)) : r("", !0),
884
+ x.value ? (p(), n(Ze, {
885
+ key: 1,
886
+ port: e.port,
887
+ "type-def": e.typeDef,
888
+ "effective-widget": m.value,
889
+ mode: ee.value,
890
+ "display-value": e.displayValue,
891
+ placeholder: h.value,
892
+ "onUpdate:value": S,
893
+ onCommit: C
894
+ }, null, 8, [
895
+ "port",
896
+ "type-def",
897
+ "effective-widget",
898
+ "mode",
899
+ "display-value",
900
+ "placeholder"
901
+ ])) : (p(), i("span", ut, v(e.port.name), 1)),
902
+ e.side === "out" ? (p(), i("span", {
903
+ key: 3,
904
+ class: "socket",
905
+ style: u({ background: e.color }),
906
+ onPointerdown: w(d, ["stop"])
907
+ }, null, 36)) : r("", !0)
908
+ ], 6));
909
+ }
910
+ }), [["__scopeId", "data-v-28eb3da7"]]), ft = ["title"], pt = { class: "title" }, mt = {
911
+ class: "grip",
912
+ title: "Drag"
913
+ }, ht = { class: "body" }, gt = {
914
+ key: 0,
915
+ class: "col input"
916
+ }, _t = 4, vt = /*#__PURE__*/ Z(/* @__PURE__ */ s({
917
+ __name: "GraphNode",
918
+ props: {
919
+ node: {},
920
+ map: {},
921
+ zoom: { default: 1 },
922
+ ioWidgets: {
923
+ type: Boolean,
924
+ default: !1
925
+ },
926
+ ioResults: {},
927
+ selected: {
928
+ type: Boolean,
929
+ default: !1
930
+ },
931
+ selectedIds: {},
932
+ error: {}
933
+ },
934
+ emits: [
935
+ "connectStart",
936
+ "select",
937
+ "drillIn"
938
+ ],
939
+ setup(o, { emit: s }) {
940
+ b((e) => ({
941
+ v50d21574: d,
942
+ v691ebaeb: f
943
+ }));
944
+ let d = "11px", f = "6px", m = o, g = s;
945
+ function _(e, t) {
946
+ g("connectStart", {
947
+ node: m.node.id,
948
+ port: e.id
949
+ }, e, t);
950
+ }
951
+ function x(e) {
952
+ e.userOnly && A(m.map, m.node);
953
+ }
954
+ function ee(e) {
955
+ e.stopPropagation(), me(m.node) && g("drillIn", m.node.id);
956
+ }
957
+ function S(e) {
958
+ e.button === 0 && (e.stopPropagation(), g("select", m.node.id, e.shiftKey));
959
+ }
960
+ let C = t(() => m.map.nodeTypes[m.node.typeId]), w = t(() => m.node.label || C.value?.displayName || m.node.typeId), T = t(() => m.node.color ?? C.value?.color ?? "#3a3f4b"), E = t(() => tt(m.node)), D = t(() => Object.values(m.node.inputs)), O = t(() => Object.values(m.node.outputs)), k = t(() => m.ioWidgets && m.node.typeId === "io/input"), j = t(() => {
961
+ let e = /* @__PURE__ */ new Set();
962
+ for (let t of m.map.graph.connections) t.to.node === m.node.id && e.add(t.to.port);
963
+ return e;
964
+ });
965
+ function M(e) {
966
+ return m.map.types[e]?.color ?? "#888";
967
+ }
968
+ function N(e) {
969
+ return m.map.types[e.type];
970
+ }
971
+ let P = (e) => m.map.types[e.type], F = t(() => nt(m.node, P));
972
+ function I(e) {
973
+ return m.ioWidgets ? m.node.typeId === "io/input" && e === "out" ? "editable" : m.node.typeId === "io/output" && e === "in" ? "readonly" : "auto" : "auto";
974
+ }
975
+ function L(e) {
976
+ if (e.button !== 0) return;
977
+ e.stopPropagation();
978
+ let t = e.clientX, n = e.clientY, r = e.shiftKey, i = m.zoom, a = !1, o = null;
979
+ async function s() {
980
+ !r && !m.selectedIds?.has(m.node.id) && (g("select", m.node.id, !1), await c());
981
+ let e = m.selectedIds ?? new Set([m.node.id]);
982
+ o = (e.size > 1 && e.has(m.node.id) ? m.map.graph.nodes.filter((t) => e.has(t.id)) : [m.node]).map((e) => ({
983
+ node: e,
984
+ x: e.location.x,
985
+ y: e.location.y
986
+ }));
987
+ }
988
+ function l(e) {
989
+ if (!a) {
990
+ let r = e.clientX - t, i = e.clientY - n;
991
+ if (Math.hypot(r, i) < _t) return;
992
+ a = !0, s();
993
+ return;
994
+ }
995
+ if (!o) return;
996
+ let r = (e.clientX - t) / i, c = (e.clientY - n) / i;
997
+ for (let { node: e, x: t, y: n } of o) e.location.x = t + r, e.location.y = n + c;
998
+ }
999
+ function u() {
1000
+ window.removeEventListener("pointermove", l), window.removeEventListener("pointerup", u), a || g("select", m.node.id, r);
1001
+ }
1002
+ window.addEventListener("pointermove", l), window.addEventListener("pointerup", u);
1003
+ }
1004
+ return (t, s) => (p(), i("div", {
1005
+ class: l(["node", {
1006
+ selected: o.selected,
1007
+ errored: !!o.error
1008
+ }]),
1009
+ style: u({
1010
+ left: o.node.location.x + "px",
1011
+ top: o.node.location.y + "px",
1012
+ width: E.value + "px",
1013
+ height: F.value + "px",
1014
+ zIndex: o.node.z ?? 0
1015
+ }),
1016
+ onPointerdown: S
1017
+ }, [
1018
+ o.error ? (p(), i("div", {
1019
+ key: 0,
1020
+ class: "error-ring",
1021
+ title: o.error
1022
+ }, null, 8, ft)) : r("", !0),
1023
+ a("div", {
1024
+ class: "header",
1025
+ style: u({
1026
+ background: T.value,
1027
+ height: y(20) + "px"
1028
+ }),
1029
+ onPointerdown: L,
1030
+ onDblclick: ee
1031
+ }, [a("span", pt, v(w.value), 1), a("div", mt, [(p(), i(e, null, h(6, (e) => a("span", {
1032
+ key: e,
1033
+ class: "dot"
1034
+ })), 64))])], 36),
1035
+ a("div", ht, [D.value.length ? (p(), i("div", gt, [(p(!0), i(e, null, h(D.value, (e) => (p(), n(dt, {
1036
+ key: e.id,
1037
+ port: e,
1038
+ "type-def": N(e),
1039
+ color: M(e.type),
1040
+ side: "in",
1041
+ connected: j.value.has(e.id),
1042
+ "widget-mode": I("in"),
1043
+ "display-value": o.ioResults?.[e.name],
1044
+ onConnectStart: _,
1045
+ onValueChange: x
1046
+ }, null, 8, [
1047
+ "port",
1048
+ "type-def",
1049
+ "color",
1050
+ "connected",
1051
+ "widget-mode",
1052
+ "display-value"
1053
+ ]))), 128))])) : r("", !0), O.value.length ? (p(), i("div", {
1054
+ key: 1,
1055
+ class: l(["col output", { wide: k.value }])
1056
+ }, [(p(!0), i(e, null, h(O.value, (e) => (p(), n(dt, {
1057
+ key: e.id,
1058
+ port: e,
1059
+ "type-def": N(e),
1060
+ color: M(e.type),
1061
+ side: "out",
1062
+ "widget-mode": I("out"),
1063
+ onConnectStart: _
1064
+ }, null, 8, [
1065
+ "port",
1066
+ "type-def",
1067
+ "color",
1068
+ "widget-mode"
1069
+ ]))), 128))], 2)) : r("", !0)])
1070
+ ], 38));
1071
+ }
1072
+ }), [["__scopeId", "data-v-4f4ae398"]]), yt = { class: "wires" }, bt = ["d"], xt = ["d"], St = ["d"], Ct = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1073
+ __name: "WireLayer",
1074
+ props: {
1075
+ map: {},
1076
+ pendingPath: {},
1077
+ slicePath: {}
1078
+ },
1079
+ setup(n) {
1080
+ let a = n, o = (e) => a.map.types[e.type], s = t(() => {
1081
+ let e = {};
1082
+ for (let t of a.map.graph.nodes) e[t.id] = t;
1083
+ return e;
1084
+ }), c = t(() => a.map.graph.connections.map((e) => {
1085
+ let t = s.value[e.from.node], n = s.value[e.to.node];
1086
+ if (!t || !n) return null;
1087
+ let r = it(t, e.from.port, o), i = it(n, e.to.port, o);
1088
+ return !r || !i ? null : {
1089
+ id: e.id,
1090
+ d: ot(r, i)
1091
+ };
1092
+ }).filter((e) => e !== null));
1093
+ return (t, a) => (p(), i("svg", yt, [
1094
+ (p(!0), i(e, null, h(c.value, (e) => (p(), i("path", {
1095
+ key: e.id,
1096
+ d: e.d
1097
+ }, null, 8, bt))), 128)),
1098
+ n.pendingPath ? (p(), i("path", {
1099
+ key: 0,
1100
+ class: "pending",
1101
+ d: n.pendingPath
1102
+ }, null, 8, xt)) : r("", !0),
1103
+ n.slicePath ? (p(), i("path", {
1104
+ key: 1,
1105
+ class: "slice",
1106
+ d: n.slicePath
1107
+ }, null, 8, St)) : r("", !0)
1108
+ ]));
1109
+ }
1110
+ }), [["__scopeId", "data-v-682ffd13"]]), wt = { class: "inspector-section-header" }, Tt = { class: "inspector-section-title" }, Et = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1111
+ __name: "InspectorSection",
1112
+ props: {
1113
+ title: {},
1114
+ divided: {
1115
+ type: Boolean,
1116
+ default: !0
1117
+ }
1118
+ },
1119
+ setup(e) {
1120
+ return (t, n) => (p(), i("div", { class: l(["inspector-section", { divided: e.divided }]) }, [a("div", wt, [a("span", Tt, v(e.title), 1), g(t.$slots, "actions", {}, void 0, !0)]), g(t.$slots, "default", {}, void 0, !0)], 2));
1121
+ }
1122
+ }), [["__scopeId", "data-v-5e38007a"]]), Dt = {
1123
+ key: 0,
1124
+ class: "iface-grid iface-head",
1125
+ "aria-hidden": "true"
1126
+ }, Ot = {
1127
+ key: 1,
1128
+ class: "iface-rows"
1129
+ }, kt = { class: "iface-grid iface-row" }, At = ["value", "onChange"], jt = ["value", "onChange"], Mt = ["value"], Nt = ["onClick"], Pt = {
1130
+ key: 0,
1131
+ class: "iface-default-row"
1132
+ }, Ft = {
1133
+ key: 2,
1134
+ class: "iface-empty"
1135
+ }, It = {
1136
+ key: 3,
1137
+ class: "iface-error"
1138
+ }, Lt = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1139
+ __name: "GraphInterfacePanel",
1140
+ props: {
1141
+ graphInterface: {},
1142
+ mode: {},
1143
+ revision: {},
1144
+ typeIds: {},
1145
+ types: {},
1146
+ commitError: {},
1147
+ applyMutation: { type: Function }
1148
+ },
1149
+ setup(s) {
1150
+ let c = s, l = m(""), u = m({}), d = t(() => c.commitError || l.value || ""), f = t(() => c.mode === "parameters" ? "Graph inputs" : "Graph outputs"), g = t(() => c.mode === "parameters"), _ = t(() => {
1151
+ let e = g.value ? c.graphInterface.parameters : c.graphInterface.returns;
1152
+ return Object.entries(e ?? {}).map(([e, t]) => ({
1153
+ name: e,
1154
+ spec: t
1155
+ }));
1156
+ });
1157
+ function b(e) {
1158
+ return c.types[e]?.defaultValue;
1159
+ }
1160
+ function x(e, t) {
1161
+ return t.defaultValue === void 0 ? b(t.type) : t.defaultValue;
1162
+ }
1163
+ function C() {
1164
+ if (!g.value) {
1165
+ u.value = {};
1166
+ return;
1167
+ }
1168
+ let e = {};
1169
+ for (let { name: t, spec: n } of _.value) e[t] = x(t, n);
1170
+ u.value = e;
1171
+ }
1172
+ ee(() => c.revision, () => {
1173
+ l.value = "", C();
1174
+ }), ee(g, C, { immediate: !0 });
1175
+ function T(e) {
1176
+ l.value = "";
1177
+ try {
1178
+ let t = c.applyMutation(e);
1179
+ t.length && (l.value = t[0] ?? "Unknown error");
1180
+ } catch (e) {
1181
+ l.value = e instanceof Error ? e.message : String(e);
1182
+ }
1183
+ }
1184
+ function E(e, t) {
1185
+ return {
1186
+ id: `iface-default-${e}`,
1187
+ name: e,
1188
+ type: t.type,
1189
+ direction: "input",
1190
+ value: u.value[e] ?? x(e, t)
1191
+ };
1192
+ }
1193
+ function D(e, t) {
1194
+ u.value = {
1195
+ ...u.value,
1196
+ [e]: t
1197
+ };
1198
+ }
1199
+ function O(e) {
1200
+ if (!c.graphInterface.parameters?.[e]) return;
1201
+ let t = u.value[e];
1202
+ T((n) => {
1203
+ let r = n.parameters?.[e];
1204
+ if (!r) return;
1205
+ let i = c.types[r.type], a = i?.coerce?.(t) ?? (i?.validate(t) ? t : x(e, r));
1206
+ n.parameters = {
1207
+ ...n.parameters,
1208
+ [e]: {
1209
+ ...r,
1210
+ defaultValue: a
1211
+ }
1212
+ };
1213
+ });
1214
+ }
1215
+ function k() {
1216
+ T((e) => {
1217
+ let t = g.value ? e.parameters : e.returns, n = new Set(Object.keys(t ?? {})), r = g.value ? "input" : "output";
1218
+ if (n.has(r)) {
1219
+ let e = 2;
1220
+ for (; n.has(`${r}${e}`);) e++;
1221
+ r = `${r}${e}`;
1222
+ }
1223
+ let i = c.typeIds[0] ?? "number", a = g.value ? {
1224
+ type: i,
1225
+ defaultValue: b(i)
1226
+ } : { type: i };
1227
+ g.value ? e.parameters = {
1228
+ ...e.parameters,
1229
+ [r]: a
1230
+ } : e.returns = {
1231
+ ...e.returns,
1232
+ [r]: a
1233
+ };
1234
+ });
1235
+ }
1236
+ function A(e) {
1237
+ T((t) => {
1238
+ if (g.value) {
1239
+ if (!t.parameters) return;
1240
+ let { [e]: n, ...r } = t.parameters;
1241
+ t.parameters = Object.keys(r).length ? r : void 0;
1242
+ } else {
1243
+ if (!t.returns) return;
1244
+ let { [e]: n, ...r } = t.returns;
1245
+ t.returns = Object.keys(r).length ? r : void 0;
1246
+ }
1247
+ });
1248
+ }
1249
+ function j(e, t) {
1250
+ if (!t || !te.test(t)) {
1251
+ l.value = `Invalid port name "${t}"`;
1252
+ return;
1253
+ }
1254
+ e !== t && T((n) => {
1255
+ let r = (g.value ? n.parameters : n.returns)?.[e];
1256
+ if (r) if (g.value) {
1257
+ let { [e]: i, ...a } = n.parameters ?? {};
1258
+ n.parameters = {
1259
+ ...a,
1260
+ [t]: r
1261
+ };
1262
+ } else {
1263
+ let { [e]: i, ...a } = n.returns ?? {};
1264
+ n.returns = {
1265
+ ...a,
1266
+ [t]: r
1267
+ };
1268
+ }
1269
+ });
1270
+ }
1271
+ function M(e, t) {
1272
+ T((n) => {
1273
+ if (g.value) {
1274
+ let r = n.parameters?.[e];
1275
+ if (!r) return;
1276
+ let i = b(t);
1277
+ u.value = {
1278
+ ...u.value,
1279
+ [e]: i
1280
+ }, n.parameters = {
1281
+ ...n.parameters,
1282
+ [e]: {
1283
+ ...r,
1284
+ type: t,
1285
+ defaultValue: i
1286
+ }
1287
+ };
1288
+ } else {
1289
+ let r = n.returns?.[e];
1290
+ if (!r) return;
1291
+ n.returns = {
1292
+ ...n.returns,
1293
+ [e]: {
1294
+ ...r,
1295
+ type: t
1296
+ }
1297
+ };
1298
+ }
1299
+ });
1300
+ }
1301
+ return (t, c) => (p(), n(Et, { title: f.value }, {
1302
+ actions: S(() => [a("button", {
1303
+ class: "inspector-icon-btn",
1304
+ type: "button",
1305
+ title: "Add port",
1306
+ onClick: w(k, ["stop", "prevent"])
1307
+ }, " + ")]),
1308
+ default: S(() => [
1309
+ _.value.length ? (p(), i("div", Dt, [...c[0] ||= [
1310
+ a("span", null, "Name", -1),
1311
+ a("span", null, "Type", -1),
1312
+ a("span", null, null, -1)
1313
+ ]])) : r("", !0),
1314
+ _.value.length ? (p(), i("div", Ot, [(p(!0), i(e, null, h(_.value, (t) => (p(), i("div", {
1315
+ key: t.name,
1316
+ class: "iface-entry"
1317
+ }, [a("div", kt, [
1318
+ a("input", {
1319
+ class: "iface-field iface-name",
1320
+ type: "text",
1321
+ value: t.name,
1322
+ onChange: (e) => j(t.name, e.target.value.trim())
1323
+ }, null, 40, At),
1324
+ a("select", {
1325
+ class: "iface-field iface-select",
1326
+ value: t.spec.type,
1327
+ onChange: (e) => M(t.name, e.target.value)
1328
+ }, [(p(!0), i(e, null, h(s.typeIds, (e) => (p(), i("option", {
1329
+ key: e,
1330
+ value: e
1331
+ }, v(e), 9, Mt))), 128))], 40, jt),
1332
+ a("button", {
1333
+ class: "iface-remove",
1334
+ type: "button",
1335
+ title: "Remove port",
1336
+ onClick: w((e) => A(t.name), ["stop", "prevent"])
1337
+ }, " × ", 8, Nt)
1338
+ ]), g.value ? (p(), i("div", Pt, [c[1] ||= a("span", { class: "iface-default-label" }, "Default", -1), o(Ze, {
1339
+ class: "iface-default-widget",
1340
+ port: E(t.name, t.spec),
1341
+ "type-def": s.types[t.spec.type],
1342
+ "effective-widget": y(Le)(s.types[t.spec.type], E(t.name, t.spec)),
1343
+ mode: "editable",
1344
+ placeholder: t.name,
1345
+ "onUpdate:value": (e) => D(t.name, e),
1346
+ onCommit: (e) => O(t.name)
1347
+ }, null, 8, [
1348
+ "port",
1349
+ "type-def",
1350
+ "effective-widget",
1351
+ "placeholder",
1352
+ "onUpdate:value",
1353
+ "onCommit"
1354
+ ])])) : r("", !0)]))), 128))])) : (p(), i("div", Ft, "No ports")),
1355
+ d.value ? (p(), i("p", It, v(d.value), 1)) : r("", !0)
1356
+ ]),
1357
+ _: 1
1358
+ }, 8, ["title"]));
1359
+ }
1360
+ }), [["__scopeId", "data-v-e5bdc707"]]), Rt = {
1361
+ key: 0,
1362
+ class: "inspector-title static"
1363
+ }, zt = [
1364
+ "value",
1365
+ "placeholder",
1366
+ "title"
1367
+ ], Bt = { class: "inspector-header-actions" }, Vt = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1368
+ __name: "InspectorPanel",
1369
+ props: {
1370
+ title: {},
1371
+ titlePlaceholder: { default: "" },
1372
+ headerColor: { default: "#3a3f4b" },
1373
+ showUp: {
1374
+ type: Boolean,
1375
+ default: !1
1376
+ },
1377
+ staticTitle: {
1378
+ type: Boolean,
1379
+ default: !1
1380
+ },
1381
+ flush: {
1382
+ type: Boolean,
1383
+ default: !1
1384
+ },
1385
+ fill: {
1386
+ type: Boolean,
1387
+ default: !1
1388
+ }
1389
+ },
1390
+ emits: ["update:title", "up"],
1391
+ setup(e, { emit: t }) {
1392
+ b((e) => ({
1393
+ a8ea4b7e: o,
1394
+ v2ca6cb43: c,
1395
+ v78510090: s
1396
+ }));
1397
+ let n = t, o = "11px", s = "6px", c = "20px";
1398
+ function d(e) {
1399
+ n("update:title", e.target.value);
1400
+ }
1401
+ return (t, o) => (p(), i("div", { class: l(["inspector-panel", { fill: e.fill }]) }, [a("div", {
1402
+ class: "inspector-header",
1403
+ style: u({ background: e.headerColor })
1404
+ }, [g(t.$slots, "title", {}, () => [e.staticTitle ? (p(), i("span", Rt, v(e.title), 1)) : (p(), i("input", {
1405
+ key: 1,
1406
+ class: "inspector-title",
1407
+ type: "text",
1408
+ value: e.title,
1409
+ placeholder: e.titlePlaceholder,
1410
+ title: e.title,
1411
+ onInput: d
1412
+ }, null, 40, zt))], !0), a("div", Bt, [g(t.$slots, "header-actions", {}, void 0, !0), e.showUp ? (p(), i("button", {
1413
+ key: 0,
1414
+ class: "inspector-icon-btn",
1415
+ type: "button",
1416
+ title: "Go up",
1417
+ onClick: o[0] ||= (e) => n("up")
1418
+ }, " ↩ ")) : r("", !0)])], 4), a("div", { class: l(["inspector-body", { flush: e.flush }]) }, [g(t.$slots, "default", {}, void 0, !0)], 2)], 2));
1419
+ }
1420
+ }), [["__scopeId", "data-v-78844099"]]), Ht = { class: "inspector-row" }, Ut = { class: "inspector-key" }, Wt = ["value"], Gt = /* @__PURE__ */ s({
1421
+ __name: "InspectorColorField",
1422
+ props: {
1423
+ modelValue: {},
1424
+ label: { default: "Color" }
1425
+ },
1426
+ emits: ["update:modelValue"],
1427
+ setup(e, { emit: t }) {
1428
+ let n = t;
1429
+ function r(e) {
1430
+ n("update:modelValue", e.target.value);
1431
+ }
1432
+ return (t, n) => (p(), i("label", Ht, [a("span", Ut, v(e.label), 1), a("input", {
1433
+ class: "inspector-swatch",
1434
+ type: "color",
1435
+ value: e.modelValue,
1436
+ onInput: r
1437
+ }, null, 40, Wt)]));
1438
+ }
1439
+ }), Kt = { class: "inspector-error" }, qt = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1440
+ __name: "InspectorError",
1441
+ props: { message: {} },
1442
+ setup(e) {
1443
+ return (t, n) => (p(), i("p", Kt, v(e.message), 1));
1444
+ }
1445
+ }), [["__scopeId", "data-v-a863f513"]]), Jt = { class: "inspector-row pair" }, Yt = ["value"], Xt = ["value"], Zt = /* @__PURE__ */ s({
1446
+ __name: "InspectorPositionField",
1447
+ props: {
1448
+ x: {},
1449
+ y: {}
1450
+ },
1451
+ emits: ["update:x", "update:y"],
1452
+ setup(e, { emit: t }) {
1453
+ let n = t;
1454
+ function r(e) {
1455
+ return Number(e.target.value);
1456
+ }
1457
+ return (t, o) => (p(), i("div", Jt, [a("label", null, [o[2] ||= a("span", { class: "inspector-key" }, "X", -1), a("input", {
1458
+ class: "inspector-field",
1459
+ type: "number",
1460
+ value: e.x,
1461
+ onInput: o[0] ||= (e) => n("update:x", r(e))
1462
+ }, null, 40, Yt)]), a("label", null, [o[3] ||= a("span", { class: "inspector-key" }, "Y", -1), a("input", {
1463
+ class: "inspector-field",
1464
+ type: "number",
1465
+ value: e.y,
1466
+ onInput: o[1] ||= (e) => n("update:y", r(e))
1467
+ }, null, 40, Xt)])]));
1468
+ }
1469
+ }), Qt = { class: "inspector-row" }, $t = [
1470
+ "min",
1471
+ "max",
1472
+ "value"
1473
+ ], en = { class: "inspector-slider-value" }, tn = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1474
+ __name: "InspectorWidthField",
1475
+ props: {
1476
+ modelValue: {},
1477
+ min: {},
1478
+ max: {},
1479
+ accentColor: {}
1480
+ },
1481
+ emits: ["update:modelValue"],
1482
+ setup(e, { emit: t }) {
1483
+ let n = t;
1484
+ function r(e) {
1485
+ n("update:modelValue", Number(e.target.value));
1486
+ }
1487
+ return (t, n) => (p(), i("label", Qt, [
1488
+ n[0] ||= a("span", { class: "inspector-key" }, "Width", -1),
1489
+ a("input", {
1490
+ class: "inspector-slider",
1491
+ type: "range",
1492
+ min: e.min,
1493
+ max: e.max,
1494
+ step: "1",
1495
+ value: e.modelValue,
1496
+ style: u({ accentColor: e.accentColor }),
1497
+ onInput: r
1498
+ }, null, 44, $t),
1499
+ a("span", en, v(e.modelValue), 1)
1500
+ ]));
1501
+ }
1502
+ }), [["__scopeId", "data-v-472135f4"]]), nn = "#3a3f4b", rn = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1503
+ __name: "NodePanel",
1504
+ props: {
1505
+ map: {},
1506
+ nodes: {},
1507
+ def: {},
1508
+ error: {},
1509
+ graphInterface: {},
1510
+ interfaceRevision: {},
1511
+ interfaceCommitError: {},
1512
+ applyInterfaceMutation: { type: Function }
1513
+ },
1514
+ emits: ["update:label"],
1515
+ setup(e, { emit: i }) {
1516
+ let a = e, s = i, c = t(() => a.nodes.length > 1), l = t(() => a.nodes[0] ?? null), u = t(() => c.value || !l.value ? null : l.value.typeId === "io/input" ? "parameters" : l.value.typeId === "io/output" ? "returns" : null), d = t(() => Object.keys(a.map.types).sort((e, t) => e.localeCompare(t))), f = t(() => a.def?.displayName ?? l.value?.typeId ?? ""), m = t(() => {
1517
+ if (c.value) return `${a.nodes.length} nodes`;
1518
+ let e = l.value;
1519
+ return e ? e.label || a.def?.displayName || e.typeId : "";
1520
+ }), h = t(() => {
1521
+ let e = l.value;
1522
+ return e ? e.color ?? a.def?.color ?? "#3a3f4b" : "#3a3f4b";
1523
+ }), g = t(() => l.value?.width ?? 100), _ = t(() => {
1524
+ if (!a.nodes.length) return 0;
1525
+ let e = a.nodes.reduce((e, t) => e + t.location.x, 0);
1526
+ return Math.round(e / a.nodes.length);
1527
+ }), v = t(() => {
1528
+ if (!a.nodes.length) return 0;
1529
+ let e = a.nodes.reduce((e, t) => e + t.location.y, 0);
1530
+ return Math.round(e / a.nodes.length);
1531
+ });
1532
+ function b(e) {
1533
+ let t = l.value;
1534
+ t && (t.label = e, s("update:label", e));
1535
+ }
1536
+ function x(e) {
1537
+ let t = l.value;
1538
+ t && (t.color = e);
1539
+ }
1540
+ function ee(e) {
1541
+ let t = l.value;
1542
+ t && (t.width = e);
1543
+ }
1544
+ function C(e) {
1545
+ let t = e - _.value;
1546
+ for (let e of a.nodes) e.location.x += t;
1547
+ }
1548
+ function w(e) {
1549
+ let t = e - v.value;
1550
+ for (let e of a.nodes) e.location.y += t;
1551
+ }
1552
+ return (t, i) => l.value ? (p(), n(Vt, {
1553
+ key: 0,
1554
+ class: "node-panel",
1555
+ title: m.value,
1556
+ "title-placeholder": f.value,
1557
+ "header-color": nn,
1558
+ "static-title": c.value,
1559
+ "onUpdate:title": b
1560
+ }, {
1561
+ default: S(() => [
1562
+ c.value ? r("", !0) : (p(), n(Gt, {
1563
+ key: 0,
1564
+ "model-value": h.value,
1565
+ "onUpdate:modelValue": x
1566
+ }, null, 8, ["model-value"])),
1567
+ o(Zt, {
1568
+ x: _.value,
1569
+ y: v.value,
1570
+ "onUpdate:x": C,
1571
+ "onUpdate:y": w
1572
+ }, null, 8, ["x", "y"]),
1573
+ c.value ? r("", !0) : (p(), n(tn, {
1574
+ key: 1,
1575
+ "model-value": g.value,
1576
+ min: y(60),
1577
+ max: y(320),
1578
+ "accent-color": h.value,
1579
+ "onUpdate:modelValue": ee
1580
+ }, null, 8, [
1581
+ "model-value",
1582
+ "min",
1583
+ "max",
1584
+ "accent-color"
1585
+ ])),
1586
+ e.error && !c.value ? (p(), n(qt, {
1587
+ key: 2,
1588
+ message: e.error
1589
+ }, null, 8, ["message"])) : r("", !0),
1590
+ u.value ? (p(), n(Lt, {
1591
+ key: 3,
1592
+ "graph-interface": e.graphInterface,
1593
+ mode: u.value,
1594
+ revision: e.interfaceRevision,
1595
+ "type-ids": d.value,
1596
+ types: e.map.types,
1597
+ "commit-error": e.interfaceCommitError,
1598
+ "apply-mutation": e.applyInterfaceMutation
1599
+ }, null, 8, [
1600
+ "graph-interface",
1601
+ "mode",
1602
+ "revision",
1603
+ "type-ids",
1604
+ "types",
1605
+ "commit-error",
1606
+ "apply-mutation"
1607
+ ])) : r("", !0)
1608
+ ]),
1609
+ _: 1
1610
+ }, 8, [
1611
+ "title",
1612
+ "title-placeholder",
1613
+ "static-title"
1614
+ ])) : r("", !0);
1615
+ }
1616
+ }), [["__scopeId", "data-v-51945220"]]), an = { class: "inspector-row inspector-check" }, on = { class: "inspector-key" }, sn = ["checked"], cn = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1617
+ __name: "InspectorCheckboxField",
1618
+ props: {
1619
+ modelValue: { type: Boolean },
1620
+ label: {}
1621
+ },
1622
+ emits: ["update:modelValue"],
1623
+ setup(e, { emit: t }) {
1624
+ let n = t;
1625
+ function r(e) {
1626
+ n("update:modelValue", e.target.checked);
1627
+ }
1628
+ return (t, n) => (p(), i("label", an, [a("span", on, v(e.label), 1), a("input", {
1629
+ type: "checkbox",
1630
+ checked: e.modelValue,
1631
+ onChange: r
1632
+ }, null, 40, sn)]));
1633
+ }
1634
+ }), [["__scopeId", "data-v-7b38cfa2"]]), ln = "#3a3f4b", un = /* @__PURE__ */ s({
1635
+ __name: "GroupPanel",
1636
+ props: {
1637
+ composite: {},
1638
+ ioWidgets: { type: Boolean }
1639
+ },
1640
+ emits: ["up", "update:ioWidgets"],
1641
+ setup(e, { emit: i }) {
1642
+ let a = e, s = i, c = t(() => ce.displayName), l = t(() => a.composite?.label || ce.displayName), u = t(() => a.composite?.color ?? ce.color ?? ln);
1643
+ function d(e) {
1644
+ let t = a.composite;
1645
+ t && (t.label = e);
1646
+ }
1647
+ function f(e) {
1648
+ let t = a.composite;
1649
+ t && (t.color = e);
1650
+ }
1651
+ return (t, i) => e.composite ? (p(), n(Vt, {
1652
+ key: 0,
1653
+ title: l.value,
1654
+ "title-placeholder": c.value,
1655
+ "header-color": ln,
1656
+ "show-up": "",
1657
+ "onUpdate:title": d,
1658
+ onUp: i[1] ||= (e) => s("up")
1659
+ }, {
1660
+ default: S(() => [o(Gt, {
1661
+ "model-value": u.value,
1662
+ "onUpdate:modelValue": f
1663
+ }, null, 8, ["model-value"]), o(cn, {
1664
+ label: "IO test",
1665
+ "model-value": e.ioWidgets,
1666
+ "onUpdate:modelValue": i[0] ||= (e) => s("update:ioWidgets", e)
1667
+ }, null, 8, ["model-value"])]),
1668
+ _: 1
1669
+ }, 8, ["title", "title-placeholder"])) : r("", !0);
1670
+ }
1671
+ });
1672
+ //#endregion
1673
+ //#region src/store/registry/groups.ts
1674
+ function dn(e, t) {
1675
+ return {
1676
+ name: e,
1677
+ path: t,
1678
+ subgroups: [],
1679
+ nodes: []
1680
+ };
1681
+ }
1682
+ function fn(e, t) {
1683
+ let n = dn("", []);
1684
+ for (let r of Object.values(e)) {
1685
+ if (t && !t(r)) continue;
1686
+ let e = n, i = [];
1687
+ for (let t of r.group ?? []) {
1688
+ i.push(t);
1689
+ let n = e.subgroups.find((e) => e.name === t);
1690
+ n || (n = dn(t, [...i]), e.subgroups.push(n)), e = n;
1691
+ }
1692
+ e.nodes.push(r);
1693
+ }
1694
+ return n;
1695
+ }
1696
+ function pn(e) {
1697
+ e.subgroups.sort((e, t) => e.name.localeCompare(t.name)), e.nodes.sort((e, t) => e.displayName.localeCompare(t.displayName));
1698
+ for (let t of e.subgroups) pn(t);
1699
+ return e;
1700
+ }
1701
+ //#endregion
1702
+ //#region src/components/AddNodePanel.vue?vue&type=script&setup=true&lang.ts
1703
+ var mn = ["title"], hn = { class: "picker-body" }, gn = { class: "list" }, _n = ["title", "onClick"], vn = { class: "name" }, yn = { class: "path" }, bn = {
1704
+ key: 0,
1705
+ class: "path-sep"
1706
+ }, xn = { class: "path-seg" }, Sn = {
1707
+ key: 0,
1708
+ class: "empty"
1709
+ }, Cn = ["onClick"], wn = { class: "name" }, Tn = ["title", "onClick"], En = { class: "name" }, Dn = {
1710
+ key: 1,
1711
+ class: "empty"
1712
+ }, On = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1713
+ __name: "AddNodePanel",
1714
+ props: {
1715
+ map: {},
1716
+ screen: {}
1717
+ },
1718
+ emits: [
1719
+ "select",
1720
+ "addComposite",
1721
+ "close"
1722
+ ],
1723
+ setup(n, { emit: s }) {
1724
+ b((e) => ({
1725
+ v0e391f60: g,
1726
+ ae7fef7e: y,
1727
+ v113015c7: _
1728
+ }));
1729
+ let c = n, f = s, g = "11px", _ = "6px", y = "20px", T = m(""), E = m(null);
1730
+ d(() => E.value?.focus());
1731
+ let D = (e) => e.typeId !== "io/input" && e.typeId !== "io/output" && e.typeId !== "composite/group", O = t(() => pn(fn(c.map.nodeTypes, D))), k = m([]), A = t(() => {
1732
+ let e = O.value;
1733
+ for (let t of k.value) {
1734
+ let n = e.subgroups.find((e) => e.name === t);
1735
+ if (!n) break;
1736
+ e = n;
1737
+ }
1738
+ return e;
1739
+ }), j = t(() => k.value.length ? k.value.join(" › ") : "Add Node"), M = t(() => k.value.length ? k.value : null);
1740
+ function N(e) {
1741
+ return e.group ?? [];
1742
+ }
1743
+ function P(e) {
1744
+ k.value = [...k.value, e];
1745
+ }
1746
+ function F() {
1747
+ k.value = k.value.slice(0, -1);
1748
+ }
1749
+ let I = t(() => {
1750
+ let e = T.value.trim().toLowerCase();
1751
+ return e ? Object.values(c.map.nodeTypes).filter(D).filter((t) => t.displayName.toLowerCase().includes(e)).sort((e, t) => e.displayName.localeCompare(t.displayName)) : null;
1752
+ });
1753
+ function L(e) {
1754
+ f("select", e.typeId);
1755
+ }
1756
+ let R = t(() => I.value ? I.value : A.value.nodes), z = m(0);
1757
+ ee(R, () => {
1758
+ z.value = 0;
1759
+ });
1760
+ function te() {
1761
+ let e = R.value;
1762
+ e.length && L(e[z.value] ?? e[0]);
1763
+ }
1764
+ function B(e) {
1765
+ let t = R.value;
1766
+ t.length && (e.key === "ArrowDown" ? (e.preventDefault(), z.value = (z.value + 1) % t.length) : e.key === "ArrowUp" ? (e.preventDefault(), z.value = (z.value - 1 + t.length) % t.length) : e.key === "Enter" && (e.preventDefault(), te()));
1767
+ }
1768
+ function V(e, t) {
1769
+ z.value = t, L(e);
1770
+ }
1771
+ function H(e) {
1772
+ e.stopPropagation(), f("close");
1773
+ }
1774
+ return (t, s) => (p(), i("div", {
1775
+ class: "backdrop",
1776
+ onPointerdown: H,
1777
+ onContextmenu: s[4] ||= w(() => {}, ["prevent"])
1778
+ }, [a("div", {
1779
+ class: "anchor",
1780
+ style: u({
1781
+ left: n.screen.x + "px",
1782
+ top: n.screen.y + "px"
1783
+ }),
1784
+ onPointerdown: s[2] ||= w(() => {}, ["stop"]),
1785
+ onContextmenu: s[3] ||= w(() => {}, ["prevent"])
1786
+ }, [o(Vt, {
1787
+ title: "Add Node",
1788
+ "static-title": "",
1789
+ fill: "",
1790
+ flush: ""
1791
+ }, {
1792
+ title: S(() => [a("nav", {
1793
+ class: "crumbs",
1794
+ title: j.value
1795
+ }, [a("span", { class: l(["crumb", { current: !M.value }]) }, " Add Node ", 2), M.value ? (p(!0), i(e, { key: 0 }, h(M.value, (t, n) => (p(), i(e, { key: `${n}-${t}` }, [s[5] ||= a("span", { class: "crumb-sep" }, "›", -1), a("span", { class: l(["crumb", { current: n === M.value.length - 1 }]) }, v(t), 3)], 64))), 128)) : r("", !0)], 8, mn)]),
1796
+ "header-actions": S(() => [a("button", {
1797
+ class: "inspector-icon-btn",
1798
+ type: "button",
1799
+ title: "Add composite",
1800
+ onClick: s[0] ||= (e) => f("addComposite")
1801
+ }, " + ")]),
1802
+ default: S(() => [a("div", hn, [C(a("input", {
1803
+ ref_key: "searchEl",
1804
+ ref: E,
1805
+ "onUpdate:modelValue": s[1] ||= (e) => T.value = e,
1806
+ class: "search",
1807
+ type: "text",
1808
+ placeholder: "Search nodes…",
1809
+ onKeydown: B
1810
+ }, null, 544), [[x, T.value]]), a("div", gn, [I.value ? (p(), i(e, { key: 0 }, [(p(!0), i(e, null, h(I.value, (t, n) => (p(), i("button", {
1811
+ key: t.typeId,
1812
+ class: l(["row node", { active: n === z.value }]),
1813
+ title: t.description,
1814
+ onClick: (e) => V(t, n)
1815
+ }, [
1816
+ a("span", {
1817
+ class: "dot",
1818
+ style: u({ background: t.color })
1819
+ }, null, 4),
1820
+ a("span", vn, v(t.displayName), 1),
1821
+ a("span", yn, [(p(!0), i(e, null, h(N(t), (n, o) => (p(), i(e, { key: `${t.typeId}-${o}-${n}` }, [o > 0 ? (p(), i("span", bn, "›")) : r("", !0), a("span", xn, v(n), 1)], 64))), 128))])
1822
+ ], 10, _n))), 128)), I.value.length ? r("", !0) : (p(), i("div", Sn, "No matches"))], 64)) : (p(), i(e, { key: 1 }, [
1823
+ k.value.length ? (p(), i("button", {
1824
+ key: 0,
1825
+ class: "row up",
1826
+ onClick: F
1827
+ }, [...s[6] ||= [a("span", { class: "icon" }, "↩", -1), a("span", { class: "name" }, "..", -1)]])) : r("", !0),
1828
+ (p(!0), i(e, null, h(A.value.subgroups, (e) => (p(), i("button", {
1829
+ key: e.name,
1830
+ class: "row folder",
1831
+ onClick: (t) => P(e.name)
1832
+ }, [a("span", wn, v(e.name), 1), s[7] ||= a("span", { class: "chev" }, "›", -1)], 8, Cn))), 128)),
1833
+ (p(!0), i(e, null, h(A.value.nodes, (e, t) => (p(), i("button", {
1834
+ key: e.typeId,
1835
+ class: l(["row node", { active: t === z.value }]),
1836
+ title: e.description,
1837
+ onClick: (n) => V(e, t)
1838
+ }, [a("span", {
1839
+ class: "dot",
1840
+ style: u({ background: e.color })
1841
+ }, null, 4), a("span", En, v(e.displayName), 1)], 10, Tn))), 128)),
1842
+ !A.value.subgroups.length && !A.value.nodes.length ? (p(), i("div", Dn, " Empty ")) : r("", !0)
1843
+ ], 64))])])]),
1844
+ _: 1
1845
+ })], 36)], 32));
1846
+ }
1847
+ }), [["__scopeId", "data-v-999f2b7d"]]), kn = 4, An = .25, jn = 2, Mn = .001, Nn = 4, Pn = 120 * 1e3, Fn = /*#__PURE__*/ Z(/* @__PURE__ */ s({
1848
+ __name: "NodeViewer",
1849
+ props: {
1850
+ map: {},
1851
+ ioWidgets: {
1852
+ type: Boolean,
1853
+ default: !1
1854
+ }
1855
+ },
1856
+ setup(s, { expose: c }) {
1857
+ function g(e) {
1858
+ return b.value.types[e.type];
1859
+ }
1860
+ let _ = s, v = m([]), y = t(() => ke(_.map, v.value)), b = t(() => y.value.activeMap), x = t(() => Ae(_.map, v.value)), S = m(0), C = m(""), T = t(() => Oe(_.map, v.value)), E = m(!1), D = t(() => v.value.length ? E.value : _.ioWidgets);
1861
+ function O() {
1862
+ v.value.length && (v.value = v.value.slice(0, -1), U(), q.value = null);
1863
+ }
1864
+ function k(e) {
1865
+ C.value = "";
1866
+ try {
1867
+ let t = je(_.map, v.value, e);
1868
+ return t.length ? (C.value = t[0] ?? "Unknown error", t) : (S.value++, []);
1869
+ } catch (e) {
1870
+ return C.value = e instanceof Error ? e.message : String(e), [C.value];
1871
+ }
1872
+ }
1873
+ function A(e) {
1874
+ let t = b.value.graph.nodes.find((t) => t.id === e);
1875
+ if (!t || !me(t)) return;
1876
+ let n = Fe(_.map, v.value, t);
1877
+ if (n) {
1878
+ console.warn(`[Group] ${n}`);
1879
+ return;
1880
+ }
1881
+ v.value.push({ compositeNodeId: e }), U(), q.value = null;
1882
+ }
1883
+ let j = t(() => he(b.value)), M = t(() => D.value ? j.value.values : void 0), N = t(() => j.value.errors), P = m({});
1884
+ ee(N, (e) => {
1885
+ for (let [t, n] of Object.entries(e)) {
1886
+ if (P.value[t] === n) continue;
1887
+ let e = b.value.graph.nodes.find((e) => e.id === t), r = e ? b.value.nodeTypes[e.typeId] : void 0, i = e?.label || r?.displayName || e?.typeId || t;
1888
+ console.error(`[${i}] ${n}`), P.value[t] = n;
1889
+ }
1890
+ for (let t of Object.keys(P.value)) t in e || delete P.value[t];
1891
+ });
1892
+ let F = m(null), I = m(0), L = m(0), z = m(1), te = m(!1), B = m([]), V = t(() => new Set(B.value)), H = t(() => b.value.graph.nodes.filter((e) => V.value.has(e.id))), ne = t(() => H.value[0] ?? null), re = t(() => ne.value ? b.value.nodeTypes[ne.value.typeId] ?? null : null);
1893
+ function ie(e) {
1894
+ B.value = [e], De(b.value, e);
1895
+ }
1896
+ function ae(e) {
1897
+ B.value.indexOf(e) >= 0 ? B.value = B.value.filter((t) => t !== e) : (B.value = [...B.value, e], De(b.value, e));
1898
+ }
1899
+ function oe(e, t) {
1900
+ if (t) {
1901
+ ae(e);
1902
+ return;
1903
+ }
1904
+ if (V.value.has(e) && B.value.length > 1) {
1905
+ De(b.value, e);
1906
+ return;
1907
+ }
1908
+ ie(e);
1909
+ }
1910
+ function U() {
1911
+ B.value = [];
1912
+ }
1913
+ function se(e, t) {
1914
+ let n = Math.min(e.x, t.x), r = Math.max(e.x, t.x), i = Math.min(e.y, t.y), a = Math.max(e.y, t.y);
1915
+ return b.value.graph.nodes.filter((e) => {
1916
+ let t = tt(e), o = nt(e, g);
1917
+ return e.location.x < r && e.location.x + t > n && e.location.y < a && e.location.y + o > i;
1918
+ }).map((e) => e.id);
1919
+ }
1920
+ let W = m(null), ce = t(() => {
1921
+ let e = W.value;
1922
+ if (!e) return null;
1923
+ let t = Math.min(e.start.x, e.cur.x), n = Math.min(e.start.y, e.cur.y);
1924
+ return {
1925
+ left: `${t}px`,
1926
+ top: `${n}px`,
1927
+ width: `${Math.abs(e.cur.x - e.start.x)}px`,
1928
+ height: `${Math.abs(e.cur.y - e.start.y)}px`
1929
+ };
1930
+ }), G = null, le = !1;
1931
+ function ue(e) {
1932
+ if (G) {
1933
+ if (!le) {
1934
+ let t = e.clientX - G.clientX, n = e.clientY - G.clientY;
1935
+ if (Math.hypot(t, n) < kn) return;
1936
+ le = !0;
1937
+ }
1938
+ W.value = {
1939
+ start: G.world,
1940
+ cur: K(e.clientX, e.clientY)
1941
+ };
1942
+ }
1943
+ }
1944
+ function de() {
1945
+ window.removeEventListener("pointermove", ue), window.removeEventListener("pointerup", de), le && W.value ? B.value = se(W.value.start, W.value.cur) : G && (U(), q.value = null), W.value = null, G = null, le = !1;
1946
+ }
1947
+ let fe = t(() => ({ transform: `translate(${I.value}px, ${L.value}px) scale(${z.value})` }));
1948
+ function K(e, t) {
1949
+ let n = F.value?.getBoundingClientRect(), r = n?.left ?? 0, i = n?.top ?? 0;
1950
+ return {
1951
+ x: (e - r - I.value) / z.value,
1952
+ y: (t - i - L.value) / z.value
1953
+ };
1954
+ }
1955
+ function ge(e, t) {
1956
+ let n = F.value?.getBoundingClientRect();
1957
+ return {
1958
+ x: e - (n?.left ?? 0),
1959
+ y: t - (n?.top ?? 0)
1960
+ };
1961
+ }
1962
+ let q = m(null);
1963
+ function ye(e) {
1964
+ if (e === "composite/group") {
1965
+ we();
1966
+ return;
1967
+ }
1968
+ let t = b.value.nodeTypes[e];
1969
+ if (t) {
1970
+ let e = q.value?.world ?? {
1971
+ x: 0,
1972
+ y: 0
1973
+ }, n = R(t, {
1974
+ x: e.x,
1975
+ y: e.y
1976
+ });
1977
+ b.value.graph.nodes.push(n), Ee(b.value), oe(n.id, !1);
1978
+ }
1979
+ q.value = null;
1980
+ }
1981
+ function we() {
1982
+ let e = q.value?.world ?? {
1983
+ x: 0,
1984
+ y: 0
1985
+ }, t = b.value.graph, n = pe(_.map, {
1986
+ x: e.x,
1987
+ y: e.y
1988
+ }), r = Ie(_.map, v.value, n, t);
1989
+ if (r) {
1990
+ console.warn(`[Group] ${r}`), q.value = null;
1991
+ return;
1992
+ }
1993
+ t.nodes.push(n), Ee(b.value), oe(n.id, !1), q.value = null;
1994
+ }
1995
+ let J = m(null), Y = m(null), Me = m(null), Ne = t(() => {
1996
+ let e = J.value, t = Y.value;
1997
+ if (!e || !t) return null;
1998
+ let n = Re(t, e.dir === "output" ? "input" : "output", e.ref.node, Me.value);
1999
+ if (!n) return null;
2000
+ let r = b.value.graph.nodes.find((e) => e.id === n.node);
2001
+ return r ? it(r, n.port, g) : null;
2002
+ }), Pe = t(() => {
2003
+ let e = J.value, t = Y.value;
2004
+ if (!e || !t) return null;
2005
+ let n = Ne.value ?? t;
2006
+ return e.dir === "output" ? ot(e.pos, n) : ot(n, e.pos);
2007
+ });
2008
+ function X(e, t, n) {
2009
+ let r = b.value.graph.nodes.find((t) => t.id === e.node), i = r ? it(r, e.port, g) : null;
2010
+ i && (J.value = {
2011
+ ref: e,
2012
+ dir: t.direction,
2013
+ pos: i
2014
+ }, Y.value = K(n.clientX, n.clientY), Me.value = new Set(t.direction === "output" ? _e(b.value, e.node) : ve(b.value, e.node)), window.addEventListener("pointermove", Le), window.addEventListener("pointerup", ze));
2015
+ }
2016
+ function Le(e) {
2017
+ Y.value = K(e.clientX, e.clientY);
2018
+ }
2019
+ function Re(e, t, n, r) {
2020
+ let i = null, a = Infinity;
2021
+ for (let o of b.value.graph.nodes) {
2022
+ if (o.id === n || r?.has(o.id)) continue;
2023
+ let s = o.location.x - 20, c = o.location.x + tt(o) + 20;
2024
+ if (e.x < s || e.x > c) continue;
2025
+ let l = t === "input" ? o.inputs : o.outputs;
2026
+ for (let t of Object.values(l)) {
2027
+ if (t.userOnly) continue;
2028
+ let n = g(t), r = it(o, t.id, g);
2029
+ if (!r) continue;
2030
+ let s = $e(t, n) / 2;
2031
+ if (e.y < r.y - s || e.y > r.y + s) continue;
2032
+ let c = Math.hypot(r.x - e.x, r.y - e.y);
2033
+ c < a && (a = c, i = {
2034
+ node: o.id,
2035
+ port: t.id
2036
+ });
2037
+ }
2038
+ }
2039
+ return i;
2040
+ }
2041
+ function ze() {
2042
+ let e = J.value, t = Y.value;
2043
+ if (e && t) {
2044
+ let n = Re(t, e.dir === "output" ? "input" : "output", e.ref.node, Me.value);
2045
+ if (n) {
2046
+ let t = e.dir === "output" ? e.ref : n, r = e.dir === "output" ? n : e.ref;
2047
+ be(b.value, t, r);
2048
+ }
2049
+ }
2050
+ J.value = null, Y.value = null, Me.value = null, window.removeEventListener("pointermove", Le), window.removeEventListener("pointerup", ze);
2051
+ }
2052
+ let Be = m([]), Z = null, Q = !1, Ve = t(() => {
2053
+ let e = Be.value;
2054
+ return e.length < 2 ? null : "M " + e.map((e) => `${e.x} ${e.y}`).join(" L ");
2055
+ });
2056
+ function He(e) {
2057
+ e.preventDefault();
2058
+ let t = e.target;
2059
+ Z = {
2060
+ clientX: e.clientX,
2061
+ clientY: e.clientY,
2062
+ world: K(e.clientX, e.clientY),
2063
+ screen: ge(e.clientX, e.clientY),
2064
+ onBackground: !t?.closest(".node") && !t?.closest(".config-bar")
2065
+ }, Q = !1, Be.value = [Z.world], window.addEventListener("pointermove", Ue), window.addEventListener("pointerup", $);
2066
+ }
2067
+ function Ue(e) {
2068
+ if (!Z) return;
2069
+ if (!Q) {
2070
+ let t = e.clientX - Z.clientX, n = e.clientY - Z.clientY;
2071
+ if (Math.hypot(t, n) < Nn) return;
2072
+ Q = !0;
2073
+ }
2074
+ let t = K(e.clientX, e.clientY), n = Be.value, r = n[n.length - 1];
2075
+ n.push(t), r && We(r, t);
2076
+ }
2077
+ function We(e, t) {
2078
+ for (let n of [...b.value.graph.connections]) {
2079
+ let r = b.value.graph.nodes.find((e) => e.id === n.from.node), i = b.value.graph.nodes.find((e) => e.id === n.to.node);
2080
+ if (!r || !i) continue;
2081
+ let a = it(r, n.from.port, g), o = it(i, n.to.port, g);
2082
+ if (!a || !o) continue;
2083
+ let s = st(a, o);
2084
+ for (let r = 0; r < s.length - 1; r++) if (ct(e, t, s[r], s[r + 1])) {
2085
+ xe(b.value, n.id);
2086
+ break;
2087
+ }
2088
+ }
2089
+ }
2090
+ function $() {
2091
+ window.removeEventListener("pointermove", Ue), window.removeEventListener("pointerup", $);
2092
+ let e = Z, t = Q;
2093
+ Be.value = [], Z = null, Q = !1, !t && e && e.onBackground && (q.value = {
2094
+ screen: e.screen,
2095
+ world: e.world
2096
+ });
2097
+ }
2098
+ function Ge() {
2099
+ I.value = 0, L.value = 0, z.value = 1;
2100
+ }
2101
+ function Ke() {
2102
+ v.value = [], U(), q.value = null, S.value++;
2103
+ }
2104
+ c({ resetView: Ke });
2105
+ function qe(e) {
2106
+ if (e.key === "Escape") {
2107
+ q.value ? q.value = null : v.value.length ? O() : B.value.length ? U() : Ge();
2108
+ return;
2109
+ }
2110
+ if (e.key !== "Delete" && e.key !== "Backspace") return;
2111
+ let t = e.target;
2112
+ if (!(t instanceof HTMLElement && t.closest("input, textarea, select")) && B.value.length) {
2113
+ for (let e of B.value) Se(b.value, e) && Ce(b.value, e);
2114
+ U(), e.preventDefault();
2115
+ }
2116
+ }
2117
+ function Je(e) {
2118
+ e.preventDefault();
2119
+ let t = F.value;
2120
+ if (!t) return;
2121
+ let n = t.getBoundingClientRect(), r = e.clientX - n.left, i = e.clientY - n.top, a = (r - I.value) / z.value, o = (i - L.value) / z.value, s = Math.min(jn, Math.max(An, z.value * (1 - e.deltaY * Mn)));
2122
+ I.value = r - a * s, L.value = i - o * s, z.value = s;
2123
+ }
2124
+ function Ye(e) {
2125
+ let t = e.clientX, n = e.clientY, r = I.value, i = L.value;
2126
+ te.value = !0;
2127
+ function a(e) {
2128
+ I.value = r + (e.clientX - t), L.value = i + (e.clientY - n);
2129
+ }
2130
+ function o() {
2131
+ te.value = !1, window.removeEventListener("pointermove", a), window.removeEventListener("pointerup", o);
2132
+ }
2133
+ window.addEventListener("pointermove", a), window.addEventListener("pointerup", o);
2134
+ }
2135
+ function Xe(e) {
2136
+ e.button === 0 && (e.stopPropagation(), G = {
2137
+ clientX: e.clientX,
2138
+ clientY: e.clientY,
2139
+ world: K(e.clientX, e.clientY)
2140
+ }, le = !1, window.addEventListener("pointermove", ue), window.addEventListener("pointerup", de));
2141
+ }
2142
+ function Ze(e) {
2143
+ e.button === 1 ? (e.preventDefault(), Ye(e)) : e.button === 2 && He(e);
2144
+ }
2145
+ let Qe;
2146
+ return d(() => {
2147
+ window.addEventListener("keydown", qe), Ee(b.value), Qe = window.setInterval(() => Te(b.value), Pn);
2148
+ }), f(() => {
2149
+ window.removeEventListener("keydown", qe), Qe !== void 0 && window.clearInterval(Qe);
2150
+ }), (t, s) => (p(), i("div", {
2151
+ ref_key: "viewerEl",
2152
+ ref: F,
2153
+ class: l(["viewer", { panning: te.value }]),
2154
+ onWheel: Je,
2155
+ onPointerdown: Ze,
2156
+ onContextmenu: s[3] ||= w(() => {}, ["prevent"])
2157
+ }, [
2158
+ a("div", {
2159
+ class: "top-right-stack",
2160
+ onPointerdown: s[1] ||= w(() => {}, ["stop"])
2161
+ }, [v.value.length ? (p(), n(un, {
2162
+ key: 0,
2163
+ composite: T.value,
2164
+ "io-widgets": E.value,
2165
+ onUp: O,
2166
+ "onUpdate:ioWidgets": s[0] ||= (e) => E.value = e
2167
+ }, null, 8, ["composite", "io-widgets"])) : r("", !0), ne.value ? (p(), n(rn, {
2168
+ key: 1,
2169
+ class: "stacked-panel",
2170
+ map: b.value,
2171
+ nodes: H.value,
2172
+ def: re.value,
2173
+ "graph-interface": x.value,
2174
+ "interface-revision": S.value,
2175
+ "interface-commit-error": C.value,
2176
+ "apply-interface-mutation": k,
2177
+ error: H.value.length === 1 ? N.value[ne.value.id] : void 0
2178
+ }, null, 8, [
2179
+ "map",
2180
+ "nodes",
2181
+ "def",
2182
+ "graph-interface",
2183
+ "interface-revision",
2184
+ "interface-commit-error",
2185
+ "error"
2186
+ ])) : r("", !0)], 32),
2187
+ a("div", {
2188
+ class: "viewport",
2189
+ style: u(fe.value)
2190
+ }, [
2191
+ a("div", {
2192
+ class: "canvas-bg",
2193
+ onPointerdown: Xe
2194
+ }, null, 32),
2195
+ o(Ct, {
2196
+ map: b.value,
2197
+ "pending-path": Pe.value,
2198
+ "slice-path": Ve.value
2199
+ }, null, 8, [
2200
+ "map",
2201
+ "pending-path",
2202
+ "slice-path"
2203
+ ]),
2204
+ ce.value ? (p(), i("div", {
2205
+ key: 0,
2206
+ class: "marquee",
2207
+ style: u(ce.value)
2208
+ }, null, 4)) : r("", !0),
2209
+ (p(!0), i(e, null, h(b.value.graph.nodes, (e) => (p(), n(vt, {
2210
+ key: e.id,
2211
+ node: e,
2212
+ map: b.value,
2213
+ zoom: z.value,
2214
+ "io-widgets": D.value,
2215
+ "io-results": M.value,
2216
+ selected: B.value.includes(e.id),
2217
+ "selected-ids": V.value,
2218
+ error: N.value[e.id],
2219
+ onConnectStart: X,
2220
+ onSelect: oe,
2221
+ onDrillIn: A
2222
+ }, null, 8, [
2223
+ "node",
2224
+ "map",
2225
+ "zoom",
2226
+ "io-widgets",
2227
+ "io-results",
2228
+ "selected",
2229
+ "selected-ids",
2230
+ "error"
2231
+ ]))), 128))
2232
+ ], 4),
2233
+ q.value ? (p(), n(On, {
2234
+ key: 0,
2235
+ map: b.value,
2236
+ screen: q.value.screen,
2237
+ onSelect: ye,
2238
+ onAddComposite: we,
2239
+ onClose: s[2] ||= (e) => q.value = null
2240
+ }, null, 8, ["map", "screen"])) : r("", !0)
2241
+ ], 34));
2242
+ }
2243
+ }), [["__scopeId", "data-v-ff1ea32f"]]);
2244
+ //#endregion
2245
+ //#region src/components/types/registerDefaultTypeWidgets.ts
2246
+ function In() {
2247
+ Je("number", Q), Je("string", $);
2248
+ }
2249
+ //#endregion
2250
+ //#region src/store/nodes/math.ts
2251
+ var Ln = {
2252
+ typeId: "math/add",
2253
+ displayName: "Add",
2254
+ color: "#4a7a4a",
2255
+ description: "Add two numbers",
2256
+ group: ["math", "basic operations"],
2257
+ inputs: {
2258
+ a: {
2259
+ type: "number",
2260
+ defaultValue: 0
2261
+ },
2262
+ b: {
2263
+ type: "number",
2264
+ defaultValue: 0
2265
+ }
2266
+ },
2267
+ outputs: { sum: { type: "number" } },
2268
+ execute: (e) => ({ sum: Number(e.a ?? 0) + Number(e.b ?? 0) })
2269
+ }, Rn = {
2270
+ typeId: "math/multiply",
2271
+ displayName: "Multiply",
2272
+ color: "#4a7a4a",
2273
+ description: "Multiply two numbers",
2274
+ group: ["math", "basic operations"],
2275
+ inputs: {
2276
+ a: {
2277
+ type: "number",
2278
+ defaultValue: 0
2279
+ },
2280
+ b: {
2281
+ type: "number",
2282
+ defaultValue: 0
2283
+ }
2284
+ },
2285
+ outputs: { product: { type: "number" } },
2286
+ execute: (e) => ({ product: Number(e.a ?? 0) * Number(e.b ?? 0) })
2287
+ }, zn = {
2288
+ typeId: "math/divide",
2289
+ displayName: "Divide",
2290
+ color: "#4a7a4a",
2291
+ description: "Divide two numbers",
2292
+ group: ["math", "basic operations"],
2293
+ inputs: {
2294
+ a: {
2295
+ type: "number",
2296
+ defaultValue: 0
2297
+ },
2298
+ b: {
2299
+ type: "number",
2300
+ defaultValue: 1
2301
+ }
2302
+ },
2303
+ outputs: { quotient: { type: "number" } },
2304
+ execute: (e) => {
2305
+ let t = Number(e.a ?? 0), n = Number(e.b ?? 1);
2306
+ if (n === 0) throw Error("Division by zero");
2307
+ return { quotient: t / n };
2308
+ }
2309
+ }, Bn = {
2310
+ [Ln.typeId]: Ln,
2311
+ [Rn.typeId]: Rn,
2312
+ [zn.typeId]: zn
2313
+ };
2314
+ //#endregion
2315
+ //#region src/store/registry/defineType.ts
2316
+ function Vn(e) {
2317
+ let t = e.widget, n = Wn(t);
2318
+ return {
2319
+ id: e.id,
2320
+ label: e.label ?? Hn(e.id),
2321
+ color: e.color ?? "#888",
2322
+ validate: e.validate,
2323
+ accepts: e.accepts,
2324
+ defaultValue: e.defaultValue,
2325
+ widget: t,
2326
+ parse: e.parse ?? n.parse,
2327
+ format: e.format ?? n.format,
2328
+ coerce: e.coerce ?? n.coerce
2329
+ };
2330
+ }
2331
+ function Hn(e) {
2332
+ return e.charAt(0).toUpperCase() + e.slice(1);
2333
+ }
2334
+ function Un(e, t, n) {
2335
+ let r = Number(e);
2336
+ return Number.isNaN(r) && (r = 0), t !== void 0 && (r = Math.max(t, r)), n !== void 0 && (r = Math.min(n, r)), r;
2337
+ }
2338
+ function Wn(e) {
2339
+ if (!e) return {
2340
+ parse: (e) => e,
2341
+ format: (e) => e == null ? "" : String(e)
2342
+ };
2343
+ switch (e.kind) {
2344
+ case "number": return {
2345
+ parse: (e) => Number(e),
2346
+ format: (e) => e == null ? "" : String(e),
2347
+ coerce: (t) => Un(t, e.min, e.max)
2348
+ };
2349
+ case "text": return {
2350
+ parse: (e) => e,
2351
+ format: (e) => e == null ? "" : String(e)
2352
+ };
2353
+ case "custom": return { format: (e) => e == null ? "" : String(e) };
2354
+ }
2355
+ }
2356
+ //#endregion
2357
+ //#region src/store/types/index.ts
2358
+ var Gn = Vn({
2359
+ id: "number",
2360
+ label: "Number",
2361
+ color: "#7dd3fc",
2362
+ validate: (e) => typeof e == "number" && !Number.isNaN(e),
2363
+ defaultValue: 0,
2364
+ widget: { kind: "number" }
2365
+ }), Kn = Vn({
2366
+ id: "string",
2367
+ label: "String",
2368
+ color: "#c4b5fd",
2369
+ validate: (e) => typeof e == "string",
2370
+ defaultValue: "",
2371
+ widget: { kind: "text" }
2372
+ }), qn = {
2373
+ id: "@local/core",
2374
+ types: {
2375
+ [Gn.id]: Gn,
2376
+ [Kn.id]: Kn
2377
+ },
2378
+ nodeTypes: Bn
2379
+ };
2380
+ //#endregion
2381
+ //#region src/store/graph/createNodeMap.ts
2382
+ function Jn(e = {}) {
2383
+ let t = {
2384
+ graph: e.graph ?? {
2385
+ nodes: [],
2386
+ connections: []
2387
+ },
2388
+ types: {},
2389
+ nodeTypes: {},
2390
+ extensions: e.extensions ? [...e.extensions] : [],
2391
+ graphInterface: z(e.graphInterface ?? M),
2392
+ loadPack: () => []
2393
+ };
2394
+ return e.types && P(t, e.types), e.nodeTypes && F(t, e.nodeTypes), ie(t, t.graphInterface), oe(t), t;
2395
+ }
2396
+ //#endregion
2397
+ //#region src/store/packs/installPack.ts
2398
+ function Yn(e, t, n) {
2399
+ if (e.extensions.includes(t.id)) return [];
2400
+ let r = [];
2401
+ if (t.types) for (let n of Object.keys(t.types)) e.types[n] && r.push(`type "${n}" already registered by another pack`);
2402
+ if (t.nodeTypes) for (let n of Object.keys(t.nodeTypes)) e.nodeTypes[n] && r.push(`node type "${n}" already registered by another pack`);
2403
+ return r.length ? r : (I(e, t), n && t.setup?.(n), []);
2404
+ }
2405
+ //#endregion
2406
+ //#region src/vue/attachLoadPack.ts
2407
+ function Xn() {
2408
+ return {
2409
+ registerTypeWidget: Je,
2410
+ registerComponentWidget: Ye
2411
+ };
2412
+ }
2413
+ function Zn(e) {
2414
+ e.loadPack = (t) => Yn(e, t, Xn());
2415
+ }
2416
+ //#endregion
2417
+ //#region src/vue/createNodeMap.ts
2418
+ var Qn = !1;
2419
+ function $n(e = {}) {
2420
+ Qn ||= (In(), !0);
2421
+ let t = Jn(e);
2422
+ Zn(t), e.defaultPack !== !1 && t.loadPack(qn);
2423
+ for (let n of e.packs ?? []) t.loadPack(n);
2424
+ return t;
2425
+ }
2426
+ //#endregion
2427
+ //#region src/store/graph/validateGraphTypes.ts
2428
+ function er(e, t, n, r, i) {
2429
+ e.types[n.type] || i.push(`node "${t.label ?? t.typeId}" (${t.id}): unknown ${r} port type "${n.type}" on port "${n.name}"`);
2430
+ }
2431
+ function tr(e, t, n) {
2432
+ e.nodeTypes[t.typeId] || n.push(`node "${t.label ?? t.id}": unknown typeId "${t.typeId}"`);
2433
+ for (let r of Object.values(t.inputs)) er(e, t, r, "input", n);
2434
+ for (let r of Object.values(t.outputs)) er(e, t, r, "output", n);
2435
+ t.composite?.graph && nr(e, t.composite.graph, n);
2436
+ }
2437
+ function nr(e, t, n = []) {
2438
+ for (let r of t.nodes) tr(e, r, n);
2439
+ return n;
2440
+ }
2441
+ //#endregion
2442
+ //#region src/store/graph/document.ts
2443
+ function rr(e) {
2444
+ return {
2445
+ graph: z(e.graph),
2446
+ interface: z(e.graphInterface),
2447
+ extensions: e.extensions.length ? [...e.extensions] : void 0
2448
+ };
2449
+ }
2450
+ function ir(e) {
2451
+ return rr(e);
2452
+ }
2453
+ function ar(e) {
2454
+ let t;
2455
+ try {
2456
+ t = JSON.parse(e);
2457
+ } catch {
2458
+ throw Error("invalid JSON");
2459
+ }
2460
+ if (!t || typeof t != "object") throw Error("document must be an object");
2461
+ let n = t;
2462
+ if (!n.graph || typeof n.graph != "object") throw Error("document missing graph");
2463
+ if (!Array.isArray(n.graph.nodes)) throw Error("graph.nodes must be an array");
2464
+ if (!Array.isArray(n.graph.connections)) throw Error("graph.connections must be an array");
2465
+ if (!n.interface || typeof n.interface != "object") throw Error("document missing interface");
2466
+ if (n.extensions !== void 0 && (!Array.isArray(n.extensions) || n.extensions.some((e) => typeof e != "string"))) throw Error("extensions must be an array of strings");
2467
+ return n;
2468
+ }
2469
+ function or(e, t) {
2470
+ return t?.length ? t.filter((t) => !e.extensions.includes(t)).map((e) => `missing pack "${e}" (call map.loadPack() before import)`) : [];
2471
+ }
2472
+ function sr(e, t) {
2473
+ let n = [];
2474
+ return n.push(...or(e, t.extensions)), n.push(...se({
2475
+ ...e,
2476
+ graph: t.graph
2477
+ })), n.push(...B(e, t.interface)), n.push(...nr(e, t.graph)), n;
2478
+ }
2479
+ function cr(e, t) {
2480
+ let n = or(e, t.extensions);
2481
+ return n.length ? n : (e.graph = z(t.graph), e.graphInterface = z(t.interface), ie(e, e.graphInterface), oe(e), n.push(...sr(e, t)), n);
2482
+ }
2483
+ function lr(e, t) {
2484
+ return cr(e, t);
2485
+ }
2486
+ //#endregion
2487
+ export { V as INPUT_TYPE, Fn as NodeViewer, H as OUTPUT_TYPE, cr as applyDocument, ae as boundaryNodes, $n as createNodeMap, Vn as defineType, ir as exportGraph, lr as importGraph, R as instantiate, ar as parseGraphDocument, Ye as registerComponentWidget, In as registerDefaultTypeWidgets, Je as registerTypeWidget, he as runGraph, rr as serializeDocument, sr as validateDocument };