@babsey/code-graph 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,24 @@
1
- import Z from "mustache";
2
- import { reactive as D, defineComponent as F, createElementBlock as p, openBlock as d, toDisplayString as G, markRaw as z, computed as O, createElementVNode as u, withDirectives as de, vModelText as le, createStaticVNode as se, toRef as Be, onMounted as fe, onBeforeUnmount as ze, watch as He, createBlock as j, unref as w, withCtx as ee, createVNode as L, normalizeProps as pt, guardReactiveProps as ht, renderSlot as ne, mergeProps as mt, ref as V, onUpdated as Le, normalizeStyle as ve, normalizeClass as Y, createCommentVNode as M, withModifiers as te, Fragment as B, createTextVNode as ft, withKeys as he, renderList as J, nextTick as vt, inject as gt, Transition as bt, resolveDynamicComponent as Me, shallowReadonly as _t } from "vue";
3
- import { v4 as K } from "uuid";
4
- import { AbstractNode as yt, NodeInterface as A, getGraphNodeTypeString as Ue, Graph as Ct, GraphTemplate as It, GRAPH_NODE_TYPE_PREFIX as wt, GRAPH_INPUT_NODE_TYPE as kt, GRAPH_OUTPUT_NODE_TYPE as Nt, Editor as xt } from "@baklavajs/core";
5
- import { NodeInterfaceType as X, BaklavaInterfaceTypes as Ot, setType as $ } from "@baklavajs/interface-types";
6
- import { allowMultipleConnections as Q, applyResult as Ae, BaseEngine as Tt, sortTopologically as Et } from "@baklavajs/engine";
7
- import { displayInSidebar as De, CheckboxInterfaceComponent as $t, useGraph as ge, IntegerInterfaceComponent as Mt, TextInputInterfaceComponent as Fe, NumberInterfaceComponent as Gt, SelectInterfaceComponent as St, SliderInterfaceComponent as Pt, TextareaInputInterfaceComponent as Vt, IntegerInterface as Rt, TextInputInterface as be, DEFAULT_TOOLBAR_COMMANDS as jt, Commands as q, BaklavaEditor as Bt, Components as me, useViewModel as oe, useTemporaryConnection as zt, useTransform as Ht, useNodeCategories as Lt, DEFAULT_SETTINGS as Ut, useCommandHandler as At, useHistory as Dt, useClipboard as Ft, registerDeleteNodesCommand as Wt, registerSaveSubgraphCommand as Yt, registerSwitchToMainGraphCommand as Kt, registerSidebarCommands as Xt, registerZoomToFitCommands as qt, setViewNodeProperties as Jt } from "@baklavajs/renderer-vue";
8
- import Qt from "toposort";
9
- import { SequentialHook as Ge } from "@baklavajs/events";
10
- import { usePointer as Zt } from "@vueuse/core";
11
- Z.escape = (n) => n;
12
- class We extends yt {
13
- state;
1
+ import ce from "mustache";
2
+ import { reactive as te, defineComponent as F, createElementBlock as b, openBlock as p, toDisplayString as L, markRaw as W, computed as P, createElementVNode as m, withDirectives as ke, vModelText as xe, createStaticVNode as fe, toRef as Me, ref as H, createVNode as G, unref as O, mergeModels as Ue, useModel as xt, resolveComponent as Ze, createCommentVNode as j, onMounted as Se, onBeforeUnmount as et, watch as tt, createBlock as B, withCtx as ee, normalizeProps as It, guardReactiveProps as Nt, renderSlot as q, mergeProps as Et, onUpdated as nt, normalizeStyle as Pe, normalizeClass as ne, withModifiers as le, Fragment as U, createTextVNode as ot, withKeys as Oe, renderList as se, nextTick as Tt, resolveDynamicComponent as De, inject as Ot, Transition as $t, shallowReadonly as Mt } from "vue";
3
+ import { v4 as re } from "uuid";
4
+ import { AbstractNode as St, NodeInterface as J, Graph as Pt, getGraphNodeTypeString as st, GraphTemplate as Gt, GRAPH_NODE_TYPE_PREFIX as At, GRAPH_INPUT_NODE_TYPE as Rt, GRAPH_OUTPUT_NODE_TYPE as jt, Editor as Lt } from "@baklavajs/core";
5
+ import { NodeInterfaceType as ae, BaklavaInterfaceTypes as Vt, setType as V } from "@baklavajs/interface-types";
6
+ import { allowMultipleConnections as de, BaseEngine as Bt, sortTopologically as Ht, applyResult as rt } from "@baklavajs/engine";
7
+ import { displayInSidebar as at, CheckboxInterfaceComponent as zt, useGraph as Ge, IntegerInterfaceComponent as Ut, TextInputInterfaceComponent as it, NumberInterfaceComponent as Dt, SelectInterfaceComponent as Ft, SliderInterfaceComponent as Wt, TextareaInputInterfaceComponent as Yt, IntegerInterface as Xt, TextInputInterface as Ae, DEFAULT_TOOLBAR_COMMANDS as Kt, Commands as ue, BaklavaEditor as qt, Components as $e, useViewModel as me, useTemporaryConnection as Jt, useTransform as Qt, useNodeCategories as Zt, DEFAULT_SETTINGS as en, useCommandHandler as tn, useHistory as nn, useClipboard as on, registerDeleteNodesCommand as sn, registerSaveSubgraphCommand as rn, registerSwitchToMainGraphCommand as an, registerSidebarCommands as ln, registerZoomToFitCommands as un, setViewNodeProperties as dn } from "@baklavajs/renderer-vue";
8
+ import cn from "toposort";
9
+ import { SequentialHook as Fe } from "@baklavajs/events";
10
+ import { usePointer as pn } from "@vueuse/core";
11
+ ce.escape = (n) => n;
12
+ class lt extends St {
13
+ codeTemplate;
14
14
  isCodeNode = !0;
15
+ mask = null;
15
16
  name = "";
16
- codeTemplate;
17
+ state;
17
18
  inputs = {};
18
19
  outputs = {};
19
20
  constructor() {
20
- super(), this.initializeIo(), this.twoColumn = !0, this.state = D({
21
+ super(), this.initializeIo(), this.twoColumn = !0, this.state = te({
21
22
  codeTemplate: "",
22
23
  hidden: !1,
23
24
  integrated: !1,
@@ -27,7 +28,7 @@ class We extends yt {
27
28
  script: "",
28
29
  variableName: "a"
29
30
  }), this.codeTemplate = function() {
30
- return `${this.name}(${en(this.codeNodeInputs).join(", ")})`;
31
+ return `${this.name}(${hn(this.codeNodeInputs).join(", ")})`;
31
32
  };
32
33
  }
33
34
  get code() {
@@ -121,30 +122,23 @@ class We extends yt {
121
122
  let s = [];
122
123
  if (t !== "outputs" && this.inputs[e]) {
123
124
  const o = this.graph.connections.filter(
124
- (a) => a.to.id === this.inputs[e]?.id || a.from.id === this.inputs[e]?.id
125
- ).map((a) => a.from.nodeId);
125
+ (r) => r.to.id === this.inputs[e]?.id || r.from.id === this.inputs[e]?.id
126
+ ).map((r) => r.from.nodeId);
126
127
  o && (s = s.concat(o));
127
128
  }
128
129
  if (t !== "inputs" && this.outputs[e]) {
129
130
  const o = this.graph.connections.filter(
130
- (a) => a.from.id === this.outputs[e]?.id || a.from.id === this.outputs[e]?.id
131
- ).map((a) => a.to.nodeId);
131
+ (r) => r.from.id === this.outputs[e]?.id || r.from.id === this.outputs[e]?.id
132
+ ).map((r) => r.to.nodeId);
132
133
  o && (s = s.concat(o));
133
134
  }
134
135
  return !s || s.length == 0 ? [] : s.map((o) => this.graph.findNodeById(o));
135
136
  }
136
- /**
137
- * Register code
138
- * @param code
139
- */
140
- registerCode(e) {
141
- this.code = e;
142
- }
143
137
  /**
144
138
  * Render code of this node.
145
139
  */
146
140
  renderCode(e) {
147
- return Z.render(this.state.codeTemplate, e);
141
+ return ce.render(this.state.codeTemplate, e);
148
142
  }
149
143
  /**
150
144
  * Update code templates.
@@ -189,7 +183,7 @@ class We extends yt {
189
183
  this.state.props = e;
190
184
  }
191
185
  }
192
- class _e extends We {
186
+ class Re extends lt {
193
187
  /**
194
188
  * The default implementation does nothing.
195
189
  * Overwrite this method to do calculation.
@@ -202,58 +196,58 @@ class _e extends We {
202
196
  return this.lockCode || (s._code = this.renderCode({ inputs: e, ...t })), this.updateOutputValues(s), s;
203
197
  };
204
198
  load(e) {
205
- super.load(e), Ye(this.graph, e);
199
+ super.load(e), ut(this.graph, e);
206
200
  }
207
201
  save() {
208
202
  const e = super.save();
209
- return tn(this.graph, e), e;
203
+ return fn(this.graph, e), e;
210
204
  }
211
205
  }
212
- const en = (n, e = !0) => {
206
+ const hn = (n, e = !0) => {
213
207
  const t = [], s = Object.keys(n);
214
208
  return s.forEach((o) => {
215
209
  if (n[o]?.hidden) return;
216
210
  const i = e && t.length < s.indexOf(o) ? `${o}=` : "";
217
211
  t.push(`${i}{{ inputs.${o} }}`);
218
212
  }), t;
219
- }, Ye = (n, e) => {
213
+ }, ut = (n, e) => {
220
214
  if (!n) return;
221
215
  const t = n.findNodeById(e.id);
222
216
  if (!t || t.subgraph) return;
223
217
  const s = t;
224
- s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([o, a]) => {
225
- o !== "_code" && s.inputs[o] && (s.inputs[o].hidden = a.hidden);
226
- }), Object.entries(e.outputs).forEach(([o, a]) => {
227
- o !== "_code" && s.outputs[o] && (s.outputs[o].hidden = a.hidden);
218
+ s.state && (s.state.integrated = e.integrated, s.state.modules = e.modules, s.state.props = e.props), Object.entries(e.inputs).forEach(([o, r]) => {
219
+ o !== "_code" && s.inputs[o] && (s.inputs[o].hidden = r.hidden);
220
+ }), Object.entries(e.outputs).forEach(([o, r]) => {
221
+ o !== "_code" && s.outputs[o] && (s.outputs[o].hidden = r.hidden);
228
222
  });
229
- }, tn = (n, e) => {
223
+ }, fn = (n, e) => {
230
224
  if (!n) return;
231
225
  const t = n.findNodeById(e.id);
232
226
  if (!t || t.subgraph) return;
233
227
  const s = t;
234
- s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([o, a]) => {
235
- o !== "_code" && s.inputs[o] && (a.hidden = s.inputs[o].hidden);
236
- }), Object.entries(e.outputs).forEach(([o, a]) => {
237
- o !== "_code" && s.outputs[o] && (a.hidden = s.outputs[o].hidden);
228
+ s.state && (e.integrated = s.state.integrated, e.modules = s.state.modules), Object.entries(e.inputs).forEach(([o, r]) => {
229
+ o !== "_code" && s.inputs[o] && (r.hidden = s.inputs[o].hidden);
230
+ }), Object.entries(e.outputs).forEach(([o, r]) => {
231
+ o !== "_code" && s.outputs[o] && (r.hidden = s.outputs[o].hidden);
238
232
  });
239
- }, nn = ["title"], ye = /* @__PURE__ */ F({
233
+ }, mn = ["title"], je = /* @__PURE__ */ F({
240
234
  __name: "CodeNodeInterface",
241
235
  props: {
242
236
  intf: {}
243
237
  },
244
238
  setup(n) {
245
- return (e, t) => (d(), p("div", {
239
+ return (e, t) => (p(), b("div", {
246
240
  title: n.intf.value
247
- }, G(n.intf.name), 9, nn));
241
+ }, L(n.intf.name), 9, mn));
248
242
  }
249
243
  });
250
- class R extends A {
244
+ class D extends J {
251
245
  isCodeNode = !0;
252
246
  code;
253
247
  state;
254
248
  type = null;
255
249
  constructor(e, t) {
256
- super(e, t), this.setComponent(z(ye)), this.state = D({
250
+ super(e, t), this.setComponent(W(je)), this.state = te({
257
251
  optional: !1
258
252
  });
259
253
  }
@@ -268,9 +262,9 @@ class R extends A {
268
262
  return this.state.optional = e, this.setHidden(e), this;
269
263
  }
270
264
  }
271
- class ae extends R {
265
+ class ve extends D {
272
266
  constructor(e = "", t) {
273
- super(e, t), this.setComponent(z(ye)), this.use(De, !0);
267
+ super(e, t), this.setComponent(W(je)), this.use(at, !0);
274
268
  }
275
269
  get value() {
276
270
  return super.value;
@@ -279,69 +273,69 @@ class ae extends R {
279
273
  super.value = e, this.name !== "_code" && this.setHidden(!1);
280
274
  }
281
275
  }
282
- const Ke = new X("boolean"), sn = new X("dict"), Xe = new X("list"), U = new X("node"), Ce = new X("number"), Ie = new X("string"), qe = new X("tuple"), mo = (n) => {
283
- new Ot(n.editor, { viewPlugin: n }).addTypes(Ke, sn, Xe, U, Ce, Ie, qe);
276
+ const dt = new ae("boolean"), vn = new ae("dict"), ct = new ae("list"), X = new ae("node"), Le = new ae("number"), Ve = new ae("string"), pt = new ae("tuple"), or = (n) => {
277
+ new Vt(n.editor, { viewPlugin: n }).addTypes(dt, vn, ct, X, Le, Ve, pt);
284
278
  };
285
- class fo extends ae {
279
+ class sr extends ve {
286
280
  constructor(e, t) {
287
- super(e, t), this.setComponent(z($t)), this.use($, Ke);
281
+ super(e, t), this.setComponent(W(zt)), this.use(V, dt);
288
282
  }
289
283
  getValue = () => this.value ? "True" : "False";
290
284
  }
291
- class on extends R {
285
+ class gn extends D {
292
286
  isCodeNodeOutput = !0;
293
287
  suffix = "";
294
288
  constructor(e = "", t = "") {
295
- super(e, ""), this.suffix = t, this.setComponent(z(ye));
289
+ super(e, ""), this.suffix = t, this.setComponent(W(je));
296
290
  }
297
291
  get codeValue() {
298
292
  return this.node?.outputs._code.value ?? "";
299
293
  }
300
294
  get node() {
301
- const { graph: e } = ge();
295
+ const { graph: e } = Ge();
302
296
  return e.value.findNodeById(this.nodeId);
303
297
  }
304
298
  }
305
- class we extends ae {
299
+ class Be extends ve {
306
300
  min;
307
301
  max;
308
302
  constructor(e, t, s, o) {
309
- super(e, t), this.min = s, this.max = o, this.use($, Ce);
303
+ super(e, t), this.min = s, this.max = o, this.use(V, Le);
310
304
  }
311
305
  validate(e) {
312
306
  return (this.min === void 0 || e >= this.min) && (this.max === void 0 || e <= this.max);
313
307
  }
314
308
  }
315
- class vo extends we {
316
- component = z(Mt);
309
+ class rr extends Be {
310
+ component = W(Ut);
317
311
  validate(e) {
318
312
  return Number.isInteger(e) && super.validate(e);
319
313
  }
320
314
  }
321
- class go extends ae {
315
+ class ar extends ve {
322
316
  constructor(e = "", t = "") {
323
- super(e, t), this.setComponent(z(Fe)), this.use($, Xe);
317
+ super(e, t), this.setComponent(W(it)), this.use(V, ct);
324
318
  }
325
319
  getValue = () => `[${this.value}]`;
326
320
  }
327
- class bo extends we {
328
- component = z(Gt);
321
+ class ir extends Be {
322
+ component = W(Dt);
329
323
  }
330
- class ke extends ae {
324
+ class He extends ve {
331
325
  constructor(e, t) {
332
- super(e, t), this.use($, Ie);
326
+ super(e, t), this.use(V, Ve);
333
327
  }
334
328
  getValue = () => `"${this.value}"`;
335
329
  }
336
- class _o extends ke {
337
- component = z(St);
330
+ class lr extends He {
331
+ component = W(Ft);
338
332
  items;
339
333
  constructor(e, t, s) {
340
334
  super(e, t), this.items = s;
341
335
  }
342
336
  }
343
- class yo extends we {
344
- component = z(Pt);
337
+ class ur extends Be {
338
+ component = W(Wt);
345
339
  min;
346
340
  max;
347
341
  constructor(e, t, s, o) {
@@ -349,7 +343,7 @@ class yo extends we {
349
343
  }
350
344
  getValue = () => `${Math.round(this.value * 1e3) / 1e3}`;
351
345
  }
352
- const an = F({
346
+ const bn = F({
353
347
  props: {
354
348
  intf: {
355
349
  type: Object,
@@ -362,58 +356,58 @@ const an = F({
362
356
  },
363
357
  emits: ["update:modelValue"],
364
358
  setup(n, { emit: e }) {
365
- return { v: O({
359
+ return { v: P({
366
360
  get: () => n.modelValue,
367
361
  set: (s) => {
368
362
  e("update:modelValue", s);
369
363
  }
370
364
  }) };
371
365
  }
372
- }), P = (n, e) => {
366
+ }), A = (n, e) => {
373
367
  const t = n.__vccOpts || n;
374
368
  for (const [s, o] of e)
375
369
  t[s] = o;
376
370
  return t;
377
- }, rn = { style: { position: "relative" } }, dn = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, ln = ["placeholder", "title"];
378
- function un(n, e, t, s, o, a) {
379
- return d(), p("div", rn, [
380
- u("label", dn, G(n.intf.name), 1),
381
- de(u("input", {
371
+ }, yn = { style: { position: "relative" } }, _n = { style: { "font-size": "12px", padding: "0 6px", position: "absolute", top: "-8px", "background-color": "var(--baklava-node-color-background)" } }, Cn = ["placeholder", "title"];
372
+ function wn(n, e, t, s, o, r) {
373
+ return p(), b("div", yn, [
374
+ m("label", _n, L(n.intf.name), 1),
375
+ ke(m("input", {
382
376
  "onUpdate:modelValue": e[0] || (e[0] = (i) => n.v = i),
383
377
  type: "text",
384
378
  class: "baklava-input",
385
379
  placeholder: n.intf.name,
386
380
  title: n.intf.name
387
- }, null, 8, ln), [
388
- [le, n.v]
381
+ }, null, 8, Cn), [
382
+ [xe, n.v]
389
383
  ])
390
384
  ]);
391
385
  }
392
- const cn = /* @__PURE__ */ P(an, [["render", un]]);
393
- class Co extends ke {
394
- component = z(cn);
386
+ const kn = /* @__PURE__ */ A(bn, [["render", wn]]);
387
+ class dr extends He {
388
+ component = W(kn);
395
389
  }
396
- class Io extends ke {
397
- component = z(Vt);
390
+ class cr extends He {
391
+ component = W(Yt);
398
392
  }
399
- class wo extends ae {
393
+ class pr extends ve {
400
394
  constructor(e = "", t = "") {
401
- super(e, t), this.setComponent(z(Fe)), this.use($, qe);
395
+ super(e, t), this.setComponent(W(it)), this.use(V, pt);
402
396
  }
403
397
  getValue = () => `(${this.value})`;
404
398
  }
405
- function ko(n) {
406
- return class extends _e {
399
+ function hr(n) {
400
+ return class extends Re {
407
401
  type = n.type;
408
402
  inputs = {};
409
403
  outputs = {};
410
404
  constructor() {
411
405
  super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate.call(this, { inputs: e, ...t })), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.variableName != null && (this.state.variableName = n.variableName), n.codeTemplate && (this.codeTemplate = n.codeTemplate), this.addInput(
412
406
  "_code",
413
- new R("", []).use($, U).use(Q).setHidden(!0)
407
+ new D("", []).use(V, X).use(de).setHidden(!0)
414
408
  ), this.addOutput(
415
409
  "_code",
416
- new R("", []).use($, U).use(Q).setHidden(!0)
410
+ new D("", []).use(V, X).use(de).setHidden(!0)
417
411
  );
418
412
  }
419
413
  onPlaced() {
@@ -439,10 +433,10 @@ function ko(n) {
439
433
  }
440
434
  };
441
435
  }
442
- class pn extends _e {
436
+ class xn extends Re {
443
437
  }
444
- function No(n) {
445
- return class extends pn {
438
+ function fr(n) {
439
+ return class extends xn {
446
440
  type = n.type;
447
441
  inputs = {};
448
442
  outputs = {};
@@ -452,10 +446,10 @@ function No(n) {
452
446
  constructor() {
453
447
  super(), this._title = n.title ?? n.type, this.executeFactory("input", n.inputs), this.executeFactory("output", n.outputs), n.calculate && (this.calculate = (e, t) => n.calculate?.call(this, e, t)), n.onCreate?.call(this), this.name = n.name ?? n.type, this.updateModules(n.modules), n.codeTemplate && (this.codeTemplate = n.codeTemplate), n.variableName && (this.state.variableName = n.variableName), this.addInput(
454
448
  "_code",
455
- new R("", []).use($, U).use(Q).setHidden(!0)
449
+ new D("", []).use(V, X).use(de).setHidden(!0)
456
450
  ), this.addOutput(
457
451
  "_code",
458
- new R("", []).use($, U).use(Q).setHidden(!0)
452
+ new D("", []).use(V, X).use(de).setHidden(!0)
459
453
  ), this.staticInputKeys.push("_code"), this.staticOutputKeys.push("_code");
460
454
  }
461
455
  onPlaced() {
@@ -487,19 +481,19 @@ function No(n) {
487
481
  if (!this.inputs[t]) {
488
482
  const s = e.inputs[t].value;
489
483
  let o;
490
- typeof s == "number" ? o = new Rt(t, s).use($, Ce) : o = new be(t, JSON.stringify(s)).use($, Ie), o.use(De, !0), this.addInput(t, o);
484
+ typeof s == "number" ? o = new Xt(t, s).use(V, Le) : o = new Ae(t, JSON.stringify(s)).use(V, Ve), o.use(at, !0), this.addInput(t, o);
491
485
  }
492
486
  this.inputs[t] && (this.inputs[t].load(e.inputs[t]), this.inputs[t].nodeId = this.id);
493
487
  }
494
488
  for (const t of Object.keys(e.outputs))
495
489
  if (!this.staticOutputKeys.includes(t)) {
496
490
  if (!this.outputs[t]) {
497
- const s = new on(t);
491
+ const s = new gn(t);
498
492
  this.addOutput(t, s);
499
493
  }
500
494
  this.outputs[t] && (this.outputs[t].load(e.outputs[t]), this.outputs[t].nodeId = this.id);
501
495
  }
502
- Ye(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
496
+ ut(this.graph, e), this.preventUpdate = !1, this.events.loaded.emit(this);
503
497
  }
504
498
  onUpdate() {
505
499
  if (this.preventUpdate) return;
@@ -514,13 +508,13 @@ function No(n) {
514
508
  return s;
515
509
  }
516
510
  updateInterfaces(e, t, s) {
517
- const o = e === "input" ? this.staticInputKeys : this.staticOutputKeys, a = e === "input" ? this.inputs : this.outputs;
518
- for (const i of Object.keys(a))
511
+ const o = e === "input" ? this.staticInputKeys : this.staticOutputKeys, r = e === "input" ? this.inputs : this.outputs;
512
+ for (const i of Object.keys(r))
519
513
  o.includes(i) || t[i] && !s.includes(i) || (e === "input" ? this.removeInput(i) : this.removeOutput(i));
520
514
  for (const i of Object.keys(t)) {
521
- if (a[i]) continue;
522
- const r = t[i]();
523
- e === "input" ? this.addInput(i, r) : this.addOutput(i, r);
515
+ if (r[i]) continue;
516
+ const a = t[i]();
517
+ e === "input" ? this.addInput(i, a) : this.addOutput(i, a);
524
518
  }
525
519
  }
526
520
  updateProps(e) {
@@ -534,186 +528,13 @@ function No(n) {
534
528
  }
535
529
  };
536
530
  }
537
- const Se = "__baklava_SubgraphInputNode", Pe = "__baklava_SubgraphOutputNode";
538
- class Je extends _e {
539
- graphInterfaceId;
540
- constructor() {
541
- super(), this.graphInterfaceId = K();
542
- }
543
- onPlaced() {
544
- super.onPlaced(), this.initializeIo();
545
- }
546
- load(e) {
547
- super.load(e), this.graphInterfaceId = e.graphInterfaceId;
548
- }
549
- save() {
550
- return {
551
- ...super.save(),
552
- graphInterfaceId: this.graphInterfaceId
553
- };
554
- }
555
- update() {
556
- }
557
- }
558
- class Qe extends Je {
559
- static isGraphInputNode(e) {
560
- return e.type === Se;
561
- }
562
- type = Se;
563
- inputs = {
564
- name: new A("Name", "Input")
565
- };
566
- outputs = {
567
- placeholder: new A("Value", void 0)
568
- };
569
- }
570
- class Ze extends Je {
571
- static isGraphOutputNode(e) {
572
- return e.type === Pe;
573
- }
574
- type = Pe;
575
- inputs = {
576
- name: new A("Name", "Output"),
577
- placeholder: new A("Value", void 0)
578
- };
579
- outputs = {
580
- output: new A("Output", void 0).setHidden(!0)
581
- };
582
- calculate = ({ placeholder: e }) => ({
583
- output: e
584
- });
585
- }
586
- const hn = [
587
- "component",
588
- "connectionCount",
589
- "events",
590
- "hidden",
591
- "hooks",
592
- "id",
593
- "isCodeNode",
594
- "isInput",
595
- "name",
596
- "nodeId",
597
- "port",
598
- "templateId",
599
- "value"
600
- ];
601
- function mn(n) {
602
- return class extends We {
603
- type = Ue(n);
604
- get title() {
605
- return this._title;
606
- }
607
- set title(t) {
608
- this.template.name = t;
609
- }
610
- inputs = {};
611
- outputs = {};
612
- template = n;
613
- subgraph;
614
- update() {
615
- }
616
- onConnected() {
617
- }
618
- onUnconnected() {
619
- }
620
- calculate = async (t, s) => {
621
- if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
622
- if (!s.engine || typeof s.engine != "object")
623
- throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
624
- const o = s.engine.getInputValues(this.subgraph);
625
- for (const r of this.subgraph.inputs)
626
- o.set(r.nodeInterfaceId, t[r.id]);
627
- const a = await s.engine.runGraph(
628
- this.subgraph,
629
- o,
630
- s.globalValues
631
- );
632
- s.engine.pause(), Ae(a, s.engine.editor), s.engine.resume();
633
- const i = {};
634
- for (const r of this.subgraph.outputs)
635
- i[r.id] = a.get(r.nodeId)?.get("output");
636
- return i._calculationResults = a, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
637
- };
638
- load(t) {
639
- if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
640
- if (!this.template) throw new Error("Unable to load graph node without graph template");
641
- this.subgraph.load(t.graphState), super.load(t);
642
- }
643
- save() {
644
- if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
645
- return {
646
- ...super.save(),
647
- graphState: this.subgraph.save()
648
- };
649
- }
650
- onPlaced() {
651
- this.template.events.updated.subscribe(this, () => this.initialize()), this.template.events.nameChanged.subscribe(this, (t) => {
652
- this._title = t;
653
- }), this.initialize();
654
- }
655
- onDestroy() {
656
- this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
657
- }
658
- initialize() {
659
- this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
660
- {{ /nodes }}`, this.events.update.emit(null);
661
- }
662
- /**
663
- * Render code of this node.
664
- */
665
- renderCode(t) {
666
- return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : Z.render(this.state.codeTemplate, t);
667
- }
668
- updateInterfaces() {
669
- if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
670
- for (const t of this.subgraph.inputs)
671
- t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
672
- for (const t of Object.keys(this.inputs))
673
- this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
674
- for (const t of this.subgraph.outputs)
675
- t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
676
- for (const t of Object.keys(this.outputs))
677
- this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
678
- this.addInput(
679
- "_code",
680
- new R("", []).use($, U).use(Q).setHidden(!0)
681
- ), this.addOutput(
682
- "_code",
683
- new R("", []).use($, U).use(Q).setHidden(!0)
684
- ), this.addOutput("_calculationResults", new A("_calculationResults", void 0).setHidden(!0));
685
- }
686
- /**
687
- * When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
688
- * For example, the `type` property or the `allowMultipleConnections` property.
689
- * These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
690
- */
691
- createProxyInterface(t, s) {
692
- const o = new R(t.name, void 0);
693
- return new Proxy(o, {
694
- get: (a, i) => {
695
- if (hn.includes(i) || i in a || typeof i == "string" && i.startsWith("__v_"))
696
- return Reflect.get(a, i);
697
- let r;
698
- s ? r = this.subgraph?.nodes.find(
699
- (_) => Qe.isGraphInputNode(_) && _.graphInterfaceId === t.id
700
- )?.outputs.placeholder.id : r = this.subgraph?.nodes.find(
701
- (_) => Ze.isGraphOutputNode(_) && _.graphInterfaceId === t.id
702
- )?.inputs.placeholder.id;
703
- const c = this.subgraph?.connections.find((g) => r === (s ? g.from : g.to)?.id), h = s ? c?.to : c?.from;
704
- if (h) return Reflect.get(h, i);
705
- }
706
- });
707
- }
708
- };
709
- }
710
- Z.escape = (n) => n;
711
- class fn {
531
+ ce.escape = (n) => n;
532
+ class ze {
712
533
  _id;
713
534
  _state;
714
535
  viewModel;
715
536
  constructor() {
716
- this._id = K(), this._state = D({
537
+ this._id = re(), this._state = te({
717
538
  lockCode: !1,
718
539
  modules: {},
719
540
  script: "",
@@ -777,13 +598,23 @@ class fn {
777
598
  * Render code script.
778
599
  */
779
600
  renderCode(e) {
780
- this.state.script = Z.render(this.state.template || "", e);
601
+ this.state.script = ce.render(this.state.template || "", e);
602
+ }
603
+ }
604
+ class mr extends ze {
605
+ constructor() {
606
+ super(), this.loadTemplate(import("./python-CKuCd7tg.js"));
607
+ }
608
+ }
609
+ class vr extends ze {
610
+ constructor() {
611
+ super(), this.loadTemplate(import("./javascript-DK1c6Ap1.js"));
781
612
  }
782
613
  }
783
- const Oo = (n) => {
614
+ const gr = (n) => {
784
615
  n.allowMultipleConnections = !0;
785
616
  };
786
- class vn extends Tt {
617
+ class In extends Bt {
787
618
  order = /* @__PURE__ */ new Map();
788
619
  constructor(e) {
789
620
  super(e);
@@ -792,34 +623,32 @@ class vn extends Tt {
792
623
  super.start(), this.recalculateOrder = !0, this.calculateWithoutData();
793
624
  }
794
625
  async runGraph(e, t, s) {
795
- this.order.has(e.id) || this.order.set(e.id, Et(e));
796
- const { calculationOrder: o, connectionsFromNode: a } = this.order.get(e.id), i = /* @__PURE__ */ new Map();
797
- for (const r of o) {
798
- const c = {};
799
- Object.entries(r.inputs).forEach(([g, _]) => {
800
- c[g] = this.getInterfaceValue(t, _.id);
801
- }), r.isCodeNode && (r.updateCodeTemplate(), r.updateOutputNames()), this.events.beforeNodeCalculation.emit({ inputValues: c, node: r });
802
- let h;
803
- if (r.calculate) {
804
- if (h = await r.calculate(c, { globalValues: s, engine: this }), a.has(r))
805
- for (const [g, _] of Object.entries(h))
806
- this.hooks.transferData.execute(h[g], _), a.get(r).forEach((m) => {
807
- t.set(m.to.id, _);
808
- });
626
+ this.order.has(e.id) || this.order.set(e.id, Ht(e));
627
+ const { calculationOrder: o, connectionsFromNode: r } = this.order.get(e.id), i = /* @__PURE__ */ new Map();
628
+ for (const a of o) {
629
+ const l = {};
630
+ Object.entries(a.inputs).forEach(([f, C]) => {
631
+ l[f] = this.getInterfaceValue(t, C.id);
632
+ }), a.isCodeNode && (a.updateCodeTemplate(), a.updateOutputNames()), this.events.beforeNodeCalculation.emit({ inputValues: l, node: a });
633
+ let d;
634
+ if (a.calculate) {
635
+ if (d = await a.calculate(l, { globalValues: s, engine: this }), r.has(a))
636
+ for (const [f, C] of Object.entries(d))
637
+ this.hooks.transferData.execute(d[f], C), r.get(a).forEach((h) => t.set(h.to.id, C));
809
638
  } else {
810
- h = {};
811
- for (const [g, _] of Object.entries(r.outputs))
812
- h[g] = this.getInterfaceValue(t, _.id);
639
+ d = {};
640
+ for (const [f, C] of Object.entries(a.outputs))
641
+ d[f] = this.getInterfaceValue(t, C.id);
813
642
  }
814
- this.events.afterNodeCalculation.emit({ outputValues: h, node: r }), i.set(r.id, new Map(Object.entries(h))), a.has(r) && a.get(r).forEach((g) => {
815
- const _ = Object.entries(r.outputs).find(([, k]) => k.id === g.from.id)?.[0];
816
- if (!_)
643
+ this.events.afterNodeCalculation.emit({ outputValues: d, node: a }), i.set(a.id, new Map(Object.entries(d))), r.has(a) && r.get(a).forEach((f) => {
644
+ const C = Object.entries(a.outputs).find(([, N]) => N.id === f.from.id)?.[0];
645
+ if (!C)
817
646
  throw new Error(
818
- `Could not find key for interface ${g.from.id}
647
+ `Could not find key for interface ${f.from.id}
819
648
  This is likely an internal issue. Please report it on GitHub.`
820
649
  );
821
- const m = this.hooks.transferData.execute(h[_], g);
822
- g.to.allowMultipleConnections ? t.has(g.to.id) ? t.get(g.to.id).push(m) : t.set(g.to.id, [m]) : t.set(g.to.id, m);
650
+ const h = this.hooks.transferData.execute(d[C], f);
651
+ f.to.allowMultipleConnections ? t.has(f.to.id) ? t.get(f.to.id).push(h) : t.set(f.to.id, [h]) : t.set(f.to.id, h);
823
652
  });
824
653
  }
825
654
  return i;
@@ -851,7 +680,29 @@ This is likely an internal issue. Please report it on GitHub.`
851
680
  return e.get(t);
852
681
  }
853
682
  }
854
- const gn = {}, bn = {
683
+ const Nn = {}, En = {
684
+ xmlns: "http://www.w3.org/2000/svg",
685
+ width: "24",
686
+ height: "24",
687
+ viewBox: "0 0 24 24",
688
+ fill: "none",
689
+ stroke: "currentColor",
690
+ "stroke-width": "2",
691
+ "stroke-linecap": "round",
692
+ "stroke-linejoin": "round",
693
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-check"
694
+ };
695
+ function Tn(n, e) {
696
+ return p(), b("svg", En, [...e[0] || (e[0] = [
697
+ m("path", {
698
+ stroke: "none",
699
+ d: "M0 0h24v24H0z",
700
+ fill: "none"
701
+ }, null, -1),
702
+ m("path", { d: "M5 12l5 5l10 -10" }, null, -1)
703
+ ])]);
704
+ }
705
+ const On = /* @__PURE__ */ A(Nn, [["render", Tn]]), $n = {}, Mn = {
855
706
  xmlns: "http://www.w3.org/2000/svg",
856
707
  width: "24",
857
708
  height: "24",
@@ -863,17 +714,40 @@ const gn = {}, bn = {
863
714
  "stroke-linejoin": "round",
864
715
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-code-variable"
865
716
  };
866
- function _n(n, e) {
867
- return d(), p("svg", bn, [...e[0] || (e[0] = [
868
- u("path", {
717
+ function Sn(n, e) {
718
+ return p(), b("svg", Mn, [...e[0] || (e[0] = [
719
+ m("path", {
869
720
  stroke: "none",
870
721
  d: "M0 0h24v24H0z",
871
722
  fill: "none"
872
723
  }, null, -1),
873
- u("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)
724
+ m("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)
874
725
  ])]);
875
726
  }
876
- const yn = /* @__PURE__ */ P(gn, [["render", _n]]), Cn = {}, In = {
727
+ const Pn = /* @__PURE__ */ A($n, [["render", Sn]]), Gn = {}, An = {
728
+ xmlns: "http://www.w3.org/2000/svg",
729
+ width: "24",
730
+ height: "24",
731
+ viewBox: "0 0 24 24",
732
+ fill: "none",
733
+ stroke: "currentColor",
734
+ "stroke-width": "2",
735
+ "stroke-linecap": "round",
736
+ "stroke-linejoin": "round",
737
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-copy"
738
+ };
739
+ function Rn(n, e) {
740
+ return p(), b("svg", An, [...e[0] || (e[0] = [
741
+ m("path", {
742
+ stroke: "none",
743
+ d: "M0 0h24v24H0z",
744
+ fill: "none"
745
+ }, null, -1),
746
+ m("path", { d: "M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" }, null, -1),
747
+ m("path", { d: "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" }, null, -1)
748
+ ])]);
749
+ }
750
+ const jn = /* @__PURE__ */ A(Gn, [["render", Rn]]), Ln = {}, Vn = {
877
751
  xmlns: "http://www.w3.org/2000/svg",
878
752
  width: "24",
879
753
  height: "24",
@@ -885,19 +759,19 @@ const yn = /* @__PURE__ */ P(gn, [["render", _n]]), Cn = {}, In = {
885
759
  "stroke-linejoin": "round",
886
760
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-dots-vertical"
887
761
  };
888
- function wn(n, e) {
889
- return d(), p("svg", In, [...e[0] || (e[0] = [
890
- u("path", {
762
+ function Bn(n, e) {
763
+ return p(), b("svg", Vn, [...e[0] || (e[0] = [
764
+ m("path", {
891
765
  stroke: "none",
892
766
  d: "M0 0h24v24H0z",
893
767
  fill: "none"
894
768
  }, null, -1),
895
- u("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
896
- u("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
897
- u("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
769
+ m("path", { d: "M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
770
+ m("path", { d: "M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1),
771
+ m("path", { d: "M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0" }, null, -1)
898
772
  ])]);
899
773
  }
900
- const kn = /* @__PURE__ */ P(Cn, [["render", wn]]), Nn = {}, xn = {
774
+ const Hn = /* @__PURE__ */ A(Ln, [["render", Bn]]), zn = {}, Un = {
901
775
  xmlns: "http://www.w3.org/2000/svg",
902
776
  width: "24",
903
777
  height: "24",
@@ -905,17 +779,17 @@ const kn = /* @__PURE__ */ P(Cn, [["render", wn]]), Nn = {}, xn = {
905
779
  fill: "currentColor",
906
780
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-collapse"
907
781
  };
908
- function On(n, e) {
909
- return d(), p("svg", xn, [...e[0] || (e[0] = [
910
- u("path", {
782
+ function Dn(n, e) {
783
+ return p(), b("svg", Un, [...e[0] || (e[0] = [
784
+ m("path", {
911
785
  stroke: "none",
912
786
  d: "M0 0h24v24H0z",
913
787
  fill: "none"
914
788
  }, null, -1),
915
- u("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)
789
+ m("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)
916
790
  ])]);
917
791
  }
918
- const Tn = /* @__PURE__ */ P(Nn, [["render", On]]), En = {}, $n = {
792
+ const Fn = /* @__PURE__ */ A(zn, [["render", Dn]]), Wn = {}, Yn = {
919
793
  xmlns: "http://www.w3.org/2000/svg",
920
794
  width: "24",
921
795
  height: "24",
@@ -923,17 +797,17 @@ const Tn = /* @__PURE__ */ P(Nn, [["render", On]]), En = {}, $n = {
923
797
  fill: "currentColor",
924
798
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-left-expand"
925
799
  };
926
- function Mn(n, e) {
927
- return d(), p("svg", $n, [...e[0] || (e[0] = [
928
- u("path", {
800
+ function Xn(n, e) {
801
+ return p(), b("svg", Yn, [...e[0] || (e[0] = [
802
+ m("path", {
929
803
  stroke: "none",
930
804
  d: "M0 0h24v24H0z",
931
805
  fill: "none"
932
806
  }, null, -1),
933
- u("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)
807
+ m("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)
934
808
  ])]);
935
809
  }
936
- const Gn = /* @__PURE__ */ P(En, [["render", Mn]]), Sn = {}, Pn = {
810
+ const Kn = /* @__PURE__ */ A(Wn, [["render", Xn]]), qn = {}, Jn = {
937
811
  xmlns: "http://www.w3.org/2000/svg",
938
812
  width: "24",
939
813
  height: "24",
@@ -941,17 +815,17 @@ const Gn = /* @__PURE__ */ P(En, [["render", Mn]]), Sn = {}, Pn = {
941
815
  fill: "currentColor",
942
816
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right"
943
817
  };
944
- function Vn(n, e) {
945
- return d(), p("svg", Pn, [...e[0] || (e[0] = [
946
- u("path", {
818
+ function Qn(n, e) {
819
+ return p(), b("svg", Jn, [...e[0] || (e[0] = [
820
+ m("path", {
947
821
  stroke: "none",
948
822
  d: "M0 0h24v24H0z",
949
823
  fill: "none"
950
824
  }, null, -1),
951
- u("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)
825
+ m("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)
952
826
  ])]);
953
827
  }
954
- const Rn = /* @__PURE__ */ P(Sn, [["render", Vn]]), jn = {}, Bn = {
828
+ const Zn = /* @__PURE__ */ A(qn, [["render", Qn]]), eo = {}, to = {
955
829
  xmlns: "http://www.w3.org/2000/svg",
956
830
  width: "24",
957
831
  height: "24",
@@ -959,17 +833,17 @@ const Rn = /* @__PURE__ */ P(Sn, [["render", Vn]]), jn = {}, Bn = {
959
833
  fill: "currentColor",
960
834
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-collapse"
961
835
  };
962
- function zn(n, e) {
963
- return d(), p("svg", Bn, [...e[0] || (e[0] = [
964
- u("path", {
836
+ function no(n, e) {
837
+ return p(), b("svg", to, [...e[0] || (e[0] = [
838
+ m("path", {
965
839
  stroke: "none",
966
840
  d: "M0 0h24v24H0z",
967
841
  fill: "none"
968
842
  }, null, -1),
969
- u("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)
843
+ m("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)
970
844
  ])]);
971
845
  }
972
- const Hn = /* @__PURE__ */ P(jn, [["render", zn]]), Ln = {}, Un = {
846
+ const oo = /* @__PURE__ */ A(eo, [["render", no]]), so = {}, ro = {
973
847
  xmlns: "http://www.w3.org/2000/svg",
974
848
  width: "24",
975
849
  height: "24",
@@ -977,17 +851,17 @@ const Hn = /* @__PURE__ */ P(jn, [["render", zn]]), Ln = {}, Un = {
977
851
  fill: "currentColor",
978
852
  class: "baklava-icon icon icon-tabler icons-tabler-filled icon-tabler-layout-sidebar-right-expand"
979
853
  };
980
- function An(n, e) {
981
- return d(), p("svg", Un, [...e[0] || (e[0] = [
982
- u("path", {
854
+ function ao(n, e) {
855
+ return p(), b("svg", ro, [...e[0] || (e[0] = [
856
+ m("path", {
983
857
  stroke: "none",
984
858
  d: "M0 0h24v24H0z",
985
859
  fill: "none"
986
860
  }, null, -1),
987
- u("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)
861
+ m("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)
988
862
  ])]);
989
863
  }
990
- const Dn = /* @__PURE__ */ P(Ln, [["render", An]]), Fn = {}, Wn = {
864
+ const io = /* @__PURE__ */ A(so, [["render", ao]]), lo = {}, uo = {
991
865
  xmlns: "http://www.w3.org/2000/svg",
992
866
  width: "24",
993
867
  height: "24",
@@ -999,12 +873,12 @@ const Dn = /* @__PURE__ */ P(Ln, [["render", An]]), Fn = {}, Wn = {
999
873
  "stroke-linejoin": "round",
1000
874
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-lock-code"
1001
875
  };
1002
- function Yn(n, e) {
1003
- return d(), p("svg", Wn, [...e[0] || (e[0] = [
1004
- se('<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)
876
+ function co(n, e) {
877
+ return p(), b("svg", uo, [...e[0] || (e[0] = [
878
+ fe('<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)
1005
879
  ])]);
1006
880
  }
1007
- const Kn = /* @__PURE__ */ P(Fn, [["render", Yn]]), Xn = {}, qn = {
881
+ const ht = /* @__PURE__ */ A(lo, [["render", co]]), po = {}, ho = {
1008
882
  xmlns: "http://www.w3.org/2000/svg",
1009
883
  width: "24",
1010
884
  height: "24",
@@ -1016,17 +890,40 @@ const Kn = /* @__PURE__ */ P(Fn, [["render", Yn]]), Xn = {}, qn = {
1016
890
  "stroke-linejoin": "round",
1017
891
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-player-play"
1018
892
  };
1019
- function Jn(n, e) {
1020
- return d(), p("svg", qn, [...e[0] || (e[0] = [
1021
- u("path", {
893
+ function fo(n, e) {
894
+ return p(), b("svg", ho, [...e[0] || (e[0] = [
895
+ m("path", {
1022
896
  stroke: "none",
1023
897
  d: "M0 0h24v24H0z",
1024
898
  fill: "none"
1025
899
  }, null, -1),
1026
- u("path", { d: "M7 4v16l13 -8z" }, null, -1)
900
+ m("path", { d: "M7 4v16l13 -8z" }, null, -1)
1027
901
  ])]);
1028
902
  }
1029
- const Qn = /* @__PURE__ */ P(Xn, [["render", Jn]]), Zn = {}, es = {
903
+ const mo = /* @__PURE__ */ A(po, [["render", fo]]), vo = {}, go = {
904
+ xmlns: "http://www.w3.org/2000/svg",
905
+ width: "24",
906
+ height: "24",
907
+ viewBox: "0 0 24 24",
908
+ fill: "none",
909
+ stroke: "currentColor",
910
+ "stroke-width": "2",
911
+ "stroke-linecap": "round",
912
+ "stroke-linejoin": "round",
913
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-plus"
914
+ };
915
+ function bo(n, e) {
916
+ return p(), b("svg", go, [...e[0] || (e[0] = [
917
+ m("path", {
918
+ stroke: "none",
919
+ d: "M0 0h24v24H0z",
920
+ fill: "none"
921
+ }, null, -1),
922
+ m("path", { d: "M12 5l0 14" }, null, -1),
923
+ m("path", { d: "M5 12l14 0" }, null, -1)
924
+ ])]);
925
+ }
926
+ const yo = /* @__PURE__ */ A(vo, [["render", bo]]), _o = {}, Co = {
1030
927
  xmlns: "http://www.w3.org/2000/svg",
1031
928
  width: "24",
1032
929
  height: "24",
@@ -1038,12 +935,12 @@ const Qn = /* @__PURE__ */ P(Xn, [["render", Jn]]), Zn = {}, es = {
1038
935
  "stroke-linejoin": "round",
1039
936
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema"
1040
937
  };
1041
- function ts(n, e) {
1042
- return d(), p("svg", es, [...e[0] || (e[0] = [
1043
- se('<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)
938
+ function wo(n, e) {
939
+ return p(), b("svg", Co, [...e[0] || (e[0] = [
940
+ fe('<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)
1044
941
  ])]);
1045
942
  }
1046
- const ns = /* @__PURE__ */ P(Zn, [["render", ts]]), ss = {}, os = {
943
+ const ko = /* @__PURE__ */ A(_o, [["render", wo]]), xo = {}, Io = {
1047
944
  xmlns: "http://www.w3.org/2000/svg",
1048
945
  width: "24",
1049
946
  height: "24",
@@ -1055,12 +952,12 @@ const ns = /* @__PURE__ */ P(Zn, [["render", ts]]), ss = {}, os = {
1055
952
  "stroke-linejoin": "round",
1056
953
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-schema-off"
1057
954
  };
1058
- function as(n, e) {
1059
- return d(), p("svg", os, [...e[0] || (e[0] = [
1060
- se('<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)
955
+ function No(n, e) {
956
+ return p(), b("svg", Io, [...e[0] || (e[0] = [
957
+ fe('<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)
1061
958
  ])]);
1062
959
  }
1063
- const is = /* @__PURE__ */ P(ss, [["render", as]]), rs = {}, ds = {
960
+ const Eo = /* @__PURE__ */ A(xo, [["render", No]]), To = {}, Oo = {
1064
961
  xmlns: "http://www.w3.org/2000/svg",
1065
962
  width: "24",
1066
963
  height: "24",
@@ -1072,12 +969,12 @@ const is = /* @__PURE__ */ P(ss, [["render", as]]), rs = {}, ds = {
1072
969
  "stroke-linejoin": "round",
1073
970
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-transition-bottom"
1074
971
  };
1075
- function ls(n, e) {
1076
- return d(), p("svg", ds, [...e[0] || (e[0] = [
1077
- se('<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)
972
+ function $o(n, e) {
973
+ return p(), b("svg", Oo, [...e[0] || (e[0] = [
974
+ fe('<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)
1078
975
  ])]);
1079
976
  }
1080
- const us = /* @__PURE__ */ P(rs, [["render", ls]]), cs = {}, ps = {
977
+ const Mo = /* @__PURE__ */ A(To, [["render", $o]]), So = {}, Po = {
1081
978
  xmlns: "http://www.w3.org/2000/svg",
1082
979
  width: "24",
1083
980
  height: "24",
@@ -1089,60 +986,83 @@ const us = /* @__PURE__ */ P(rs, [["render", ls]]), cs = {}, ps = {
1089
986
  "stroke-linejoin": "round",
1090
987
  class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-trash-off"
1091
988
  };
1092
- function hs(n, e) {
1093
- return d(), p("svg", ps, [...e[0] || (e[0] = [
1094
- se('<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)
989
+ function Go(n, e) {
990
+ return p(), b("svg", Po, [...e[0] || (e[0] = [
991
+ fe('<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)
1095
992
  ])]);
1096
993
  }
1097
- const ms = /* @__PURE__ */ P(cs, [["render", hs]]), et = "CLEAR_ALL", tt = "RUN_ENGINE", nt = "TOGGLE_MINIMAP", st = "TOGGLE_PALETTE", fs = (n, e, t) => {
994
+ const Ao = /* @__PURE__ */ A(So, [["render", Go]]), Ro = {}, jo = {
995
+ xmlns: "http://www.w3.org/2000/svg",
996
+ width: "24",
997
+ height: "24",
998
+ viewBox: "0 0 24 24",
999
+ fill: "none",
1000
+ stroke: "currentColor",
1001
+ "stroke-width": "2",
1002
+ "stroke-linecap": "round",
1003
+ "stroke-linejoin": "round",
1004
+ class: "baklava-icon icon icon-tabler icons-tabler-outline icon-tabler-x"
1005
+ };
1006
+ function Lo(n, e) {
1007
+ return p(), b("svg", jo, [...e[0] || (e[0] = [
1008
+ m("path", {
1009
+ stroke: "none",
1010
+ d: "M0 0h24v24H0z",
1011
+ fill: "none"
1012
+ }, null, -1),
1013
+ m("path", { d: "M18 6l-12 12" }, null, -1),
1014
+ m("path", { d: "M6 6l12 12" }, null, -1)
1015
+ ])]);
1016
+ }
1017
+ const Vo = /* @__PURE__ */ A(Ro, [["render", Lo]]), ft = "CLEAR_ALL", mt = "RUN_ENGINE", vt = "TOGGLE_MINIMAP", gt = "TOGGLE_PALETTE", Bo = (n, e, t) => {
1098
1018
  const s = t.zoomToFit.paddingLeft;
1099
- e.registerCommand(st, {
1019
+ e.registerCommand(gt, {
1100
1020
  execute: () => {
1101
1021
  t.palette.enabled = !t.palette.enabled, t.zoomToFit.paddingLeft = t.palette.enabled ? s : 50;
1102
1022
  },
1103
1023
  canExecute: () => !0
1104
- }), e.registerCommand(et, {
1024
+ }), e.registerCommand(ft, {
1105
1025
  execute: () => n.value.clear(),
1106
1026
  canExecute: () => n.value.nodes.length > 0
1107
- }), e.registerCommand(nt, {
1027
+ }), e.registerCommand(vt, {
1108
1028
  execute: () => t.enableMinimap = !t.enableMinimap,
1109
1029
  canExecute: () => n.value.nodes.length > 1
1110
1030
  });
1111
- }, vs = (n) => {
1031
+ }, Ho = (n) => {
1112
1032
  const e = {
1113
- command: tt,
1033
+ command: mt,
1114
1034
  title: "Run",
1115
1035
  // Tooltip text
1116
- icon: O(() => Qn)
1036
+ icon: P(() => mo)
1117
1037
  }, t = {
1118
- command: st,
1038
+ command: gt,
1119
1039
  title: "Toggle palette",
1120
1040
  // Tooltip text
1121
- icon: O(() => n.palette.enabled ? Tn : Gn)
1041
+ icon: P(() => n.palette.enabled ? Fn : Kn)
1122
1042
  }, s = {
1123
- command: et,
1043
+ command: ft,
1124
1044
  title: "Clear all",
1125
1045
  // Tooltip text
1126
- icon: O(() => ms)
1046
+ icon: P(() => Ao)
1127
1047
  }, o = {
1128
- command: nt,
1048
+ command: vt,
1129
1049
  title: "Toggle minimap",
1130
1050
  // Tooltip text
1131
- icon: O(() => n.enableMinimap ? is : ns)
1051
+ icon: P(() => n.enableMinimap ? Eo : ko)
1132
1052
  };
1133
- n.toolbar.commands = [t, e, ...jt, s, o];
1134
- }, gs = (n, e) => {
1135
- e.registerCommand(tt, {
1053
+ n.toolbar.commands = [t, e, ...Kt, s, o];
1054
+ }, zo = (n, e) => {
1055
+ e.registerCommand(mt, {
1136
1056
  execute: () => n.runOnce(null),
1137
1057
  canExecute: () => !0
1138
1058
  });
1139
1059
  };
1140
- function bs(n) {
1060
+ function Uo(n) {
1141
1061
  const e = Symbol("CodeEngineToken");
1142
- n.engine = new vn(n.editor), gs(n.engine, n.commandHandler), n.loadEditor = (t) => {
1143
- n.engine?.pause(), n.displayedGraph.clear(), n.editor.load(t), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.engine?.resume(), n.engine?.runOnce(null);
1062
+ n.engine = new In(n.editor), zo(n.engine, n.commandHandler), n.loadEditor = (t) => {
1063
+ n.engine?.pause(), n.displayedGraph.clear(), n.editor.load(t), n.commandHandler.executeCommand(ue.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(ue.CLEAR_HISTORY_COMMAND), n.engine?.resume(), n.engine?.runOnce(null);
1144
1064
  }, n.newGraph = () => {
1145
- n.engine?.pause(), n.displayedGraph.clear(), n.commandHandler.executeCommand(q.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(q.CLEAR_HISTORY_COMMAND), n.displayedGraph.id = K(), n.engine?.resume(), n.engine?.runOnce(null);
1065
+ n.engine?.pause(), n.displayedGraph.clear(), n.commandHandler.executeCommand(ue.CLEAR_CLIPBOARD_COMMAND), n.commandHandler.executeCommand(ue.CLEAR_HISTORY_COMMAND), n.displayedGraph.id = re(), n.engine?.resume(), n.engine?.runOnce(null);
1146
1066
  }, n.subscribe = () => {
1147
1067
  n.displayedGraph.events.addConnection.subscribe(e, (t) => {
1148
1068
  const s = n.displayedGraph.findNodeById(t.to.nodeId);
@@ -1157,7 +1077,7 @@ function bs(n) {
1157
1077
  }), n.engine?.events.beforeRun.subscribe(e, () => {
1158
1078
  n.engine?.pause(), n.displayedGraph.sortNodes(), n.engine?.resume();
1159
1079
  }), n.engine?.events.afterRun.subscribe(e, (t) => {
1160
- n.engine?.pause(), Ae(t, n.editor), n.code.state.lockCode || n.code.renderCode({
1080
+ n.engine?.pause(), rt(t, n.editor), n.code.state.lockCode || n.code.renderCode({
1161
1081
  nodes: n.editor.graph.scriptedCodeNodes,
1162
1082
  modules: n.editor.code.modules
1163
1083
  }), n.engine?.resume();
@@ -1166,10 +1086,10 @@ function bs(n) {
1166
1086
  n.displayedGraph.events.addConnection.unsubscribe(e), n.displayedGraph.events.removeConnection.unsubscribe(e), n.engine?.events.beforeRun.unsubscribe(e), n.engine?.events.afterRun.unsubscribe(e);
1167
1087
  };
1168
1088
  }
1169
- class ue extends Ct {
1089
+ class Ie extends Pt {
1170
1090
  code = null;
1171
1091
  editor;
1172
- _state = D({
1092
+ _state = te({
1173
1093
  codeTemplate: "{{ #nodes }}{{ script }}{{ /nodes }}",
1174
1094
  lockCode: !1
1175
1095
  });
@@ -1177,7 +1097,7 @@ class ue extends Ct {
1177
1097
  super(e, t), this.editor = e, this.template = t, e.code && (this.code = e.code);
1178
1098
  }
1179
1099
  get codeNodes() {
1180
- return ot(this);
1100
+ return bt(this);
1181
1101
  }
1182
1102
  get connections() {
1183
1103
  return super.connections;
@@ -1206,15 +1126,14 @@ class ue extends Ct {
1206
1126
  get visibleNodes() {
1207
1127
  return this.nodes.filter((e) => !e.state?.hidden);
1208
1128
  }
1209
- // /**
1210
- // * Add code node to graph.
1211
- // * @param node code node
1212
- // * @param props optional
1213
- // */
1214
- // public override addNode(node: AbstractCodeNode, props?: unknown): AbstractCodeNode | undefined {
1215
- // if (node.state && props) node.state.props = props;
1216
- // return super.addNode(node as AbstractNode) as AbstractCodeNode;
1217
- // }
1129
+ /**
1130
+ * Add code node to graph.
1131
+ * @param node code node
1132
+ * @param props optional
1133
+ */
1134
+ addNode(e, t) {
1135
+ return e.state && t && (e.state.props = t), super.addNode(e);
1136
+ }
1218
1137
  /**
1219
1138
  * Add code node at coordinates.
1220
1139
  * @param node code node
@@ -1278,7 +1197,7 @@ class ue extends Ct {
1278
1197
  * Render code script.
1279
1198
  */
1280
1199
  renderCode(e) {
1281
- return Z.render(this.state?.codeTemplate || "", e);
1200
+ return ce.render(this.state?.codeTemplate || "", e);
1282
1201
  }
1283
1202
  /**
1284
1203
  * Sort code nodes.
@@ -1288,40 +1207,212 @@ class ue extends Ct {
1288
1207
  try {
1289
1208
  let e = this.nodeIds;
1290
1209
  const t = this.connections.filter(
1291
- (a) => e.includes(a.to.nodeId) && e.includes(a.from.nodeId)
1292
- ).map((a) => [a.to.nodeId, a.from.nodeId]);
1293
- e.reverse(), e = Qt.array(e, t), e.reverse();
1294
- const s = this.nodes.map((a) => a.id).filter((a) => !e.includes(a));
1210
+ (r) => e.includes(r.to.nodeId) && e.includes(r.from.nodeId)
1211
+ ).map((r) => [r.to.nodeId, r.from.nodeId]);
1212
+ e.reverse(), e = cn.array(e, t), e.reverse();
1213
+ const s = this.nodes.map((r) => r.id).filter((r) => !e.includes(r));
1295
1214
  e = [...e, ...s];
1296
- const o = e.map((a) => this.findNodeById(a));
1215
+ const o = e.map((r) => this.findNodeById(r));
1297
1216
  o && (this.nodes = o);
1298
1217
  } catch {
1299
1218
  console.warn("Failed to sort nodes.");
1300
1219
  }
1301
1220
  }
1302
1221
  }
1303
- const ot = (n) => {
1222
+ const bt = (n) => {
1304
1223
  const e = [];
1305
1224
  return n.nodes.length === 0 || n.nodes.forEach((t) => {
1306
- t && (t.hasOwnProperty("subgraph") ? e.push(...ot(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
1225
+ t && (t.hasOwnProperty("subgraph") ? e.push(...bt(t.subgraph)) : t.hasOwnProperty("isCodeNode") && e.push(t));
1307
1226
  }), e;
1308
- }, To = (n = 0, e = 100) => ({
1227
+ }, br = (n = 0, e = 100) => ({
1309
1228
  x: n * 420,
1310
1229
  y: e
1311
- }), Eo = (n) => {
1230
+ }), yr = (n) => {
1312
1231
  const e = { ...n.position };
1313
1232
  return e.x -= 440, e.y += 50, e;
1314
- };
1315
- function _s(n, e) {
1233
+ }, We = "__baklava_SubgraphInputNode", Ye = "__baklava_SubgraphOutputNode";
1234
+ class yt extends Re {
1235
+ graphInterfaceId;
1236
+ constructor() {
1237
+ super(), this.graphInterfaceId = re();
1238
+ }
1239
+ onPlaced() {
1240
+ super.onPlaced(), this.initializeIo();
1241
+ }
1242
+ load(e) {
1243
+ super.load(e), this.graphInterfaceId = e.graphInterfaceId;
1244
+ }
1245
+ save() {
1246
+ return {
1247
+ ...super.save(),
1248
+ graphInterfaceId: this.graphInterfaceId
1249
+ };
1250
+ }
1251
+ update() {
1252
+ }
1253
+ }
1254
+ class _t extends yt {
1255
+ static isGraphInputNode(e) {
1256
+ return e.type === We;
1257
+ }
1258
+ type = We;
1259
+ inputs = {
1260
+ name: new J("Name", "Input")
1261
+ };
1262
+ outputs = {
1263
+ placeholder: new J("Value", void 0)
1264
+ };
1265
+ }
1266
+ class Ct extends yt {
1267
+ static isGraphOutputNode(e) {
1268
+ return e.type === Ye;
1269
+ }
1270
+ type = Ye;
1271
+ inputs = {
1272
+ name: new J("Name", "Output"),
1273
+ placeholder: new J("Value", void 0)
1274
+ };
1275
+ outputs = {
1276
+ output: new J("Output", void 0).setHidden(!0)
1277
+ };
1278
+ calculate = ({ placeholder: e }) => ({
1279
+ output: e
1280
+ });
1281
+ }
1282
+ const Do = [
1283
+ "component",
1284
+ "connectionCount",
1285
+ "events",
1286
+ "hidden",
1287
+ "hooks",
1288
+ "id",
1289
+ "isCodeNode",
1290
+ "isInput",
1291
+ "name",
1292
+ "nodeId",
1293
+ "port",
1294
+ "templateId",
1295
+ "value"
1296
+ ];
1297
+ function Fo(n) {
1298
+ return class extends lt {
1299
+ type = st(n);
1300
+ get title() {
1301
+ return this._title;
1302
+ }
1303
+ set title(t) {
1304
+ this.template.name = t;
1305
+ }
1306
+ inputs = {};
1307
+ outputs = {};
1308
+ template = n;
1309
+ subgraph;
1310
+ update() {
1311
+ }
1312
+ onConnected() {
1313
+ }
1314
+ onUnconnected() {
1315
+ }
1316
+ calculate = async (t, s) => {
1317
+ if (!this.subgraph) throw new Error(`GraphNode ${this.id}: calculate called without subgraph being initialized`);
1318
+ if (!s.engine || typeof s.engine != "object")
1319
+ throw new Error(`GraphNode ${this.id}: calculate called but no engine provided in context`);
1320
+ const o = s.engine.getInputValues(this.subgraph);
1321
+ for (const a of this.subgraph.inputs)
1322
+ o.set(a.nodeInterfaceId, t[a.id]);
1323
+ const r = await s.engine.runGraph(
1324
+ this.subgraph,
1325
+ o,
1326
+ s.globalValues
1327
+ );
1328
+ s.engine.pause(), rt(r, s.engine.editor), s.engine.resume();
1329
+ const i = {};
1330
+ for (const a of this.subgraph.outputs)
1331
+ i[a.id] = r.get(a.nodeId)?.get("output");
1332
+ return i._calculationResults = r, this.lockCode || (i._code = this.renderCode({ inputs: t, ...s.globalValues })), this.updateOutputValues(i), i;
1333
+ };
1334
+ load(t) {
1335
+ if (!this.subgraph) throw new Error("Cannot load a graph node without a graph");
1336
+ if (!this.template) throw new Error("Unable to load graph node without graph template");
1337
+ this.subgraph.load(t.graphState), super.load(t);
1338
+ }
1339
+ save() {
1340
+ if (!this.subgraph) throw new Error("Cannot save a graph node without a graph");
1341
+ return {
1342
+ ...super.save(),
1343
+ graphState: this.subgraph.save()
1344
+ };
1345
+ }
1346
+ onPlaced() {
1347
+ this.template.events.updated.subscribe(this, () => this.initialize()), this.template.events.nameChanged.subscribe(this, (t) => {
1348
+ this._title = t;
1349
+ }), this.initialize();
1350
+ }
1351
+ onDestroy() {
1352
+ this.template.events.updated.unsubscribe(this), this.template.events.nameChanged.unsubscribe(this), this.subgraph?.destroy();
1353
+ }
1354
+ initialize() {
1355
+ this.subgraph && this.subgraph.destroy(), this.subgraph = this.template.createGraph(), this._title = this.template.name, this.updateInterfaces(), this.state.codeTemplate = `{{ #nodes }}{{ script }}
1356
+ {{ /nodes }}`, this.events.update.emit(null);
1357
+ }
1358
+ /**
1359
+ * Render code of this node.
1360
+ */
1361
+ renderCode(t) {
1362
+ return this.subgraph ? this.subgraph.renderCode({ nodes: this.subgraph.scriptedCodeNodes }) : ce.render(this.state.codeTemplate, t);
1363
+ }
1364
+ updateInterfaces() {
1365
+ if (!this.subgraph) throw new Error("Trying to update interfaces without graph instance");
1366
+ for (const t of this.subgraph.inputs)
1367
+ t.id in this.inputs ? this.inputs[t.id].name = t.name : this.addInput(t.id, this.createProxyInterface(t, !0));
1368
+ for (const t of Object.keys(this.inputs))
1369
+ this.subgraph.inputs.some((s) => s.id === t) || this.removeInput(t);
1370
+ for (const t of this.subgraph.outputs)
1371
+ t.id in this.outputs ? this.outputs[t.id].name = t.name : this.addOutput(t.id, this.createProxyInterface(t, !1));
1372
+ for (const t of Object.keys(this.outputs))
1373
+ this.subgraph.outputs.some((s) => s.id === t) || this.removeOutput(t);
1374
+ this.addInput(
1375
+ "_code",
1376
+ new D("", []).use(V, X).use(de).setHidden(!0)
1377
+ ), this.addOutput(
1378
+ "_code",
1379
+ new D("", []).use(V, X).use(de).setHidden(!0)
1380
+ ), this.addOutput("_calculationResults", new J("_calculationResults", void 0).setHidden(!0));
1381
+ }
1382
+ /**
1383
+ * When we create a interface in the graph node, we hide certain properties of the interface in the subgraph.
1384
+ * For example, the `type` property or the `allowMultipleConnections` property.
1385
+ * These properties should be proxied to the subgraph interface, so they behave the same as the original interface.
1386
+ */
1387
+ createProxyInterface(t, s) {
1388
+ const o = new D(t.name, void 0);
1389
+ return new Proxy(o, {
1390
+ get: (r, i) => {
1391
+ if (Do.includes(i) || i in r || typeof i == "string" && i.startsWith("__v_"))
1392
+ return Reflect.get(r, i);
1393
+ let a;
1394
+ s ? a = this.subgraph?.nodes.find(
1395
+ (C) => _t.isGraphInputNode(C) && C.graphInterfaceId === t.id
1396
+ )?.outputs.placeholder.id : a = this.subgraph?.nodes.find(
1397
+ (C) => Ct.isGraphOutputNode(C) && C.graphInterfaceId === t.id
1398
+ )?.inputs.placeholder.id;
1399
+ const l = this.subgraph?.connections.find((f) => a === (s ? f.from : f.to)?.id), d = s ? l?.to : l?.from;
1400
+ if (d) return Reflect.get(d, i);
1401
+ }
1402
+ });
1403
+ }
1404
+ };
1405
+ }
1406
+ function Wo(n, e) {
1316
1407
  return Object.fromEntries(Object.entries(n).filter(e));
1317
1408
  }
1318
- function ys(n, e) {
1409
+ function Yo(n, e) {
1319
1410
  return Object.fromEntries(Object.entries(n).map(([t, s]) => [t, e(s)]));
1320
1411
  }
1321
- class ce extends It {
1412
+ class Ne extends Gt {
1322
1413
  /** Create a new GraphTemplate from the nodes and connections inside the graph instance */
1323
1414
  static fromGraph(e, t) {
1324
- return new ce(e.save(), t);
1415
+ return new Ne(e.save(), t);
1325
1416
  }
1326
1417
  constructor(e, t) {
1327
1418
  super(e, t);
@@ -1334,52 +1425,52 @@ class ce extends It {
1334
1425
  * or load the state into the provided graph instance.
1335
1426
  */
1336
1427
  createGraph(e) {
1337
- const t = /* @__PURE__ */ new Map(), s = (m) => {
1338
- const k = K();
1339
- return t.set(m, k), k;
1340
- }, o = (m) => {
1341
- const k = t.get(m);
1342
- if (!k) throw new Error(`Unable to create graph from template: Could not map old id ${m} to new id`);
1343
- return k;
1344
- }, a = (m) => ys(m, (k) => ({
1345
- id: s(k.id),
1346
- templateId: k.id,
1347
- value: k.value
1348
- })), i = this.nodes.map((m) => ({
1349
- ...m,
1350
- id: s(m.id),
1351
- inputs: a(m.inputs),
1352
- outputs: a(m.outputs)
1353
- })), r = this.connections.map((m) => ({
1354
- id: s(m.id),
1355
- from: o(m.from),
1356
- to: o(m.to)
1357
- })), c = this.inputs.map((m) => ({
1358
- id: m.id,
1359
- name: m.name,
1360
- nodeId: o(m.nodeId),
1361
- nodeInterfaceId: o(m.nodeInterfaceId)
1362
- })), h = this.outputs.map((m) => ({
1363
- id: m.id,
1364
- name: m.name,
1365
- nodeId: o(m.nodeId),
1366
- nodeInterfaceId: o(m.nodeInterfaceId)
1367
- })), g = {
1368
- id: K(),
1428
+ const t = /* @__PURE__ */ new Map(), s = (h) => {
1429
+ const N = re();
1430
+ return t.set(h, N), N;
1431
+ }, o = (h) => {
1432
+ const N = t.get(h);
1433
+ if (!N) throw new Error(`Unable to create graph from template: Could not map old id ${h} to new id`);
1434
+ return N;
1435
+ }, r = (h) => Yo(h, (N) => ({
1436
+ id: s(N.id),
1437
+ templateId: N.id,
1438
+ value: N.value
1439
+ })), i = this.nodes.map((h) => ({
1440
+ ...h,
1441
+ id: s(h.id),
1442
+ inputs: r(h.inputs),
1443
+ outputs: r(h.outputs)
1444
+ })), a = this.connections.map((h) => ({
1445
+ id: s(h.id),
1446
+ from: o(h.from),
1447
+ to: o(h.to)
1448
+ })), l = this.inputs.map((h) => ({
1449
+ id: h.id,
1450
+ name: h.name,
1451
+ nodeId: o(h.nodeId),
1452
+ nodeInterfaceId: o(h.nodeInterfaceId)
1453
+ })), d = this.outputs.map((h) => ({
1454
+ id: h.id,
1455
+ name: h.name,
1456
+ nodeId: o(h.nodeId),
1457
+ nodeInterfaceId: o(h.nodeInterfaceId)
1458
+ })), f = {
1459
+ id: re(),
1369
1460
  nodes: i,
1370
- connections: r,
1371
- inputs: c,
1372
- outputs: h
1461
+ connections: a,
1462
+ inputs: l,
1463
+ outputs: d
1373
1464
  };
1374
- return e || (e = new ue(this.editor)), e.load(g).forEach((m) => console.warn(m)), e.template = this, e;
1465
+ return e || (e = new Ie(this.editor)), e.load(f).forEach((h) => console.warn(h)), e.template = this, e;
1375
1466
  }
1376
1467
  }
1377
- const Cs = (n) => !(n instanceof ue);
1378
- function Is(n, e) {
1468
+ const Xo = (n) => !(n instanceof Ie);
1469
+ function Ko(n, e) {
1379
1470
  return { switchGraph: (s) => {
1380
1471
  let o;
1381
- if (Cs(s))
1382
- o = new ue(n.value), s.createGraph(o);
1472
+ if (Xo(s))
1473
+ o = new Ie(n.value), s.createGraph(o);
1383
1474
  else {
1384
1475
  if (s !== n.value.graph)
1385
1476
  throw new Error(
@@ -1390,32 +1481,601 @@ function Is(n, e) {
1390
1481
  e.value && e.value !== n.value.graph && e.value.destroy(), o.panning = o.panning ?? s.panning ?? { x: 0, y: 0 }, o.scaling = o.scaling ?? s.scaling ?? 1, o.selectedNodes = o.selectedNodes ?? [], o.sidebar = o.sidebar ?? { visible: !1, nodeId: "", optionName: "" }, e.value = o, o.code?.engine?.runOnce(null);
1391
1482
  } };
1392
1483
  }
1393
- const $o = /* @__PURE__ */ F({
1484
+ function qo(n) {
1485
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
1486
+ }
1487
+ var we = { exports: {} };
1488
+ var Jo = we.exports, Xe;
1489
+ function Qo() {
1490
+ return Xe || (Xe = 1, (function(n, e) {
1491
+ (function(s, o) {
1492
+ n.exports = o();
1493
+ })(Jo, function() {
1494
+ return (
1495
+ /******/
1496
+ (function() {
1497
+ var t = {
1498
+ /***/
1499
+ 686: (
1500
+ /***/
1501
+ (function(r, i, a) {
1502
+ a.d(i, {
1503
+ default: function() {
1504
+ return (
1505
+ /* binding */
1506
+ $
1507
+ );
1508
+ }
1509
+ });
1510
+ var l = a(279), d = /* @__PURE__ */ a.n(l), f = a(370), C = /* @__PURE__ */ a.n(f), h = a(817), N = /* @__PURE__ */ a.n(h);
1511
+ function v(g) {
1512
+ try {
1513
+ return document.execCommand(g);
1514
+ } catch {
1515
+ return !1;
1516
+ }
1517
+ }
1518
+ var w = function(c) {
1519
+ var _ = N()(c);
1520
+ return v("cut"), _;
1521
+ }, u = w;
1522
+ function y(g) {
1523
+ var c = document.documentElement.getAttribute("dir") === "rtl", _ = document.createElement("textarea");
1524
+ _.style.fontSize = "12pt", _.style.border = "0", _.style.padding = "0", _.style.margin = "0", _.style.position = "absolute", _.style[c ? "right" : "left"] = "-9999px";
1525
+ var x = window.pageYOffset || document.documentElement.scrollTop;
1526
+ return _.style.top = "".concat(x, "px"), _.setAttribute("readonly", ""), _.value = g, _;
1527
+ }
1528
+ var M = function(c, _) {
1529
+ var x = y(c);
1530
+ _.container.appendChild(x);
1531
+ var I = N()(x);
1532
+ return v("copy"), x.remove(), I;
1533
+ }, T = function(c) {
1534
+ var _ = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1535
+ container: document.body
1536
+ }, x = "";
1537
+ return typeof c == "string" ? x = M(c, _) : c instanceof HTMLInputElement && !["text", "search", "url", "tel", "password"].includes(c?.type) ? x = M(c.value, _) : (x = N()(c), v("copy")), x;
1538
+ }, S = T;
1539
+ function Q(g) {
1540
+ "@babel/helpers - typeof";
1541
+ return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Q = function(_) {
1542
+ return typeof _;
1543
+ } : Q = function(_) {
1544
+ return _ && typeof Symbol == "function" && _.constructor === Symbol && _ !== Symbol.prototype ? "symbol" : typeof _;
1545
+ }, Q(g);
1546
+ }
1547
+ var Z = function() {
1548
+ var c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ = c.action, x = _ === void 0 ? "copy" : _, I = c.container, E = c.target, Y = c.text;
1549
+ if (x !== "copy" && x !== "cut")
1550
+ throw new Error('Invalid "action" value, use either "copy" or "cut"');
1551
+ if (E !== void 0)
1552
+ if (E && Q(E) === "object" && E.nodeType === 1) {
1553
+ if (x === "copy" && E.hasAttribute("disabled"))
1554
+ throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
1555
+ if (x === "cut" && (E.hasAttribute("readonly") || E.hasAttribute("disabled")))
1556
+ throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`);
1557
+ } else
1558
+ throw new Error('Invalid "target" value, use a valid Element');
1559
+ if (Y)
1560
+ return S(Y, {
1561
+ container: I
1562
+ });
1563
+ if (E)
1564
+ return x === "cut" ? u(E) : S(E, {
1565
+ container: I
1566
+ });
1567
+ }, pe = Z;
1568
+ function K(g) {
1569
+ "@babel/helpers - typeof";
1570
+ return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? K = function(_) {
1571
+ return typeof _;
1572
+ } : K = function(_) {
1573
+ return _ && typeof Symbol == "function" && _.constructor === Symbol && _ !== Symbol.prototype ? "symbol" : typeof _;
1574
+ }, K(g);
1575
+ }
1576
+ function k(g, c) {
1577
+ if (!(g instanceof c))
1578
+ throw new TypeError("Cannot call a class as a function");
1579
+ }
1580
+ function R(g, c) {
1581
+ for (var _ = 0; _ < c.length; _++) {
1582
+ var x = c[_];
1583
+ x.enumerable = x.enumerable || !1, x.configurable = !0, "value" in x && (x.writable = !0), Object.defineProperty(g, x.key, x);
1584
+ }
1585
+ }
1586
+ function z(g, c, _) {
1587
+ return c && R(g.prototype, c), _ && R(g, _), g;
1588
+ }
1589
+ function ge(g, c) {
1590
+ if (typeof c != "function" && c !== null)
1591
+ throw new TypeError("Super expression must either be null or a function");
1592
+ g.prototype = Object.create(c && c.prototype, { constructor: { value: g, writable: !0, configurable: !0 } }), c && he(g, c);
1593
+ }
1594
+ function he(g, c) {
1595
+ return he = Object.setPrototypeOf || function(x, I) {
1596
+ return x.__proto__ = I, x;
1597
+ }, he(g, c);
1598
+ }
1599
+ function Ee(g) {
1600
+ var c = Te();
1601
+ return function() {
1602
+ var x = oe(g), I;
1603
+ if (c) {
1604
+ var E = oe(this).constructor;
1605
+ I = Reflect.construct(x, arguments, E);
1606
+ } else
1607
+ I = x.apply(this, arguments);
1608
+ return be(this, I);
1609
+ };
1610
+ }
1611
+ function be(g, c) {
1612
+ return c && (K(c) === "object" || typeof c == "function") ? c : ye(g);
1613
+ }
1614
+ function ye(g) {
1615
+ if (g === void 0)
1616
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1617
+ return g;
1618
+ }
1619
+ function Te() {
1620
+ if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1;
1621
+ if (typeof Proxy == "function") return !0;
1622
+ try {
1623
+ return Date.prototype.toString.call(Reflect.construct(Date, [], function() {
1624
+ })), !0;
1625
+ } catch {
1626
+ return !1;
1627
+ }
1628
+ }
1629
+ function oe(g) {
1630
+ return oe = Object.setPrototypeOf ? Object.getPrototypeOf : function(_) {
1631
+ return _.__proto__ || Object.getPrototypeOf(_);
1632
+ }, oe(g);
1633
+ }
1634
+ function ie(g, c) {
1635
+ var _ = "data-clipboard-".concat(g);
1636
+ if (c.hasAttribute(_))
1637
+ return c.getAttribute(_);
1638
+ }
1639
+ var _e = /* @__PURE__ */ (function(g) {
1640
+ ge(_, g);
1641
+ var c = Ee(_);
1642
+ function _(x, I) {
1643
+ var E;
1644
+ return k(this, _), E = c.call(this), E.resolveOptions(I), E.listenClick(x), E;
1645
+ }
1646
+ return z(_, [{
1647
+ key: "resolveOptions",
1648
+ value: function() {
1649
+ var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1650
+ this.action = typeof I.action == "function" ? I.action : this.defaultAction, this.target = typeof I.target == "function" ? I.target : this.defaultTarget, this.text = typeof I.text == "function" ? I.text : this.defaultText, this.container = K(I.container) === "object" ? I.container : document.body;
1651
+ }
1652
+ /**
1653
+ * Adds a click event listener to the passed trigger.
1654
+ * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
1655
+ */
1656
+ }, {
1657
+ key: "listenClick",
1658
+ value: function(I) {
1659
+ var E = this;
1660
+ this.listener = C()(I, "click", function(Y) {
1661
+ return E.onClick(Y);
1662
+ });
1663
+ }
1664
+ /**
1665
+ * Defines a new `ClipboardAction` on each click event.
1666
+ * @param {Event} e
1667
+ */
1668
+ }, {
1669
+ key: "onClick",
1670
+ value: function(I) {
1671
+ var E = I.delegateTarget || I.currentTarget, Y = this.action(E) || "copy", Ce = pe({
1672
+ action: Y,
1673
+ container: this.container,
1674
+ target: this.target(E),
1675
+ text: this.text(E)
1676
+ });
1677
+ this.emit(Ce ? "success" : "error", {
1678
+ action: Y,
1679
+ text: Ce,
1680
+ trigger: E,
1681
+ clearSelection: function() {
1682
+ E && E.focus(), window.getSelection().removeAllRanges();
1683
+ }
1684
+ });
1685
+ }
1686
+ /**
1687
+ * Default `action` lookup function.
1688
+ * @param {Element} trigger
1689
+ */
1690
+ }, {
1691
+ key: "defaultAction",
1692
+ value: function(I) {
1693
+ return ie("action", I);
1694
+ }
1695
+ /**
1696
+ * Default `target` lookup function.
1697
+ * @param {Element} trigger
1698
+ */
1699
+ }, {
1700
+ key: "defaultTarget",
1701
+ value: function(I) {
1702
+ var E = ie("target", I);
1703
+ if (E)
1704
+ return document.querySelector(E);
1705
+ }
1706
+ /**
1707
+ * Allow fire programmatically a copy action
1708
+ * @param {String|HTMLElement} target
1709
+ * @param {Object} options
1710
+ * @returns Text copied.
1711
+ */
1712
+ }, {
1713
+ key: "defaultText",
1714
+ /**
1715
+ * Default `text` lookup function.
1716
+ * @param {Element} trigger
1717
+ */
1718
+ value: function(I) {
1719
+ return ie("text", I);
1720
+ }
1721
+ /**
1722
+ * Destroy lifecycle.
1723
+ */
1724
+ }, {
1725
+ key: "destroy",
1726
+ value: function() {
1727
+ this.listener.destroy();
1728
+ }
1729
+ }], [{
1730
+ key: "copy",
1731
+ value: function(I) {
1732
+ var E = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
1733
+ container: document.body
1734
+ };
1735
+ return S(I, E);
1736
+ }
1737
+ /**
1738
+ * Allow fire programmatically a cut action
1739
+ * @param {String|HTMLElement} target
1740
+ * @returns Text cutted.
1741
+ */
1742
+ }, {
1743
+ key: "cut",
1744
+ value: function(I) {
1745
+ return u(I);
1746
+ }
1747
+ /**
1748
+ * Returns the support of the given action, or all actions if no action is
1749
+ * given.
1750
+ * @param {String} [action]
1751
+ */
1752
+ }, {
1753
+ key: "isSupported",
1754
+ value: function() {
1755
+ var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ["copy", "cut"], E = typeof I == "string" ? [I] : I, Y = !!document.queryCommandSupported;
1756
+ return E.forEach(function(Ce) {
1757
+ Y = Y && !!document.queryCommandSupported(Ce);
1758
+ }), Y;
1759
+ }
1760
+ }]), _;
1761
+ })(d()), $ = _e;
1762
+ })
1763
+ ),
1764
+ /***/
1765
+ 828: (
1766
+ /***/
1767
+ (function(r) {
1768
+ var i = 9;
1769
+ if (typeof Element < "u" && !Element.prototype.matches) {
1770
+ var a = Element.prototype;
1771
+ a.matches = a.matchesSelector || a.mozMatchesSelector || a.msMatchesSelector || a.oMatchesSelector || a.webkitMatchesSelector;
1772
+ }
1773
+ function l(d, f) {
1774
+ for (; d && d.nodeType !== i; ) {
1775
+ if (typeof d.matches == "function" && d.matches(f))
1776
+ return d;
1777
+ d = d.parentNode;
1778
+ }
1779
+ }
1780
+ r.exports = l;
1781
+ })
1782
+ ),
1783
+ /***/
1784
+ 438: (
1785
+ /***/
1786
+ (function(r, i, a) {
1787
+ var l = a(828);
1788
+ function d(h, N, v, w, u) {
1789
+ var y = C.apply(this, arguments);
1790
+ return h.addEventListener(v, y, u), {
1791
+ destroy: function() {
1792
+ h.removeEventListener(v, y, u);
1793
+ }
1794
+ };
1795
+ }
1796
+ function f(h, N, v, w, u) {
1797
+ return typeof h.addEventListener == "function" ? d.apply(null, arguments) : typeof v == "function" ? d.bind(null, document).apply(null, arguments) : (typeof h == "string" && (h = document.querySelectorAll(h)), Array.prototype.map.call(h, function(y) {
1798
+ return d(y, N, v, w, u);
1799
+ }));
1800
+ }
1801
+ function C(h, N, v, w) {
1802
+ return function(u) {
1803
+ u.delegateTarget = l(u.target, N), u.delegateTarget && w.call(h, u);
1804
+ };
1805
+ }
1806
+ r.exports = f;
1807
+ })
1808
+ ),
1809
+ /***/
1810
+ 879: (
1811
+ /***/
1812
+ (function(r, i) {
1813
+ i.node = function(a) {
1814
+ return a !== void 0 && a instanceof HTMLElement && a.nodeType === 1;
1815
+ }, i.nodeList = function(a) {
1816
+ var l = Object.prototype.toString.call(a);
1817
+ return a !== void 0 && (l === "[object NodeList]" || l === "[object HTMLCollection]") && "length" in a && (a.length === 0 || i.node(a[0]));
1818
+ }, i.string = function(a) {
1819
+ return typeof a == "string" || a instanceof String;
1820
+ }, i.fn = function(a) {
1821
+ var l = Object.prototype.toString.call(a);
1822
+ return l === "[object Function]";
1823
+ };
1824
+ })
1825
+ ),
1826
+ /***/
1827
+ 370: (
1828
+ /***/
1829
+ (function(r, i, a) {
1830
+ var l = a(879), d = a(438);
1831
+ function f(v, w, u) {
1832
+ if (!v && !w && !u)
1833
+ throw new Error("Missing required arguments");
1834
+ if (!l.string(w))
1835
+ throw new TypeError("Second argument must be a String");
1836
+ if (!l.fn(u))
1837
+ throw new TypeError("Third argument must be a Function");
1838
+ if (l.node(v))
1839
+ return C(v, w, u);
1840
+ if (l.nodeList(v))
1841
+ return h(v, w, u);
1842
+ if (l.string(v))
1843
+ return N(v, w, u);
1844
+ throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");
1845
+ }
1846
+ function C(v, w, u) {
1847
+ return v.addEventListener(w, u), {
1848
+ destroy: function() {
1849
+ v.removeEventListener(w, u);
1850
+ }
1851
+ };
1852
+ }
1853
+ function h(v, w, u) {
1854
+ return Array.prototype.forEach.call(v, function(y) {
1855
+ y.addEventListener(w, u);
1856
+ }), {
1857
+ destroy: function() {
1858
+ Array.prototype.forEach.call(v, function(y) {
1859
+ y.removeEventListener(w, u);
1860
+ });
1861
+ }
1862
+ };
1863
+ }
1864
+ function N(v, w, u) {
1865
+ return d(document.body, v, w, u);
1866
+ }
1867
+ r.exports = f;
1868
+ })
1869
+ ),
1870
+ /***/
1871
+ 817: (
1872
+ /***/
1873
+ (function(r) {
1874
+ function i(a) {
1875
+ var l;
1876
+ if (a.nodeName === "SELECT")
1877
+ a.focus(), l = a.value;
1878
+ else if (a.nodeName === "INPUT" || a.nodeName === "TEXTAREA") {
1879
+ var d = a.hasAttribute("readonly");
1880
+ d || a.setAttribute("readonly", ""), a.select(), a.setSelectionRange(0, a.value.length), d || a.removeAttribute("readonly"), l = a.value;
1881
+ } else {
1882
+ a.hasAttribute("contenteditable") && a.focus();
1883
+ var f = window.getSelection(), C = document.createRange();
1884
+ C.selectNodeContents(a), f.removeAllRanges(), f.addRange(C), l = f.toString();
1885
+ }
1886
+ return l;
1887
+ }
1888
+ r.exports = i;
1889
+ })
1890
+ ),
1891
+ /***/
1892
+ 279: (
1893
+ /***/
1894
+ (function(r) {
1895
+ function i() {
1896
+ }
1897
+ i.prototype = {
1898
+ on: function(a, l, d) {
1899
+ var f = this.e || (this.e = {});
1900
+ return (f[a] || (f[a] = [])).push({
1901
+ fn: l,
1902
+ ctx: d
1903
+ }), this;
1904
+ },
1905
+ once: function(a, l, d) {
1906
+ var f = this;
1907
+ function C() {
1908
+ f.off(a, C), l.apply(d, arguments);
1909
+ }
1910
+ return C._ = l, this.on(a, C, d);
1911
+ },
1912
+ emit: function(a) {
1913
+ var l = [].slice.call(arguments, 1), d = ((this.e || (this.e = {}))[a] || []).slice(), f = 0, C = d.length;
1914
+ for (f; f < C; f++)
1915
+ d[f].fn.apply(d[f].ctx, l);
1916
+ return this;
1917
+ },
1918
+ off: function(a, l) {
1919
+ var d = this.e || (this.e = {}), f = d[a], C = [];
1920
+ if (f && l)
1921
+ for (var h = 0, N = f.length; h < N; h++)
1922
+ f[h].fn !== l && f[h].fn._ !== l && C.push(f[h]);
1923
+ return C.length ? d[a] = C : delete d[a], this;
1924
+ }
1925
+ }, r.exports = i, r.exports.TinyEmitter = i;
1926
+ })
1927
+ )
1928
+ /******/
1929
+ }, s = {};
1930
+ function o(r) {
1931
+ if (s[r])
1932
+ return s[r].exports;
1933
+ var i = s[r] = {
1934
+ /******/
1935
+ // no module.id needed
1936
+ /******/
1937
+ // no module.loaded needed
1938
+ /******/
1939
+ exports: {}
1940
+ /******/
1941
+ };
1942
+ return t[r](i, i.exports, o), i.exports;
1943
+ }
1944
+ return (function() {
1945
+ o.n = function(r) {
1946
+ var i = r && r.__esModule ? (
1947
+ /******/
1948
+ function() {
1949
+ return r.default;
1950
+ }
1951
+ ) : (
1952
+ /******/
1953
+ function() {
1954
+ return r;
1955
+ }
1956
+ );
1957
+ return o.d(i, { a: i }), i;
1958
+ };
1959
+ })(), (function() {
1960
+ o.d = function(r, i) {
1961
+ for (var a in i)
1962
+ o.o(i, a) && !o.o(r, a) && Object.defineProperty(r, a, { enumerable: !0, get: i[a] });
1963
+ };
1964
+ })(), (function() {
1965
+ o.o = function(r, i) {
1966
+ return Object.prototype.hasOwnProperty.call(r, i);
1967
+ };
1968
+ })(), o(686);
1969
+ })().default
1970
+ );
1971
+ });
1972
+ })(we)), we.exports;
1973
+ }
1974
+ var Zo = Qo();
1975
+ const es = /* @__PURE__ */ qo(Zo), ts = (n) => ({
1976
+ toClipboard(e, t) {
1977
+ return new Promise((s, o) => {
1978
+ const r = document.createElement("button"), i = new es(r, {
1979
+ text: () => e,
1980
+ action: () => "copy",
1981
+ container: t !== void 0 ? t : document.body
1982
+ });
1983
+ i.on("success", (a) => {
1984
+ i.destroy(), s(a);
1985
+ }), i.on("error", (a) => {
1986
+ i.destroy(), o(a);
1987
+ }), document.body.appendChild(r), r.click(), document.body.removeChild(r);
1988
+ });
1989
+ }
1990
+ }), ns = {
1991
+ key: 0,
1992
+ class: "baklava-button"
1993
+ }, os = /* @__PURE__ */ F({
1994
+ __name: "CopyToClipboard",
1995
+ props: { text: String },
1996
+ setup(n) {
1997
+ const { toClipboard: e } = ts(), s = Me(n, "text"), o = H(!1), r = async () => {
1998
+ try {
1999
+ await e(s.value), o.value = !0, setTimeout(() => o.value = !1, 1500), console.log("Copied to clipboard");
2000
+ } catch (i) {
2001
+ console.error(i);
2002
+ }
2003
+ };
2004
+ return (i, a) => (p(), b("div", null, [
2005
+ o.value ? (p(), b("button", ns, [
2006
+ G(O(On))
2007
+ ])) : (p(), b("button", {
2008
+ key: 1,
2009
+ onClick: r,
2010
+ class: "baklava-button"
2011
+ }, [
2012
+ G(O(jn))
2013
+ ]))
2014
+ ]));
2015
+ }
2016
+ }), ss = { class: "code-editor" }, rs = { class: "code-buttons" }, Cr = /* @__PURE__ */ F({
2017
+ __name: "CodeEditor",
2018
+ props: /* @__PURE__ */ Ue({
2019
+ locked: { type: Boolean },
2020
+ extensions: {}
2021
+ }, {
2022
+ modelValue: { required: !0, type: String },
2023
+ modelModifiers: {}
2024
+ }),
2025
+ emits: /* @__PURE__ */ Ue(["update:locked"], ["update:modelValue"]),
2026
+ setup(n, { emit: e }) {
2027
+ const t = xt(n, "modelValue"), s = e, o = (r) => s("update:locked", r);
2028
+ return (r, i) => {
2029
+ const a = Ze("codemirror");
2030
+ return p(), b("div", ss, [
2031
+ m("div", rs, [
2032
+ n.locked ? (p(), b("button", {
2033
+ key: 0,
2034
+ class: "baklava-button",
2035
+ title: "The code is locked.",
2036
+ onClick: i[0] || (i[0] = (l) => o(!1))
2037
+ }, [
2038
+ G(O(ht))
2039
+ ])) : j("", !0),
2040
+ G(os, { text: n.modelValue }, null, 8, ["text"])
2041
+ ]),
2042
+ G(a, {
2043
+ modelValue: t.value,
2044
+ "onUpdate:modelValue": i[1] || (i[1] = (l) => t.value = l),
2045
+ extensions: n.extensions,
2046
+ class: "codemirror",
2047
+ style: { height: "100%" },
2048
+ onKeydown: i[2] || (i[2] = (l) => o(!0))
2049
+ }, null, 8, ["modelValue", "extensions"])
2050
+ ]);
2051
+ };
2052
+ }
2053
+ }), wr = /* @__PURE__ */ F({
1394
2054
  __name: "CodeGraphEditor",
1395
2055
  props: {
1396
2056
  viewModel: {}
1397
2057
  },
1398
2058
  setup(n) {
1399
- const t = Be(n, "viewModel"), s = (o) => o.events.update.emit(null);
1400
- return fe(() => {
2059
+ const t = Me(n, "viewModel"), s = (o) => o.events.update.emit(null);
2060
+ return Se(() => {
1401
2061
  t.value.subscribe && t.value.subscribe(), t.value.engine?.start();
1402
- }), ze(() => {
2062
+ }), et(() => {
1403
2063
  t.value.unsubscribe && t.value.unsubscribe(), t.value.engine?.stop();
1404
- }), He(t, (o, a) => {
1405
- a && a.unsubscribe(), o && o.subscribe();
1406
- }), (o, a) => (d(), j(w(Bt), { viewModel: t.value }, {
2064
+ }), tt(t, (o, r) => {
2065
+ r && r.unsubscribe(), o && o.subscribe();
2066
+ }), (o, r) => (p(), B(O(qt), { viewModel: t.value }, {
1407
2067
  palette: ee(() => [
1408
- L(w(Ls))
2068
+ G(O(As))
1409
2069
  ]),
1410
2070
  node: ee((i) => [
1411
- L(w(Ps), mt(i, {
1412
- onUpdate: (r) => s(i.node)
2071
+ G(O(gs), Et(i, {
2072
+ onUpdate: (a) => s(i.node)
1413
2073
  }), null, 16, ["onUpdate"])
1414
2074
  ]),
1415
2075
  sidebar: ee((i) => [
1416
- L(w(Qs), pt(ht(i)), {
1417
- codeEditor: ee(({ node: r }) => [
1418
- ne(o.$slots, "sidebarCodeEditor", { node: r })
2076
+ G(O($s), It(Nt(i)), {
2077
+ codeEditor: ee(({ node: a }) => [
2078
+ q(o.$slots, "sidebarCodeEditor", { node: a })
1419
2079
  ]),
1420
2080
  _: 3
1421
2081
  }, 16)
@@ -1423,27 +2083,27 @@ const $o = /* @__PURE__ */ F({
1423
2083
  _: 3
1424
2084
  }, 8, ["viewModel"]));
1425
2085
  }
1426
- }), ws = { class: "code-graph-info" }, Mo = /* @__PURE__ */ F({
2086
+ }), as = { class: "code-graph-info" }, kr = /* @__PURE__ */ F({
1427
2087
  __name: "CodeGraphInfo",
1428
2088
  props: {
1429
2089
  viewModel: {}
1430
2090
  },
1431
2091
  setup(n) {
1432
- return (e, t) => (d(), p("div", ws, [
1433
- u("div", null, "Editor graph: " + G(n.viewModel.editor.graph.shortId), 1),
1434
- u("div", null, "Displayed graph: " + G(n.viewModel.displayedGraph.shortId), 1),
1435
- u("div", null, "Graphs: " + G(n.viewModel.editor.graphIds), 1),
1436
- u("div", null, "Graph templates: " + G(n.viewModel.editor.graphTemplateIds), 1),
1437
- u("div", null, "Engine status: " + G(n.viewModel.engine?.status), 1)
2092
+ return (e, t) => (p(), b("div", as, [
2093
+ m("div", null, "Editor graph: " + L(n.viewModel.editor.graph.shortId), 1),
2094
+ m("div", null, "Displayed graph: " + L(n.viewModel.displayedGraph.shortId), 1),
2095
+ m("div", null, "Graphs: " + L(n.viewModel.editor.graphIds), 1),
2096
+ m("div", null, "Graph templates: " + L(n.viewModel.editor.graphTemplateIds), 1),
2097
+ m("div", null, "Engine status: " + L(n.viewModel.engine?.status), 1)
1438
2098
  ]));
1439
2099
  }
1440
- }), ks = ["id", "data-node-type"], Ns = {
2100
+ }), is = ["id", "data-node-type"], ls = {
1441
2101
  class: "__title-label",
1442
2102
  style: { "flex-grow": "1" }
1443
- }, xs = { key: 0 }, Os = {
2103
+ }, us = { key: 0 }, ds = {
1444
2104
  class: "__menu",
1445
2105
  style: { display: "flex" }
1446
- }, Ts = { class: "__outputs" }, Es = { key: 0 }, $s = ["id", "title"], Ms = { class: "__inputs" }, Gs = { key: 0 }, Ss = ["id", "title"], Ps = /* @__PURE__ */ F({
2106
+ }, cs = { class: "__outputs" }, ps = { key: 0 }, hs = ["id", "title"], fs = { class: "__inputs" }, ms = { key: 0 }, vs = ["id", "title"], gs = /* @__PURE__ */ F({
1447
2107
  __name: "CodeGraphNode",
1448
2108
  props: {
1449
2109
  node: {},
@@ -1452,366 +2112,275 @@ const $o = /* @__PURE__ */ F({
1452
2112
  },
1453
2113
  emits: ["select", "start-drag", "update"],
1454
2114
  setup(n, { emit: e }) {
1455
- const t = me.ContextMenu, s = me.NodeInterface, o = n, a = O(() => o.node), i = e, { viewModel: r } = oe(), { graph: c, switchGraph: h } = ge(), g = V(null), _ = V(!1), m = V(""), k = V(null), b = V(!1);
1456
- let I = 0, l = 0;
1457
- const f = V(!1), N = O(() => {
1458
- const C = [
2115
+ const t = $e.ContextMenu, s = $e.NodeInterface, o = n, r = P(() => o.node), i = e, { viewModel: a } = me(), { graph: l, switchGraph: d } = Ge(), f = H(null), C = H(!1), h = H(""), N = H(null), v = H(!1);
2116
+ let w = 0, u = 0;
2117
+ const y = H(!1), M = P(() => {
2118
+ const $ = [
1459
2119
  { value: "edit", label: "Edit" },
1460
2120
  { value: "rename", label: "Rename" },
1461
2121
  { value: "delete", label: "Delete" }
1462
2122
  ];
1463
- return o.node.type.startsWith(wt) && C.push({ value: "editSubgraph", label: "Edit Subgraph" }), C;
1464
- }), y = O(() => ({
2123
+ return o.node.type.startsWith(At) && $.push({ value: "editSubgraph", label: "Edit Subgraph" }), $;
2124
+ }), T = P(() => ({
1465
2125
  "--selected": o.selected,
1466
2126
  "--dragging": o.dragging,
1467
2127
  "--two-column": !!o.node.twoColumn,
1468
- "--hidden": a.value.state?.hidden
1469
- })), T = O(() => ({
1470
- "--reverse-y": o.node.reverseY ?? r.value.settings.nodes.reverseY
1471
- })), ie = O(() => ({
2128
+ "--hidden": r.value.state?.hidden
2129
+ })), S = P(() => ({
2130
+ "--reverse-y": o.node.reverseY ?? a.value.settings.nodes.reverseY
2131
+ })), Q = P(() => ({
1472
2132
  top: `${o.node.position?.y ?? 0}px`,
1473
2133
  left: `${o.node.position?.x ?? 0}px`,
1474
- "--width": `${o.node.width ?? r.value.settings.nodes.defaultWidth}px`
1475
- })), W = O(() => Object.values(o.node.inputs).filter((C) => !C.hidden)), pe = O(() => Object.values(o.node.outputs).filter((C) => !C.hidden)), re = () => {
2134
+ "--width": `${o.node.width ?? a.value.settings.nodes.defaultWidth}px`
2135
+ })), Z = P(() => Object.values(o.node.inputs).filter(($) => !$.hidden)), pe = P(() => Object.values(o.node.outputs).filter(($) => !$.hidden)), K = () => {
1476
2136
  i("select");
1477
- }, v = (C) => {
1478
- o.selected || re(), i("start-drag", C);
1479
- }, S = () => {
1480
- f.value = !0;
1481
- }, H = () => {
1482
- const C = r.value.displayedGraph.sidebar;
1483
- C.nodeId = "", C.visible = !1;
1484
- }, Ne = () => {
1485
- const C = r.value.displayedGraph.sidebar;
1486
- C.nodeId = o.node.id, C.visible = !0;
1487
- }, rt = () => {
1488
- const C = r.value.displayedGraph.sidebar;
1489
- C.nodeId = o.node.id;
1490
- }, dt = async (C) => {
1491
- switch (C) {
2137
+ }, k = ($) => {
2138
+ o.selected || K(), i("start-drag", $);
2139
+ }, R = () => {
2140
+ y.value = !0;
2141
+ }, z = () => {
2142
+ const $ = a.value.displayedGraph.sidebar;
2143
+ $.nodeId = "", $.visible = !1;
2144
+ }, ge = () => {
2145
+ const $ = a.value.displayedGraph.sidebar;
2146
+ $.nodeId = o.node.id, $.visible = !0;
2147
+ }, he = () => {
2148
+ const $ = a.value.displayedGraph.sidebar;
2149
+ $.nodeId = o.node.id;
2150
+ }, Ee = async ($) => {
2151
+ switch ($) {
1492
2152
  case "edit":
1493
- Ne();
2153
+ ge();
1494
2154
  break;
1495
2155
  case "delete":
1496
- c.value.removeNode(o.node);
2156
+ l.value.removeNode(o.node);
1497
2157
  break;
1498
2158
  case "rename":
1499
- m.value = o.node.title, _.value = !0, await vt(), k.value?.focus();
2159
+ h.value = o.node.title, C.value = !0, await Tt(), N.value?.focus();
1500
2160
  break;
1501
2161
  case "editSubgraph":
1502
- h(o.node.template);
2162
+ d(o.node.template);
1503
2163
  break;
1504
2164
  }
1505
- }, xe = () => {
1506
- a.value.title = m.value, _.value = !1;
1507
- }, Oe = () => {
1508
- g.value && r.value.hooks.renderNode.execute({ node: o.node, el: g.value });
1509
- }, lt = (C) => {
1510
- b.value = !0, I = o.node.width, l = C.clientX, C.preventDefault();
1511
- }, Te = (C) => {
1512
- a.value.state && (a.value.state.integrated = C, i("update"));
1513
- }, Ee = (C) => {
1514
- if (!b.value) return;
1515
- const E = C.clientX - l, x = I + E / c.value.scaling, ut = r.value.settings.nodes.minWidth, ct = r.value.settings.nodes.maxWidth;
1516
- a.value.width = Math.max(ut, Math.min(ct, x));
1517
- }, $e = () => {
1518
- b.value = !1;
2165
+ }, be = () => {
2166
+ r.value.title = h.value, C.value = !1;
2167
+ }, ye = () => {
2168
+ f.value && a.value.hooks.renderNode.execute({ node: o.node, el: f.value });
2169
+ }, Te = ($) => {
2170
+ v.value = !0, w = o.node.width, u = $.clientX, $.preventDefault();
2171
+ }, oe = ($) => {
2172
+ r.value.state && (r.value.state.integrated = $, i("update"));
2173
+ }, ie = ($) => {
2174
+ if (!v.value) return;
2175
+ const g = $.clientX - u, c = w + g / l.value.scaling, _ = a.value.settings.nodes.minWidth, x = a.value.settings.nodes.maxWidth;
2176
+ r.value.width = Math.max(_, Math.min(x, c));
2177
+ }, _e = () => {
2178
+ v.value = !1;
1519
2179
  };
1520
- return fe(() => {
1521
- Oe(), window.addEventListener("mousemove", Ee), window.addEventListener("mouseup", $e);
1522
- }), Le(Oe), ze(() => {
1523
- window.removeEventListener("mousemove", Ee), window.removeEventListener("mouseup", $e);
1524
- }), (C, E) => (d(), p("div", {
1525
- id: a.value.id,
2180
+ return Se(() => {
2181
+ ye(), window.addEventListener("mousemove", ie), window.addEventListener("mouseup", _e);
2182
+ }), nt(ye), et(() => {
2183
+ window.removeEventListener("mousemove", ie), window.removeEventListener("mouseup", _e);
2184
+ }), ($, g) => (p(), b("div", {
2185
+ id: r.value.id,
1526
2186
  ref_key: "el",
1527
- ref: g,
1528
- class: Y([y.value, "baklava-node"]),
1529
- "data-node-type": a.value.type,
1530
- style: ve(ie.value),
1531
- onPointerdown: re
2187
+ ref: f,
2188
+ class: ne([T.value, "baklava-node"]),
2189
+ "data-node-type": r.value.type,
2190
+ style: Pe(Q.value),
2191
+ onPointerdown: K
1532
2192
  }, [
1533
- w(r).settings.nodes.resizable ? (d(), p("div", {
2193
+ O(a).settings.nodes.resizable ? (p(), b("div", {
1534
2194
  key: 0,
1535
2195
  class: "__resize-handle",
1536
- onMousedown: lt
1537
- }, null, 32)) : M("", !0),
1538
- u("div", {
2196
+ onMousedown: Te
2197
+ }, null, 32)) : j("", !0),
2198
+ m("div", {
1539
2199
  class: "__title",
1540
- onPointerdown: te(v, ["self", "stop"]),
1541
- onContextmenu: te(S, ["prevent"])
2200
+ onPointerdown: le(k, ["self", "stop"]),
2201
+ onContextmenu: le(R, ["prevent"])
1542
2202
  }, [
1543
- a.value.inputs._code ? (d(), j(w(Ve), {
2203
+ r.value.inputs._code ? (p(), B(O(Ke), {
1544
2204
  key: 0,
1545
- node: a.value,
1546
- intf: a.value.inputs._code,
1547
- title: a.value.inputs._code.value,
2205
+ node: r.value,
2206
+ intf: r.value.inputs._code,
2207
+ title: r.value.inputs._code.value,
1548
2208
  class: "--input",
1549
2209
  "data-interface-type": "node",
1550
2210
  style: { "flex-grow": "0" }
1551
- }, null, 8, ["node", "intf", "title"])) : M("", !0),
1552
- _.value ? de((d(), p("input", {
2211
+ }, null, 8, ["node", "intf", "title"])) : j("", !0),
2212
+ C.value ? ke((p(), b("input", {
1553
2213
  key: 2,
1554
2214
  ref_key: "renameInputEl",
1555
- ref: k,
1556
- "onUpdate:modelValue": E[4] || (E[4] = (x) => m.value = x),
2215
+ ref: N,
2216
+ "onUpdate:modelValue": g[4] || (g[4] = (c) => h.value = c),
1557
2217
  class: "baklava-input",
1558
2218
  placeholder: "Node Name",
1559
2219
  style: { "flex-grow": "1" },
1560
2220
  type: "text",
1561
- onBlur: xe,
1562
- onKeydown: he(xe, ["enter"])
2221
+ onBlur: be,
2222
+ onKeydown: Oe(be, ["enter"])
1563
2223
  }, null, 544)), [
1564
- [le, m.value]
1565
- ]) : (d(), p(B, { key: 1 }, [
1566
- u("div", Ns, [
1567
- a.value.idx > -1 ? (d(), p("span", xs, G(a.value.idx + 1) + " - ", 1)) : M("", !0),
1568
- ft(G(a.value.title) + " " + G(a.value.graph.shortId) + " " + G(a.value.shortId), 1)
2224
+ [xe, h.value]
2225
+ ]) : (p(), b(U, { key: 1 }, [
2226
+ m("div", ls, [
2227
+ r.value.idx > -1 ? (p(), b("span", us, L(r.value.idx + 1) + " - ", 1)) : j("", !0),
2228
+ ot(L(r.value.title) + " " + L(r.value.graph.shortId) + " " + L(r.value.shortId), 1)
1569
2229
  ]),
1570
- u("div", Os, [
1571
- a.value.isCodeNode ? (d(), p(B, { key: 0 }, [
1572
- a.value.state.lockCode ? (d(), j(w(Kn), {
2230
+ m("div", ds, [
2231
+ r.value.isCodeNode ? (p(), b(U, { key: 0 }, [
2232
+ r.value.state.lockCode ? (p(), B(O(ht), {
1573
2233
  key: 0,
1574
2234
  class: "--clickable mx-1",
1575
- onClick: E[0] || (E[0] = (x) => a.value.lockCode = !1)
1576
- })) : M("", !0),
1577
- a.value.state.integrated ? (d(), j(w(yn), {
2235
+ onClick: g[0] || (g[0] = (c) => r.value.lockCode = !1)
2236
+ })) : j("", !0),
2237
+ r.value.state.integrated ? (p(), B(O(Pn), {
1578
2238
  key: 1,
1579
2239
  class: "--clickable mx-1",
1580
- onClick: E[1] || (E[1] = (x) => Te(!1))
1581
- })) : (d(), j(w(us), {
2240
+ onClick: g[1] || (g[1] = (c) => oe(!1))
2241
+ })) : (p(), B(O(Mo), {
1582
2242
  key: 2,
1583
2243
  class: "--clickable mx-1",
1584
- onClick: E[2] || (E[2] = (x) => Te(!0))
2244
+ onClick: g[2] || (g[2] = (c) => oe(!0))
1585
2245
  })),
1586
- !w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Dn), {
2246
+ !O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(io), {
1587
2247
  key: 3,
1588
2248
  class: "--clickable mx-1",
1589
- onClick: Ne
1590
- })) : w(r).displayedGraph.sidebar.visible && w(r).displayedGraph.sidebar.nodeId !== a.value.id ? (d(), j(w(Rn), {
2249
+ onClick: ge
2250
+ })) : O(a).displayedGraph.sidebar.visible && O(a).displayedGraph.sidebar.nodeId !== r.value.id ? (p(), B(O(Zn), {
1591
2251
  key: 4,
1592
2252
  class: "--clickable mx-1",
1593
- onClick: rt
1594
- })) : (d(), j(w(Hn), {
2253
+ onClick: he
2254
+ })) : (p(), B(O(oo), {
1595
2255
  key: 5,
1596
2256
  class: "--clickable mx-1",
1597
- onClick: H
2257
+ onClick: z
1598
2258
  }))
1599
- ], 64)) : M("", !0),
1600
- L(w(kn), {
2259
+ ], 64)) : j("", !0),
2260
+ G(O(Hn), {
1601
2261
  class: "--clickable mx-1",
1602
- onClick: S
2262
+ onClick: R
1603
2263
  }),
1604
- L(w(t), {
1605
- modelValue: f.value,
1606
- "onUpdate:modelValue": E[3] || (E[3] = (x) => f.value = x),
2264
+ G(O(t), {
2265
+ modelValue: y.value,
2266
+ "onUpdate:modelValue": g[3] || (g[3] = (c) => y.value = c),
1607
2267
  x: 0,
1608
2268
  y: 0,
1609
- items: N.value,
1610
- onClick: dt
2269
+ items: M.value,
2270
+ onClick: Ee
1611
2271
  }, null, 8, ["modelValue", "items"])
1612
2272
  ])
1613
2273
  ], 64)),
1614
- a.value.outputs._code ? (d(), j(w(Ve), {
2274
+ r.value.outputs._code ? (p(), B(O(Ke), {
1615
2275
  key: 3,
1616
- node: a.value,
1617
- intf: a.value.outputs._code,
2276
+ node: r.value,
2277
+ intf: r.value.outputs._code,
1618
2278
  class: "--output",
1619
- title: a.value.outputs._code.value,
2279
+ title: r.value.outputs._code.value,
1620
2280
  "data-interface-type": "node"
1621
- }, null, 8, ["node", "intf", "title"])) : M("", !0)
2281
+ }, null, 8, ["node", "intf", "title"])) : j("", !0)
1622
2282
  ], 32),
1623
- u("div", {
1624
- class: Y(["__content", T.value]),
1625
- onKeydown: E[5] || (E[5] = he(te(() => {
2283
+ m("div", {
2284
+ class: ne(["__content", S.value]),
2285
+ onKeydown: g[5] || (g[5] = Oe(le(() => {
1626
2286
  }, ["stop"]), ["delete"])),
1627
- onContextmenu: E[6] || (E[6] = te(() => {
2287
+ onContextmenu: g[6] || (g[6] = le(() => {
1628
2288
  }, ["prevent"]))
1629
2289
  }, [
1630
- u("div", Ts, [
1631
- (d(!0), p(B, null, J(pe.value, (x) => (d(), p(B, {
1632
- key: x.id
2290
+ m("div", cs, [
2291
+ (p(!0), b(U, null, se(pe.value, (c) => (p(), b(U, {
2292
+ key: c.id
1633
2293
  }, [
1634
- a.value.state?.hidden ? (d(), p("div", Es, [
1635
- x.port ? (d(), p("div", {
2294
+ r.value.state?.hidden ? (p(), b("div", ps, [
2295
+ c.port ? (p(), b("div", {
1636
2296
  key: 0,
1637
- id: x.id,
1638
- title: x.name,
2297
+ id: c.id,
2298
+ title: c.name,
1639
2299
  class: "baklava-node-interface --output --connected"
1640
- }, [...E[7] || (E[7] = [
1641
- u("div", { class: "__port" }, null, -1)
1642
- ])], 8, $s)) : M("", !0)
1643
- ])) : ne(C.$slots, "nodeInterface", {
2300
+ }, [...g[7] || (g[7] = [
2301
+ m("div", { class: "__port" }, null, -1)
2302
+ ])], 8, hs)) : j("", !0)
2303
+ ])) : q($.$slots, "nodeInterface", {
1644
2304
  key: 1,
1645
2305
  type: "output",
1646
- node: a.value,
1647
- intf: x
2306
+ node: r.value,
2307
+ intf: c
1648
2308
  }, () => [
1649
- L(w(s), {
1650
- node: a.value,
1651
- intf: x,
1652
- title: x.value
2309
+ G(O(s), {
2310
+ node: r.value,
2311
+ intf: c,
2312
+ title: c.value
1653
2313
  }, null, 8, ["node", "intf", "title"])
1654
2314
  ])
1655
2315
  ], 64))), 128))
1656
2316
  ]),
1657
- u("div", Ms, [
1658
- (d(!0), p(B, null, J(W.value, (x) => (d(), p(B, {
1659
- key: x.id
2317
+ m("div", fs, [
2318
+ (p(!0), b(U, null, se(Z.value, (c) => (p(), b(U, {
2319
+ key: c.id
1660
2320
  }, [
1661
- a.value.state?.hidden ? (d(), p("div", Gs, [
1662
- x.port ? (d(), p("div", {
2321
+ r.value.state?.hidden ? (p(), b("div", ms, [
2322
+ c.port ? (p(), b("div", {
1663
2323
  key: 0,
1664
- id: x.id,
1665
- title: x.name,
2324
+ id: c.id,
2325
+ title: c.name,
1666
2326
  class: "baklava-node-interface --input --connected"
1667
- }, [...E[8] || (E[8] = [
1668
- u("div", { class: "__port" }, null, -1)
1669
- ])], 8, Ss)) : M("", !0)
1670
- ])) : ne(C.$slots, "nodeInterface", {
2327
+ }, [...g[8] || (g[8] = [
2328
+ m("div", { class: "__port" }, null, -1)
2329
+ ])], 8, vs)) : j("", !0)
2330
+ ])) : q($.$slots, "nodeInterface", {
1671
2331
  key: 1,
1672
- node: a.value,
1673
- intf: x,
2332
+ node: r.value,
2333
+ intf: c,
1674
2334
  type: "input"
1675
2335
  }, () => [
1676
- L(w(s), {
1677
- node: a.value,
1678
- intf: x,
1679
- title: x.value
2336
+ G(O(s), {
2337
+ node: r.value,
2338
+ intf: c,
2339
+ title: c.value
1680
2340
  }, null, 8, ["node", "intf", "title"])
1681
2341
  ])
1682
2342
  ], 64))), 128))
1683
2343
  ])
1684
2344
  ], 34)
1685
- ], 46, ks));
2345
+ ], 46, is));
1686
2346
  }
1687
- }), Vs = ["id"], Rs = { class: "align-middle" }, Ve = /* @__PURE__ */ F({
2347
+ }), bs = ["id"], ys = { class: "align-middle" }, Ke = /* @__PURE__ */ F({
1688
2348
  __name: "CodeGraphNodeInterface",
1689
2349
  props: {
1690
2350
  node: {},
1691
2351
  intf: {}
1692
2352
  },
1693
2353
  setup(n) {
1694
- const e = n, { viewModel: t } = oe(), { hoveredOver: s, temporaryConnection: o } = zt(), a = V(null), i = O(() => e.intf.connectionCount > 0), r = O(() => ({
2354
+ const e = n, { viewModel: t } = me(), { hoveredOver: s, temporaryConnection: o } = Jt(), r = H(null), i = P(() => e.intf.connectionCount > 0), a = P(() => ({
1695
2355
  "--connected": i.value
1696
- })), c = () => {
2356
+ })), l = () => {
1697
2357
  s(e.intf);
1698
- }, h = () => {
2358
+ }, d = () => {
1699
2359
  s(void 0);
1700
- }, g = () => {
1701
- a.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: a.value });
2360
+ }, f = () => {
2361
+ r.value && t.value.hooks.renderInterface.execute({ intf: e.intf, el: r.value });
1702
2362
  };
1703
- return fe(g), Le(g), (_, m) => (d(), p("div", {
2363
+ return Se(f), nt(f), (C, h) => (p(), b("div", {
1704
2364
  id: n.intf.id,
1705
2365
  ref_key: "el",
1706
- ref: a,
1707
- class: Y(["baklava-node-interface", r.value])
2366
+ ref: r,
2367
+ class: ne(["baklava-node-interface", a.value])
1708
2368
  }, [
1709
- n.intf.port ? (d(), p("div", {
2369
+ n.intf.port ? (p(), b("div", {
1710
2370
  key: 0,
1711
- class: Y(["__port", { "--selected": w(o)?.from === n.intf }]),
1712
- onPointerover: c,
1713
- onPointerout: h
1714
- }, null, 34)) : M("", !0),
1715
- u("span", Rs, [
1716
- ne(_.$slots, "default")
2371
+ class: ne(["__port", { "--selected": O(o)?.from === n.intf }]),
2372
+ onPointerover: l,
2373
+ onPointerout: d
2374
+ }, null, 34)) : j("", !0),
2375
+ m("span", ys, [
2376
+ q(C.$slots, "default")
1717
2377
  ])
1718
- ], 10, Vs));
2378
+ ], 10, bs));
1719
2379
  }
1720
- }), js = {
1721
- class: "baklava-node --palette",
1722
- style: { "margin-top": "-20px", "margin-bottom": "20px" }
1723
- }, Bs = {
1724
- key: 0,
1725
- style: { display: "flex", "justify-content": "space-between" }
1726
- }, zs = ["onClick"], Hs = {
1727
- key: 0,
1728
- style: { margin: "auto 0", "font-size": "12px" }
1729
- }, Ls = /* @__PURE__ */ F({
1730
- __name: "CodeNodePalette",
1731
- setup(n) {
1732
- const e = me.PaletteEntry, { viewModel: t } = oe(), { x: s, y: o } = Zt(), { transform: a } = Ht(), i = Lt(t), r = gt("editorEl"), c = V(""), h = V(null), g = () => c.value ? i.value.filter(
1733
- (b) => b.name.toLowerCase().includes(c.value.toLowerCase()) || Object.values(b.nodeTypes).some(
1734
- (I) => I.title.toLowerCase().includes(c.value.toLowerCase())
1735
- )
1736
- ) : i.value, _ = (b) => c.value ? _s(b, (I) => {
1737
- const l = I[1];
1738
- return l.category.includes(c.value.toLowerCase()) || l.title?.toLowerCase().includes(c.value.toLowerCase());
1739
- }) : b, m = O(() => {
1740
- if (!h.value || !r?.value) return {};
1741
- const { left: b, top: I } = r.value.getBoundingClientRect();
1742
- return {
1743
- top: `${o.value - I}px`,
1744
- left: `${s.value - b}px`
1745
- };
1746
- }), k = (b, I) => {
1747
- h.value = {
1748
- type: b,
1749
- nodeInformation: I
1750
- };
1751
- const l = () => {
1752
- const f = D(new I.type());
1753
- t.value.displayedGraph.addNode(f);
1754
- const N = r.value.getBoundingClientRect(), [y, T] = a(s.value - N.left, o.value - N.top);
1755
- f.position.x = y, f.position.y = T, h.value = null, document.removeEventListener("pointerup", l);
1756
- };
1757
- document.addEventListener("pointerup", l);
1758
- };
1759
- return (b, I) => (d(), p(B, null, [
1760
- u("div", {
1761
- class: Y([{ "--open": w(t).settings.palette.enabled }, "baklava-node-palette"]),
1762
- onContextmenu: I[1] || (I[1] = te(() => {
1763
- }, ["stop", "prevent"]))
1764
- }, [
1765
- u("div", js, [
1766
- de(u("input", {
1767
- "onUpdate:modelValue": I[0] || (I[0] = (l) => c.value = l),
1768
- type: "text",
1769
- class: "baklava-input",
1770
- title: "Filter nodes",
1771
- onKeyup: g
1772
- }, null, 544), [
1773
- [le, c.value]
1774
- ])
1775
- ]),
1776
- (d(!0), p(B, null, J(g(), (l) => (d(), p("section", {
1777
- key: l.name
1778
- }, [
1779
- l.name !== "default" ? (d(), p("h3", Bs, [
1780
- u("div", {
1781
- onClick: (f) => c.value = l.name,
1782
- style: { cursor: "pointer" }
1783
- }, G(l.name), 9, zs),
1784
- Object.keys(_(l.nodeTypes)).length < Object.values(l.nodeTypes).length ? (d(), p("div", Hs, " ( " + G(Object.keys(_(l.nodeTypes)).length) + " / " + G(Object.values(l.nodeTypes).length) + " ) ", 1)) : M("", !0)
1785
- ])) : M("", !0),
1786
- (d(!0), p(B, null, J(_(l.nodeTypes), (f, N) => (d(), j(w(e), {
1787
- key: N,
1788
- type: N,
1789
- title: f.title,
1790
- onPointerdown: (y) => k(N, f)
1791
- }, null, 8, ["type", "title", "onPointerdown"]))), 128))
1792
- ]))), 128))
1793
- ], 34),
1794
- L(bt, { name: "fade" }, {
1795
- default: ee(() => [
1796
- h.value ? (d(), p("div", {
1797
- key: 0,
1798
- class: "baklava-dragged-node",
1799
- style: ve(m.value)
1800
- }, [
1801
- L(w(e), {
1802
- type: h.value.type,
1803
- title: h.value.nodeInformation.title
1804
- }, null, 8, ["type", "title"])
1805
- ], 4)) : M("", !0)
1806
- ]),
1807
- _: 1
1808
- })
1809
- ], 64));
1810
- }
1811
- }), Us = ["title"], As = {
2380
+ }), _s = ["title"], Cs = {
1812
2381
  key: 0,
1813
2382
  class: "__label"
1814
- }, Re = /* @__PURE__ */ F({
2383
+ }, qe = /* @__PURE__ */ F({
1815
2384
  __name: "SidebarCheckbox",
1816
2385
  props: {
1817
2386
  disabled: { type: Boolean },
@@ -1822,257 +2391,409 @@ const $o = /* @__PURE__ */ F({
1822
2391
  emits: ["update:modelValue"],
1823
2392
  setup(n, { emit: e }) {
1824
2393
  const t = e;
1825
- return (s, o) => (d(), p("div", {
1826
- class: Y(["baklava-checkbox", { "--checked": n.inversed ? !n.modelValue : n.modelValue, "--disabled": n.disabled }]),
2394
+ return (s, o) => (p(), b("div", {
2395
+ class: ne(["baklava-checkbox", { "--checked": n.inversed ? !n.modelValue : n.modelValue, "--disabled": n.disabled }]),
1827
2396
  title: n.name,
1828
- onClick: o[0] || (o[0] = (a) => t("update:modelValue", !n.modelValue))
2397
+ onClick: o[0] || (o[0] = (r) => t("update:modelValue", !n.modelValue))
1829
2398
  }, [
1830
- o[1] || (o[1] = u("div", { class: "__checkmark-container" }, [
1831
- u("svg", {
2399
+ o[1] || (o[1] = m("div", { class: "__checkmark-container" }, [
2400
+ m("svg", {
1832
2401
  xmlns: "http://www.w3.org/2000/svg",
1833
2402
  width: "18",
1834
2403
  height: "18",
1835
2404
  viewBox: "0 0 18 18"
1836
2405
  }, [
1837
- u("path", {
2406
+ m("path", {
1838
2407
  class: "__checkmark",
1839
2408
  d: "M 6 5 L 6 10 L 16 10",
1840
2409
  transform: "rotate(-45 10 10)"
1841
2410
  })
1842
2411
  ])
1843
2412
  ], -1)),
1844
- n.name ? (d(), p("div", As, G(n.name), 1)) : M("", !0)
1845
- ], 10, Us));
2413
+ n.name ? (p(), b("div", Cs, L(n.name), 1)) : j("", !0)
2414
+ ], 10, _s));
1846
2415
  }
1847
- }), Ds = { class: "__header" }, Fs = { class: "__node-name" }, Ws = { class: "__interfaces" }, Ys = { class: "__inputs" }, Ks = { style: { display: "flex" } }, Xs = { class: "__outputs" }, qs = {
2416
+ }), ws = { class: "__header" }, ks = { class: "__node-name" }, xs = { class: "__interfaces" }, Is = { class: "__inputs" }, Ns = { style: { display: "flex" } }, Es = { class: "__outputs" }, Ts = {
1848
2417
  key: 0,
1849
2418
  class: "__interface"
1850
- }, Js = { style: { display: "flex" } }, Qs = /* @__PURE__ */ F({
2419
+ }, Os = { style: { display: "flex" } }, $s = /* @__PURE__ */ F({
1851
2420
  __name: "CodeGraphSidebar",
1852
2421
  setup(n) {
1853
- const { viewModel: e } = oe(), { graph: t } = ge(), s = V(null), o = Be(e.value.settings.sidebar, "width"), a = O(() => e.value.settings.sidebar.resizable);
1854
- let i = 0, r = 0;
1855
- const c = O(() => {
1856
- const f = t.value.sidebar.nodeId;
1857
- return t.value.nodes.find((N) => N.id === f);
1858
- }), h = O(() => c.value), g = O(() => ({
2422
+ const { viewModel: e } = me(), { graph: t } = Ge(), s = H(null), o = Me(e.value.settings.sidebar, "width"), r = P(() => e.value.settings.sidebar.resizable);
2423
+ let i = 0, a = 0;
2424
+ const l = P(() => {
2425
+ const y = t.value.sidebar.nodeId;
2426
+ return t.value.nodes.find((M) => M.id === y);
2427
+ }), d = P(() => l.value), f = P(() => ({
1859
2428
  width: `${o.value}px`
1860
- })), _ = O(() => h.value ? Object.values(h.value.inputs).filter((f) => f.displayInSidebar && f.component) : []), m = O(() => h.value ? Object.values(h.value.outputs).filter((f) => f.displayInSidebar && f.component) : []), k = () => {
2429
+ })), C = P(() => d.value ? Object.values(d.value.inputs).filter((y) => y.displayInSidebar && y.component) : []), h = P(() => d.value ? Object.values(d.value.outputs).filter((y) => y.displayInSidebar && y.component) : []), N = () => {
1861
2430
  t.value.sidebar.visible = !1;
1862
- }, b = () => {
1863
- c.value?.events.update.emit(null);
1864
- }, I = (f) => {
1865
- i = o.value, r = f.clientX, window.addEventListener("mousemove", l), window.addEventListener(
2431
+ }, v = () => {
2432
+ l.value?.events.update.emit(null);
2433
+ }, w = (y) => {
2434
+ i = o.value, a = y.clientX, window.addEventListener("mousemove", u), window.addEventListener(
1866
2435
  "mouseup",
1867
2436
  () => {
1868
- window.removeEventListener("mousemove", l);
2437
+ window.removeEventListener("mousemove", u);
1869
2438
  },
1870
2439
  { once: !0 }
1871
2440
  );
1872
- }, l = (f) => {
1873
- const N = s.value?.parentElement?.getBoundingClientRect().width ?? 500, y = f.clientX - r;
1874
- let T = i - y;
1875
- T < 300 ? T = 300 : T > 0.9 * N && (T = 0.9 * N), o.value = T;
2441
+ }, u = (y) => {
2442
+ const M = s.value?.parentElement?.getBoundingClientRect().width ?? 500, T = y.clientX - a;
2443
+ let S = i - T;
2444
+ S < 300 ? S = 300 : S > 0.9 * M && (S = 0.9 * M), o.value = S;
1876
2445
  };
1877
- return (f, N) => (d(), p("div", {
1878
- class: Y([{ "--open": w(t).sidebar.visible }, "baklava-sidebar"]),
1879
- style: ve(g.value),
2446
+ return (y, M) => (p(), b("div", {
2447
+ class: ne([{ "--open": O(t).sidebar.visible }, "baklava-sidebar"]),
2448
+ style: Pe(f.value),
1880
2449
  ref_key: "el",
1881
2450
  ref: s
1882
2451
  }, [
1883
- a.value ? (d(), p("div", {
2452
+ r.value ? (p(), b("div", {
1884
2453
  key: 0,
1885
2454
  class: "__resizer",
1886
- onMousedown: I
1887
- }, null, 32)) : M("", !0),
1888
- c.value ? (d(), p(B, { key: 1 }, [
1889
- u("div", Ds, [
1890
- u("button", {
2455
+ onMousedown: w
2456
+ }, null, 32)) : j("", !0),
2457
+ l.value ? (p(), b(U, { key: 1 }, [
2458
+ m("div", ws, [
2459
+ m("button", {
1891
2460
  tabindex: "-1",
1892
2461
  class: "__close",
1893
- onClick: k
2462
+ onClick: N
1894
2463
  }, "×"),
1895
- u("div", Fs, [
1896
- u("b", null, G(c.value.title), 1)
2464
+ m("div", ks, [
2465
+ m("b", null, L(l.value.title), 1)
1897
2466
  ])
1898
2467
  ]),
1899
- u("div", Ws, [
1900
- u("div", Ys, [
1901
- (d(!0), p(B, null, J(_.value, (y) => (d(), p("div", {
1902
- key: y.id,
2468
+ m("div", xs, [
2469
+ m("div", Is, [
2470
+ (p(!0), b(U, null, se(C.value, (T) => (p(), b("div", {
2471
+ key: T.id,
1903
2472
  class: "__interface"
1904
2473
  }, [
1905
- u("div", Ks, [
1906
- L(Re, {
1907
- modelValue: y.hidden,
2474
+ m("div", Ns, [
2475
+ G(qe, {
2476
+ modelValue: T.hidden,
1908
2477
  "onUpdate:modelValue": [
1909
- (T) => y.hidden = T,
1910
- N[0] || (N[0] = () => c.value?.events.update.emit(null))
2478
+ (S) => T.hidden = S,
2479
+ M[0] || (M[0] = () => l.value?.events.update.emit(null))
1911
2480
  ],
1912
- disabled: !y.optional,
2481
+ disabled: !T.optional,
1913
2482
  inversed: "",
1914
2483
  style: { "padding-right": "8px" }
1915
2484
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1916
- (d(), j(Me(y.component), {
1917
- modelValue: y.value,
1918
- "onUpdate:modelValue": (T) => y.value = T,
1919
- node: c.value,
1920
- intf: y,
2485
+ (p(), B(De(T.component), {
2486
+ modelValue: T.value,
2487
+ "onUpdate:modelValue": (S) => T.value = S,
2488
+ node: l.value,
2489
+ intf: T,
1921
2490
  style: { width: "100%" }
1922
2491
  }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1923
2492
  ])
1924
2493
  ]))), 128))
1925
2494
  ]),
1926
- u("div", Xs, [
1927
- h.value && h.value.state ? (d(), p("div", qs, [
1928
- N[3] || (N[3] = u("label", null, "Variable name", -1)),
1929
- de(u("input", {
1930
- "onUpdate:modelValue": N[1] || (N[1] = (y) => h.value.state.variableName = y),
2495
+ m("div", Es, [
2496
+ d.value && d.value.state ? (p(), b("div", Ts, [
2497
+ M[3] || (M[3] = m("label", null, "Variable name", -1)),
2498
+ ke(m("input", {
2499
+ "onUpdate:modelValue": M[1] || (M[1] = (T) => d.value.state.variableName = T),
1931
2500
  type: "text",
1932
2501
  class: "baklava-input",
1933
2502
  title: "Variable name",
1934
- onBlur: b,
1935
- onKeydown: he(b, ["enter"])
2503
+ onBlur: v,
2504
+ onKeydown: Oe(v, ["enter"])
1936
2505
  }, null, 544), [
1937
- [le, h.value.state.variableName]
2506
+ [xe, d.value.state.variableName]
1938
2507
  ])
1939
- ])) : M("", !0),
1940
- (d(!0), p(B, null, J(m.value, (y) => (d(), p("div", {
1941
- key: y.id,
2508
+ ])) : j("", !0),
2509
+ (p(!0), b(U, null, se(h.value, (T) => (p(), b("div", {
2510
+ key: T.id,
1942
2511
  class: "__interface"
1943
2512
  }, [
1944
- u("div", Js, [
1945
- L(Re, {
1946
- modelValue: y.hidden,
2513
+ m("div", Os, [
2514
+ G(qe, {
2515
+ modelValue: T.hidden,
1947
2516
  "onUpdate:modelValue": [
1948
- (T) => y.hidden = T,
1949
- N[2] || (N[2] = () => c.value?.events.update.emit(null))
2517
+ (S) => T.hidden = S,
2518
+ M[2] || (M[2] = () => l.value?.events.update.emit(null))
1950
2519
  ],
1951
- disabled: !y.optional,
2520
+ disabled: !T.optional,
1952
2521
  inversed: "",
1953
2522
  style: { "padding-right": "8px" }
1954
2523
  }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
1955
- (d(), j(Me(y.component), {
1956
- modelValue: y.value,
1957
- "onUpdate:modelValue": (T) => y.value = T,
1958
- node: c.value,
1959
- intf: y,
2524
+ (p(), B(De(T.component), {
2525
+ modelValue: T.value,
2526
+ "onUpdate:modelValue": (S) => T.value = S,
2527
+ node: l.value,
2528
+ intf: T,
1960
2529
  style: { width: "100%" }
1961
2530
  }, null, 8, ["modelValue", "onUpdate:modelValue", "node", "intf"]))
1962
2531
  ])
1963
2532
  ]))), 128))
1964
2533
  ])
1965
2534
  ]),
1966
- ne(f.$slots, "codeEditor", { node: c.value })
1967
- ], 64)) : M("", !0)
2535
+ q(y.$slots, "codeEditor", { node: l.value })
2536
+ ], 64)) : j("", !0)
1968
2537
  ], 6));
1969
2538
  }
2539
+ }), Ms = {
2540
+ class: "baklava-node --palette",
2541
+ style: { "margin-top": "-20px", "margin-bottom": "20px" }
2542
+ }, Ss = {
2543
+ key: 0,
2544
+ style: { display: "flex", "justify-content": "space-between" }
2545
+ }, Ps = ["onClick"], Gs = {
2546
+ key: 0,
2547
+ style: { margin: "auto 0", "font-size": "12px" }
2548
+ }, As = /* @__PURE__ */ F({
2549
+ __name: "CodeNodePalette",
2550
+ setup(n) {
2551
+ const e = $e.PaletteEntry, { viewModel: t } = me(), { x: s, y: o } = pn(), { transform: r } = Qt(), i = Zt(t), a = Ot("editorEl"), l = H(""), d = H(null), f = () => l.value ? i.value.filter(
2552
+ (v) => v.name.toLowerCase().includes(l.value.toLowerCase()) || Object.values(v.nodeTypes).some(
2553
+ (w) => w.title.toLowerCase().includes(l.value.toLowerCase())
2554
+ )
2555
+ ) : i.value, C = (v) => l.value ? Wo(v, (w) => {
2556
+ const u = w[1];
2557
+ return u.category.includes(l.value.toLowerCase()) || u.title?.toLowerCase().includes(l.value.toLowerCase());
2558
+ }) : v, h = P(() => {
2559
+ if (!d.value || !a?.value) return {};
2560
+ const { left: v, top: w } = a.value.getBoundingClientRect();
2561
+ return {
2562
+ top: `${o.value - w}px`,
2563
+ left: `${s.value - v}px`
2564
+ };
2565
+ }), N = (v, w) => {
2566
+ d.value = {
2567
+ type: v,
2568
+ nodeInformation: w
2569
+ };
2570
+ const u = () => {
2571
+ const y = te(new w.type());
2572
+ t.value.displayedGraph.addNode(y);
2573
+ const M = a.value.getBoundingClientRect(), [T, S] = r(s.value - M.left, o.value - M.top);
2574
+ y.position.x = T, y.position.y = S, d.value = null, document.removeEventListener("pointerup", u);
2575
+ };
2576
+ document.addEventListener("pointerup", u);
2577
+ };
2578
+ return (v, w) => (p(), b(U, null, [
2579
+ m("div", {
2580
+ class: ne([{ "--open": O(t).settings.palette.enabled }, "baklava-node-palette"]),
2581
+ onContextmenu: w[1] || (w[1] = le(() => {
2582
+ }, ["stop", "prevent"]))
2583
+ }, [
2584
+ m("div", Ms, [
2585
+ ke(m("input", {
2586
+ "onUpdate:modelValue": w[0] || (w[0] = (u) => l.value = u),
2587
+ type: "text",
2588
+ class: "baklava-input",
2589
+ title: "Filter nodes",
2590
+ onKeyup: f
2591
+ }, null, 544), [
2592
+ [xe, l.value]
2593
+ ])
2594
+ ]),
2595
+ (p(!0), b(U, null, se(f(), (u) => (p(), b("section", {
2596
+ key: u.name
2597
+ }, [
2598
+ u.name !== "default" ? (p(), b("h3", Ss, [
2599
+ m("div", {
2600
+ onClick: (y) => l.value = u.name,
2601
+ style: { cursor: "pointer" }
2602
+ }, L(u.name), 9, Ps),
2603
+ Object.keys(C(u.nodeTypes)).length < Object.values(u.nodeTypes).length ? (p(), b("div", Gs, " ( " + L(Object.keys(C(u.nodeTypes)).length) + " / " + L(Object.values(u.nodeTypes).length) + " ) ", 1)) : j("", !0)
2604
+ ])) : j("", !0),
2605
+ (p(!0), b(U, null, se(C(u.nodeTypes), (y, M) => (p(), B(O(e), {
2606
+ key: M,
2607
+ type: M,
2608
+ title: y.title,
2609
+ onPointerdown: (T) => N(M, y)
2610
+ }, null, 8, ["type", "title", "onPointerdown"]))), 128))
2611
+ ]))), 128))
2612
+ ], 34),
2613
+ G($t, { name: "fade" }, {
2614
+ default: ee(() => [
2615
+ d.value ? (p(), b("div", {
2616
+ key: 0,
2617
+ class: "baklava-dragged-node",
2618
+ style: Pe(h.value)
2619
+ }, [
2620
+ G(O(e), {
2621
+ type: d.value.type,
2622
+ title: d.value.nodeInformation.title
2623
+ }, null, 8, ["type", "title"])
2624
+ ], 4)) : j("", !0)
2625
+ ]),
2626
+ _: 1
2627
+ })
2628
+ ], 64));
2629
+ }
2630
+ }), Rs = {}, js = { class: "prependIcon" }, Ls = { class: "appendIcon" };
2631
+ function Vs(n, e) {
2632
+ const t = Ze("router-link");
2633
+ return p(), B(t, { class: "navItem" }, {
2634
+ default: ee(() => [
2635
+ m("span", js, [
2636
+ q(n.$slots, "prependIcon")
2637
+ ]),
2638
+ q(n.$slots, "default"),
2639
+ m("span", Ls, [
2640
+ q(n.$slots, "appendIcon")
2641
+ ])
2642
+ ]),
2643
+ _: 3
2644
+ });
2645
+ }
2646
+ const Je = /* @__PURE__ */ A(Rs, [["render", Vs]]), Bs = { class: "navbar" }, Hs = ["onClick"], xr = /* @__PURE__ */ F({
2647
+ __name: "NavBar",
2648
+ props: {
2649
+ viewModel: {},
2650
+ editorStates: {},
2651
+ routes: {}
2652
+ },
2653
+ emits: ["click:remove"],
2654
+ setup(n, { emit: e }) {
2655
+ const t = e, s = (o) => {
2656
+ t("click:remove", o);
2657
+ };
2658
+ return (o, r) => (p(), b("nav", Bs, [
2659
+ q(o.$slots, "prepend"),
2660
+ (p(!0), b(U, null, se(n.editorStates, (i) => (p(), B(Je, {
2661
+ key: i.graph.id,
2662
+ class: ne({ active: i.graph.id === n.viewModel.displayedGraph.id }),
2663
+ to: { name: n.routes?.edit ?? "edit", params: { editorId: i.graph.id } }
2664
+ }, {
2665
+ appendIcon: ee(() => [
2666
+ m("button", {
2667
+ class: "remove",
2668
+ onClick: le((a) => s(i.graph.id), ["prevent"])
2669
+ }, [
2670
+ G(O(Vo))
2671
+ ], 8, Hs)
2672
+ ]),
2673
+ default: ee(() => [
2674
+ ot(L(i.graph.id.slice(0, 6)) + " ", 1)
2675
+ ]),
2676
+ _: 2
2677
+ }, 1032, ["class", "to"]))), 128)),
2678
+ q(o.$slots, "append", {}, () => [
2679
+ G(Je, {
2680
+ to: { name: n.routes?.new ?? "new" },
2681
+ class: "navItem"
2682
+ }, {
2683
+ default: ee(() => [
2684
+ G(O(yo), { class: "plus" })
2685
+ ]),
2686
+ _: 1
2687
+ }, 8, ["to"])
2688
+ ])
2689
+ ]));
2690
+ }
1970
2691
  });
1971
- class at extends Qe {
2692
+ class wt extends _t {
1972
2693
  _title = "Subgraph Input";
1973
2694
  inputs = {
1974
- _code: new R("", "").use($, U).setHidden(!0),
1975
- name: new be("Name", "Input").setPort(!1)
2695
+ _code: new D("", "").use(V, X).setHidden(!0),
2696
+ name: new Ae("Name", "Input").setPort(!1)
1976
2697
  };
1977
2698
  outputs = {
1978
- _code: new R("", "").use($, U).setHidden(!0),
1979
- placeholder: new A("Connection", void 0)
2699
+ _code: new D("", "").use(V, X).setHidden(!0),
2700
+ placeholder: new J("Connection", void 0)
1980
2701
  };
1981
2702
  }
1982
- class it extends Ze {
2703
+ class kt extends Ct {
1983
2704
  _title = "Subgraph Output";
1984
2705
  inputs = {
1985
- _code: new R("", "").use($, U).setHidden(!0),
1986
- name: new be("Name", "Output").setPort(!1),
1987
- placeholder: new A("Connection", void 0)
2706
+ _code: new D("", "").use(V, X).setHidden(!0),
2707
+ name: new Ae("Name", "Output").setPort(!1),
2708
+ placeholder: new J("Connection", void 0)
1988
2709
  };
1989
2710
  outputs = {
1990
- _code: new R("", "").use($, U).setHidden(!0),
1991
- output: new A("Output", void 0).setHidden(!0)
2711
+ _code: new D("", "").use(V, X).setHidden(!0),
2712
+ output: new J("Output", void 0).setHidden(!0)
1992
2713
  };
1993
2714
  }
1994
- const Zs = "CREATE_SUBGRAPH", je = [kt, Nt];
1995
- function eo(n, e, t) {
1996
- const s = () => n.value.selectedNodes.filter((a) => !je.includes(a.type)).length > 0, o = () => {
1997
- const { viewModel: a } = oe(), i = n.value, r = n.value.editor;
2715
+ const zs = "CREATE_SUBGRAPH", Qe = [Rt, jt];
2716
+ function Us(n, e, t) {
2717
+ const s = () => n.value.selectedNodes.filter((r) => !Qe.includes(r.type)).length > 0, o = () => {
2718
+ const { viewModel: r } = me(), i = n.value, a = n.value.editor;
1998
2719
  if (i.selectedNodes.length === 0) return;
1999
- const c = i.selectedNodes.filter((v) => !je.includes(v.type)), h = c.flatMap((v) => Object.values(v.inputs)), g = c.flatMap((v) => Object.values(v.outputs)), _ = i.connections.filter(
2000
- (v) => !g.includes(v.from) && h.includes(v.to)
2001
- ), m = i.connections.filter(
2002
- (v) => g.includes(v.from) && !h.includes(v.to)
2003
- ), k = i.connections.filter(
2004
- (v) => g.includes(v.from) && h.includes(v.to)
2005
- ), b = c.map((v) => v.save()), I = k.map((v) => ({
2006
- id: v.id,
2007
- from: v.from.id,
2008
- to: v.to.id
2009
- })), l = /* @__PURE__ */ new Map(), { xLeft: f, xRight: N, yTop: y } = to(c);
2010
- for (const [v, S] of _.entries()) {
2011
- const H = new at();
2012
- H.inputs.name.value = S.to.name, b.push({
2013
- ...H.save(),
2014
- position: { x: N - a.value.settings.nodes.defaultWidth - 100, y: y + v * 200 }
2015
- }), I.push({ id: K(), from: H.outputs.placeholder.id, to: S.to.id }), l.set(S.to.id, H.graphInterfaceId);
2720
+ const l = i.selectedNodes.filter((k) => !Qe.includes(k.type)), d = l.flatMap((k) => Object.values(k.inputs)), f = l.flatMap((k) => Object.values(k.outputs)), C = i.connections.filter(
2721
+ (k) => !f.includes(k.from) && d.includes(k.to)
2722
+ ), h = i.connections.filter(
2723
+ (k) => f.includes(k.from) && !d.includes(k.to)
2724
+ ), N = i.connections.filter(
2725
+ (k) => f.includes(k.from) && d.includes(k.to)
2726
+ ), v = l.map((k) => k.save()), w = N.map((k) => ({
2727
+ id: k.id,
2728
+ from: k.from.id,
2729
+ to: k.to.id
2730
+ })), u = /* @__PURE__ */ new Map(), { xLeft: y, xRight: M, yTop: T } = Ds(l);
2731
+ for (const [k, R] of C.entries()) {
2732
+ const z = new wt();
2733
+ z.inputs.name.value = R.to.name, v.push({
2734
+ ...z.save(),
2735
+ position: { x: M - r.value.settings.nodes.defaultWidth - 100, y: T + k * 200 }
2736
+ }), w.push({ id: re(), from: z.outputs.placeholder.id, to: R.to.id }), u.set(R.to.id, z.graphInterfaceId);
2016
2737
  }
2017
- for (const [v, S] of m.entries()) {
2018
- const H = new it();
2019
- H.inputs.name.value = S.from.name, b.push({
2020
- ...H.save(),
2021
- position: { x: f + 100, y: y + v * 200 }
2022
- }), I.push({ id: K(), from: S.from.id, to: H.inputs.placeholder.id }), l.set(S.from.id, H.graphInterfaceId);
2738
+ for (const [k, R] of h.entries()) {
2739
+ const z = new kt();
2740
+ z.inputs.name.value = R.from.name, v.push({
2741
+ ...z.save(),
2742
+ position: { x: y + 100, y: T + k * 200 }
2743
+ }), w.push({ id: re(), from: R.from.id, to: z.inputs.placeholder.id }), u.set(R.from.id, z.graphInterfaceId);
2023
2744
  }
2024
- const T = D(
2025
- new ce(
2745
+ const S = te(
2746
+ new Ne(
2026
2747
  {
2027
- connections: I,
2028
- nodes: b,
2748
+ connections: w,
2749
+ nodes: v,
2029
2750
  // ignored, but still providing to make TS happy
2030
2751
  inputs: [],
2031
2752
  outputs: []
2032
2753
  },
2033
- r
2754
+ a
2034
2755
  )
2035
2756
  );
2036
- r.addGraphTemplate(T);
2037
- const ie = r.nodeTypes.get(Ue(T));
2038
- if (!ie) throw new Error("Unable to create subgraph: Could not find corresponding graph node type");
2757
+ a.addGraphTemplate(S);
2758
+ const Q = a.nodeTypes.get(st(S));
2759
+ if (!Q) throw new Error("Unable to create subgraph: Could not find corresponding graph node type");
2039
2760
  i.activeTransactions++;
2040
- const W = D(new ie.type());
2041
- i.addNode(W);
2761
+ const Z = te(new Q.type());
2762
+ i.addNode(Z);
2042
2763
  const pe = Math.round(
2043
- c.map((v) => v.position.x).reduce((v, S) => v + S, 0) / c.length
2044
- ), re = Math.round(
2045
- c.map((v) => v.position.y).reduce((v, S) => v + S, 0) / c.length
2764
+ l.map((k) => k.position.x).reduce((k, R) => k + R, 0) / l.length
2765
+ ), K = Math.round(
2766
+ l.map((k) => k.position.y).reduce((k, R) => k + R, 0) / l.length
2046
2767
  );
2047
- W.position.x = pe, W.position.y = re, _.forEach((v) => {
2048
- i.removeConnection(v), i.addConnection(v.from, W.inputs[l.get(v.to.id)]);
2049
- }), m.forEach((v) => {
2050
- i.removeConnection(v), i.addConnection(W.outputs[l.get(v.from.id)], v.to);
2051
- }), c.forEach((v) => i.removeNode(v)), i.activeTransactions--, e.canExecuteCommand(q.SAVE_SUBGRAPH_COMMAND) && e.executeCommand(q.SAVE_SUBGRAPH_COMMAND), t(T), n.value.panning = { ...i.panning }, n.value.scaling = i.scaling;
2768
+ Z.position.x = pe, Z.position.y = K, C.forEach((k) => {
2769
+ i.removeConnection(k), i.addConnection(k.from, Z.inputs[u.get(k.to.id)]);
2770
+ }), h.forEach((k) => {
2771
+ i.removeConnection(k), i.addConnection(Z.outputs[u.get(k.from.id)], k.to);
2772
+ }), l.forEach((k) => i.removeNode(k)), i.activeTransactions--, e.canExecuteCommand(ue.SAVE_SUBGRAPH_COMMAND) && e.executeCommand(ue.SAVE_SUBGRAPH_COMMAND), t(S), n.value.panning = { ...i.panning }, n.value.scaling = i.scaling;
2052
2773
  };
2053
- e.registerCommand(Zs, {
2774
+ e.registerCommand(zs, {
2054
2775
  canExecute: s,
2055
2776
  execute: o
2056
2777
  });
2057
2778
  }
2058
- function to(n) {
2059
- const e = n.reduce((o, a) => {
2060
- const i = a.position.x;
2779
+ function Ds(n) {
2780
+ const e = n.reduce((o, r) => {
2781
+ const i = r.position.x;
2061
2782
  return i < o ? i : o;
2062
- }, 1 / 0), t = n.reduce((o, a) => {
2063
- const i = a.position.y;
2783
+ }, 1 / 0), t = n.reduce((o, r) => {
2784
+ const i = r.position.y;
2064
2785
  return i < o ? i : o;
2065
2786
  }, 1 / 0);
2066
- return { xLeft: n.reduce((o, a) => {
2067
- const i = a.position.x + a.width;
2787
+ return { xLeft: n.reduce((o, r) => {
2788
+ const i = r.position.x + r.width;
2068
2789
  return i > o ? i : o;
2069
2790
  }, -1 / 0), xRight: e, yTop: t };
2070
2791
  }
2071
- class no extends xt {
2792
+ class Fs extends Lt {
2072
2793
  code;
2073
2794
  graph;
2074
2795
  constructor(e) {
2075
- super(), this.code = e, this.graph = new ue(this);
2796
+ super(), this.code = e, this.graph = new Ie(this);
2076
2797
  }
2077
2798
  get graphIds() {
2078
2799
  const e = [];
@@ -2089,7 +2810,7 @@ class no extends xt {
2089
2810
  addGraphTemplate(e) {
2090
2811
  if (this.events.beforeAddGraphTemplate.emit(e).prevented) return;
2091
2812
  this._graphTemplates.push(e), this.graphTemplateEvents.addTarget(e.events), this.graphTemplateHooks.addTarget(e.hooks);
2092
- const t = mn(e);
2813
+ const t = Fo(e);
2093
2814
  this.registerNodeType(t, { category: "Subgraphs", title: e.name }), this.events.addGraphTemplate.emit(e);
2094
2815
  }
2095
2816
  /**
@@ -2102,7 +2823,7 @@ class no extends xt {
2102
2823
  for (super._loading = !0, e = this.hooks.load.execute(e); this.graphTemplates.length > 0; )
2103
2824
  this.removeGraphTemplate(this.graphTemplates[0]);
2104
2825
  e.graphTemplates.forEach((s) => {
2105
- const o = new ce(s, this);
2826
+ const o = new Ne(s, this);
2106
2827
  this.addGraphTemplate(o);
2107
2828
  });
2108
2829
  const t = this.graph.load(e.graph);
@@ -2120,113 +2841,123 @@ class no extends xt {
2120
2841
  this.code.state.modules[e] = t;
2121
2842
  }
2122
2843
  }
2123
- function Go(n) {
2124
- const e = V(n?.code ?? new fn()), t = V(n?.existingEditor ?? new no(e.value)), s = Symbol("ViewModelToken"), o = V(null), a = _t(o), { switchGraph: i } = Is(t, o), r = O(() => a.value && a.value !== t.value.graph), c = D(Ut());
2125
- c.nodes.defaultWidth = 400;
2126
- const h = At(), g = Dt(a, h), _ = Ft(a, t, h), m = {
2844
+ function Ir(n) {
2845
+ const e = H(n?.code ?? new ze()), t = H(n?.existingEditor ?? new Fs(e.value)), s = Symbol("ViewModelToken"), o = H(null), r = Mt(o), { switchGraph: i } = Ko(t, o), a = P(() => r.value && r.value !== t.value.graph), l = te(en());
2846
+ l.nodes.defaultWidth = 400;
2847
+ const d = tn(), f = nn(r, d), C = on(r, t, d), h = {
2127
2848
  /** Called whenever a node is rendered */
2128
- renderNode: new Ge(null),
2849
+ renderNode: new Fe(null),
2129
2850
  /** Called whenever an interface is rendered */
2130
- renderInterface: new Ge(null)
2131
- }, k = D({
2132
- clipboard: _,
2851
+ renderInterface: new Fe(null)
2852
+ }, N = te({
2853
+ clipboard: C,
2133
2854
  code: e,
2134
- commandHandler: h,
2135
- displayedGraph: a,
2855
+ commandHandler: d,
2856
+ displayedGraph: r,
2136
2857
  editor: t,
2137
- history: g,
2138
- hooks: m,
2139
- isSubgraph: r,
2140
- settings: c,
2858
+ history: f,
2859
+ hooks: h,
2860
+ isSubgraph: a,
2861
+ settings: l,
2141
2862
  switchGraph: i
2142
2863
  });
2143
- return e.value.registerViewModel(k), bs(k), Wt(a, h), eo(a, h, i), Yt(a, h), Kt(a, h, i), Xt(a, h), qt(a, h, c), fs(a, h, c), vs(c), He(
2864
+ return e.value.registerViewModel(N), Uo(N), sn(r, d), Us(r, d, i), rn(r, d), an(r, d, i), ln(r, d), un(r, d, l), Bo(r, d, l), Ho(l), tt(
2144
2865
  t,
2145
- (b, I) => {
2146
- I && (I.events.registerGraph.unsubscribe(s), I.graphEvents.beforeAddNode.unsubscribe(s), b.nodeHooks.beforeLoad.unsubscribe(s), b.nodeHooks.afterSave.unsubscribe(s), b.graphTemplateHooks.beforeLoad.unsubscribe(s), b.graphTemplateHooks.afterSave.unsubscribe(s), b.graph.hooks.load.unsubscribe(s), b.graph.hooks.save.unsubscribe(s)), b && (b.nodeHooks.beforeLoad.subscribe(s, (l, f) => (f.position = l.position ?? { x: 0, y: 0 }, f.width = l.width ?? c.nodes.defaultWidth, f.twoColumn = l.twoColumn ?? !1, l)), b.nodeHooks.afterSave.subscribe(s, (l, f) => (l.position = f.position, l.width = f.width, l.twoColumn = f.twoColumn, l)), b.graphTemplateHooks.beforeLoad.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graphTemplateHooks.afterSave.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graph.hooks.load.subscribe(s, (l, f) => (f.panning = l.panning, f.scaling = l.scaling, l)), b.graph.hooks.save.subscribe(s, (l, f) => (l.panning = f.panning, l.scaling = f.scaling, l)), b.graphEvents.beforeAddNode.subscribe(
2866
+ (v, w) => {
2867
+ w && (w.events.registerGraph.unsubscribe(s), w.graphEvents.beforeAddNode.unsubscribe(s), v.nodeHooks.beforeLoad.unsubscribe(s), v.nodeHooks.afterSave.unsubscribe(s), v.graphTemplateHooks.beforeLoad.unsubscribe(s), v.graphTemplateHooks.afterSave.unsubscribe(s), v.graph.hooks.load.unsubscribe(s), v.graph.hooks.save.unsubscribe(s)), v && (v.nodeHooks.beforeLoad.subscribe(s, (u, y) => (y.position = u.position ?? { x: 0, y: 0 }, y.width = u.width ?? l.nodes.defaultWidth, y.twoColumn = u.twoColumn ?? !1, u)), v.nodeHooks.afterSave.subscribe(s, (u, y) => (u.position = y.position, u.width = y.width, u.twoColumn = y.twoColumn, u)), v.graphTemplateHooks.beforeLoad.subscribe(s, (u, y) => (y.panning = u.panning, y.scaling = u.scaling, u)), v.graphTemplateHooks.afterSave.subscribe(s, (u, y) => (u.panning = y.panning, u.scaling = y.scaling, u)), v.graph.hooks.load.subscribe(s, (u, y) => (y.panning = u.panning, y.scaling = u.scaling, u)), v.graph.hooks.save.subscribe(s, (u, y) => (u.panning = y.panning, u.scaling = y.scaling, u)), v.graphEvents.beforeAddNode.subscribe(
2147
2868
  s,
2148
- (l) => Jt(l, { defaultWidth: c.nodes.defaultWidth })
2149
- ), t.value.registerNodeType(at, { category: "Subgraphs" }), t.value.registerNodeType(it, { category: "Subgraphs" }), i(b.graph));
2869
+ (u) => dn(u, { defaultWidth: l.nodes.defaultWidth })
2870
+ ), t.value.registerNodeType(wt, { category: "Subgraphs" }), t.value.registerNodeType(kt, { category: "Subgraphs" }), i(v.graph));
2150
2871
  },
2151
2872
  { immediate: !0 }
2152
- ), k;
2873
+ ), N;
2153
2874
  }
2154
2875
  export {
2155
- We as AbstractCodeNode,
2156
- et as CLEAR_ALL_COMMAND,
2157
- Zs as CREATE_SUBGRAPH_COMMAND,
2158
- fo as CheckboxInterface,
2159
- fn as Code,
2160
- vn as CodeEngine,
2161
- ue as CodeGraph,
2162
- $o as CodeGraphEditor,
2163
- Mo as CodeGraphInfo,
2164
- Qe as CodeGraphInputNode,
2165
- Ps as CodeGraphNode,
2166
- Ve as CodeGraphNodeInterface,
2167
- Ze as CodeGraphOutputNode,
2168
- Qs as CodeGraphSidebar,
2169
- ce as CodeGraphTemplate,
2170
- _e as CodeNode,
2171
- ae as CodeNodeInputInterface,
2172
- R as CodeNodeInterface,
2173
- ye as CodeNodeInterfaceComponent,
2174
- on as CodeNodeOutputInterface,
2175
- Ls as CodeNodePalette,
2176
- yn as CodeVariable,
2177
- kn as DotsVertical,
2178
- pn as DynamicCodeNode,
2179
- Se as GRAPH_INPUT_NODE_TYPE,
2180
- Pe as GRAPH_OUTPUT_NODE_TYPE,
2181
- vo as IntegerInterface,
2182
- Tn as LayoutSidebarLeftCollapse,
2183
- Gn as LayoutSidebarLeftExpand,
2184
- Rn as LayoutSidebarRight,
2185
- Hn as LayoutSidebarRightCollapse,
2186
- Dn as LayoutSidebarRightExpand,
2187
- go as ListInputInterface,
2188
- Kn as LockCode,
2189
- bo as NumberInterface,
2190
- Qn as PlayerPlay,
2191
- tt as RUN_ENGINE_COMMAND,
2192
- ns as Schema,
2193
- is as SchemaOff,
2194
- _o as SelectInterface,
2195
- Re as SidebarCheckbox,
2196
- yo as SliderInterface,
2197
- at as SubgraphInputNode,
2198
- it as SubgraphOutputNode,
2199
- nt as TOGGLE_MINIMAP_COMMAND,
2200
- st as TOGGLE_PALETTE_COMMAND,
2201
- Co as TextInputInterface,
2202
- cn as TextInputInterfaceComponent,
2203
- Io as TextareaInputInterface,
2204
- us as TransitionBottom,
2205
- ms as TrashOff,
2206
- wo as TupleInputInterface,
2207
- mo as addDefaultInterfaceTypes,
2208
- Oo as allowMultipleConnections,
2209
- Ke as booleanType,
2210
- mn as createCodeGraphNodeType,
2211
- ko as defineCodeNode,
2212
- No as defineDynamicCodeNode,
2213
- sn as dictType,
2214
- en as formatInputs,
2215
- ot as getCodeNodes,
2216
- To as getPositionAtColumn,
2217
- Eo as getPositionBeforeNode,
2218
- Xe as listType,
2219
- Ye as loadNodeState,
2220
- U as nodeType,
2221
- Ce as numberType,
2222
- bs as registerCodeEngine,
2223
- eo as registerCreateSubgraphCommand,
2224
- fs as registerCustomCommands,
2225
- gs as registerRunEngineCommands,
2226
- tn as saveNodeState,
2227
- Ie as stringType,
2228
- qe as tupleType,
2229
- vs as updateToolbarItems,
2230
- Go as useCodeGraph,
2231
- Is as useSwitchCodeGraph
2876
+ lt as AbstractCodeNode,
2877
+ ft as CLEAR_ALL_COMMAND,
2878
+ zs as CREATE_SUBGRAPH_COMMAND,
2879
+ On as Check,
2880
+ sr as CheckboxInterface,
2881
+ ze as Code,
2882
+ Cr as CodeEditor,
2883
+ In as CodeEngine,
2884
+ Ie as CodeGraph,
2885
+ wr as CodeGraphEditor,
2886
+ kr as CodeGraphInfo,
2887
+ _t as CodeGraphInputNode,
2888
+ gs as CodeGraphNode,
2889
+ Ke as CodeGraphNodeInterface,
2890
+ Ct as CodeGraphOutputNode,
2891
+ $s as CodeGraphSidebar,
2892
+ Ne as CodeGraphTemplate,
2893
+ Re as CodeNode,
2894
+ ve as CodeNodeInputInterface,
2895
+ D as CodeNodeInterface,
2896
+ je as CodeNodeInterfaceComponent,
2897
+ gn as CodeNodeOutputInterface,
2898
+ As as CodeNodePalette,
2899
+ Pn as CodeVariable,
2900
+ jn as Copy,
2901
+ os as CopyToClipboard,
2902
+ Hn as DotsVertical,
2903
+ xn as DynamicCodeNode,
2904
+ We as GRAPH_INPUT_NODE_TYPE,
2905
+ Ye as GRAPH_OUTPUT_NODE_TYPE,
2906
+ rr as IntegerInterface,
2907
+ vr as JavascriptCode,
2908
+ Fn as LayoutSidebarLeftCollapse,
2909
+ Kn as LayoutSidebarLeftExpand,
2910
+ Zn as LayoutSidebarRight,
2911
+ oo as LayoutSidebarRightCollapse,
2912
+ io as LayoutSidebarRightExpand,
2913
+ ar as ListInputInterface,
2914
+ ht as LockCode,
2915
+ xr as NavBar,
2916
+ Je as NavItem,
2917
+ ir as NumberInterface,
2918
+ mo as PlayerPlay,
2919
+ yo as Plus,
2920
+ mr as PythonCode,
2921
+ mt as RUN_ENGINE_COMMAND,
2922
+ ko as Schema,
2923
+ Eo as SchemaOff,
2924
+ lr as SelectInterface,
2925
+ qe as SidebarCheckbox,
2926
+ ur as SliderInterface,
2927
+ wt as SubgraphInputNode,
2928
+ kt as SubgraphOutputNode,
2929
+ vt as TOGGLE_MINIMAP_COMMAND,
2930
+ gt as TOGGLE_PALETTE_COMMAND,
2931
+ dr as TextInputInterface,
2932
+ kn as TextInputInterfaceComponent,
2933
+ cr as TextareaInputInterface,
2934
+ Mo as TransitionBottom,
2935
+ Ao as TrashOff,
2936
+ pr as TupleInputInterface,
2937
+ Vo as X,
2938
+ or as addDefaultInterfaceTypes,
2939
+ gr as allowMultipleConnections,
2940
+ dt as booleanType,
2941
+ Fo as createCodeGraphNodeType,
2942
+ hr as defineCodeNode,
2943
+ fr as defineDynamicCodeNode,
2944
+ vn as dictType,
2945
+ hn as formatInputs,
2946
+ bt as getCodeNodes,
2947
+ br as getPositionAtColumn,
2948
+ yr as getPositionBeforeNode,
2949
+ ct as listType,
2950
+ ut as loadNodeState,
2951
+ X as nodeType,
2952
+ Le as numberType,
2953
+ Uo as registerCodeEngine,
2954
+ Us as registerCreateSubgraphCommand,
2955
+ Bo as registerCustomCommands,
2956
+ zo as registerRunEngineCommands,
2957
+ fn as saveNodeState,
2958
+ Ve as stringType,
2959
+ pt as tupleType,
2960
+ Ho as updateToolbarItems,
2961
+ Ir as useCodeGraph,
2962
+ Ko as useSwitchCodeGraph
2232
2963
  };