@babsey/code-graph 0.0.17 → 0.1.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 (37) hide show
  1. package/dist/code-graph.css +1 -1
  2. package/dist/code-graph.js +693 -486
  3. package/dist/code-graph.umd.cjs +1 -1
  4. package/dist/code.d.ts +19 -2
  5. package/dist/codeNode/codeNode.d.ts +32 -4
  6. package/dist/codeNode/defineCodeNode.d.ts +4 -2
  7. package/dist/codeNode/dynamicCodeNode.d.ts +3 -1
  8. package/dist/codeNodeInterfaces/checkbox/checkboxInterface.d.ts +0 -2
  9. package/dist/codeNodeInterfaces/codeNode/CodeNodeInterface.vue.d.ts +2 -1
  10. package/dist/codeNodeInterfaces/codeNode/codeNodeInterface.d.ts +4 -1
  11. package/dist/codeNodeInterfaces/codeNodeInput/codeNodeInputInterface.d.ts +1 -0
  12. package/dist/codeNodeInterfaces/number/numberInterface.d.ts +0 -2
  13. package/dist/codeNodeInterfaces/textInput/TextInputInterface.vue.d.ts +26 -0
  14. package/dist/codeNodeInterfaces/textInput/textInputInterface.d.ts +2 -0
  15. package/dist/components/CodeGraphEditor.vue.d.ts +14 -1
  16. package/dist/components/node/CodeGraphNode.vue.d.ts +7 -6
  17. package/dist/components/nodeInterface/CodeGraphNodeInterface.vue.d.ts +3 -2
  18. package/dist/components/nodePalette/CodeNodePalette.vue.d.ts +2 -1
  19. package/dist/components/nodePalette/PaletteEntry.vue.d.ts +2 -1
  20. package/dist/components/sidebar/Checkbox.vue.d.ts +2 -1
  21. package/dist/components/sidebar/CodeGraphSidebar.vue.d.ts +14 -1
  22. package/dist/icons/Check.vue.d.ts +3 -0
  23. package/dist/icons/CodeVariable.vue.d.ts +2 -1
  24. package/dist/icons/Copy.vue.d.ts +3 -0
  25. package/dist/icons/DotsVertical.vue.d.ts +2 -1
  26. package/dist/icons/LayoutSidebarLeftCollapse.vue.d.ts +2 -1
  27. package/dist/icons/LayoutSidebarLeftExpand.vue.d.ts +2 -1
  28. package/dist/icons/LayoutSidebarRight.vue.d.ts +2 -1
  29. package/dist/icons/LayoutSidebarRightCollapse.vue.d.ts +2 -1
  30. package/dist/icons/LayoutSidebarRightExpand.vue.d.ts +2 -1
  31. package/dist/icons/LockCode.vue.d.ts +3 -0
  32. package/dist/icons/Schema.vue.d.ts +2 -1
  33. package/dist/icons/SchemaOff.vue.d.ts +2 -1
  34. package/dist/icons/TransitionBottom.vue.d.ts +2 -1
  35. package/dist/icons/TrashOff.vue.d.ts +2 -1
  36. package/dist/icons/index.d.ts +3 -0
  37. package/package.json +7 -7
