sldeditor 0.10.1 → 0.10.2

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
@@ -3,7 +3,7 @@ var nv = (e, t, n) => t in e ? tv(e, t, { enumerable: !0, configurable: !0, writ
3
3
  var wt = (e, t, n) => nv(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as L, jsx as m, Fragment as et } from "react/jsx-runtime";
5
5
  import * as Se from "react";
6
- import Bt, { forwardRef as Rr, createElement as zn, useState as we, useRef as ge, useCallback as Kt, useMemo as Fr, useLayoutEffect as sn, useEffect as ae, createContext as Hr, useContext as Wr, useId as ov, cloneElement as rv, Fragment as iv } from "react";
6
+ import Lt, { forwardRef as Rr, createElement as zn, useState as we, useRef as ge, useCallback as Vt, useMemo as Fr, useLayoutEffect as sn, useEffect as ae, createContext as Hr, useContext as Wr, useId as ov, cloneElement as rv, Fragment as iv } from "react";
7
7
  import { createPortal as qr } from "react-dom";
8
8
  /**
9
9
  * @license lucide-react v0.469.0 - ISC
@@ -289,7 +289,7 @@ const yv = re("Hand", [
289
289
  * This source code is licensed under the ISC license.
290
290
  * See the LICENSE file in the root directory of this source tree.
291
291
  */
292
- const Vt = re("LayoutGrid", [
292
+ const Ut = re("LayoutGrid", [
293
293
  ["rect", { width: "7", height: "7", x: "3", y: "3", rx: "1", key: "1g98yp" }],
294
294
  ["rect", { width: "7", height: "7", x: "14", y: "3", rx: "1", key: "6d4xhi" }],
295
295
  ["rect", { width: "7", height: "7", x: "14", y: "14", rx: "1", key: "nxv5o0" }],
@@ -2818,7 +2818,7 @@ function o2() {
2818
2818
  throw new Error("useContextMenu must be used inside <ContextMenuHost>");
2819
2819
  return e;
2820
2820
  }
2821
- const Lt = 8;
2821
+ const zt = 8;
2822
2822
  function r2({ children: e }) {
2823
2823
  const [t, n] = we({
2824
2824
  open: !1,
@@ -2827,9 +2827,9 @@ function r2({ children: e }) {
2827
2827
  items: []
2828
2828
  }), [o, r] = we(
2829
2829
  null
2830
- ), i = ge(null), s = Kt(() => {
2830
+ ), i = ge(null), s = Vt(() => {
2831
2831
  n((c) => c.open ? { ...c, open: !1 } : c);
2832
- }, []), a = Kt(
2832
+ }, []), a = Vt(
2833
2833
  (c, u, d) => {
2834
2834
  r(null), n({ open: !0, x: c, y: u, items: d });
2835
2835
  },
@@ -2839,7 +2839,7 @@ function r2({ children: e }) {
2839
2839
  if (!t.open || !i.current) return;
2840
2840
  const c = i.current.getBoundingClientRect();
2841
2841
  let u = t.x, d = t.y;
2842
- u + c.width > window.innerWidth - Lt && (u = Math.max(Lt, t.x - c.width)), d + c.height > window.innerHeight - Lt && (d = Math.max(Lt, t.y - c.height)), r({ left: u, top: d });
2842
+ u + c.width > window.innerWidth - zt && (u = Math.max(zt, t.x - c.width)), d + c.height > window.innerHeight - zt && (d = Math.max(zt, t.y - c.height)), r({ left: u, top: d });
2843
2843
  }, [t]), ae(() => {
2844
2844
  if (!t.open) return;
2845
2845
  const c = (p) => {
@@ -2919,12 +2919,12 @@ const Oo = (e) => {
2919
2919
  return a;
2920
2920
  }, i2 = ((e) => e ? Oo(e) : Oo), s2 = (e) => e;
2921
2921
  function a2(e, t = s2) {
2922
- const n = Bt.useSyncExternalStore(
2922
+ const n = Lt.useSyncExternalStore(
2923
2923
  e.subscribe,
2924
- Bt.useCallback(() => t(e.getState()), [e, t]),
2925
- Bt.useCallback(() => t(e.getInitialState()), [e, t])
2924
+ Lt.useCallback(() => t(e.getState()), [e, t]),
2925
+ Lt.useCallback(() => t(e.getInitialState()), [e, t])
2926
2926
  );
2927
- return Bt.useDebugValue(n), n;
2927
+ return Lt.useDebugValue(n), n;
2928
2928
  }
2929
2929
  const jo = (e) => {
2930
2930
  const t = i2(e), n = (o) => a2(t, o);
@@ -3536,7 +3536,7 @@ const f2 = {
3536
3536
  e: "w",
3537
3537
  w: "e"
3538
3538
  };
3539
- function Xt(e, t) {
3539
+ function Yt(e, t) {
3540
3540
  let n = t.mirror ? h2[e] : e;
3541
3541
  const o = t.rot / 90 | 0;
3542
3542
  for (let r = 0; r < o; r++) n = f2[n];
@@ -3593,11 +3593,11 @@ const Do = ["n", "e", "s", "w"], Ro = {
3593
3593
  e: "w",
3594
3594
  w: "e"
3595
3595
  };
3596
- function zt(e, t) {
3596
+ function Dt(e, t) {
3597
3597
  const n = Do.indexOf(e), r = ((Do.indexOf(t) - n) % 4 + 4) % 4;
3598
3598
  return [0, 90, 180, 270][r];
3599
3599
  }
3600
- const $n = 320, Dt = 220, kt = 260, Sn = 720, _t = 30, Fo = 30, Ye = 80, Ho = 10, p2 = 60, g2 = 520, y2 = 80, b2 = 80, Wo = 8, qo = /* @__PURE__ */ new Set(["source", "renewable"]);
3600
+ const $n = 320, Rt = 220, kt = 260, Sn = 720, _t = 30, Fo = 30, Ye = 80, Ho = 10, p2 = 60, g2 = 520, y2 = 80, b2 = 80, Wo = 8, qo = /* @__PURE__ */ new Set(["source", "renewable"]);
3601
3601
  function w2(e) {
3602
3602
  var _o, $o, So, No, Eo, Mo;
3603
3603
  const { elements: t, buses: n, junctions: o, wires: r, library: i, userLayout: s, userBusLayout: a } = e, l = new Map(s), c = new Map(a), u = /* @__PURE__ */ new Map(), d = new Set(s.keys()), f = new Set(a.keys()), p = /* @__PURE__ */ new Map();
@@ -3706,23 +3706,23 @@ function w2(e) {
3706
3706
  }
3707
3707
  for (const Me of ee) ke(Me);
3708
3708
  const Ee = ee.map((Me) => ue.get(Me));
3709
- ue.set(K, Ee.reduce((Me, jt) => Me + jt, 0) / Ee.length);
3709
+ ue.set(K, Ee.reduce((Me, Bt) => Me + Bt, 0) / Ee.length);
3710
3710
  };
3711
3711
  ke(H);
3712
3712
  for (const K of Q) {
3713
- const ee = ye($n + (ue.get(K) ?? 0) * 160), Ee = ye(Dt + (W.get(K) ?? 0) * 140);
3713
+ const ee = ye($n + (ue.get(K) ?? 0) * 160), Ee = ye(Rt + (W.get(K) ?? 0) * 140);
3714
3714
  if (k.has(K)) {
3715
3715
  u.set(K, [ee, Ee]);
3716
3716
  continue;
3717
3717
  }
3718
3718
  let Me = 0;
3719
- const jt = q.get(K) ?? null;
3720
- if (jt) {
3721
- const bt = D(K, jt);
3722
- bt && (Me = zt(bt.orientation, "n"));
3719
+ const Bt = q.get(K) ?? null;
3720
+ if (Bt) {
3721
+ const bt = D(K, Bt);
3722
+ bt && (Me = Dt(bt.orientation, "n"));
3723
3723
  } else {
3724
3724
  const bt = (Z.get(K) ?? [])[0], To = bt ? D(K, bt) : null;
3725
- To && (Me = zt(To.orientation, "s"));
3725
+ To && (Me = Dt(To.orientation, "s"));
3726
3726
  }
3727
3727
  l.set(K, { at: [ee, Ee], rot: Me, mirror: !1 }), d.add(K);
3728
3728
  }
@@ -4198,7 +4198,7 @@ function w2(e) {
4198
4198
  const Q = l.get(y.elementId), X = De(
4199
4199
  [C.x, C.y],
4200
4200
  Q
4201
- ), Y = Xt(
4201
+ ), Y = Yt(
4202
4202
  C.orientation,
4203
4203
  Q
4204
4204
  );
@@ -4242,7 +4242,7 @@ function w2(e) {
4242
4242
  const W = zo(D), Z = [
4243
4243
  A[0] + W[0] * _t,
4244
4244
  A[1] + W[1] * _t
4245
- ], Q = Ro[D], X = zt(q.orientation, Q), Y = De([q.x, q.y], {
4245
+ ], Q = Ro[D], X = Dt(q.orientation, Q), Y = De([q.x, q.y], {
4246
4246
  at: [0, 0],
4247
4247
  rot: X,
4248
4248
  mirror: !1
@@ -4256,7 +4256,7 @@ function w2(e) {
4256
4256
  const ke = `${B}.${ue.id}`;
4257
4257
  N.add(ke);
4258
4258
  const K = { at: U, rot: X, mirror: !1 };
4259
- A = De([ue.x, ue.y], K), D = Xt(ue.orientation, K), _ = ke;
4259
+ A = De([ue.x, ue.y], K), D = Yt(ue.orientation, K), _ = ke;
4260
4260
  }
4261
4261
  }, Ux = (y) => {
4262
4262
  if (l.has(y.elementId) || y.orientation !== "horizontal") return;
@@ -4278,25 +4278,25 @@ function w2(e) {
4278
4278
  mirror: !1
4279
4279
  });
4280
4280
  }, po = 100;
4281
- let Ot = Dt;
4281
+ let jt = Rt;
4282
4282
  for (let y = 0; y < ve.length; y++) {
4283
4283
  const v = ve[y], S = xe.get(v);
4284
4284
  let E;
4285
4285
  if (y === 0)
4286
- E = Dt;
4286
+ E = Rt;
4287
4287
  else {
4288
4288
  const _ = xe.get(ve[y - 1]);
4289
4289
  let A = 0;
4290
4290
  for (const D of _)
4291
4291
  for (const C of S)
4292
4292
  (No = de.get(D)) != null && No.get(C) && (A = Math.max(A, Ie(D, C)));
4293
- A === 0 && (A = kt), E = Ot + A;
4293
+ A === 0 && (A = kt), E = jt + A;
4294
4294
  }
4295
- Ot = E;
4295
+ jt = E;
4296
4296
  let N = $n;
4297
4297
  for (const _ of S) {
4298
4298
  if (c.has(_)) {
4299
- Ot = Math.max(Ot, c.get(_).at[1]);
4299
+ jt = Math.max(jt, c.get(_).at[1]);
4300
4300
  continue;
4301
4301
  }
4302
4302
  let A;
@@ -4384,7 +4384,7 @@ function w2(e) {
4384
4384
  mirror: !1
4385
4385
  }) : [0, 0];
4386
4386
  l.set(_, {
4387
- at: [ye(E - C[0]), ye(Dt - C[1])],
4387
+ at: [ye(E - C[0]), ye(Rt - C[1])],
4388
4388
  rot: 0,
4389
4389
  mirror: !1
4390
4390
  }), E += Math.max(Sn, N.length * Ye) + po;
@@ -4445,7 +4445,7 @@ function w2(e) {
4445
4445
  const B = De(
4446
4446
  [M.x, M.y],
4447
4447
  I
4448
- ), z = Xt(
4448
+ ), z = Yt(
4449
4449
  M.orientation,
4450
4450
  I
4451
4451
  ), H = zo(z), q = [-H[1], H[0]];
@@ -4457,7 +4457,7 @@ function w2(e) {
4457
4457
  for (let X = 0; X < E.length; X++) {
4458
4458
  const Y = E[X], U = W[X], ue = Q + U / 2;
4459
4459
  Q += U;
4460
- const ke = Ro[z], K = zt(
4460
+ const ke = Ro[z], K = Dt(
4461
4461
  Y.localTerm.orientation,
4462
4462
  ke
4463
4463
  ), ee = De(
@@ -4741,9 +4741,9 @@ function x2(e, t) {
4741
4741
  const { axis: f, at: p, span: h } = d.geometry, g = h / 2;
4742
4742
  let w;
4743
4743
  if (f === "x")
4744
- w = [Ut(u[0], p[0] - g, p[0] + g), p[1]];
4744
+ w = [Jt(u[0], p[0] - g, p[0] + g), p[1]];
4745
4745
  else {
4746
- const $ = Ut(u[1], p[1] - g, p[1] + g);
4746
+ const $ = Jt(u[1], p[1] - g, p[1] + g);
4747
4747
  w = [p[0], $];
4748
4748
  }
4749
4749
  return { wireId: e.id, path: Yo(u, w) };
@@ -4775,8 +4775,8 @@ function Xo(e, t, n) {
4775
4775
  if (!t) return [s[0], s[1]];
4776
4776
  const l = a / 2;
4777
4777
  if (i === "x")
4778
- return [Ut(t[0], s[0] - l, s[0] + l), s[1]];
4779
- const c = Ut(t[1], s[1] - l, s[1] + l);
4778
+ return [Jt(t[0], s[0] - l, s[0] + l), s[1]];
4779
+ const c = Jt(t[1], s[1] - l, s[1] + l);
4780
4780
  return [s[0], c];
4781
4781
  }
4782
4782
  const o = n.terminals.get(e);
@@ -4785,7 +4785,7 @@ function Xo(e, t, n) {
4785
4785
  function Yo(e, t) {
4786
4786
  return e[0] === t[0] || e[1] === t[1] ? [e, t] : [e, [e[0], t[1]], t];
4787
4787
  }
4788
- function Ut(e, t, n) {
4788
+ function Jt(e, t, n) {
4789
4789
  return e < t ? t : e > n ? n : e;
4790
4790
  }
4791
4791
  const gi = "ammeter", yi = "电流表 (A)", bi = "measurement", wi = "-22 -42 44 44", xi = 44, vi = 44, ki = '<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-15" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">A</text>', _i = [{ id: "t_top", x: 0, y: -40, orientation: "n" }], $i = { kind: "inline" }, v2 = {
@@ -7216,7 +7216,7 @@ function Ze(e) {
7216
7216
  if (!T) continue;
7217
7217
  const j = [];
7218
7218
  for (const R of x.libraryDef.terminals) {
7219
- const V = `${x.element.id}.${R.id}`, J = De([R.x, R.y], T), ne = Xt(R.orientation, T);
7219
+ const V = `${x.element.id}.${R.id}`, J = De([R.x, R.y], T), ne = Yt(R.orientation, T);
7220
7220
  t.terminals.set(V, {
7221
7221
  ref: V,
7222
7222
  elementId: x.element.id,
@@ -7343,7 +7343,7 @@ function ro(e) {
7343
7343
  ...(e.junctions ?? []).map((t) => t.id)
7344
7344
  ]);
7345
7345
  }
7346
- function Jt(e, t) {
7346
+ function Zt(e, t) {
7347
7347
  const n = R$[t] ?? t, o = ro(e);
7348
7348
  let r = 1;
7349
7349
  for (; o.has(`${n}${r}`); ) r++;
@@ -7587,7 +7587,7 @@ const b = an()(
7587
7587
  continue;
7588
7588
  }
7589
7589
  const g = r.layout.get(p);
7590
- g && (c[p] = Rt(g));
7590
+ g && (c[p] = Ft(g));
7591
7591
  }
7592
7592
  const u = {};
7593
7593
  for (const p of n) {
@@ -7613,7 +7613,7 @@ const b = an()(
7613
7613
  const i = o + 1, s = tr * i, a = tr * i, l = /* @__PURE__ */ new Map();
7614
7614
  let c = r;
7615
7615
  for (const d of n.elements) {
7616
- const f = Jt(c, d.kind);
7616
+ const f = Zt(c, d.kind);
7617
7617
  l.set(d.id, f), c = {
7618
7618
  ...c,
7619
7619
  elements: [...c.elements, { id: f, kind: d.kind }]
@@ -7733,7 +7733,7 @@ const b = an()(
7733
7733
  for (const l of o.elements) {
7734
7734
  if (r[l.id]) continue;
7735
7735
  const c = n.layout.get(l.id);
7736
- c && (i[l.id] = Rt(c));
7736
+ c && (i[l.id] = Ft(c));
7737
7737
  }
7738
7738
  const s = [];
7739
7739
  if ((o.buses ?? []).forEach((l, c) => {
@@ -7763,7 +7763,7 @@ const b = an()(
7763
7763
  } else {
7764
7764
  if (i[u]) continue;
7765
7765
  const d = o.layout.get(u);
7766
- d && (s[u] = Rt(d));
7766
+ d && (s[u] = Ft(d));
7767
7767
  }
7768
7768
  if (Object.keys(s).length === 0 && a.size === 0)
7769
7769
  return r;
@@ -7791,7 +7791,7 @@ const b = an()(
7791
7791
  a.set(u, d);
7792
7792
  continue;
7793
7793
  }
7794
- const f = o.layout.get(u), p = i[u] ?? (f ? Rt(f) : { at: [0, 0] });
7794
+ const f = o.layout.get(u), p = i[u] ?? (f ? Ft(f) : { at: [0, 0] });
7795
7795
  i[u] = {
7796
7796
  ...p,
7797
7797
  at: [p.at[0] + d[0], p.at[1] + d[1]]
@@ -7938,7 +7938,7 @@ const b = an()(
7938
7938
  addElement: (n, o, r) => {
7939
7939
  if (n === "busbar")
7940
7940
  return t().addBus(o, 320);
7941
- const i = Jt(t().diagram, n);
7941
+ const i = Zt(t().diagram, n);
7942
7942
  return t().dispatch((s) => {
7943
7943
  const a = { id: i, kind: n, ...r ?? {} };
7944
7944
  return {
@@ -8131,7 +8131,7 @@ function nr(e, t) {
8131
8131
  n.has(r.id) || (n.add(r.id), o.push(r));
8132
8132
  return o;
8133
8133
  }
8134
- function Rt(e) {
8134
+ function Ft(e) {
8135
8135
  return {
8136
8136
  at: [e.at[0], e.at[1]],
8137
8137
  ...e.rot ? { rot: e.rot } : {},
@@ -8152,14 +8152,14 @@ function or(e) {
8152
8152
  function tt() {
8153
8153
  return sx;
8154
8154
  }
8155
- const Zt = 10;
8155
+ const Qt = 10;
8156
8156
  function ax() {
8157
8157
  if (typeof document > "u") return !0;
8158
8158
  const e = document.querySelector(".ole-canvas-root");
8159
8159
  return !!e && !e.classList.contains("hide-grid");
8160
8160
  }
8161
8161
  function fe(e) {
8162
- return ax() ? Math.round(e / Zt) * Zt : e;
8162
+ return ax() ? Math.round(e / Qt) * Qt : e;
8163
8163
  }
8164
8164
  const G$ = 30, X$ = 144;
8165
8165
  function lx(e, t) {
@@ -8171,7 +8171,7 @@ function lx(e, t) {
8171
8171
  const g = cx(n), w = g ? [fe(t[0]) - g.x, fe(t[1]) - g.y] : [fe(t[0]), fe(t[1])];
8172
8172
  return { newElementId: o.addElement(e, w), attachedToBus: !1 };
8173
8173
  }
8174
- const { busId: s, busAt: a, axis: l } = i, c = K$(n, l), u = Jt(r, e), d = n.terminals.find((g) => g.id === c), f = l === "x" ? t[0] : a[0], p = l === "y" ? t[1] : a[1], h = d ? [fe(f) - d.x, fe(p) - d.y] : [fe(t[0]), fe(t[1])];
8174
+ const { busId: s, busAt: a, axis: l } = i, c = K$(n, l), u = Zt(r, e), d = n.terminals.find((g) => g.id === c), f = l === "x" ? t[0] : a[0], p = l === "y" ? t[1] : a[1], h = d ? [fe(f) - d.x, fe(p) - d.y] : [fe(t[0]), fe(t[1])];
8175
8175
  return o.dispatch((g) => {
8176
8176
  const w = { id: u, kind: e }, $ = { at: h }, k = `${u}.${c}`, x = {
8177
8177
  id: lt(s, k),
@@ -8264,7 +8264,7 @@ function U$(e, t, n) {
8264
8264
  const a = n[0] - s.world[0], l = n[1] - s.world[1], c = a * a + l * l <= X$, u = [fe(n[0]), fe(n[1])], d = ux(o, s, u), f = c ? s.world : u, p = [
8265
8265
  fe(f[0] - d.x),
8266
8266
  fe(f[1] - d.y)
8267
- ], h = Jt(i, e);
8267
+ ], h = Zt(i, e);
8268
8268
  return r.dispatch((g) => {
8269
8269
  const w = { id: h, kind: e }, $ = { at: p }, k = `${h}.${d.id}`, x = s.isBus && s.busId ? s.busId : t, T = {
8270
8270
  id: lt(x, k),
@@ -8278,7 +8278,7 @@ function U$(e, t, n) {
8278
8278
  };
8279
8279
  }), r.setSelection([h]), { newElementId: h, attachedToBus: s.isBus };
8280
8280
  }
8281
- const cn = 9, Qt = 7;
8281
+ const cn = 9, Ct = 7;
8282
8282
  function dn(e, t) {
8283
8283
  var i, s;
8284
8284
  const n = [], o = ((i = e.element.name) == null ? void 0 : i.trim()) || e.element.id;
@@ -8293,7 +8293,11 @@ function dn(e, t) {
8293
8293
  }
8294
8294
  function un(e) {
8295
8295
  const t = J$(e.viewBox);
8296
- return t ? { x: t.x + t.w + 2, y: t.y + 4, anchor: "start" } : { x: 0, y: 0, anchor: "start" };
8296
+ return t ? {
8297
+ x: t.x + t.w + 2,
8298
+ y: t.y + t.h / 2 + Ct / 3,
8299
+ anchor: "start"
8300
+ } : { x: 0, y: 0, anchor: "start" };
8297
8301
  }
8298
8302
  function mn(e, t) {
8299
8303
  let n = e.x, o = e.y;
@@ -8614,7 +8618,7 @@ function ir({
8614
8618
  }, l = (u) => {
8615
8619
  const d = s.current;
8616
8620
  if (!d || u.pointerId !== d.pointerId || !i) return;
8617
- const f = i.screenToSvg(u.clientX, u.clientY), p = r === "x" ? f[0] - d.startSvg[0] : f[1] - d.startSvg[1], h = ax() ? Math.round(p / Zt) * Zt : p, g = d.startSpan + (o === "end" ? h : -h);
8621
+ const f = i.screenToSvg(u.clientX, u.clientY), p = r === "x" ? f[0] - d.startSvg[0] : f[1] - d.startSvg[1], h = ax() ? Math.round(p / Qt) * Qt : p, g = d.startSpan + (o === "end" ? h : -h);
8618
8622
  if (g < oS) return;
8619
8623
  const w = r === "x" ? [d.startAt[0] + h / 2, d.startAt[1]] : [d.startAt[0], d.startAt[1] + h / 2];
8620
8624
  b.getState().updateBus(n, { span: g, at: w });
@@ -8906,7 +8910,7 @@ function dS() {
8906
8910
  )
8907
8911
  ] });
8908
8912
  }
8909
- const uS = 4, mS = 9, fS = 13, hS = -13, pS = 4.5, gS = 8;
8913
+ const uS = 2.5, mS = 9, fS = 13, hS = -13, pS = 4.5, gS = 8;
8910
8914
  function yS() {
8911
8915
  const e = b((a) => a.internal.junctions), t = b((a) => a.selection), n = b((a) => a.selectedNode), o = b((a) => a.internal.nodes), r = b((a) => a.internal.terminalToNode), i = new Set(t), s = /* @__PURE__ */ new Set();
8912
8916
  if (n) {
@@ -9029,7 +9033,7 @@ function xS() {
9029
9033
  }
9030
9034
  let fx = null;
9031
9035
  const qn = /* @__PURE__ */ new Set();
9032
- function Ft(e) {
9036
+ function Ht(e) {
9033
9037
  fx = e;
9034
9038
  for (const t of qn) t(e);
9035
9039
  }
@@ -9497,10 +9501,10 @@ function WS(e) {
9497
9501
  }, a = (d) => {
9498
9502
  var p, h;
9499
9503
  if (d === n) return;
9500
- n && ((p = t.querySelector(`[data-element-id="${Ht(n)}"]`)) == null || p.classList.remove(ar)), d && ((h = t.querySelector(`[data-element-id="${Ht(d)}"]`)) == null || h.classList.add(ar));
9504
+ n && ((p = t.querySelector(`[data-element-id="${Wt(n)}"]`)) == null || p.classList.remove(ar)), d && ((h = t.querySelector(`[data-element-id="${Wt(d)}"]`)) == null || h.classList.add(ar));
9501
9505
  const f = d ? Array.from(
9502
9506
  t.querySelectorAll(
9503
- `.ole-terminal[data-element-id="${Ht(d)}"]`
9507
+ `.ole-terminal[data-element-id="${Wt(d)}"]`
9504
9508
  )
9505
9509
  ) : [];
9506
9510
  s(r, f, FS), n = d, d ? t.setAttribute("data-hover-element", "") : t.removeAttribute("data-hover-element"), zS(d);
@@ -9508,7 +9512,7 @@ function WS(e) {
9508
9512
  if (d === o) return;
9509
9513
  const f = d ? Array.from(
9510
9514
  t.querySelectorAll(
9511
- `[data-node-id="${Ht(d)}"]`
9515
+ `[data-node-id="${Wt(d)}"]`
9512
9516
  )
9513
9517
  ) : [];
9514
9518
  s(i, f, HS), o = d, d ? t.setAttribute("data-hover-node", "") : t.removeAttribute("data-hover-node");
@@ -9525,7 +9529,7 @@ function WS(e) {
9525
9529
  };
9526
9530
  }, [e]);
9527
9531
  }
9528
- function Ht(e) {
9532
+ function Wt(e) {
9529
9533
  return e.replace(/(["\\])/g, "\\$1");
9530
9534
  }
9531
9535
  function qS(e, t) {
@@ -9547,7 +9551,7 @@ function qS(e, t) {
9547
9551
  const o = n.terminals.get(e);
9548
9552
  return o ? { ref: e, world: o.world, isBus: !1 } : null;
9549
9553
  }
9550
- const lr = 10, Wt = (e) => Math.round(e / lr) * lr, GS = 16;
9554
+ const lr = 10, qt = (e) => Math.round(e / lr) * lr, GS = 16;
9551
9555
  function gx(e, t) {
9552
9556
  let n = e[0], o = 1 / 0;
9553
9557
  for (let r = 0; r < e.length - 1; r++) {
@@ -9584,10 +9588,10 @@ function Tt(e, t, n) {
9584
9588
  a && (r = a.wireId, i = a.at);
9585
9589
  }
9586
9590
  if (r && i) {
9587
- const a = [Wt(i[0]), Wt(i[1])];
9591
+ const a = [qt(i[0]), qt(i[1])];
9588
9592
  return { spec: { onWire: r, at: a }, world: a, ref: null, isBus: !1, create: !0 };
9589
9593
  }
9590
- const s = [Wt(t[0]), Wt(t[1])];
9594
+ const s = [qt(t[0]), qt(t[1])];
9591
9595
  return { spec: { junctionAt: s }, world: s, ref: null, isBus: !1, create: !0 };
9592
9596
  }
9593
9597
  function At(e, t, n) {
@@ -9764,7 +9768,7 @@ const YS = {
9764
9768
  }
9765
9769
  if (Ce && e.pointerId === Ce.pointerId) {
9766
9770
  const n = t.viewport.screenToSvg(e.clientX, e.clientY);
9767
- Ft(dr(Ce.startSvg, n));
9771
+ Ht(dr(Ce.startSvg, n));
9768
9772
  return;
9769
9773
  }
9770
9774
  },
@@ -9829,7 +9833,7 @@ const YS = {
9829
9833
  } else
9830
9834
  b.getState().setSelection(r);
9831
9835
  }
9832
- Ft(null), Ce = null;
9836
+ Ht(null), Ce = null;
9833
9837
  }
9834
9838
  },
9835
9839
  onPointerCancel(e, t) {
@@ -9882,7 +9886,7 @@ const YS = {
9882
9886
  t.hostEl.releasePointerCapture(e.pointerId);
9883
9887
  } catch {
9884
9888
  }
9885
- Ft(null), Ce = null;
9889
+ Ht(null), Ce = null;
9886
9890
  }
9887
9891
  },
9888
9892
  onDoubleClick(e) {
@@ -9900,7 +9904,7 @@ const YS = {
9900
9904
  const t = b.getState();
9901
9905
  t.setWireFromTerminal(null), t.setWireDragFrom(null), t.setCursorSvg(null), Ke(null), Te = null;
9902
9906
  }
9903
- Ft(null);
9907
+ Ht(null);
9904
9908
  }
9905
9909
  };
9906
9910
  function dr(e, t) {
@@ -10511,7 +10515,7 @@ function w4() {
10511
10515
  };
10512
10516
  return u(r.getViewport()), r.subscribe(u);
10513
10517
  }, [r]);
10514
- const i = o2(), s = Kt(
10518
+ const i = o2(), s = Vt(
10515
10519
  (u, d, f) => {
10516
10520
  const p = b.getState(), h = p.activeTool;
10517
10521
  if (h === "wire" || h === "busbar" || h === "junction" || h === "place") {
@@ -11212,7 +11216,7 @@ function Sr(e) {
11212
11216
  } catch {
11213
11217
  }
11214
11218
  }
11215
- const Ct = an((e, t) => ({
11219
+ const Pt = an((e, t) => ({
11216
11220
  ...G4(),
11217
11221
  setOutlineOpen: (n) => {
11218
11222
  e({ outlineOpen: n }), Sr(t());
@@ -11220,7 +11224,7 @@ const Ct = an((e, t) => ({
11220
11224
  toggleOutline: () => {
11221
11225
  e((n) => ({ outlineOpen: !n.outlineOpen })), Sr(t());
11222
11226
  }
11223
- })), Yt = [0.1, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4, 6, 8], Sx = 0.1, Nx = 8, Ex = "ole-grid";
11227
+ })), Kt = [0.1, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4, 6, 8], Sx = 0.1, Nx = 8, Ex = "ole-grid";
11224
11228
  function X4() {
11225
11229
  try {
11226
11230
  const e = window.localStorage.getItem(Ex);
@@ -11254,7 +11258,7 @@ function so(e) {
11254
11258
  function V4() {
11255
11259
  const e = tt();
11256
11260
  if (!e) return;
11257
- const t = e.getViewport().scale, n = Yt.find((o) => o > t + 1e-6) ?? Nx;
11261
+ const t = e.getViewport().scale, n = Kt.find((o) => o > t + 1e-6) ?? Nx;
11258
11262
  so(n);
11259
11263
  }
11260
11264
  function U4() {
@@ -11262,9 +11266,9 @@ function U4() {
11262
11266
  if (!e) return;
11263
11267
  const t = e.getViewport().scale;
11264
11268
  let n = Sx;
11265
- for (let o = Yt.length - 1; o >= 0; o--)
11266
- if (Yt[o] < t - 1e-6) {
11267
- n = Yt[o];
11269
+ for (let o = Kt.length - 1; o >= 0; o--)
11270
+ if (Kt[o] < t - 1e-6) {
11271
+ n = Kt[o];
11268
11272
  break;
11269
11273
  }
11270
11274
  so(n);
@@ -11705,7 +11709,7 @@ function o6() {
11705
11709
  );
11706
11710
  }
11707
11711
  function r6({ stacked: e }) {
11708
- const t = le(), n = Ct((r) => r.outlineOpen), o = Ct((r) => r.toggleOutline);
11712
+ const t = le(), n = Pt((r) => r.outlineOpen), o = Pt((r) => r.toggleOutline);
11709
11713
  return /* @__PURE__ */ m(
11710
11714
  dt,
11711
11715
  {
@@ -11825,7 +11829,7 @@ function i6({ iconOnly: e }) {
11825
11829
  Pe,
11826
11830
  {
11827
11831
  onClick: i(() => b.getState().fillUnplacedAll()),
11828
- icon: /* @__PURE__ */ m(Vt, {}),
11832
+ icon: /* @__PURE__ */ m(Ut, {}),
11829
11833
  disabled: !r.hasGapsAll,
11830
11834
  children: t("layout.allFill")
11831
11835
  }
@@ -11834,7 +11838,7 @@ function i6({ iconOnly: e }) {
11834
11838
  Pe,
11835
11839
  {
11836
11840
  onClick: i(() => b.getState().fillUnplacedSelection()),
11837
- icon: /* @__PURE__ */ m(Vt, {}),
11841
+ icon: /* @__PURE__ */ m(Ut, {}),
11838
11842
  disabled: !r.hasSelection || !r.selectionHasGaps,
11839
11843
  children: t("layout.selFill")
11840
11844
  }
@@ -11934,7 +11938,7 @@ function s6({ stacked: e }) {
11934
11938
  Pe,
11935
11939
  {
11936
11940
  onClick: d(() => b.getState().fillUnplacedAll()),
11937
- icon: /* @__PURE__ */ m(Vt, {}),
11941
+ icon: /* @__PURE__ */ m(Ut, {}),
11938
11942
  disabled: !u.hasGapsAll,
11939
11943
  children: t("layout.allFill")
11940
11944
  }
@@ -11943,7 +11947,7 @@ function s6({ stacked: e }) {
11943
11947
  Pe,
11944
11948
  {
11945
11949
  onClick: d(() => b.getState().fillUnplacedSelection()),
11946
- icon: /* @__PURE__ */ m(Vt, {}),
11950
+ icon: /* @__PURE__ */ m(Ut, {}),
11947
11951
  disabled: !u.hasSelection || !u.selectionHasGaps,
11948
11952
  children: t("layout.selFill")
11949
11953
  }
@@ -11977,7 +11981,7 @@ function Pe({
11977
11981
  );
11978
11982
  }
11979
11983
  function a6() {
11980
- const e = Ct((r) => r.outlineOpen), t = Ct((r) => r.setOutlineOpen), n = Je();
11984
+ const e = Pt((r) => r.outlineOpen), t = Pt((r) => r.setOutlineOpen), n = Je();
11981
11985
  return Le(n, "dense") ? e ? /* @__PURE__ */ m(
11982
11986
  "div",
11983
11987
  {
@@ -12394,7 +12398,7 @@ const u6 = {
12394
12398
  function f6(e, t) {
12395
12399
  return Mr[e][t] ?? Mr.zh[t];
12396
12400
  }
12397
- function Pt() {
12401
+ function Ot() {
12398
12402
  const e = ln((t) => t.locale);
12399
12403
  return (t, n) => f6(e, t) ?? n ?? t;
12400
12404
  }
@@ -12435,7 +12439,7 @@ function y6(e) {
12435
12439
  }
12436
12440
  }
12437
12441
  function b6() {
12438
- const e = le(), t = b((d) => d.activeTool === "place"), n = b((d) => d.placeKind), o = b((d) => d.setActiveTool), r = Ct((d) => d.outlineOpen), i = Je(), s = Le(i, "dense"), a = 68, c = s ? void 0 : `calc(100vh - ${a}px - ${r ? "calc(40vh + 20px)" : "68px"})`;
12442
+ const e = le(), t = b((d) => d.activeTool === "place"), n = b((d) => d.placeKind), o = b((d) => d.setActiveTool), r = Pt((d) => d.outlineOpen), i = Je(), s = Le(i, "dense"), a = 68, c = s ? void 0 : `calc(100vh - ${a}px - ${r ? "calc(40vh + 20px)" : "68px"})`;
12439
12443
  if (!t || s && n != null) return null;
12440
12444
  const u = s ? {
12441
12445
  top: `calc(${a}px + var(--ole-top-inset, 0px))`,
@@ -12478,7 +12482,7 @@ function b6() {
12478
12482
  );
12479
12483
  }
12480
12484
  function w6({ sheet: e }) {
12481
- const t = le(), n = Pt(), [o, r] = we(""), [i, s] = we(
12485
+ const t = le(), n = Ot(), [o, r] = we(""), [i, s] = we(
12482
12486
  () => g6()
12483
12487
  ), a = Fr(() => {
12484
12488
  const d = o.trim().toLowerCase();
@@ -12492,7 +12496,7 @@ function w6({ sheet: e }) {
12492
12496
  g.length && (f[p] = g);
12493
12497
  }
12494
12498
  return f;
12495
- }, [o, n]), l = o.trim().length > 0, c = l && Object.values(a).every((d) => !(d != null && d.length)), u = Kt((d, f) => {
12499
+ }, [o, n]), l = o.trim().length > 0, c = l && Object.values(a).every((d) => !(d != null && d.length)), u = Vt((d, f) => {
12496
12500
  s((p) => {
12497
12501
  const h = new Set(p);
12498
12502
  return f ? h.delete(d) : h.add(d), y6(h), h;
@@ -12564,7 +12568,7 @@ function v6({
12564
12568
  entry: e,
12565
12569
  sheet: t
12566
12570
  }) {
12567
- const n = le(), o = Pt(), r = o(`${e.id}.name`, e.name), i = o(`${e.id}.desc`, e.description ?? ""), s = b((d) => d.setActiveTool), a = b(
12571
+ const n = le(), o = Ot(), r = o(`${e.id}.name`, e.name), i = o(`${e.id}.desc`, e.description ?? ""), s = b((d) => d.setActiveTool), a = b(
12568
12572
  (d) => d.activeTool === "place" && d.placeKind === e.id
12569
12573
  ), l = b(
12570
12574
  (d) => t && d.activeTool === "place" && d.placeKind == null && d.lastPlaceKind === e.id
@@ -12808,7 +12812,7 @@ function E6({
12808
12812
  field: n
12809
12813
  }) {
12810
12814
  var l;
12811
- const o = le(), r = Pt(), i = ((l = t.params) == null ? void 0 : l[n.name]) ?? n.default, s = r(`${t.kind}.param.${n.name}`, n.label ?? n.name), a = (c) => {
12815
+ const o = le(), r = Ot(), i = ((l = t.params) == null ? void 0 : l[n.name]) ?? n.default, s = r(`${t.kind}.param.${n.name}`, n.label ?? n.name), a = (c) => {
12812
12816
  const u = { ...t.params ?? {} };
12813
12817
  c === void 0 || c === n.default ? delete u[n.name] : u[n.name] = c, b.getState().updateElement(e, {
12814
12818
  params: Object.keys(u).length > 0 ? u : void 0
@@ -13143,7 +13147,7 @@ function O6({
13143
13147
  field: n
13144
13148
  }) {
13145
13149
  var l;
13146
- const o = le(), i = Pt()(`${t.kind}.state.${n.name}`, n.label ?? n.name), s = ((l = t.state) == null ? void 0 : l[n.name]) ?? n.default, a = (c) => {
13150
+ const o = le(), i = Ot()(`${t.kind}.state.${n.name}`, n.label ?? n.name), s = ((l = t.state) == null ? void 0 : l[n.name]) ?? n.default, a = (c) => {
13147
13151
  const u = { ...t.state ?? {} };
13148
13152
  c === void 0 || c === n.default ? delete u[n.name] : u[n.name] = c, b.getState().updateElement(e, {
13149
13153
  state: Object.keys(u).length > 0 ? u : void 0
@@ -13166,7 +13170,7 @@ function O6({
13166
13170
  );
13167
13171
  }
13168
13172
  function j6() {
13169
- const e = le(), t = Pt(), n = b((d) => d.selection), o = b((d) => d.selectedNode), r = b((d) => d.selectedWire), i = b((d) => d.diagram.elements), s = b((d) => d.diagram.buses), a = Je(), l = Le(a, "dense");
13173
+ const e = le(), t = Ot(), n = b((d) => d.selection), o = b((d) => d.selectedNode), r = b((d) => d.selectedWire), i = b((d) => d.diagram.elements), s = b((d) => d.diagram.buses), a = Je(), l = Le(a, "dense");
13170
13174
  if (n.length === 0 && !o && !r) return null;
13171
13175
  let c = e("props.title"), u = null;
13172
13176
  if (r)
@@ -13404,16 +13408,16 @@ function v5() {
13404
13408
  className: "ole-glass absolute left-0 top-full mt-1.5 min-w-44 rounded-md border border-border p-1 shadow-md",
13405
13409
  children: [
13406
13410
  /* @__PURE__ */ m("div", { className: "border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground", children: n }),
13407
- /* @__PURE__ */ m(qt, { onClick: u(o), icon: /* @__PURE__ */ m(hv, {}), children: e("topbar.file.new") }),
13408
- /* @__PURE__ */ m(qt, { onClick: u(r), icon: /* @__PURE__ */ m(Ao, {}), hint: "⌘O", children: e("topbar.file.open") }),
13409
- /* @__PURE__ */ m(qt, { onClick: u(i), icon: /* @__PURE__ */ m(Io, {}), hint: "⌘S", children: e("topbar.file.save") }),
13410
- /* @__PURE__ */ m(qt, { onClick: u(s), icon: /* @__PURE__ */ m(Io, {}), hint: "⌘⇧S", children: e("topbar.file.saveAs") })
13411
+ /* @__PURE__ */ m(Gt, { onClick: u(o), icon: /* @__PURE__ */ m(hv, {}), children: e("topbar.file.new") }),
13412
+ /* @__PURE__ */ m(Gt, { onClick: u(r), icon: /* @__PURE__ */ m(Ao, {}), hint: "⌘O", children: e("topbar.file.open") }),
13413
+ /* @__PURE__ */ m(Gt, { onClick: u(i), icon: /* @__PURE__ */ m(Io, {}), hint: "⌘S", children: e("topbar.file.save") }),
13414
+ /* @__PURE__ */ m(Gt, { onClick: u(s), icon: /* @__PURE__ */ m(Io, {}), hint: "⌘⇧S", children: e("topbar.file.saveAs") })
13411
13415
  ]
13412
13416
  }
13413
13417
  )
13414
13418
  ] });
13415
13419
  }
13416
- function qt({
13420
+ function Gt({
13417
13421
  children: e,
13418
13422
  icon: t,
13419
13423
  hint: n,
@@ -13491,7 +13495,7 @@ function K6(e, t = {}) {
13491
13495
  const a = r.libraryDef.label ?? un(r.libraryDef), [l, c] = mn(a, i);
13492
13496
  for (let u = 0; u < s.length; u++) {
13493
13497
  const [d, f] = Be([l, c + u * cn]);
13494
- n.text(Pr, [d, f], s[u], Qt, 0, !1);
13498
+ n.text(Pr, [d, f], s[u], Ct, 0, !1);
13495
13499
  }
13496
13500
  }
13497
13501
  for (const r of t.annotations ?? []) {
@@ -13739,9 +13743,9 @@ ${this.fmt(n)}
13739
13743
  function zr(e) {
13740
13744
  return e.replace(/[\r\n]+/g, " ").slice(0, 250);
13741
13745
  }
13742
- const c5 = "http://www.w3.org/2000/svg", Gt = 24, Fx = 8, Hx = 1.25;
13746
+ const c5 = "http://www.w3.org/2000/svg", Xt = 24, Fx = 8, Hx = 1.25;
13743
13747
  function Wx(e, t = {}) {
13744
- const n = d5(e, t), o = Math.floor(n.minX - Gt), r = Math.floor(n.minY - Gt), i = Math.ceil(n.maxX + Gt) - o, s = Math.ceil(n.maxY + Gt) - r, a = t.background ?? "#FFFFFF", l = [];
13748
+ const n = d5(e, t), o = Math.floor(n.minX - Xt), r = Math.floor(n.minY - Xt), i = Math.ceil(n.maxX + Xt) - o, s = Math.ceil(n.maxY + Xt) - r, a = t.background ?? "#FFFFFF", l = [];
13745
13749
  l.push('<?xml version="1.0" encoding="UTF-8"?>'), l.push(
13746
13750
  `<svg xmlns="${c5}" viewBox="${o} ${r} ${i} ${s}" width="${i}" height="${s}">`
13747
13751
  ), t.title && l.push(` <title>${at(t.title)}</title>`), a !== "transparent" && l.push(
@@ -13774,7 +13778,7 @@ function Wx(e, t = {}) {
13774
13778
  if (c !== "off") {
13775
13779
  const d = a === "transparent" ? "#FFFFFF" : a;
13776
13780
  l.push(
13777
- ` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Qt}" paint-order="stroke" stroke="${d}" stroke-width="2" stroke-linejoin="round">`
13781
+ ` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Ct}" paint-order="stroke" stroke="${d}" stroke-width="2" stroke-linejoin="round">`
13778
13782
  );
13779
13783
  for (const f of e.elements.values()) {
13780
13784
  const p = e.layout.get(f.element.id);
@@ -13850,8 +13854,8 @@ function d5(e, t) {
13850
13854
  if (!c || !l.libraryDef) continue;
13851
13855
  const u = dn(l, a);
13852
13856
  if (u.length === 0) continue;
13853
- const d = l.libraryDef.label ?? un(l.libraryDef), [f, p] = mn(d, c), h = Dr(u, Qt), g = u.length * cn, w = d.anchor ?? "start", $ = w === "middle" ? f - h / 2 : w === "end" ? f - h : f;
13854
- s($, p - Qt), s($ + h, p + g);
13857
+ const d = l.libraryDef.label ?? un(l.libraryDef), [f, p] = mn(d, c), h = Dr(u, Ct), g = u.length * cn, w = d.anchor ?? "start", $ = w === "middle" ? f - h / 2 : w === "end" ? f - h : f;
13858
+ s($, p - Ct), s($ + h, p + g);
13855
13859
  }
13856
13860
  for (const l of t.annotations ?? []) {
13857
13861
  if (!l.text) continue;
@@ -14022,11 +14026,11 @@ export {
14022
14026
  w5 as getInitialTheme,
14023
14027
  L$ as getLibraryEntry,
14024
14028
  Zo as newBusId,
14025
- Jt as newElementId,
14029
+ Zt as newElementId,
14026
14030
  Qo as newJunctionId,
14027
14031
  zo as orientationVec,
14028
14032
  m2 as resolvePlacement,
14029
- Xt as transformOrientation,
14033
+ Yt as transformOrientation,
14030
14034
  De as transformPoint,
14031
14035
  b as useEditorStore,
14032
14036
  ln as useLocale,