sldeditor 0.15.0 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sldeditor.js CHANGED
@@ -2,8 +2,8 @@ var a2 = Object.defineProperty;
2
2
  var l2 = (e, t, n) => t in e ? a2(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var Mt = (e, t, n) => l2(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as C, jsx as f, Fragment as Ke } from "react/jsx-runtime";
5
- import * as Ee from "react";
6
- import tn, { forwardRef as Ni, createElement as co, useState as ve, useRef as fe, useCallback as yn, useMemo as Ai, useLayoutEffect as An, useEffect as se, createContext as Ti, useContext as Mi, useId as c2, cloneElement as d2, Fragment as u2 } from "react";
5
+ import * as Ne from "react";
6
+ import tn, { forwardRef as Ni, createElement as co, useState as xe, useRef as fe, useCallback as yn, useMemo as Ai, useLayoutEffect as An, useEffect as se, createContext as Ti, useContext as Mi, useId as c2, cloneElement as d2, Fragment as u2 } from "react";
7
7
  import { createPortal as Ci } from "react-dom";
8
8
  /**
9
9
  * @license lucide-react v0.469.0 - ISC
@@ -708,12 +708,12 @@ const Po = "-", j2 = (e) => {
708
708
  }
709
709
  x === "[" ? c++ : x === "]" && c--;
710
710
  }
711
- const m = l.length === 0 ? a : a.substring(d), g = m.startsWith(Yi), p = g ? m.substring(1) : m, h = u && u > d ? u - d : void 0;
711
+ const h = l.length === 0 ? a : a.substring(d), g = h.startsWith(Yi), m = g ? h.substring(1) : h, p = u && u > d ? u - d : void 0;
712
712
  return {
713
713
  modifiers: l,
714
714
  hasImportantModifier: g,
715
- baseClassName: p,
716
- maybePostfixModifierPosition: h
715
+ baseClassName: m,
716
+ maybePostfixModifierPosition: p
717
717
  };
718
718
  };
719
719
  return n ? (a) => n({
@@ -743,28 +743,28 @@ const Po = "-", j2 = (e) => {
743
743
  const c = s[l], {
744
744
  modifiers: d,
745
745
  hasImportantModifier: u,
746
- baseClassName: m,
746
+ baseClassName: h,
747
747
  maybePostfixModifierPosition: g
748
748
  } = n(c);
749
- let p = !!g, h = o(p ? m.substring(0, g) : m);
750
- if (!h) {
751
- if (!p) {
749
+ let m = !!g, p = o(m ? h.substring(0, g) : h);
750
+ if (!p) {
751
+ if (!m) {
752
752
  a = c + (a.length > 0 ? " " + a : a);
753
753
  continue;
754
754
  }
755
- if (h = o(m), !h) {
755
+ if (p = o(h), !p) {
756
756
  a = c + (a.length > 0 ? " " + a : a);
757
757
  continue;
758
758
  }
759
- p = !1;
759
+ m = !1;
760
760
  }
761
- const b = H2(d).join(":"), x = u ? b + Yi : b, v = x + h;
761
+ const b = H2(d).join(":"), x = u ? b + Yi : b, v = x + p;
762
762
  if (i.includes(v))
763
763
  continue;
764
764
  i.push(v);
765
- const P = r(h, p);
766
- for (let j = 0; j < P.length; ++j) {
767
- const F = P[j];
765
+ const P = r(p, m);
766
+ for (let O = 0; O < P.length; ++O) {
767
+ const F = P[O];
768
768
  i.push(x + F);
769
769
  }
770
770
  a = c + (a.length > 0 ? " " + a : a);
@@ -814,7 +814,7 @@ const be = (e) => {
814
814
  // I could also use lookbehind assertion in `lengthUnitRegex` but that isn't supported widely enough.
815
815
  J2.test(e) && !Z2.test(e)
816
816
  ), Ui = () => !1, ck = (e) => Q2.test(e), dk = (e) => ek.test(e), uk = () => {
817
- const e = be("colors"), t = be("spacing"), n = be("blur"), o = be("brightness"), r = be("borderColor"), i = be("borderRadius"), s = be("borderSpacing"), a = be("borderWidth"), l = be("contrast"), c = be("grayscale"), d = be("hueRotate"), u = be("invert"), m = be("gap"), g = be("gradientColorStops"), p = be("gradientColorStopPositions"), h = be("inset"), b = be("margin"), x = be("opacity"), v = be("padding"), P = be("saturate"), j = be("scale"), F = be("sepia"), G = be("skew"), $ = be("space"), H = be("translate"), W = () => ["auto", "contain", "none"], X = () => ["auto", "hidden", "clip", "visible", "scroll"], I = () => ["auto", re, t], R = () => [re, t], Z = () => ["", We, tt], ae = () => ["auto", bt, re], he = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], ee = () => ["solid", "dashed", "dotted", "double", "none"], le = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], ge = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], ke = () => ["", "0", re], Ae = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Oe = () => [bt, re];
817
+ const e = be("colors"), t = be("spacing"), n = be("blur"), o = be("brightness"), r = be("borderColor"), i = be("borderRadius"), s = be("borderSpacing"), a = be("borderWidth"), l = be("contrast"), c = be("grayscale"), d = be("hueRotate"), u = be("invert"), h = be("gap"), g = be("gradientColorStops"), m = be("gradientColorStopPositions"), p = be("inset"), b = be("margin"), x = be("opacity"), v = be("padding"), P = be("saturate"), O = be("scale"), F = be("sepia"), G = be("skew"), $ = be("space"), H = be("translate"), W = () => ["auto", "contain", "none"], X = () => ["auto", "hidden", "clip", "visible", "scroll"], I = () => ["auto", re, t], R = () => [re, t], Z = () => ["", We, tt], ae = () => ["auto", bt, re], he = () => ["bottom", "center", "left", "left-bottom", "left-top", "right", "right-bottom", "right-top", "top"], ee = () => ["solid", "dashed", "dotted", "double", "none"], le = () => ["normal", "multiply", "screen", "overlay", "darken", "lighten", "color-dodge", "color-burn", "hard-light", "soft-light", "difference", "exclusion", "hue", "saturation", "color", "luminosity"], ge = () => ["start", "end", "center", "between", "around", "evenly", "stretch"], ke = () => ["", "0", re], Ae = () => ["auto", "avoid", "all", "avoid-page", "page", "left", "right", "column"], Oe = () => [bt, re];
818
818
  return {
819
819
  cacheSize: 500,
820
820
  separator: ":",
@@ -991,63 +991,63 @@ const be = (e) => {
991
991
  * @see https://tailwindcss.com/docs/top-right-bottom-left
992
992
  */
993
993
  inset: [{
994
- inset: [h]
994
+ inset: [p]
995
995
  }],
996
996
  /**
997
997
  * Right / Left
998
998
  * @see https://tailwindcss.com/docs/top-right-bottom-left
999
999
  */
1000
1000
  "inset-x": [{
1001
- "inset-x": [h]
1001
+ "inset-x": [p]
1002
1002
  }],
1003
1003
  /**
1004
1004
  * Top / Bottom
1005
1005
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1006
1006
  */
1007
1007
  "inset-y": [{
1008
- "inset-y": [h]
1008
+ "inset-y": [p]
1009
1009
  }],
1010
1010
  /**
1011
1011
  * Start
1012
1012
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1013
1013
  */
1014
1014
  start: [{
1015
- start: [h]
1015
+ start: [p]
1016
1016
  }],
1017
1017
  /**
1018
1018
  * End
1019
1019
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1020
1020
  */
1021
1021
  end: [{
1022
- end: [h]
1022
+ end: [p]
1023
1023
  }],
1024
1024
  /**
1025
1025
  * Top
1026
1026
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1027
1027
  */
1028
1028
  top: [{
1029
- top: [h]
1029
+ top: [p]
1030
1030
  }],
1031
1031
  /**
1032
1032
  * Right
1033
1033
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1034
1034
  */
1035
1035
  right: [{
1036
- right: [h]
1036
+ right: [p]
1037
1037
  }],
1038
1038
  /**
1039
1039
  * Bottom
1040
1040
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1041
1041
  */
1042
1042
  bottom: [{
1043
- bottom: [h]
1043
+ bottom: [p]
1044
1044
  }],
1045
1045
  /**
1046
1046
  * Left
1047
1047
  * @see https://tailwindcss.com/docs/top-right-bottom-left
1048
1048
  */
1049
1049
  left: [{
1050
- left: [h]
1050
+ left: [p]
1051
1051
  }],
1052
1052
  /**
1053
1053
  * Visibility
@@ -1197,21 +1197,21 @@ const be = (e) => {
1197
1197
  * @see https://tailwindcss.com/docs/gap
1198
1198
  */
1199
1199
  gap: [{
1200
- gap: [m]
1200
+ gap: [h]
1201
1201
  }],
1202
1202
  /**
1203
1203
  * Gap X
1204
1204
  * @see https://tailwindcss.com/docs/gap
1205
1205
  */
1206
1206
  "gap-x": [{
1207
- "gap-x": [m]
1207
+ "gap-x": [h]
1208
1208
  }],
1209
1209
  /**
1210
1210
  * Gap Y
1211
1211
  * @see https://tailwindcss.com/docs/gap
1212
1212
  */
1213
1213
  "gap-y": [{
1214
- "gap-y": [m]
1214
+ "gap-y": [h]
1215
1215
  }],
1216
1216
  /**
1217
1217
  * Justify Content
@@ -1785,21 +1785,21 @@ const be = (e) => {
1785
1785
  * @see https://tailwindcss.com/docs/gradient-color-stops
1786
1786
  */
1787
1787
  "gradient-from-pos": [{
1788
- from: [p]
1788
+ from: [m]
1789
1789
  }],
1790
1790
  /**
1791
1791
  * Gradient Color Stops Via Position
1792
1792
  * @see https://tailwindcss.com/docs/gradient-color-stops
1793
1793
  */
1794
1794
  "gradient-via-pos": [{
1795
- via: [p]
1795
+ via: [m]
1796
1796
  }],
1797
1797
  /**
1798
1798
  * Gradient Color Stops To Position
1799
1799
  * @see https://tailwindcss.com/docs/gradient-color-stops
1800
1800
  */
1801
1801
  "gradient-to-pos": [{
1802
- to: [p]
1802
+ to: [m]
1803
1803
  }],
1804
1804
  /**
1805
1805
  * Gradient Color Stops From
@@ -2452,21 +2452,21 @@ const be = (e) => {
2452
2452
  * @see https://tailwindcss.com/docs/scale
2453
2453
  */
2454
2454
  scale: [{
2455
- scale: [j]
2455
+ scale: [O]
2456
2456
  }],
2457
2457
  /**
2458
2458
  * Scale X
2459
2459
  * @see https://tailwindcss.com/docs/scale
2460
2460
  */
2461
2461
  "scale-x": [{
2462
- "scale-x": [j]
2462
+ "scale-x": [O]
2463
2463
  }],
2464
2464
  /**
2465
2465
  * Scale Y
2466
2466
  * @see https://tailwindcss.com/docs/scale
2467
2467
  */
2468
2468
  "scale-y": [{
2469
- "scale-y": [j]
2469
+ "scale-y": [O]
2470
2470
  }],
2471
2471
  /**
2472
2472
  * Rotate
@@ -2843,7 +2843,7 @@ const be = (e) => {
2843
2843
  }
2844
2844
  };
2845
2845
  }, fk = /* @__PURE__ */ G2(uk);
2846
- function Ne(...e) {
2846
+ function Ee(...e) {
2847
2847
  return fk(qi(e));
2848
2848
  }
2849
2849
  const Vi = Ti(null);
@@ -2855,12 +2855,12 @@ function hk() {
2855
2855
  }
2856
2856
  const nn = 8;
2857
2857
  function mk({ children: e }) {
2858
- const [t, n] = ve({
2858
+ const [t, n] = xe({
2859
2859
  open: !1,
2860
2860
  x: 0,
2861
2861
  y: 0,
2862
2862
  items: []
2863
- }), [o, r] = ve(
2863
+ }), [o, r] = xe(
2864
2864
  null
2865
2865
  ), i = fe(null), s = yn(() => {
2866
2866
  n((c) => c.open ? { ...c, open: !1 } : c);
@@ -2881,9 +2881,9 @@ function mk({ children: e }) {
2881
2881
  i.current && !i.current.contains(g.target) && s();
2882
2882
  }, d = (g) => {
2883
2883
  g.key === "Escape" && (g.preventDefault(), s());
2884
- }, u = () => s(), m = () => s();
2885
- return document.addEventListener("pointerdown", c, !0), document.addEventListener("keydown", d, !0), window.addEventListener("wheel", u, { passive: !0 }), window.addEventListener("blur", m), () => {
2886
- document.removeEventListener("pointerdown", c, !0), document.removeEventListener("keydown", d, !0), window.removeEventListener("wheel", u), window.removeEventListener("blur", m);
2884
+ }, u = () => s(), h = () => s();
2885
+ return document.addEventListener("pointerdown", c, !0), document.addEventListener("keydown", d, !0), window.addEventListener("wheel", u, { passive: !0 }), window.addEventListener("blur", h), () => {
2886
+ document.removeEventListener("pointerdown", c, !0), document.removeEventListener("keydown", d, !0), window.removeEventListener("wheel", u), window.removeEventListener("blur", h);
2887
2887
  };
2888
2888
  }, [t.open, s]), /* @__PURE__ */ C(Vi.Provider, { value: l, children: [
2889
2889
  e,
@@ -2917,7 +2917,7 @@ function mk({ children: e }) {
2917
2917
  type: "button",
2918
2918
  role: "menuitem",
2919
2919
  disabled: c.disabled,
2920
- className: Ne(
2920
+ className: Ee(
2921
2921
  "flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left",
2922
2922
  "hover:bg-accent hover:text-accent-foreground",
2923
2923
  "focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",
@@ -2947,8 +2947,8 @@ const cr = (e) => {
2947
2947
  const n = /* @__PURE__ */ new Set(), o = (c, d) => {
2948
2948
  const u = typeof c == "function" ? c(t) : c;
2949
2949
  if (!Object.is(u, t)) {
2950
- const m = t;
2951
- t = d ?? (typeof u != "object" || u === null) ? u : Object.assign({}, t, u), n.forEach((g) => g(t, m));
2950
+ const h = t;
2951
+ t = d ?? (typeof u != "object" || u === null) ? u : Object.assign({}, t, u), n.forEach((g) => g(t, h));
2952
2952
  }
2953
2953
  }, r = () => t, a = { setState: o, getState: r, getInitialState: () => l, subscribe: (c) => (n.add(c), () => n.delete(c)) }, l = t = e(o, r, a);
2954
2954
  return a;
@@ -3500,31 +3500,31 @@ const ho = (e) => (t) => {
3500
3500
  state: b,
3501
3501
  version: i.version
3502
3502
  });
3503
- }, m = r.setState;
3504
- r.setState = (b, x) => (m(b, x), u());
3503
+ }, h = r.setState;
3504
+ r.setState = (b, x) => (h(b, x), u());
3505
3505
  const g = e(
3506
3506
  (...b) => (n(...b), u()),
3507
3507
  o,
3508
3508
  r
3509
3509
  );
3510
3510
  r.getInitialState = () => g;
3511
- let p;
3512
- const h = () => {
3511
+ let m;
3512
+ const p = () => {
3513
3513
  var b, x;
3514
3514
  if (!d) return;
3515
3515
  const v = ++a;
3516
- s = !1, l.forEach((j) => {
3516
+ s = !1, l.forEach((O) => {
3517
3517
  var F;
3518
- return j((F = o()) != null ? F : g);
3518
+ return O((F = o()) != null ? F : g);
3519
3519
  });
3520
3520
  const P = ((x = i.onRehydrateStorage) == null ? void 0 : x.call(i, (b = o()) != null ? b : g)) || void 0;
3521
- return ho(d.getItem.bind(d))(i.name).then((j) => {
3522
- if (j)
3523
- if (typeof j.version == "number" && j.version !== i.version) {
3521
+ return ho(d.getItem.bind(d))(i.name).then((O) => {
3522
+ if (O)
3523
+ if (typeof O.version == "number" && O.version !== i.version) {
3524
3524
  if (i.migrate) {
3525
3525
  const F = i.migrate(
3526
- j.state,
3527
- j.version
3526
+ O.state,
3527
+ O.version
3528
3528
  );
3529
3529
  return F instanceof Promise ? F.then((G) => [!0, G]) : [!0, F];
3530
3530
  }
@@ -3532,22 +3532,22 @@ const ho = (e) => (t) => {
3532
3532
  "State loaded from storage couldn't be migrated since no migrate function was provided"
3533
3533
  );
3534
3534
  } else
3535
- return [!1, j.state];
3535
+ return [!1, O.state];
3536
3536
  return [!1, void 0];
3537
- }).then((j) => {
3537
+ }).then((O) => {
3538
3538
  var F;
3539
3539
  if (v !== a)
3540
3540
  return;
3541
- const [G, $] = j;
3542
- if (p = i.merge(
3541
+ const [G, $] = O;
3542
+ if (m = i.merge(
3543
3543
  $,
3544
3544
  (F = o()) != null ? F : g
3545
- ), n(p, !0), G)
3545
+ ), n(m, !0), G)
3546
3546
  return u();
3547
3547
  }).then(() => {
3548
- v === a && (P == null || P(o(), void 0), p = o(), s = !0, c.forEach((j) => j(p)));
3549
- }).catch((j) => {
3550
- v === a && (P == null || P(void 0, j));
3548
+ v === a && (P == null || P(o(), void 0), m = o(), s = !0, c.forEach((O) => O(m)));
3549
+ }).catch((O) => {
3550
+ v === a && (P == null || P(void 0, O));
3551
3551
  });
3552
3552
  };
3553
3553
  return r.persist = {
@@ -3561,7 +3561,7 @@ const ho = (e) => (t) => {
3561
3561
  d == null || d.removeItem(i.name);
3562
3562
  },
3563
3563
  getOptions: () => i,
3564
- rehydrate: () => h(),
3564
+ rehydrate: () => p(),
3565
3565
  hasHydrated: () => s,
3566
3566
  onHydrate: (b) => (l.add(b), () => {
3567
3567
  l.delete(b);
@@ -3569,7 +3569,7 @@ const ho = (e) => (t) => {
3569
3569
  onFinishHydration: (b) => (c.add(b), () => {
3570
3570
  c.delete(b);
3571
3571
  })
3572
- }, i.skipHydration || h(), p || g;
3572
+ }, i.skipHydration || p(), m || g;
3573
3573
  }, xk = wk, qe = 0.5;
3574
3574
  function ts(e) {
3575
3575
  if (e.length < 2) return e.map((r) => [r[0], r[1]]);
@@ -3711,11 +3711,11 @@ function on(e, t) {
3711
3711
  const Yn = 320, rn = 220, It = 260, Gn = 720, Ot = 30, gr = 30, ot = 80, yr = 10, $k = 60, Ek = 520, Nk = 80, Ak = 80, br = 8, wr = /* @__PURE__ */ new Set(["source", "renewable"]);
3712
3712
  function Tk(e) {
3713
3713
  var Zo, Qo, er, tr, nr, or;
3714
- const { elements: t, buses: n, junctions: o, wires: r, library: i, userLayout: s, userBusLayout: a } = e, l = new Map(s), c = new Map(a), d = /* @__PURE__ */ new Map(), u = new Set(s.keys()), m = new Set(a.keys()), g = /* @__PURE__ */ new Map();
3714
+ const { elements: t, buses: n, junctions: o, wires: r, library: i, userLayout: s, userBusLayout: a } = e, l = new Map(s), c = new Map(a), d = /* @__PURE__ */ new Map(), u = new Set(s.keys()), h = new Set(a.keys()), g = /* @__PURE__ */ new Map();
3715
3715
  for (const w of t) g.set(w.id, w);
3716
- const p = /* @__PURE__ */ new Map();
3717
- for (const w of n) p.set(w.id, w);
3718
- const h = (w) => {
3716
+ const m = /* @__PURE__ */ new Map();
3717
+ for (const w of n) m.set(w.id, w);
3718
+ const p = (w) => {
3719
3719
  const k = g.get(w);
3720
3720
  if (k)
3721
3721
  return i.get(k.kind);
@@ -3724,17 +3724,17 @@ function Tk(e) {
3724
3724
  var k;
3725
3725
  return (k = w.layout) == null ? void 0 : k.at;
3726
3726
  }).map((w) => w.id)
3727
- ), j = new ns();
3727
+ ), O = new ns();
3728
3728
  for (const w of r)
3729
- j.add(w.ends[0]), j.add(w.ends[1]), j.union(w.ends[0], w.ends[1]);
3729
+ O.add(w.ends[0]), O.add(w.ends[1]), O.union(w.ends[0], w.ends[1]);
3730
3730
  for (const w of t) {
3731
3731
  const k = i.get(w.kind);
3732
3732
  if (k)
3733
- for (const S of k.terminals) j.add(`${w.id}.${S.id}`);
3733
+ for (const S of k.terminals) O.add(`${w.id}.${S.id}`);
3734
3734
  }
3735
- for (const w of n) j.add(w.id);
3735
+ for (const w of n) O.add(w.id);
3736
3736
  const F = [];
3737
- for (const [, w] of j.groups())
3737
+ for (const [, w] of O.groups())
3738
3738
  w.length >= 2 && F.push(w);
3739
3739
  const G = /* @__PURE__ */ new Map();
3740
3740
  for (const w of F)
@@ -3749,7 +3749,7 @@ function Tk(e) {
3749
3749
  }
3750
3750
  }
3751
3751
  {
3752
- const S = (M) => g.has(M) && !!h(M), N = (M) => {
3752
+ const S = (M) => g.has(M) && !!p(M), N = (M) => {
3753
3753
  if (x(M)) return null;
3754
3754
  if (v.has(M)) return M;
3755
3755
  const A = M.indexOf(".");
@@ -3781,7 +3781,7 @@ function Tk(e) {
3781
3781
  for (let te = Y + 1; te < K.length; te++) T(K[Y], K[te]);
3782
3782
  }
3783
3783
  const z = (M, A) => {
3784
- const L = h(M);
3784
+ const L = p(M);
3785
3785
  if (!L) return null;
3786
3786
  for (const D of L.terminals) {
3787
3787
  const q = `${M}.${D.id}`;
@@ -3789,13 +3789,13 @@ function Tk(e) {
3789
3789
  for (const Y of K) if (N(Y) === A) return D;
3790
3790
  }
3791
3791
  return null;
3792
- }, O = (M) => {
3792
+ }, j = (M) => {
3793
3793
  const A = (J) => {
3794
3794
  var oe;
3795
3795
  return ((oe = E.get(J)) == null ? void 0 : oe.size) ?? 0;
3796
3796
  }, L = (J) => {
3797
3797
  var oe;
3798
- return ((oe = h(J)) == null ? void 0 : oe.category) ?? "";
3798
+ return ((oe = p(J)) == null ? void 0 : oe.category) ?? "";
3799
3799
  }, D = (J) => {
3800
3800
  const oe = L(J);
3801
3801
  return oe === "source" ? 0 : oe === "renewable" ? 1 : 2 + Math.min(A(J), 9) / 10;
@@ -3821,7 +3821,7 @@ function Tk(e) {
3821
3821
  };
3822
3822
  _e(q);
3823
3823
  for (const J of ne) {
3824
- const oe = xe(Yn + (me.get(J) ?? 0) * 160), Te = xe(rn + (Y.get(J) ?? 0) * 140);
3824
+ const oe = ve(Yn + (me.get(J) ?? 0) * 160), Te = ve(rn + (Y.get(J) ?? 0) * 140);
3825
3825
  if (v.has(J)) {
3826
3826
  d.set(J, [oe, Te]);
3827
3827
  continue;
@@ -3846,7 +3846,7 @@ function Tk(e) {
3846
3846
  A.push(D);
3847
3847
  for (const q of E.get(D) ?? []) B.has(q) || (B.add(q), L.push(q));
3848
3848
  }
3849
- A.length < 2 || A.some((D) => _.has(D)) || A.some((D) => l.has(D) || P.has(D)) || A.some(S) && O(A);
3849
+ A.length < 2 || A.some((D) => _.has(D)) || A.some((D) => l.has(D) || P.has(D)) || A.some(S) && j(A);
3850
3850
  }
3851
3851
  }
3852
3852
  const H = /* @__PURE__ */ new Map();
@@ -3859,7 +3859,7 @@ function Tk(e) {
3859
3859
  if (N < 0) continue;
3860
3860
  const E = S.slice(0, N), _ = S.slice(N + 1), T = H.get(E) ?? [];
3861
3861
  for (const z of k)
3862
- T.some((O) => O.busId === z && O.pin === _) || T.push({ busId: z, pin: _ });
3862
+ T.some((j) => j.busId === z && j.pin === _) || T.push({ busId: z, pin: _ });
3863
3863
  H.set(E, T);
3864
3864
  }
3865
3865
  }
@@ -3894,7 +3894,7 @@ function Tk(e) {
3894
3894
  for (const _ of S) {
3895
3895
  const T = _.slice(w.id.length + 1);
3896
3896
  N.set(T, /* @__PURE__ */ new Set());
3897
- const z = new Set(S.filter((M) => M !== _)), O = /* @__PURE__ */ new Set([_]), B = [_];
3897
+ const z = new Set(S.filter((M) => M !== _)), j = /* @__PURE__ */ new Set([_]), B = [_];
3898
3898
  for (; B.length > 0; ) {
3899
3899
  const M = B.shift();
3900
3900
  if (x(M)) {
@@ -3904,7 +3904,7 @@ function Tk(e) {
3904
3904
  const A = I.get(M);
3905
3905
  if (A)
3906
3906
  for (const L of A)
3907
- O.has(L) || z.has(L) || (O.add(L), B.push(L));
3907
+ j.has(L) || z.has(L) || (j.add(L), B.push(L));
3908
3908
  }
3909
3909
  }
3910
3910
  const E = /* @__PURE__ */ new Set();
@@ -3913,23 +3913,23 @@ function Tk(e) {
3913
3913
  if (E.size >= 2) {
3914
3914
  const _ = [];
3915
3915
  for (const [T, z] of N)
3916
- for (const O of z) _.push({ busId: O, pin: T });
3916
+ for (const j of z) _.push({ busId: j, pin: T });
3917
3917
  W.push({ elementId: w.id, attachments: _, orientation: "vertical" }), X.add(w.id);
3918
3918
  }
3919
3919
  }
3920
3920
  const Z = (w, k) => {
3921
3921
  var z;
3922
- const S = h(k), N = S ? S.terminals.map((O) => `${k}.${O.id}`) : [], E = w, _ = /* @__PURE__ */ new Set([E, ...N]), T = [E];
3922
+ const S = p(k), N = S ? S.terminals.map((j) => `${k}.${j.id}`) : [], E = w, _ = /* @__PURE__ */ new Set([E, ...N]), T = [E];
3923
3923
  for (; T.length > 0; ) {
3924
- const O = T.shift(), B = O.indexOf(".");
3924
+ const j = T.shift(), B = j.indexOf(".");
3925
3925
  if (B > 0) {
3926
- const A = O.slice(0, B), L = g.get(A);
3926
+ const A = j.slice(0, B), L = g.get(A);
3927
3927
  if (L) {
3928
3928
  const D = (z = i.get(L.kind)) == null ? void 0 : z.category;
3929
3929
  if (D && wr.has(D)) return !0;
3930
3930
  }
3931
3931
  }
3932
- const M = I.get(O);
3932
+ const M = I.get(j);
3933
3933
  if (M)
3934
3934
  for (const A of M)
3935
3935
  _.has(A) || (_.add(A), T.push(A));
@@ -3952,7 +3952,7 @@ function Tk(e) {
3952
3952
  (_) => `${w.id}.${_.id}`
3953
3953
  ), N = /* @__PURE__ */ new Map();
3954
3954
  for (const _ of S) {
3955
- const T = _.slice(w.id.length + 1), z = new Set(S.filter((M) => M !== _)), O = /* @__PURE__ */ new Set([_]), B = [_];
3955
+ const T = _.slice(w.id.length + 1), z = new Set(S.filter((M) => M !== _)), j = /* @__PURE__ */ new Set([_]), B = [_];
3956
3956
  for (; B.length > 0; ) {
3957
3957
  const M = B.shift();
3958
3958
  if (x(M)) {
@@ -3962,7 +3962,7 @@ function Tk(e) {
3962
3962
  const A = I.get(M);
3963
3963
  if (A)
3964
3964
  for (const L of A) {
3965
- if (O.has(L) || z.has(L)) continue;
3965
+ if (j.has(L) || z.has(L)) continue;
3966
3966
  const D = L.indexOf(".");
3967
3967
  if (D > 0) {
3968
3968
  const q = L.slice(0, D);
@@ -3971,7 +3971,7 @@ function Tk(e) {
3971
3971
  if ((Y == null ? void 0 : Y.category) === "transformer") continue;
3972
3972
  }
3973
3973
  }
3974
- O.add(L), B.push(L);
3974
+ j.add(L), B.push(L);
3975
3975
  }
3976
3976
  }
3977
3977
  }
@@ -4039,17 +4039,17 @@ function Tk(e) {
4039
4039
  S.push(w.id), ge.set(k, S);
4040
4040
  }
4041
4041
  const ke = [...ge.keys()].sort((w, k) => w - k), Ae = (w, k, S) => {
4042
- const N = `${w.elementId}.${S}`, E = k, _ = h(w.elementId), T = /* @__PURE__ */ new Set();
4042
+ const N = `${w.elementId}.${S}`, E = k, _ = p(w.elementId), T = /* @__PURE__ */ new Set();
4043
4043
  if (_)
4044
4044
  for (const A of _.terminals)
4045
4045
  A.id !== S && T.add(`${w.elementId}.${A.id}`);
4046
- const z = /* @__PURE__ */ new Set([N]), O = [
4046
+ const z = /* @__PURE__ */ new Set([N]), j = [
4047
4047
  { ref: N, dist: 0 }
4048
4048
  ], B = /* @__PURE__ */ new Map(), M = (A, L, D, q) => {
4049
- z.add(A), B.set(A, L), O.push({ ref: A, dist: q + D });
4049
+ z.add(A), B.set(A, L), j.push({ ref: A, dist: q + D });
4050
4050
  };
4051
- for (; O.length > 0; ) {
4052
- const { ref: A, dist: L } = O.shift();
4051
+ for (; j.length > 0; ) {
4052
+ const { ref: A, dist: L } = j.shift();
4053
4053
  if (A === E) {
4054
4054
  const Y = B.get(E);
4055
4055
  let te;
@@ -4067,7 +4067,7 @@ function Tk(e) {
4067
4067
  continue;
4068
4068
  const q = A.slice(0, D), K = A.slice(D + 1);
4069
4069
  if (!x(q) && !X.has(q)) {
4070
- const Y = h(q), te = Y == null ? void 0 : Y.terminals.find((ne) => ne.id === K);
4070
+ const Y = p(q), te = Y == null ? void 0 : Y.terminals.find((ne) => ne.id === K);
4071
4071
  if (Y && te)
4072
4072
  for (const ne of Y.terminals) {
4073
4073
  if (ne.id === K) continue;
@@ -4087,41 +4087,41 @@ function Tk(e) {
4087
4087
  var A, L, D;
4088
4088
  const S = (A = ae.get(w)) == null ? void 0 : A.get(k);
4089
4089
  if (!S || S.orientation === "horizontal") return It;
4090
- const N = h(S.elementId);
4090
+ const N = p(S.elementId);
4091
4091
  if (!N) return It;
4092
4092
  const E = (L = S.attachments.find((q) => q.busId === w)) == null ? void 0 : L.pin, _ = (D = S.attachments.find((q) => q.busId === k)) == null ? void 0 : D.pin;
4093
4093
  if (!E || !_) return It;
4094
4094
  const T = N.terminals.find((q) => q.id === E), z = N.terminals.find((q) => q.id === _);
4095
4095
  if (!T || !z) return It;
4096
- const O = Math.abs(z.y - T.y), B = Ae(S, w, E).extent, M = Ae(S, k, _).extent;
4097
- return B + O + M;
4096
+ const j = Math.abs(z.y - T.y), B = Ae(S, w, E).extent, M = Ae(S, k, _).extent;
4097
+ return B + j + M;
4098
4098
  }, zn = /* @__PURE__ */ new Map();
4099
4099
  for (const w of W) {
4100
4100
  if (w.orientation !== "vertical") continue;
4101
4101
  const k = w.attachments.slice().sort(
4102
- (z, O) => (le.get(z.busId) ?? 0) - (le.get(O.busId) ?? 0)
4102
+ (z, j) => (le.get(z.busId) ?? 0) - (le.get(j.busId) ?? 0)
4103
4103
  );
4104
4104
  if (k.length < 2) continue;
4105
4105
  const S = k[0].busId, N = k[1].busId, E = k[0].pin, T = Ae(w, S, E).head ?? w.elementId;
4106
4106
  zn.set(T, { lowerBusId: N });
4107
4107
  }
4108
4108
  const zo = 30, Ro = (w) => {
4109
- const k = h(w);
4109
+ const k = p(w);
4110
4110
  return Math.max((k == null ? void 0 : k.width) ?? ot, ot);
4111
4111
  }, Jv = 2, Fo = (w, k, S, N = 0) => {
4112
- const E = h(k);
4112
+ const E = p(k);
4113
4113
  let _ = Ro(k);
4114
4114
  if (E && !S.has(k) && N < Jv) {
4115
4115
  S.add(k);
4116
4116
  let T = 0;
4117
4117
  for (const z of E.terminals) {
4118
- const O = `${k}.${z.id}`;
4119
- if (O !== w)
4120
- for (const B of G.get(O) ?? []) {
4118
+ const j = `${k}.${z.id}`;
4119
+ if (j !== w)
4120
+ for (const B of G.get(j) ?? []) {
4121
4121
  const M = /* @__PURE__ */ new Set();
4122
4122
  let A = !1;
4123
4123
  for (const D of B) {
4124
- if (D === O) continue;
4124
+ if (D === j) continue;
4125
4125
  if (x(D)) {
4126
4126
  A = !0;
4127
4127
  continue;
@@ -4170,18 +4170,18 @@ function Tk(e) {
4170
4170
  if (x(T)) continue;
4171
4171
  const z = T.indexOf(".");
4172
4172
  if (z < 0) continue;
4173
- const O = T.slice(0, z), B = T.slice(z + 1);
4174
- if (Ho(O, w)) continue;
4175
- const M = h(O);
4173
+ const j = T.slice(0, z), B = T.slice(z + 1);
4174
+ if (Ho(j, w)) continue;
4175
+ const M = p(j);
4176
4176
  if (!M) continue;
4177
4177
  const A = M.terminals.find((q) => q.id === B);
4178
4178
  if (!A) continue;
4179
- const L = zn.get(O);
4179
+ const L = zn.get(j);
4180
4180
  L && Wo(L.lowerBusId, k);
4181
4181
  const D = Nt(
4182
- O,
4182
+ j,
4183
4183
  M.width,
4184
- `${O}.${B}`
4184
+ `${j}.${B}`
4185
4185
  );
4186
4186
  A.y > 0 ? N += D : E += D;
4187
4187
  }
@@ -4193,25 +4193,25 @@ function Tk(e) {
4193
4193
  };
4194
4194
  for (const w of n) Wo(w.id, /* @__PURE__ */ new Set());
4195
4195
  const et = /* @__PURE__ */ new Map(), Zv = (w, k, S) => {
4196
- const N = h(k);
4196
+ const N = p(k);
4197
4197
  if (!N) return;
4198
- const E = `${k}.${S}`, _ = N.terminals.filter((O) => O.id !== S).map((O) => `${k}.${O.id}`);
4198
+ const E = `${k}.${S}`, _ = N.terminals.filter((j) => j.id !== S).map((j) => `${k}.${j.id}`);
4199
4199
  if (_.length === 0) return;
4200
4200
  const T = /* @__PURE__ */ new Set([E, ..._]), z = _.slice();
4201
4201
  for (; z.length > 0; ) {
4202
- const O = z.shift();
4203
- if (x(O) && O !== w) {
4204
- const M = c.get(O);
4202
+ const j = z.shift();
4203
+ if (x(j) && j !== w) {
4204
+ const M = c.get(j);
4205
4205
  return M ? M.at[0] : void 0;
4206
4206
  }
4207
- for (const M of G.get(O) ?? [])
4207
+ for (const M of G.get(j) ?? [])
4208
4208
  for (const A of M)
4209
- A === O || T.has(A) || (T.add(A), z.push(A));
4210
- const B = O.indexOf(".");
4209
+ A === j || T.has(A) || (T.add(A), z.push(A));
4210
+ const B = j.indexOf(".");
4211
4211
  if (B > 0) {
4212
- const M = O.slice(0, B);
4212
+ const M = j.slice(0, B);
4213
4213
  if (!x(M)) {
4214
- const A = h(M);
4214
+ const A = p(M);
4215
4215
  if (A)
4216
4216
  for (const L of A.terminals) {
4217
4217
  const D = `${M}.${L.id}`;
@@ -4232,7 +4232,7 @@ function Tk(e) {
4232
4232
  const D = A.slice(0, L), q = A.slice(L + 1);
4233
4233
  if (l.has(D)) return [];
4234
4234
  if (Ho(D, w)) return [];
4235
- const K = h(D);
4235
+ const K = p(D);
4236
4236
  if (!K) return [];
4237
4237
  const Y = K.terminals.find((te) => te.id === q);
4238
4238
  return Y ? [{
@@ -4250,8 +4250,8 @@ function Tk(e) {
4250
4250
  const T = (A) => A.reduce(
4251
4251
  (L, D) => L + Nt(D.elId, D.lib.width, D.busFacingRef),
4252
4252
  0
4253
- ), z = Math.max(T(E), T(_)) + ot, O = Math.max(S.span, z);
4254
- O !== S.span && !m.has(w) && c.set(w, { ...S, span: O });
4253
+ ), z = Math.max(T(E), T(_)) + ot, j = Math.max(S.span, z);
4254
+ j !== S.span && !h.has(w) && c.set(w, { ...S, span: j });
4255
4255
  const B = c.get(w), M = (A, L) => {
4256
4256
  if (A.length === 0) return;
4257
4257
  const D = /* @__PURE__ */ new Map();
@@ -4267,13 +4267,13 @@ function Tk(e) {
4267
4267
  });
4268
4268
  const q = A.map(
4269
4269
  (V) => Nt(V.elId, V.lib.width, V.busFacingRef)
4270
- ), K = q.reduce((V, Q) => V + Q, 0), Y = Math.max(O, K), te = (Y - K) / (A.length + 1);
4270
+ ), K = q.reduce((V, Q) => V + Q, 0), Y = Math.max(j, K), te = (Y - K) / (A.length + 1);
4271
4271
  let ne = B.at[0] - Y / 2 + te;
4272
4272
  const U = B.at[1] + L * gr;
4273
4273
  for (let V = 0; V < A.length; V++) {
4274
4274
  const Q = A[V], me = q[V], _e = ne + me / 2;
4275
4275
  Q.isLinker ? et.has(Q.elId) || et.set(Q.elId, _e) : l.set(Q.elId, {
4276
- at: [xe(_e - Q.localTerm.x), xe(U - Q.localTerm.y)],
4276
+ at: [ve(_e - Q.localTerm.x), ve(U - Q.localTerm.y)],
4277
4277
  rot: 0,
4278
4278
  mirror: !1
4279
4279
  }), ne += me + te;
@@ -4282,7 +4282,7 @@ function Tk(e) {
4282
4282
  M(E, -1), M(_, 1);
4283
4283
  }, e2 = (w) => {
4284
4284
  if (l.has(w.elementId) || w.orientation === "horizontal") return;
4285
- const k = h(w.elementId);
4285
+ const k = p(w.elementId);
4286
4286
  if (!k) return;
4287
4287
  const S = w.attachments.filter(
4288
4288
  (ne) => c.has(ne.busId)
@@ -4290,9 +4290,9 @@ function Tk(e) {
4290
4290
  if (S.length < 2) return;
4291
4291
  const N = S.slice().sort(
4292
4292
  (ne, U) => (le.get(ne.busId) ?? 0) - (le.get(U.busId) ?? 0)
4293
- ), E = N[0].busId, _ = c.get(E), T = N[0].pin, z = N[N.length - 1].pin, O = k.terminals.find((ne) => ne.id === T), B = k.terminals.find((ne) => ne.id === z);
4294
- if (!O || !B) return;
4295
- const M = O.y <= B.y ? 0 : 180, A = le.get(E) ?? 0, L = S.filter(
4293
+ ), E = N[0].busId, _ = c.get(E), T = N[0].pin, z = N[N.length - 1].pin, j = k.terminals.find((ne) => ne.id === T), B = k.terminals.find((ne) => ne.id === z);
4294
+ if (!j || !B) return;
4295
+ const M = j.y <= B.y ? 0 : 180, A = le.get(E) ?? 0, L = S.filter(
4296
4296
  (ne) => (le.get(ne.busId) ?? 0) === A
4297
4297
  ), D = [];
4298
4298
  let q = 0;
@@ -4304,13 +4304,13 @@ function Tk(e) {
4304
4304
  }
4305
4305
  let K;
4306
4306
  D.length > 0 ? K = D.reduce((ne, U) => ne + U, 0) / D.length : et.has(w.elementId) ? K = et.get(w.elementId) : K = _.at[0];
4307
- const Y = _.at[1] + q, te = M === 0 ? [xe(K - O.x), xe(Y - O.y)] : [xe(K + O.x), xe(Y + O.y)];
4307
+ const Y = _.at[1] + q, te = M === 0 ? [ve(K - j.x), ve(Y - j.y)] : [ve(K + j.x), ve(Y + j.y)];
4308
4308
  if (l.set(w.elementId, { at: te, rot: M, mirror: !1 }), L.length > 1) {
4309
4309
  const ne = l.get(w.elementId), U = ze(
4310
- [O.x, O.y],
4310
+ [j.x, j.y],
4311
4311
  ne
4312
4312
  ), V = pn(
4313
- O.orientation,
4313
+ j.orientation,
4314
4314
  ne
4315
4315
  );
4316
4316
  t2(
@@ -4324,9 +4324,9 @@ function Tk(e) {
4324
4324
  const E = /* @__PURE__ */ new Set([w]);
4325
4325
  let _ = w, T = k, z = S;
4326
4326
  for (; ; ) {
4327
- const O = G.get(_) ?? [];
4327
+ const j = G.get(_) ?? [];
4328
4328
  let B, M = !1;
4329
- for (const oe of O) {
4329
+ for (const oe of j) {
4330
4330
  if (oe.length >= 3) {
4331
4331
  M = !0;
4332
4332
  break;
@@ -4346,7 +4346,7 @@ function Tk(e) {
4346
4346
  if (A < 0) break;
4347
4347
  const L = B.slice(0, A), D = B.slice(A + 1);
4348
4348
  if (x(L) || X.has(L) || l.has(L)) break;
4349
- const q = h(L);
4349
+ const q = p(L);
4350
4350
  if (!q) break;
4351
4351
  const K = q.terminals.find((oe) => oe.id === D);
4352
4352
  if (!K) break;
@@ -4358,8 +4358,8 @@ function Tk(e) {
4358
4358
  rot: U,
4359
4359
  mirror: !1
4360
4360
  }), Q = [
4361
- xe(N - V[0]),
4362
- xe(te[1] - V[1])
4361
+ ve(N - V[0]),
4362
+ ve(te[1] - V[1])
4363
4363
  ];
4364
4364
  l.set(L, { at: Q, rot: U, mirror: !1 }), E.add(B);
4365
4365
  const me = q.terminals.find((oe) => oe.id !== D);
@@ -4371,7 +4371,7 @@ function Tk(e) {
4371
4371
  }
4372
4372
  }, n2 = (w) => {
4373
4373
  if (l.has(w.elementId) || w.orientation !== "horizontal") return;
4374
- const k = h(w.elementId);
4374
+ const k = p(w.elementId);
4375
4375
  if (!k) return;
4376
4376
  const S = w.attachments.filter((L) => c.has(L.busId));
4377
4377
  if (S.length < 2) return;
@@ -4382,10 +4382,10 @@ function Tk(e) {
4382
4382
  N.sort((L, D) => L.x - D.x);
4383
4383
  const E = N[0], _ = N[N.length - 1], T = k.terminals.find((L) => L.id === E.att.pin), z = k.terminals.find((L) => L.id === _.att.pin);
4384
4384
  if (!T || !z) return;
4385
- const O = T.y <= z.y ? 270 : 90, B = (E.x + _.x) / 2, A = c.get(E.att.busId).at[1] + Math.max(E.extent, _.extent);
4385
+ const j = T.y <= z.y ? 270 : 90, B = (E.x + _.x) / 2, A = c.get(E.att.busId).at[1] + Math.max(E.extent, _.extent);
4386
4386
  l.set(w.elementId, {
4387
- at: [xe(B), xe(A)],
4388
- rot: O,
4387
+ at: [ve(B), ve(A)],
4388
+ rot: j,
4389
4389
  mirror: !1
4390
4390
  });
4391
4391
  }, qo = 100;
@@ -4399,8 +4399,8 @@ function Tk(e) {
4399
4399
  const _ = ge.get(ke[w - 1]);
4400
4400
  let T = 0;
4401
4401
  for (const z of _)
4402
- for (const O of S)
4403
- (tr = ae.get(z)) != null && tr.get(O) && (T = Math.max(T, Oe(z, O)));
4402
+ for (const j of S)
4403
+ (tr = ae.get(z)) != null && tr.get(j) && (T = Math.max(T, Oe(z, j)));
4404
4404
  T === 0 && (T = It), N = Qt + T;
4405
4405
  }
4406
4406
  Qt = N;
@@ -4412,8 +4412,8 @@ function Tk(e) {
4412
4412
  }
4413
4413
  let T;
4414
4414
  if (w > 0) {
4415
- const O = ge.get(ke[w - 1]), B = [];
4416
- for (const M of O) {
4415
+ const j = ge.get(ke[w - 1]), B = [];
4416
+ for (const M of j) {
4417
4417
  const A = (nr = ae.get(M)) == null ? void 0 : nr.get(_);
4418
4418
  if (!A || A.orientation !== "vertical") continue;
4419
4419
  const L = (or = A.attachments.find(
@@ -4426,12 +4426,12 @@ function Tk(e) {
4426
4426
  B.length > 0 && (T = B.reduce((M, A) => M + A, 0) / B.length);
4427
4427
  }
4428
4428
  if (T === void 0) {
4429
- const O = ht.get(_) ?? Gn;
4430
- T = E + O / 2, E += O + qo;
4429
+ const j = ht.get(_) ?? Gn;
4430
+ T = E + j / 2, E += j + qo;
4431
4431
  }
4432
4432
  const z = ht.get(_) ?? Gn;
4433
4433
  c.set(_, {
4434
- at: [xe(T), xe(N)],
4434
+ at: [ve(T), ve(N)],
4435
4435
  rot: 0,
4436
4436
  span: z,
4437
4437
  axis: mo(0)
@@ -4451,13 +4451,13 @@ function Tk(e) {
4451
4451
  }
4452
4452
  if (n.length === 0 && l.size < t.length) {
4453
4453
  const w = (E) => {
4454
- const _ = /* @__PURE__ */ new Set(), T = h(E);
4454
+ const _ = /* @__PURE__ */ new Set(), T = p(E);
4455
4455
  if (!T) return _;
4456
4456
  for (const z of T.terminals) {
4457
- const O = `${E}.${z.id}`;
4458
- for (const B of G.get(O) ?? [])
4457
+ const j = `${E}.${z.id}`;
4458
+ for (const B of G.get(j) ?? [])
4459
4459
  for (const M of B) {
4460
- if (M === O || x(M)) continue;
4460
+ if (M === j || x(M)) continue;
4461
4461
  const A = M.indexOf(".");
4462
4462
  if (A < 0) continue;
4463
4463
  const L = M.slice(0, A);
@@ -4467,13 +4467,13 @@ function Tk(e) {
4467
4467
  return _;
4468
4468
  }, k = /* @__PURE__ */ new Set(), S = [];
4469
4469
  for (const E of t) {
4470
- if (k.has(E.id) || !h(E.id)) continue;
4470
+ if (k.has(E.id) || !p(E.id)) continue;
4471
4471
  const _ = [], T = [E.id];
4472
4472
  for (k.add(E.id); T.length > 0; ) {
4473
4473
  const z = T.pop();
4474
4474
  _.push(z);
4475
- for (const O of w(z))
4476
- k.has(O) || (k.add(O), T.push(O));
4475
+ for (const j of w(z))
4476
+ k.has(j) || (k.add(j), T.push(j));
4477
4477
  }
4478
4478
  _.length >= 2 && S.push(_);
4479
4479
  }
@@ -4487,15 +4487,15 @@ function Tk(e) {
4487
4487
  const D = w(B).size, q = w(M).size;
4488
4488
  return D !== q ? D - q : B.localeCompare(M);
4489
4489
  });
4490
- const _ = E[0], T = h(_);
4490
+ const _ = E[0], T = p(_);
4491
4491
  if (!T) continue;
4492
- const z = T.terminals.slice().sort((B, M) => M.y - B.y)[0], O = z ? ze([z.x, z.y], {
4492
+ const z = T.terminals.slice().sort((B, M) => M.y - B.y)[0], j = z ? ze([z.x, z.y], {
4493
4493
  at: [0, 0],
4494
4494
  rot: 0,
4495
4495
  mirror: !1
4496
4496
  }) : [0, 0];
4497
4497
  l.set(_, {
4498
- at: [xe(N - O[0]), xe(rn - O[1])],
4498
+ at: [ve(N - j[0]), ve(rn - j[1])],
4499
4499
  rot: 0,
4500
4500
  mirror: !1
4501
4501
  }), N += Math.max(Gn, E.length * ot) + qo;
@@ -4523,7 +4523,7 @@ function Tk(e) {
4523
4523
  continue;
4524
4524
  }
4525
4525
  if (X.has(Q) || S.has(Q)) continue;
4526
- const _e = h(Q);
4526
+ const _e = p(Q);
4527
4527
  if (!_e) continue;
4528
4528
  const J = _e.terminals.find((oe) => oe.id === me);
4529
4529
  J && S.set(Q, {
@@ -4549,9 +4549,9 @@ function Tk(e) {
4549
4549
  (Q > U || Q === U && (_ === void 0 || V < _)) && (U = Q, _ = V);
4550
4550
  }
4551
4551
  if (_ || (_ = [...k].sort()[0]), !_) continue;
4552
- const T = _.indexOf("."), z = _.slice(0, T), O = _.slice(T + 1), B = h(z), M = l.get(z);
4552
+ const T = _.indexOf("."), z = _.slice(0, T), j = _.slice(T + 1), B = p(z), M = l.get(z);
4553
4553
  if (!B || !M) continue;
4554
- const A = B.terminals.find((U) => U.id === O);
4554
+ const A = B.terminals.find((U) => U.id === j);
4555
4555
  if (!A) continue;
4556
4556
  const L = ze(
4557
4557
  [A.x, A.y],
@@ -4578,35 +4578,35 @@ function Tk(e) {
4578
4578
  L[0] + q[0] * Ot + K[0] * me,
4579
4579
  L[1] + q[1] * Ot + K[1] * me
4580
4580
  ], Me = [
4581
- xe(Te[0] - oe[0]),
4582
- xe(Te[1] - oe[1])
4581
+ ve(Te[0] - oe[0]),
4582
+ ve(Te[1] - oe[1])
4583
4583
  ];
4584
4584
  l.set(V.elId, { at: Me, rot: J, mirror: !1 }), Rn = !0;
4585
4585
  }
4586
4586
  }
4587
4587
  }
4588
4588
  const At = (w) => {
4589
- const k = l.get(w), S = h(w);
4589
+ const k = l.get(w), S = p(w);
4590
4590
  if (!k || !S) return null;
4591
4591
  const N = S.viewBox.split(/\s+/).map(Number);
4592
4592
  if (N.length < 4 || N.some((A) => Number.isNaN(A))) {
4593
4593
  const A = S.width / 2;
4594
4594
  return { min: k.at[0] - A, max: k.at[0] + A };
4595
4595
  }
4596
- const [E, _, T, z] = N, O = [
4596
+ const [E, _, T, z] = N, j = [
4597
4597
  [E, _],
4598
4598
  [E + T, _],
4599
4599
  [E, _ + z],
4600
4600
  [E + T, _ + z]
4601
4601
  ];
4602
4602
  let B = 1 / 0, M = -1 / 0;
4603
- for (const A of O) {
4603
+ for (const A of j) {
4604
4604
  const L = ze(A, k);
4605
4605
  B = Math.min(B, L[0]), M = Math.max(M, L[0]);
4606
4606
  }
4607
4607
  return { min: B, max: M };
4608
4608
  }, Fn = (w) => {
4609
- const k = /* @__PURE__ */ new Set(), S = h(w);
4609
+ const k = /* @__PURE__ */ new Set(), S = p(w);
4610
4610
  if (!S) return k;
4611
4611
  for (const N of S.terminals) {
4612
4612
  const E = `${w}.${N.id}`;
@@ -4615,27 +4615,27 @@ function Tk(e) {
4615
4615
  if (T === E || x(T)) continue;
4616
4616
  const z = T.indexOf(".");
4617
4617
  if (z < 0) continue;
4618
- const O = T.slice(0, z);
4619
- O !== w && k.add(O);
4618
+ const j = T.slice(0, z);
4619
+ j !== w && k.add(j);
4620
4620
  }
4621
4621
  }
4622
4622
  return k;
4623
4623
  }, Xo = 40, Hn = (w) => {
4624
- const k = l.get(w), S = h(w);
4624
+ const k = l.get(w), S = p(w);
4625
4625
  if (!k || !S) return null;
4626
4626
  const N = S.viewBox.split(/\s+/).map(Number);
4627
4627
  if (N.length < 4 || N.some((A) => Number.isNaN(A))) {
4628
4628
  const A = S.height / 2;
4629
4629
  return { min: k.at[1] - A, max: k.at[1] + A };
4630
4630
  }
4631
- const [E, _, T, z] = N, O = [
4631
+ const [E, _, T, z] = N, j = [
4632
4632
  [E, _],
4633
4633
  [E + T, _],
4634
4634
  [E, _ + z],
4635
4635
  [E + T, _ + z]
4636
4636
  ];
4637
4637
  let B = 1 / 0, M = -1 / 0;
4638
- for (const A of O) {
4638
+ for (const A of j) {
4639
4639
  const L = ze(A, k);
4640
4640
  B = Math.min(B, L[1]), M = Math.max(M, L[1]);
4641
4641
  }
@@ -4672,18 +4672,18 @@ function Tk(e) {
4672
4672
  E = !1;
4673
4673
  for (let _ = 0; _ < w.length && !E; _++)
4674
4674
  for (let T = _ + 1; T < w.length; T++) {
4675
- const z = w[_], O = w[T], B = At(z), M = At(O), A = Hn(z), L = Hn(O);
4675
+ const z = w[_], j = w[T], B = At(z), M = At(j), A = Hn(z), L = Hn(j);
4676
4676
  if (!B || !M || !A || !L) continue;
4677
4677
  const D = Math.min(B.max, M.max) - Math.max(B.min, M.min), q = Math.min(A.max, L.max) - Math.max(A.min, L.min);
4678
4678
  if (D <= 0 || q <= 0) continue;
4679
- const K = Yo(z, O, k), Y = Yo(O, z, k);
4680
- if (K.has(O) || Y.has(z)) continue;
4679
+ const K = Yo(z, j, k), Y = Yo(j, z, k);
4680
+ if (K.has(j) || Y.has(z)) continue;
4681
4681
  const te = ![...K].some((J) => u.has(J)), ne = ![...Y].some((J) => u.has(J));
4682
4682
  if (!te && !ne) continue;
4683
4683
  const U = (B.min + B.max) / 2, V = (M.min + M.max) / 2;
4684
4684
  let Q, me;
4685
4685
  te && (!ne || K.size <= Y.size) ? (Q = K, me = U <= V ? -1 : 1) : (Q = Y, me = V <= U ? -1 : 1);
4686
- const _e = xe(me * (D + Xo));
4686
+ const _e = ve(me * (D + Xo));
4687
4687
  if (_e !== 0) {
4688
4688
  for (const J of Q) {
4689
4689
  const oe = l.get(J);
@@ -4708,21 +4708,21 @@ function Tk(e) {
4708
4708
  if (Go(N, S)) {
4709
4709
  let _ = 1 / 0, T = -1 / 0;
4710
4710
  for (const z of N) {
4711
- const O = At(z);
4712
- O && (_ = Math.min(_, O.min), T = Math.max(T, O.max));
4711
+ const j = At(z);
4712
+ j && (_ = Math.min(_, j.min), T = Math.max(T, j.max));
4713
4713
  }
4714
4714
  if (Number.isFinite(_)) {
4715
- const O = N.some((M) => u.has(M)) ? 0 : xe(k.at[0] - (_ + T) / 2);
4716
- if (O !== 0)
4715
+ const j = N.some((M) => u.has(M)) ? 0 : ve(k.at[0] - (_ + T) / 2);
4716
+ if (j !== 0)
4717
4717
  for (const M of N) {
4718
4718
  const A = l.get(M);
4719
4719
  A && l.set(M, {
4720
4720
  ...A,
4721
- at: [A.at[0] + O, A.at[1]]
4721
+ at: [A.at[0] + j, A.at[1]]
4722
4722
  });
4723
4723
  }
4724
4724
  const B = T - _ + Xo;
4725
- if (B > k.span && !m.has(w.id)) {
4725
+ if (B > k.span && !h.has(w.id)) {
4726
4726
  const M = c.get(w.id);
4727
4727
  c.set(w.id, { ...M, span: B });
4728
4728
  }
@@ -4765,8 +4765,8 @@ function Tk(e) {
4765
4765
  continue;
4766
4766
  } else
4767
4767
  continue;
4768
- for (const O of Fn(E))
4769
- l.has(O) && (w.has(O) || S.push({ el: O, bus: _, d: T + 1 }));
4768
+ for (const j of Fn(E))
4769
+ l.has(j) && (w.has(j) || S.push({ el: j, bus: _, d: T + 1 }));
4770
4770
  }
4771
4771
  for (const [E, _] of k) _ && Jo.set(E, _);
4772
4772
  }
@@ -4774,7 +4774,7 @@ function Tk(e) {
4774
4774
  const k = (ge.get(w) ?? []).filter(
4775
4775
  (B) => c.has(B)
4776
4776
  );
4777
- if (k.length < 2 || k.some((B) => m.has(B))) continue;
4777
+ if (k.length < 2 || k.some((B) => h.has(B))) continue;
4778
4778
  const S = [];
4779
4779
  let N = 0;
4780
4780
  for (const B of k) {
@@ -4795,9 +4795,9 @@ function Tk(e) {
4795
4795
  const T = _ - E, z = N + Wn * (S.length - 1);
4796
4796
  if (!(T > z + Wn)) continue;
4797
4797
  S.sort((B, M) => (B.min + B.max) / 2 - (M.min + M.max) / 2);
4798
- let O = E;
4798
+ let j = E;
4799
4799
  for (const B of S) {
4800
- const M = xe(O - B.min);
4800
+ const M = ve(j - B.min);
4801
4801
  if (M !== 0) {
4802
4802
  const A = c.get(B.busId);
4803
4803
  c.set(B.busId, { ...A, at: [A.at[0] + M, A.at[1]] });
@@ -4807,7 +4807,7 @@ function Tk(e) {
4807
4807
  }
4808
4808
  B.min += M, B.max += M;
4809
4809
  }
4810
- O = B.max + Wn;
4810
+ j = B.max + Wn;
4811
4811
  }
4812
4812
  for (const B of S) {
4813
4813
  const M = c.get(B.busId), A = Math.max(Et, B.max - B.min);
@@ -4830,8 +4830,8 @@ function Tk(e) {
4830
4830
  const k = qn % br, S = Math.floor(qn / br);
4831
4831
  l.set(w.id, {
4832
4832
  at: [
4833
- xe($k + k * Nk),
4834
- xe(Ek + S * Ak)
4833
+ ve($k + k * Nk),
4834
+ ve(Ek + S * Ak)
4835
4835
  ],
4836
4836
  rot: 0,
4837
4837
  mirror: !1
@@ -4839,7 +4839,7 @@ function Tk(e) {
4839
4839
  }
4840
4840
  return { devices: l, buses: c, junctions: d };
4841
4841
  }
4842
- function xe(e) {
4842
+ function ve(e) {
4843
4843
  return Math.round(e / yr) * yr;
4844
4844
  }
4845
4845
  function Mk(e, t) {
@@ -4849,12 +4849,12 @@ function Mk(e, t) {
4849
4849
  if (!d) return null;
4850
4850
  const u = t.buses.get(l);
4851
4851
  if (!u) return null;
4852
- const { axis: m, at: g, span: p } = u.geometry, h = p / 2;
4852
+ const { axis: h, at: g, span: m } = u.geometry, p = m / 2;
4853
4853
  let b;
4854
- if (m === "x")
4855
- b = [wn(d[0], g[0] - h, g[0] + h), g[1]];
4854
+ if (h === "x")
4855
+ b = [wn(d[0], g[0] - p, g[0] + p), g[1]];
4856
4856
  else {
4857
- const x = wn(d[1], g[1] - h, g[1] + h);
4857
+ const x = wn(d[1], g[1] - p, g[1] + p);
4858
4858
  b = [g[0], x];
4859
4859
  }
4860
4860
  return { wireId: e.id, path: kr(d, b) };
@@ -7221,7 +7221,7 @@ function V$(e) {
7221
7221
  }
7222
7222
  const J$ = 320;
7223
7223
  function ct(e) {
7224
- var v, P, j, F, G;
7224
+ var v, P, O, F, G;
7225
7225
  const t = vk(), n = /* @__PURE__ */ new Map();
7226
7226
  e.elements.forEach(($, H) => {
7227
7227
  if (n.has($.id)) {
@@ -7344,7 +7344,7 @@ function ct(e) {
7344
7344
  geometry: {
7345
7345
  at: ((v = H.layout) == null ? void 0 : v.at) ?? [0, 0],
7346
7346
  span: ((P = H.layout) == null ? void 0 : P.span) ?? J$,
7347
- rot: ((j = H.layout) == null ? void 0 : j.rot) ?? 0,
7347
+ rot: ((O = H.layout) == null ? void 0 : O.rot) ?? 0,
7348
7348
  axis: mo(((F = H.layout) == null ? void 0 : F.rot) ?? 0)
7349
7349
  }
7350
7350
  });
@@ -7365,33 +7365,33 @@ function ct(e) {
7365
7365
  }
7366
7366
  t.elementToTerminals.set($.element.id, W);
7367
7367
  }
7368
- const m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set();
7368
+ const h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set();
7369
7369
  for (const [$, H] of i)
7370
- (G = H.layout) != null && G.at ? (m.set($, [H.layout.at[0], H.layout.at[1]]), g.add($)) : u.junctions.has($) && (m.set($, u.junctions.get($)), g.add($));
7371
- const p = ($) => {
7370
+ (G = H.layout) != null && G.at ? (h.set($, [H.layout.at[0], H.layout.at[1]]), g.add($)) : u.junctions.has($) && (h.set($, u.junctions.get($)), g.add($));
7371
+ const m = ($) => {
7372
7372
  if (!$.includes(".")) {
7373
7373
  const W = t.buses.get($);
7374
- return W ? W.geometry.at : m.get($) ?? null;
7374
+ return W ? W.geometry.at : h.get($) ?? null;
7375
7375
  }
7376
7376
  const H = t.terminals.get($);
7377
7377
  return H ? H.world : null;
7378
- }, h = /* @__PURE__ */ new Map();
7379
- for (const [$] of i) g.has($) || h.set($, []);
7378
+ }, p = /* @__PURE__ */ new Map();
7379
+ for (const [$] of i) g.has($) || p.set($, []);
7380
7380
  for (const $ of c) {
7381
7381
  const [H, W] = $.ends;
7382
- h.has(H) && h.get(H).push(W), h.has(W) && h.get(W).push(H);
7382
+ p.has(H) && p.get(H).push(W), p.has(W) && p.get(W).push(H);
7383
7383
  }
7384
7384
  for (let $ = 0; $ < 12; $++) {
7385
7385
  let H = !1;
7386
- for (const [W, X] of h) {
7386
+ for (const [W, X] of p) {
7387
7387
  let I = 0, R = 0, Z = 0;
7388
7388
  for (const le of X) {
7389
- const ge = p(le);
7389
+ const ge = m(le);
7390
7390
  ge && (I += ge[0], R += ge[1], Z++);
7391
7391
  }
7392
7392
  if (!Z) continue;
7393
- const ae = I / Z, he = R / Z, ee = m.get(W);
7394
- (!ee || Math.abs(ee[0] - ae) > 0.01 || Math.abs(ee[1] - he) > 0.01) && (m.set(W, [ae, he]), H = !0);
7393
+ const ae = I / Z, he = R / Z, ee = h.get(W);
7394
+ (!ee || Math.abs(ee[0] - ae) > 0.01 || Math.abs(ee[1] - he) > 0.01) && (h.set(W, [ae, he]), H = !0);
7395
7395
  }
7396
7396
  if (!H) break;
7397
7397
  }
@@ -7405,7 +7405,7 @@ function ct(e) {
7405
7405
  for (const [$, H] of i)
7406
7406
  t.junctions.set($, {
7407
7407
  junction: H,
7408
- world: m.get($) ?? [0, 0],
7408
+ world: h.get($) ?? [0, 0],
7409
7409
  degree: b.get($) ?? 0
7410
7410
  });
7411
7411
  const x = new ns();
@@ -7757,10 +7757,10 @@ const y = Mn()(
7757
7757
  const { selection: n, selectedAnnotation: o, diagram: r, internal: i } = t();
7758
7758
  if (n.length === 0) {
7759
7759
  if (!o) return;
7760
- const p = (r.annotations ?? []).find(
7761
- (h) => h.id === o
7760
+ const m = (r.annotations ?? []).find(
7761
+ (p) => p.id === o
7762
7762
  );
7763
- if (!p) return;
7763
+ if (!m) return;
7764
7764
  e({
7765
7765
  clipboard: {
7766
7766
  elements: [],
@@ -7769,39 +7769,39 @@ const y = Mn()(
7769
7769
  placements: {},
7770
7770
  busLayouts: {},
7771
7771
  wires: [],
7772
- annotations: [structuredClone(p)]
7772
+ annotations: [structuredClone(m)]
7773
7773
  },
7774
7774
  clipboardPasteIndex: 0
7775
7775
  });
7776
7776
  return;
7777
7777
  }
7778
- const s = new Set(n), a = r.elements.filter((p) => s.has(p.id)).map((p) => structuredClone(p)), l = (r.buses ?? []).filter((p) => s.has(p.id)).map((p) => structuredClone(p)), c = (r.junctions ?? []).filter((p) => s.has(p.id)).map((p) => {
7778
+ const s = new Set(n), a = r.elements.filter((m) => s.has(m.id)).map((m) => structuredClone(m)), l = (r.buses ?? []).filter((m) => s.has(m.id)).map((m) => structuredClone(m)), c = (r.junctions ?? []).filter((m) => s.has(m.id)).map((m) => {
7779
7779
  var b;
7780
- const h = structuredClone(p);
7781
- if (!h.layout) {
7782
- const x = (b = i.junctions.get(p.id)) == null ? void 0 : b.world;
7783
- x && (h.layout = { at: [x[0], x[1]] });
7780
+ const p = structuredClone(m);
7781
+ if (!p.layout) {
7782
+ const x = (b = i.junctions.get(m.id)) == null ? void 0 : b.world;
7783
+ x && (p.layout = { at: [x[0], x[1]] });
7784
7784
  }
7785
- return h;
7785
+ return p;
7786
7786
  }), d = {};
7787
- for (const p of n)
7788
- if (s.has(p) && !i.buses.has(p)) {
7789
- const h = (g = r.layout) == null ? void 0 : g[p];
7790
- if (h) {
7791
- d[p] = structuredClone(h);
7787
+ for (const m of n)
7788
+ if (s.has(m) && !i.buses.has(m)) {
7789
+ const p = (g = r.layout) == null ? void 0 : g[m];
7790
+ if (p) {
7791
+ d[m] = structuredClone(p);
7792
7792
  continue;
7793
7793
  }
7794
- const b = i.layout.get(p);
7795
- b && (d[p] = sn(b));
7794
+ const b = i.layout.get(m);
7795
+ b && (d[m] = sn(b));
7796
7796
  }
7797
7797
  const u = {};
7798
- for (const p of n) {
7799
- const h = i.buses.get(p);
7800
- h && (u[p] = mt(h.geometry));
7798
+ for (const m of n) {
7799
+ const p = i.buses.get(m);
7800
+ p && (u[m] = mt(p.geometry));
7801
7801
  }
7802
- const m = (r.wires ?? []).filter(
7803
- (p) => p.ends.every((h) => s.has(Zn(h)))
7804
- ).map((p) => structuredClone(p));
7802
+ const h = (r.wires ?? []).filter(
7803
+ (m) => m.ends.every((p) => s.has(Zn(p)))
7804
+ ).map((m) => structuredClone(m));
7805
7805
  e({
7806
7806
  clipboard: {
7807
7807
  elements: a,
@@ -7809,7 +7809,7 @@ const y = Mn()(
7809
7809
  junctions: c,
7810
7810
  placements: d,
7811
7811
  busLayouts: u,
7812
- wires: m,
7812
+ wires: h,
7813
7813
  annotations: []
7814
7814
  },
7815
7815
  clipboardPasteIndex: 0
@@ -7825,13 +7825,13 @@ const y = Mn()(
7825
7825
  if (n.elements.length === 0 && n.buses.length === 0 && n.junctions.length === 0) {
7826
7826
  const u = n.annotations ?? [];
7827
7827
  if (u.length === 0) return;
7828
- const m = o + 1, g = Jn * m;
7829
- let p = null;
7830
- t().dispatch((h) => {
7831
- let b = h;
7828
+ const h = o + 1, g = Jn * h;
7829
+ let m = null;
7830
+ t().dispatch((p) => {
7831
+ let b = p;
7832
7832
  for (const x of u) {
7833
7833
  const v = Un(b);
7834
- p = v;
7834
+ m = v;
7835
7835
  const P = {
7836
7836
  ...structuredClone(x),
7837
7837
  id: v,
@@ -7843,65 +7843,65 @@ const y = Mn()(
7843
7843
  };
7844
7844
  }
7845
7845
  return b;
7846
- }), p && e({
7847
- selectedAnnotation: p,
7846
+ }), m && e({
7847
+ selectedAnnotation: m,
7848
7848
  selection: [],
7849
7849
  selectedWire: null,
7850
7850
  selectedNode: null,
7851
- clipboardPasteIndex: m
7851
+ clipboardPasteIndex: h
7852
7852
  });
7853
7853
  return;
7854
7854
  }
7855
7855
  const i = o + 1, s = Jn * i, a = Jn * i, l = /* @__PURE__ */ new Map();
7856
7856
  let c = r;
7857
7857
  for (const u of n.elements) {
7858
- const m = xn(c, u.kind);
7859
- l.set(u.id, m), c = {
7858
+ const h = xn(c, u.kind);
7859
+ l.set(u.id, h), c = {
7860
7860
  ...c,
7861
- elements: [...c.elements, { id: m, kind: u.kind }]
7861
+ elements: [...c.elements, { id: h, kind: u.kind }]
7862
7862
  };
7863
7863
  }
7864
7864
  for (const u of n.buses) {
7865
- const m = Nr(c);
7866
- l.set(u.id, m), c = {
7865
+ const h = Nr(c);
7866
+ l.set(u.id, h), c = {
7867
7867
  ...c,
7868
- buses: [...c.buses ?? [], { id: m }]
7868
+ buses: [...c.buses ?? [], { id: h }]
7869
7869
  };
7870
7870
  }
7871
7871
  for (const u of n.junctions) {
7872
- const m = Ar(c);
7873
- l.set(u.id, m), c = {
7872
+ const h = Ar(c);
7873
+ l.set(u.id, h), c = {
7874
7874
  ...c,
7875
- junctions: [...c.junctions ?? [], { id: m }]
7875
+ junctions: [...c.junctions ?? [], { id: h }]
7876
7876
  };
7877
7877
  }
7878
7878
  const d = (u) => {
7879
- const m = u.indexOf("."), g = m < 0 ? u : u.slice(0, m), p = l.get(g);
7880
- return p ? m < 0 ? p : `${p}${u.slice(m)}` : u;
7879
+ const h = u.indexOf("."), g = h < 0 ? u : u.slice(0, h), m = l.get(g);
7880
+ return m ? h < 0 ? m : `${m}${u.slice(h)}` : u;
7881
7881
  };
7882
7882
  t().dispatch((u) => {
7883
- const m = n.elements.map((v) => {
7883
+ const h = n.elements.map((v) => {
7884
7884
  const P = structuredClone(v);
7885
7885
  return P.id = l.get(v.id), P;
7886
7886
  }), g = n.buses.map((v) => {
7887
7887
  const P = structuredClone(v);
7888
7888
  P.id = l.get(v.id);
7889
- const j = n.busLayouts[v.id];
7890
- return j && (P.layout = {
7891
- ...j,
7892
- at: [j.at[0] + s, j.at[1] + a]
7889
+ const O = n.busLayouts[v.id];
7890
+ return O && (P.layout = {
7891
+ ...O,
7892
+ at: [O.at[0] + s, O.at[1] + a]
7893
7893
  }), P;
7894
- }), p = n.junctions.map((v) => {
7894
+ }), m = n.junctions.map((v) => {
7895
7895
  const P = structuredClone(v);
7896
7896
  return P.id = l.get(v.id), P.layout && (P.layout = {
7897
7897
  at: [P.layout.at[0] + s, P.layout.at[1] + a]
7898
7898
  }), P;
7899
- }), h = { ...u.layout ?? {} };
7899
+ }), p = { ...u.layout ?? {} };
7900
7900
  for (const [v, P] of l) {
7901
- const j = n.placements[v];
7902
- j && (h[P] = {
7903
- ...j,
7904
- at: [j.at[0] + s, j.at[1] + a]
7901
+ const O = n.placements[v];
7902
+ O && (p[P] = {
7903
+ ...O,
7904
+ at: [O.at[0] + s, O.at[1] + a]
7905
7905
  });
7906
7906
  }
7907
7907
  const b = n.wires.map((v) => {
@@ -7917,11 +7917,11 @@ const y = Mn()(
7917
7917
  }), x = Mr(u.wires ?? [], b);
7918
7918
  return {
7919
7919
  ...u,
7920
- elements: [...u.elements, ...m],
7920
+ elements: [...u.elements, ...h],
7921
7921
  buses: g.length ? [...u.buses ?? [], ...g] : u.buses,
7922
- junctions: p.length ? [...u.junctions ?? [], ...p] : u.junctions,
7922
+ junctions: m.length ? [...u.junctions ?? [], ...m] : u.junctions,
7923
7923
  wires: x.length ? x : void 0,
7924
- layout: Object.keys(h).length ? h : void 0
7924
+ layout: Object.keys(p).length ? p : void 0
7925
7925
  };
7926
7926
  }), e({
7927
7927
  selection: Array.from(l.values()),
@@ -8005,7 +8005,7 @@ const y = Mn()(
8005
8005
  for (const d of n)
8006
8006
  if (o.buses.has(d)) {
8007
8007
  const u = o.buses.get(d);
8008
- (c = r.buses) != null && c.find((m) => m.id === d && m.layout) || a.set(d, mt(u.geometry));
8008
+ (c = r.buses) != null && c.find((h) => h.id === d && h.layout) || a.set(d, mt(u.geometry));
8009
8009
  } else {
8010
8010
  if (i[d]) continue;
8011
8011
  const u = o.layout.get(d);
@@ -8037,7 +8037,7 @@ const y = Mn()(
8037
8037
  a.set(d, u);
8038
8038
  continue;
8039
8039
  }
8040
- const m = o.layout.get(d), g = i[d] ?? (m ? sn(m) : { at: [0, 0] });
8040
+ const h = o.layout.get(d), g = i[d] ?? (h ? sn(h) : { at: [0, 0] });
8041
8041
  i[d] = {
8042
8042
  ...g,
8043
8043
  at: [g.at[0] + u[0], g.at[1] + u[1]]
@@ -8047,22 +8047,22 @@ const y = Mn()(
8047
8047
  s.size > 0 && (l = (r.buses ?? []).map((d) => {
8048
8048
  const u = s.get(d.id);
8049
8049
  if (!u) return d;
8050
- const m = d.layout ?? mt(o.buses.get(d.id).geometry);
8050
+ const h = d.layout ?? mt(o.buses.get(d.id).geometry);
8051
8051
  return {
8052
8052
  ...d,
8053
8053
  layout: {
8054
- ...m,
8055
- at: [m.at[0] + u[0], m.at[1] + u[1]]
8054
+ ...h,
8055
+ at: [h.at[0] + u[0], h.at[1] + u[1]]
8056
8056
  }
8057
8057
  };
8058
8058
  }));
8059
8059
  let c = r.junctions;
8060
8060
  return a.size > 0 && (c = (r.junctions ?? []).map((d) => {
8061
- var g, p;
8061
+ var g, m;
8062
8062
  const u = a.get(d.id);
8063
8063
  if (!u) return d;
8064
- const m = ((g = d.layout) == null ? void 0 : g.at) ?? ((p = o.junctions.get(d.id)) == null ? void 0 : p.world) ?? [0, 0];
8065
- return { ...d, layout: { at: [m[0] + u[0], m[1] + u[1]] } };
8064
+ const h = ((g = d.layout) == null ? void 0 : g.at) ?? ((m = o.junctions.get(d.id)) == null ? void 0 : m.world) ?? [0, 0];
8065
+ return { ...d, layout: { at: [h[0] + u[0], h[1] + u[1]] } };
8066
8066
  })), { ...r, layout: i, buses: l, junctions: c };
8067
8067
  });
8068
8068
  },
@@ -8101,10 +8101,10 @@ const y = Mn()(
8101
8101
  const c = { ...s.layout ?? {} };
8102
8102
  for (const u of i) {
8103
8103
  if (c[u]) continue;
8104
- const m = o.layout.get(u);
8105
- if (!m) continue;
8106
- const g = { at: m.at };
8107
- m.rot && (g.rot = m.rot), m.mirror && (g.mirror = m.mirror), c[u] = g;
8104
+ const h = o.layout.get(u);
8105
+ if (!h) continue;
8106
+ const g = { at: h.at };
8107
+ h.rot && (g.rot = h.rot), h.mirror && (g.mirror = h.mirror), c[u] = g;
8108
8108
  }
8109
8109
  const d = Vn(a, l, s.junctions ?? []);
8110
8110
  return {
@@ -8127,15 +8127,15 @@ const y = Mn()(
8127
8127
  }
8128
8128
  t().dispatch((a) => {
8129
8129
  const l = { ...a.layout ?? {} };
8130
- for (const m of s) {
8131
- if (l[m]) continue;
8132
- const g = o.layout.get(m);
8130
+ for (const h of s) {
8131
+ if (l[h]) continue;
8132
+ const g = o.layout.get(h);
8133
8133
  if (!g) continue;
8134
- const p = { at: g.at };
8135
- g.rot && (p.rot = g.rot), g.mirror && (p.mirror = g.mirror), l[m] = p;
8134
+ const m = { at: g.at };
8135
+ g.rot && (m.rot = g.rot), g.mirror && (m.mirror = g.mirror), l[h] = m;
8136
8136
  }
8137
8137
  const c = a.wires ?? [], d = c.filter(
8138
- (m) => !i.has(m.ends[0]) && !i.has(m.ends[1])
8138
+ (h) => !i.has(h.ends[0]) && !i.has(h.ends[1])
8139
8139
  ), u = Vn(c, d, a.junctions ?? []);
8140
8140
  return {
8141
8141
  ...a,
@@ -8148,7 +8148,7 @@ const y = Mn()(
8148
8148
  rotateSelection: (n) => {
8149
8149
  const { selection: o, internal: r } = t();
8150
8150
  o.length !== 0 && t().dispatch((i) => {
8151
- var c, d, u, m;
8151
+ var c, d, u, h;
8152
8152
  const s = { ...i.layout ?? {} }, a = /* @__PURE__ */ new Map();
8153
8153
  for (const g of o) {
8154
8154
  if (r.junctions.has(g)) continue;
@@ -8157,14 +8157,14 @@ const y = Mn()(
8157
8157
  a.set(g, v);
8158
8158
  continue;
8159
8159
  }
8160
- const p = s[g] ?? { at: ((m = r.layout.get(g)) == null ? void 0 : m.at) ?? [0, 0] }, h = (((p.rot ?? 0) + n) % 360 + 360) % 360;
8161
- s[g] = { ...p, rot: h };
8160
+ const m = s[g] ?? { at: ((h = r.layout.get(g)) == null ? void 0 : h.at) ?? [0, 0] }, p = (((m.rot ?? 0) + n) % 360 + 360) % 360;
8161
+ s[g] = { ...m, rot: p };
8162
8162
  }
8163
8163
  let l = i.buses;
8164
8164
  return a.size > 0 && (l = (i.buses ?? []).map((g) => {
8165
8165
  if (!a.has(g.id)) return g;
8166
- const p = g.layout ?? mt(r.buses.get(g.id).geometry);
8167
- return { ...g, layout: { ...p, rot: a.get(g.id) } };
8166
+ const m = g.layout ?? mt(r.buses.get(g.id).geometry);
8167
+ return { ...g, layout: { ...m, rot: a.get(g.id) } };
8168
8168
  })), { ...i, layout: s, buses: l };
8169
8169
  });
8170
8170
  },
@@ -8237,41 +8237,41 @@ const y = Mn()(
8237
8237
  t().dispatch((r) => {
8238
8238
  let i = r;
8239
8239
  const s = /* @__PURE__ */ new Set([
8240
- ...i.elements.map((p) => p.id),
8241
- ...(i.buses ?? []).map((p) => p.id),
8242
- ...(i.junctions ?? []).map((p) => p.id)
8240
+ ...i.elements.map((m) => m.id),
8241
+ ...(i.buses ?? []).map((m) => m.id),
8242
+ ...(i.junctions ?? []).map((m) => m.id)
8243
8243
  ]), a = () => {
8244
- let p = 1;
8245
- for (; s.has(`J${p}`); ) p++;
8246
- const h = `J${p}`;
8247
- return s.add(h), h;
8248
- }, l = (p) => {
8249
- const h = a();
8244
+ let m = 1;
8245
+ for (; s.has(`J${m}`); ) m++;
8246
+ const p = `J${m}`;
8247
+ return s.add(p), p;
8248
+ }, l = (m) => {
8249
+ const p = a();
8250
8250
  return i = {
8251
8251
  ...i,
8252
- junctions: [...i.junctions ?? [], { id: h, layout: { at: p } }]
8253
- }, h;
8254
- }, c = (p) => {
8255
- if ("end" in p) return p.end;
8256
- if ("junctionAt" in p) return l(p.junctionAt);
8257
- const h = (i.wires ?? []).find((P) => P.id === p.onWire), b = l(p.at);
8258
- if (!h) return b;
8259
- const x = (i.wires ?? []).filter((P) => P.id !== p.onWire), v = (P, j) => ({
8260
- id: yt(P, j),
8261
- ends: [P, j],
8262
- ...h.label ? { label: h.label } : {}
8252
+ junctions: [...i.junctions ?? [], { id: p, layout: { at: m } }]
8253
+ }, p;
8254
+ }, c = (m) => {
8255
+ if ("end" in m) return m.end;
8256
+ if ("junctionAt" in m) return l(m.junctionAt);
8257
+ const p = (i.wires ?? []).find((P) => P.id === m.onWire), b = l(m.at);
8258
+ if (!p) return b;
8259
+ const x = (i.wires ?? []).filter((P) => P.id !== m.onWire), v = (P, O) => ({
8260
+ id: yt(P, O),
8261
+ ends: [P, O],
8262
+ ...p.label ? { label: p.label } : {}
8263
8263
  });
8264
8264
  return i = {
8265
8265
  ...i,
8266
8266
  wires: Mr(x, [
8267
- v(h.ends[0], b),
8268
- v(b, h.ends[1])
8267
+ v(p.ends[0], b),
8268
+ v(b, p.ends[1])
8269
8269
  ])
8270
8270
  }, b;
8271
8271
  }, d = c(n), u = c(o);
8272
8272
  if (d === null || u === null || d === u) return i;
8273
- const m = yt(d, u), g = i.wires ?? [];
8274
- return g.some((p) => p.id === m) ? i : { ...i, wires: [...g, { id: m, ends: [d, u] }] };
8273
+ const h = yt(d, u), g = i.wires ?? [];
8274
+ return g.some((m) => m.id === h) ? i : { ...i, wires: [...g, { id: h, ends: [d, u] }] };
8275
8275
  });
8276
8276
  },
8277
8277
  updateWirePath: (n, o) => {
@@ -8444,20 +8444,20 @@ function sv(e, t) {
8444
8444
  return { newElementId: o.addElement(e, t), attachedToBus: !1 };
8445
8445
  const i = r4(r, t);
8446
8446
  if (!i) {
8447
- const h = av(n), b = h ? [ue(t[0]) - h.x, ue(t[1]) - h.y] : [ue(t[0]), ue(t[1])];
8447
+ const p = av(n), b = p ? [ue(t[0]) - p.x, ue(t[1]) - p.y] : [ue(t[0]), ue(t[1])];
8448
8448
  return { newElementId: o.addElement(e, b), attachedToBus: !1 };
8449
8449
  }
8450
- const { busId: s, busAt: a, axis: l } = i, c = i4(n, l), d = xn(r, e), u = n.terminals.find((h) => h.id === c), m = l === "x" ? t[0] : a[0], g = l === "y" ? t[1] : a[1], p = u ? [ue(m) - u.x, ue(g) - u.y] : [ue(t[0]), ue(t[1])];
8451
- return o.dispatch((h) => {
8452
- const b = { id: d, kind: e }, x = { at: p }, v = `${d}.${c}`, P = {
8450
+ const { busId: s, busAt: a, axis: l } = i, c = i4(n, l), d = xn(r, e), u = n.terminals.find((p) => p.id === c), h = l === "x" ? t[0] : a[0], g = l === "y" ? t[1] : a[1], m = u ? [ue(h) - u.x, ue(g) - u.y] : [ue(t[0]), ue(t[1])];
8451
+ return o.dispatch((p) => {
8452
+ const b = { id: d, kind: e }, x = { at: m }, v = `${d}.${c}`, P = {
8453
8453
  id: yt(s, v),
8454
8454
  ends: [s, v]
8455
8455
  };
8456
8456
  return {
8457
- ...h,
8458
- elements: [...h.elements, b],
8459
- wires: [...h.wires ?? [], P],
8460
- layout: { ...h.layout ?? {}, [d]: x }
8457
+ ...p,
8458
+ elements: [...p.elements, b],
8459
+ wires: [...p.wires ?? [], P],
8460
+ layout: { ...p.layout ?? {}, [d]: x }
8461
8461
  };
8462
8462
  }), o.setSelection([d]), { newElementId: d, attachedToBus: !0 };
8463
8463
  }
@@ -8470,11 +8470,11 @@ function r4(e, t) {
8470
8470
  const { axis: s, at: a, span: l } = i.geometry;
8471
8471
  let c;
8472
8472
  if (s === "x") {
8473
- const d = a[0] - l / 2, u = a[0] + l / 2, m = t[0] < d ? d - t[0] : t[0] > u ? t[0] - u : 0, g = Math.abs(t[1] - a[1]);
8474
- c = Math.sqrt(m * m + g * g);
8473
+ const d = a[0] - l / 2, u = a[0] + l / 2, h = t[0] < d ? d - t[0] : t[0] > u ? t[0] - u : 0, g = Math.abs(t[1] - a[1]);
8474
+ c = Math.sqrt(h * h + g * g);
8475
8475
  } else {
8476
- const d = a[1] - l / 2, u = a[1] + l / 2, m = t[1] < d ? d - t[1] : t[1] > u ? t[1] - u : 0, g = Math.abs(t[0] - a[0]);
8477
- c = Math.sqrt(g * g + m * m);
8476
+ const d = a[1] - l / 2, u = a[1] + l / 2, h = t[1] < d ? d - t[1] : t[1] > u ? t[1] - u : 0, g = Math.abs(t[0] - a[0]);
8477
+ c = Math.sqrt(g * g + h * h);
8478
8478
  }
8479
8479
  c <= n4 && (!o || c < o.dist) && (o = { busId: r.id, busAt: [a[0], a[1]], axis: s, dist: c });
8480
8480
  }
@@ -8493,11 +8493,11 @@ function lv(e, t) {
8493
8493
  if (!e.includes(".") && n.buses.has(e)) {
8494
8494
  const r = n.buses.get(e), { axis: i, at: s, span: a } = r.geometry;
8495
8495
  if (i === "x") {
8496
- const g = s[0] - a / 2, p = s[0] + a / 2, h = Math.max(g, Math.min(p, t[0])), b = s[1], x = t[1] >= b ? "s" : "n";
8497
- return { ref: e, world: [h, b], orientation: x, isBus: !0, busId: e };
8496
+ const g = s[0] - a / 2, m = s[0] + a / 2, p = Math.max(g, Math.min(m, t[0])), b = s[1], x = t[1] >= b ? "s" : "n";
8497
+ return { ref: e, world: [p, b], orientation: x, isBus: !0, busId: e };
8498
8498
  }
8499
- const l = s[1] - a / 2, c = s[1] + a / 2, d = Math.max(l, Math.min(c, t[1])), u = s[0], m = t[0] >= u ? "e" : "w";
8500
- return { ref: e, world: [u, d], orientation: m, isBus: !0, busId: e };
8499
+ const l = s[1] - a / 2, c = s[1] + a / 2, d = Math.max(l, Math.min(c, t[1])), u = s[0], h = t[0] >= u ? "e" : "w";
8500
+ return { ref: e, world: [u, d], orientation: h, isBus: !0, busId: e };
8501
8501
  }
8502
8502
  if (!e.includes(".") && n.junctions.has(e)) {
8503
8503
  const r = n.junctions.get(e), [i, s] = r.world, a = t[0] - i, l = t[1] - s, c = Math.abs(a) >= Math.abs(l) ? a >= 0 ? "e" : "w" : l >= 0 ? "s" : "n";
@@ -8537,22 +8537,22 @@ function a4(e, t, n) {
8537
8537
  if (!o) return null;
8538
8538
  const s = lv(t, n);
8539
8539
  if (!s) return null;
8540
- const a = n[0] - s.world[0], l = n[1] - s.world[1], c = a * a + l * l <= o4, d = [ue(n[0]), ue(n[1])], u = cv(o, s, d), m = c ? s.world : d, g = [
8541
- ue(m[0] - u.x),
8542
- ue(m[1] - u.y)
8543
- ], p = xn(i, e);
8544
- return r.dispatch((h) => {
8545
- const b = { id: p, kind: e }, x = { at: g }, v = `${p}.${u.id}`, P = s.isBus && s.busId ? s.busId : t, j = {
8540
+ const a = n[0] - s.world[0], l = n[1] - s.world[1], c = a * a + l * l <= o4, d = [ue(n[0]), ue(n[1])], u = cv(o, s, d), h = c ? s.world : d, g = [
8541
+ ue(h[0] - u.x),
8542
+ ue(h[1] - u.y)
8543
+ ], m = xn(i, e);
8544
+ return r.dispatch((p) => {
8545
+ const b = { id: m, kind: e }, x = { at: g }, v = `${m}.${u.id}`, P = s.isBus && s.busId ? s.busId : t, O = {
8546
8546
  id: yt(P, v),
8547
8547
  ends: [P, v]
8548
8548
  };
8549
8549
  return {
8550
- ...h,
8551
- elements: [...h.elements, b],
8552
- wires: [...h.wires ?? [], j],
8553
- layout: { ...h.layout ?? {}, [p]: x }
8550
+ ...p,
8551
+ elements: [...p.elements, b],
8552
+ wires: [...p.wires ?? [], O],
8553
+ layout: { ...p.layout ?? {}, [m]: x }
8554
8554
  };
8555
- }), r.setSelection([p]), { newElementId: p, attachedToBus: s.isBus };
8555
+ }), r.setSelection([m]), { newElementId: m, attachedToBus: s.isBus };
8556
8556
  }
8557
8557
  const Kt = 9, Fe = 7;
8558
8558
  function Pn(e, t) {
@@ -8641,7 +8641,7 @@ function c4() {
8641
8641
  ), r = y((i) => i.editingElement);
8642
8642
  return /* @__PURE__ */ C("g", { className: "ole-annotation-layer", pointerEvents: "none", children: [
8643
8643
  Array.from(e.values()).map((i) => {
8644
- var m;
8644
+ var h;
8645
8645
  const s = t.get(i.element.id);
8646
8646
  if (!s || !i.libraryDef) return null;
8647
8647
  const a = i.libraryDef.label ?? In(i.libraryDef), l = Pn(i, o), { world: c, textAnchor: d, dy: u } = On(
@@ -8654,7 +8654,7 @@ function c4() {
8654
8654
  d4,
8655
8655
  {
8656
8656
  elementId: i.element.id,
8657
- currentName: ((m = i.element.name) == null ? void 0 : m.trim()) || i.element.id,
8657
+ currentName: ((h = i.element.name) == null ? void 0 : h.trim()) || i.element.id,
8658
8658
  world: c,
8659
8659
  anchor: d
8660
8660
  },
@@ -8664,16 +8664,16 @@ function c4() {
8664
8664
  {
8665
8665
  className: "ole-annotation",
8666
8666
  transform: `translate(${c[0]} ${c[1]})`,
8667
- children: l.map((g, p) => /* @__PURE__ */ f(
8667
+ children: l.map((g, m) => /* @__PURE__ */ f(
8668
8668
  "text",
8669
8669
  {
8670
8670
  x: 0,
8671
- y: u + p * Kt,
8671
+ y: u + m * Kt,
8672
8672
  textAnchor: d,
8673
8673
  className: "ole-annotation-text",
8674
8674
  children: g
8675
8675
  },
8676
- p
8676
+ m
8677
8677
  ))
8678
8678
  },
8679
8679
  i.element.id
@@ -8716,13 +8716,13 @@ function d4({
8716
8716
  d == null || d.removeAllRanges(), d == null || d.addRange(c);
8717
8717
  }, [e]);
8718
8718
  function i() {
8719
- var m;
8719
+ var h;
8720
8720
  const l = y.getState(), c = l.diagram.elements.find((g) => g.id === e);
8721
8721
  if (!c) {
8722
8722
  l.setEditingElement(null);
8723
8723
  return;
8724
8724
  }
8725
- const d = (((m = r.current) == null ? void 0 : m.innerText) ?? "").replace(/\u00a0/g, " ").trim(), u = d === "" || d === e ? void 0 : d;
8725
+ const d = (((h = r.current) == null ? void 0 : h.innerText) ?? "").replace(/\u00a0/g, " ").trim(), u = d === "" || d === e ? void 0 : d;
8726
8726
  u !== c.name && l.updateElement(e, { name: u }), l.setEditingElement(null);
8727
8727
  }
8728
8728
  function s(l) {
@@ -9032,24 +9032,24 @@ function x4({
9032
9032
  var g;
9033
9033
  const [o, r] = e.at, [i, s] = Je(e), a = St(e), l = $t(e), c = e.fontSize ?? vt;
9034
9034
  let d = "";
9035
- for (let p = 1; p < e.colWidths.length; p++)
9036
- d += `M${o + a[p]} ${r}V${r + s}`;
9037
- for (let p = 1; p < e.rowHeights.length; p++)
9038
- d += `M${o} ${r + l[p]}H${o + i}`;
9039
- const u = [], m = [];
9040
- for (let p = 0; p < e.rowHeights.length; p++)
9041
- for (let h = 0; h < e.colWidths.length; h++) {
9042
- const b = ((g = e.cells[p]) == null ? void 0 : g[h]) ?? "";
9035
+ for (let m = 1; m < e.colWidths.length; m++)
9036
+ d += `M${o + a[m]} ${r}V${r + s}`;
9037
+ for (let m = 1; m < e.rowHeights.length; m++)
9038
+ d += `M${o} ${r + l[m]}H${o + i}`;
9039
+ const u = [], h = [];
9040
+ for (let m = 0; m < e.rowHeights.length; m++)
9041
+ for (let p = 0; p < e.colWidths.length; p++) {
9042
+ const b = ((g = e.cells[m]) == null ? void 0 : g[p]) ?? "";
9043
9043
  if (b === "") continue;
9044
- const x = e.colWidths[h], v = o + a[h] + Wt, P = r + l[p] + e.rowHeights[p] / 2 + c * 0.35, j = b.length * c * 0.55 > x - 2 * Wt, F = `ole-ann-clip-${e.id}-${p}-${h}`;
9045
- j && m.push(
9044
+ const x = e.colWidths[p], v = o + a[p] + Wt, P = r + l[m] + e.rowHeights[m] / 2 + c * 0.35, O = b.length * c * 0.55 > x - 2 * Wt, F = `ole-ann-clip-${e.id}-${m}-${p}`;
9045
+ O && h.push(
9046
9046
  /* @__PURE__ */ f("clipPath", { id: F, children: /* @__PURE__ */ f(
9047
9047
  "rect",
9048
9048
  {
9049
- x: o + a[h],
9050
- y: r + l[p],
9049
+ x: o + a[p],
9050
+ y: r + l[m],
9051
9051
  width: x,
9052
- height: e.rowHeights[p]
9052
+ height: e.rowHeights[m]
9053
9053
  }
9054
9054
  ) }, F)
9055
9055
  ), u.push(
@@ -9060,10 +9060,10 @@ function x4({
9060
9060
  x: v,
9061
9061
  y: P,
9062
9062
  fontSize: c,
9063
- clipPath: j ? `url(#${F})` : void 0,
9063
+ clipPath: O ? `url(#${F})` : void 0,
9064
9064
  children: b
9065
9065
  },
9066
- `${p}-${h}`
9066
+ `${m}-${p}`
9067
9067
  )
9068
9068
  );
9069
9069
  }
@@ -9074,7 +9074,7 @@ function x4({
9074
9074
  className: "ole-ann ole-ann-table",
9075
9075
  "data-selected": t ? "true" : void 0,
9076
9076
  children: [
9077
- m.length > 0 && /* @__PURE__ */ f("defs", { children: m }),
9077
+ h.length > 0 && /* @__PURE__ */ f("defs", { children: h }),
9078
9078
  /* @__PURE__ */ f("rect", { className: "ole-ann-table-bg", x: o, y: r, width: i, height: s }),
9079
9079
  d && /* @__PURE__ */ f("path", { className: "ole-ann-table-grid", d }),
9080
9080
  /* @__PURE__ */ f("rect", { className: "ole-ann-table-border", x: o, y: r, width: i, height: s }),
@@ -9091,43 +9091,43 @@ function v4({
9091
9091
  var g;
9092
9092
  const [n, o] = t, r = fe(null), i = St(e), s = $t(e), a = e.fontSize ?? vt, l = ((g = e.cells[n]) == null ? void 0 : g[o]) ?? "";
9093
9093
  se(() => {
9094
- const p = r.current;
9095
- p && (p.focus(), p.select());
9094
+ const m = r.current;
9095
+ m && (m.focus(), m.select());
9096
9096
  }, [n, o]);
9097
9097
  function c() {
9098
9098
  var b;
9099
- const p = y.getState(), h = ((b = r.current) == null ? void 0 : b.value) ?? "";
9100
- if (h !== l) {
9099
+ const m = y.getState(), p = ((b = r.current) == null ? void 0 : b.value) ?? "";
9100
+ if (p !== l) {
9101
9101
  const x = e.cells.map((v) => [...v]);
9102
9102
  for (; x.length <= n; ) x.push([]);
9103
- x[n][o] = h, p.updateAnnotation(e.id, { cells: x });
9103
+ x[n][o] = p, m.updateAnnotation(e.id, { cells: x });
9104
9104
  }
9105
9105
  }
9106
9106
  function d() {
9107
9107
  y.getState().setEditingAnnotation(null);
9108
9108
  }
9109
- function u(p, h) {
9109
+ function u(m, p) {
9110
9110
  const b = e.rowHeights.length, x = e.colWidths.length;
9111
- if (h >= x ? (h = 0, p += 1) : h < 0 && (h = x - 1, p -= 1), p < 0 || p >= b) {
9111
+ if (p >= x ? (p = 0, m += 1) : p < 0 && (p = x - 1, m -= 1), m < 0 || m >= b) {
9112
9112
  d();
9113
9113
  return;
9114
9114
  }
9115
- y.getState().setEditingCell([p, h]);
9115
+ y.getState().setEditingCell([m, p]);
9116
9116
  }
9117
- function m(p) {
9118
- if (p.key === "Enter") {
9119
- p.preventDefault(), c(), u(n + 1, o);
9117
+ function h(m) {
9118
+ if (m.key === "Enter") {
9119
+ m.preventDefault(), c(), u(n + 1, o);
9120
9120
  return;
9121
9121
  }
9122
- if (p.key === "Tab") {
9123
- p.preventDefault(), c(), u(n, p.shiftKey ? o - 1 : o + 1);
9122
+ if (m.key === "Tab") {
9123
+ m.preventDefault(), c(), u(n, m.shiftKey ? o - 1 : o + 1);
9124
9124
  return;
9125
9125
  }
9126
- if (p.key === "Escape") {
9127
- p.preventDefault(), r.current && (r.current.value = l), c(), d();
9126
+ if (m.key === "Escape") {
9127
+ m.preventDefault(), r.current && (r.current.value = l), c(), d();
9128
9128
  return;
9129
9129
  }
9130
- p.stopPropagation();
9130
+ m.stopPropagation();
9131
9131
  }
9132
9132
  return /* @__PURE__ */ f(
9133
9133
  "foreignObject",
@@ -9145,9 +9145,9 @@ function v4({
9145
9145
  onBlur: () => {
9146
9146
  c(), d();
9147
9147
  },
9148
- onKeyDown: m,
9149
- onPointerDown: (p) => p.stopPropagation(),
9150
- onMouseDown: (p) => p.stopPropagation(),
9148
+ onKeyDown: h,
9149
+ onPointerDown: (m) => m.stopPropagation(),
9150
+ onMouseDown: (m) => m.stopPropagation(),
9151
9151
  style: {
9152
9152
  width: "100%",
9153
9153
  height: "100%",
@@ -9353,16 +9353,16 @@ function Jt(e, t, n) {
9353
9353
  }, onPointerMove: (l) => {
9354
9354
  const c = o.current, d = Ue();
9355
9355
  if (!c || l.pointerId !== c.pointerId || !d) return;
9356
- const u = d.screenToSvg(l.clientX, l.clientY), m = ue(u[0] - c.startSvg[0]), g = ue(u[1] - c.startSvg[1]);
9357
- y.getState().setAnnotationPreview(t(c.orig, m, g, l.nativeEvent));
9356
+ const u = d.screenToSvg(l.clientX, l.clientY), h = ue(u[0] - c.startSvg[0]), g = ue(u[1] - c.startSvg[1]);
9357
+ y.getState().setAnnotationPreview(t(c.orig, h, g, l.nativeEvent));
9358
9358
  }, onPointerUp: (l) => {
9359
9359
  const c = o.current;
9360
9360
  if (!c || l.pointerId !== c.pointerId) return;
9361
9361
  o.current = null;
9362
9362
  const d = l.target;
9363
9363
  d.hasPointerCapture(l.pointerId) && d.releasePointerCapture(l.pointerId);
9364
- const u = y.getState(), m = u.annotationPreview;
9365
- u.setAnnotationPreview(null), m && m.id === e.id && u.updateAnnotation(e.id, n(m));
9364
+ const u = y.getState(), h = u.annotationPreview;
9365
+ u.setAnnotationPreview(null), h && h.id === e.id && u.updateAnnotation(e.id, n(h));
9366
9366
  }, onPointerCancel: (l) => {
9367
9367
  const c = o.current;
9368
9368
  !c || l.pointerId !== c.pointerId || (o.current = null, y.getState().setAnnotationPreview(null));
@@ -9473,11 +9473,11 @@ function T4({
9473
9473
  a,
9474
9474
  po * i.colWidths.length,
9475
9475
  go * i.rowHeights.length
9476
- ), d = Dr(i.colWidths, c.size[0] / l[0], po), u = Dr(i.rowHeights, c.size[1] / l[1], go), m = d.reduce((h, b) => h + b, 0), g = u.reduce((h, b) => h + b, 0), p = [
9477
- e.dirX === -1 ? i.at[0] + l[0] - m : i.at[0],
9476
+ ), d = Dr(i.colWidths, c.size[0] / l[0], po), u = Dr(i.rowHeights, c.size[1] / l[1], go), h = d.reduce((p, b) => p + b, 0), g = u.reduce((p, b) => p + b, 0), m = [
9477
+ e.dirX === -1 ? i.at[0] + l[0] - h : i.at[0],
9478
9478
  e.dirY === -1 ? i.at[1] + l[1] - g : i.at[1]
9479
9479
  ];
9480
- return { ...i, at: p, colWidths: d, rowHeights: u };
9480
+ return { ...i, at: m, colWidths: d, rowHeights: u };
9481
9481
  },
9482
9482
  (i) => ({
9483
9483
  at: i.at,
@@ -9649,10 +9649,10 @@ function zr({
9649
9649
  }, l = (d) => {
9650
9650
  const u = s.current;
9651
9651
  if (!u || d.pointerId !== u.pointerId || !i) return;
9652
- const m = i.screenToSvg(d.clientX, d.clientY), g = r === "x" ? m[0] - u.startSvg[0] : m[1] - u.startSvg[1], p = iv() ? Math.round(g / vn) * vn : g, h = u.startSpan + (o === "end" ? p : -p);
9653
- if (h < O4) return;
9654
- const b = r === "x" ? [u.startAt[0] + p / 2, u.startAt[1]] : [u.startAt[0], u.startAt[1] + p / 2];
9655
- y.getState().updateBus(n, { span: h, at: b });
9652
+ const h = i.screenToSvg(d.clientX, d.clientY), g = r === "x" ? h[0] - u.startSvg[0] : h[1] - u.startSvg[1], m = iv() ? Math.round(g / vn) * vn : g, p = u.startSpan + (o === "end" ? m : -m);
9653
+ if (p < O4) return;
9654
+ const b = r === "x" ? [u.startAt[0] + m / 2, u.startAt[1]] : [u.startAt[0], u.startAt[1] + m / 2];
9655
+ y.getState().updateBus(n, { span: p, at: b });
9656
9656
  }, c = (d) => {
9657
9657
  const u = s.current;
9658
9658
  !u || d.pointerId !== u.pointerId || (d.target.hasPointerCapture(d.pointerId) && d.target.releasePointerCapture(d.pointerId), s.current = null);
@@ -9683,14 +9683,14 @@ function B4() {
9683
9683
  if (!n || n.path.length < 2) return null;
9684
9684
  const o = n.path, r = o.length, i = [];
9685
9685
  for (let a = 1; a < r - 1; a++) {
9686
- const l = zt(o[a - 1], o[a]), c = zt(o[a], o[a + 1]), d = a - 1 === 0, u = a + 1 === r - 1, m = d && l === "v" || u && c === "v", g = d && l === "h" || u && c === "h";
9687
- m && g || i.push(
9686
+ const l = zt(o[a - 1], o[a]), c = zt(o[a], o[a + 1]), d = a - 1 === 0, u = a + 1 === r - 1, h = d && l === "v" || u && c === "v", g = d && l === "h" || u && c === "h";
9687
+ h && g || i.push(
9688
9688
  /* @__PURE__ */ f(
9689
9689
  L4,
9690
9690
  {
9691
9691
  wireId: e,
9692
9692
  index: a,
9693
- xLocked: m,
9693
+ xLocked: h,
9694
9694
  yLocked: g
9695
9695
  },
9696
9696
  `v-${a}`
@@ -9723,41 +9723,41 @@ function L4({
9723
9723
  xLocked: n,
9724
9724
  yLocked: o
9725
9725
  }) {
9726
- const r = Ue(), i = fe(null), s = y((p) => {
9727
- var h;
9728
- return (h = p.internal.wireRenders.get(e)) == null ? void 0 : h.path;
9726
+ const r = Ue(), i = fe(null), s = y((m) => {
9727
+ var p;
9728
+ return (p = m.internal.wireRenders.get(e)) == null ? void 0 : p.path;
9729
9729
  });
9730
9730
  if (!s || t <= 0 || t >= s.length - 1) return null;
9731
- const [a, l] = s[t], c = n && !o ? "ns-resize" : !n && o ? "ew-resize" : "move", d = (p) => {
9732
- if (p.button !== 0 || (p.stopPropagation(), p.preventDefault(), !r)) return;
9733
- const h = y.getState().internal.wireRenders.get(e);
9734
- h && (i.current = {
9735
- pointerId: p.pointerId,
9736
- startPath: h.path.map((b) => [b[0], b[1]]),
9737
- startSvg: r.screenToSvg(p.clientX, p.clientY),
9731
+ const [a, l] = s[t], c = n && !o ? "ns-resize" : !n && o ? "ew-resize" : "move", d = (m) => {
9732
+ if (m.button !== 0 || (m.stopPropagation(), m.preventDefault(), !r)) return;
9733
+ const p = y.getState().internal.wireRenders.get(e);
9734
+ p && (i.current = {
9735
+ pointerId: m.pointerId,
9736
+ startPath: p.path.map((b) => [b[0], b[1]]),
9737
+ startSvg: r.screenToSvg(m.clientX, m.clientY),
9738
9738
  index: t,
9739
9739
  xLocked: n,
9740
9740
  yLocked: o
9741
- }, document.body.style.cursor = c, p.target.setPointerCapture(p.pointerId));
9742
- }, u = (p) => {
9743
- const h = i.current;
9744
- if (!h || p.pointerId !== h.pointerId || !r) return;
9745
- const b = r.screenToSvg(p.clientX, p.clientY), x = h.startPath, v = h.index;
9741
+ }, document.body.style.cursor = c, m.target.setPointerCapture(m.pointerId));
9742
+ }, u = (m) => {
9743
+ const p = i.current;
9744
+ if (!p || m.pointerId !== p.pointerId || !r) return;
9745
+ const b = r.screenToSvg(m.clientX, m.clientY), x = p.startPath, v = p.index;
9746
9746
  if (v <= 0 || v >= x.length - 1) return;
9747
- const P = x[v], j = [
9748
- h.xLocked ? P[0] : ue(P[0] + (b[0] - h.startSvg[0])),
9749
- h.yLocked ? P[1] : ue(P[1] + (b[1] - h.startSvg[1]))
9747
+ const P = x[v], O = [
9748
+ p.xLocked ? P[0] : ue(P[0] + (b[0] - p.startSvg[0])),
9749
+ p.yLocked ? P[1] : ue(P[1] + (b[1] - p.startSvg[1]))
9750
9750
  ];
9751
- if (j[0] === P[0] && j[1] === P[1]) return;
9751
+ if (O[0] === P[0] && O[1] === P[1]) return;
9752
9752
  const F = x.map((H) => [H[0], H[1]]);
9753
- F[v] = j;
9753
+ F[v] = O;
9754
9754
  const G = zt(x[v - 1], x[v]);
9755
- v - 1 > 0 && (G === "h" ? F[v - 1] = [x[v - 1][0], j[1]] : F[v - 1] = [j[0], x[v - 1][1]]);
9755
+ v - 1 > 0 && (G === "h" ? F[v - 1] = [x[v - 1][0], O[1]] : F[v - 1] = [O[0], x[v - 1][1]]);
9756
9756
  const $ = zt(x[v], x[v + 1]);
9757
- v + 1 < x.length - 1 && ($ === "h" ? F[v + 1] = [x[v + 1][0], j[1]] : F[v + 1] = [j[0], x[v + 1][1]]), y.getState().updateWirePath(e, F);
9758
- }, m = (p) => {
9759
- const h = i.current;
9760
- !h || p.pointerId !== h.pointerId || (p.target.hasPointerCapture(p.pointerId) && p.target.releasePointerCapture(p.pointerId), i.current = null, document.body.style.cursor = "");
9757
+ v + 1 < x.length - 1 && ($ === "h" ? F[v + 1] = [x[v + 1][0], O[1]] : F[v + 1] = [O[0], x[v + 1][1]]), y.getState().updateWirePath(e, F);
9758
+ }, h = (m) => {
9759
+ const p = i.current;
9760
+ !p || m.pointerId !== p.pointerId || (m.target.hasPointerCapture(m.pointerId) && m.target.releasePointerCapture(m.pointerId), i.current = null, document.body.style.cursor = "");
9761
9761
  };
9762
9762
  return /* @__PURE__ */ f(
9763
9763
  "circle",
@@ -9769,13 +9769,13 @@ function L4({
9769
9769
  style: { cursor: c },
9770
9770
  onPointerDown: d,
9771
9771
  onPointerMove: u,
9772
- onPointerUp: m,
9773
- onPointerCancel: m,
9774
- onDoubleClick: (p) => {
9775
- p.stopPropagation(), p.preventDefault();
9776
- const h = y.getState().internal.wireRenders.get(e);
9777
- if (!h || h.path.length <= 2 || t <= 0 || t >= h.path.length - 1) return;
9778
- const b = h.path.filter((x, v) => v !== t);
9772
+ onPointerUp: h,
9773
+ onPointerCancel: h,
9774
+ onDoubleClick: (m) => {
9775
+ m.stopPropagation(), m.preventDefault();
9776
+ const p = y.getState().internal.wireRenders.get(e);
9777
+ if (!p || p.path.length <= 2 || t <= 0 || t >= p.path.length - 1) return;
9778
+ const b = p.path.filter((x, v) => v !== t);
9779
9779
  y.getState().updateWirePath(e, b);
9780
9780
  }
9781
9781
  }
@@ -9786,42 +9786,42 @@ function D4({
9786
9786
  segIndex: t,
9787
9787
  axis: n
9788
9788
  }) {
9789
- const o = Ue(), r = fe(null), i = y((p) => {
9790
- var h;
9791
- return (h = p.internal.wireRenders.get(e)) == null ? void 0 : h.path;
9789
+ const o = Ue(), r = fe(null), i = y((m) => {
9790
+ var p;
9791
+ return (p = m.internal.wireRenders.get(e)) == null ? void 0 : p.path;
9792
9792
  });
9793
9793
  if (!i || t < 0 || t >= i.length - 1) return null;
9794
- const s = i[t], a = i[t + 1], l = (s[0] + a[0]) / 2, c = (s[1] + a[1]) / 2, d = n === "h" ? "ns-resize" : "ew-resize", u = (p) => {
9795
- if (p.button !== 0 || (p.stopPropagation(), p.preventDefault(), !o)) return;
9796
- const h = y.getState().internal.wireRenders.get(e);
9797
- h && (r.current = {
9798
- pointerId: p.pointerId,
9799
- startPath: h.path.map((b) => [b[0], b[1]]),
9800
- startSvg: o.screenToSvg(p.clientX, p.clientY),
9794
+ const s = i[t], a = i[t + 1], l = (s[0] + a[0]) / 2, c = (s[1] + a[1]) / 2, d = n === "h" ? "ns-resize" : "ew-resize", u = (m) => {
9795
+ if (m.button !== 0 || (m.stopPropagation(), m.preventDefault(), !o)) return;
9796
+ const p = y.getState().internal.wireRenders.get(e);
9797
+ p && (r.current = {
9798
+ pointerId: m.pointerId,
9799
+ startPath: p.path.map((b) => [b[0], b[1]]),
9800
+ startSvg: o.screenToSvg(m.clientX, m.clientY),
9801
9801
  axis: n,
9802
9802
  segIndex: t
9803
- }, document.body.style.cursor = d, p.currentTarget.setPointerCapture(p.pointerId));
9804
- }, m = (p) => {
9805
- const h = r.current;
9806
- if (!h || p.pointerId !== h.pointerId || !o) return;
9807
- const b = o.screenToSvg(p.clientX, p.clientY), x = h.startPath, v = h.segIndex;
9803
+ }, document.body.style.cursor = d, m.currentTarget.setPointerCapture(m.pointerId));
9804
+ }, h = (m) => {
9805
+ const p = r.current;
9806
+ if (!p || m.pointerId !== p.pointerId || !o) return;
9807
+ const b = o.screenToSvg(m.clientX, m.clientY), x = p.startPath, v = p.segIndex;
9808
9808
  if (v >= x.length - 1) return;
9809
- const P = x[v], j = x[v + 1], F = [];
9809
+ const P = x[v], O = x[v + 1], F = [];
9810
9810
  for (let G = 0; G <= v; G++) F.push(x[G]);
9811
- if (h.axis === "h") {
9812
- const G = ue(P[1] + (b[1] - h.startSvg[1]));
9813
- F.push([P[0], G]), F.push([j[0], G]);
9811
+ if (p.axis === "h") {
9812
+ const G = ue(P[1] + (b[1] - p.startSvg[1]));
9813
+ F.push([P[0], G]), F.push([O[0], G]);
9814
9814
  } else {
9815
- const G = ue(P[0] + (b[0] - h.startSvg[0]));
9816
- F.push([G, P[1]]), F.push([G, j[1]]);
9815
+ const G = ue(P[0] + (b[0] - p.startSvg[0]));
9816
+ F.push([G, P[1]]), F.push([G, O[1]]);
9817
9817
  }
9818
9818
  for (let G = v + 1; G < x.length; G++) F.push(x[G]);
9819
9819
  y.getState().updateWirePath(e, F);
9820
- }, g = (p) => {
9821
- const h = r.current;
9822
- if (!h || p.pointerId !== h.pointerId) return;
9823
- const b = p.currentTarget;
9824
- b.hasPointerCapture(p.pointerId) && b.releasePointerCapture(p.pointerId), r.current = null, document.body.style.cursor = "";
9820
+ }, g = (m) => {
9821
+ const p = r.current;
9822
+ if (!p || m.pointerId !== p.pointerId) return;
9823
+ const b = m.currentTarget;
9824
+ b.hasPointerCapture(m.pointerId) && b.releasePointerCapture(m.pointerId), r.current = null, document.body.style.cursor = "";
9825
9825
  };
9826
9826
  return /* @__PURE__ */ C(
9827
9827
  "g",
@@ -9829,7 +9829,7 @@ function D4({
9829
9829
  className: "ole-wire-handle ole-wire-midpoint-group",
9830
9830
  style: { cursor: d },
9831
9831
  onPointerDown: u,
9832
- onPointerMove: m,
9832
+ onPointerMove: h,
9833
9833
  onPointerUp: g,
9834
9834
  onPointerCancel: g,
9835
9835
  children: [
@@ -9865,7 +9865,7 @@ function R4() {
9865
9865
  !l.includes(".") && e.has(l) && s.add(l);
9866
9866
  }
9867
9867
  return /* @__PURE__ */ f("g", { className: "ole-bus-layer", children: Array.from(e.values()).map(({ bus: a, geometry: l }) => {
9868
- const { axis: c, at: d, span: u } = l, m = u / 2, g = c === "x" ? d[0] - m : d[0], p = c === "x" ? d[1] : d[1] - m, h = c === "x" ? d[0] + m : d[0], b = c === "x" ? d[1] : d[1] + m, x = i.has(a.id), v = s.has(a.id), P = r.get(a.id) ?? void 0, j = to / 2, F = c === "x" ? d[0] - m : d[0] - j, G = c === "x" ? d[1] - j : d[1] - m, $ = c === "x" ? u : to, H = c === "x" ? to : u;
9868
+ const { axis: c, at: d, span: u } = l, h = u / 2, g = c === "x" ? d[0] - h : d[0], m = c === "x" ? d[1] : d[1] - h, p = c === "x" ? d[0] + h : d[0], b = c === "x" ? d[1] : d[1] + h, x = i.has(a.id), v = s.has(a.id), P = r.get(a.id) ?? void 0, O = to / 2, F = c === "x" ? d[0] - h : d[0] - O, G = c === "x" ? d[1] - O : d[1] - h, $ = c === "x" ? u : to, H = c === "x" ? to : u;
9869
9869
  return /* @__PURE__ */ C(
9870
9870
  "g",
9871
9871
  {
@@ -9891,8 +9891,8 @@ function R4() {
9891
9891
  "line",
9892
9892
  {
9893
9893
  x1: g,
9894
- y1: p,
9895
- x2: h,
9894
+ y1: m,
9895
+ x2: p,
9896
9896
  y2: b,
9897
9897
  stroke: "currentColor",
9898
9898
  strokeWidth: z4,
@@ -9949,7 +9949,7 @@ function K4() {
9949
9949
  if (a) for (const l of a.terminals) s.add(l);
9950
9950
  }
9951
9951
  return /* @__PURE__ */ f("g", { className: "ole-junction-layer", children: Array.from(e.values()).map(({ junction: a, world: l, degree: c }) => {
9952
- const d = r.get(a.id) ?? void 0, u = t.length === 1 && t[0] === a.id, m = l[0] + q4, g = l[1] + X4;
9952
+ const d = r.get(a.id) ?? void 0, u = t.length === 1 && t[0] === a.id, h = l[0] + q4, g = l[1] + X4;
9953
9953
  return /* @__PURE__ */ C(
9954
9954
  "g",
9955
9955
  {
@@ -9964,9 +9964,9 @@ function K4() {
9964
9964
  /* @__PURE__ */ f("circle", { cx: l[0], cy: l[1], r: W4, fill: "transparent", className: "ole-junction-hit" }),
9965
9965
  /* @__PURE__ */ f("circle", { cx: l[0], cy: l[1], r: H4, className: "ole-junction-dot" }),
9966
9966
  u && /* @__PURE__ */ C("g", { className: "ole-junction-wire-handle-group", children: [
9967
- /* @__PURE__ */ f("line", { x1: l[0], y1: l[1], x2: m, y2: g, className: "ole-junction-wire-handle-stem" }),
9968
- /* @__PURE__ */ f("circle", { cx: m, cy: g, r: G4, fill: "transparent", className: "ole-junction-wire-handle" }),
9969
- /* @__PURE__ */ f("circle", { cx: m, cy: g, r: Y4, className: "ole-junction-wire-handle-dot" })
9967
+ /* @__PURE__ */ f("line", { x1: l[0], y1: l[1], x2: h, y2: g, className: "ole-junction-wire-handle-stem" }),
9968
+ /* @__PURE__ */ f("circle", { cx: h, cy: g, r: G4, fill: "transparent", className: "ole-junction-wire-handle" }),
9969
+ /* @__PURE__ */ f("circle", { cx: h, cy: g, r: Y4, className: "ole-junction-wire-handle-dot" })
9970
9970
  ] })
9971
9971
  ]
9972
9972
  },
@@ -10088,7 +10088,7 @@ function Q4(e) {
10088
10088
  };
10089
10089
  }
10090
10090
  function e6() {
10091
- const [e, t] = ve(Z4());
10091
+ const [e, t] = xe(Z4());
10092
10092
  return se(() => Q4(t), []), !e || e.w === 0 && e.h === 0 ? null : /* @__PURE__ */ f(
10093
10093
  "rect",
10094
10094
  {
@@ -10151,12 +10151,12 @@ function n6() {
10151
10151
  return e.length === 0 ? null : /* @__PURE__ */ f("g", { className: "ole-selection-overlay", pointerEvents: "none", children: e.map((r) => {
10152
10152
  const i = o.get(r);
10153
10153
  if (i) {
10154
- const { axis: c, at: d, span: u } = i.geometry, m = u / 2, g = c === "x" ? d[0] - m : d[0] - 4, p = c === "x" ? d[1] - 4 : d[1] - m;
10154
+ const { axis: c, at: d, span: u } = i.geometry, h = u / 2, g = c === "x" ? d[0] - h : d[0] - 4, m = c === "x" ? d[1] - 4 : d[1] - h;
10155
10155
  return /* @__PURE__ */ f(
10156
10156
  "rect",
10157
10157
  {
10158
10158
  x: g,
10159
- y: p,
10159
+ y: m,
10160
10160
  width: c === "x" ? u : 8,
10161
10161
  height: c === "x" ? 8 : u,
10162
10162
  fill: "none",
@@ -10225,10 +10225,10 @@ function s6(e, t) {
10225
10225
  o.push(s);
10226
10226
  continue;
10227
10227
  }
10228
- const l = s[0] - i[0], c = s[1] - i[1], d = Math.hypot(l, c) || 1, u = l / d, m = c / d, g = (h) => (h[0] - i[0]) * u + (h[1] - i[1]) * m, p = a.slice().sort((h, b) => g(h) - g(b));
10229
- for (const h of p) {
10230
- const b = g(h), x = Math.max(0, b - Rr), v = Math.min(d, b + Rr);
10231
- o.push([i[0] + u * x, i[1] + m * x]), n.push(o), o = [[i[0] + u * v, i[1] + m * v]];
10228
+ const l = s[0] - i[0], c = s[1] - i[1], d = Math.hypot(l, c) || 1, u = l / d, h = c / d, g = (p) => (p[0] - i[0]) * u + (p[1] - i[1]) * h, m = a.slice().sort((p, b) => g(p) - g(b));
10229
+ for (const p of m) {
10230
+ const b = g(p), x = Math.max(0, b - Rr), v = Math.min(d, b + Rr);
10231
+ o.push([i[0] + u * x, i[1] + h * x]), n.push(o), o = [[i[0] + u * v, i[1] + h * v]];
10232
10232
  }
10233
10233
  o.push(s);
10234
10234
  }
@@ -10249,24 +10249,24 @@ function a6() {
10249
10249
  const l = /* @__PURE__ */ new Map();
10250
10250
  for (let c = 0; c < a.length; c++)
10251
10251
  for (let d = c + 1; d < a.length; d++) {
10252
- const u = a[c], m = a[d];
10253
- if (u.wireId === m.wireId || !(u.node && m.node && u.node !== m.node)) continue;
10254
- const g = i6(u.a, u.b, m.a, m.b);
10252
+ const u = a[c], h = a[d];
10253
+ if (u.wireId === h.wireId || !(u.node && h.node && u.node !== h.node)) continue;
10254
+ const g = i6(u.a, u.b, h.a, h.b);
10255
10255
  if (!g) continue;
10256
- const p = u.wireId < m.wireId ? u : m;
10257
- let h = l.get(p.wireId);
10258
- h || (h = /* @__PURE__ */ new Map(), l.set(p.wireId, h));
10259
- const b = h.get(p.i) ?? [];
10260
- b.push(g), h.set(p.i, b);
10256
+ const m = u.wireId < h.wireId ? u : h;
10257
+ let p = l.get(m.wireId);
10258
+ p || (p = /* @__PURE__ */ new Map(), l.set(m.wireId, p));
10259
+ const b = p.get(m.i) ?? [];
10260
+ b.push(g), p.set(m.i, b);
10261
10261
  }
10262
10262
  return /* @__PURE__ */ f("g", { className: "ole-wire-layer", fill: "none", stroke: "currentColor", strokeWidth: 1, children: s.flatMap((c) => {
10263
- const d = c.path, u = d.map((v) => `${v[0]},${v[1]}`).join(" "), m = i.get(c.wireId), g = o === c.wireId, p = r != null && r === m, h = g || p ? "true" : void 0, b = l.get(c.wireId), x = b ? s6(d, b) : [d];
10263
+ const d = c.path, u = d.map((v) => `${v[0]},${v[1]}`).join(" "), h = i.get(c.wireId), g = o === c.wireId, m = r != null && r === h, p = g || m ? "true" : void 0, b = l.get(c.wireId), x = b ? s6(d, b) : [d];
10264
10264
  return [
10265
10265
  /* @__PURE__ */ f(
10266
10266
  "polyline",
10267
10267
  {
10268
10268
  "data-wire-id": c.wireId,
10269
- "data-node-id": m,
10269
+ "data-node-id": h,
10270
10270
  className: "ole-wire-hit",
10271
10271
  points: u
10272
10272
  },
@@ -10276,11 +10276,11 @@ function a6() {
10276
10276
  "polyline",
10277
10277
  {
10278
10278
  "data-wire-id": c.wireId,
10279
- "data-node-id": m,
10279
+ "data-node-id": h,
10280
10280
  "data-manual": c.userEdited ? "true" : void 0,
10281
- "data-selected": h,
10281
+ "data-selected": p,
10282
10282
  className: "ole-wire",
10283
- points: v.map((j) => `${j[0]},${j[1]}`).join(" ")
10283
+ points: v.map((O) => `${O[0]},${O[1]}`).join(" ")
10284
10284
  },
10285
10285
  `${c.wireId}-${P}`
10286
10286
  ))
@@ -10304,7 +10304,7 @@ function c6(e) {
10304
10304
  };
10305
10305
  }
10306
10306
  function d6() {
10307
- const e = y((l) => l.wireDragFrom), t = y((l) => l.cursorSvg), [n, o] = ve(l6());
10307
+ const e = y((l) => l.wireDragFrom), t = y((l) => l.cursorSvg), [n, o] = xe(l6());
10308
10308
  if (se(() => c6(o), []), !e || !t) return null;
10309
10309
  const r = e.world, i = (n == null ? void 0 : n.world[0]) ?? t[0], s = (n == null ? void 0 : n.world[1]) ?? t[1], a = (n == null ? void 0 : n.create) === "junction";
10310
10310
  return /* @__PURE__ */ C("g", { className: "ole-wire-preview", pointerEvents: "none", children: [
@@ -10549,34 +10549,34 @@ function x6(e) {
10549
10549
  const t = e.current;
10550
10550
  if (!t) return;
10551
10551
  let n = null, o = null;
10552
- const r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = (u, m, g) => {
10553
- for (const p of u) p.classList.remove(g);
10552
+ const r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), s = (u, h, g) => {
10553
+ for (const m of u) m.classList.remove(g);
10554
10554
  u.clear();
10555
- for (const p of m)
10556
- p.classList.add(g), u.add(p);
10555
+ for (const m of h)
10556
+ m.classList.add(g), u.add(m);
10557
10557
  }, a = (u) => {
10558
- var g, p;
10558
+ var g, m;
10559
10559
  if (u === n) return;
10560
- n && ((g = t.querySelector(`[data-element-id="${dn(n)}"]`)) == null || g.classList.remove(Fr)), u && ((p = t.querySelector(`[data-element-id="${dn(u)}"]`)) == null || p.classList.add(Fr));
10561
- const m = u ? Array.from(
10560
+ n && ((g = t.querySelector(`[data-element-id="${dn(n)}"]`)) == null || g.classList.remove(Fr)), u && ((m = t.querySelector(`[data-element-id="${dn(u)}"]`)) == null || m.classList.add(Fr));
10561
+ const h = u ? Array.from(
10562
10562
  t.querySelectorAll(
10563
10563
  `.ole-terminal[data-element-id="${dn(u)}"]`
10564
10564
  )
10565
10565
  ) : [];
10566
- s(r, m, b6), n = u, u ? t.setAttribute("data-hover-element", "") : t.removeAttribute("data-hover-element"), p6(u);
10566
+ s(r, h, b6), n = u, u ? t.setAttribute("data-hover-element", "") : t.removeAttribute("data-hover-element"), p6(u);
10567
10567
  }, l = (u) => {
10568
10568
  if (u === o) return;
10569
- const m = u ? Array.from(
10569
+ const h = u ? Array.from(
10570
10570
  t.querySelectorAll(
10571
10571
  `[data-node-id="${dn(u)}"]`
10572
10572
  )
10573
10573
  ) : [];
10574
- s(i, m, w6), o = u, u ? t.setAttribute("data-hover-node", "") : t.removeAttribute("data-hover-node");
10574
+ s(i, h, w6), o = u, u ? t.setAttribute("data-hover-node", "") : t.removeAttribute("data-hover-node");
10575
10575
  }, c = (u) => {
10576
10576
  a(kt(u.target));
10577
- const m = Bn(u.target);
10577
+ const h = Bn(u.target);
10578
10578
  let g = null;
10579
- m ? g = y.getState().internal.terminalToNode.get(m) ?? null : g = Ln(u.target), l(g);
10579
+ h ? g = y.getState().internal.terminalToNode.get(h) ?? null : g = Ln(u.target), l(g);
10580
10580
  }, d = () => {
10581
10581
  a(null), l(null);
10582
10582
  };
@@ -10595,8 +10595,8 @@ function v6(e, t) {
10595
10595
  if (r) {
10596
10596
  const { axis: s, at: a, span: l } = r.geometry;
10597
10597
  if (s === "x") {
10598
- const m = a[0] - l / 2, g = a[0] + l / 2, p = Math.max(m, Math.min(g, t[0]));
10599
- return { ref: e, world: [p, a[1]], isBus: !0 };
10598
+ const h = a[0] - l / 2, g = a[0] + l / 2, m = Math.max(h, Math.min(g, t[0]));
10599
+ return { ref: e, world: [m, a[1]], isBus: !0 };
10600
10600
  }
10601
10601
  const c = a[1] - l / 2, d = a[1] + l / 2, u = Math.max(c, Math.min(d, t[1]));
10602
10602
  return { ref: e, world: [a[0], u], isBus: !0 };
@@ -10611,8 +10611,8 @@ const Hr = 10, un = (e) => Math.round(e / Hr) * Hr, k6 = 16;
10611
10611
  function Sv(e, t) {
10612
10612
  let n = e[0], o = 1 / 0;
10613
10613
  for (let r = 0; r < e.length - 1; r++) {
10614
- const [i, s] = e[r], [a, l] = e[r + 1], c = a - i, d = l - s, u = c * c + d * d, m = u === 0 ? 0 : Math.max(0, Math.min(1, ((t[0] - i) * c + (t[1] - s) * d) / u)), g = i + m * c, p = s + m * d, h = (g - t[0]) ** 2 + (p - t[1]) ** 2;
10615
- h < o && (o = h, n = [g, p]);
10614
+ const [i, s] = e[r], [a, l] = e[r + 1], c = a - i, d = l - s, u = c * c + d * d, h = u === 0 ? 0 : Math.max(0, Math.min(1, ((t[0] - i) * c + (t[1] - s) * d) / u)), g = i + h * c, m = s + h * d, p = (g - t[0]) ** 2 + (m - t[1]) ** 2;
10615
+ p < o && (o = p, n = [g, m]);
10616
10616
  }
10617
10617
  return n;
10618
10618
  }
@@ -10671,13 +10671,13 @@ const S6 = {
10671
10671
  id: "select",
10672
10672
  cursor: "default",
10673
10673
  onPointerDown(e, t) {
10674
- var p, h, b, x, v, P, j, F, G, $, H, W;
10674
+ var m, p, b, x, v, P, O, F, G, $, H, W;
10675
10675
  if (e.button !== 0 || e.target instanceof Element && e.target.closest(".ole-bus-handle, .ole-wire-handle, .ole-annotation-handle"))
10676
10676
  return;
10677
10677
  const n = y.getState(), o = Yt(e.target);
10678
10678
  if (o) {
10679
10679
  e.preventDefault(), e.stopPropagation();
10680
- const X = (p = n.diagram.annotations) == null ? void 0 : p.find((R) => R.id === o);
10680
+ const X = (m = n.diagram.annotations) == null ? void 0 : m.find((R) => R.id === o);
10681
10681
  if (!X) return;
10682
10682
  const I = n.selectedAnnotation === o;
10683
10683
  n.setSelectedAnnotation(o), ye = {
@@ -10692,7 +10692,7 @@ const S6 = {
10692
10692
  }
10693
10693
  const r = e.target instanceof Element ? e.target.closest(".ole-junction-wire-handle") : null;
10694
10694
  if (r) {
10695
- const X = (h = r.closest("[data-junction-id]")) == null ? void 0 : h.getAttribute("data-junction-id");
10695
+ const X = (p = r.closest("[data-junction-id]")) == null ? void 0 : p.getAttribute("data-junction-id");
10696
10696
  if (X) {
10697
10697
  e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((x = (b = e.target).hasPointerCapture) != null && x.call(b, e.pointerId)) && e.target.releasePointerCapture(e.pointerId), t.hostEl.classList.add("tool-wire"), n.setWireFromTerminal(X);
10698
10698
  const I = (v = n.internal.junctions.get(X)) == null ? void 0 : v.world;
@@ -10704,7 +10704,7 @@ const S6 = {
10704
10704
  if (s) {
10705
10705
  const X = s.indexOf("."), I = X > 0 ? s.slice(0, X) : "";
10706
10706
  if (I && n.selection.includes(I)) {
10707
- e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((F = (j = e.target).hasPointerCapture) != null && F.call(j, e.pointerId)) && e.target.releasePointerCapture(e.pointerId), t.hostEl.classList.add("tool-wire"), n.setWireFromTerminal(s);
10707
+ e.preventDefault(), e.stopPropagation(), e.target instanceof Element && ((F = (O = e.target).hasPointerCapture) != null && F.call(O, e.pointerId)) && e.target.releasePointerCapture(e.pointerId), t.hostEl.classList.add("tool-wire"), n.setWireFromTerminal(s);
10708
10708
  const R = (G = n.internal.terminals.get(
10709
10709
  s
10710
10710
  )) == null ? void 0 : G.world;
@@ -10751,11 +10751,11 @@ const S6 = {
10751
10751
  e.shiftKey ? n.toggleInSelection(a) : l.includes(a) || n.setSelection([a]);
10752
10752
  const c = e.shiftKey ? y.getState().selection : l.includes(a) ? l : [a];
10753
10753
  if (c.length === 0) return;
10754
- const d = y.getState().internal, u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
10754
+ const d = y.getState().internal, u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
10755
10755
  for (const X of c) {
10756
10756
  const I = d.buses.get(X);
10757
10757
  if (I) {
10758
- m.set(X, [I.geometry.at[0], I.geometry.at[1]]);
10758
+ h.set(X, [I.geometry.at[0], I.geometry.at[1]]);
10759
10759
  continue;
10760
10760
  }
10761
10761
  const R = d.junctions.get(X);
@@ -10766,11 +10766,11 @@ const S6 = {
10766
10766
  const Z = d.layout.get(X);
10767
10767
  Z && u.set(X, { ...Z });
10768
10768
  }
10769
- u.size === 0 && m.size === 0 && g.size === 0 || (pe = {
10769
+ u.size === 0 && h.size === 0 && g.size === 0 || (pe = {
10770
10770
  pointerId: e.pointerId,
10771
10771
  startSvg: t.viewport.screenToSvg(e.clientX, e.clientY),
10772
10772
  originals: u,
10773
- busOriginals: m,
10773
+ busOriginals: h,
10774
10774
  junctionOriginals: g,
10775
10775
  moved: !1
10776
10776
  }, e.preventDefault());
@@ -11000,15 +11000,15 @@ function $6(e) {
11000
11000
  [i.x + i.w, i.y],
11001
11001
  [i.x, i.y + i.h],
11002
11002
  [i.x + i.w, i.y + i.h]
11003
- ].map(([u, m]) => E6([u, m], r));
11003
+ ].map(([u, h]) => E6([u, h], r));
11004
11004
  let a = 1 / 0, l = -1 / 0, c = 1 / 0, d = -1 / 0;
11005
- for (const [u, m] of s)
11006
- u < a && (a = u), u > l && (l = u), m < c && (c = m), m > d && (d = m);
11005
+ for (const [u, h] of s)
11006
+ u < a && (a = u), u > l && (l = u), h < c && (c = h), h > d && (d = h);
11007
11007
  l >= e.x && a <= e.x + e.w && d >= e.y && c <= e.y + e.h && n.push(o.element.id);
11008
11008
  }
11009
11009
  for (const { bus: o, geometry: r } of t.buses.values()) {
11010
- const { axis: i, at: s, span: a } = r, l = a / 2, c = i === "x" ? s[0] - l : s[0], d = i === "x" ? s[0] + l : s[0], u = i === "x" ? s[1] : s[1] - l, m = i === "x" ? s[1] : s[1] + l;
11011
- d >= e.x && c <= e.x + e.w && m >= e.y && u <= e.y + e.h && n.push(o.id);
11010
+ const { axis: i, at: s, span: a } = r, l = a / 2, c = i === "x" ? s[0] - l : s[0], d = i === "x" ? s[0] + l : s[0], u = i === "x" ? s[1] : s[1] - l, h = i === "x" ? s[1] : s[1] + l;
11011
+ d >= e.x && c <= e.x + e.w && h >= e.y && u <= e.y + e.h && n.push(o.id);
11012
11012
  }
11013
11013
  for (const { junction: o, world: r } of t.junctions.values())
11014
11014
  r[0] >= e.x && r[0] <= e.x + e.w && r[1] >= e.y && r[1] <= e.y + e.h && n.push(o.id);
@@ -11057,8 +11057,8 @@ const T6 = {
11057
11057
  c.set(d, [u.geometry.at[0], u.geometry.at[1]]);
11058
11058
  continue;
11059
11059
  }
11060
- const m = a.layout.get(d);
11061
- m && l.set(d, { ...m });
11060
+ const h = a.layout.get(d);
11061
+ h && l.set(d, { ...h });
11062
11062
  }
11063
11063
  (l.size > 0 || c.size > 0) && (r = {
11064
11064
  startSvg: t.viewport.screenToSvg(e.clientX, e.clientY),
@@ -11200,7 +11200,7 @@ function at() {
11200
11200
  return Mi(Ev);
11201
11201
  }
11202
11202
  function P6(e) {
11203
- const [t, n] = ve(null);
11203
+ const [t, n] = xe(null);
11204
11204
  return An(() => {
11205
11205
  const o = e.current;
11206
11206
  if (!o) return;
@@ -11545,33 +11545,33 @@ const B6 = {
11545
11545
  function q6(e, t) {
11546
11546
  const n = y((r) => r.activeTool), o = y((r) => r.readOnly);
11547
11547
  se(() => {
11548
- var p;
11548
+ var m;
11549
11549
  const r = e.current;
11550
11550
  if (!r) return;
11551
11551
  const i = o ? "pan" : n, s = o ? ti.pan : ti[n], a = { viewport: t, hostEl: r };
11552
- r.dataset.tool = i, (p = s.onActivate) == null || p.call(s, a), s.cursor && (r.style.cursor = s.cursor);
11553
- const l = (h) => {
11552
+ r.dataset.tool = i, (m = s.onActivate) == null || m.call(s, a), s.cursor && (r.style.cursor = s.cursor);
11553
+ const l = (p) => {
11554
11554
  var b;
11555
- return (b = s.onPointerDown) == null ? void 0 : b.call(s, h, a);
11556
- }, c = (h) => {
11555
+ return (b = s.onPointerDown) == null ? void 0 : b.call(s, p, a);
11556
+ }, c = (p) => {
11557
11557
  var b;
11558
- return (b = s.onPointerMove) == null ? void 0 : b.call(s, h, a);
11559
- }, d = (h) => {
11558
+ return (b = s.onPointerMove) == null ? void 0 : b.call(s, p, a);
11559
+ }, d = (p) => {
11560
11560
  var b;
11561
- return (b = s.onPointerUp) == null ? void 0 : b.call(s, h, a);
11562
- }, u = (h) => {
11561
+ return (b = s.onPointerUp) == null ? void 0 : b.call(s, p, a);
11562
+ }, u = (p) => {
11563
11563
  var b;
11564
- return s.onPointerCancel ? s.onPointerCancel(h, a) : (b = s.onPointerUp) == null ? void 0 : b.call(s, h, a);
11565
- }, m = (h) => {
11564
+ return s.onPointerCancel ? s.onPointerCancel(p, a) : (b = s.onPointerUp) == null ? void 0 : b.call(s, p, a);
11565
+ }, h = (p) => {
11566
11566
  var b;
11567
- return (b = s.onPointerLeave) == null ? void 0 : b.call(s, h, a);
11568
- }, g = (h) => {
11567
+ return (b = s.onPointerLeave) == null ? void 0 : b.call(s, p, a);
11568
+ }, g = (p) => {
11569
11569
  var b;
11570
- return (b = s.onDoubleClick) == null ? void 0 : b.call(s, h, a);
11570
+ return (b = s.onDoubleClick) == null ? void 0 : b.call(s, p, a);
11571
11571
  };
11572
- return r.addEventListener("pointerdown", l), r.addEventListener("pointermove", c), r.addEventListener("pointerup", d), r.addEventListener("pointercancel", u), r.addEventListener("pointerleave", m), r.addEventListener("dblclick", g), () => {
11573
- var h;
11574
- r.removeEventListener("pointerdown", l), r.removeEventListener("pointermove", c), r.removeEventListener("pointerup", d), r.removeEventListener("pointercancel", u), r.removeEventListener("pointerleave", m), r.removeEventListener("dblclick", g), (h = s.onDeactivate) == null || h.call(s, a), r.style.cursor = "", delete r.dataset.tool;
11572
+ return r.addEventListener("pointerdown", l), r.addEventListener("pointermove", c), r.addEventListener("pointerup", d), r.addEventListener("pointercancel", u), r.addEventListener("pointerleave", h), r.addEventListener("dblclick", g), () => {
11573
+ var p;
11574
+ r.removeEventListener("pointerdown", l), r.removeEventListener("pointermove", c), r.removeEventListener("pointerup", d), r.removeEventListener("pointercancel", u), r.removeEventListener("pointerleave", h), r.removeEventListener("dblclick", g), (p = s.onDeactivate) == null || p.call(s, a), r.style.cursor = "", delete r.dataset.tool;
11575
11575
  };
11576
11576
  }, [n, o, e, t]);
11577
11577
  }
@@ -11606,16 +11606,16 @@ function V6(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
11606
11606
  return se(() => {
11607
11607
  const s = e.current;
11608
11608
  if (!s) return;
11609
- let a = !1, l = -1, c = 0, d = 0, u = 0, m = 0, g = !1;
11610
- const p = /* @__PURE__ */ new Map();
11611
- let h = null, b = !1;
11609
+ let a = !1, l = -1, c = 0, d = 0, u = 0, h = 0, g = !1;
11610
+ const m = /* @__PURE__ */ new Map();
11611
+ let p = null, b = !1;
11612
11612
  const x = () => {
11613
- if (p.size < 2) {
11614
- h = null;
11613
+ if (m.size < 2) {
11614
+ p = null;
11615
11615
  return;
11616
11616
  }
11617
- const I = [...p.values()], R = I[1].x - I[0].x, Z = I[1].y - I[0].y, ae = Math.hypot(R, Z) || 1, he = s.getBoundingClientRect();
11618
- h = {
11617
+ const I = [...m.values()], R = I[1].x - I[0].x, Z = I[1].y - I[0].y, ae = Math.hypot(R, Z) || 1, he = s.getBoundingClientRect();
11618
+ p = {
11619
11619
  startDist: ae,
11620
11620
  startScale: o.current.scale,
11621
11621
  startTx: o.current.tx,
@@ -11625,9 +11625,9 @@ function V6(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
11625
11625
  };
11626
11626
  }, v = (I) => {
11627
11627
  if (I.pointerType === "touch") {
11628
- if (p.set(I.pointerId, { x: I.clientX, y: I.clientY }), p.size >= 2 && !b) {
11628
+ if (m.set(I.pointerId, { x: I.clientX, y: I.clientY }), m.size >= 2 && !b) {
11629
11629
  b = !0;
11630
- for (const R of p.keys())
11630
+ for (const R of m.keys())
11631
11631
  R !== I.pointerId && kv(s, R);
11632
11632
  x();
11633
11633
  }
@@ -11640,21 +11640,21 @@ function V6(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
11640
11640
  }
11641
11641
  }
11642
11642
  }, P = (I) => {
11643
- if (I.pointerType !== "touch" || !p.has(I.pointerId) || (p.set(I.pointerId, { x: I.clientX, y: I.clientY }), !b || !h)) return;
11643
+ if (I.pointerType !== "touch" || !m.has(I.pointerId) || (m.set(I.pointerId, { x: I.clientX, y: I.clientY }), !b || !p)) return;
11644
11644
  I.stopPropagation();
11645
- const R = [...p.values()];
11645
+ const R = [...m.values()];
11646
11646
  if (R.length < 2) return;
11647
- const Z = R[1].x - R[0].x, ae = R[1].y - R[0].y, he = Math.hypot(Z, ae) || 1, ee = s.getBoundingClientRect(), le = (R[0].x + R[1].x) / 2 - ee.left, ge = (R[0].y + R[1].y) / 2 - ee.top, ke = he / h.startDist, Ae = ro(h.startScale * ke, no, oo), Oe = Ae / h.startScale;
11648
- o.current.tx = h.startMidX - (h.startMidX - h.startTx) * Oe + (le - h.startMidX), o.current.ty = h.startMidY - (h.startMidY - h.startTy) * Oe + (ge - h.startMidY), o.current.scale = Ae, i();
11649
- }, j = (I) => {
11647
+ const Z = R[1].x - R[0].x, ae = R[1].y - R[0].y, he = Math.hypot(Z, ae) || 1, ee = s.getBoundingClientRect(), le = (R[0].x + R[1].x) / 2 - ee.left, ge = (R[0].y + R[1].y) / 2 - ee.top, ke = he / p.startDist, Ae = ro(p.startScale * ke, no, oo), Oe = Ae / p.startScale;
11648
+ o.current.tx = p.startMidX - (p.startMidX - p.startTx) * Oe + (le - p.startMidX), o.current.ty = p.startMidY - (p.startMidY - p.startTy) * Oe + (ge - p.startMidY), o.current.scale = Ae, i();
11649
+ }, O = (I) => {
11650
11650
  var R;
11651
- if (I.pointerType === "touch" && p.has(I.pointerId) && (p.delete(I.pointerId), b)) {
11651
+ if (I.pointerType === "touch" && m.has(I.pointerId) && (m.delete(I.pointerId), b)) {
11652
11652
  if (I.stopPropagation(), (R = s.hasPointerCapture) != null && R.call(s, I.pointerId))
11653
11653
  try {
11654
11654
  s.releasePointerCapture(I.pointerId);
11655
11655
  } catch {
11656
11656
  }
11657
- p.size >= 2 ? x() : h = null, p.size === 0 && (b = !1);
11657
+ m.size >= 2 ? x() : p = null, m.size === 0 && (b = !1);
11658
11658
  }
11659
11659
  }, F = (I) => {
11660
11660
  I.preventDefault();
@@ -11667,9 +11667,9 @@ function V6(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
11667
11667
  i();
11668
11668
  }, G = (I) => {
11669
11669
  const R = I.button === 1, Z = g && I.button === 0;
11670
- !R && !Z || (I.preventDefault(), a = !0, l = I.pointerId, c = I.clientX, d = I.clientY, u = o.current.tx, m = o.current.ty, s.setPointerCapture(I.pointerId), s.style.cursor = "grabbing");
11670
+ !R && !Z || (I.preventDefault(), a = !0, l = I.pointerId, c = I.clientX, d = I.clientY, u = o.current.tx, h = o.current.ty, s.setPointerCapture(I.pointerId), s.style.cursor = "grabbing");
11671
11671
  }, $ = (I) => {
11672
- !a || I.pointerId !== l || (o.current.tx = u + (I.clientX - c), o.current.ty = m + (I.clientY - d), i());
11672
+ !a || I.pointerId !== l || (o.current.tx = u + (I.clientX - c), o.current.ty = h + (I.clientY - d), i());
11673
11673
  }, H = (I) => {
11674
11674
  a && I.pointerId === l && (a = !1, s.releasePointerCapture(I.pointerId), s.style.cursor = g ? "grab" : "");
11675
11675
  }, W = (I) => {
@@ -11681,8 +11681,8 @@ function V6(e, t, n = { tx: 0, ty: 0, scale: 1 }) {
11681
11681
  }, X = (I) => {
11682
11682
  I.code === "Space" && (g = !1, a || (s.style.cursor = ""));
11683
11683
  };
11684
- return s.addEventListener("wheel", F, { passive: !1 }), s.addEventListener("pointerdown", G), s.addEventListener("pointermove", $), s.addEventListener("pointerup", H), s.addEventListener("pointercancel", H), s.addEventListener("pointerdown", v, { capture: !0 }), s.addEventListener("pointermove", P, { capture: !0 }), s.addEventListener("pointerup", j, { capture: !0 }), s.addEventListener("pointercancel", j, { capture: !0 }), window.addEventListener("keydown", W), window.addEventListener("keyup", X), i(), () => {
11685
- s.removeEventListener("wheel", F), s.removeEventListener("pointerdown", G), s.removeEventListener("pointermove", $), s.removeEventListener("pointerup", H), s.removeEventListener("pointercancel", H), s.removeEventListener("pointerdown", v, { capture: !0 }), s.removeEventListener("pointermove", P, { capture: !0 }), s.removeEventListener("pointerup", j, { capture: !0 }), s.removeEventListener("pointercancel", j, { capture: !0 }), window.removeEventListener("keydown", W), window.removeEventListener("keyup", X);
11684
+ return s.addEventListener("wheel", F, { passive: !1 }), s.addEventListener("pointerdown", G), s.addEventListener("pointermove", $), s.addEventListener("pointerup", H), s.addEventListener("pointercancel", H), s.addEventListener("pointerdown", v, { capture: !0 }), s.addEventListener("pointermove", P, { capture: !0 }), s.addEventListener("pointerup", O, { capture: !0 }), s.addEventListener("pointercancel", O, { capture: !0 }), window.addEventListener("keydown", W), window.addEventListener("keyup", X), i(), () => {
11685
+ s.removeEventListener("wheel", F), s.removeEventListener("pointerdown", G), s.removeEventListener("pointermove", $), s.removeEventListener("pointerup", H), s.removeEventListener("pointercancel", H), s.removeEventListener("pointerdown", v, { capture: !0 }), s.removeEventListener("pointermove", P, { capture: !0 }), s.removeEventListener("pointerup", O, { capture: !0 }), s.removeEventListener("pointercancel", O, { capture: !0 }), window.removeEventListener("keydown", W), window.removeEventListener("keyup", X);
11686
11686
  };
11687
11687
  }, []), {
11688
11688
  screenToSvg(s, a) {
@@ -11717,32 +11717,32 @@ function eE() {
11717
11717
  const e = ce(), t = fe(null), n = fe(null), o = fe(null), r = V6(t, n);
11718
11718
  q6(t, r), x6(t), se(() => (Cr(r), () => Cr(null)), [r]), se(() => {
11719
11719
  const d = (u) => {
11720
- const m = o.current;
11721
- if (!m) return;
11722
- const p = Q6(u.scale) * u.scale;
11723
- m.setAttribute("width", String(p)), m.setAttribute("height", String(p)), m.setAttribute("patternTransform", `translate(${u.tx} ${u.ty})`);
11720
+ const h = o.current;
11721
+ if (!h) return;
11722
+ const m = Q6(u.scale) * u.scale;
11723
+ h.setAttribute("width", String(m)), h.setAttribute("height", String(m)), h.setAttribute("patternTransform", `translate(${u.tx} ${u.ty})`);
11724
11724
  };
11725
11725
  return d(r.getViewport()), r.subscribe(d);
11726
11726
  }, [r]);
11727
11727
  const i = hk(), s = yn(
11728
- (d, u, m) => {
11728
+ (d, u, h) => {
11729
11729
  const g = y.getState();
11730
11730
  if (g.readOnly) return;
11731
- const p = g.activeTool;
11732
- if (p === "wire" || p === "busbar" || p === "junction" || p === "place") {
11731
+ const m = g.activeTool;
11732
+ if (m === "wire" || m === "busbar" || m === "junction" || m === "place") {
11733
11733
  _v();
11734
11734
  return;
11735
11735
  }
11736
- const h = Yt(m), b = h ? null : kt(m);
11737
- if (h)
11738
- g.selectedAnnotation !== h && g.setSelectedAnnotation(h);
11736
+ const p = Yt(h), b = p ? null : kt(h);
11737
+ if (p)
11738
+ g.selectedAnnotation !== p && g.setSelectedAnnotation(p);
11739
11739
  else if (b)
11740
11740
  g.selection.includes(b) || g.setSelection([b]);
11741
11741
  else {
11742
- const W = Ln(m);
11742
+ const W = Ln(h);
11743
11743
  W && g.selectedNode !== W && g.setSelectedNode(W);
11744
11744
  }
11745
- const x = y.getState(), v = x.selection.length > 0, P = x.selectedAnnotation != null, j = v || P, F = x.selectedNode != null, G = !!x.clipboard, $ = x.diagram.elements.length > 0, H = [
11745
+ const x = y.getState(), v = x.selection.length > 0, P = x.selectedAnnotation != null, O = v || P, F = x.selectedNode != null, G = !!x.clipboard, $ = x.diagram.elements.length > 0, H = [
11746
11746
  {
11747
11747
  label: e("menu.undo"),
11748
11748
  shortcut: `${gt}Z`,
@@ -11763,14 +11763,14 @@ function eE() {
11763
11763
  shortcut: `${gt}X`,
11764
11764
  icon: zi,
11765
11765
  onSelect: () => y.getState().cutSelection(),
11766
- disabled: !j
11766
+ disabled: !O
11767
11767
  },
11768
11768
  {
11769
11769
  label: e("menu.copy"),
11770
11770
  shortcut: `${gt}C`,
11771
11771
  icon: ji,
11772
11772
  onSelect: () => y.getState().copySelection(),
11773
- disabled: !j
11773
+ disabled: !O
11774
11774
  },
11775
11775
  {
11776
11776
  label: e("menu.paste"),
@@ -11807,15 +11807,15 @@ function eE() {
11807
11807
  },
11808
11808
  { type: "separator" },
11809
11809
  {
11810
- label: e(F && !j ? "menu.disconnect" : "menu.delete"),
11810
+ label: e(F && !O ? "menu.disconnect" : "menu.delete"),
11811
11811
  shortcut: "Del",
11812
11812
  icon: Fi,
11813
11813
  destructive: !0,
11814
11814
  onSelect: () => {
11815
11815
  const W = y.getState();
11816
- F && !j ? W.deleteSelectedNode() : P && W.selectedAnnotation ? W.deleteAnnotation(W.selectedAnnotation) : W.deleteSelection();
11816
+ F && !O ? W.deleteSelectedNode() : P && W.selectedAnnotation ? W.deleteAnnotation(W.selectedAnnotation) : W.deleteSelection();
11817
11817
  },
11818
- disabled: !j && !F
11818
+ disabled: !O && !F
11819
11819
  }
11820
11820
  ];
11821
11821
  i.open(d, u, H);
@@ -11825,29 +11825,29 @@ function eE() {
11825
11825
  return se(() => {
11826
11826
  const d = t.current;
11827
11827
  if (!d) return;
11828
- const u = 700, m = 4;
11829
- let g, p = null;
11830
- const h = () => {
11831
- g !== void 0 && window.clearTimeout(g), g = void 0, p = null;
11828
+ const u = 700, h = 4;
11829
+ let g, m = null;
11830
+ const p = () => {
11831
+ g !== void 0 && window.clearTimeout(g), g = void 0, m = null;
11832
11832
  }, b = (P) => {
11833
- P.pointerType === "touch" && (h(), p = {
11833
+ P.pointerType === "touch" && (p(), m = {
11834
11834
  pointerId: P.pointerId,
11835
11835
  x: P.clientX,
11836
11836
  y: P.clientY,
11837
11837
  target: P.target
11838
11838
  }, g = window.setTimeout(() => {
11839
- const j = p;
11840
- p = null, g = void 0, j && (kv(d, j.pointerId), s(j.x, j.y, j.target));
11839
+ const O = m;
11840
+ m = null, g = void 0, O && (kv(d, O.pointerId), s(O.x, O.y, O.target));
11841
11841
  }, u));
11842
11842
  }, x = (P) => {
11843
- if (!p || P.pointerId !== p.pointerId) return;
11844
- const j = P.clientX - p.x, F = P.clientY - p.y;
11845
- Math.hypot(j, F) > m && h();
11843
+ if (!m || P.pointerId !== m.pointerId) return;
11844
+ const O = P.clientX - m.x, F = P.clientY - m.y;
11845
+ Math.hypot(O, F) > h && p();
11846
11846
  }, v = (P) => {
11847
- !p || P.pointerId !== p.pointerId || h();
11847
+ !m || P.pointerId !== m.pointerId || p();
11848
11848
  };
11849
11849
  return d.addEventListener("pointerdown", b), d.addEventListener("pointermove", x), d.addEventListener("pointerup", v), d.addEventListener("pointercancel", v), () => {
11850
- h(), d.removeEventListener("pointerdown", b), d.removeEventListener("pointermove", x), d.removeEventListener("pointerup", v), d.removeEventListener("pointercancel", v);
11850
+ p(), d.removeEventListener("pointerdown", b), d.removeEventListener("pointermove", x), d.removeEventListener("pointerup", v), d.removeEventListener("pointercancel", v);
11851
11851
  };
11852
11852
  }, [s]), /* @__PURE__ */ f(
11853
11853
  "div",
@@ -11862,8 +11862,8 @@ function eE() {
11862
11862
  const u = d.dataTransfer.getData("application/x-oneline-kind");
11863
11863
  if (!u) return;
11864
11864
  d.preventDefault();
11865
- const m = r.screenToSvg(d.clientX, d.clientY);
11866
- sv(u, m);
11865
+ const h = r.screenToSvg(d.clientX, d.clientY);
11866
+ sv(u, h);
11867
11867
  },
11868
11868
  onContextMenu: (d) => {
11869
11869
  d.preventDefault(), s(d.clientX, d.clientY, d.target);
@@ -11931,18 +11931,18 @@ function Tv() {
11931
11931
  v.width === 0 && v.height === 0 || (v.left < r && (r = v.left), v.top < i && (i = v.top), v.right > s && (s = v.right), v.bottom > a && (a = v.bottom));
11932
11932
  }
11933
11933
  if (r === 1 / 0) return !1;
11934
- const [l, c] = e.screenToSvg(r, i), [d, u] = e.screenToSvg(s, a), m = Math.max(d - l, 1), g = Math.max(u - c, 1), p = rE(
11934
+ const [l, c] = e.screenToSvg(r, i), [d, u] = e.screenToSvg(s, a), h = Math.max(d - l, 1), g = Math.max(u - c, 1), m = rE(
11935
11935
  Math.min(
11936
- (n.width - ni * 2) / m,
11936
+ (n.width - ni * 2) / h,
11937
11937
  (n.height - ni * 2) / g
11938
11938
  ),
11939
11939
  tE,
11940
11940
  nE
11941
- ), h = (l + d) / 2, b = (c + u) / 2;
11941
+ ), p = (l + d) / 2, b = (c + u) / 2;
11942
11942
  return e.setViewport({
11943
- tx: n.width / 2 - p * h,
11944
- ty: n.height / 2 - p * b,
11945
- scale: p
11943
+ tx: n.width / 2 - m * p,
11944
+ ty: n.height / 2 - m * b,
11945
+ scale: m
11946
11946
  }), !0;
11947
11947
  }
11948
11948
  function Mv() {
@@ -11957,31 +11957,31 @@ function aE() {
11957
11957
  return typeof window > "u" || !window.matchMedia ? !1 : window.matchMedia("(hover: none), (pointer: coarse)").matches;
11958
11958
  }
11959
11959
  function ri() {
11960
- const [e, t] = ve(g6()), [n, o] = ve(!1), [r, i] = ve(null), s = fe(null), a = fe(void 0), [l] = ve(aE);
11961
- se(() => y6((p) => t(p)), []), se(() => {
11960
+ const [e, t] = xe(g6()), [n, o] = xe(!1), [r, i] = xe(null), s = fe(null), a = fe(void 0), [l] = xe(aE);
11961
+ se(() => y6((m) => t(m)), []), se(() => {
11962
11962
  if (window.clearTimeout(a.current), o(!1), i(null), !!e)
11963
11963
  return a.current = window.setTimeout(() => o(!0), sE), () => window.clearTimeout(a.current);
11964
11964
  }, [e]);
11965
- const c = y((p) => e ? p.diagram.elements.find((h) => h.id === e) ?? null : null);
11965
+ const c = y((m) => e ? m.diagram.elements.find((p) => p.id === e) ?? null : null);
11966
11966
  if (An(() => {
11967
11967
  if (!n || !e) return;
11968
- let p = 0, h = -1, b = -1;
11968
+ let m = 0, p = -1, b = -1;
11969
11969
  const x = () => {
11970
11970
  const v = document.querySelector(
11971
11971
  `[data-element-id="${lE(e)}"]`
11972
11972
  ), P = s.current;
11973
11973
  if (v && P) {
11974
- const j = v.getBoundingClientRect();
11975
- let F = j.bottom + oi;
11976
- F + P.offsetHeight > window.innerHeight - 4 && (F = j.top - P.offsetHeight - oi);
11977
- let G = j.left + j.width / 2 - P.offsetWidth / 2;
11978
- G = Math.max(4, Math.min(G, window.innerWidth - P.offsetWidth - 4)), (F !== h || G !== b) && (i({ top: F, left: G }), h = F, b = G);
11974
+ const O = v.getBoundingClientRect();
11975
+ let F = O.bottom + oi;
11976
+ F + P.offsetHeight > window.innerHeight - 4 && (F = O.top - P.offsetHeight - oi);
11977
+ let G = O.left + O.width / 2 - P.offsetWidth / 2;
11978
+ G = Math.max(4, Math.min(G, window.innerWidth - P.offsetWidth - 4)), (F !== p || G !== b) && (i({ top: F, left: G }), p = F, b = G);
11979
11979
  }
11980
- p = requestAnimationFrame(x);
11980
+ m = requestAnimationFrame(x);
11981
11981
  };
11982
- return p = requestAnimationFrame(x), () => cancelAnimationFrame(p);
11982
+ return m = requestAnimationFrame(x), () => cancelAnimationFrame(m);
11983
11983
  }, [n, e]), l || !n || !e || !c) return null;
11984
- const d = st[c.kind], u = c.name ?? c.id, m = (d == null ? void 0 : d.name) ?? c.kind, g = c.name && c.name !== c.id;
11984
+ const d = st[c.kind], u = c.name ?? c.id, h = (d == null ? void 0 : d.name) ?? c.kind, g = c.name && c.name !== c.id;
11985
11985
  return typeof document > "u" ? null : Ci(
11986
11986
  /* @__PURE__ */ C(
11987
11987
  "div",
@@ -11999,7 +11999,7 @@ function ri() {
11999
11999
  /* @__PURE__ */ f("span", { className: "font-medium text-foreground", children: u }),
12000
12000
  g && /* @__PURE__ */ f("span", { className: "font-mono text-[10px] text-muted-foreground", children: c.id }),
12001
12001
  /* @__PURE__ */ f("span", { className: "text-muted-foreground/80", children: "·" }),
12002
- /* @__PURE__ */ f("span", { className: "text-muted-foreground", children: m })
12002
+ /* @__PURE__ */ f("span", { className: "text-muted-foreground", children: h })
12003
12003
  ]
12004
12004
  }
12005
12005
  ),
@@ -12037,7 +12037,7 @@ function dE(...e) {
12037
12037
  };
12038
12038
  };
12039
12039
  }
12040
- var uE = Symbol.for("react.lazy"), Nn = Ee[" use ".trim().toString()];
12040
+ var uE = Symbol.for("react.lazy"), Nn = Ne[" use ".trim().toString()];
12041
12041
  function fE(e) {
12042
12042
  return typeof e == "object" && e !== null && "then" in e;
12043
12043
  }
@@ -12046,13 +12046,13 @@ function Cv(e) {
12046
12046
  }
12047
12047
  // @__NO_SIDE_EFFECTS__
12048
12048
  function hE(e) {
12049
- const t = /* @__PURE__ */ pE(e), n = Ee.forwardRef((o, r) => {
12049
+ const t = /* @__PURE__ */ pE(e), n = Ne.forwardRef((o, r) => {
12050
12050
  let { children: i, ...s } = o;
12051
12051
  Cv(i) && typeof Nn == "function" && (i = Nn(i._payload));
12052
- const a = Ee.Children.toArray(i), l = a.find(yE);
12052
+ const a = Ne.Children.toArray(i), l = a.find(yE);
12053
12053
  if (l) {
12054
- const c = l.props.children, d = a.map((u) => u === l ? Ee.Children.count(c) > 1 ? Ee.Children.only(null) : Ee.isValidElement(c) ? c.props.children : null : u);
12055
- return /* @__PURE__ */ f(t, { ...s, ref: r, children: Ee.isValidElement(c) ? Ee.cloneElement(c, void 0, d) : null });
12054
+ const c = l.props.children, d = a.map((u) => u === l ? Ne.Children.count(c) > 1 ? Ne.Children.only(null) : Ne.isValidElement(c) ? c.props.children : null : u);
12055
+ return /* @__PURE__ */ f(t, { ...s, ref: r, children: Ne.isValidElement(c) ? Ne.cloneElement(c, void 0, d) : null });
12056
12056
  }
12057
12057
  return /* @__PURE__ */ f(t, { ...s, ref: r, children: i });
12058
12058
  });
@@ -12061,19 +12061,19 @@ function hE(e) {
12061
12061
  var mE = /* @__PURE__ */ hE("Slot");
12062
12062
  // @__NO_SIDE_EFFECTS__
12063
12063
  function pE(e) {
12064
- const t = Ee.forwardRef((n, o) => {
12064
+ const t = Ne.forwardRef((n, o) => {
12065
12065
  let { children: r, ...i } = n;
12066
- if (Cv(r) && typeof Nn == "function" && (r = Nn(r._payload)), Ee.isValidElement(r)) {
12066
+ if (Cv(r) && typeof Nn == "function" && (r = Nn(r._payload)), Ne.isValidElement(r)) {
12067
12067
  const s = wE(r), a = bE(i, r.props);
12068
- return r.type !== Ee.Fragment && (a.ref = o ? dE(o, s) : s), Ee.cloneElement(r, a);
12068
+ return r.type !== Ne.Fragment && (a.ref = o ? dE(o, s) : s), Ne.cloneElement(r, a);
12069
12069
  }
12070
- return Ee.Children.count(r) > 1 ? Ee.Children.only(null) : null;
12070
+ return Ne.Children.count(r) > 1 ? Ne.Children.only(null) : null;
12071
12071
  });
12072
12072
  return t.displayName = `${e}.SlotClone`, t;
12073
12073
  }
12074
12074
  var gE = Symbol("radix.slottable");
12075
12075
  function yE(e) {
12076
- return Ee.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === gE;
12076
+ return Ne.isValidElement(e) && typeof e.type == "function" && "__radixId" in e.type && e.type.__radixId === gE;
12077
12077
  }
12078
12078
  function bE(e, t) {
12079
12079
  const n = { ...t };
@@ -12097,26 +12097,26 @@ const si = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, ai = qi, x
12097
12097
  const { variants: r, defaultVariants: i } = t, s = Object.keys(r).map((c) => {
12098
12098
  const d = n == null ? void 0 : n[c], u = i == null ? void 0 : i[c];
12099
12099
  if (d === null) return null;
12100
- const m = si(d) || si(u);
12101
- return r[c][m];
12100
+ const h = si(d) || si(u);
12101
+ return r[c][h];
12102
12102
  }), a = n && Object.entries(n).reduce((c, d) => {
12103
- let [u, m] = d;
12104
- return m === void 0 || (c[u] = m), c;
12103
+ let [u, h] = d;
12104
+ return h === void 0 || (c[u] = h), c;
12105
12105
  }, {}), l = t == null || (o = t.compoundVariants) === null || o === void 0 ? void 0 : o.reduce((c, d) => {
12106
- let { class: u, className: m, ...g } = d;
12107
- return Object.entries(g).every((p) => {
12108
- let [h, b] = p;
12106
+ let { class: u, className: h, ...g } = d;
12107
+ return Object.entries(g).every((m) => {
12108
+ let [p, b] = m;
12109
12109
  return Array.isArray(b) ? b.includes({
12110
12110
  ...i,
12111
12111
  ...a
12112
- }[h]) : {
12112
+ }[p]) : {
12113
12113
  ...i,
12114
12114
  ...a
12115
- }[h] === b;
12115
+ }[p] === b;
12116
12116
  }) ? [
12117
12117
  ...c,
12118
12118
  u,
12119
- m
12119
+ h
12120
12120
  ] : c;
12121
12121
  }, []);
12122
12122
  return ai(e, s, l, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
@@ -12144,11 +12144,11 @@ const si = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, ai = qi, x
12144
12144
  size: "default"
12145
12145
  }
12146
12146
  }
12147
- ), Pe = Ee.forwardRef(
12147
+ ), Pe = Ne.forwardRef(
12148
12148
  ({ className: e, variant: t, size: n, asChild: o = !1, ...r }, i) => /* @__PURE__ */ f(
12149
12149
  o ? mE : "button",
12150
12150
  {
12151
- className: Ne(vE({ variant: t, size: n, className: e })),
12151
+ className: Ee(vE({ variant: t, size: n, className: e })),
12152
12152
  ref: i,
12153
12153
  ...r
12154
12154
  }
@@ -12162,7 +12162,7 @@ function Ie({
12162
12162
  disabled: n,
12163
12163
  delayMs: o = kE
12164
12164
  }) {
12165
- const r = fe(null), i = fe(null), [s, a] = ve(!1), [l, c] = ve(null), d = c2(), u = fe(void 0), m = () => {
12165
+ const r = fe(null), i = fe(null), [s, a] = xe(!1), [l, c] = xe(null), d = c2(), u = fe(void 0), h = () => {
12166
12166
  n || (window.clearTimeout(u.current), u.current = window.setTimeout(() => a(!0), o));
12167
12167
  }, g = () => {
12168
12168
  window.clearTimeout(u.current), a(!1);
@@ -12170,10 +12170,10 @@ function Ie({
12170
12170
  An(() => {
12171
12171
  if (!s || !r.current || !i.current) return;
12172
12172
  const x = r.current.getBoundingClientRect(), v = i.current.getBoundingClientRect(), P = 8;
12173
- let j = "top", F = x.top - v.height - P;
12174
- F < 4 && (j = "bottom", F = x.bottom + P);
12173
+ let O = "top", F = x.top - v.height - P;
12174
+ F < 4 && (O = "bottom", F = x.bottom + P);
12175
12175
  let G = x.left + x.width / 2 - v.width / 2;
12176
- G = Math.max(4, Math.min(G, window.innerWidth - v.width - 4)), c({ top: F, left: G, side: j });
12176
+ G = Math.max(4, Math.min(G, window.innerWidth - v.width - 4)), c({ top: F, left: G, side: O });
12177
12177
  }, [s, e]), se(() => () => window.clearTimeout(u.current), []), se(() => {
12178
12178
  if (!s) return;
12179
12179
  const x = (P) => {
@@ -12183,29 +12183,29 @@ function Ie({
12183
12183
  window.removeEventListener("keydown", x), window.removeEventListener("scroll", v, !0), window.removeEventListener("resize", v);
12184
12184
  };
12185
12185
  }, [s]);
12186
- const p = t, h = p.props, b = d2(p, {
12186
+ const m = t, p = m.props, b = d2(m, {
12187
12187
  ref: (x) => {
12188
12188
  r.current = x;
12189
- const v = p.ref;
12189
+ const v = m.ref;
12190
12190
  typeof v == "function" ? v(x) : v && typeof v == "object" && (v.current = x);
12191
12191
  },
12192
12192
  onPointerEnter: (x) => {
12193
12193
  var v;
12194
- (v = h.onPointerEnter) == null || v.call(h, x), m();
12194
+ (v = p.onPointerEnter) == null || v.call(p, x), h();
12195
12195
  },
12196
12196
  onPointerLeave: (x) => {
12197
12197
  var v;
12198
- (v = h.onPointerLeave) == null || v.call(h, x), g();
12198
+ (v = p.onPointerLeave) == null || v.call(p, x), g();
12199
12199
  },
12200
12200
  onFocus: (x) => {
12201
12201
  var v;
12202
- (v = h.onFocus) == null || v.call(h, x), m();
12202
+ (v = p.onFocus) == null || v.call(p, x), h();
12203
12203
  },
12204
12204
  onBlur: (x) => {
12205
12205
  var v;
12206
- (v = h.onBlur) == null || v.call(h, x), g();
12206
+ (v = p.onBlur) == null || v.call(p, x), g();
12207
12207
  },
12208
- "aria-describedby": s ? d : h["aria-describedby"]
12208
+ "aria-describedby": s ? d : p["aria-describedby"]
12209
12209
  });
12210
12210
  return /* @__PURE__ */ C(Ke, { children: [
12211
12211
  b,
@@ -12234,12 +12234,12 @@ function Ie({
12234
12234
  const li = 12, _E = 56;
12235
12235
  function SE() {
12236
12236
  var x;
12237
- const e = ce(), t = y((v) => v.selection), n = y((v) => v.selectedNode), o = y((v) => v.selectedWire), r = y((v) => v.activeTool), i = y((v) => v.rotateSelection), s = y((v) => v.mirrorSelection), a = y((v) => v.deleteSelection), l = y((v) => v.deleteSelectedNode), c = y((v) => v.deleteSelectedWire), d = y((v) => v.resetWirePath), u = y((v) => v.internal.wireRenders), m = o != null && ((x = u.get(o)) == null ? void 0 : x.userEdited) === !0, g = fe(null);
12237
+ const e = ce(), t = y((v) => v.selection), n = y((v) => v.selectedNode), o = y((v) => v.selectedWire), r = y((v) => v.activeTool), i = y((v) => v.rotateSelection), s = y((v) => v.mirrorSelection), a = y((v) => v.deleteSelection), l = y((v) => v.deleteSelectedNode), c = y((v) => v.deleteSelectedWire), d = y((v) => v.resetWirePath), u = y((v) => v.internal.wireRenders), h = o != null && ((x = u.get(o)) == null ? void 0 : x.userEdited) === !0, g = fe(null);
12238
12238
  se(() => {
12239
12239
  const v = g.current;
12240
12240
  if (!v) return;
12241
- const P = t.length > 0, j = !P && o != null, F = !P && !j && n != null;
12242
- if (!((P || j || F) && (r === "select" || r === "pan"))) {
12241
+ const P = t.length > 0, O = !P && o != null, F = !P && !O && n != null;
12242
+ if (!((P || O || F) && (r === "select" || r === "pan"))) {
12243
12243
  v.style.display = "none";
12244
12244
  return;
12245
12245
  }
@@ -12257,7 +12257,7 @@ function SE() {
12257
12257
  );
12258
12258
  le && he(le.getBoundingClientRect());
12259
12259
  }
12260
- else if (j && o) {
12260
+ else if (O && o) {
12261
12261
  const ee = document.querySelector(
12262
12262
  `polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`
12263
12263
  );
@@ -12279,16 +12279,16 @@ function SE() {
12279
12279
  };
12280
12280
  return $ = requestAnimationFrame(W), () => cancelAnimationFrame($);
12281
12281
  }, [t, n, o, r]);
12282
- const p = t.length === 0 && o != null, h = t.length === 0 && !p && n != null, b = h || p;
12282
+ const m = t.length === 0 && o != null, p = t.length === 0 && !m && n != null, b = p || m;
12283
12283
  return /* @__PURE__ */ C(
12284
12284
  "div",
12285
12285
  {
12286
12286
  ref: g,
12287
12287
  role: "toolbar",
12288
- "aria-label": e(p ? "ctx.ariaWire" : h ? "ctx.ariaNode" : "ctx.ariaElement"),
12288
+ "aria-label": e(m ? "ctx.ariaWire" : p ? "ctx.ariaNode" : "ctx.ariaElement"),
12289
12289
  className: "ole-glass pointer-events-auto fixed left-0 top-0 z-30 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",
12290
12290
  children: [
12291
- p && m && o && /* @__PURE__ */ C(Ke, { children: [
12291
+ m && h && o && /* @__PURE__ */ C(Ke, { children: [
12292
12292
  /* @__PURE__ */ f(
12293
12293
  Ie,
12294
12294
  {
@@ -12368,7 +12368,7 @@ function SE() {
12368
12368
  /* @__PURE__ */ f("span", { className: "font-medium", children: e("ctx.delete") }),
12369
12369
  /* @__PURE__ */ f("span", { className: "ml-1.5 text-muted-foreground", children: "Del" })
12370
12370
  ] }),
12371
- /* @__PURE__ */ f("div", { className: "text-muted-foreground", children: e(p ? "ctx.deleteHintWire" : h ? "ctx.deleteHintNode" : "ctx.deleteHintElement") })
12371
+ /* @__PURE__ */ f("div", { className: "text-muted-foreground", children: e(m ? "ctx.deleteHintWire" : p ? "ctx.deleteHintNode" : "ctx.deleteHintElement") })
12372
12372
  ] }),
12373
12373
  children: /* @__PURE__ */ f(
12374
12374
  Pe,
@@ -12376,7 +12376,7 @@ function SE() {
12376
12376
  variant: "ghost",
12377
12377
  size: "icon",
12378
12378
  className: "size-7 text-destructive hover:text-destructive",
12379
- onClick: () => p ? c() : h ? l() : a(),
12379
+ onClick: () => m ? c() : p ? l() : a(),
12380
12380
  "aria-label": e("ctx.delete"),
12381
12381
  children: /* @__PURE__ */ f(Fi, {})
12382
12382
  }
@@ -12406,10 +12406,10 @@ function EE() {
12406
12406
  const d = di() ?? document.querySelector($o) ?? document.querySelector(Eo) ?? document.querySelector(`[data-annotation-id="${CSS.escape(t)}"]`);
12407
12407
  if (d) {
12408
12408
  const u = d.getBoundingClientRect();
12409
- let m = u.top - ci, g = "-100%";
12410
- m < $E && (m = u.bottom + ci, g = "0%");
12411
- const p = `translate3d(${u.left}px, ${m}px, 0) translate(0, ${g})`;
12412
- p !== l && (s.style.transform = p, l = p);
12409
+ let h = u.top - ci, g = "-100%";
12410
+ h < $E && (h = u.bottom + ci, g = "0%");
12411
+ const m = `translate3d(${u.left}px, ${h}px, 0) translate(0, ${g})`;
12412
+ m !== l && (s.style.transform = m, l = m);
12413
12413
  }
12414
12414
  a = requestAnimationFrame(c);
12415
12415
  };
@@ -12426,9 +12426,9 @@ function EE() {
12426
12426
  return;
12427
12427
  }
12428
12428
  if (He(l) === "table" && s.editingCell) {
12429
- const u = document.querySelector(`${$o} input`), [m, g] = s.editingCell;
12429
+ const u = document.querySelector(`${$o} input`), [h, g] = s.editingCell;
12430
12430
  if (u) {
12431
- u.value = ((d = l.cells[m]) == null ? void 0 : d[g]) ?? "", u.blur();
12431
+ u.value = ((d = l.cells[h]) == null ? void 0 : d[g]) ?? "", u.blur();
12432
12432
  return;
12433
12433
  }
12434
12434
  } else {
@@ -12601,7 +12601,7 @@ function OE() {
12601
12601
  });
12602
12602
  }
12603
12603
  function Lv() {
12604
- const [e, t] = ve(() => AE());
12604
+ const [e, t] = xe(() => AE());
12605
12605
  return se(() => {
12606
12606
  const n = Bv();
12607
12607
  n == null || n.classList.toggle("hide-grid", !e), TE(e);
@@ -12659,7 +12659,7 @@ function zv() {
12659
12659
  );
12660
12660
  }
12661
12661
  function Rv() {
12662
- const e = ce(), [t, n] = ve(Y6);
12662
+ const e = ce(), [t, n] = xe(Y6);
12663
12663
  return se(() => G6(n), []), /* @__PURE__ */ f(
12664
12664
  Ie,
12665
12665
  {
@@ -12728,7 +12728,7 @@ function Hv({
12728
12728
  onClick: () => t((o) => !o),
12729
12729
  "aria-label": n(e ? "view.gridHideAria" : "view.gridShowAria"),
12730
12730
  "aria-pressed": e,
12731
- className: Ne(!e && "text-muted-foreground/60"),
12731
+ className: Ee(!e && "text-muted-foreground/60"),
12732
12732
  children: /* @__PURE__ */ f(_2, {})
12733
12733
  }
12734
12734
  )
@@ -12757,7 +12757,7 @@ function Wv() {
12757
12757
  onClick: OE,
12758
12758
  "aria-label": e("view.label"),
12759
12759
  "aria-pressed": t !== "off",
12760
- className: Ne(t === "off" && "text-muted-foreground/60"),
12760
+ className: Ee(t === "off" && "text-muted-foreground/60"),
12761
12761
  children: /* @__PURE__ */ f(Hi, {})
12762
12762
  }
12763
12763
  )
@@ -12765,7 +12765,7 @@ function Wv() {
12765
12765
  );
12766
12766
  }
12767
12767
  function jE({ stacked: e } = {}) {
12768
- const t = ce(), [n, o] = ve(!1), [r, i] = Lv(), s = /* @__PURE__ */ C("div", { className: "space-y-0.5", children: [
12768
+ const t = ce(), [n, o] = xe(!1), [r, i] = Lv(), s = /* @__PURE__ */ C("div", { className: "space-y-0.5", children: [
12769
12769
  /* @__PURE__ */ f("div", { className: "font-medium", children: t("view.menu") }),
12770
12770
  /* @__PURE__ */ f("div", { className: "text-muted-foreground", children: t("view.menuHint") })
12771
12771
  ] }), a = e ? /* @__PURE__ */ f(Ie, { content: s, children: /* @__PURE__ */ C(
@@ -12775,7 +12775,7 @@ function jE({ stacked: e } = {}) {
12775
12775
  onClick: () => o((l) => !l),
12776
12776
  "aria-label": t("view.menu"),
12777
12777
  "aria-pressed": n,
12778
- className: Ne(
12778
+ className: Ee(
12779
12779
  "flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",
12780
12780
  n ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
12781
12781
  ),
@@ -12936,14 +12936,14 @@ const hi = [
12936
12936
  }
12937
12937
  ];
12938
12938
  function LE() {
12939
- const e = ce(), t = y((m) => m.activeTool), n = y((m) => m.placeKind), o = y((m) => m.placeFromTerminal), r = y((m) => m.wireDragFrom), i = y((m) => m.busbarDrawStart), s = y(
12940
- (m) => m.selection.length > 0 || m.selectedNode != null
12941
- ), a = y((m) => m.editingAnnotation), l = y((m) => {
12942
- var h;
12943
- const g = m.selectedAnnotation;
12939
+ const e = ce(), t = y((h) => h.activeTool), n = y((h) => h.placeKind), o = y((h) => h.placeFromTerminal), r = y((h) => h.wireDragFrom), i = y((h) => h.busbarDrawStart), s = y(
12940
+ (h) => h.selection.length > 0 || h.selectedNode != null
12941
+ ), a = y((h) => h.editingAnnotation), l = y((h) => {
12942
+ var p;
12943
+ const g = h.selectedAnnotation;
12944
12944
  if (!g) return null;
12945
- const p = (h = m.diagram.annotations) == null ? void 0 : h.find((b) => b.id === g);
12946
- return p ? He(p) : null;
12945
+ const m = (p = h.diagram.annotations) == null ? void 0 : p.find((b) => b.id === g);
12946
+ return m ? He(m) : null;
12947
12947
  });
12948
12948
  if (a)
12949
12949
  return /* @__PURE__ */ f("div", { className: "ole-glass pointer-events-none flex items-center gap-2 rounded-full border border-border px-3 py-1 text-xs text-muted-foreground shadow-sm", children: /* @__PURE__ */ f("span", { children: e("mode.annEditing") }) });
@@ -12995,45 +12995,56 @@ function LE() {
12995
12995
  ] });
12996
12996
  }
12997
12997
  function DE() {
12998
- const e = ce(), t = y((h) => h.activeTool), n = y((h) => h.placeKind), o = y((h) => h.setActiveTool), r = y((h) => h.past.length), i = y((h) => h.future.length), s = y((h) => h.undo), a = y((h) => h.redo), l = at(), c = Le(l, "tight"), d = !Le(l, "dense"), u = Le(l, "dense"), m = /* @__PURE__ */ new Set(["select", "text", "rect", "line", "table"]), g = u ? hi.filter((h) => !m.has(h.id)) : hi, p = (h) => t === h.switchTo;
12998
+ const e = ce(), t = y((x) => x.activeTool), n = y((x) => x.placeKind), o = y((x) => x.setActiveTool), r = y((x) => x.past.length), i = y((x) => x.future.length), s = y((x) => x.undo), a = y((x) => x.redo), l = at(), c = Le(l, "tight"), d = !Le(l, "dense"), u = Le(l, "dense"), h = /* @__PURE__ */ new Set(["select", "text", "rect", "line", "table"]), g = u ? hi.filter((x) => !h.has(x.id)) : hi, m = (x) => t === x.switchTo, [p, b] = xe(!1);
12999
12999
  return /* @__PURE__ */ C(
13000
13000
  "div",
13001
13001
  {
13002
13002
  className: "absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",
13003
13003
  style: { bottom: "calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))" },
13004
13004
  children: [
13005
- d && /* @__PURE__ */ f(LE, {}),
13005
+ d && /* @__PURE__ */ f(
13006
+ "div",
13007
+ {
13008
+ className: Ee(
13009
+ "transition-opacity duration-150",
13010
+ p && "pointer-events-none opacity-0"
13011
+ ),
13012
+ children: /* @__PURE__ */ f(LE, {})
13013
+ }
13014
+ ),
13006
13015
  /* @__PURE__ */ C(
13007
13016
  "div",
13008
13017
  {
13009
- className: Ne(
13018
+ onPointerEnter: () => b(!0),
13019
+ onPointerLeave: () => b(!1),
13020
+ className: Ee(
13010
13021
  "ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",
13011
13022
  u ? "gap-0.5 p-1" : "gap-0.5 p-1.5"
13012
13023
  ),
13013
13024
  children: [
13014
13025
  u && /* @__PURE__ */ f(zE, { stacked: !0 }),
13015
- g.map((h) => {
13016
- const b = h.icon, x = p(h), v = h.id === "place" && x && n == null ? e("tool.placeNoKindTooltip") : e(h.descriptionKey);
13026
+ g.map((x) => {
13027
+ const v = x.icon, P = m(x), O = x.id === "place" && P && n == null ? e("tool.placeNoKindTooltip") : e(x.descriptionKey);
13017
13028
  return /* @__PURE__ */ C(u2, { children: [
13018
13029
  /* @__PURE__ */ f(
13019
13030
  wt,
13020
13031
  {
13021
- icon: b,
13022
- label: e(h.labelKey),
13023
- hotkey: h.hotkey,
13024
- active: x,
13025
- iconOnly: !u && (h.iconOnly || c),
13032
+ icon: v,
13033
+ label: e(x.labelKey),
13034
+ hotkey: x.hotkey,
13035
+ active: P,
13036
+ iconOnly: !u && (x.iconOnly || c),
13026
13037
  stacked: u,
13027
- description: v,
13038
+ description: O,
13028
13039
  onClick: () => {
13029
- o(h.switchTo, {
13030
- placeKind: h.presetPlaceKind !== void 0 ? h.presetPlaceKind : void 0
13040
+ o(x.switchTo, {
13041
+ placeKind: x.presetPlaceKind !== void 0 ? x.presetPlaceKind : void 0
13031
13042
  });
13032
13043
  }
13033
13044
  }
13034
13045
  ),
13035
- h.groupBreakAfter && !u && /* @__PURE__ */ f("div", { "aria-hidden": !0, className: "mx-1 h-5 w-px bg-border" })
13036
- ] }, h.id);
13046
+ x.groupBreakAfter && !u && /* @__PURE__ */ f("div", { "aria-hidden": !0, className: "mx-1 h-5 w-px bg-border" })
13047
+ ] }, x.id);
13037
13048
  }),
13038
13049
  !u && /* @__PURE__ */ f("div", { "aria-hidden": !0, className: "mx-1 h-5 w-px bg-border" }),
13039
13050
  u ? /* @__PURE__ */ f(FE, { stacked: !0 }) : /* @__PURE__ */ C(Ke, { children: [
@@ -13111,7 +13122,7 @@ function wt({
13111
13122
  disabled: r,
13112
13123
  "aria-label": t,
13113
13124
  "aria-pressed": o,
13114
- className: Ne(
13125
+ className: Ee(
13115
13126
  "rounded-md font-medium transition-colors",
13116
13127
  s ? "flex h-12 w-12 flex-col items-center justify-center gap-0.5 text-[10px] leading-tight" : "flex h-9 items-center gap-1.5 text-xs",
13117
13128
  !s && (i ? "w-9 justify-center" : "px-2.5"),
@@ -13125,7 +13136,7 @@ function wt({
13125
13136
  "span",
13126
13137
  {
13127
13138
  "aria-hidden": !0,
13128
- className: Ne(
13139
+ className: Ee(
13129
13140
  "pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",
13130
13141
  o ? "bg-primary-foreground/20 text-primary-foreground/85" : "bg-foreground/10 text-muted-foreground"
13131
13142
  ),
@@ -13150,7 +13161,7 @@ function qv() {
13150
13161
  };
13151
13162
  }
13152
13163
  function RE({ iconOnly: e }) {
13153
- const t = ce(), [n, o] = ve(!1), r = qv(), i = (s) => () => {
13164
+ const t = ce(), [n, o] = xe(!1), r = qv(), i = (s) => () => {
13154
13165
  o(!1), s();
13155
13166
  };
13156
13167
  return /* @__PURE__ */ C(
@@ -13212,8 +13223,8 @@ function RE({ iconOnly: e }) {
13212
13223
  );
13213
13224
  }
13214
13225
  function FE({ stacked: e }) {
13215
- const t = ce(), [n, o] = ve(!1), r = y((m) => m.past.length), i = y((m) => m.future.length), s = y((m) => m.undo), a = y((m) => m.redo), l = y((m) => m.selection.length > 0), c = y((m) => m.clipboard != null), d = qv(), u = (m) => () => {
13216
- o(!1), m();
13226
+ const t = ce(), [n, o] = xe(!1), r = y((h) => h.past.length), i = y((h) => h.future.length), s = y((h) => h.undo), a = y((h) => h.redo), l = y((h) => h.selection.length > 0), c = y((h) => h.clipboard != null), d = qv(), u = (h) => () => {
13227
+ o(!1), h();
13217
13228
  };
13218
13229
  return /* @__PURE__ */ C(
13219
13230
  jo,
@@ -13229,7 +13240,7 @@ function FE({ stacked: e }) {
13229
13240
  active: n,
13230
13241
  iconOnly: !0,
13231
13242
  stacked: e,
13232
- onClick: () => o((m) => !m)
13243
+ onClick: () => o((h) => !h)
13233
13244
  }
13234
13245
  ),
13235
13246
  children: [
@@ -13333,7 +13344,7 @@ function Be({
13333
13344
  role: "menuitem",
13334
13345
  disabled: o,
13335
13346
  onClick: n,
13336
- className: Ne(
13347
+ className: Ee(
13337
13348
  "flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",
13338
13349
  o && "pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"
13339
13350
  ),
@@ -13379,7 +13390,7 @@ function WE({ onClick: e }) {
13379
13390
  onClick: e,
13380
13391
  "aria-label": t("outline.title"),
13381
13392
  title: t("outline.title"),
13382
- className: Ne(
13393
+ className: Ee(
13383
13394
  "ole-glass flex h-12 items-center rounded-2xl border border-border text-muted-foreground shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground",
13384
13395
  o ? "w-12 justify-center" : "gap-2 px-3"
13385
13396
  ),
@@ -13398,7 +13409,7 @@ function mi({
13398
13409
  return /* @__PURE__ */ C(
13399
13410
  "aside",
13400
13411
  {
13401
- className: Ne(
13412
+ className: Ee(
13402
13413
  "ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",
13403
13414
  t ? "w-full" : s ? "w-52" : "w-64"
13404
13415
  ),
@@ -13849,37 +13860,37 @@ function QE() {
13849
13860
  );
13850
13861
  }
13851
13862
  function eN({ sheet: e }) {
13852
- const t = ce(), n = Zt(), [o, r] = ve(""), [i, s] = ve(
13863
+ const t = ce(), n = Zt(), [o, r] = xe(""), [i, s] = xe(
13853
13864
  () => JE()
13854
13865
  ), a = Ai(() => {
13855
13866
  const u = o.trim().toLowerCase();
13856
13867
  if (!u) return Ht;
13857
- const m = {};
13858
- for (const [g, p] of Object.entries(Ht)) {
13859
- const h = p.filter((b) => {
13868
+ const h = {};
13869
+ for (const [g, m] of Object.entries(Ht)) {
13870
+ const p = m.filter((b) => {
13860
13871
  const x = n(`${b.id}.name`, b.name).toLowerCase(), v = n(`${b.id}.desc`, b.description ?? "").toLowerCase();
13861
13872
  return x.includes(u) || b.id.toLowerCase().includes(u) || v.includes(u);
13862
13873
  });
13863
- h.length && (m[g] = h);
13874
+ p.length && (h[g] = p);
13864
13875
  }
13865
- return m;
13866
- }, [o, n]), l = o.trim().length > 0, c = l && Object.values(a).every((u) => !(u != null && u.length)), d = yn((u, m) => {
13876
+ return h;
13877
+ }, [o, n]), l = o.trim().length > 0, c = l && Object.values(a).every((u) => !(u != null && u.length)), d = yn((u, h) => {
13867
13878
  s((g) => {
13868
- const p = new Set(g);
13869
- return m ? p.delete(u) : p.add(u), ZE(p), p;
13879
+ const m = new Set(g);
13880
+ return h ? m.delete(u) : m.add(u), ZE(m), m;
13870
13881
  });
13871
13882
  }, []);
13872
13883
  return /* @__PURE__ */ C(Ke, { children: [
13873
13884
  /* @__PURE__ */ f("div", { className: "px-2 pb-1.5 pt-2", children: /* @__PURE__ */ f(tN, { value: o, onChange: r }) }),
13874
13885
  /* @__PURE__ */ f("div", { className: "flex-1 overflow-y-auto px-2 pb-2", children: c ? /* @__PURE__ */ f("p", { className: "px-3 py-6 text-center text-xs text-muted-foreground", children: t("library.empty") }) : VE.map((u) => {
13875
13886
  var b;
13876
- const m = a[u];
13877
- if (!(m != null && m.length)) return null;
13878
- const g = ((b = Ht[u]) == null ? void 0 : b.length) ?? m.length, p = t(`cat.${u}`), h = l || !i.has(u);
13887
+ const h = a[u];
13888
+ if (!(h != null && h.length)) return null;
13889
+ const g = ((b = Ht[u]) == null ? void 0 : b.length) ?? h.length, m = t(`cat.${u}`), p = l || !i.has(u);
13879
13890
  return /* @__PURE__ */ C(
13880
13891
  "details",
13881
13892
  {
13882
- open: h,
13893
+ open: p,
13883
13894
  className: "group mb-2 last:mb-0",
13884
13895
  onToggle: (x) => {
13885
13896
  l || d(
@@ -13890,10 +13901,10 @@ function eN({ sheet: e }) {
13890
13901
  children: [
13891
13902
  /* @__PURE__ */ C("summary", { className: "flex cursor-pointer select-none items-center gap-1.5 rounded-md px-2 py-1.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground hover:bg-accent hover:text-accent-foreground", children: [
13892
13903
  /* @__PURE__ */ f(g2, { className: "size-3 transition-transform [details:not([open])>summary>&]:-rotate-90" }),
13893
- /* @__PURE__ */ f("span", { className: "flex-1", children: p }),
13894
- /* @__PURE__ */ f(oN, { children: l && m.length !== g ? `${m.length}/${g}` : g })
13904
+ /* @__PURE__ */ f("span", { className: "flex-1", children: m }),
13905
+ /* @__PURE__ */ f(oN, { children: l && h.length !== g ? `${h.length}/${g}` : g })
13895
13906
  ] }),
13896
- /* @__PURE__ */ f("ul", { className: "mt-0.5 space-y-px", children: m.map((x) => /* @__PURE__ */ f(nN, { entry: x, sheet: e }, x.id)) })
13907
+ /* @__PURE__ */ f("ul", { className: "mt-0.5 space-y-px", children: h.map((x) => /* @__PURE__ */ f(nN, { entry: x, sheet: e }, x.id)) })
13897
13908
  ]
13898
13909
  },
13899
13910
  u
@@ -13951,8 +13962,8 @@ function nN({
13951
13962
  draggable: !0,
13952
13963
  onDragStart: (u) => {
13953
13964
  u.dataTransfer.effectAllowed = "copy", u.dataTransfer.setData("application/x-oneline-kind", e.id), u.dataTransfer.setData("text/plain", e.id);
13954
- const m = document.createElement("div");
13955
- m.className = "ole-glass", m.style.cssText = [
13965
+ const h = document.createElement("div");
13966
+ h.className = "ole-glass", h.style.cssText = [
13956
13967
  "position:absolute",
13957
13968
  "top:-9999px",
13958
13969
  "left:-9999px",
@@ -13966,7 +13977,7 @@ function nN({
13966
13977
  "box-shadow:0 4px 12px rgba(0,0,0,0.12)",
13967
13978
  "color:var(--foreground)",
13968
13979
  "padding:8px"
13969
- ].join(";"), m.innerHTML = `<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`, document.body.appendChild(m), u.dataTransfer.setDragImage(m, 32, 32), setTimeout(() => m.remove(), 0);
13980
+ ].join(";"), h.innerHTML = `<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`, document.body.appendChild(h), u.dataTransfer.setDragImage(h, 32, 32), setTimeout(() => h.remove(), 0);
13970
13981
  },
13971
13982
  onClick: () => s("place", { placeKind: e.id }),
13972
13983
  "data-kind": e.id,
@@ -14116,7 +14127,7 @@ function sN() {
14116
14127
  if (d) return /* @__PURE__ */ f(wN, { junction: d });
14117
14128
  const u = n.find((g) => g.id === l);
14118
14129
  if (!u) return null;
14119
- const m = st[u.kind];
14130
+ const h = st[u.kind];
14120
14131
  return /* @__PURE__ */ C("div", { className: "flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs", children: [
14121
14132
  /* @__PURE__ */ f(
14122
14133
  Ze,
@@ -14136,13 +14147,13 @@ function sN() {
14136
14147
  },
14137
14148
  l
14138
14149
  ),
14139
- (m == null ? void 0 : m.state) && m.state.length > 0 && /* @__PURE__ */ f("div", { className: "mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5", children: m.state.map((g) => /* @__PURE__ */ f(kN, { id: l, element: u, field: g }, g.name)) }),
14150
+ (h == null ? void 0 : h.state) && h.state.length > 0 && /* @__PURE__ */ f("div", { className: "mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5", children: h.state.map((g) => /* @__PURE__ */ f(kN, { id: l, element: u, field: g }, g.name)) }),
14140
14151
  /* @__PURE__ */ f(
14141
14152
  aN,
14142
14153
  {
14143
14154
  id: l,
14144
14155
  element: u,
14145
- schema: (m == null ? void 0 : m.params) ?? []
14156
+ schema: (h == null ? void 0 : h.params) ?? []
14146
14157
  }
14147
14158
  )
14148
14159
  ] });
@@ -14425,7 +14436,7 @@ function fn({
14425
14436
  type: "button",
14426
14437
  "aria-pressed": t === r.value,
14427
14438
  onClick: () => o(r.value),
14428
- className: Ne(
14439
+ className: Ee(
14429
14440
  "h-7 flex-1 truncate px-1.5 text-[11px] transition-colors",
14430
14441
  t === r.value ? "bg-primary text-primary-foreground" : "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
14431
14442
  ),
@@ -14494,16 +14505,16 @@ function bN({ wireId: e }) {
14494
14505
  const t = ce(), n = y((b) => b.diagram.wires), o = y((b) => b.diagram.elements), r = y((b) => b.diagram.buses), i = y((b) => b.diagram.junctions), s = y((b) => b.internal.terminalToNode), a = y((b) => b.setSelectedNode), l = (n ?? []).find((b) => b.id === e);
14495
14506
  if (!l)
14496
14507
  return /* @__PURE__ */ f("div", { className: "px-4 py-5 text-center text-xs text-muted-foreground", children: t("props.wireNotFound", { id: e }) });
14497
- const c = s.get(l.ends[0]), d = new Map(o.map((b) => [b.id, b])), u = new Map((r ?? []).map((b) => [b.id, b])), m = new Map((i ?? []).map((b) => [b.id, b])), g = (b) => {
14508
+ const c = s.get(l.ends[0]), d = new Map(o.map((b) => [b.id, b])), u = new Map((r ?? []).map((b) => [b.id, b])), h = new Map((i ?? []).map((b) => [b.id, b])), g = (b) => {
14498
14509
  if (!b.includes(".")) {
14499
14510
  const F = u.get(b);
14500
14511
  if (F) return { id: b, label: F.name ?? b };
14501
- const G = m.get(b);
14512
+ const G = h.get(b);
14502
14513
  return { id: b, label: (G == null ? void 0 : G.name) ?? b };
14503
14514
  }
14504
- const x = b.indexOf("."), v = b.slice(0, x), P = b.slice(x + 1), j = d.get(v);
14505
- return { id: v, label: (j == null ? void 0 : j.name) ?? v, pin: P };
14506
- }, p = g(l.ends[0]), h = g(l.ends[1]);
14515
+ const x = b.indexOf("."), v = b.slice(0, x), P = b.slice(x + 1), O = d.get(v);
14516
+ return { id: v, label: (O == null ? void 0 : O.name) ?? v, pin: P };
14517
+ }, m = g(l.ends[0]), p = g(l.ends[1]);
14507
14518
  return /* @__PURE__ */ C("div", { className: "flex flex-col gap-3 px-3 py-3 text-xs", children: [
14508
14519
  /* @__PURE__ */ C("div", { className: "space-y-1", children: [
14509
14520
  /* @__PURE__ */ f("div", { className: "text-[11px] uppercase tracking-wide text-muted-foreground", children: t("props.wire") }),
@@ -14518,7 +14529,7 @@ function bN({ wireId: e }) {
14518
14529
  onCommit: (b) => y.getState().updateWire(e, { label: b.trim() === "" ? void 0 : b.trim() })
14519
14530
  }
14520
14531
  ),
14521
- /* @__PURE__ */ f("ul", { className: "space-y-0.5 border-t border-border/40 pt-2", children: [p, h].map((b, x) => /* @__PURE__ */ C(
14532
+ /* @__PURE__ */ f("ul", { className: "space-y-0.5 border-t border-border/40 pt-2", children: [m, p].map((b, x) => /* @__PURE__ */ C(
14522
14533
  "li",
14523
14534
  {
14524
14535
  className: "flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",
@@ -14637,7 +14648,7 @@ function Ze({
14637
14648
  unit: o,
14638
14649
  onCommit: r
14639
14650
  }) {
14640
- const [i, s] = ve(t), a = fe(null);
14651
+ const [i, s] = xe(t), a = fe(null);
14641
14652
  return se(() => s(t), [t]), /* @__PURE__ */ f(lt, { label: e, children: /* @__PURE__ */ C("div", { className: "relative", children: [
14642
14653
  /* @__PURE__ */ f(
14643
14654
  "input",
@@ -14654,7 +14665,7 @@ function Ze({
14654
14665
  var c, d;
14655
14666
  l.key === "Enter" && ((c = a.current) == null || c.blur()), l.key === "Escape" && (s(t), (d = a.current) == null || d.blur());
14656
14667
  },
14657
- className: Ne(
14668
+ className: Ee(
14658
14669
  "h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",
14659
14670
  o && "pr-8"
14660
14671
  )
@@ -14669,7 +14680,7 @@ function Lo({
14669
14680
  value: t,
14670
14681
  onCommit: n
14671
14682
  }) {
14672
- const [o, r] = ve(t), i = fe(!1), s = fe(null), a = fe({ local: o, value: t, onCommit: n });
14683
+ const [o, r] = xe(t), i = fe(!1), s = fe(null), a = fe({ local: o, value: t, onCommit: n });
14673
14684
  a.current = { local: o, value: t, onCommit: n };
14674
14685
  const l = fe(null);
14675
14686
  se(() => {
@@ -14707,7 +14718,7 @@ function Dn({
14707
14718
  unit: o,
14708
14719
  onCommit: r
14709
14720
  }) {
14710
- const [i, s] = ve(String(t)), a = fe(null);
14721
+ const [i, s] = xe(String(t)), a = fe(null);
14711
14722
  return se(() => s(String(t)), [t]), /* @__PURE__ */ f(lt, { label: e, children: /* @__PURE__ */ C("div", { className: "relative", children: [
14712
14723
  /* @__PURE__ */ f(
14713
14724
  "input",
@@ -14725,7 +14736,7 @@ function Dn({
14725
14736
  l.key === "Enter" && ((c = a.current) == null || c.blur()), l.key === "Escape" && (s(String(t)), (d = a.current) == null || d.blur());
14726
14737
  },
14727
14738
  min: n,
14728
- className: Ne(
14739
+ className: Ee(
14729
14740
  "h-7 w-full rounded-md border border-border/60 bg-background/50 px-2 font-mono text-[11px] tabular-nums focus:border-border focus:outline-none focus:ring-1 focus:ring-ring",
14730
14741
  o && "pr-8"
14731
14742
  )
@@ -14744,7 +14755,7 @@ function Do({
14744
14755
  {
14745
14756
  type: "button",
14746
14757
  onClick: t,
14747
- className: Ne(
14758
+ className: Ee(
14748
14759
  "flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",
14749
14760
  e ? "border-[var(--selection)] bg-[var(--selection)]/15 text-foreground" : "border-border/60 text-muted-foreground hover:bg-accent"
14750
14761
  ),
@@ -14785,31 +14796,31 @@ function _N() {
14785
14796
  const e = ce(), t = Zt(), n = y((g) => g.selection), o = y((g) => g.selectedNode), r = y((g) => g.selectedWire), i = y((g) => g.selectedAnnotation), s = y((g) => g.diagram.annotations), a = y((g) => g.diagram.elements), l = y((g) => g.diagram.buses), c = at(), d = Le(c, "dense");
14786
14797
  if (n.length === 0 && !o && !r && !i)
14787
14798
  return null;
14788
- let u = e("props.title"), m = null;
14799
+ let u = e("props.title"), h = null;
14789
14800
  if (r)
14790
14801
  u = e("props.wire");
14791
14802
  else if (o)
14792
14803
  u = e("props.node");
14793
14804
  else if (i) {
14794
- const g = (s ?? []).find((h) => h.id === i), p = g ? He(g) : "text";
14795
- u = e(p === "rect" ? "props.annRect" : p === "line" ? "props.annLine" : p === "table" ? "props.annTable" : "props.annText");
14805
+ const g = (s ?? []).find((p) => p.id === i), m = g ? He(g) : "text";
14806
+ u = e(m === "rect" ? "props.annRect" : m === "line" ? "props.annLine" : m === "table" ? "props.annTable" : "props.annText");
14796
14807
  } else if (n.length === 1) {
14797
- const g = n[0], p = (l ?? []).find((h) => h.id === g);
14798
- if (p)
14799
- u = p.name ?? e("props.bus");
14808
+ const g = n[0], m = (l ?? []).find((p) => p.id === g);
14809
+ if (m)
14810
+ u = m.name ?? e("props.bus");
14800
14811
  else {
14801
- const h = a.find((b) => b.id === g);
14802
- if (h) {
14803
- const b = st[h.kind];
14804
- u = b ? t(`${b.id}.name`, b.name) : h.kind;
14812
+ const p = a.find((b) => b.id === g);
14813
+ if (p) {
14814
+ const b = st[p.kind];
14815
+ u = b ? t(`${b.id}.name`, b.name) : p.kind;
14805
14816
  }
14806
14817
  }
14807
14818
  } else
14808
- m = n.length;
14819
+ h = n.length;
14809
14820
  return /* @__PURE__ */ C(
14810
14821
  "aside",
14811
14822
  {
14812
- className: Ne(
14823
+ className: Ee(
14813
14824
  "ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",
14814
14825
  d ? "w-48" : "w-56"
14815
14826
  ),
@@ -14821,7 +14832,7 @@ function _N() {
14821
14832
  children: [
14822
14833
  /* @__PURE__ */ C("div", { className: "flex items-center gap-1.5 border-b border-border/40 px-3 py-2", children: [
14823
14834
  /* @__PURE__ */ f("span", { className: "flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: u }),
14824
- m != null && /* @__PURE__ */ f("span", { className: "rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80", children: e("props.nSelected", { n: m }) })
14835
+ h != null && /* @__PURE__ */ f("span", { className: "rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80", children: e("props.nSelected", { n: h }) })
14825
14836
  ] }),
14826
14837
  /* @__PURE__ */ f(sN, {})
14827
14838
  ]
@@ -14995,23 +15006,23 @@ async function vi(e, t, n = {}) {
14995
15006
  return i.href = r, i.download = (t == null ? void 0 : t.name) ?? "diagram.json", i.click(), URL.revokeObjectURL(r), t ?? { name: "diagram.json" };
14996
15007
  }
14997
15008
  function p5() {
14998
- const e = ce(), t = y((u) => u.fileSession), n = (t == null ? void 0 : t.name) ?? e("common.unnamed"), { onNew: o, onOpen: r, onSave: i, onSaveAs: s } = PN(), [a, l] = ve(!1), c = fe(null);
15009
+ const e = ce(), t = y((u) => u.fileSession), n = (t == null ? void 0 : t.name) ?? e("common.unnamed"), { onNew: o, onOpen: r, onSave: i, onSaveAs: s } = PN(), [a, l] = xe(!1), c = fe(null);
14999
15010
  se(() => {
15000
- const u = (m) => {
15001
- if (!(m.metaKey || m.ctrlKey)) return;
15002
- const g = m.key.toLowerCase();
15003
- g === "o" ? (m.preventDefault(), r()) : g === "s" && (m.preventDefault(), m.shiftKey ? s() : i());
15011
+ const u = (h) => {
15012
+ if (!(h.metaKey || h.ctrlKey)) return;
15013
+ const g = h.key.toLowerCase();
15014
+ g === "o" ? (h.preventDefault(), r()) : g === "s" && (h.preventDefault(), h.shiftKey ? s() : i());
15004
15015
  };
15005
15016
  return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
15006
15017
  }, [r, i, s]), se(() => {
15007
15018
  if (!a) return;
15008
15019
  const u = (g) => {
15009
15020
  c.current && !c.current.contains(g.target) && l(!1);
15010
- }, m = (g) => {
15021
+ }, h = (g) => {
15011
15022
  g.key === "Escape" && l(!1);
15012
15023
  };
15013
- return window.addEventListener("mousedown", u), window.addEventListener("keydown", m), () => {
15014
- window.removeEventListener("mousedown", u), window.removeEventListener("keydown", m);
15024
+ return window.addEventListener("mousedown", u), window.addEventListener("keydown", h), () => {
15025
+ window.removeEventListener("mousedown", u), window.removeEventListener("keydown", h);
15015
15026
  };
15016
15027
  }, [a]);
15017
15028
  const d = (u) => () => {
@@ -15111,8 +15122,8 @@ function BN(e, t = {}) {
15111
15122
  for (const s of e.wireRenders.values())
15112
15123
  s.path.length < 2 || n.lwpolyline(ao, s.path.map(we), !1);
15113
15124
  for (const { geometry: s } of e.buses.values()) {
15114
- const { axis: a, at: l, span: c } = s, d = c / 2, u = a === "x" ? [l[0] - d, l[1]] : [l[0], l[1] - d], m = a === "x" ? [l[0] + d, l[1]] : [l[0], l[1] + d];
15115
- n.lwpolyline(ao, [u, m].map(we), !1);
15125
+ const { axis: a, at: l, span: c } = s, d = c / 2, u = a === "x" ? [l[0] - d, l[1]] : [l[0], l[1] - d], h = a === "x" ? [l[0] + d, l[1]] : [l[0], l[1] + d];
15126
+ n.lwpolyline(ao, [u, h].map(we), !1);
15116
15127
  }
15117
15128
  for (const s of e.elements.values()) {
15118
15129
  const a = e.layout.get(s.element.id), l = s.libraryDef;
@@ -15127,12 +15138,12 @@ function BN(e, t = {}) {
15127
15138
  if (l.length === 0) continue;
15128
15139
  const c = s.libraryDef.label ?? In(s.libraryDef), {
15129
15140
  world: [d, u],
15130
- textAnchor: m,
15141
+ textAnchor: h,
15131
15142
  dy: g
15132
15143
  } = On(c, s.libraryDef, a, l.length);
15133
- for (let p = 0; p < l.length; p++) {
15134
- const [h, b] = we([d, u + g + p * Kt]);
15135
- n.text(lo, [h, b], l[p], Fe, 0, !1, m);
15144
+ for (let m = 0; m < l.length; m++) {
15145
+ const [p, b] = we([d, u + g + m * Kt]);
15146
+ n.text(lo, [p, b], l[m], Fe, 0, !1, h);
15136
15147
  }
15137
15148
  }
15138
15149
  for (const s of e.wireRenders.values()) {
@@ -15158,11 +15169,11 @@ function BN(e, t = {}) {
15158
15169
  ].map(we),
15159
15170
  !0
15160
15171
  ), a.label) {
15161
- const m = we([
15172
+ const h = we([
15162
15173
  l + xt,
15163
15174
  c + xt + Ge
15164
15175
  ]);
15165
- n.text(Re, m, a.label, Ge, 0, !1);
15176
+ n.text(Re, h, a.label, Ge, 0, !1);
15166
15177
  }
15167
15178
  break;
15168
15179
  }
@@ -15175,7 +15186,7 @@ function BN(e, t = {}) {
15175
15186
  break;
15176
15187
  }
15177
15188
  case "table": {
15178
- const a = s, [l, c] = a.at, [d, u] = Je(a), m = St(a), g = $t(a), p = a.fontSize ?? Ge;
15189
+ const a = s, [l, c] = a.at, [d, u] = Je(a), h = St(a), g = $t(a), m = a.fontSize ?? Ge;
15179
15190
  n.lwpolyline(
15180
15191
  Re,
15181
15192
  [
@@ -15186,27 +15197,27 @@ function BN(e, t = {}) {
15186
15197
  ].map(we),
15187
15198
  !0
15188
15199
  );
15189
- for (let h = 1; h < a.colWidths.length; h++)
15200
+ for (let p = 1; p < a.colWidths.length; p++)
15190
15201
  n.line(
15191
15202
  Re,
15192
- we([l + m[h], c]),
15193
- we([l + m[h], c + u])
15203
+ we([l + h[p], c]),
15204
+ we([l + h[p], c + u])
15194
15205
  );
15195
- for (let h = 1; h < a.rowHeights.length; h++)
15206
+ for (let p = 1; p < a.rowHeights.length; p++)
15196
15207
  n.line(
15197
15208
  Re,
15198
- we([l, c + g[h]]),
15199
- we([l + d, c + g[h]])
15209
+ we([l, c + g[p]]),
15210
+ we([l + d, c + g[p]])
15200
15211
  );
15201
- for (let h = 0; h < a.rowHeights.length; h++)
15212
+ for (let p = 0; p < a.rowHeights.length; p++)
15202
15213
  for (let b = 0; b < a.colWidths.length; b++) {
15203
- const x = ((i = a.cells[h]) == null ? void 0 : i[b]) ?? "";
15214
+ const x = ((i = a.cells[p]) == null ? void 0 : i[b]) ?? "";
15204
15215
  if (x === "") continue;
15205
15216
  const v = we([
15206
- l + m[b] + Wt,
15207
- c + g[h] + a.rowHeights[h] / 2 + p * 0.35
15217
+ l + h[b] + Wt,
15218
+ c + g[p] + a.rowHeights[p] / 2 + m * 0.35
15208
15219
  ]);
15209
- n.text(Re, v, x, p, 0, !1);
15220
+ n.text(Re, v, x, m, 0, !1);
15210
15221
  }
15211
15222
  break;
15212
15223
  }
@@ -15216,11 +15227,11 @@ function BN(e, t = {}) {
15216
15227
  const l = a.fontSize ?? IN, c = a.text.split(`
15217
15228
  `);
15218
15229
  for (let d = 0; d < c.length; d++) {
15219
- const [u, m] = we([
15230
+ const [u, h] = we([
15220
15231
  a.at[0],
15221
15232
  a.at[1] + (d + 1) * l * ON
15222
15233
  ]);
15223
- n.text(Re, [u, m], c[d], l, 0, !1);
15234
+ n.text(Re, [u, h], c[d], l, 0, !1);
15224
15235
  }
15225
15236
  break;
15226
15237
  }
@@ -15332,25 +15343,25 @@ function YN(e, t, n) {
15332
15343
  if (l.cmd === "M")
15333
15344
  a(), i = [l.args[0], l.args[1]], s.push(i);
15334
15345
  else if (l.cmd === "A" && i) {
15335
- const [c, d, , u, m, g, p] = l.args, h = KN(
15346
+ const [c, d, , u, h, g, m] = l.args, p = KN(
15336
15347
  i,
15337
- [g, p],
15348
+ [g, m],
15338
15349
  c,
15339
15350
  d,
15340
15351
  u !== 0,
15341
- m !== 0
15352
+ h !== 0
15342
15353
  );
15343
- if (h)
15354
+ if (p)
15344
15355
  for (let b = 1; b <= ki; b++) {
15345
- const x = h.theta1 + h.delta * b / ki;
15356
+ const x = p.theta1 + p.delta * b / ki;
15346
15357
  s.push([
15347
- h.cx + c * Math.cos(x),
15348
- h.cy + d * Math.sin(x)
15358
+ p.cx + c * Math.cos(x),
15359
+ p.cy + d * Math.sin(x)
15349
15360
  ]);
15350
15361
  }
15351
15362
  else
15352
- s.push([g, p]);
15353
- i = [g, p];
15363
+ s.push([g, m]);
15364
+ i = [g, m];
15354
15365
  }
15355
15366
  a();
15356
15367
  }
@@ -15368,21 +15379,21 @@ function KN(e, t, n, o, r, i) {
15368
15379
  const [s, a] = e, [l, c] = t;
15369
15380
  if (s === l && a === c) return null;
15370
15381
  const d = (s - l) / 2, u = (a - c) / 2;
15371
- let m = Math.abs(n), g = Math.abs(o);
15372
- const p = m * m, h = g * g, b = d * d / p + u * u / h;
15382
+ let h = Math.abs(n), g = Math.abs(o);
15383
+ const m = h * h, p = g * g, b = d * d / m + u * u / p;
15373
15384
  if (b > 1) {
15374
15385
  const R = Math.sqrt(b);
15375
- m *= R, g *= R;
15386
+ h *= R, g *= R;
15376
15387
  }
15377
- const x = r === i ? -1 : 1, v = m * m * g * g - m * m * u * u - g * g * d * d, P = m * m * u * u + g * g * d * d, j = x * Math.sqrt(Math.max(0, v / P)), F = j * (m * u) / g, G = j * -(g * d) / m, $ = F + (s + l) / 2, H = G + (a + c) / 2, W = (R, Z, ae, he) => {
15388
+ const x = r === i ? -1 : 1, v = h * h * g * g - h * h * u * u - g * g * d * d, P = h * h * u * u + g * g * d * d, O = x * Math.sqrt(Math.max(0, v / P)), F = O * (h * u) / g, G = O * -(g * d) / h, $ = F + (s + l) / 2, H = G + (a + c) / 2, W = (R, Z, ae, he) => {
15378
15389
  const ee = R * ae + Z * he, le = Math.hypot(R, Z) * Math.hypot(ae, he);
15379
15390
  let ge = Math.acos(Math.max(-1, Math.min(1, ee / le)));
15380
15391
  return R * he - Z * ae < 0 && (ge = -ge), ge;
15381
- }, X = W(1, 0, (d - F) / m, (u - G) / g);
15392
+ }, X = W(1, 0, (d - F) / h, (u - G) / g);
15382
15393
  let I = W(
15383
- (d - F) / m,
15394
+ (d - F) / h,
15384
15395
  (u - G) / g,
15385
- (-d - F) / m,
15396
+ (-d - F) / h,
15386
15397
  (-u - G) / g
15387
15398
  );
15388
15399
  return !i && I > 0 ? I -= 2 * Math.PI : i && I < 0 && (I += 2 * Math.PI), { cx: $, cy: H, theta1: X, delta: I };
@@ -15467,76 +15478,76 @@ function Uv(e, t = {}) {
15467
15478
  ), t.title && l.push(` <title>${Xe(t.title)}</title>`), a !== "transparent" && l.push(
15468
15479
  ` <rect x="${o}" y="${r}" width="${i}" height="${s}" fill="${a}"/>`
15469
15480
  ), l.push(' <g fill="none" stroke="black" stroke-width="1">');
15470
- for (const m of e.wireRenders.values()) {
15471
- if (m.path.length < 2) continue;
15472
- const g = m.path.map(([p, h]) => `${p},${h}`).join(" ");
15481
+ for (const h of e.wireRenders.values()) {
15482
+ if (h.path.length < 2) continue;
15483
+ const g = h.path.map(([m, p]) => `${m},${p}`).join(" ");
15473
15484
  l.push(` <polyline points="${g}"/>`);
15474
15485
  }
15475
15486
  l.push(" </g>");
15476
- for (const { bus: m, geometry: g } of e.buses.values()) {
15477
- const { axis: p, at: h, span: b } = g, x = b / 2, v = p === "x" ? h[0] - x : h[0], P = p === "x" ? h[1] : h[1] - x, j = p === "x" ? h[0] + x : h[0], F = p === "x" ? h[1] : h[1] + x;
15487
+ for (const { bus: h, geometry: g } of e.buses.values()) {
15488
+ const { axis: m, at: p, span: b } = g, x = b / 2, v = m === "x" ? p[0] - x : p[0], P = m === "x" ? p[1] : p[1] - x, O = m === "x" ? p[0] + x : p[0], F = m === "x" ? p[1] : p[1] + x;
15478
15489
  l.push(
15479
- ` <line id="${Xe(m.id)}" x1="${v}" y1="${P}" x2="${j}" y2="${F}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`
15490
+ ` <line id="${Xe(h.id)}" x1="${v}" y1="${P}" x2="${O}" y2="${F}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`
15480
15491
  );
15481
15492
  }
15482
- for (const { junction: m, world: g, degree: p } of e.junctions.values())
15483
- p < 3 || l.push(
15484
- ` <circle id="${Xe(m.id)}" cx="${g[0]}" cy="${g[1]}" r="3.5" fill="black"/>`
15493
+ for (const { junction: h, world: g, degree: m } of e.junctions.values())
15494
+ m < 3 || l.push(
15495
+ ` <circle id="${Xe(h.id)}" cx="${g[0]}" cy="${g[1]}" r="3.5" fill="black"/>`
15485
15496
  );
15486
- for (const m of e.elements.values()) {
15487
- if (!m.libraryDef) continue;
15488
- const g = e.layout.get(m.element.id);
15497
+ for (const h of e.elements.values()) {
15498
+ if (!h.libraryDef) continue;
15499
+ const g = e.layout.get(h.element.id);
15489
15500
  g && (l.push(
15490
- ` <g id="${Xe(m.element.id)}" transform="${it(g)}">`
15491
- ), l.push(` ${m.libraryDef.svg}`), l.push(" </g>"));
15501
+ ` <g id="${Xe(h.element.id)}" transform="${it(g)}">`
15502
+ ), l.push(` ${h.libraryDef.svg}`), l.push(" </g>"));
15492
15503
  }
15493
15504
  const c = t.labelMode ?? "all";
15494
15505
  if (c !== "off") {
15495
- const m = a === "transparent" ? "#FFFFFF" : a;
15506
+ const h = a === "transparent" ? "#FFFFFF" : a;
15496
15507
  l.push(
15497
- ` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Fe}" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`
15508
+ ` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Fe}" paint-order="stroke" stroke="${h}" stroke-width="2" stroke-linejoin="round">`
15498
15509
  );
15499
15510
  for (const g of e.elements.values()) {
15500
- const p = e.layout.get(g.element.id);
15501
- if (!p || !g.libraryDef) continue;
15502
- const h = Pn(g, c);
15503
- if (h.length === 0) continue;
15511
+ const m = e.layout.get(g.element.id);
15512
+ if (!m || !g.libraryDef) continue;
15513
+ const p = Pn(g, c);
15514
+ if (p.length === 0) continue;
15504
15515
  const b = g.libraryDef.label ?? In(g.libraryDef), {
15505
15516
  world: [x, v],
15506
15517
  textAnchor: P,
15507
- dy: j
15508
- } = On(b, g.libraryDef, p, h.length);
15509
- for (let F = 0; F < h.length; F++)
15518
+ dy: O
15519
+ } = On(b, g.libraryDef, m, p.length);
15520
+ for (let F = 0; F < p.length; F++)
15510
15521
  l.push(
15511
- ` <text x="${x}" y="${v + j + F * Kt}" text-anchor="${P}">${Xe(h[F])}</text>`
15522
+ ` <text x="${x}" y="${v + O + F * Kt}" text-anchor="${P}">${Xe(p[F])}</text>`
15512
15523
  );
15513
15524
  }
15514
15525
  for (const g of e.wireRenders.values()) {
15515
- const p = (u = g.label) == null ? void 0 : u.trim();
15516
- if (!p) continue;
15517
- const h = jn(g.path);
15518
- h && l.push(
15519
- ` <text x="${h.world[0]}" y="${h.world[1]}" text-anchor="${h.textAnchor}">${Xe(p)}</text>`
15526
+ const m = (u = g.label) == null ? void 0 : u.trim();
15527
+ if (!m) continue;
15528
+ const p = jn(g.path);
15529
+ p && l.push(
15530
+ ` <text x="${p.world[0]}" y="${p.world[1]}" text-anchor="${p.textAnchor}">${Xe(m)}</text>`
15520
15531
  );
15521
15532
  }
15522
15533
  l.push(" </g>");
15523
15534
  }
15524
15535
  const d = t.annotations ?? [];
15525
15536
  if (d.length > 0) {
15526
- const m = a === "transparent" ? "#FFFFFF" : a, g = a === "transparent" ? "none" : a, p = `font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round"`;
15527
- for (const h of d)
15528
- switch (He(h)) {
15537
+ const h = a === "transparent" ? "#FFFFFF" : a, g = a === "transparent" ? "none" : a, m = `font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${h}" stroke-width="2" stroke-linejoin="round"`;
15538
+ for (const p of d)
15539
+ switch (He(p)) {
15529
15540
  case "rect":
15530
- e5(l, h, p);
15541
+ e5(l, p, m);
15531
15542
  break;
15532
15543
  case "line":
15533
- t5(l, h);
15544
+ t5(l, p);
15534
15545
  break;
15535
15546
  case "table":
15536
- n5(l, h, g);
15547
+ n5(l, p, g);
15537
15548
  break;
15538
15549
  default:
15539
- QN(l, h, p);
15550
+ QN(l, p, m);
15540
15551
  break;
15541
15552
  }
15542
15553
  }
@@ -15579,7 +15590,7 @@ function t5(e, t) {
15579
15590
  );
15580
15591
  }
15581
15592
  function n5(e, t, n) {
15582
- var m;
15593
+ var h;
15583
15594
  const [o, r] = t.at, [i, s] = Je(t), a = St(t), l = $t(t), c = t.fontSize ?? Ge;
15584
15595
  n !== "none" && e.push(
15585
15596
  ` <rect x="${o}" y="${r}" width="${i}" height="${s}" fill="${n}"/>`
@@ -15594,12 +15605,12 @@ function n5(e, t, n) {
15594
15605
  );
15595
15606
  const u = [];
15596
15607
  for (let g = 0; g < t.rowHeights.length; g++)
15597
- for (let p = 0; p < t.colWidths.length; p++) {
15598
- const h = ((m = t.cells[g]) == null ? void 0 : m[p]) ?? "";
15599
- if (h === "") continue;
15600
- const b = o + a[p] + Wt, x = r + l[g] + t.rowHeights[g] / 2 + c * 0.35;
15608
+ for (let m = 0; m < t.colWidths.length; m++) {
15609
+ const p = ((h = t.cells[g]) == null ? void 0 : h[m]) ?? "";
15610
+ if (p === "") continue;
15611
+ const b = o + a[m] + Wt, x = r + l[g] + t.rowHeights[g] / 2 + c * 0.35;
15601
15612
  u.push(
15602
- ` <text x="${b}" y="${x}" font-size="${c}">${Xe(h)}</text>`
15613
+ ` <text x="${b}" y="${x}" font-size="${c}">${Xe(p)}</text>`
15603
15614
  );
15604
15615
  }
15605
15616
  u.length > 0 && (e.push(
@@ -15617,24 +15628,24 @@ function o5(e, t) {
15617
15628
  for (const c of e.elements.values()) {
15618
15629
  const d = e.layout.get(c.element.id), u = c.libraryDef;
15619
15630
  if (!d || !u) continue;
15620
- const m = r5(u.viewBox);
15621
- if (!m) {
15631
+ const h = r5(u.viewBox);
15632
+ if (!h) {
15622
15633
  s(d.at[0], d.at[1]);
15623
15634
  continue;
15624
15635
  }
15625
15636
  const g = [
15626
- [m.x, m.y],
15627
- [m.x + m.w, m.y],
15628
- [m.x, m.y + m.h],
15629
- [m.x + m.w, m.y + m.h]
15637
+ [h.x, h.y],
15638
+ [h.x + h.w, h.y],
15639
+ [h.x, h.y + h.h],
15640
+ [h.x + h.w, h.y + h.h]
15630
15641
  ];
15631
- for (const p of g) {
15632
- const [h, b] = ze(p, d);
15633
- s(h, b);
15642
+ for (const m of g) {
15643
+ const [p, b] = ze(m, d);
15644
+ s(p, b);
15634
15645
  }
15635
15646
  }
15636
15647
  for (const { geometry: c } of e.buses.values()) {
15637
- const { axis: d, at: u, span: m } = c, g = m / 2;
15648
+ const { axis: d, at: u, span: h } = c, g = h / 2;
15638
15649
  d === "x" ? (s(u[0] - g, u[1]), s(u[0] + g, u[1])) : (s(u[0], u[1] - g), s(u[0], u[1] + g));
15639
15650
  }
15640
15651
  for (const c of e.wireRenders.values())
@@ -15646,20 +15657,20 @@ function o5(e, t) {
15646
15657
  if (!d || !c.libraryDef) continue;
15647
15658
  const u = Pn(c, a);
15648
15659
  if (u.length === 0) continue;
15649
- const m = c.libraryDef.label ?? In(c.libraryDef), {
15650
- world: [g, p],
15651
- textAnchor: h,
15660
+ const h = c.libraryDef.label ?? In(c.libraryDef), {
15661
+ world: [g, m],
15662
+ textAnchor: p,
15652
15663
  dy: b
15653
- } = On(m, c.libraryDef, d, u.length), x = Ei(u, Fe), v = u.length * Kt, P = h === "middle" ? g - x / 2 : h === "end" ? g - x : g;
15654
- s(P, p + b - Fe), s(P + x, p + b + v);
15664
+ } = On(h, c.libraryDef, d, u.length), x = Ei(u, Fe), v = u.length * Kt, P = p === "middle" ? g - x / 2 : p === "end" ? g - x : g;
15665
+ s(P, m + b - Fe), s(P + x, m + b + v);
15655
15666
  }
15656
15667
  for (const c of e.wireRenders.values()) {
15657
15668
  const d = (l = c.label) == null ? void 0 : l.trim();
15658
15669
  if (!d) continue;
15659
15670
  const u = jn(c.path);
15660
15671
  if (!u) continue;
15661
- const [m, g] = u.world, p = Ei([d], Fe), h = u.textAnchor === "middle" ? m - p / 2 : m;
15662
- s(h, g - Fe), s(h + p, g);
15672
+ const [h, g] = u.world, m = Ei([d], Fe), p = u.textAnchor === "middle" ? h - m / 2 : h;
15673
+ s(p, g - Fe), s(p + m, g);
15663
15674
  }
15664
15675
  }
15665
15676
  for (const c of t.annotations ?? []) {
@@ -15703,7 +15714,7 @@ async function s5(e, t = "diagram.png", n) {
15703
15714
  if (!l) throw new Error("canvas 2d context unavailable");
15704
15715
  n != null && n.background && n.background !== "transparent" && (l.fillStyle = n.background, l.fillRect(0, 0, a.width, a.height)), l.drawImage(s, 0, 0, a.width, a.height);
15705
15716
  const c = await new Promise((d, u) => {
15706
- a.toBlob((m) => m ? d(m) : u(new Error("toBlob failed")), "image/png");
15717
+ a.toBlob((h) => h ? d(h) : u(new Error("toBlob failed")), "image/png");
15707
15718
  });
15708
15719
  Vv(c, t);
15709
15720
  } finally {
@@ -15721,7 +15732,7 @@ function Vv(e, t) {
15721
15732
  o.href = n, o.download = t, o.click(), URL.revokeObjectURL(n);
15722
15733
  }
15723
15734
  function g5() {
15724
- const e = ce(), [t, n] = ve(!1), o = fe(null);
15735
+ const e = ce(), [t, n] = xe(!1), o = fe(null);
15725
15736
  se(() => {
15726
15737
  if (!t) return;
15727
15738
  const i = (a) => {
@@ -15734,17 +15745,17 @@ function g5() {
15734
15745
  };
15735
15746
  }, [t]);
15736
15747
  const r = (i) => () => {
15737
- var u, m, g, p;
15748
+ var u, h, g, m;
15738
15749
  n(!1);
15739
- const { internal: s, diagram: a, fileSession: l } = y.getState(), c = ((u = l == null ? void 0 : l.name) == null ? void 0 : u.replace(/\.json$/i, "")) ?? ((m = a.meta) == null ? void 0 : m.title) ?? "diagram", d = {
15750
+ const { internal: s, diagram: a, fileSession: l } = y.getState(), c = ((u = l == null ? void 0 : l.name) == null ? void 0 : u.replace(/\.json$/i, "")) ?? ((h = a.meta) == null ? void 0 : h.title) ?? "diagram", d = {
15740
15751
  title: (g = a.meta) == null ? void 0 : g.title,
15741
- labelMode: (p = a.meta) == null ? void 0 : p.labelMode,
15752
+ labelMode: (m = a.meta) == null ? void 0 : m.labelMode,
15742
15753
  annotations: a.annotations
15743
15754
  };
15744
- i === "svg" ? i5(s, `${c}.svg`, d) : i === "png" ? s5(s, `${c}.png`, { ...d, scale: 2 }).catch((h) => {
15745
- console.error(h), alert(e("topbar.export.pngFailed", { err: h.message }));
15746
- }) : LN(s, `${c}.dxf`, d).catch((h) => {
15747
- console.error(h), alert(e("topbar.export.dxfFailed", { err: h.message }));
15755
+ i === "svg" ? i5(s, `${c}.svg`, d) : i === "png" ? s5(s, `${c}.png`, { ...d, scale: 2 }).catch((p) => {
15756
+ console.error(p), alert(e("topbar.export.pngFailed", { err: p.message }));
15757
+ }) : LN(s, `${c}.dxf`, d).catch((p) => {
15758
+ console.error(p), alert(e("topbar.export.dxfFailed", { err: p.message }));
15748
15759
  });
15749
15760
  };
15750
15761
  return /* @__PURE__ */ C("div", { ref: o, className: "relative", children: [