@@ -1,12 +1,11 @@
1
- import { AbstractNode as Ae, sortTopologically as Ce, NodeInterface as Fe, displayInSidebar as Ie, NodeInterfaceType as G, BaklavaInterfaceTypes as We, CheckboxInterfaceComponent as Xe, setType as E, IntegerInterfaceComponent as Je, TextInputInterfaceComponent as se, NumberInterfaceComponent as Ye, SelectInterfaceComponent as qe, SliderInterfaceComponent as Qe, TextareaInputInterfaceComponent as Ke, allowMultipleConnections as Y, IntegerInterface as Ze, TextInputInterface as et, useViewModel as F, useTemporaryConnection as tt, Components as we, useGraph as ne, GRAPH_NODE_TYPE_PREFIX as K, useTransform as st, useNodeCategories as nt, BaklavaEditor as ot, DEFAULT_TOOLBAR_COMMANDS as at, useBaklava as it, DependencyEngine as rt, applyResult as lt } from "baklavajs";
2
- import { CheckboxInterfaceComponent as In, NumberInterfaceComponent as Nn } from "baklavajs";
3
- import q from "mustache";
4
- import { reactive as R, defineComponent as L, createElementBlock as r, openBlock as i, toDisplayString as B, markRaw as M, ref as T, computed as _, onMounted as oe, onUpdated as Ne, normalizeClass as U, createCommentVNode as I, createElementVNode as l, unref as y, renderSlot as Z, createStaticVNode as Q, onBeforeUnmount as dt, normalizeStyle as ae, withModifiers as P, createBlock as S, withDirectives as ie, Fragment as z, createTextVNode as ut, createVNode as V, withKeys as ee, vModelText as re, renderList as H, nextTick as ct, toRef as Me, resolveDynamicComponent as pt, inject as ht, Transition as vt, withCtx as J, onUnmounted as mt, normalizeProps as ft, guardReactiveProps as gt, mergeProps as bt } from "vue";
5
- import yt from "toposort";
6
- import { v4 as _t } from "uuid";
7
- import { usePointer as wt } from "@vueuse/core";
8
- q.escape = (s) => s;
9
- class kt extends Ae {
1
+ import { AbstractNode as We, sortTopologically as Ne, NodeInterface as Xe, displayInSidebar as Me, NodeInterfaceType as R, BaklavaInterfaceTypes as qe, CheckboxInterfaceComponent as Je, setType as S, IntegerInterfaceComponent as Ye, TextInputInterfaceComponent as $e, NumberInterfaceComponent as Qe, SelectInterfaceComponent as Ke, SliderInterfaceComponent as Ze, TextareaInputInterfaceComponent as et, allowMultipleConnections as K, IntegerInterface as tt, TextInputInterface as st, useViewModel as q, useTemporaryConnection as nt, Components as ke, useGraph as ae, GRAPH_NODE_TYPE_PREFIX as se, useTransform as ot, useNodeCategories as at, BaklavaEditor as it, DEFAULT_TOOLBAR_COMMANDS as rt, useBaklava as lt, DependencyEngine as dt, applyResult as ut } from "baklavajs";
2
+ import Z from "mustache";
3
+ import { reactive as P, defineComponent as U, createElementBlock as r, openBlock as i, toDisplayString as j, markRaw as E, computed as b, createElementVNode as l, withDirectives as ee, vModelText as te, ref as B, onMounted as ie, onUpdated as Oe, normalizeClass as G, createCommentVNode as I, unref as _, renderSlot as W, createStaticVNode as J, onBeforeUnmount as ct, normalizeStyle as re, withModifiers as A, createBlock as O, Fragment as T, createTextVNode as pt, createVNode as z, withKeys as ne, renderList as D, nextTick as ht, toRef as Te, resolveDynamicComponent as Ce, inject as vt, Transition as mt, withCtx as F, onUnmounted as ft, normalizeProps as gt, guardReactiveProps as bt, mergeProps as yt } from "vue";
4
+ import _t from "toposort";
5
+ import { v4 as kt } from "uuid";
6
+ import { usePointer as Ct } from "@vueuse/core";
7
+ Z.escape = (s) => s;
8
+ class wt extends We {
10
9
  state;
11
10
  code;
12
11
  isCodeNode = !0;
@@ -15,11 +14,13 @@ class kt extends Ae {
15
14
  inputs = {};
16
15
  outputs = {};
17
16
  constructor() {
18
- super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state = R({
17
+ super(), this.initializeIo(), this.width = 400, this.twoColumn = !0, this.state = P({
19
18
  codeTemplate: "",
20
19
  hidden: !1,
21
20
  integrated: !1,
21
+ lockCode: !1,
22
22
  modules: [],
23
+ props: null,
23
24
  script: "",
24
25
  variableName: ""
25
26
  }), this.codeTemplate = function() {
@@ -27,7 +28,14 @@ class kt extends Ae {
27
28
  };
28
29
  }
29
30
  get codeNodeInputs() {
30
- return Object.fromEntries(Object.entries(this.inputs).filter(([e, t]) => t.type != "node"));
31
+ return Object.fromEntries(
32
+ Object.entries(this.inputs).filter((e) => e[1].type != "node")
33
+ );
34
+ }
35
+ get codeNodeOutputs() {
36
+ return Object.fromEntries(
37
+ Object.entries(this.outputs).filter((e) => e[1].type != "node")
38
+ );
31
39
  }
32
40
  get idx() {
33
41
  return this.code?.codeNodes.filter((e) => !e.state.integrated).indexOf(this) ?? -1;
@@ -35,15 +43,28 @@ class kt extends Ae {
35
43
  get idxByVariableNames() {
36
44
  return this.code?.getNodesBySameVariableNames(this.state.variableName).indexOf(this) ?? -1;
37
45
  }
46
+ get lockCode() {
47
+ return this.state.lockCode;
48
+ }
49
+ set lockCode(e) {
50
+ this.state.lockCode = e, this.events.update.emit(null);
51
+ }
38
52
  get optionalInputs() {
39
- return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(([e, t]) => t.optional));
53
+ return Object.fromEntries(
54
+ Object.entries(this.codeNodeInputs).filter((e) => e[1].optional)
55
+ );
40
56
  }
41
57
  get requiredInputs() {
42
- return Object.fromEntries(Object.entries(this.codeNodeInputs).filter(([e, t]) => !t.optional));
58
+ return Object.fromEntries(
59
+ Object.entries(this.codeNodeInputs).filter((e) => !e[1].optional)
60
+ );
43
61
  }
44
62
  get script() {
45
63
  return this.state.script;
46
64
  }
65
+ set script(e) {
66
+ this.state.script = e, this.events.update.emit(null);
67
+ }
47
68
  get shortId() {
48
69
  return this.id.slice(0, 6);
49
70
  }
@@ -52,6 +73,15 @@ class kt extends Ae {
52
73
  get variableName() {
53
74
  return this.state.variableName ? this.state.variableName + (this.idxByVariableNames + 1) : "";
54
75
  }
76
+ /**
77
+ * Get connected node to the node interface.
78
+ * @param nodeInterface string
79
+ * @returns code node instance or null
80
+ */
81
+ getConnectedNodeByInterface(e, t) {
82
+ const n = this.getConnectedNodesByInterface(e, t);
83
+ return n.length > 0 ? n[0] : null;
84
+ }
55
85
  /**
56
86
  * Get connected nodes to the node.
57
87
  * @param type inputs or outputs
@@ -69,6 +99,31 @@ class kt extends Ae {
69
99
  }
70
100
  return !t || t.length == 0 ? [] : t.map((n) => this.graph?.findNodeById(n));
71
101
  }
102
+ /**
103
+ * Get connected nodes to the node interface.
104
+ * @param nodeInterface string
105
+ * @returns code node instances
106
+ */
107
+ getConnectedNodesByInterface(e, t) {
108
+ let n = [];
109
+ if (t !== "outputs" && this.inputs[e]) {
110
+ const o = this.graph?.connections.filter(
111
+ (a) => a.to.id === this.inputs[e]?.id || a.from.id === this.inputs[e]?.id
112
+ ).map((a) => a.from.nodeId);
113
+ o && (n = n.concat(o));
114
+ }
115
+ if (t !== "inputs" && this.outputs[e]) {
116
+ const o = this.graph?.connections.filter(
117
+ (a) => a.from.id === this.outputs[e]?.id || a.from.id === this.outputs[e]?.id
118
+ ).map((a) => a.to.nodeId);
119
+ o && (n = n.concat(o));
120
+ }
121
+ return !n || n.length == 0 ? [] : n.map((o) => this.graph?.findNodeById(o));
122
+ }
123
+ /**
124
+ * Register code
125
+ * @param code
126
+ */
72
127
  registerCode(e) {
73
128
  this.code = e;
74
129
  }
@@ -76,19 +131,25 @@ class kt extends Ae {
76
131
  * Render code of this node.
77
132
  */
78
133
  renderCode() {
79
- const e = {};
80
- Object.keys(this.inputs).forEach((n) => {
81
- if (n === "_node") return;
82
- const o = this.inputs[n];
83
- o && o.state && (e[n] = o.state.script.length > 0 ? o.state.script : o.getValue());
84
- });
85
- const t = {};
86
- Object.keys(this.outputs).forEach((n) => {
87
- if (n === "_node") return;
88
- const o = this.outputs[n];
89
- o && o.state && (t[n] = o.getValue());
90
- }), this.state.script = q.render(this.state.codeTemplate, { inputs: e, outputs: t }), this.outputs.code && (this.outputs.code.state.script = this.state.script);
134
+ if (!this.lockCode) {
135
+ const e = {};
136
+ Object.keys(this.inputs).forEach((n) => {
137
+ if (n === "_node") return;
138
+ const o = this.inputs[n];
139
+ o && o.state && (e[n] = o.state.script.length > 0 ? o.state.script : o.getValue());
140
+ });
141
+ const t = {};
142
+ Object.keys(this.outputs).forEach((n) => {
143
+ if (n === "_node") return;
144
+ const o = this.outputs[n];
145
+ o && o.state && (t[n] = o.getValue());
146
+ }), this.state.script = Z.render(this.state.codeTemplate, { inputs: e, outputs: t });
147
+ }
148
+ this.outputs.out && (this.outputs.out.state.script = this.script);
91
149
  }
150
+ /**
151
+ * Reset script of input interfaces.
152
+ */
92
153
  resetInputInterfaceScript() {
93
154
  Object.values(this.inputs).forEach((e) => e.state.script = "");
94
155
  }
@@ -97,28 +158,25 @@ class kt extends Ae {
97
158
  }
98
159
  updateConnectedInputInterfaces() {
99
160
  if (!this.graph) return;
100
- const { connectionsFromNode: e } = Ce(this.graph);
161
+ const { connectionsFromNode: e } = Ne(this.graph);
101
162
  if (!e.has(this)) return;
102
163
  const t = e.get(this);
103
164
  t && t.forEach((n) => {
104
165
  if (!n.from.isCodeNode || !n.to.isCodeNode) return;
105
166
  const o = this.graph?.findNodeById(n.from.nodeId);
106
- if (o)
107
- if (o.renderCode(), n.to.allowMultipleConnections)
108
- if (n.to.state.script.startsWith("[") && n.to.state.script.endsWith("]")) {
109
- const a = JSON.parse(n.to.state.script);
110
- n.to.state.script = JSON.stringify([...a, n.from.script]);
111
- } else
112
- n.to.state.script += n.from.script;
113
- else
114
- n.to.state.script = n.from.script;
167
+ o && (o.renderCode(), n.to.script = n.from.script);
168
+ });
169
+ }
170
+ updateOutputNames() {
171
+ Object.values(this.codeNodeOutputs).forEach((e) => {
172
+ e.name = this.state.integrated ? "" : this.variableName + e.value;
115
173
  });
116
174
  }
117
- updateOutputVariableName() {
118
- this.outputs.code && (this.outputs.code.name = this.state.integrated ? "" : this.variableName);
175
+ updateProps(e) {
176
+ this.state.props = e;
119
177
  }
120
178
  }
121
- class $e extends kt {
179
+ class Ee extends wt {
122
180
  /**
123
181
  * The default implementation does nothing.
124
182
  * Overwrite this method to do calculation.
@@ -128,11 +186,11 @@ class $e extends kt {
128
186
  */
129
187
  calculate;
130
188
  load(e) {
131
- super.load(e), Oe(this.graph, e);
189
+ super.load(e), Ve(this.graph, e);
132
190
  }
133
191
  save() {
134
192
  const e = super.save();
135
- return Ct(this.graph, e), e;
193
+ return It(this.graph, e), e;
136
194
  }
137
195
  updateModules(e) {
138
196
  if (e)
@@ -143,14 +201,14 @@ class $e extends kt {
143
201
  }
144
202
  }
145
203
  }
146
- const xt = (s) => {
147
- const e = [], t = Object.keys(s);
148
- return t.forEach((n) => {
149
- if (s[n]?.hidden) return;
150
- const a = e.length < t.indexOf(n) ? `${n}=` : "";
151
- e.push(`${a}{{ inputs.${n} }}`);
152
- }), e;
153
- }, Oe = (s, e) => {
204
+ const xt = (s, e = !0) => {
205
+ const t = [], n = Object.keys(s);
206
+ return n.forEach((o) => {
207
+ if (s[o]?.hidden) return;
208
+ const d = e && t.length < n.indexOf(o) ? `${o}=` : "";
209
+ t.push(`${d}{{ inputs.${o} }}`);
210
+ }), t;
211
+ }, Ve = (s, e) => {
154
212
  if (!s) return;
155
213
  const t = s.findNodeById(e.id);
156
214
  if (!t || t.subgraph) return;
@@ -160,7 +218,7 @@ const xt = (s) => {
160
218
  }), Object.entries(e.outputs).forEach(([o, a]) => {
161
219
  o !== "_node" && n.outputs[o] && (n.outputs[o].hidden = a.hidden);
162
220
  });
163
- }, Ct = (s, e) => {
221
+ }, It = (s, e) => {
164
222
  if (!s) return;
165
223
  const t = s.findNodeById(e.id);
166
224
  if (!t || t.subgraph) return;
@@ -170,7 +228,7 @@ const xt = (s) => {
170
228
  }), Object.entries(e.outputs).forEach(([o, a]) => {
171
229
  o !== "_node" && n.outputs[o] && (a.hidden = n.outputs[o].hidden);
172
230
  });
173
- }, It = ["title"], le = /* @__PURE__ */ L({
231
+ }, Nt = ["title"], le = /* @__PURE__ */ U({
174
232
  __name: "CodeNodeInterface",
175
233
  props: {
176
234
  intf: {}
@@ -178,16 +236,16 @@ const xt = (s) => {
178
236
  setup(s) {
179
237
  return (e, t) => (i(), r("div", {
180
238
  title: s.intf.state?.script
181
- }, B(s.intf.name), 9, It));
239
+ }, j(s.intf.name), 9, Nt));
182
240
  }
183
241
  });
184
- class D extends Fe {
242
+ class H extends Xe {
185
243
  isCodeNode = !0;
186
244
  code;
187
245
  state;
188
246
  type = null;
189
247
  constructor(e, t) {
190
- super(e, t), this.setComponent(M(le)), this.state = R({
248
+ super(e, t), this.setComponent(E(le)), this.state = P({
191
249
  optional: !1,
192
250
  script: ""
193
251
  });
@@ -195,17 +253,30 @@ class D extends Fe {
195
253
  get optional() {
196
254
  return this.state.optional;
197
255
  }
256
+ get script() {
257
+ return this.state.script;
258
+ }
259
+ set script(e) {
260
+ this.state.script = e;
261
+ }
198
262
  get shortId() {
199
263
  return this.id.slice(0, 6);
200
264
  }
201
265
  getValue = () => `${this.value ?? "None"}`;
202
266
  }
203
- const on = (s, e) => {
267
+ const yn = (s, e) => {
204
268
  s.state.optional = e, s.setHidden(e);
205
269
  };
206
- class W extends D {
270
+ class Y extends H {
207
271
  constructor(e = "", t) {
208
- super(e, t), this.setComponent(M(le)), this.use(Ie, !0);
272
+ super(e, t), this.setComponent(E(le)), this.use(Me, !0);
273
+ }
274
+ set script(e) {
275
+ if (this.state.script && this.allowMultipleConnections) {
276
+ const t = this.state.script;
277
+ t.startsWith("[") && t.endsWith("]") ? e = JSON.stringify([e, ...JSON.parse(t)]) : e = [e, t].join(", ");
278
+ }
279
+ this.state.script = e;
209
280
  }
210
281
  get value() {
211
282
  return super.value;
@@ -214,64 +285,64 @@ class W extends D {
214
285
  super.value = e, this.name !== "_node" && this.setHidden(!1);
215
286
  }
216
287
  }
217
- const Te = new G("boolean"), Nt = new G("dict"), Ee = new G("list"), A = new G("node"), de = new G("number"), ue = new G("string"), Se = new G("tuple"), an = (s) => {
218
- new We(s.editor, { viewPlugin: s }).addTypes(Te, Nt, Ee, A, de, ue, Se);
288
+ const Be = new R("boolean"), Mt = new R("dict"), Se = new R("list"), X = new R("node"), de = new R("number"), ue = new R("string"), ze = new R("tuple"), _n = (s) => {
289
+ new qe(s.editor, { viewPlugin: s }).addTypes(Be, Mt, Se, X, de, ue, ze);
219
290
  };
220
- class rn extends W {
291
+ class kn extends Y {
221
292
  constructor(e, t) {
222
- super(e, t), this.setComponent(M(Xe)), this.use(E, Te);
293
+ super(e, t), this.setComponent(E(Je)), this.use(S, Be);
223
294
  }
224
295
  getValue = () => this.value ? "True" : "False";
225
296
  }
226
- class Mt extends D {
297
+ class $t extends H {
227
298
  isCodeNodeOutput = !0;
228
299
  constructor(e = "", t = "") {
229
- super(e, t), this.setComponent(M(le));
300
+ super(e, t), this.setComponent(E(le));
230
301
  }
231
302
  get script() {
232
- return this.name.length > 0 ? this.name : this.state.script;
303
+ return this.name ? this.name : this.state.script;
233
304
  }
234
305
  }
235
- class ce extends W {
306
+ class ce extends Y {
236
307
  min;
237
308
  max;
238
309
  constructor(e, t, n, o) {
239
- super(e, t), this.min = n, this.max = o, this.use(E, de);
310
+ super(e, t), this.min = n, this.max = o, this.use(S, de);
240
311
  }
241
312
  validate(e) {
242
313
  return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
243
314
  }
244
315
  }
245
- class ln extends ce {
246
- component = M(Je);
316
+ class Cn extends ce {
317
+ component = E(Ye);
247
318
  validate(e) {
248
319
  return Number.isInteger(e) && super.validate(e);
249
320
  }
250
321
  }
251
- class dn extends W {
322
+ class wn extends Y {
252
323
  constructor(e = "", t = "") {
253
- super(e, t), this.setComponent(M(se)), this.use(E, Ee);
324
+ super(e, t), this.setComponent(E($e)), this.use(S, Se);
254
325
  }
255
326
  getValue = () => `[${this.value}]`;
256
327
  }
257
- class un extends ce {
258
- component = M(Ye);
328
+ class xn extends ce {
329
+ component = E(Qe);
259
330
  }
260
- class pe extends W {
331
+ class pe extends Y {
261
332
  constructor(e, t) {
262
- super(e, t), this.use(E, ue);
333
+ super(e, t), this.use(S, ue);
263
334
  }
264
- getValue = () => `'${this.value}'`;
335
+ getValue = () => `"${this.value}"`;
265
336
  }
266
- class cn extends pe {
267
- component = M(qe);
337
+ class In extends pe {
338
+ component = E(Ke);
268
339
  items;
269
340
  constructor(e, t, n) {
270
341
  super(e, t), this.items = n;
271
342
  }
272
343
  }
273
- class pn extends ce {
274
- component = M(Qe);
344
+ class Nn extends ce {
345
+ component = E(Ze);
275
346
  min;
276
347
  max;
277
348
  constructor(e, t, n, o) {
@@ -279,30 +350,71 @@ class pn extends ce {
279
350
  }
280
351
  getValue = () => `${Math.round(this.value * 1e3) / 1e3}`;
281
352
  }
282
- class hn extends pe {
283
- component = M(se);
353
+ const Ot = U({
354
+ props: {
355
+ intf: {
356
+ type: Object,
357
+ required: !0
358
+ },
359
+ modelValue: {
360
+ type: String,
361
+ required: !0
362
+ }
363
+ },
364
+ emits: ["update:modelValue"],
365
+ setup(s, { emit: e }) {
366
+ return { v: b({
367
+ get: () => s.modelValue,
368
+ set: (n) => {
369
+ e("update:modelValue", n);
370
+ }
371
+ }) };
372
+ }
373
+ }), $ = (s, e) => {
374
+ const t = s.__vccOpts || s;
375
+ for (const [n, o] of e)
376
+ t[n] = o;
377
+ return t;
378
+ }, Tt = { style: { position: "relative" } }, Et = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, Vt = ["placeholder", "title"];
379
+ function Bt(s, e, t, n, o, a) {
380
+ return i(), r("div", Tt, [
381
+ l("label", Et, j(s.intf.name), 1),
382
+ ee(l("input", {
383
+ "onUpdate:modelValue": e[0] || (e[0] = (d) => s.v = d),
384
+ type: "text",
385
+ class: "baklava-input",
386
+ placeholder: s.intf.name,
387
+ title: s.intf.name
388
+ }, null, 8, Vt), [
389
+ [te, s.v]
390
+ ])
391
+ ]);
392
+ }
393
+ const St = /* @__PURE__ */ $(Ot, [["render", Bt]]);
394
+ class Mn extends pe {
395
+ component = E(St);
284
396
  }
285
- class vn extends pe {
286
- component = M(Ke);
397
+ class $n extends pe {
398
+ component = E(et);
287
399
  }
288
- class mn extends W {
400
+ class On extends Y {
289
401
  constructor(e = "", t = "") {
290
- super(e, t), this.setComponent(M(se)), this.use(E, Se);
402
+ super(e, t), this.setComponent(E($e)), this.use(S, ze);
291
403
  }
292
404
  getValue = () => `(${this.value})`;
293
405
  }
294
- function fn(s) {
295
- return class extends $e {
406
+ function Tn(s) {
407
+ return class extends Ee {
296
408
  type = s.type;
297
409
  inputs = {};
298
410
  outputs = {};
299
411
  constructor() {
300
412
  super(), this._title = s.title ?? s.type, this.name = s.name ?? s.type, this.updateModules(s.modules), s.variableName && (this.state.variableName = s.variableName), s.codeTemplate && (this.codeTemplate = s.codeTemplate), this.addInput(
301
413
  "_node",
302
- new D("", []).use(E, A).use(Y).setHidden(!0)
414
+ new H("", []).use(S, X).use(K).setHidden(!0)
303
415
  ), this.addOutput(
304
416
  "_node",
305
- new D("", []).use(E, A).use(Y).setHidden(!0)
417
+ new H("", []).use(S, X).use(K).setHidden(!0)
306
418
  ), this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this);
307
419
  }
308
420
  // public calculate = definition.calculate
@@ -314,11 +426,17 @@ function fn(s) {
314
426
  onPlaced() {
315
427
  s.onPlaced?.call(this);
316
428
  }
429
+ onConnected() {
430
+ s.onConnected?.call(this);
431
+ }
317
432
  onDestroy() {
318
433
  s.onDestroy?.call(this);
319
434
  }
320
- onCodeUpdate() {
321
- s.onCodeUpdate?.call(this);
435
+ onUnconnected() {
436
+ s.onUnconnected?.call(this);
437
+ }
438
+ update() {
439
+ s.update?.call(this);
322
440
  }
323
441
  executeFactory(e, t) {
324
442
  Object.keys(t || {}).forEach((n) => {
@@ -328,7 +446,7 @@ function fn(s) {
328
446
  }
329
447
  };
330
448
  }
331
- class $t extends $e {
449
+ class zt extends Ee {
332
450
  /**
333
451
  * The default implementation does nothing.
334
452
  * Overwrite this method to do calculation.
@@ -338,8 +456,8 @@ class $t extends $e {
338
456
  */
339
457
  calculate;
340
458
  }
341
- function gn(s) {
342
- return class extends $t {
459
+ function En(s) {
460
+ return class extends zt {
343
461
  type = s.type;
344
462
  inputs = {};
345
463
  outputs = {};
@@ -350,10 +468,10 @@ function gn(s) {
350
468
  constructor() {
351
469
  super(), this._title = s.title ?? s.type, this.name = s.name ?? s.type, this.updateModules(s.modules), s.codeTemplate && (this.codeTemplate = s.codeTemplate), s.variableName && (this.state.variableName = s.variableName), this.addInput(
352
470
  "_node",
353
- new D("", []).use(E, A).use(Y).setHidden(!0)
471
+ new H("", []).use(S, X).use(K).setHidden(!0)
354
472
  ), this.addOutput(
355
473
  "_node",
356
- new D("", []).use(E, A).use(Y).setHidden(!0)
474
+ new H("", []).use(S, X).use(K).setHidden(!0)
357
475
  ), this.staticInputKeys.push("_node"), this.staticOutputKeys.push("_node"), this.executeFactory("input", s.inputs), this.executeFactory("output", s.outputs), s.onCreate?.call(this);
358
476
  }
359
477
  onPlaced() {
@@ -361,11 +479,17 @@ function gn(s) {
361
479
  e && (e.type === "input" && this.staticInputKeys.includes(e.name) || e.type === "output" && this.staticOutputKeys.includes(e.name)) && this.onUpdate();
362
480
  }), this.onUpdate(), s.onPlaced?.call(this);
363
481
  }
482
+ onConnected() {
483
+ s.onConnected?.call(this);
484
+ }
364
485
  onDestroy() {
365
486
  s.onDestroy?.call(this);
366
487
  }
367
- onCodeUpdate() {
368
- s.onCodeUpdate?.call(this);
488
+ onUnconnected() {
489
+ s.onUnconnected?.call(this);
490
+ }
491
+ update() {
492
+ s.update?.call(this);
369
493
  }
370
494
  load(e) {
371
495
  this.preventUpdate = !0, this.hooks.beforeLoad.execute(e), this.id = e.id, this.title = e.title;
@@ -379,19 +503,19 @@ function gn(s) {
379
503
  if (!this.inputs[t]) {
380
504
  const n = e.inputs[t].value;
381
505
  let o;
382
- typeof n == "number" ? o = new Ze(t, n).use(E, de) : o = new et(t, JSON.stringify(n)).use(E, ue), o.use(Ie, !0), this.addInput(t, o);
506
+ typeof n == "number" ? o = new tt(t, n).use(S, de) : o = new st(t, JSON.stringify(n)).use(S, ue), o.use(Me, !0), this.addInput(t, o);
383
507
  }
384
508
  this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
385
509
  }
386
510
  for (const t of Object.keys(e.outputs))
387
511
  if (!this.staticOutputKeys.includes(t)) {
388
512
  if (!this.outputs[t]) {
389
- const n = new Mt(t);
513
+ const n = new $t(t);
390
514
  this.addOutput(t, n);
391
515
  }
392
516
  this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
393
517
  }
394
- Oe(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
518
+ Ve(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
395
519
  }
396
520
  onUpdate() {
397
521
  if (this.preventUpdate) return;
@@ -415,6 +539,9 @@ function gn(s) {
415
539
  e === "input" ? this.addInput(d, u) : this.addOutput(d, u);
416
540
  }
417
541
  }
542
+ updateProps(e) {
543
+ this.state.props = e, this.onUpdate();
544
+ }
418
545
  executeFactory(e, t) {
419
546
  Object.keys(t || {}).forEach((n) => {
420
547
  const o = t[n]();
@@ -423,22 +550,23 @@ function gn(s) {
423
550
  }
424
551
  };
425
552
  }
426
- q.escape = (s) => s;
427
- class Ot {
553
+ Z.escape = (s) => s;
554
+ class jt {
428
555
  _id;
429
556
  _viewModel;
430
557
  _state;
431
558
  constructor(e) {
432
- this._id = _t(), this._viewModel = e, this._state = R({
559
+ this._id = kt(), this._viewModel = e, this._state = P({
433
560
  autosort: !1,
561
+ lockCode: !1,
434
562
  modules: {},
435
563
  script: "",
436
- token: null,
437
- template: ""
564
+ template: "",
565
+ token: null
438
566
  });
439
567
  }
440
568
  get codeNodes() {
441
- return te(this.graph);
569
+ return oe(this.graph);
442
570
  }
443
571
  get connections() {
444
572
  return this.graph.connections;
@@ -452,6 +580,12 @@ class Ot {
452
580
  get id() {
453
581
  return this._id;
454
582
  }
583
+ get lockCode() {
584
+ return this.state.lockCode;
585
+ }
586
+ set lockCode(e) {
587
+ this.state.lockCode = e, this.viewModel.engine.runOnce(null);
588
+ }
455
589
  get modules() {
456
590
  let e = [];
457
591
  return this.codeNodes.filter((t) => t.state.modules?.length > 0).forEach((t) => {
@@ -467,8 +601,14 @@ class Ot {
467
601
  set nodes(e) {
468
602
  this.graph._nodes = e;
469
603
  }
604
+ get script() {
605
+ return this.state.script;
606
+ }
607
+ set script(e) {
608
+ this.state.script = e, this.viewModel.engine.runOnce(null);
609
+ }
470
610
  get scriptedCodeNodes() {
471
- return te(this.graph).filter(
611
+ return oe(this.graph).filter(
472
612
  (e) => !e.state?.integrated
473
613
  );
474
614
  }
@@ -547,9 +687,6 @@ class Ot {
547
687
  this._state.template = t.default ?? "";
548
688
  });
549
689
  }
550
- onCodeUpdate() {
551
- this.codeNodes.forEach((e) => e.onCodeUpdate());
552
- }
553
690
  /**
554
691
  * Remove connection from the graph
555
692
  * @param connection connection between code nodes
@@ -568,14 +705,17 @@ class Ot {
568
705
  * Render node codes.
569
706
  */
570
707
  renderNodeCodes() {
571
- this.codeNodes.length !== 0 && this.codeNodes.forEach((e) => e.renderCode());
708
+ this.state.lockCode || this.codeNodes.length !== 0 && this.codeNodes.forEach((e) => e.renderCode());
572
709
  }
573
710
  /**
574
711
  * Render code.
575
712
  */
576
713
  renderCode() {
577
- this.state.script = q.render(this.state.template || "", this);
714
+ this.state.lockCode || (this.state.script = Z.render(this.state.template || "", this));
578
715
  }
716
+ /**
717
+ * Reset scripts of intput interfaces.
718
+ */
579
719
  resetInputInterfaceScript() {
580
720
  this.codeNodes.forEach((e) => e.resetInputInterfaceScript());
581
721
  }
@@ -613,7 +753,7 @@ class Ot {
613
753
  a.from.nodeId
614
754
  ]);
615
755
  let t = [...this.nodeIds];
616
- t.reverse(), t = yt.array(t, e), t.reverse();
756
+ t.reverse(), t = _t.array(t, e), t.reverse();
617
757
  const n = this.graph.nodes.map((a) => a.id).filter((a) => !t.includes(a));
618
758
  t = t.concat(n);
619
759
  const o = t.map((a) => this.findNodeById(a));
@@ -622,26 +762,32 @@ class Ot {
622
762
  console.warn("Failed to sort nodes.");
623
763
  }
624
764
  }
765
+ /**
766
+ * Update code nodes.
767
+ */
768
+ updateCodeNodes() {
769
+ this.codeNodes.forEach((e) => e.update());
770
+ }
771
+ /**
772
+ * Update code templates.
773
+ */
625
774
  updateCodeTemplates() {
626
775
  this.codeNodes.forEach((e) => e.updateCodeTemplate());
627
776
  }
628
- updateOutputVariableNames() {
629
- this.codeNodes.forEach((e) => e.updateOutputVariableName());
630
- }
631
777
  }
632
- const te = (s) => {
778
+ const oe = (s) => {
633
779
  let e = [];
634
780
  return s.nodes.forEach((t) => {
635
- t.subgraph ? e = e.concat(te(t.subgraph)) : t.isCodeNode && e.push(t);
781
+ t.subgraph ? e = e.concat(oe(t.subgraph)) : t.isCodeNode && e.push(t);
636
782
  }), e;
637
- }, bn = (s = 0, e = 100) => ({
783
+ }, Vn = (s = 0, e = 100) => ({
638
784
  x: s * 420,
639
785
  y: e
640
- }), yn = (s) => {
786
+ }), Bn = (s) => {
641
787
  const e = { ...s.position };
642
- return e.x -= 400, e.y += 50, e;
643
- }, _n = (s) => {
644
- const { calculationOrder: e, connectionsFromNode: t } = Ce(s);
788
+ return e.x -= 440, e.y += 50, e;
789
+ }, Sn = (s) => {
790
+ const { calculationOrder: e, connectionsFromNode: t } = Ne(s);
645
791
  e.forEach((n) => {
646
792
  if (!n.isCodeNode) return;
647
793
  const o = n;
@@ -649,45 +795,40 @@ const te = (s) => {
649
795
  a.to.state && a.from.script && (a.to.state.script = a.from.script);
650
796
  });
651
797
  });
652
- }, Tt = ["id"], Et = { class: "align-middle" }, ke = /* @__PURE__ */ L({
798
+ }, Lt = ["id"], Ut = { class: "align-middle" }, we = /* @__PURE__ */ U({
653
799
  __name: "CodeGraphNodeInterface",
654
800
  props: {
655
801
  node: {},
656
802
  intf: {}
657
803
  },
658
804
  setup(s) {
659
- const e = s, { viewModel: t } = F(), { hoveredOver: n, temporaryConnection: o } = tt(), a = T(null), d = _(() => e.intf.connectionCount > 0), u = _(() => ({
805
+ const e = s, { viewModel: t } = q(), { hoveredOver: n, temporaryConnection: o } = nt(), a = B(null), d = b(() => e.intf.connectionCount > 0), u = b(() => ({
660
806
  "--connected": d.value
661
- })), m = () => {
807
+ })), v = () => {
662
808
  n(e.intf);
663
- }, w = () => {
664
- n(void 0);
665
809
  }, k = () => {
810
+ n(void 0);
811
+ }, w = () => {
666
812
  a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
667
813
  };
668
- return oe(k), Ne(k), (O, j) => (i(), r("div", {
814
+ return ie(w), Oe(w), (V, L) => (i(), r("div", {
669
815
  id: s.intf.id,
670
816
  ref_key: "el",
671
817
  ref: a,
672
- class: U(["baklava-node-interface", u.value])
818
+ class: G(["baklava-node-interface", u.value])
673
819
  }, [
674
820
  s.intf.port ? (i(), r("div", {
675
821
  key: 0,
676
- class: U(["__port", { "--selected": y(o)?.from === s.intf }]),
677
- onPointerover: m,
678
- onPointerout: w
822
+ class: G(["__port", { "--selected": _(o)?.from === s.intf }]),
823
+ onPointerover: v,
824
+ onPointerout: k
679
825
  }, null, 34)) : I("", !0),
680
- l("span", Et, [
681
- Z(O.$slots, "default")
826
+ l("span", Ut, [
827
+ W(V.$slots, "default")
682
828
  ])
683
- ], 10, Tt));
829
+ ], 10, Lt));
684
830
  }
685
- }), $ = (s, e) => {
686
- const t = s.__vccOpts || s;
687
- for (const [n, o] of e)
688
- t[n] = o;
689
- return t;
690
- }, St = {}, zt = {
831
+ }), Gt = {}, Rt = {
691
832
  xmlns: "http://www.w3.org/2000/svg",
692
833
  width: "24",
693
834
  height: "24",
@@ -699,8 +840,8 @@ const te = (s) => {
699
840
  "stroke-linejoin": "round",
700
841
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
701
842
  };
702
- function Vt(s, e) {
703
- return i(), r("svg", zt, [...e[0] || (e[0] = [
843
+ function Pt(s, e) {
844
+ return i(), r("svg", Rt, [...e[0] || (e[0] = [
704
845
  l("path", {
705
846
  stroke: "none",
706
847
  d: "M0 0h24v24H0z",
@@ -709,7 +850,7 @@ function Vt(s, e) {
709
850
  l("path", { d: "M4 8m0 2a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2z" }, null, -1)
710
851
  ])]);
711
852
  }
712
- const Bt = /* @__PURE__ */ $(St, [["render", Vt]]), jt = {}, Lt = {
853
+ const Dt = /* @__PURE__ */ $(Gt, [["render", Pt]]), Ht = {}, At = {
713
854
  xmlns: "http://www.w3.org/2000/svg",
714
855
  width: "24",
715
856
  height: "24",
@@ -721,8 +862,8 @@ const Bt = /* @__PURE__ */ $(St, [["render", Vt]]), jt = {}, Lt = {
721
862
  "stroke-linejoin": "round",
722
863
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
723
864
  };
724
- function Ut(s, e) {
725
- return i(), r("svg", Lt, [...e[0] || (e[0] = [
865
+ function Ft(s, e) {
866
+ return i(), r("svg", At, [...e[0] || (e[0] = [
726
867
  l("path", {
727
868
  stroke: "none",
728
869
  d: "M0 0h24v24H0z",
@@ -733,7 +874,7 @@ function Ut(s, e) {
733
874
  l("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
734
875
  ])]);
735
876
  }
736
- const Gt = /* @__PURE__ */ $(jt, [["render", Ut]]), Rt = {}, Dt = {
877
+ const Wt = /* @__PURE__ */ $(Ht, [["render", Ft]]), Xt = {}, qt = {
737
878
  xmlns: "http://www.w3.org/2000/svg",
738
879
  width: "24",
739
880
  height: "24",
@@ -741,8 +882,8 @@ const Gt = /* @__PURE__ */ $(jt, [["render", Ut]]), Rt = {}, Dt = {
741
882
  fill: "currentColor",
742
883
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
743
884
  };
744
- function Pt(s, e) {
745
- return i(), r("svg", Dt, [...e[0] || (e[0] = [
885
+ function Jt(s, e) {
886
+ return i(), r("svg", qt, [...e[0] || (e[0] = [
746
887
  l("path", {
747
888
  stroke: "none",
748
889
  d: "M0 0h24v24H0z",
@@ -751,7 +892,7 @@ function Pt(s, e) {
751
892
  l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-2.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
752
893
  ])]);
753
894
  }
754
- const Ht = /* @__PURE__ */ $(Rt, [["render", Pt]]), At = {}, Ft = {
895
+ const Yt = /* @__PURE__ */ $(Xt, [["render", Jt]]), Qt = {}, Kt = {
755
896
  xmlns: "http://www.w3.org/2000/svg",
756
897
  width: "24",
757
898
  height: "24",
@@ -759,8 +900,8 @@ const Ht = /* @__PURE__ */ $(Rt, [["render", Pt]]), At = {}, Ft = {
759
900
  fill: "currentColor",
760
901
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
761
902
  };
762
- function Wt(s, e) {
763
- return i(), r("svg", Ft, [...e[0] || (e[0] = [
903
+ function Zt(s, e) {
904
+ return i(), r("svg", Kt, [...e[0] || (e[0] = [
764
905
  l("path", {
765
906
  stroke: "none",
766
907
  d: "M0 0h24v24H0z",
@@ -769,16 +910,16 @@ function Wt(s, e) {
769
910
  l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm0 2h-9v14h9a1 1 0 0 0 .993 -.883l.007 -.117v-12a1 1 0 0 0 -.883 -.993l-.117 -.007zm-4.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
770
911
  ])]);
771
912
  }
772
- const Xt = /* @__PURE__ */ $(At, [["render", Wt]]), Jt = {}, Yt = {
913
+ const es = /* @__PURE__ */ $(Qt, [["render", Zt]]), ts = {}, ss = {
773
914
  xmlns: "http://www.w3.org/2000/svg",
774
915
  width: "24",
775
916
  height: "24",
776
917
  viewBox: "0 0 24 24",
777
918
  fill: "currentColor",
778
- class: "balkava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
919
+ class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
779
920
  };
780
- function qt(s, e) {
781
- return i(), r("svg", Yt, [...e[0] || (e[0] = [
921
+ function ns(s, e) {
922
+ return i(), r("svg", ss, [...e[0] || (e[0] = [
782
923
  l("path", {
783
924
  stroke: "none",
784
925
  d: "M0 0h24v24H0z",
@@ -787,7 +928,7 @@ function qt(s, e) {
787
928
  l("path", { d: "M6 21a3 3 0 0 1 -3 -3v-12a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3zm8 -16h-8a1 1 0 0 0 -1 1v12a1 1 0 0 0 1 1h8z" }, null, -1)
788
929
  ])]);
789
930
  }
790
- const Qt = /* @__PURE__ */ $(Jt, [["render", qt]]), Kt = {}, Zt = {
931
+ const os = /* @__PURE__ */ $(ts, [["render", ns]]), as = {}, is = {
791
932
  xmlns: "http://www.w3.org/2000/svg",
792
933
  width: "24",
793
934
  height: "24",
@@ -795,8 +936,8 @@ const Qt = /* @__PURE__ */ $(Jt, [["render", qt]]), Kt = {}, Zt = {
795
936
  fill: "currentColor",
796
937
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
797
938
  };
798
- function es(s, e) {
799
- return i(), r("svg", Zt, [...e[0] || (e[0] = [
939
+ function rs(s, e) {
940
+ return i(), r("svg", is, [...e[0] || (e[0] = [
800
941
  l("path", {
801
942
  stroke: "none",
802
943
  d: "M0 0h24v24H0z",
@@ -805,7 +946,7 @@ function es(s, e) {
805
946
  l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-5.387 4.21l.094 .083l2 2a1 1 0 0 1 .083 1.32l-.083 .094l-2 2a1 1 0 0 1 -1.497 -1.32l.083 -.094l1.292 -1.293l-1.292 -1.293a1 1 0 0 1 -.083 -1.32l.083 -.094a1 1 0 0 1 1.32 -.083z" }, null, -1)
806
947
  ])]);
807
948
  }
808
- const ts = /* @__PURE__ */ $(Kt, [["render", es]]), ss = {}, ns = {
949
+ const ls = /* @__PURE__ */ $(as, [["render", rs]]), ds = {}, us = {
809
950
  xmlns: "http://www.w3.org/2000/svg",
810
951
  width: "24",
811
952
  height: "24",
@@ -813,8 +954,8 @@ const ts = /* @__PURE__ */ $(Kt, [["render", es]]), ss = {}, ns = {
813
954
  fill: "currentColor",
814
955
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
815
956
  };
816
- function os(s, e) {
817
- return i(), r("svg", ns, [...e[0] || (e[0] = [
957
+ function cs(s, e) {
958
+ return i(), r("svg", us, [...e[0] || (e[0] = [
818
959
  l("path", {
819
960
  stroke: "none",
820
961
  d: "M0 0h24v24H0z",
@@ -823,7 +964,24 @@ function os(s, e) {
823
964
  l("path", { d: "M18 3a3 3 0 0 1 2.995 2.824l.005 .176v12a3 3 0 0 1 -2.824 2.995l-.176 .005h-12a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-12a3 3 0 0 1 2.824 -2.995l.176 -.005h12zm-3 2h-9a1 1 0 0 0 -.993 .883l-.007 .117v12a1 1 0 0 0 .883 .993l.117 .007h9v-14zm-3.293 4.293a1 1 0 0 1 .083 1.32l-.083 .094l-1.292 1.293l1.292 1.293a1 1 0 0 1 .083 1.32l-.083 .094a1 1 0 0 1 -1.32 .083l-.094 -.083l-2 -2a1 1 0 0 1 -.083 -1.32l.083 -.094l2 -2a1 1 0 0 1 1.414 0z" }, null, -1)
824
965
  ])]);
825
966
  }
826
- const as = /* @__PURE__ */ $(ss, [["render", os]]), is = {}, rs = {
967
+ const ps = /* @__PURE__ */ $(ds, [["render", cs]]), hs = {}, vs = {
968
+ xmlns: "http://www.w3.org/2000/svg",
969
+ width: "24",
970
+ height: "24",
971
+ viewBox: "0 0 24 24",
972
+ fill: "none",
973
+ stroke: "currentColor",
974
+ "stroke-width": "2",
975
+ "stroke-linecap": "round",
976
+ "stroke-linejoin": "round",
977
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"
978
+ };
979
+ function ms(s, e) {
980
+ return i(), r("svg", vs, [...e[0] || (e[0] = [
981
+ J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M11.5 21h-4.5a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2"></path><path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0"></path><path d="M8 11v-4a4 4 0 1 1 8 0v4"></path><path d="M20 21l2 -2l-2 -2"></path><path d="M17 17l-2 2l2 2"></path>', 6)
982
+ ])]);
983
+ }
984
+ const fs = /* @__PURE__ */ $(hs, [["render", ms]]), gs = {}, bs = {
827
985
  xmlns: "http://www.w3.org/2000/svg",
828
986
  width: "24",
829
987
  height: "24",
@@ -835,12 +993,12 @@ const as = /* @__PURE__ */ $(ss, [["render", os]]), is = {}, rs = {
835
993
  "stroke-linejoin": "round",
836
994
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
837
995
  };
838
- function ls(s, e) {
839
- return i(), r("svg", rs, [...e[0] || (e[0] = [
840
- Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>', 8)
996
+ function ys(s, e) {
997
+ return i(), r("svg", bs, [...e[0] || (e[0] = [
998
+ J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M5 2h5v4h-5z"></path><path d="M15 10h5v4h-5z"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h5"></path><path d="M7.5 6v4"></path><path d="M7.5 14v4"></path>', 8)
841
999
  ])]);
842
1000
  }
843
- const ds = /* @__PURE__ */ $(is, [["render", ls]]), us = {}, cs = {
1001
+ const _s = /* @__PURE__ */ $(gs, [["render", ys]]), ks = {}, Cs = {
844
1002
  xmlns: "http://www.w3.org/2000/svg",
845
1003
  width: "24",
846
1004
  height: "24",
@@ -852,12 +1010,12 @@ const ds = /* @__PURE__ */ $(is, [["render", ls]]), us = {}, cs = {
852
1010
  "stroke-linejoin": "round",
853
1011
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
854
1012
  };
855
- function ps(s, e) {
856
- return i(), r("svg", cs, [...e[0] || (e[0] = [
857
- Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>', 9)
1013
+ function ws(s, e) {
1014
+ return i(), r("svg", Cs, [...e[0] || (e[0] = [
1015
+ J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M6 2h4v4m-4 0h-1v-1"></path><path d="M15 11v-1h5v4h-2"></path><path d="M5 18h5v4h-5z"></path><path d="M5 10h5v4h-5z"></path><path d="M10 12h2"></path><path d="M7.5 7.5v2.5"></path><path d="M7.5 14v4"></path><path d="M3 3l18 18"></path>', 9)
858
1016
  ])]);
859
1017
  }
860
- const hs = /* @__PURE__ */ $(us, [["render", ps]]), vs = {}, ms = {
1018
+ const xs = /* @__PURE__ */ $(ks, [["render", ws]]), Is = {}, Ns = {
861
1019
  xmlns: "http://www.w3.org/2000/svg",
862
1020
  width: "24",
863
1021
  height: "24",
@@ -869,12 +1027,12 @@ const hs = /* @__PURE__ */ $(us, [["render", ps]]), vs = {}, ms = {
869
1027
  "stroke-linejoin": "round",
870
1028
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
871
1029
  };
872
- function fs(s, e) {
873
- return i(), r("svg", ms, [...e[0] || (e[0] = [
874
- Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
1030
+ function Ms(s, e) {
1031
+ return i(), r("svg", Ns, [...e[0] || (e[0] = [
1032
+ J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M21 18a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3"></path><path d="M3 3m0 3a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v0a3 3 0 0 1 -3 3h-12a3 3 0 0 1 -3 -3z"></path><path d="M12 9v8"></path><path d="M9 14l3 3l3 -3"></path>', 5)
875
1033
  ])]);
876
1034
  }
877
- const gs = /* @__PURE__ */ $(vs, [["render", fs]]), bs = {}, ys = {
1035
+ const $s = /* @__PURE__ */ $(Is, [["render", Ms]]), Os = {}, Ts = {
878
1036
  xmlns: "http://www.w3.org/2000/svg",
879
1037
  width: "24",
880
1038
  height: "24",
@@ -886,18 +1044,18 @@ const gs = /* @__PURE__ */ $(vs, [["render", fs]]), bs = {}, ys = {
886
1044
  "stroke-linejoin": "round",
887
1045
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
888
1046
  };
889
- function _s(s, e) {
890
- return i(), r("svg", ys, [...e[0] || (e[0] = [
891
- Q('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
1047
+ function Es(s, e) {
1048
+ return i(), r("svg", Ts, [...e[0] || (e[0] = [
1049
+ J('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M3 3l18 18"></path><path d="M4 7h3m4 0h9"></path><path d="M10 11l0 6"></path><path d="M14 14l0 3"></path><path d="M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l.077 -.923"></path><path d="M18.384 14.373l.616 -7.373"></path><path d="M9 5v-1a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3"></path>', 8)
892
1050
  ])]);
893
1051
  }
894
- const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"], xs = {
1052
+ const Vs = /* @__PURE__ */ $(Os, [["render", Es]]), Bs = ["id", "data-node-type"], Ss = {
895
1053
  class: "__title-label",
896
1054
  style: { "flex-grow": "1" }
897
- }, Cs = { key: 0 }, Is = {
1055
+ }, zs = { key: 0 }, js = {
898
1056
  class: "__menu",
899
1057
  style: { display: "flex" }
900
- }, Ns = { class: "__outputs" }, Ms = { key: 0 }, $s = ["id", "title"], Os = { class: "__inputs" }, Ts = { key: 0 }, Es = ["id", "title"], Ss = /* @__PURE__ */ L({
1058
+ }, Ls = { class: "__outputs" }, Us = { key: 0 }, Gs = ["id", "title"], Rs = { class: "__inputs" }, Ps = { key: 0 }, Ds = ["id", "title"], Hs = /* @__PURE__ */ U({
901
1059
  __name: "CodeGraphNode",
902
1060
  props: {
903
1061
  node: {},
@@ -906,95 +1064,95 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
906
1064
  },
907
1065
  emits: ["select", "start-drag", "update"],
908
1066
  setup(s, { emit: e }) {
909
- const t = we.ContextMenu, n = we.NodeInterface, o = s, a = _(() => o.node), d = e, { viewModel: u } = F(), { graph: m, switchGraph: w } = ne(), k = T(null), O = T(!1), j = T(""), x = T(null), f = T(!1);
910
- let g = 0, v = 0;
911
- const h = T(!1), C = _(() => {
1067
+ const t = ke.ContextMenu, n = ke.NodeInterface, o = s, a = b(() => o.node), d = e, { viewModel: u } = q(), { graph: v, switchGraph: k } = ae(), w = B(null), V = B(!1), L = B(""), N = B(null), m = B(!1);
1068
+ let y = 0, x = 0;
1069
+ const f = B(!1), C = b(() => {
912
1070
  const c = [
913
1071
  { value: "edit", label: "Edit" },
914
1072
  { value: "rename", label: "Rename" },
915
1073
  { value: "delete", label: "Delete" }
916
1074
  ];
917
- return o.node.type.startsWith(K) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
918
- }), N = _(() => ({
1075
+ return o.node.type.startsWith(se) && c.push({ value: "editSubgraph", label: "Edit Subgraph" }), c;
1076
+ }), p = b(() => ({
919
1077
  "--selected": o.selected,
920
1078
  "--dragging": o.dragging,
921
1079
  "--two-column": !!o.node.twoColumn,
922
1080
  "--hidden": a.value.state?.hidden
923
- })), ze = _(() => ({
1081
+ })), M = b(() => ({
924
1082
  "--reverse-y": o.node.reverseY ?? u.value.settings.nodes.reverseY
925
- })), Ve = _(() => ({
1083
+ })), je = b(() => ({
926
1084
  top: `${o.node.position?.y ?? 0}px`,
927
1085
  left: `${o.node.position?.x ?? 0}px`,
928
1086
  "--width": `${o.node.width ?? u.value.settings.nodes.defaultWidth}px`
929
- })), Be = _(() => Object.values(o.node.inputs).filter((c) => !c.hidden)), je = _(() => Object.values(o.node.outputs).filter((c) => !c.hidden)), he = () => {
1087
+ })), Le = b(() => Object.values(o.node.inputs).filter((c) => !c.hidden)), Ue = b(() => Object.values(o.node.outputs).filter((c) => !c.hidden)), he = () => {
930
1088
  d("select");
931
- }, Le = (c) => {
1089
+ }, Ge = (c) => {
932
1090
  o.selected || he(), d("start-drag", c);
933
1091
  }, ve = () => {
934
- h.value = !0;
935
- }, Ue = () => {
1092
+ f.value = !0;
1093
+ }, Re = () => {
936
1094
  const c = u.value.displayedGraph.sidebar;
937
1095
  c.nodeId = "", c.visible = !1;
938
1096
  }, me = () => {
939
1097
  const c = u.value.displayedGraph.sidebar;
940
1098
  c.nodeId = o.node.id, c.visible = !0;
941
- }, Ge = () => {
1099
+ }, Pe = () => {
942
1100
  const c = u.value.displayedGraph.sidebar;
943
1101
  c.nodeId = o.node.id;
944
- }, Re = async (c) => {
1102
+ }, De = async (c) => {
945
1103
  switch (c) {
946
1104
  case "edit":
947
1105
  me();
948
1106
  break;
949
1107
  case "delete":
950
- m.value.removeNode(o.node);
1108
+ v.value.removeNode(o.node);
951
1109
  break;
952
1110
  case "rename":
953
- j.value = o.node.title, O.value = !0, await ct(), x.value?.focus();
1111
+ L.value = o.node.title, V.value = !0, await ht(), N.value?.focus();
954
1112
  break;
955
1113
  case "editSubgraph":
956
- w(o.node.template);
1114
+ k(o.node.template);
957
1115
  break;
958
1116
  }
959
1117
  }, fe = () => {
960
- o.node.title = j.value, O.value = !1;
1118
+ a.value.title = L.value, V.value = !1;
961
1119
  }, ge = () => {
962
- k.value && u.value.hooks.renderNode.execute({ node: o.node, el: k.value });
963
- }, De = (c) => {
964
- f.value = !0, g = o.node.width, v = c.clientX, c.preventDefault();
1120
+ w.value && u.value.hooks.renderNode.execute({ node: o.node, el: w.value });
1121
+ }, He = (c) => {
1122
+ m.value = !0, y = o.node.width, x = c.clientX, c.preventDefault();
965
1123
  }, be = (c) => {
966
1124
  a.value.state && (a.value.state.integrated = c, d("update"));
967
1125
  }, ye = (c) => {
968
- if (!f.value) return;
969
- const b = c.clientX - v, p = g + b / m.value.scaling, Pe = u.value.settings.nodes.minWidth, He = u.value.settings.nodes.maxWidth;
970
- o.node.width = Math.max(Pe, Math.min(He, p));
1126
+ if (!m.value) return;
1127
+ const g = c.clientX - x, h = y + g / v.value.scaling, Ae = u.value.settings.nodes.minWidth, Fe = u.value.settings.nodes.maxWidth;
1128
+ a.value.width = Math.max(Ae, Math.min(Fe, h));
971
1129
  }, _e = () => {
972
- f.value = !1;
1130
+ m.value = !1;
973
1131
  };
974
- return oe(() => {
1132
+ return ie(() => {
975
1133
  ge(), window.addEventListener("mousemove", ye), window.addEventListener("mouseup", _e);
976
- }), Ne(ge), dt(() => {
1134
+ }), Oe(ge), ct(() => {
977
1135
  window.removeEventListener("mousemove", ye), window.removeEventListener("mouseup", _e);
978
- }), (c, b) => (i(), r("div", {
1136
+ }), (c, g) => (i(), r("div", {
979
1137
  id: a.value.id,
980
1138
  ref_key: "el",
981
- ref: k,
982
- class: U([N.value, "baklava-node"]),
1139
+ ref: w,
1140
+ class: G([p.value, "baklava-node"]),
983
1141
  "data-node-type": a.value.type,
984
- style: ae(Ve.value),
1142
+ style: re(je.value),
985
1143
  onPointerdown: he
986
1144
  }, [
987
- y(u).settings.nodes.resizable ? (i(), r("div", {
1145
+ _(u).settings.nodes.resizable ? (i(), r("div", {
988
1146
  key: 0,
989
1147
  class: "__resize-handle",
990
- onMousedown: De
1148
+ onMousedown: He
991
1149
  }, null, 32)) : I("", !0),
992
1150
  l("div", {
993
1151
  class: "__title",
994
- onPointerdown: P(Le, ["self", "stop"]),
995
- onContextmenu: P(ve, ["prevent"])
1152
+ onPointerdown: A(Ge, ["self", "stop"]),
1153
+ onContextmenu: A(ve, ["prevent"])
996
1154
  }, [
997
- a.value.inputs._node ? (i(), S(ke, {
1155
+ a.value.inputs._node ? (i(), O(we, {
998
1156
  key: 0,
999
1157
  node: a.value,
1000
1158
  intf: a.value.inputs._node,
@@ -1002,64 +1160,69 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
1002
1160
  "data-interface-type": "node",
1003
1161
  style: { "flex-grow": "0" }
1004
1162
  }, null, 8, ["node", "intf"])) : I("", !0),
1005
- O.value ? ie((i(), r("input", {
1163
+ V.value ? ee((i(), r("input", {
1006
1164
  key: 2,
1007
1165
  ref_key: "renameInputEl",
1008
- ref: x,
1009
- "onUpdate:modelValue": b[3] || (b[3] = (p) => j.value = p),
1166
+ ref: N,
1167
+ "onUpdate:modelValue": g[4] || (g[4] = (h) => L.value = h),
1010
1168
  class: "baklava-input",
1011
1169
  placeholder: "Node Name",
1012
1170
  style: { "flex-grow": "1" },
1013
1171
  type: "text",
1014
1172
  onBlur: fe,
1015
- onKeydown: ee(fe, ["enter"])
1173
+ onKeydown: ne(fe, ["enter"])
1016
1174
  }, null, 544)), [
1017
- [re, j.value]
1018
- ]) : (i(), r(z, { key: 1 }, [
1019
- l("div", xs, [
1020
- a.value.idx > -1 ? (i(), r("span", Cs, B(a.value.idx + 1) + " - ", 1)) : I("", !0),
1021
- ut(B(a.value.title) + " (" + B(a.value.shortId) + ") ", 1)
1175
+ [te, L.value]
1176
+ ]) : (i(), r(T, { key: 1 }, [
1177
+ l("div", Ss, [
1178
+ a.value.idx > -1 ? (i(), r("span", zs, j(a.value.idx + 1) + " - ", 1)) : I("", !0),
1179
+ pt(j(a.value.title), 1)
1022
1180
  ]),
1023
- l("div", Is, [
1024
- a.value.subgraph ? I("", !0) : (i(), r(z, { key: 0 }, [
1025
- a.value.state.integrated ? (i(), S(y(Bt), {
1181
+ l("div", js, [
1182
+ a.value.subgraph ? I("", !0) : (i(), r(T, { key: 0 }, [
1183
+ a.value.state.lockCode ? (i(), O(_(fs), {
1026
1184
  key: 0,
1027
1185
  class: "--clickable mx-1",
1028
- onClick: b[0] || (b[0] = (p) => be(!1))
1029
- })) : (i(), S(y(gs), {
1186
+ onClick: g[0] || (g[0] = (h) => a.value.lockCode = !1)
1187
+ })) : I("", !0),
1188
+ a.value.state.integrated ? (i(), O(_(Dt), {
1030
1189
  key: 1,
1031
1190
  class: "--clickable mx-1",
1032
- onClick: b[1] || (b[1] = (p) => be(!0))
1033
- })),
1034
- !y(u).displayedGraph.sidebar.visible && y(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), S(y(as), {
1191
+ onClick: g[1] || (g[1] = (h) => be(!1))
1192
+ })) : (i(), O(_($s), {
1035
1193
  key: 2,
1036
1194
  class: "--clickable mx-1",
1037
- onClick: me
1038
- })) : y(u).displayedGraph.sidebar.visible && y(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), S(y(Qt), {
1195
+ onClick: g[2] || (g[2] = (h) => be(!0))
1196
+ })),
1197
+ !_(u).displayedGraph.sidebar.visible && _(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), O(_(ps), {
1039
1198
  key: 3,
1040
1199
  class: "--clickable mx-1",
1041
- onClick: Ge
1042
- })) : (i(), S(y(ts), {
1200
+ onClick: me
1201
+ })) : _(u).displayedGraph.sidebar.visible && _(u).displayedGraph.sidebar.nodeId !== a.value.id ? (i(), O(_(os), {
1043
1202
  key: 4,
1044
1203
  class: "--clickable mx-1",
1045
- onClick: Ue
1204
+ onClick: Pe
1205
+ })) : (i(), O(_(ls), {
1206
+ key: 5,
1207
+ class: "--clickable mx-1",
1208
+ onClick: Re
1046
1209
  }))
1047
1210
  ], 64)),
1048
- V(y(Gt), {
1211
+ z(_(Wt), {
1049
1212
  class: "--clickable mx-1",
1050
1213
  onClick: ve
1051
1214
  }),
1052
- V(y(t), {
1053
- modelValue: h.value,
1054
- "onUpdate:modelValue": b[2] || (b[2] = (p) => h.value = p),
1215
+ z(_(t), {
1216
+ modelValue: f.value,
1217
+ "onUpdate:modelValue": g[3] || (g[3] = (h) => f.value = h),
1055
1218
  x: 0,
1056
1219
  y: 0,
1057
1220
  items: C.value,
1058
- onClick: Re
1221
+ onClick: De
1059
1222
  }, null, 8, ["modelValue", "items"])
1060
1223
  ])
1061
1224
  ], 64)),
1062
- a.value.outputs._node ? (i(), S(ke, {
1225
+ a.value.outputs._node ? (i(), O(we, {
1063
1226
  key: 3,
1064
1227
  node: a.value,
1065
1228
  intf: a.value.outputs._node,
@@ -1068,73 +1231,73 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
1068
1231
  }, null, 8, ["node", "intf"])) : I("", !0)
1069
1232
  ], 32),
1070
1233
  l("div", {
1071
- class: U(["__content", ze.value]),
1072
- onKeydown: b[4] || (b[4] = ee(P(() => {
1234
+ class: G(["__content", M.value]),
1235
+ onKeydown: g[5] || (g[5] = ne(A(() => {
1073
1236
  }, ["stop"]), ["delete"])),
1074
- onContextmenu: b[5] || (b[5] = P(() => {
1237
+ onContextmenu: g[6] || (g[6] = A(() => {
1075
1238
  }, ["prevent"]))
1076
1239
  }, [
1077
- l("div", Ns, [
1078
- (i(!0), r(z, null, H(je.value, (p) => (i(), r(z, {
1079
- key: p.id
1240
+ l("div", Ls, [
1241
+ (i(!0), r(T, null, D(Ue.value, (h) => (i(), r(T, {
1242
+ key: h.id
1080
1243
  }, [
1081
- a.value.state?.hidden ? (i(), r("div", Ms, [
1082
- p.port ? (i(), r("div", {
1244
+ a.value.state?.hidden ? (i(), r("div", Us, [
1245
+ h.port ? (i(), r("div", {
1083
1246
  key: 0,
1084
- id: p.id,
1085
- title: p.name,
1247
+ id: h.id,
1248
+ title: h.name,
1086
1249
  class: "baklava-node-interface --output --connected"
1087
- }, [...b[6] || (b[6] = [
1250
+ }, [...g[7] || (g[7] = [
1088
1251
  l("div", { class: "__port" }, null, -1)
1089
- ])], 8, $s)) : I("", !0)
1090
- ])) : Z(c.$slots, "nodeInterface", {
1252
+ ])], 8, Gs)) : I("", !0)
1253
+ ])) : W(c.$slots, "nodeInterface", {
1091
1254
  key: 1,
1092
1255
  type: "output",
1093
1256
  node: a.value,
1094
- intf: p
1257
+ intf: h
1095
1258
  }, () => [
1096
- V(y(n), {
1259
+ z(_(n), {
1097
1260
  node: a.value,
1098
- intf: p,
1099
- title: p.type
1261
+ intf: h,
1262
+ title: h.type
1100
1263
  }, null, 8, ["node", "intf", "title"])
1101
1264
  ])
1102
1265
  ], 64))), 128))
1103
1266
  ]),
1104
- l("div", Os, [
1105
- (i(!0), r(z, null, H(Be.value, (p) => (i(), r(z, {
1106
- key: p.id
1267
+ l("div", Rs, [
1268
+ (i(!0), r(T, null, D(Le.value, (h) => (i(), r(T, {
1269
+ key: h.id
1107
1270
  }, [
1108
- a.value.state?.hidden ? (i(), r("div", Ts, [
1109
- p.port ? (i(), r("div", {
1271
+ a.value.state?.hidden ? (i(), r("div", Ps, [
1272
+ h.port ? (i(), r("div", {
1110
1273
  key: 0,
1111
- id: p.id,
1112
- title: p.name,
1274
+ id: h.id,
1275
+ title: h.name,
1113
1276
  class: "baklava-node-interface --input --connected"
1114
- }, [...b[7] || (b[7] = [
1277
+ }, [...g[8] || (g[8] = [
1115
1278
  l("div", { class: "__port" }, null, -1)
1116
- ])], 8, Es)) : I("", !0)
1117
- ])) : Z(c.$slots, "nodeInterface", {
1279
+ ])], 8, Ds)) : I("", !0)
1280
+ ])) : W(c.$slots, "nodeInterface", {
1118
1281
  key: 1,
1119
1282
  node: a.value,
1120
- intf: p,
1283
+ intf: h,
1121
1284
  type: "input"
1122
1285
  }, () => [
1123
- V(y(n), {
1286
+ z(_(n), {
1124
1287
  node: a.value,
1125
- intf: p,
1126
- title: p.type
1288
+ intf: h,
1289
+ title: h.type
1127
1290
  }, null, 8, ["node", "intf", "title"])
1128
1291
  ])
1129
1292
  ], 64))), 128))
1130
1293
  ])
1131
1294
  ], 34)
1132
- ], 46, ks));
1295
+ ], 46, Bs));
1133
1296
  }
1134
- }), zs = ["title"], Vs = {
1297
+ }), As = ["title"], Fs = {
1135
1298
  key: 0,
1136
1299
  class: "__label"
1137
- }, Bs = /* @__PURE__ */ L({
1300
+ }, xe = /* @__PURE__ */ U({
1138
1301
  __name: "Checkbox",
1139
1302
  props: {
1140
1303
  disabled: { type: Boolean },
@@ -1146,7 +1309,7 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
1146
1309
  setup(s, { emit: e }) {
1147
1310
  const t = e;
1148
1311
  return (n, o) => (i(), r("div", {
1149
- class: U(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue, "--disabled": s.disabled }]),
1312
+ class: G(["baklava-checkbox", { "--checked": s.inversed ? !s.modelValue : s.modelValue, "--disabled": s.disabled }]),
1150
1313
  title: s.name,
1151
1314
  onClick: o[0] || (o[0] = (a) => t("update:modelValue", !s.modelValue))
1152
1315
  }, [
@@ -1164,100 +1327,133 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
1164
1327
  })
1165
1328
  ])
1166
1329
  ], -1)),
1167
- s.name ? (i(), r("div", Vs, B(s.name), 1)) : I("", !0)
1168
- ], 10, zs));
1330
+ s.name ? (i(), r("div", Fs, j(s.name), 1)) : I("", !0)
1331
+ ], 10, As));
1169
1332
  }
1170
- }), js = { class: "__header" }, Ls = { class: "__node-name" }, Us = { style: { display: "flex" } }, Gs = {
1171
- key: 1,
1333
+ }), Ws = { class: "__header" }, Xs = { class: "__node-name" }, qs = { class: "__interfaces" }, Js = { class: "__inputs" }, Ys = { style: { display: "flex" } }, Qs = { class: "__outputs" }, Ks = {
1334
+ key: 0,
1172
1335
  class: "__interface"
1173
- }, Rs = /* @__PURE__ */ L({
1336
+ }, Zs = { style: { display: "flex" } }, en = /* @__PURE__ */ U({
1174
1337
  __name: "CodeGraphSidebar",
1175
1338
  setup(s) {
1176
- const { viewModel: e } = F(), { graph: t } = ne(), n = T(null), o = Me(e.value.settings.sidebar, "width"), a = _(() => e.value.settings.sidebar.resizable);
1339
+ const { viewModel: e } = q(), { graph: t } = ae(), n = B(null), o = Te(e.value.settings.sidebar, "width"), a = b(() => e.value.settings.sidebar.resizable);
1177
1340
  let d = 0, u = 0;
1178
- const m = _(() => {
1179
- const v = t.value.sidebar.nodeId;
1180
- return t.value.nodes.find((h) => h.id === v);
1181
- }), w = _(() => m.value), k = _(() => ({
1341
+ const v = b(() => {
1342
+ const f = t.value.sidebar.nodeId;
1343
+ return t.value.nodes.find((C) => C.id === f);
1344
+ }), k = b(() => v.value), w = b(() => ({
1182
1345
  width: `${o.value}px`
1183
- })), O = _(() => w.value ? [...Object.values(w.value.inputs), ...Object.values(w.value.outputs)].filter((h) => h.displayInSidebar && h.component) : []), j = () => {
1346
+ })), V = b(() => k.value ? Object.values(k.value.inputs).filter((f) => f.displayInSidebar && f.component) : []), L = b(() => k.value ? Object.values(k.value.outputs).filter((f) => f.displayInSidebar && f.component) : []), N = () => {
1184
1347
  t.value.sidebar.visible = !1;
1185
- }, x = () => {
1186
- m.value?.events.update.emit(null);
1187
- }, f = (v) => {
1188
- d = o.value, u = v.clientX, window.addEventListener("mousemove", g), window.addEventListener(
1348
+ }, m = () => {
1349
+ v.value?.events.update.emit(null);
1350
+ }, y = (f) => {
1351
+ d = o.value, u = f.clientX, window.addEventListener("mousemove", x), window.addEventListener(
1189
1352
  "mouseup",
1190
1353
  () => {
1191
- window.removeEventListener("mousemove", g);
1354
+ window.removeEventListener("mousemove", x);
1192
1355
  },
1193
1356
  { once: !0 }
1194
1357
  );
1195
- }, g = (v) => {
1196
- const h = n.value?.parentElement?.getBoundingClientRect().width ?? 500, C = v.clientX - u;
1197
- let N = d - C;
1198
- N < 300 ? N = 300 : N > 0.9 * h && (N = 0.9 * h), o.value = N;
1358
+ }, x = (f) => {
1359
+ const C = n.value?.parentElement?.getBoundingClientRect().width ?? 500, p = f.clientX - u;
1360
+ let M = d - p;
1361
+ M < 300 ? M = 300 : M > 0.9 * C && (M = 0.9 * C), o.value = M;
1199
1362
  };
1200
- return (v, h) => (i(), r("div", {
1363
+ return (f, C) => (i(), r("div", {
1364
+ class: G([{ "--open": _(t).sidebar.visible }, "baklava-sidebar"]),
1365
+ style: re(w.value),
1201
1366
  ref_key: "el",
1202
- ref: n,
1203
- class: U(["baklava-sidebar", { "--open": y(t).sidebar.visible }]),
1204
- style: ae(k.value)
1367
+ ref: n
1205
1368
  }, [
1206
1369
  a.value ? (i(), r("div", {
1207
1370
  key: 0,
1208
1371
  class: "__resizer",
1209
- onMousedown: f
1372
+ onMousedown: y
1210
1373
  }, null, 32)) : I("", !0),
1211
- l("div", js, [
1212
- l("button", {
1213
- tabindex: "-1",
1214
- class: "__close",
1215
- onClick: j
1216
- }, "×"),
1217
- l("div", Ls, [
1218
- l("b", null, B(m.value ? m.value.title : ""), 1)
1219
- ])
1220
- ]),
1221
- (i(!0), r(z, null, H(O.value, (C) => (i(), r("div", {
1222
- key: C.id,
1223
- class: "__interface"
1224
- }, [
1225
- l("div", Us, [
1226
- V(Bs, {
1227
- modelValue: C.hidden,
1228
- "onUpdate:modelValue": [
1229
- (N) => C.hidden = N,
1230
- h[0] || (h[0] = () => m.value?.events.update.emit(null))
1231
- ],
1232
- disabled: !C.optional,
1233
- inversed: "",
1234
- style: { "padding-right": "8px" }
1235
- }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1236
- (i(), S(pt(C.component), {
1237
- modelValue: C.value,
1238
- "onUpdate:modelValue": (N) => C.value = N,
1239
- node: m.value,
1240
- intf: C,
1241
- style: { width: "100%" }
1242
- }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1243
- ])
1244
- ]))), 128)),
1245
- w.value && w.value.state ? (i(), r("div", Gs, [
1246
- h[2] || (h[2] = l("label", null, "Variable name", -1)),
1247
- ie(l("input", {
1248
- "onUpdate:modelValue": h[1] || (h[1] = (C) => w.value.state.variableName = C),
1249
- type: "text",
1250
- class: "baklava-input",
1251
- title: "Variable name",
1252
- onBlur: x,
1253
- onKeydown: ee(x, ["enter"])
1254
- }, null, 544), [
1255
- [re, w.value.state.variableName]
1256
- ])
1257
- ])) : I("", !0)
1374
+ v.value ? (i(), r(T, { key: 1 }, [
1375
+ l("div", Ws, [
1376
+ l("button", {
1377
+ tabindex: "-1",
1378
+ class: "__close",
1379
+ onClick: N
1380
+ }, "×"),
1381
+ l("div", Xs, [
1382
+ l("b", null, j(v.value.title), 1)
1383
+ ])
1384
+ ]),
1385
+ l("div", qs, [
1386
+ l("div", Js, [
1387
+ (i(!0), r(T, null, D(V.value, (p) => (i(), r("div", {
1388
+ key: p.id,
1389
+ class: "__interface"
1390
+ }, [
1391
+ l("div", Ys, [
1392
+ z(xe, {
1393
+ modelValue: p.hidden,
1394
+ "onUpdate:modelValue": [
1395
+ (M) => p.hidden = M,
1396
+ C[0] || (C[0] = () => v.value?.events.update.emit(null))
1397
+ ],
1398
+ disabled: !p.optional,
1399
+ inversed: "",
1400
+ style: { "padding-right": "8px" }
1401
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1402
+ (i(), O(Ce(p.component), {
1403
+ modelValue: p.value,
1404
+ "onUpdate:modelValue": (M) => p.value = M,
1405
+ node: v.value,
1406
+ intf: p,
1407
+ style: { width: "100%" }
1408
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1409
+ ])
1410
+ ]))), 128))
1411
+ ]),
1412
+ l("div", Qs, [
1413
+ k.value && k.value.state ? (i(), r("div", Ks, [
1414
+ C[3] || (C[3] = l("label", null, "Variable name", -1)),
1415
+ ee(l("input", {
1416
+ "onUpdate:modelValue": C[1] || (C[1] = (p) => k.value.state.variableName = p),
1417
+ type: "text",
1418
+ class: "baklava-input",
1419
+ title: "Variable name",
1420
+ onBlur: m,
1421
+ onKeydown: ne(m, ["enter"])
1422
+ }, null, 544), [
1423
+ [te, k.value.state.variableName]
1424
+ ])
1425
+ ])) : I("", !0),
1426
+ (i(!0), r(T, null, D(L.value, (p) => (i(), r("div", {
1427
+ key: p.id,
1428
+ class: "__interface"
1429
+ }, [
1430
+ l("div", Zs, [
1431
+ z(xe, {
1432
+ modelValue: p.hidden,
1433
+ "onUpdate:modelValue": [
1434
+ (M) => p.hidden = M,
1435
+ C[2] || (C[2] = () => v.value?.events.update.emit(null))
1436
+ ],
1437
+ disabled: !p.optional,
1438
+ inversed: "",
1439
+ style: { "padding-right": "8px" }
1440
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1441
+ (i(), O(Ce(p.component), {
1442
+ modelValue: p.value,
1443
+ "onUpdate:modelValue": (M) => p.value = M,
1444
+ node: v.value,
1445
+ intf: p,
1446
+ style: { width: "100%" }
1447
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1448
+ ])
1449
+ ]))), 128))
1450
+ ])
1451
+ ]),
1452
+ W(f.$slots, "codeEditor", { node: v.value })
1453
+ ], 64)) : I("", !0)
1258
1454
  ], 6));
1259
1455
  }
1260
- }), Ds = L({
1456
+ }), tn = U({
1261
1457
  props: {
1262
1458
  type: {
1263
1459
  type: String,
@@ -1269,119 +1465,119 @@ const ws = /* @__PURE__ */ $(bs, [["render", _s]]), ks = ["id", "data-node-type"
1269
1465
  }
1270
1466
  },
1271
1467
  setup(s) {
1272
- const { viewModel: e } = F(), { switchGraph: t } = ne(), n = T(!1), o = _(() => s.type.startsWith(K));
1468
+ const { viewModel: e } = q(), { switchGraph: t } = ae(), n = B(!1), o = b(() => s.type.startsWith(se));
1273
1469
  return { showContextMenu: n, hasContextMenu: o, contextMenuItems: [
1274
1470
  { label: "Edit Subgraph", value: "editSubgraph" },
1275
1471
  { label: "Delete Subgraph", value: "deleteSubgraph" }
1276
1472
  ], openContextMenu: () => {
1277
1473
  n.value = !0;
1278
- }, onContextMenuClick: (m) => {
1279
- const w = s.type.substring(K.length), k = e.value.editor.graphTemplates.find((O) => O.id === w);
1280
- if (k)
1281
- switch (m) {
1474
+ }, onContextMenuClick: (v) => {
1475
+ const k = s.type.substring(se.length), w = e.value.editor.graphTemplates.find((V) => V.id === k);
1476
+ if (w)
1477
+ switch (v) {
1282
1478
  case "editSubgraph":
1283
- t(k);
1479
+ t(w);
1284
1480
  break;
1285
1481
  case "deleteSubgraph":
1286
- e.value.editor.removeGraphTemplate(k);
1482
+ e.value.editor.removeGraphTemplate(w);
1287
1483
  break;
1288
1484
  }
1289
1485
  } };
1290
1486
  }
1291
- }), Ps = ["data-node-type"], Hs = { class: "__title" }, As = { class: "__title-label" };
1292
- function Fs(s, e, t, n, o, a) {
1487
+ }), sn = ["data-node-type"], nn = { class: "__title" }, on = { class: "__title-label" };
1488
+ function an(s, e, t, n, o, a) {
1293
1489
  return i(), r("div", {
1294
1490
  class: "baklava-node --palette",
1295
1491
  "data-node-type": s.type
1296
1492
  }, [
1297
- l("div", Hs, [
1298
- l("div", As, B(s.title), 1)
1493
+ l("div", nn, [
1494
+ l("div", on, j(s.title), 1)
1299
1495
  ])
1300
- ], 8, Ps);
1496
+ ], 8, sn);
1301
1497
  }
1302
- const xe = /* @__PURE__ */ $(Ds, [["render", Fs]]), Ws = {
1498
+ const Ie = /* @__PURE__ */ $(tn, [["render", an]]), rn = {
1303
1499
  class: "baklava-node --palette",
1304
1500
  style: { "margin-top": "-20px", "margin-bottom": "20px" }
1305
- }, Xs = {
1501
+ }, ln = {
1306
1502
  key: 0,
1307
1503
  style: { display: "flex", "justify-content": "space-between" }
1308
- }, Js = ["onClick"], Ys = {
1504
+ }, dn = ["onClick"], un = {
1309
1505
  key: 0,
1310
1506
  style: { margin: "auto 0", "font-size": "12px" }
1311
- }, qs = /* @__PURE__ */ L({
1507
+ }, cn = /* @__PURE__ */ U({
1312
1508
  __name: "CodeNodePalette",
1313
1509
  setup(s) {
1314
- const { viewModel: e } = F(), { x: t, y: n } = wt(), { transform: o } = st(), a = nt(e), d = ht("editorEl"), u = T(""), m = T(null), w = () => u.value ? a.value.filter(
1315
- (x) => x.name.toLowerCase().includes(u.value.toLowerCase()) || Object.values(x.nodeTypes).some(
1316
- (f) => f.title.toLowerCase().includes(u.value.toLowerCase())
1510
+ const { viewModel: e } = q(), { x: t, y: n } = Ct(), { transform: o } = ot(), a = at(e), d = vt("editorEl"), u = B(""), v = B(null), k = () => u.value ? a.value.filter(
1511
+ (N) => N.name.toLowerCase().includes(u.value.toLowerCase()) || Object.values(N.nodeTypes).some(
1512
+ (m) => m.title.toLowerCase().includes(u.value.toLowerCase())
1317
1513
  )
1318
- ) : a.value, k = (x) => u.value ? Object.values(x).filter(
1319
- (f) => f.category.toLowerCase().includes(u.value.toLowerCase()) || f.title.toLowerCase().includes(u.value.toLowerCase())
1320
- ) : Object.values(x), O = _(() => {
1321
- if (!m.value || !d?.value) return {};
1322
- const { left: x, top: f } = d.value.getBoundingClientRect();
1514
+ ) : a.value, w = (N) => u.value ? Object.values(N).filter(
1515
+ (m) => m.category.toLowerCase().includes(u.value.toLowerCase()) || m.title.toLowerCase().includes(u.value.toLowerCase())
1516
+ ) : Object.values(N), V = b(() => {
1517
+ if (!v.value || !d?.value) return {};
1518
+ const { left: N, top: m } = d.value.getBoundingClientRect();
1323
1519
  return {
1324
- top: `${n.value - f}px`,
1325
- left: `${t.value - x}px`
1520
+ top: `${n.value - m}px`,
1521
+ left: `${t.value - N}px`
1326
1522
  };
1327
- }), j = (x, f) => {
1328
- m.value = {
1329
- type: x,
1330
- nodeInformation: f
1523
+ }), L = (N, m) => {
1524
+ v.value = {
1525
+ type: N,
1526
+ nodeInformation: m
1331
1527
  };
1332
- const g = () => {
1333
- const v = R(new f.type());
1334
- e.value.displayedGraph.addNode(v);
1335
- const h = d.value.getBoundingClientRect(), [C, N] = o(t.value - h.left, n.value - h.top);
1336
- v.position.x = C, v.position.y = N, m.value = null, document.removeEventListener("pointerup", g);
1528
+ const y = () => {
1529
+ const x = P(new m.type());
1530
+ e.value.displayedGraph.addNode(x);
1531
+ const f = d.value.getBoundingClientRect(), [C, p] = o(t.value - f.left, n.value - f.top);
1532
+ x.position.x = C, x.position.y = p, v.value = null, document.removeEventListener("pointerup", y);
1337
1533
  };
1338
- document.addEventListener("pointerup", g);
1534
+ document.addEventListener("pointerup", y);
1339
1535
  };
1340
- return (x, f) => (i(), r(z, null, [
1536
+ return (N, m) => (i(), r(T, null, [
1341
1537
  l("div", {
1342
- class: U(["baklava-node-palette", { "--open": y(e).settings.palette.enabled }]),
1343
- onContextmenu: f[1] || (f[1] = P(() => {
1538
+ class: G([{ "--open": _(e).settings.palette.enabled }, "baklava-node-palette"]),
1539
+ onContextmenu: m[1] || (m[1] = A(() => {
1344
1540
  }, ["stop", "prevent"]))
1345
1541
  }, [
1346
- l("div", Ws, [
1347
- ie(l("input", {
1348
- "onUpdate:modelValue": f[0] || (f[0] = (g) => u.value = g),
1542
+ l("div", rn, [
1543
+ ee(l("input", {
1544
+ "onUpdate:modelValue": m[0] || (m[0] = (y) => u.value = y),
1349
1545
  type: "text",
1350
1546
  class: "baklava-input",
1351
1547
  title: "Filter nodes",
1352
- onKeyup: w
1548
+ onKeyup: k
1353
1549
  }, null, 544), [
1354
- [re, u.value]
1550
+ [te, u.value]
1355
1551
  ])
1356
1552
  ]),
1357
- (i(!0), r(z, null, H(w(), (g) => (i(), r("section", {
1358
- key: g.name
1553
+ (i(!0), r(T, null, D(k(), (y) => (i(), r("section", {
1554
+ key: y.name
1359
1555
  }, [
1360
- g.name !== "default" ? (i(), r("h3", Xs, [
1556
+ y.name !== "default" ? (i(), r("h3", ln, [
1361
1557
  l("div", {
1362
- onClick: (v) => u.value = g.name,
1558
+ onClick: (x) => u.value = y.name,
1363
1559
  style: { cursor: "pointer" }
1364
- }, B(g.name), 9, Js),
1365
- k(g.nodeTypes).length < Object.values(g.nodeTypes).length ? (i(), r("div", Ys, " ( " + B(k(g.nodeTypes).length) + " / " + B(Object.values(g.nodeTypes).length) + " ) ", 1)) : I("", !0)
1560
+ }, j(y.name), 9, dn),
1561
+ w(y.nodeTypes).length < Object.values(y.nodeTypes).length ? (i(), r("div", un, " ( " + j(w(y.nodeTypes).length) + " / " + j(Object.values(y.nodeTypes).length) + " ) ", 1)) : I("", !0)
1366
1562
  ])) : I("", !0),
1367
- (i(!0), r(z, null, H(k(g.nodeTypes), (v) => (i(), S(xe, {
1368
- key: v.type,
1369
- type: v.type,
1370
- title: v.title,
1371
- onPointerdown: (h) => j(v.type, v)
1563
+ (i(!0), r(T, null, D(w(y.nodeTypes), (x) => (i(), O(Ie, {
1564
+ key: x.type,
1565
+ type: x.type,
1566
+ title: x.title,
1567
+ onPointerdown: (f) => L(x.type, x)
1372
1568
  }, null, 8, ["type", "title", "onPointerdown"]))), 128))
1373
1569
  ]))), 128))
1374
1570
  ], 34),
1375
- V(vt, { name: "fade" }, {
1376
- default: J(() => [
1377
- m.value ? (i(), r("div", {
1571
+ z(mt, { name: "fade" }, {
1572
+ default: F(() => [
1573
+ v.value ? (i(), r("div", {
1378
1574
  key: 0,
1379
1575
  class: "baklava-dragged-node",
1380
- style: ae(O.value)
1576
+ style: re(V.value)
1381
1577
  }, [
1382
- V(xe, {
1383
- type: m.value.type,
1384
- title: m.value.nodeInformation.title
1578
+ z(Ie, {
1579
+ type: v.value.type,
1580
+ title: v.value.nodeInformation.title
1385
1581
  }, null, 8, ["type", "title"])
1386
1582
  ], 4)) : I("", !0)
1387
1583
  ]),
@@ -1389,33 +1585,38 @@ const xe = /* @__PURE__ */ $(Ds, [["render", Fs]]), Ws = {
1389
1585
  })
1390
1586
  ], 64));
1391
1587
  }
1392
- }), wn = /* @__PURE__ */ L({
1588
+ }), zn = /* @__PURE__ */ U({
1393
1589
  __name: "CodeGraphEditor",
1394
1590
  props: {
1395
1591
  viewModel: {}
1396
1592
  },
1397
1593
  setup(s) {
1398
- const t = Me(s, "viewModel"), n = (o) => o.events.update.emit(null);
1399
- return oe(() => {
1594
+ const t = Te(s, "viewModel"), n = (o) => o.events.update.emit(null);
1595
+ return ie(() => {
1400
1596
  t.value.subscribe(), t.value.engine.start();
1401
- }), mt(() => {
1597
+ }), ft(() => {
1402
1598
  t.value.unsubscribe(), t.value.engine.stop();
1403
- }), (o, a) => (i(), S(y(ot), { "view-model": t.value }, {
1404
- palette: J(() => [
1405
- V(qs)
1599
+ }), (o, a) => (i(), O(_(it), { "view-model": t.value }, {
1600
+ palette: F(() => [
1601
+ z(cn)
1406
1602
  ]),
1407
- node: J((d) => [
1408
- V(Ss, bt(d, {
1603
+ node: F((d) => [
1604
+ z(Hs, yt(d, {
1409
1605
  onUpdate: (u) => n(d.node)
1410
1606
  }), null, 16, ["onUpdate"])
1411
1607
  ]),
1412
- sidebar: J((d) => [
1413
- V(Rs, ft(gt(d)), null, 16)
1608
+ sidebar: F((d) => [
1609
+ z(en, gt(bt(d)), {
1610
+ codeEditor: F(({ node: u }) => [
1611
+ W(o.$slots, "sidebarCodeEditor", { node: u })
1612
+ ]),
1613
+ _: 3
1614
+ }, 16)
1414
1615
  ]),
1415
- _: 1
1616
+ _: 3
1416
1617
  }, 8, ["view-model"]));
1417
1618
  }
1418
- }), Qs = (s) => {
1619
+ }), pn = (s) => {
1419
1620
  const e = "TOGGLE_PALETTE";
1420
1621
  s.commandHandler.registerCommand(e, {
1421
1622
  execute: () => s.settings.palette.enabled = !s.settings.palette.enabled,
@@ -1435,23 +1636,23 @@ const xe = /* @__PURE__ */ $(Ds, [["render", Fs]]), Ws = {
1435
1636
  command: e,
1436
1637
  title: "Toggle palette",
1437
1638
  // Tooltip text
1438
- icon: _(() => s.settings.palette.enabled ? Ht : Xt)
1639
+ icon: b(() => s.settings.palette.enabled ? Yt : es)
1439
1640
  },
1440
- ...at,
1641
+ ...rt,
1441
1642
  {
1442
1643
  command: t,
1443
1644
  title: "Clear all",
1444
1645
  // Tooltip text
1445
- icon: ws
1646
+ icon: Vs
1446
1647
  },
1447
1648
  {
1448
1649
  command: n,
1449
1650
  title: "Toggle minimap",
1450
1651
  // Tooltip text
1451
- icon: _(() => s.settings.enableMinimap ? hs : ds)
1652
+ icon: b(() => s.settings.enableMinimap ? xs : _s)
1452
1653
  }
1453
1654
  ];
1454
- }, X = {
1655
+ }, Q = {
1455
1656
  enableMinimap: !1,
1456
1657
  toolbar: {
1457
1658
  enabled: !0
@@ -1466,72 +1667,78 @@ const xe = /* @__PURE__ */ $(Ds, [["render", Fs]]), Ws = {
1466
1667
  },
1467
1668
  displayValueOnHover: !1
1468
1669
  };
1469
- function kn(s) {
1470
- const e = it(s?.existingEditor);
1471
- e.code = s?.code ? new s.code(e) : new Ot(e), Qs(e);
1670
+ function jn(s) {
1671
+ const e = lt(s?.existingEditor);
1672
+ e.code = s?.code ? new s.code(e) : new jt(e), pn(e);
1472
1673
  const t = {};
1473
- return Object.keys(X).forEach((n) => {
1474
- t[n] = typeof X[n] == "object" ? { ...e.settings[n], ...X[n] } : X[n];
1475
- }), e.settings = R({ ...e.settings, ...t }), e.settings.nodes.defaultWidth = 350, e.state = R({
1674
+ return Object.keys(Q).forEach((n) => {
1675
+ t[n] = typeof Q[n] == "object" ? { ...e.settings[n], ...Q[n] } : Q[n];
1676
+ }), e.settings = P({ ...e.settings, ...t }), e.settings.nodes.defaultWidth = 350, e.state = P({
1476
1677
  modules: {},
1477
1678
  token: null
1478
- }), e.engine = new rt(e.editor), e.subscribe = () => {
1679
+ }), e.engine = new dt(e.editor), e.subscribe = () => {
1479
1680
  e.state.token && e.unsubscribe();
1480
- const n = Symbol();
1481
- e.displayedGraph.events.addNode.subscribe(n, (o) => o.code = e.code), e.engine.events.beforeRun.subscribe(n, () => {
1482
- e.engine.pause(), e.code && (e.code.onCodeUpdate(), e.code.sortNodes(), e.code.updateCodeTemplates(), e.code.resetInputInterfaceScript()), e.engine.resume();
1483
- }), e.engine.events.beforeNodeCalculation.subscribe(n, (o) => {
1681
+ const n = Symbol(), o = e.displayedGraph;
1682
+ o.events.addNode.subscribe(n, (a) => {
1683
+ a.code = e.code;
1684
+ }), o.events.addConnection.subscribe(n, (a) => {
1685
+ e.code.findNodeById(a.to.nodeId)?.onConnected(), e.code.findNodeById(a.from.nodeId)?.onConnected();
1686
+ }), o.events.removeConnection.subscribe(n, (a) => {
1687
+ e.code.findNodeById(a.to.nodeId)?.onUnconnected(), e.code.findNodeById(a.from.nodeId)?.onUnconnected();
1688
+ }), e.engine.events.beforeRun.subscribe(n, () => {
1689
+ e.engine.pause(), e.code && (e.code.updateCodeNodes(), e.code.sortNodes(), e.code.updateCodeTemplates(), e.code.resetInputInterfaceScript()), e.engine.resume();
1690
+ }), e.engine.events.beforeNodeCalculation.subscribe(n, (a) => {
1484
1691
  e.engine.pause();
1485
- const a = o.node;
1486
- a.isCodeNode && (a.updateOutputVariableName(), a.updateConnectedInputInterfaces()), e.engine.resume();
1487
- }), e.engine.events.afterRun.subscribe(n, (o) => {
1488
- e.engine.pause(), lt(o, e.editor), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
1692
+ const d = a.node;
1693
+ d.isCodeNode && (d.updateOutputNames(), d.updateConnectedInputInterfaces()), e.engine.resume();
1694
+ }), e.engine.events.afterRun.subscribe(n, (a) => {
1695
+ e.engine.pause(), ut(a, e.editor), e.code && (e.code.renderNodeCodes(), e.code.renderCode()), e.engine.resume();
1489
1696
  }), e.state.token = n;
1490
1697
  }, e.unsubscribe = () => {
1491
1698
  if (!e.state.token) return;
1492
1699
  const n = e.state.token;
1493
- e.displayedGraph.events.addNode.unsubscribe(n), e.engine.events.beforeRun.unsubscribe(n), e.engine.events.afterRun.unsubscribe(n), e.state.token = null;
1700
+ e.displayedGraph.events.addNode.unsubscribe(n), e.displayedGraph.events.addConnection.unsubscribe(n), e.engine.events.beforeRun.unsubscribe(n), e.engine.events.afterRun.unsubscribe(n), e.state.token = null;
1494
1701
  }, e;
1495
1702
  }
1496
1703
  export {
1497
- kt as AbstractCodeNode,
1498
- rn as CheckboxInterface,
1499
- In as CheckboxInterfaceComponent,
1500
- Ot as Code,
1501
- wn as CodeGraphEditor,
1502
- $e as CodeNode,
1503
- W as CodeNodeInputInterface,
1504
- D as CodeNodeInterface,
1505
- Mt as CodeNodeOutputInterface,
1506
- X as DEFAULT_SETTINGS,
1507
- $t as DynamicCodeNode,
1508
- ln as IntegerInterface,
1509
- dn as ListInputInterface,
1510
- un as NumberInterface,
1511
- Nn as NumberInterfaceComponent,
1512
- cn as SelectInterface,
1513
- pn as SliderInterface,
1514
- hn as TextInputInterface,
1515
- vn as TextareaInputInterface,
1516
- mn as TupleInputInterface,
1517
- an as addDefaultInterfaceTypes,
1518
- Qs as addToolbarCommands,
1519
- Te as booleanType,
1520
- fn as defineCodeNode,
1521
- gn as defineDynamicCodeNode,
1522
- Nt as dictType,
1704
+ wt as AbstractCodeNode,
1705
+ kn as CheckboxInterface,
1706
+ jt as Code,
1707
+ zn as CodeGraphEditor,
1708
+ Ee as CodeNode,
1709
+ Y as CodeNodeInputInterface,
1710
+ H as CodeNodeInterface,
1711
+ le as CodeNodeInterfaceComponent,
1712
+ $t as CodeNodeOutputInterface,
1713
+ Q as DEFAULT_SETTINGS,
1714
+ zt as DynamicCodeNode,
1715
+ Cn as IntegerInterface,
1716
+ wn as ListInputInterface,
1717
+ xn as NumberInterface,
1718
+ In as SelectInterface,
1719
+ Nn as SliderInterface,
1720
+ Mn as TextInputInterface,
1721
+ St as TextInputInterfaceComponent,
1722
+ $n as TextareaInputInterface,
1723
+ On as TupleInputInterface,
1724
+ _n as addDefaultInterfaceTypes,
1725
+ pn as addToolbarCommands,
1726
+ Be as booleanType,
1727
+ Tn as defineCodeNode,
1728
+ En as defineDynamicCodeNode,
1729
+ Mt as dictType,
1523
1730
  xt as formatInputs,
1524
- te as getCodeNodes,
1525
- bn as getPositionAtColumn,
1526
- yn as getPositionBeforeNode,
1527
- Ee as listType,
1528
- Oe as loadNodeState,
1529
- A as nodeType,
1731
+ oe as getCodeNodes,
1732
+ Vn as getPositionAtColumn,
1733
+ Bn as getPositionBeforeNode,
1734
+ Se as listType,
1735
+ Ve as loadNodeState,
1736
+ X as nodeType,
1530
1737
  de as numberType,
1531
- Ct as saveNodeState,
1532
- on as setOptional,
1738
+ It as saveNodeState,
1739
+ yn as setOptional,
1533
1740
  ue as stringType,
1534
- _n as transferCodeScript,
1535
- Se as tupleType,
1536
- kn as useCodeGraph
1741
+ Sn as transferCodeScript,
1742
+ ze as tupleType,
1743
+ jn as useCodeGraph
1537
1744
  };