sldeditor 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- "use strict";var o2=Object.defineProperty;var r2=(e,t,n)=>t in e?o2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>r2(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),M=require("react"),ks=require("react-dom");function s2(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const _e=s2(M);/**
1
+ "use strict";var $2=Object.defineProperty;var j2=(e,t,n)=>t in e?$2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var jt=(e,t,n)=>j2(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),C=require("react"),ks=require("react-dom");function E2(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Se=E2(C);/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const i2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_s=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
6
+ */const N2=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),_s=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim();/**
7
7
  * @license lucide-react v0.469.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */var a2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
11
+ */var A2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
12
12
  * @license lucide-react v0.469.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const l2=M.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>M.createElement("svg",{ref:l,...a2,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:_s("lucide",r),...a},[...i.map(([c,u])=>M.createElement(c,u)),...Array.isArray(s)?s:[s]]));/**
16
+ */const T2=C.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>C.createElement("svg",{ref:l,...A2,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:_s("lucide",r),...a},[...i.map(([c,u])=>C.createElement(c,u)),...Array.isArray(s)?s:[s]]));/**
17
17
  * @license lucide-react v0.469.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const se=(e,t)=>{const n=M.forwardRef(({className:o,...r},s)=>M.createElement(l2,{ref:s,iconNode:t,className:_s(`lucide-${i2(e)}`,o),...r}));return n.displayName=`${e}`,n};/**
21
+ */const se=(e,t)=>{const n=C.forwardRef(({className:o,...r},s)=>C.createElement(T2,{ref:s,iconNode:t,className:_s(`lucide-${N2(e)}`,o),...r}));return n.displayName=`${e}`,n};/**
22
22
  * @license lucide-react v0.469.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
@@ -28,17 +28,17 @@
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const c2=se("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
31
+ */const M2=se("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
32
32
  * @license lucide-react v0.469.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const d2=se("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
36
+ */const C2=se("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
37
37
  * @license lucide-react v0.469.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const u2=se("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
41
+ */const P2=se("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
42
42
  * @license lucide-react v0.469.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
@@ -53,7 +53,7 @@
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const f2=se("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
56
+ */const I2=se("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
57
57
  * @license lucide-react v0.469.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
@@ -63,22 +63,22 @@
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const h2=se("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/**
66
+ */const O2=se("FileBox",[["path",{d:"M14.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"16lz6z"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 13.1a2 2 0 0 0-1 1.76v3.24a2 2 0 0 0 .97 1.78L6 21.7a2 2 0 0 0 2.03.01L11 19.9a2 2 0 0 0 1-1.76V14.9a2 2 0 0 0-.97-1.78L8 11.3a2 2 0 0 0-2.03-.01Z",key:"99pj1s"}],["path",{d:"M7 17v5",key:"1yj1jh"}],["path",{d:"M11.7 14.2 7 17l-4.7-2.8",key:"1yk8tc"}]]);/**
67
67
  * @license lucide-react v0.469.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const m2=se("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
71
+ */const B2=se("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/**
72
72
  * @license lucide-react v0.469.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const p2=se("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
76
+ */const D2=se("FilePlus",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
77
77
  * @license lucide-react v0.469.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const g2=se("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
81
+ */const L2=se("FileType",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]]);/**
82
82
  * @license lucide-react v0.469.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
@@ -93,12 +93,12 @@
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const y2=se("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
96
+ */const z2=se("Grid2x2",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 12h18",key:"1i2n21"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]);/**
97
97
  * @license lucide-react v0.469.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
100
100
  * See the LICENSE file in the root directory of this source tree.
101
- */const x2=se("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
101
+ */const R2=se("Hand",[["path",{d:"M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",key:"1fvzgz"}],["path",{d:"M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",key:"1kc0my"}],["path",{d:"M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",key:"10h0bg"}],["path",{d:"M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",key:"1s1gnw"}]]);/**
102
102
  * @license lucide-react v0.469.0 - ISC
103
103
  *
104
104
  * This source code is licensed under the ISC license.
@@ -113,7 +113,7 @@
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const b2=se("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
116
+ */const F2=se("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
117
117
  * @license lucide-react v0.469.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
@@ -123,17 +123,17 @@
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const w2=se("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
126
+ */const H2=se("MousePointer2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);/**
127
127
  * @license lucide-react v0.469.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const v2=se("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/**
131
+ */const W2=se("PanelBottomClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]]);/**
132
132
  * @license lucide-react v0.469.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const k2=se("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
136
+ */const q2=se("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
137
137
  * @license lucide-react v0.469.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
@@ -158,7 +158,7 @@
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const _2=se("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
161
+ */const X2=se("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
162
162
  * @license lucide-react v0.469.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
@@ -168,27 +168,27 @@
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const S2=se("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/**
171
+ */const Y2=se("Slash",[["path",{d:"M22 2 2 22",key:"y4kqgn"}]]);/**
172
172
  * @license lucide-react v0.469.0 - ISC
173
173
  *
174
174
  * This source code is licensed under the ISC license.
175
175
  * See the LICENSE file in the root directory of this source tree.
176
- */const $2=se("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
176
+ */const G2=se("Spline",[["circle",{cx:"19",cy:"5",r:"2",key:"mhkx31"}],["circle",{cx:"5",cy:"19",r:"2",key:"v8kfzx"}],["path",{d:"M5 17A12 12 0 0 1 17 5",key:"1okkup"}]]);/**
177
177
  * @license lucide-react v0.469.0 - ISC
178
178
  *
179
179
  * This source code is licensed under the ISC license.
180
180
  * See the LICENSE file in the root directory of this source tree.
181
- */const j2=se("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/**
181
+ */const K2=se("SquareDashed",[["path",{d:"M5 3a2 2 0 0 0-2 2",key:"y57alp"}],["path",{d:"M19 3a2 2 0 0 1 2 2",key:"18rm91"}],["path",{d:"M21 19a2 2 0 0 1-2 2",key:"1j7049"}],["path",{d:"M5 21a2 2 0 0 1-2-2",key:"sbafld"}],["path",{d:"M9 3h1",key:"1yesri"}],["path",{d:"M9 21h1",key:"15o7lz"}],["path",{d:"M14 3h1",key:"1ec4yj"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"M3 9v1",key:"1r0deq"}],["path",{d:"M21 9v1",key:"mxsmne"}],["path",{d:"M3 14v1",key:"vnatye"}],["path",{d:"M21 14v1",key:"169vum"}]]);/**
182
182
  * @license lucide-react v0.469.0 - ISC
183
183
  *
184
184
  * This source code is licensed under the ISC license.
185
185
  * See the LICENSE file in the root directory of this source tree.
186
- */const E2=se("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
186
+ */const U2=se("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
187
187
  * @license lucide-react v0.469.0 - ISC
188
188
  *
189
189
  * This source code is licensed under the ISC license.
190
190
  * See the LICENSE file in the root directory of this source tree.
191
- */const N2=se("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
191
+ */const V2=se("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
192
192
  * @license lucide-react v0.469.0 - ISC
193
193
  *
194
194
  * This source code is licensed under the ISC license.
@@ -213,14 +213,14 @@
213
213
  *
214
214
  * This source code is licensed under the ISC license.
215
215
  * See the LICENSE file in the root directory of this source tree.
216
- */const Sn=se("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Is(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Is(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Os(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Is(e))&&(o&&(o+=" "),o+=t);return o}const No="-",A2=e=>{const t=M2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(No);return a[0]===""&&a.length!==1&&a.shift(),Bs(a,t)||T2(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Bs=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Bs(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(No);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},ir=/^\[(.+)\]$/,T2=e=>{if(ir.test(e)){const t=ir.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},M2=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return P2(Object.entries(e.classGroups),n).forEach(([s,i])=>{oo(i,o,s,t)}),o},oo=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:ar(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(C2(r)){oo(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{oo(i,ar(t,s),n,o)})})},ar=(e,t)=>{let n=e;return t.split(No).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},C2=e=>e.isThemeGetter,P2=(e,t)=>t?e.map(([n,o])=>{const r=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,a])=>[t+i,a])):s);return[n,r]}):e,I2=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return r(s,i),i},set(s,i){n.has(s)?n.set(s,i):r(s,i)}}},Ls="!",O2=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,u=0,f;for(let x=0;x<a.length;x++){let w=a[x];if(c===0){if(w===r&&(o||a.slice(x,x+s)===t)){l.push(a.slice(u,x)),u=x+s;continue}if(w==="/"){f=x;continue}}w==="["?c++:w==="]"&&c--}const m=l.length===0?a:a.substring(u),g=m.startsWith(Ls),p=g?m.substring(1):m,h=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:g,baseClassName:p,maybePostfixModifierPosition:h}};return n?a=>n({className:a,parseClassName:i}):i},B2=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},L2=e=>({cache:I2(e.cacheSize),parseClassName:O2(e),...A2(e)}),D2=/\s+/,z2=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(D2);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:m,maybePostfixModifierPosition:g}=n(c);let p=!!g,h=o(p?m.substring(0,g):m);if(!h){if(!p){a=c+(a.length>0?" "+a:a);continue}if(h=o(m),!h){a=c+(a.length>0?" "+a:a);continue}p=!1}const x=B2(u).join(":"),w=f?x+Ls:x,v=w+h;if(s.includes(v))continue;s.push(v);const C=r(h,p);for(let O=0;O<C.length;++O){const F=C[O];s.push(w+F)}a=c+(a.length>0?" "+a:a)}return a};function R2(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ds(t))&&(o&&(o+=" "),o+=n);return o}const Ds=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Ds(e[o]))&&(n&&(n+=" "),n+=t);return n};function F2(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((u,f)=>f(u),e());return n=L2(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const u=z2(l,n);return r(l,u),u}return function(){return s(R2.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},zs=/^\[(?:([a-z-]+):)?(.+)\]$/i,H2=/^\d+\/\d+$/,W2=new Set(["px","full","screen"]),q2=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,X2=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Y2=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,G2=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,K2=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Re=e=>mt(e)||W2.has(e)||H2.test(e),Je=e=>bt(e,"length",nk),mt=e=>!!e&&!Number.isNaN(Number(e)),zn=e=>bt(e,"number",mt),Et=e=>!!e&&Number.isInteger(Number(e)),U2=e=>e.endsWith("%")&&mt(e.slice(0,-1)),re=e=>zs.test(e),Ze=e=>q2.test(e),V2=new Set(["length","size","percentage"]),J2=e=>bt(e,V2,Rs),Z2=e=>bt(e,"position",Rs),Q2=new Set(["image","url"]),ek=e=>bt(e,Q2,rk),tk=e=>bt(e,"",ok),Nt=()=>!0,bt=(e,t,n)=>{const o=zs.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},nk=e=>X2.test(e)&&!Y2.test(e),Rs=()=>!1,ok=e=>G2.test(e),rk=e=>K2.test(e),sk=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),o=ge("brightness"),r=ge("borderColor"),s=ge("borderRadius"),i=ge("borderSpacing"),a=ge("borderWidth"),l=ge("contrast"),c=ge("grayscale"),u=ge("hueRotate"),f=ge("invert"),m=ge("gap"),g=ge("gradientColorStops"),p=ge("gradientColorStopPositions"),h=ge("inset"),x=ge("margin"),w=ge("opacity"),v=ge("padding"),C=ge("saturate"),O=ge("scale"),F=ge("sepia"),G=ge("skew"),$=ge("space"),H=ge("translate"),W=()=>["auto","contain","none"],X=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",re,t],R=()=>[re,t],Z=()=>["",Re,Je],ie=()=>["auto",mt,re],ue=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ee=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],be=()=>["","0",re],$e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Me=()=>[mt,re];return{cacheSize:500,separator:":",theme:{colors:[Nt],spacing:[Re,Je],blur:["none","",Ze,re],brightness:Me(),borderColor:[e],borderRadius:["none","","full",Ze,re],borderSpacing:R(),borderWidth:Z(),contrast:Me(),grayscale:be(),hueRotate:Me(),invert:be(),gap:R(),gradientColorStops:[e],gradientColorStopPositions:[U2,Je],inset:P(),margin:P(),opacity:Me(),padding:R(),saturate:Me(),scale:Me(),sepia:be(),skew:Me(),space:R(),translate:R()},classGroups:{aspect:[{aspect:["auto","square","video",re]}],container:["container"],columns:[{columns:[Ze]}],"break-after":[{"break-after":$e()}],"break-before":[{"break-before":$e()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ue(),re]}],overflow:[{overflow:X()}],"overflow-x":[{"overflow-x":X()}],"overflow-y":[{"overflow-y":X()}],overscroll:[{overscroll:W()}],"overscroll-x":[{"overscroll-x":W()}],"overscroll-y":[{"overscroll-y":W()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Et,re]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",re]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",Et,re]}],"grid-cols":[{"grid-cols":[Nt]}],"col-start-end":[{col:["auto",{span:["full",Et,re]},re]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[Nt]}],"row-start-end":[{row:["auto",{span:[Et,re]},re]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",re]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",re]}],gap:[{gap:[m]}],"gap-x":[{"gap-x":[m]}],"gap-y":[{"gap-y":[m]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",re,t]}],"min-w":[{"min-w":[re,t,"min","max","fit"]}],"max-w":[{"max-w":[re,t,"none","full","min","max","fit","prose",{screen:[Ze]},Ze]}],h:[{h:[re,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[re,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ze,Je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zn]}],"font-family":[{font:[Nt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",re]}],"line-clamp":[{"line-clamp":["none",mt,zn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Re,re]}],"list-image":[{"list-image":["none",re]}],"list-style-type":[{list:["none","disc","decimal",re]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Re,Je]}],"underline-offset":[{"underline-offset":["auto",Re,re]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ue(),Z2]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",J2]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},ek]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...ee(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[w]}],"divide-style":[{divide:ee()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...ee()]}],"outline-offset":[{"outline-offset":[Re,re]}],"outline-w":[{outline:[Re,Je]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[Re,Je]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ze,tk]}],"shadow-color":[{shadow:[Nt]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ze,re]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[C]}],sepia:[{sepia:[F]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[C]}],"backdrop-sepia":[{"backdrop-sepia":[F]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",re]}],duration:[{duration:Me()}],ease:[{ease:["linear","in","out","in-out",re]}],delay:[{delay:Me()}],animate:[{animate:["none","spin","ping","pulse","bounce",re]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[O]}],"scale-x":[{"scale-x":[O]}],"scale-y":[{"scale-y":[O]}],rotate:[{rotate:[Et,re]}],"translate-x":[{"translate-x":[H]}],"translate-y":[{"translate-y":[H]}],"skew-x":[{"skew-x":[G]}],"skew-y":[{"skew-y":[G]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",re]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",re]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",re]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Re,Je,zn]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},ik=F2(sk);function Se(...e){return ik(Os(e))}const Fs=M.createContext(null);function ak(){const e=M.useContext(Fs);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const en=8;function lk({children:e}){const[t,n]=M.useState({open:!1,x:0,y:0,items:[]}),[o,r]=M.useState(null),s=M.useRef(null),i=M.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=M.useCallback((c,u,f)=>{r(null),n({open:!0,x:c,y:u,items:f})},[]),l=M.useMemo(()=>({open:a,close:i}),[a,i]);return M.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+c.width>window.innerWidth-en&&(u=Math.max(en,t.x-c.width)),f+c.height>window.innerHeight-en&&(f=Math.max(en,t.y-c.height)),r({left:u,top:f})},[t]),M.useEffect(()=>{if(!t.open)return;const c=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},f=()=>i(),m=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",m),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",m)}},[t.open,i]),d.jsxs(Fs.Provider,{value:l,children:[e,t.open&&d.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:c=>c.preventDefault(),children:t.items.map((c,u)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:Se("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",c.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",c.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),c.onSelect()},children:[d.jsxs("span",{className:"flex items-center gap-2",children:[f?d.jsx(f,{className:"size-4"}):null,d.jsx("span",{children:c.label})]}),c.shortcut?d.jsx("span",{className:"text-xs text-muted-foreground",children:c.shortcut}):null]},`${c.label}-${u}`)})})]})}const lr=e=>{let t;const n=new Set,o=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const m=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,m))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,r,a);return a},ck=(e=>e?lr(e):lr),dk=e=>e;function uk(e,t=dk){const n=M.useSyncExternalStore(e.subscribe,M.useCallback(()=>t(e.getState()),[e,t]),M.useCallback(()=>t(e.getInitialState()),[e,t]));return M.useDebugValue(n),n}const cr=e=>{const t=ck(e),n=o=>uk(t,o);return Object.assign(n,t),n},$n=(e=>e?cr(e):cr),dr={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.junction":"接线柱","props.junctionPos":"位置","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.label":"标注","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","props.annText":"文字","props.annRect":"矩形","props.annLine":"线条","props.annTable":"表格","props.annNotFound":"标注 {id} 不存在","props.annLabel":"标签","props.annLabelPlaceholder":"如:1#配电柜","props.annStroke":"线型","props.annStrokeSolid":"实线","props.annStrokeDashed":"虚线","props.annFill":"填充","props.annFillNone":"无","props.annFillTint":"浅色","props.annArrow":"箭头","props.annArrowNone":"无","props.annArrowEnd":"单向","props.annArrowBoth":"双向","props.annFontSize":"字号","props.annRows":"行数","props.annCols":"列数","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从端子/母线/接线柱拖出;拖到空白处会自动新建接线柱,拖到已有连线上可打接点","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","tool.rect":"矩形","tool.rectHint":"拖动绘制矩形 / 分组框(默认虚线);按住 Shift 画正方形","tool.line":"线条","tool.lineHint":"拖动绘制标注线;按住 Shift 按 45° 约束;箭头在属性面板设置","tool.table":"表格","tool.tableHint":"拖动扫出行列(实时显示 列×行),或单击放置默认表格;双击单元格填写","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.rect":"拖动绘制矩形;Shift 正方形;释放后可拉伸并在属性面板加标签","mode.line":"拖动绘制线条;Shift 按 45° 约束;释放后可在属性面板加箭头","mode.table":"拖动扫出表格行列,或单击放置 3×3 表格;双击单元格填写内容","mode.annTextSel":"单击文字即可编辑 · 拖动移动 · Del 删除","mode.annTableSel":"单击单元格填写内容 · 拖动移动 · Del 删除","mode.annShapeSel":"拖动移动 · 拖动手柄缩放 · 右侧面板改样式 · Del 删除","mode.annEditing":"输入内容 · Enter 确认 · Esc 取消 · 或用 ✓ / ✕ 按钮","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.ariaEdit":"编辑操作","ctx.done":"完成","ctx.cancel":"取消","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"放一个器件","onboard.step1.body":"切到 元件 工具(P),从左侧元件库选一种拖到画布","onboard.step2.title":"拉线连接","onboard.step2.body":"用 连线 工具(W)从一个引脚拖到另一个引脚;拖到空白处会自动新建接线柱","onboard.step3.title":"母线是共用排,不是连线","onboard.step3.body":"几条回路共用一排时才用 母线 工具(B)。别拿母线连两个器件——点对点直接拉线(W)就行。","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.junction":"Junction","props.junctionPos":"Position","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.label":"Label","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","props.annText":"Text","props.annRect":"Rectangle","props.annLine":"Line","props.annTable":"Table","props.annNotFound":"Annotation {id} not found","props.annLabel":"Label","props.annLabelPlaceholder":"e.g. Panel #1","props.annStroke":"Stroke","props.annStrokeSolid":"Solid","props.annStrokeDashed":"Dashed","props.annFill":"Fill","props.annFillNone":"None","props.annFillTint":"Tint","props.annArrow":"Arrows","props.annArrowNone":"None","props.annArrowEnd":"End","props.annArrowBoth":"Both","props.annFontSize":"Font size","props.annRows":"Rows","props.annCols":"Columns","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","tool.rect":"Rectangle","tool.rectHint":"Drag to draw a rectangle / group frame (dashed by default); Shift for a square","tool.line":"Line","tool.lineHint":"Drag to draw an annotation line; Shift snaps to 45°; arrows live in the panel","tool.table":"Table","tool.tableHint":"Drag to sweep out cols × rows (live count), or click for a default table; double-click cells to type","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.junction":"Click the canvas to drop a junction","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.rect":"Drag to draw a rectangle · Shift for square · resize and label it after release","mode.line":"Drag to draw a line · Shift snaps to 45° · add arrows in the panel after release","mode.table":"Drag to sweep out the grid, or click for a 3×3 table · double-click cells to type","mode.annTextSel":"Click the text to edit · drag to move · Del to remove","mode.annTableSel":"Click a cell to fill it in · drag to move · Del to remove","mode.annShapeSel":"Drag to move · drag handles to resize · restyle in the panel · Del to remove","mode.annEditing":"Type · Enter to confirm · Esc to cancel · or the ✓ / ✕ buttons","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.ariaEdit":"Editing actions","ctx.done":"Done","ctx.cancel":"Cancel","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Place a component","onboard.step1.body":"Pick the Place tool (P) and drag a kind from the library onto the canvas","onboard.step2.title":"Wire it up","onboard.step2.body":"Use the Wire tool (W): drag from one pin to another — drag into empty space to drop a junction","onboard.step3.title":"A busbar is a shared rail, not a wire","onboard.step3.body":"Use the Busbar tool (B) only when several circuits share one rail. Don't use a bus to join two devices — just wire the pins (W).","onboard.dismiss":"Got it"}},Hs="ole-locale";function fk(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Hs);if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&typeof navigator.language=="string"?navigator.language.toLowerCase().startsWith("zh")?"zh":"en":"zh"}function ur(e){try{window.localStorage.setItem(Hs,e)}catch{}}const Yt=$n((e,t)=>({locale:fk(),setLocale:n=>{ur(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";ur(n),e({locale:n})}}));function Ws(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function qs(e,t){return dr[e][t]??dr.zh[t]??t}function ve(e,t){return Ws(qs(Yt.getState().locale,e),t)}function le(){const e=Yt(t=>t.locale);return(t,n)=>Ws(qs(e,t),n)}function Xs(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var s;const i=l=>l===null?null:JSON.parse(l,void 0),a=(s=n.getItem(r))!=null?s:null;return a instanceof Promise?a.then(i):i(a)},setItem:(r,s)=>n.setItem(r,JSON.stringify(s,void 0)),removeItem:r=>n.removeItem(r)}}const ro=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return ro(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return ro(o)(n)}}}},hk=(e,t)=>(n,o,r)=>{let s={storage:Xs(()=>window.localStorage),partialize:x=>x,version:0,merge:(x,w)=>({...w,...x}),...t},i=!1,a=0;const l=new Set,c=new Set;let u=s.storage;if(!u)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...x)},o,r);const f=()=>{const x=s.partialize({...o()});return u.setItem(s.name,{state:x,version:s.version})},m=r.setState;r.setState=(x,w)=>(m(x,w),f());const g=e((...x)=>(n(...x),f()),o,r);r.getInitialState=()=>g;let p;const h=()=>{var x,w;if(!u)return;const v=++a;i=!1,l.forEach(O=>{var F;return O((F=o())!=null?F:g)});const C=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(x=o())!=null?x:g))||void 0;return ro(u.getItem.bind(u))(s.name).then(O=>{if(O)if(typeof O.version=="number"&&O.version!==s.version){if(s.migrate){const F=s.migrate(O.state,O.version);return F instanceof Promise?F.then(G=>[!0,G]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,O.state];return[!1,void 0]}).then(O=>{var F;if(v!==a)return;const[G,$]=O;if(p=s.merge($,(F=o())!=null?F:g),n(p,!0),G)return f()}).then(()=>{v===a&&(C==null||C(o(),void 0),p=o(),i=!0,c.forEach(O=>O(p)))}).catch(O=>{v===a&&(C==null||C(void 0,O))})};return r.persist={setOptions:x=>{s={...s,...x},x.storage&&(u=x.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>h(),hasHydrated:()=>i,onHydrate:x=>(l.add(x),()=>{l.delete(x)}),onFinishHydration:x=>(c.add(x),()=>{c.delete(x)})},s.skipHydration||h(),p||g},mk=hk,Fe=.5;function Ys(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<Fe&&Math.abs(s[1]-e[r][1])<Fe||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],a=Math.abs(s[0]-i[0]),l=Math.abs(s[1]-i[1]);if(a>Fe&&l>Fe){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Fe?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<Fe&&Math.abs(i[0]-a[0])<Fe,c=Math.abs(s[1]-i[1])<Fe&&Math.abs(i[1]-a[1])<Fe;l||c||o.push(i)}return o.push(n[n.length-1]),o}function Gs(){return{elements:new Map,buses:new Map,junctions:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function Ks(e){return{at:(e==null?void 0:e.at)??[0,0],rot:(e==null?void 0:e.rot)??0,mirror:(e==null?void 0:e.mirror)??!1}}function so(e){return e===90||e===270?"y":"x"}function Ie(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const pk={n:"e",e:"s",s:"w",w:"n"},gk={n:"n",s:"s",e:"w",w:"e"};function Ot(e,t){let n=t.mirror?gk[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=pk[n];return n}function io(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class Us{constructor(){jt(this,"parent",new Map);jt(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const fr=["n","e","s","w"],hr={n:"s",s:"n",e:"w",w:"e"};function tn(e,t){const n=fr.indexOf(e),r=((fr.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const Rn=320,nn=220,At=260,Fn=720,Tt=30,mr=30,Qe=80,pr=10,yk=60,xk=520,bk=80,wk=80,gr=8,yr=new Set(["source","renewable"]);function vk(e){var Jo,Zo,Qo,er,tr,nr;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),u=new Map,f=new Set(i.keys()),m=new Set(a.keys()),g=new Map;for(const b of t)g.set(b.id,b);const p=new Map;for(const b of n)p.set(b.id,b);const h=b=>{const k=g.get(b);if(k)return s.get(k.kind)},x=new Set(n.map(b=>b.id)),w=b=>x.has(b),v=new Set(o.map(b=>b.id)),C=new Set(o.filter(b=>{var k;return(k=b.layout)==null?void 0:k.at}).map(b=>b.id)),O=new Us;for(const b of r)O.add(b.ends[0]),O.add(b.ends[1]),O.union(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(k)for(const S of k.terminals)O.add(`${b.id}.${S.id}`)}for(const b of n)O.add(b.id);const F=[];for(const[,b]of O.groups())b.length>=2&&F.push(b);const G=new Map;for(const b of F)for(const k of b)G.set(k,[b]);const $=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of k){const E=b.filter(_=>_!==S),j=$.get(S)??[];j.push(...E),$.set(S,j)}}{const S=T=>g.has(T)&&!!h(T),E=T=>{if(w(T))return null;if(v.has(T))return T;const N=T.indexOf(".");return N>0?T.slice(0,N):null},j=new Map,_=new Set,A=(T,N)=>{j.has(T)||j.set(T,new Set),j.has(N)||j.set(N,new Set),T!==N&&(j.get(T).add(N),j.get(N).add(T))};for(const T of F){const N=[];let L=!1;for(const Y of T){if(w(Y)){L=!0;continue}const te=E(Y);te&&N.push(te)}const D=[...new Set(N)];for(const Y of D)j.has(Y)||j.set(Y,new Set),L&&_.add(Y);const q=D.filter(Y=>v.has(Y)),K=D.filter(Y=>!v.has(Y));if(q.length>0){for(const Y of q)for(const te of K)A(Y,te);for(let Y=0;Y<q.length;Y++)for(let te=Y+1;te<q.length;te++)A(q[Y],q[te])}else for(let Y=0;Y<K.length;Y++)for(let te=Y+1;te<K.length;te++)A(K[Y],K[te])}const z=(T,N)=>{const L=h(T);if(!L)return null;for(const D of L.terminals){const q=`${T}.${D.id}`;for(const K of G.get(q)??[])for(const Y of K)if(E(Y)===N)return D}return null},I=T=>{const N=J=>{var oe;return((oe=j.get(J))==null?void 0:oe.size)??0},L=J=>{var oe;return((oe=h(J))==null?void 0:oe.category)??""},D=J=>{const oe=L(J);return oe==="source"?0:oe==="renewable"?1:2+Math.min(N(J),9)/10},q=T.filter(S).sort((J,oe)=>D(J)-D(oe)||J.localeCompare(oe))[0];if(!q)return;const K=new Map([[q,null]]),Y=new Map([[q,0]]),te=new Map,ne=[],U=[q],V=new Set([q]);for(;U.length;){const J=U.shift();ne.push(J);for(const oe of[...j.get(J)??[]].sort((je,Ee)=>je.localeCompare(Ee)))V.has(oe)||(V.add(oe),K.set(oe,J),Y.set(oe,(Y.get(J)??0)+1),te.has(J)||te.set(J,[]),te.get(J).push(oe),U.push(oe))}let Q=0;const fe=new Map,we=J=>{const oe=te.get(J)??[];if(oe.length===0){fe.set(J,Q++);return}for(const Ee of oe)we(Ee);const je=oe.map(Ee=>fe.get(Ee));fe.set(J,je.reduce((Ee,Qt)=>Ee+Qt,0)/je.length)};we(q);for(const J of ne){const oe=xe(Rn+(fe.get(J)??0)*160),je=xe(nn+(Y.get(J)??0)*140);if(v.has(J)){u.set(J,[oe,je]);continue}let Ee=0;const Qt=K.get(J)??null;if(Qt){const $t=z(J,Qt);$t&&(Ee=tn($t.orientation,"n"))}else{const $t=(te.get(J)??[])[0],or=$t?z(J,$t):null;or&&(Ee=tn(or.orientation,"s"))}l.set(J,{at:[oe,je],rot:Ee,mirror:!1}),f.add(J)}},B=new Set;for(const T of j.keys()){if(B.has(T))continue;const N=[],L=[T];for(B.add(T);L.length;){const D=L.pop();N.push(D);for(const q of j.get(D)??[])B.has(q)||(B.add(q),L.push(q))}N.length<2||N.some(D=>_.has(D))||N.some(D=>l.has(D)||C.has(D))||N.some(S)&&I(N)}}const H=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of b){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=S.slice(E+1),A=H.get(j)??[];for(const z of k)A.some(I=>I.busId===z&&I.pin===_)||A.push({busId:z,pin:_});H.set(j,A)}}const W=[],X=new Set;for(const[b,k]of H)if(new Set(k.map(E=>E.busId)).size>=2){const E=((Zo=s.get(((Jo=g.get(b))==null?void 0:Jo.kind)??""))==null?void 0:Zo.category)==="transformer"?"vertical":"horizontal";W.push({elementId:b,attachments:k,orientation:E}),E==="vertical"&&X.add(b)}const P=new Map,R=(b,k)=>{b!==k&&(P.has(b)||P.set(b,new Set),P.has(k)||P.set(k,new Set),P.get(b).add(k),P.get(k).add(b))};for(const b of r)R(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(!k||k.terminals.length<2)continue;const S=k.terminals.map(E=>`${b.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)R(S[E],S[j])}for(const b of t){if(X.has(b.id))continue;const k=s.get(b.kind);if(!k||k.category!=="transformer"||k.terminals.length<2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1);E.set(A,new Set);const z=new Set(S.filter(T=>T!==_)),I=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.get(A).add(T);continue}const N=P.get(T);if(N)for(const L of N)I.has(L)||z.has(L)||(I.add(L),B.push(L))}}const j=new Set;for(const _ of E.values())for(const A of _)j.add(A);if(j.size>=2){const _=[];for(const[A,z]of E)for(const I of z)_.push({busId:I,pin:A});W.push({elementId:b.id,attachments:_,orientation:"vertical"}),X.add(b.id)}}const Z=(b,k)=>{var z;const S=h(k),E=S?S.terminals.map(I=>`${k}.${I.id}`):[],j=b,_=new Set([j,...E]),A=[j];for(;A.length>0;){const I=A.shift(),B=I.indexOf(".");if(B>0){const N=I.slice(0,B),L=g.get(N);if(L){const D=(z=s.get(L.kind))==null?void 0:z.category;if(D&&yr.has(D))return!0}}const T=P.get(I);if(T)for(const N of T)_.has(N)||(_.add(N),A.push(N))}return!1};for(const b of W){if(b.orientation!=="horizontal")continue;const k=new Set(b.attachments.map(E=>E.busId));let S=0;for(const E of k)Z(E,b.elementId)&&S++;S===1&&(b.orientation="vertical",X.add(b.elementId))}for(const b of t){if(X.has(b.id)||b.kind!=="breaker")continue;const k=s.get(b.kind);if(!k||k.terminals.length!==2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1),z=new Set(S.filter(T=>T!==_)),I=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.set(A,T);break}const N=P.get(T);if(N)for(const L of N){if(I.has(L)||z.has(L))continue;const D=L.indexOf(".");if(D>0){const q=L.slice(0,D);if(q!==b.id){const K=g.get(q),Y=K?s.get(K.kind):void 0;if((Y==null?void 0:Y.category)==="transformer")continue}}I.add(L),B.push(L)}}}if(new Set(E.values()).size>=2){const _=[];for(const[A,z]of E)_.push({busId:z,pin:A});W.push({elementId:b.id,attachments:_,orientation:"horizontal"})}}const ie=new Map;for(const b of n)ie.set(b.id,new Map);for(const b of W){const k=Array.from(new Set(b.attachments.map(S=>S.busId)));for(const S of k)for(const E of k)S!==E&&((Qo=ie.get(S))==null||Qo.set(E,b))}const ue=b=>{var S;const k=(S=s.get(b))==null?void 0:S.category;return k?yr.has(k):!1},ee=[];for(const b of n){const k=$.get(b.id);if(k)for(const S of k){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=g.get(j);if(_&&ue(_.kind)){ee.push(b.id);break}}}ee.length===0&&n.length>0&&ee.push(n[0].id);const ae=new Map;for(const b of ee)ae.set(b,0);{const b=[...ee];for(;b.length>0;){const k=b.shift(),S=ae.get(k),E=ie.get(k);if(E)for(const[j,_]of E){if(ae.has(j))continue;const A=_.orientation==="horizontal"?S:S+1;ae.set(j,A),b.push(j)}}}for(const b of n){if(ae.has(b.id))continue;const k=ae.size===0?-1:Math.max(...Array.from(ae.values()));ae.set(b.id,k+1)}const me=new Map;for(const b of n){const k=ae.get(b.id),S=me.get(k)??[];S.push(b.id),me.set(k,S)}const be=[...me.keys()].sort((b,k)=>b-k),$e=(b,k,S)=>{const E=`${b.elementId}.${S}`,j=k,_=h(b.elementId),A=new Set;if(_)for(const N of _.terminals)N.id!==S&&A.add(`${b.elementId}.${N.id}`);const z=new Set([E]),I=[{ref:E,dist:0}],B=new Map,T=(N,L,D,q)=>{z.add(N),B.set(N,L),I.push({ref:N,dist:q+D})};for(;I.length>0;){const{ref:N,dist:L}=I.shift();if(N===j){const Y=B.get(j);let te;if(Y){const ne=Y.indexOf(".");if(ne>0){const U=Y.slice(0,ne);U!==b.elementId&&(te=U)}}return{extent:L,head:te}}const D=N.indexOf(".");if(D<0)continue;const q=N.slice(0,D),K=N.slice(D+1);if(!w(q)&&!X.has(q)){const Y=h(q),te=Y==null?void 0:Y.terminals.find(ne=>ne.id===K);if(Y&&te)for(const ne of Y.terminals){if(ne.id===K)continue;const U=`${q}.${ne.id}`;z.has(U)||A.has(U)||T(U,N,Math.abs(te.y-ne.y),L)}}for(const Y of G.get(N)??[])for(const te of Y){if(te===N||z.has(te)||A.has(te))continue;const ne=w(N)||w(te);T(te,N,ne?mr:Tt,L)}}return{extent:0}},Me=(b,k)=>{var N,L,D;const S=(N=ie.get(b))==null?void 0:N.get(k);if(!S||S.orientation==="horizontal")return At;const E=h(S.elementId);if(!E)return At;const j=(L=S.attachments.find(q=>q.busId===b))==null?void 0:L.pin,_=(D=S.attachments.find(q=>q.busId===k))==null?void 0:D.pin;if(!j||!_)return At;const A=E.terminals.find(q=>q.id===j),z=E.terminals.find(q=>q.id===_);if(!A||!z)return At;const I=Math.abs(z.y-A.y),B=$e(S,b,j).extent,T=$e(S,k,_).extent;return B+I+T},Pn=new Map;for(const b of W){if(b.orientation!=="vertical")continue;const k=b.attachments.slice().sort((z,I)=>(ae.get(z.busId)??0)-(ae.get(I.busId)??0));if(k.length<2)continue;const S=k[0].busId,E=k[1].busId,j=k[0].pin,A=$e(b,S,j).head??b.elementId;Pn.set(A,{lowerBusId:E})}const Do=30,zo=b=>{const k=h(b);return Math.max((k==null?void 0:k.width)??Qe,Qe)},Gv=2,Ro=(b,k,S,E=0)=>{const j=h(k);let _=zo(k);if(j&&!S.has(k)&&E<Gv){S.add(k);let A=0;for(const z of j.terminals){const I=`${k}.${z.id}`;if(I!==b)for(const B of G.get(I)??[]){const T=new Set;let N=!1;for(const D of B){if(D===I)continue;if(w(D)){N=!0;continue}const q=D.indexOf(".");if(q<0)continue;const K=D.slice(0,q);K===k||S.has(K)||X.has(K)||T.add(K)}if(N||T.size===0)continue;let L=0;for(const D of T){const q=[...B].find(K=>K.indexOf(".")>0&&K.slice(0,K.indexOf("."))===D);L+=(q?Ro(q,D,S,E+1):zo(D))+Do}A=Math.max(A,L-Do)}}S.delete(k),_=Math.max(_,A)}return _},kt=320,dt=new Map,Fo=(b,k)=>{if(!X.has(b))return!1;const S=W.find(A=>A.elementId===b),E=S==null?void 0:S.attachments.find(A=>A.busId!==k);if(!E)return!1;const j=ae.get(k)??0;return(ae.get(E.busId)??0)<j},_t=(b,k,S)=>{const E=Pn.get(b);if(E){const _=dt.get(E.lowerBusId);if(_!==void 0)return Math.max(k,_+Qe)}let j=0;return S&&(j=Ro(S,b,new Set)),Math.max(k,Qe,j)},Ho=(b,k)=>{if(dt.has(b))return dt.get(b);if(k.has(b))return kt;k.add(b);const S=$.get(b)??[];let E=0,j=0;for(const A of S){if(w(A))continue;const z=A.indexOf(".");if(z<0)continue;const I=A.slice(0,z),B=A.slice(z+1);if(Fo(I,b))continue;const T=h(I);if(!T)continue;const N=T.terminals.find(q=>q.id===B);if(!N)continue;const L=Pn.get(I);L&&Ho(L.lowerBusId,k);const D=_t(I,T.width,`${I}.${B}`);N.y>0?E+=D:j+=D}const _=Math.max(kt,Math.max(E,j)+Qe);return dt.set(b,_),k.delete(b),_};for(const b of n)Ho(b.id,new Set);const Ve=new Map,Kv=(b,k,S)=>{const E=h(k);if(!E)return;const j=`${k}.${S}`,_=E.terminals.filter(I=>I.id!==S).map(I=>`${k}.${I.id}`);if(_.length===0)return;const A=new Set([j,..._]),z=_.slice();for(;z.length>0;){const I=z.shift();if(w(I)&&I!==b){const T=c.get(I);return T?T.at[0]:void 0}for(const T of G.get(I)??[])for(const N of T)N===I||A.has(N)||(A.add(N),z.push(N));const B=I.indexOf(".");if(B>0){const T=I.slice(0,B);if(!w(T)){const N=h(T);if(N)for(const L of N.terminals){const D=`${T}.${L.id}`;A.has(D)||(A.add(D),z.push(D))}}}}},Uv=b=>{const k=$.get(b);if(!k||k.length===0)return;const S=c.get(b);if(!S)return;const E=k.flatMap(N=>{if(w(N))return[];const L=N.indexOf(".");if(L<0)return[];const D=N.slice(0,L),q=N.slice(L+1);if(l.has(D))return[];if(Fo(D,b))return[];const K=h(D);if(!K)return[];const Y=K.terminals.find(te=>te.id===q);return Y?[{elId:D,lib:K,localTerm:Y,isLinker:X.has(D),busFacingRef:`${D}.${q}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const A=N=>N.reduce((L,D)=>L+_t(D.elId,D.lib.width,D.busFacingRef),0),z=Math.max(A(j),A(_))+Qe,I=Math.max(S.span,z);I!==S.span&&!m.has(b)&&c.set(b,{...S,span:I});const B=c.get(b),T=(N,L)=>{if(N.length===0)return;const D=new Map;for(const V of N){const Q=Kv(b,V.elId,V.localTerm.id);Q!==void 0&&D.set(V.elId,Q)}N.sort((V,Q)=>{const fe=D.get(V.elId)??B.at[0],we=D.get(Q.elId)??B.at[0];if(fe!==we)return fe-we;const J=_t(V.elId,V.lib.width,V.busFacingRef);return _t(Q.elId,Q.lib.width,Q.busFacingRef)-J});const q=N.map(V=>_t(V.elId,V.lib.width,V.busFacingRef)),K=q.reduce((V,Q)=>V+Q,0),Y=Math.max(I,K),te=(Y-K)/(N.length+1);let ne=B.at[0]-Y/2+te;const U=B.at[1]+L*mr;for(let V=0;V<N.length;V++){const Q=N[V],fe=q[V],we=ne+fe/2;Q.isLinker?Ve.has(Q.elId)||Ve.set(Q.elId,we):l.set(Q.elId,{at:[xe(we-Q.localTerm.x),xe(U-Q.localTerm.y)],rot:0,mirror:!1}),ne+=fe+te}};T(j,-1),T(_,1)},Vv=b=>{if(l.has(b.elementId)||b.orientation==="horizontal")return;const k=h(b.elementId);if(!k)return;const S=b.attachments.filter(ne=>c.has(ne.busId));if(S.length<2)return;const E=S.slice().sort((ne,U)=>(ae.get(ne.busId)??0)-(ae.get(U.busId)??0)),j=E[0].busId,_=c.get(j),A=E[0].pin,z=E[E.length-1].pin,I=k.terminals.find(ne=>ne.id===A),B=k.terminals.find(ne=>ne.id===z);if(!I||!B)return;const T=I.y<=B.y?0:180,N=ae.get(j)??0,L=S.filter(ne=>(ae.get(ne.busId)??0)===N),D=[];let q=0;for(const ne of L){const U=$e(b,ne.busId,ne.pin);q=Math.max(q,U.extent);const V=U.head?l.get(U.head):void 0;V?D.push(V.at[0]):Ve.has(b.elementId)?D.push(Ve.get(b.elementId)):D.push(c.get(ne.busId).at[0])}let K;D.length>0?K=D.reduce((ne,U)=>ne+U,0)/D.length:Ve.has(b.elementId)?K=Ve.get(b.elementId):K=_.at[0];const Y=_.at[1]+q,te=T===0?[xe(K-I.x),xe(Y-I.y)]:[xe(K+I.x),xe(Y+I.y)];if(l.set(b.elementId,{at:te,rot:T,mirror:!1}),L.length>1){const ne=l.get(b.elementId),U=Ie([I.x,I.y],ne),V=Ot(I.orientation,ne);Jv(`${b.elementId}.${A}`,U,V,K)}},Jv=(b,k,S,E)=>{const j=new Set([b]);let _=b,A=k,z=S;for(;;){const I=G.get(_)??[];let B,T=!1;for(const oe of I){if(oe.length>=3){T=!0;break}const je=oe.find(Ee=>Ee!==_);if(!(!je||j.has(je))){if(w(je)){T=!0;break}B=je;break}}if(T||!B)break;const N=B.indexOf(".");if(N<0)break;const L=B.slice(0,N),D=B.slice(N+1);if(w(L)||X.has(L)||l.has(L))break;const q=h(L);if(!q)break;const K=q.terminals.find(oe=>oe.id===D);if(!K)break;const Y=io(z),te=[A[0]+Y[0]*Tt,A[1]+Y[1]*Tt],ne=hr[z],U=tn(K.orientation,ne),V=Ie([K.x,K.y],{at:[0,0],rot:U,mirror:!1}),Q=[xe(E-V[0]),xe(te[1]-V[1])];l.set(L,{at:Q,rot:U,mirror:!1}),j.add(B);const fe=q.terminals.find(oe=>oe.id!==D);if(!fe)break;const we=`${L}.${fe.id}`;j.add(we);const J={at:Q,rot:U,mirror:!1};A=Ie([fe.x,fe.y],J),z=Ot(fe.orientation,J),_=we}},Zv=b=>{if(l.has(b.elementId)||b.orientation!=="horizontal")return;const k=h(b.elementId);if(!k)return;const S=b.attachments.filter(L=>c.has(L.busId));if(S.length<2)return;const E=S.map(L=>{const D=$e(b,L.busId,L.pin),q=D.head?l.get(D.head):void 0,K=q?q.at[0]:c.get(L.busId).at[0];return{att:L,x:K,extent:D.extent}});E.sort((L,D)=>L.x-D.x);const j=E[0],_=E[E.length-1],A=k.terminals.find(L=>L.id===j.att.pin),z=k.terminals.find(L=>L.id===_.att.pin);if(!A||!z)return;const I=A.y<=z.y?270:90,B=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(b.elementId,{at:[xe(B),xe(N)],rot:I,mirror:!1})},Wo=100;let Zt=nn;for(let b=0;b<be.length;b++){const k=be[b],S=me.get(k);let E;if(b===0)E=nn;else{const _=me.get(be[b-1]);let A=0;for(const z of _)for(const I of S)(er=ie.get(z))!=null&&er.get(I)&&(A=Math.max(A,Me(z,I)));A===0&&(A=At),E=Zt+A}Zt=E;let j=Rn;for(const _ of S){if(c.has(_)){Zt=Math.max(Zt,c.get(_).at[1]);continue}let A;if(b>0){const I=me.get(be[b-1]),B=[];for(const T of I){const N=(tr=ie.get(T))==null?void 0:tr.get(_);if(!N||N.orientation!=="vertical")continue;const L=(nr=N.attachments.find(q=>q.busId===T))==null?void 0:nr.pin;if(!L)continue;const D=$e(N,T,L);D.head&&l.has(D.head)?B.push(l.get(D.head).at[0]):Ve.has(N.elementId)?B.push(Ve.get(N.elementId)):B.push(c.get(T).at[0])}B.length>0&&(A=B.reduce((T,N)=>T+N,0)/B.length)}if(A===void 0){const I=dt.get(_)??Fn;A=j+I/2,j+=I+Wo}const z=dt.get(_)??Fn;c.set(_,{at:[xe(A),xe(E)],rot:0,span:z,axis:so(0)})}for(const _ of S)Uv(_);if(b>0)for(const _ of W)l.has(_.elementId)||!_.attachments.some(z=>S.includes(z.busId))||Vv(_);for(const _ of W)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>S.includes(z.busId))||Zv(_)}if(n.length===0&&l.size<t.length){const b=j=>{const _=new Set,A=h(j);if(!A)return _;for(const z of A.terminals){const I=`${j}.${z.id}`;for(const B of G.get(I)??[])for(const T of B){if(T===I||w(T))continue;const N=T.indexOf(".");if(N<0)continue;const L=T.slice(0,N);L!==j&&_.add(L)}}return _},k=new Set,S=[];for(const j of t){if(k.has(j.id)||!h(j.id))continue;const _=[],A=[j.id];for(k.add(j.id);A.length>0;){const z=A.pop();_.push(z);for(const I of b(z))k.has(I)||(k.add(I),A.push(I))}_.length>=2&&S.push(_)}let E=Rn;for(const j of S){if(j.some(B=>l.has(B)))continue;j.sort((B,T)=>{var K,Y;const N=ue(((K=g.get(B))==null?void 0:K.kind)??"")?0:1,L=ue(((Y=g.get(T))==null?void 0:Y.kind)??"")?0:1;if(N!==L)return N-L;const D=b(B).size,q=b(T).size;return D!==q?D-q:B.localeCompare(T)});const _=j[0],A=h(_);if(!A)continue;const z=A.terminals.slice().sort((B,T)=>T.y-B.y)[0],I=z?Ie([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[xe(E-I[0]),xe(nn-I[1])],rot:0,mirror:!1}),E+=Math.max(Fn,j.length*Qe)+Wo}}const Qv=b=>{if(w(b))return c.has(b);const k=b.indexOf(".");return k<0?!1:l.has(b.slice(0,k))};let In=!0,e2=t.length+4;for(;In&&e2-- >0;){In=!1;for(const b of F){if(b.length<2)continue;const k=[],S=new Map;for(const U of b){if(w(U))continue;const V=U.indexOf(".");if(V<0)continue;const Q=U.slice(0,V),fe=U.slice(V+1);if(l.has(Q)){k.push(U);continue}if(X.has(Q)||S.has(Q))continue;const we=h(Q);if(!we)continue;const J=we.terminals.find(oe=>oe.id===fe);J&&S.set(Q,{ref:U,elId:Q,lib:we,localTerm:J})}if(S.size===0||k.length===0)continue;const E=[...S.values()],j=new Map;for(const U of E)for(const V of G.get(U.ref)??[])for(const Q of V){if(Q===U.ref||w(Q)||!Qv(Q))continue;const fe=Q;j.set(fe,(j.get(fe)??0)+1)}let _;if(j.size>0){let U=-1;for(const[V,Q]of j)(Q>U||Q===U&&(_===void 0||V<_))&&(U=Q,_=V)}if(_||(_=[...k].sort()[0]),!_)continue;const A=_.indexOf("."),z=_.slice(0,A),I=_.slice(A+1),B=h(z),T=l.get(z);if(!B||!T)continue;const N=B.terminals.find(U=>U.id===I);if(!N)continue;const L=Ie([N.x,N.y],T),D=Ot(N.orientation,T),q=io(D),K=[-q[1],q[0]];E.sort((U,V)=>U.elId.localeCompare(V.elId));const Y=E.map(U=>Math.max(U.lib.width,Qe));let ne=-Y.reduce((U,V)=>U+V,0)/2;for(let U=0;U<E.length;U++){const V=E[U],Q=Y[U],fe=ne+Q/2;ne+=Q;const we=hr[D],J=tn(V.localTerm.orientation,we),oe=Ie([V.localTerm.x,V.localTerm.y],{at:[0,0],rot:J,mirror:!1}),je=[L[0]+q[0]*Tt+K[0]*fe,L[1]+q[1]*Tt+K[1]*fe],Ee=[xe(je[0]-oe[0]),xe(je[1]-oe[1])];l.set(V.elId,{at:Ee,rot:J,mirror:!1}),In=!0}}}const St=b=>{const k=l.get(b),S=h(b);if(!k||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.width/2;return{min:k.at[0]-N,max:k.at[0]+N}}const[j,_,A,z]=E,I=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of I){const L=Ie(N,k);B=Math.min(B,L[0]),T=Math.max(T,L[0])}return{min:B,max:T}},On=b=>{const k=new Set,S=h(b);if(!S)return k;for(const E of S.terminals){const j=`${b}.${E.id}`;for(const _ of G.get(j)??[])for(const A of _){if(A===j||w(A))continue;const z=A.indexOf(".");if(z<0)continue;const I=A.slice(0,z);I!==b&&k.add(I)}}return k},qo=40,Bn=b=>{const k=l.get(b),S=h(b);if(!k||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.height/2;return{min:k.at[1]-N,max:k.at[1]+N}}const[j,_,A,z]=E,I=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of I){const L=Ie(N,k);B=Math.min(B,L[1]),T=Math.max(T,L[1])}return{min:B,max:T}},t2=(b,k)=>{const S=new Set,E=[];for(const j of $.get(b)??[]){if(w(j))continue;const _=j.indexOf(".");if(_<0)continue;const A=j.slice(0,_),z=l.get(A);!z||z.at[1]>=k-1||S.has(A)||(S.add(A),E.push(A))}for(;E.length>0;){const j=E.pop();for(const _ of On(j)){if(S.has(_))continue;const A=l.get(_);!A||A.at[1]>=k-1||(S.add(_),E.push(_))}}return S},Xo=(b,k,S)=>{const E=new Set([b]),j=[b];for(;j.length>0;){const _=j.pop();for(const A of On(_))A===k||E.has(A)||!S.has(A)||(E.add(A),j.push(A))}return E},Yo=(b,k)=>{let S=b.length*b.length+8,E=!1,j=!0;for(;j&&S-- >0;){j=!1;for(let _=0;_<b.length&&!j;_++)for(let A=_+1;A<b.length;A++){const z=b[_],I=b[A],B=St(z),T=St(I),N=Bn(z),L=Bn(I);if(!B||!T||!N||!L)continue;const D=Math.min(B.max,T.max)-Math.max(B.min,T.min),q=Math.min(N.max,L.max)-Math.max(N.min,L.min);if(D<=0||q<=0)continue;const K=Xo(z,I,k),Y=Xo(I,z,k);if(K.has(I)||Y.has(z))continue;const te=![...K].some(J=>f.has(J)),ne=![...Y].some(J=>f.has(J));if(!te&&!ne)continue;const U=(B.min+B.max)/2,V=(T.min+T.max)/2;let Q,fe;te&&(!ne||K.size<=Y.size)?(Q=K,fe=U<=V?-1:1):(Q=Y,fe=V<=U?-1:1);const we=xe(fe*(D+qo));if(we!==0){for(const J of Q){const oe=l.get(J);oe&&l.set(J,{...oe,at:[oe.at[0]+we,oe.at[1]]})}E=!0,j=!0;break}}}return E};for(const b of n){const k=c.get(b.id);if(!k)continue;const S=t2(b.id,k.at[1]);if(S.size<2)continue;const E=[...S];if(Yo(E,S)){let _=1/0,A=-1/0;for(const z of E){const I=St(z);I&&(_=Math.min(_,I.min),A=Math.max(A,I.max))}if(Number.isFinite(_)){const I=E.some(T=>f.has(T))?0:xe(k.at[0]-(_+A)/2);if(I!==0)for(const T of E){const N=l.get(T);N&&l.set(T,{...N,at:[N.at[0]+I,N.at[1]]})}const B=A-_+qo;if(B>k.span&&!m.has(b.id)){const T=c.get(b.id);c.set(b.id,{...T,span:B})}}}}const Go=()=>{const k=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:St(E),y:Bn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<k.length;E++)for(let j=E+1;j<k.length;j++){const _=Math.min(k[E].x.max,k[j].x.max)-Math.max(k[E].x.min,k[j].x.min),A=Math.min(k[E].y.max,k[j].y.max)-Math.max(k[E].y.min,k[j].y.min);_>1&&A>1&&S++}return S},n2=Go(),Ko=new Map;for(const[b,k]of l)Ko.set(b,{...k,at:[...k.at]});const Uo=new Map;for(const[b,k]of c)Uo.set(b,{...k,at:[...k.at]});const Ln=120,Vo=new Map;{const b=new Map,k=new Map,S=[];for(const j of n)for(const _ of $.get(j.id)??[]){if(w(_))continue;const A=_.indexOf(".");if(A<0)continue;const z=_.slice(0,A);l.has(z)&&S.push({el:z,bus:j.id,d:1})}S.sort((j,_)=>j.d-_.d);let E=0;for(;E<S.length;){const{el:j,bus:_,d:A}=S[E++],z=b.get(j);if(z===void 0)b.set(j,A),k.set(j,_);else if(A===z&&k.get(j)!==_){k.set(j,null);continue}else continue;for(const I of On(j))l.has(I)&&(b.has(I)||S.push({el:I,bus:_,d:A+1}))}for(const[j,_]of k)_&&Vo.set(j,_)}for(const b of be){const k=(me.get(b)??[]).filter(B=>c.has(B));if(k.length<2||k.some(B=>m.has(B)))continue;const S=[];let E=0;for(const B of k){const T=c.get(B),N=[];let L=1/0,D=-1/0;for(const[q,K]of Vo){if(K!==B)continue;const Y=St(q);Y&&(N.push(q),L=Math.min(L,Y.min),D=Math.max(D,Y.max))}Number.isFinite(L)||(L=T.at[0]-kt/2,D=T.at[0]+kt/2),S.push({busId:B,min:L,max:D,members:N}),E+=D-L}if(S.some(B=>B.members.some(T=>f.has(T))))continue;let j=1/0,_=-1/0;for(const B of S)j=Math.min(j,B.min),_=Math.max(_,B.max);const A=_-j,z=E+Ln*(S.length-1);if(!(A>z+Ln))continue;S.sort((B,T)=>(B.min+B.max)/2-(T.min+T.max)/2);let I=j;for(const B of S){const T=xe(I-B.min);if(T!==0){const N=c.get(B.busId);c.set(B.busId,{...N,at:[N.at[0]+T,N.at[1]]});for(const L of B.members){const D=l.get(L);D&&l.set(L,{...D,at:[D.at[0]+T,D.at[1]]})}B.min+=T,B.max+=T}I=B.max+Ln}for(const B of S){const T=c.get(B.busId),N=Math.max(kt,B.max-B.min);N<T.span&&c.set(B.busId,{...T,span:N})}}{const b=t.map(S=>S.id).filter(S=>l.has(S)),k=new Set(b);Yo(b,k)}if(Go()>n2){l.clear();for(const[b,k]of Ko)l.set(b,k);c.clear();for(const[b,k]of Uo)c.set(b,k)}let Dn=0;for(const b of t){if(l.has(b.id))continue;const k=Dn%gr,S=Math.floor(Dn/gr);l.set(b.id,{at:[xe(yk+k*bk),xe(xk+S*wk)],rot:0,mirror:!1}),Dn++}return{devices:l,buses:c,junctions:u}}function xe(e){return Math.round(e/pr)*pr}function kk(e,t){const n=e.ends[0],o=e.ends[1],r=xr(n,t),s=xr(o,t);if(r||s){const l=r?n:o,u=Hn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:m,at:g,span:p}=f.geometry,h=p/2;let x;if(m==="x")x=[gn(u[0],g[0]-h,g[0]+h),g[1]];else{const w=gn(u[1],g[1]-h,g[1]+h);x=[g[0],w]}return{wireId:e.id,path:wr(u,x)}}const i=Hn(n,t),a=Hn(o,t);return!i||!a?null:{wireId:e.id,path:wr(i,a)}}function xr(e,t){return!e.includes(".")&&t.buses.has(e)}function Hn(e,t){if(!e.includes(".")){const o=t.buses.get(e);if(o)return o.geometry.at;const r=t.junctions.get(e);return r?r.world:null}const n=t.terminals.get(e);return n?n.world:null}function br(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const u=n.junctions.get(e);return u?[u.world[0],u.world[1]]:null}const{axis:s,at:i,span:a}=r.geometry;if(!t)return[i[0],i[1]];const l=a/2;if(s==="x")return[gn(t[0],i[0]-l,i[0]+l),i[1]];const c=gn(t[1],i[1]-l,i[1]+l);return[i[0],c]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function wr(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function gn(e,t,n){return e<t?t:e>n?n:e}const Vs="ammeter",Js="电流表 (A)",Zs="measurement",Qs="-22 -42 44 44",ei=44,ti=44,ni='<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>',oi=[{id:"t_top",x:0,y:-40,orientation:"n"}],ri={kind:"inline"},_k={id:Vs,name:Js,category:Zs,viewBox:Qs,width:ei,height:ti,svg:ni,terminals:oi,source:ri},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:Zs,default:_k,height:ti,id:Vs,name:Js,source:ri,svg:ni,terminals:oi,viewBox:Qs,width:ei},Symbol.toStringTag,{value:"Module"})),si="arc-suppression-coil",ii="消弧线圈",ai="grounding",li="中性点谐振接地:电感线圈连接到地",ci="-12 -32 24 67",di=24,ui=67,fi='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',hi=[{id:"t_top",x:0,y:-30,orientation:"n"}],mi={kind:"inline"},$k={id:si,name:ii,category:ai,description:li,viewBox:ci,width:di,height:ui,svg:fi,terminals:hi,source:mi},jk=Object.freeze(Object.defineProperty({__proto__:null,category:ai,default:$k,description:li,height:ui,id:si,name:ii,source:mi,svg:fi,terminals:hi,viewBox:ci,width:di},Symbol.toStringTag,{value:"Module"})),pi="arrester",gi="避雷器 (FBL)",yi="protection",xi="-7 -22 14 44",bi=14,wi=44,vi='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',ki=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_i={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},Ek={id:pi,name:gi,category:yi,viewBox:xi,width:bi,height:wi,svg:vi,terminals:ki,source:_i},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:yi,default:Ek,height:wi,id:pi,name:gi,source:_i,svg:vi,terminals:ki,viewBox:xi,width:bi},Symbol.toStringTag,{value:"Module"})),Si="async-motor",$i="异步电动机",ji="load",Ei="-62 -82 64 84",Ni=64,Ai=84,Ti='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',Mi=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Ci={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},Ak={id:Si,name:$i,category:ji,viewBox:Ei,width:Ni,height:Ai,svg:Ti,terminals:Mi,source:Ci},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:ji,default:Ak,height:Ai,id:Si,name:$i,source:Ci,svg:Ti,terminals:Mi,viewBox:Ei,width:Ni},Symbol.toStringTag,{value:"Module"})),Pi="autotransformer",Ii="自耦变压器",Oi="transformer",Bi="-62 -112 64 144",Li=64,Di=144,zi='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-110" x2="-30" y2="-90" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -30 A 30 60 0 0 0 -30 -90" fill="none" stroke="black" stroke-width="1"/>',Ri=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Fi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},Mk={id:Pi,name:Ii,category:Oi,viewBox:Bi,width:Li,height:Di,svg:zi,terminals:Ri,source:Fi},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:Oi,default:Mk,height:Di,id:Pi,name:Ii,source:Fi,svg:zi,terminals:Ri,viewBox:Bi,width:Li},Symbol.toStringTag,{value:"Module"})),Hi="battery",Wi="电池储能",qi="storage",Xi="-12 -12 29 24",Yi=29,Gi=24,Ki='<line x1="-10" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-10" x2="5" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="0" x2="15" y2="0" fill="none" stroke="black" stroke-width="1"/>',Ui=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],Vi=[{name:"E",label:"容量",type:"number",unit:"kWh"}],Ji={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},Pk={id:Hi,name:Wi,category:qi,viewBox:Xi,width:Yi,height:Gi,svg:Ki,terminals:Ui,params:Vi,source:Ji},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:qi,default:Pk,height:Gi,id:Hi,name:Wi,params:Vi,source:Ji,svg:Ki,terminals:Ui,viewBox:Xi,width:Yi},Symbol.toStringTag,{value:"Module"})),Zi="bell",Qi="电铃 (HA)",ea="control",ta="信号电铃 / 警铃。",na="-32 -32 44 44",oa=44,ra=44,sa='<line x1="-30" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -10 A 20 20 0 0 0 -30 -10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',ia=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],aa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},Ok={id:Zi,name:Qi,category:ea,description:ta,viewBox:na,width:oa,height:ra,svg:sa,terminals:ia,source:aa},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:ea,default:Ok,description:ta,height:ra,id:Zi,name:Qi,source:aa,svg:sa,terminals:ia,viewBox:na,width:oa},Symbol.toStringTag,{value:"Module"})),la="break-contact",ca="常闭触点 (NC)",da="control",ua="常闭辅助触点 (break contact)。",fa="-2 -42 14 64",ha=14,ma=64,pa='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',ga=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ya=[{name:"open",type:"boolean",default:!1,label:"断开"}],xa={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},Lk={id:la,name:ca,category:da,description:ua,viewBox:fa,width:ha,height:ma,svg:pa,terminals:ga,state:ya,source:xa},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:da,default:Lk,description:ua,height:ma,id:la,name:ca,source:xa,state:ya,svg:pa,terminals:ga,viewBox:fa,width:ha},Symbol.toStringTag,{value:"Module"})),ba="breaker",wa="断路器 (QF)",va="switching",ka="-7 -22 15 46",_a=15,Sa=46,$a='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/>',ja='<text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',Ea=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Na=[{name:"open",type:"boolean",default:!1,label:"断开"}],Aa={x:6,y:-2,anchor:"start"},Ta={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},zk={id:ba,name:wa,category:va,viewBox:ka,width:_a,height:Sa,svg:$a,terminalLabelsSvg:ja,terminals:Ea,state:Na,label:Aa,source:Ta},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:va,default:zk,height:Sa,id:ba,label:Aa,name:wa,source:Ta,state:Na,svg:$a,terminalLabelsSvg:ja,terminals:Ea,viewBox:ka,width:_a},Symbol.toStringTag,{value:"Module"})),Ma="buchholz-relay",Ca="瓦斯继电器 (63)",Pa="protection",Ia="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Oa="-22 -62 44 64",Ba=44,La=64,Da='<rect x="-20" y="-60" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-20" width="10" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-55" x2="0" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -50 A 10 5 0 0 0 0 -40" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -40 A 10 5 0 0 0 0 -50" fill="none" stroke="black" stroke-width="1"/>',za=[{id:"t_top",x:0,y:-60,orientation:"n"}],Ra={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_18/en_60617_07_18_01.elmt",qetEnglishName:"Buchholz protective device; Gas relay"},Fk={id:Ma,name:Ca,category:Pa,description:Ia,viewBox:Oa,width:Ba,height:La,svg:Da,terminals:za,source:Ra},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:Fk,description:Ia,height:La,id:Ma,name:Ca,source:Ra,svg:Da,terminals:za,viewBox:Oa,width:Ba},Symbol.toStringTag,{value:"Module"})),Fa="busbar",Ha="母线段",Wa="busbar",qa="可拉伸单母线段,多设备挂接",Xa="-42 -4 84 8",Ya=84,Ga=8,Ka='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',Ua=[{id:"tap",x:0,y:0,orientation:"n"}],Va={axis:"x",minLength:20,naturalSpan:80},Ja=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],Za={x:0,y:-6,anchor:"middle"},Qa={kind:"inline"},Wk={id:Fa,name:Ha,category:Wa,description:qa,viewBox:Xa,width:Ya,height:Ga,svg:Ka,terminals:Ua,stretchable:Va,params:Ja,label:Za,source:Qa},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Wa,default:Wk,description:qa,height:Ga,id:Fa,label:Za,name:Ha,params:Ja,source:Qa,stretchable:Va,svg:Ka,terminals:Ua,viewBox:Xa,width:Ya},Symbol.toStringTag,{value:"Module"})),el="buzzer",tl="蜂鸣器 (HA)",nl="control",ol="信号蜂鸣器。",rl="-32 -52 44 64",sl=44,il=64,al='<line x1="-30" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><path d="M -30 -30 A 20 20 0 0 0 10 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-12" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-12" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',ll=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],cl={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},Xk={id:el,name:tl,category:nl,description:ol,viewBox:rl,width:sl,height:il,svg:al,terminals:ll,source:cl},Yk=Object.freeze(Object.defineProperty({__proto__:null,category:nl,default:Xk,description:ol,height:il,id:el,name:tl,source:cl,svg:al,terminals:ll,viewBox:rl,width:sl},Symbol.toStringTag,{value:"Module"})),dl="capacitor",ul="电容 (C)",fl="passive",hl="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",ml="-7 -23 14 27",pl=14,gl=27,yl='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',xl=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],bl=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],wl={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},Gk={id:dl,name:ul,category:fl,description:hl,viewBox:ml,width:pl,height:gl,svg:yl,terminals:xl,params:bl,source:wl},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:fl,default:Gk,description:hl,height:gl,id:dl,name:ul,params:bl,source:wl,svg:yl,terminals:xl,viewBox:ml,width:pl},Symbol.toStringTag,{value:"Module"})),vl="contactor",kl="接触器 (KM)",_l="motor-control",Sl="主回路接触器, 通常配热继电器和电机使用。",$l="-10 -42 15 64",jl=15,El=64,Nl='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',Al=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Tl=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ml={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_02.elmt",qetEnglishName:"Contactor; Main make contact of a contactor"},Uk={id:vl,name:kl,category:_l,description:Sl,viewBox:$l,width:jl,height:El,svg:Nl,terminals:Al,state:Tl,source:Ml},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:_l,default:Uk,description:Sl,height:El,id:vl,name:kl,source:Ml,state:Tl,svg:Nl,terminals:Al,viewBox:$l,width:jl},Symbol.toStringTag,{value:"Module"})),Cl="converter-bidir",Pl="双向变流器 (PCS)",Il="renewable",Ol="储能变流器:双向 AC ↔ DC",Bl="-42 -42 44 48",Ll=44,Dl=48,zl='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-6" x2="-14" y2="-6" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-6" x2="-4" y2="-6" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/><polyline points="-28,-4 -32,0 -28,4" fill="none" stroke="black" stroke-width="1"/><polyline points="-16,-4 -12,0 -16,4" fill="none" stroke="black" stroke-width="1"/>',Rl=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Fl=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Hl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},Jk={id:Cl,name:Pl,category:Il,description:Ol,viewBox:Bl,width:Ll,height:Dl,svg:zl,terminals:Rl,params:Fl,source:Hl},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:Il,default:Jk,description:Ol,height:Dl,id:Cl,name:Pl,params:Fl,source:Hl,svg:zl,terminals:Rl,viewBox:Bl,width:Ll},Symbol.toStringTag,{value:"Module"})),Wl="ct",ql="电流互感器 (CT)",Xl="instrument-transformer",Yl="-42 -62 54 64",Gl=54,Kl=64,Ul='<line x1="-30" y1="-60" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-30" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-20" x2="5" y2="-40" fill="none" stroke="black" stroke-width="1"/>',Vl=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Jl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},Qk={id:Wl,name:ql,category:Xl,viewBox:Yl,width:Gl,height:Kl,svg:Ul,terminals:Vl,source:Jl},e_=Object.freeze(Object.defineProperty({__proto__:null,category:Xl,default:Qk,height:Kl,id:Wl,name:ql,source:Jl,svg:Ul,terminals:Vl,viewBox:Yl,width:Gl},Symbol.toStringTag,{value:"Module"})),Zl="dc-combiner",Ql="直流汇流箱",ec="renewable",tc="光伏组串汇流箱 (4 路输入示例)。",nc="-27 -32 54 64",oc=54,rc=64,sc='<rect x="-25" y="-15" width="50" height="30" fill="none" stroke="black" stroke-width="1"/><line x1="-18" y1="-30" x2="-18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="-6" y1="-30" x2="-6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-30" x2="6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="18" y1="-30" x2="18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><text x="-9" y="5" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">DC</text>',ic=[{id:"t_s1",x:-18,y:-30,orientation:"n"},{id:"t_s2",x:-6,y:-30,orientation:"n"},{id:"t_s3",x:6,y:-30,orientation:"n"},{id:"t_s4",x:18,y:-30,orientation:"n"},{id:"t_dc",x:0,y:30,orientation:"s"}],ac={kind:"inline"},t_={id:Zl,name:Ql,category:ec,description:tc,viewBox:nc,width:oc,height:rc,svg:sc,terminals:ic,source:ac},n_=Object.freeze(Object.defineProperty({__proto__:null,category:ec,default:t_,description:tc,height:rc,id:Zl,name:Ql,source:ac,svg:sc,terminals:ic,viewBox:nc,width:oc},Symbol.toStringTag,{value:"Module"})),lc="dc-disconnector",cc="直流隔离开关",dc="switching",uc="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",fc="-12 -32 30 64",hc=30,mc=64,pc='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-4" x2="14" y2="-4" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-1" x2="9" y2="-1" stroke="black" stroke-width="0.8" fill="none"/><line x1="11" y1="-1" x2="14" y2="-1" stroke="black" stroke-width="0.8" fill="none"/>',gc=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],yc=[{name:"open",type:"boolean",default:!1,label:"断开"}],xc={kind:"inline"},o_={id:lc,name:cc,category:dc,description:uc,viewBox:fc,width:hc,height:mc,svg:pc,terminals:gc,state:yc,source:xc},r_=Object.freeze(Object.defineProperty({__proto__:null,category:dc,default:o_,description:uc,height:mc,id:lc,name:cc,source:xc,state:yc,svg:pc,terminals:gc,viewBox:fc,width:hc},Symbol.toStringTag,{value:"Module"})),bc="dc-motor",wc="直流电机 (M)",vc="load",kc="直流电动机 (串励通用符号)。",_c="-72 -82 89 84",Sc=89,$c=84,jc='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',Ec=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Nc={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},s_={id:bc,name:wc,category:vc,description:kc,viewBox:_c,width:Sc,height:$c,svg:jc,terminals:Ec,source:Nc},i_=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:s_,description:kc,height:$c,id:bc,name:wc,source:Nc,svg:jc,terminals:Ec,viewBox:_c,width:Sc},Symbol.toStringTag,{value:"Module"})),Ac="diode",Tc="二极管 (D)",Mc="passive",Cc="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Pc="-12 -42 24 44",Ic=24,Oc=44,Bc='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/>',Lc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Dc={x:6,y:-20,anchor:"start"},zc={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},a_={id:Ac,name:Tc,category:Mc,description:Cc,viewBox:Pc,width:Ic,height:Oc,svg:Bc,terminals:Lc,label:Dc,source:zc},l_=Object.freeze(Object.defineProperty({__proto__:null,category:Mc,default:a_,description:Cc,height:Oc,id:Ac,label:Dc,name:Tc,source:zc,svg:Bc,terminals:Lc,viewBox:Pc,width:Ic},Symbol.toStringTag,{value:"Module"})),Rc="disconnector",Fc="隔离开关 (QS)",Hc="switching",Wc="-10 -42 15 64",qc=15,Xc=64,Yc='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="-20" x2="3" y2="-20" fill="none" stroke="black" stroke-width="1"/>',Gc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Kc=[{name:"open",type:"boolean",default:!1,label:"断开"}],Uc={x:6,y:-10,anchor:"start"},Vc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},c_={id:Rc,name:Fc,category:Hc,viewBox:Wc,width:qc,height:Xc,svg:Yc,terminals:Gc,state:Kc,label:Uc,source:Vc},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Hc,default:c_,height:Xc,id:Rc,label:Uc,name:Fc,source:Vc,state:Kc,svg:Yc,terminals:Gc,viewBox:Wc,width:qc},Symbol.toStringTag,{value:"Module"})),Jc="distance-relay",Zc="距离继电器 (21)",Qc="protection",ed="距离 / 低阻抗保护继电器 (ANSI 21)。",td="-62 -42 64 44",nd=64,od=44,rd='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-42" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Z &lt;</text>',sd=[{id:"t_top",x:-30,y:-40,orientation:"n"}],id={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},u_={id:Jc,name:Zc,category:Qc,description:ed,viewBox:td,width:nd,height:od,svg:rd,terminals:sd,source:id},f_=Object.freeze(Object.defineProperty({__proto__:null,category:Qc,default:u_,description:ed,height:od,id:Jc,name:Zc,source:id,svg:rd,terminals:sd,viewBox:td,width:nd},Symbol.toStringTag,{value:"Module"})),ad="earth",ld="接地",cd="busbar",dd="-12 -17 24 34",ud=24,fd=34,hd='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',md=[{id:"t1",x:0,y:-15,orientation:"n"}],pd={kind:"elmt",path:"91_en_60617/en_60617_02/en_60617_02_15/en_60617_02_15_01.elmt",qetEnglishName:"Earth or ground, general symbol"},h_={id:ad,name:ld,category:cd,viewBox:dd,width:ud,height:fd,svg:hd,terminals:md,source:pd},m_=Object.freeze(Object.defineProperty({__proto__:null,category:cd,default:h_,height:fd,id:ad,name:ld,source:pd,svg:hd,terminals:md,viewBox:dd,width:ud},Symbol.toStringTag,{value:"Module"})),gd="earthing-switch",yd="接地刀闸 (QE)",xd="switching",bd="隔离开关 + 接地连接,单端口",wd="-12 -32 24 64",vd=24,kd=64,_d='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="-12" x2="-9" y2="9" stroke="black" stroke-width="1" fill="none"/><line x1="-3" y1="-12" x2="3" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-10" y1="14" x2="10" y2="14" stroke="black" stroke-width="1" fill="none"/><line x1="-7" y1="19" x2="7" y2="19" stroke="black" stroke-width="1" fill="none"/><line x1="-4" y1="24" x2="4" y2="24" stroke="black" stroke-width="1" fill="none"/><line x1="-1.5" y1="29" x2="1.5" y2="29" stroke="black" stroke-width="1" fill="none"/>',Sd=[{id:"t_top",x:0,y:-30,orientation:"n"}],$d=[{name:"open",type:"boolean",default:!0,label:"断开"}],jd={x:12,y:-8,anchor:"start"},Ed={kind:"inline"},p_={id:gd,name:yd,category:xd,description:bd,viewBox:wd,width:vd,height:kd,svg:_d,terminals:Sd,state:$d,label:jd,source:Ed},g_=Object.freeze(Object.defineProperty({__proto__:null,category:xd,default:p_,description:bd,height:kd,id:gd,label:jd,name:yd,source:Ed,state:$d,svg:_d,terminals:Sd,viewBox:wd,width:vd},Symbol.toStringTag,{value:"Module"})),Nd="energy-meter",Ad="电能表 (Wh)",Td="measurement",Md="有功电能表 (kWh) — 服务入口 / 子表。",Cd="-22 -36 44 72",Pd=44,Id=72,Od='<text x="-10" y="19.2" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Wh</text><rect x="-20" y="-10" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Bd=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Ld={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},y_={id:Nd,name:Ad,category:Td,description:Md,viewBox:Cd,width:Pd,height:Id,svg:Od,terminals:Bd,source:Ld},x_=Object.freeze(Object.defineProperty({__proto__:null,category:Td,default:y_,description:Md,height:Id,id:Nd,name:Ad,source:Ld,svg:Od,terminals:Bd,viewBox:Cd,width:Pd},Symbol.toStringTag,{value:"Module"})),Dd="ev-charger",zd="EV 充电桩",Rd="load",Fd="电动汽车充电站 / 充电桩。",Hd="-17 -27 34 49",Wd=34,qd=49,Xd='<line x1="0" y1="-25" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-15" y="-15" width="30" height="35" fill="none" stroke="black" stroke-width="1"/><rect x="-9" y="-8" width="14" height="6" fill="none" stroke="black" stroke-width="0.8"/><rect x="5" y="-7" width="2" height="4" fill="black"/><text x="-9" y="13" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">EV</text>',Yd=[{id:"t_top",x:0,y:-25,orientation:"n"}],Gd={kind:"inline"},b_={id:Dd,name:zd,category:Rd,description:Fd,viewBox:Hd,width:Wd,height:qd,svg:Xd,terminals:Yd,source:Gd},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Rd,default:b_,description:Fd,height:qd,id:Dd,name:zd,source:Gd,svg:Xd,terminals:Yd,viewBox:Hd,width:Wd},Symbol.toStringTag,{value:"Module"})),Kd="frequency-meter",Ud="频率表 (Hz)",Vd="measurement",Jd="-22 -42 44 44",Zd=44,Qd=44,eu='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Hz</text>',tu=[{id:"t_top",x:0,y:-40,orientation:"n"}],nu={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},v_={id:Kd,name:Ud,category:Vd,viewBox:Jd,width:Zd,height:Qd,svg:eu,terminals:tu,source:nu},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Vd,default:v_,height:Qd,id:Kd,name:Ud,source:nu,svg:eu,terminals:tu,viewBox:Jd,width:Zd},Symbol.toStringTag,{value:"Module"})),ou="fuse-switch-disconnector",ru="熔断器式隔离开关",su="switching",iu="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",au="-8 -32 12 64",lu=12,cu=64,du='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',uu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],fu=[{name:"open",type:"boolean",default:!1,label:"断开"}],hu={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},__={id:ou,name:ru,category:su,description:iu,viewBox:au,width:lu,height:cu,svg:du,terminals:uu,state:fu,source:hu},S_=Object.freeze(Object.defineProperty({__proto__:null,category:su,default:__,description:iu,height:cu,id:ou,name:ru,source:hu,state:fu,svg:du,terminals:uu,viewBox:au,width:lu},Symbol.toStringTag,{value:"Module"})),mu="fuse",pu="熔断器 (FU)",gu="switching",yu="-7 -32 14 64",xu=14,bu=64,wu='<line x1="0" y1="-30" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-15" width="10" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',vu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ku=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],_u={x:7,y:-2,anchor:"start"},Su={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},$_={id:mu,name:pu,category:gu,viewBox:yu,width:xu,height:bu,svg:wu,terminals:vu,state:ku,label:_u,source:Su},j_=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:$_,height:bu,id:mu,label:_u,name:pu,source:Su,state:ku,svg:wu,terminals:vu,viewBox:yu,width:xu},Symbol.toStringTag,{value:"Module"})),$u="generator",ju="发电机 (G)",Eu="source",Nu="-42 -42 44 44",Au=44,Tu=44,Mu='<rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-24" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text>',Cu=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Pu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},E_={id:$u,name:ju,category:Eu,viewBox:Nu,width:Au,height:Tu,svg:Mu,terminals:Cu,source:Pu},N_=Object.freeze(Object.defineProperty({__proto__:null,category:Eu,default:E_,height:Tu,id:$u,name:ju,source:Pu,svg:Mu,terminals:Cu,viewBox:Nu,width:Au},Symbol.toStringTag,{value:"Module"})),Iu="genset",Ou="发电机组 (G)",Bu="source",Lu="柴油 / 燃气发电机组。",Du="-28 -22 56 64",zu=56,Ru=64,Fu='<rect x="-26" y="-20" width="52" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">GEN</text><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Hu=[{id:"t_out",x:0,y:40,orientation:"s"}],Wu=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],qu={kind:"inline"},A_={id:Iu,name:Ou,category:Bu,description:Lu,viewBox:Du,width:zu,height:Ru,svg:Fu,terminals:Hu,params:Wu,source:qu},T_=Object.freeze(Object.defineProperty({__proto__:null,category:Bu,default:A_,description:Lu,height:Ru,id:Iu,name:Ou,params:Wu,source:qu,svg:Fu,terminals:Hu,viewBox:Du,width:zu},Symbol.toStringTag,{value:"Module"})),Xu="gfci-breaker",Yu="GFCI 断路器 (RCBO)",Gu="protection",Ku="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",Uu="-18 -22 22 44",Vu=22,Ju=44,Zu='<text x="-14" y="13.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">IΔ</text><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="-5,-10 0,10 0,20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-4" x2="-8" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="-4" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="-4" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><path d="M -8 1 A 2.5 3.5 0 0 0 -13 1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="1" x2="-2" y2="1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="1" x2="-13" y2="1" fill="none" stroke="black" stroke-width="0.4"/>',Qu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ef=[{name:"open",type:"boolean",default:!1,label:"断开"}],tf=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],nf={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},M_={id:Xu,name:Yu,category:Gu,description:Ku,viewBox:Uu,width:Vu,height:Ju,svg:Zu,terminals:Qu,state:ef,params:tf,source:nf},C_=Object.freeze(Object.defineProperty({__proto__:null,category:Gu,default:M_,description:Ku,height:Ju,id:Xu,name:Yu,params:tf,source:nf,state:ef,svg:Zu,terminals:Qu,viewBox:Uu,width:Vu},Symbol.toStringTag,{value:"Module"})),of="grid-source",rf="系统电源",sf="source",af="无穷大母线 / 外部电网",lf="-16 -31 32 53",cf=32,df=53,uf='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',ff=[{id:"t_bottom",x:0,y:20,orientation:"s"}],hf={kind:"inline"},P_={id:of,name:rf,category:sf,description:af,viewBox:lf,width:cf,height:df,svg:uf,terminals:ff,source:hf},I_=Object.freeze(Object.defineProperty({__proto__:null,category:sf,default:P_,description:af,height:df,id:of,name:rf,source:hf,svg:uf,terminals:ff,viewBox:lf,width:cf},Symbol.toStringTag,{value:"Module"})),mf="grounding-transformer",pf="接地变 (Z形)",gf="grounding",yf="星-曲折接线变压器,中性点接地用",xf="-62 -152 64 164",bf=64,wf=164,vf='<line x1="-30" y1="-40" x2="-35" y2="-35" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-25" y2="-35" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-35" x2="-40" y2="-38" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-150" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-35" x2="-25" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-30" y2="-45" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-45" x2="-25" y2="-48" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-130" x2="-20" y2="-140" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-135" x2="-20" y2="-145" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="5" x2="-20" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-85" x2="-30" y2="-95" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-20" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-40" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-40" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/>',kf=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],_f={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},O_={id:mf,name:pf,category:gf,description:yf,viewBox:xf,width:bf,height:wf,svg:vf,terminals:kf,source:_f},B_=Object.freeze(Object.defineProperty({__proto__:null,category:gf,default:O_,description:yf,height:wf,id:mf,name:pf,source:_f,svg:vf,terminals:kf,viewBox:xf,width:bf},Symbol.toStringTag,{value:"Module"})),Sf="heater",$f="电加热器 (EH)",jf="load",Ef="电阻加热元件 / 电热负荷。",Nf="-22 -7 54 14",Af=54,Tf=14,Mf='<line x1="-20" y1="0" x2="-10" y2="0" fill="none" stroke="black" stroke-width="1"/><rect x="-10" y="-5" width="30" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="0" x2="30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-5" x2="-5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-5" x2="5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="15" y1="-5" x2="15" y2="5" fill="none" stroke="black" stroke-width="1"/>',Cf=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Pf=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],If={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},L_={id:Sf,name:$f,category:jf,description:Ef,viewBox:Nf,width:Af,height:Tf,svg:Mf,terminals:Cf,params:Pf,source:If},D_=Object.freeze(Object.defineProperty({__proto__:null,category:jf,default:L_,description:Ef,height:Tf,id:Sf,name:$f,params:Pf,source:If,svg:Mf,terminals:Cf,viewBox:Nf,width:Af},Symbol.toStringTag,{value:"Module"})),Of="igbt",Bf="绝缘栅双极晶体管 (IGBT)",Lf="passive",Df="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",zf="-32 -32 54 74",Rf=54,Ff=74,Hf='<line x1="0" y1="25" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polyline points="-30,20 -5,20 -5,-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="20" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="20" y2="40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="15" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-25" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-8" x2="0" y2="8" fill="none" stroke="black" stroke-width="1"/><polyline points="10,-24 8,-21 12,-22" fill="none" stroke="black" stroke-width="1"/><polyline points="10,25 11,29 8,27" fill="none" stroke="black" stroke-width="1"/>',Wf=[{id:"t1",x:20,y:-30,orientation:"n"},{id:"t2",x:20,y:40,orientation:"s"},{id:"t_g",x:-30,y:20,orientation:"w"}],qf={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_05/en_60617_05_05_19.elmt",qetEnglishName:"Insulated-gate bipolar transistor (IGBT) enhancement type, N channel"},z_={id:Of,name:Bf,category:Lf,description:Df,viewBox:zf,width:Rf,height:Ff,svg:Hf,terminals:Wf,source:qf},R_=Object.freeze(Object.defineProperty({__proto__:null,category:Lf,default:z_,description:Df,height:Ff,id:Of,name:Bf,source:qf,svg:Hf,terminals:Wf,viewBox:zf,width:Rf},Symbol.toStringTag,{value:"Module"})),Xf="indicator-light",Yf="指示灯 (HL)",Gf="control",Kf="信号 / 状态指示灯。",Uf="-12 -22 24 24",Vf=24,Jf=24,Zf='<ellipse cx="0" cy="-10" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-3" x2="7" y2="-17" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-17" x2="7" y2="-3" fill="none" stroke="black" stroke-width="1"/>',Qf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],eh=[{name:"color",label:"颜色",type:"string"}],th={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},F_={id:Xf,name:Yf,category:Gf,description:Kf,viewBox:Uf,width:Vf,height:Jf,svg:Zf,terminals:Qf,params:eh,source:th},H_=Object.freeze(Object.defineProperty({__proto__:null,category:Gf,default:F_,description:Kf,height:Jf,id:Xf,name:Yf,params:eh,source:th,svg:Zf,terminals:Qf,viewBox:Uf,width:Vf},Symbol.toStringTag,{value:"Module"})),nh="inductor",oh="电感 (L)",rh="passive",sh="通用电感 / 线圈 / 扼流圈。",ih="-17 -32 34 64",ah=34,lh=64,ch='<line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><path d="M 0 15 A 15 15 0 1 0 -15 0" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',dh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],uh=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],fh={x:6,y:0,anchor:"start"},hh={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},W_={id:nh,name:oh,category:rh,description:sh,viewBox:ih,width:ah,height:lh,svg:ch,terminals:dh,params:uh,label:fh,source:hh},q_=Object.freeze(Object.defineProperty({__proto__:null,category:rh,default:W_,description:sh,height:lh,id:nh,label:fh,name:oh,params:uh,source:hh,svg:ch,terminals:dh,viewBox:ih,width:ah},Symbol.toStringTag,{value:"Module"})),mh="inverter",ph="逆变器 (DC→AC)",gh="renewable",yh="-42 -42 44 44",xh=44,bh=44,wh='<g transform="matrix(1 0 0 -1 0 -40)"><path d="M -15 -8 A 5 2.5 0 0 0 -25 -8" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><path d="M -15 -8 A 5 2.5 0 0 0 -5 -8" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/></g>',vh=[{id:"t_dc",x:-20,y:0,orientation:"s"},{id:"t_ac",x:-20,y:-40,orientation:"n"}],kh={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},X_={id:mh,name:ph,category:gh,viewBox:yh,width:xh,height:bh,svg:wh,terminals:vh,source:kh},Y_=Object.freeze(Object.defineProperty({__proto__:null,category:gh,default:X_,height:bh,id:mh,name:ph,source:kh,svg:wh,terminals:vh,viewBox:yh,width:xh},Symbol.toStringTag,{value:"Module"})),_h="limit-switch",Sh="限位开关 (SQ)",$h="control",jh="行程 / 位置开关 (常开, 机械操作)。",Eh="-10 -42 12 64",Nh=12,Ah=64,Th='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-13" x2="-7" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-12" x2="-3" y2="-8" fill="none" stroke="black" stroke-width="1"/>',Mh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ch=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Ph={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},G_={id:_h,name:Sh,category:$h,description:jh,viewBox:Eh,width:Nh,height:Ah,svg:Th,terminals:Mh,state:Ch,source:Ph},K_=Object.freeze(Object.defineProperty({__proto__:null,category:$h,default:G_,description:jh,height:Ah,id:_h,name:Sh,source:Ph,state:Ch,svg:Th,terminals:Mh,viewBox:Eh,width:Nh},Symbol.toStringTag,{value:"Module"})),Ih="load-switch",Oh="负荷开关",Bh="switching",Lh="-10 -42 14 64",Dh=14,zh=64,Rh='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',Fh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Hh=[{name:"open",type:"boolean",default:!1,label:"断开"}],Wh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},U_={id:Ih,name:Oh,category:Bh,viewBox:Lh,width:Dh,height:zh,svg:Rh,terminals:Fh,state:Hh,source:Wh},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Bh,default:U_,height:zh,id:Ih,name:Oh,source:Wh,state:Hh,svg:Rh,terminals:Fh,viewBox:Lh,width:Dh},Symbol.toStringTag,{value:"Module"})),qh="load",Xh="负荷",Yh="load",Gh="抽象负荷(电流流出箭头)",Kh="-8 -22 16 46",Uh=16,Vh=46,Jh='<line x1="0" y1="-20" x2="0" y2="10" stroke="black" stroke-width="1" fill="none"/><polygon points="-6,10 6,10 0,22" fill="black" stroke="black" stroke-width="1"/>',Zh=[{id:"t_top",x:0,y:-20,orientation:"n"}],Qh=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],em={x:6,y:0,anchor:"start"},tm={kind:"inline"},J_={id:qh,name:Xh,category:Yh,description:Gh,viewBox:Kh,width:Uh,height:Vh,svg:Jh,terminals:Zh,params:Qh,label:em,source:tm},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:Yh,default:J_,description:Gh,height:Vh,id:qh,label:em,name:Xh,params:Qh,source:tm,svg:Jh,terminals:Zh,viewBox:Kh,width:Uh},Symbol.toStringTag,{value:"Module"})),nm="make-contact",om="常开触点 (NO)",rm="control",sm="常开辅助触点 (make contact)。",im="-10 -42 12 64",am=12,lm=64,cm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',dm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],um=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],fm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_01.elmt",qetEnglishName:"Make contact, general symbol; Switch, general symbol"},Q_={id:nm,name:om,category:rm,description:sm,viewBox:im,width:am,height:lm,svg:cm,terminals:dm,state:um,source:fm},eS=Object.freeze(Object.defineProperty({__proto__:null,category:rm,default:Q_,description:sm,height:lm,id:nm,name:om,source:fm,state:um,svg:cm,terminals:dm,viewBox:im,width:am},Symbol.toStringTag,{value:"Module"})),hm="motor-starter",mm="电机启动器",pm="motor-control",gm="电机启动器 (IEC 60617 通用符号)。",ym="-22 -27 44 54",xm=44,bm=54,wm='<rect x="-20" y="-20" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,-20 0,-10 20,-20" fill="none" stroke="black" stroke-width="1"/>',vm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],km={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},tS={id:hm,name:mm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,source:km},nS=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:tS,description:gm,height:bm,id:hm,name:mm,source:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),_m="ngr",Sm="中性点电阻 (NGR)",$m="grounding",jm="小电阻接地:连接变压器中性点到地",Em="-12 -32 24 62",Nm=24,Am=62,Tm='<line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><rect x="-6" y="-15" width="12" height="22" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="7" x2="0" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="15" x2="10" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="19" x2="7" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="23" x2="4" y2="23" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="27" x2="1.5" y2="27" fill="none" stroke="black" stroke-width="1"/>',Mm=[{id:"t_top",x:0,y:-30,orientation:"n"}],Cm=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Pm={kind:"inline"},oS={id:_m,name:Sm,category:$m,description:jm,viewBox:Em,width:Nm,height:Am,svg:Tm,terminals:Mm,params:Cm,source:Pm},rS=Object.freeze(Object.defineProperty({__proto__:null,category:$m,default:oS,description:jm,height:Am,id:_m,name:Sm,params:Cm,source:Pm,svg:Tm,terminals:Mm,viewBox:Em,width:Nm},Symbol.toStringTag,{value:"Module"})),Im="overcurrent-relay",Om="过流继电器 (50/51)",Bm="protection",Lm="过电流保护继电器 (ANSI 50/51)。",Dm="-62 -62 64 64",zm=64,Rm=64,Fm='<rect x="-60" y="-60" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-48" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">5...10A</text>',Hm=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Wm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},sS={id:Im,name:Om,category:Bm,description:Lm,viewBox:Dm,width:zm,height:Rm,svg:Fm,terminals:Hm,source:Wm},iS=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:sS,description:Lm,height:Rm,id:Im,name:Om,source:Wm,svg:Fm,terminals:Hm,viewBox:Dm,width:zm},Symbol.toStringTag,{value:"Module"})),qm="panelboard",Xm="配电箱",Ym="load",Gm="配电箱 / 负荷中心(IEC 60617 分配中心符号):顶部进线,底部分路示意",Km="-52 -62 54 64",Um=54,Vm=64,Jm='<g transform="matrix(1 0 0 -1 0 -60)"><rect x="-50" y="-40" width="50" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-60" x2="-40" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-60" x2="-30" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-60" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-60" x2="-10" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-20" x2="-25" y2="0" fill="none" stroke="black" stroke-width="1"/></g>',Zm=[{id:"t_in",x:-25,y:-60,orientation:"n"}],Qm={kind:"elmt",path:"91_en_60617/en_60617_11/en_60617_11_12/en_60617_11_12_07.elmt",qetEnglishName:"Distribution centre"},aS={id:qm,name:Xm,category:Ym,description:Gm,viewBox:Km,width:Um,height:Vm,svg:Jm,terminals:Zm,source:Qm},lS=Object.freeze(Object.defineProperty({__proto__:null,category:Ym,default:aS,description:Gm,height:Vm,id:qm,name:Xm,source:Qm,svg:Jm,terminals:Zm,viewBox:Km,width:Um},Symbol.toStringTag,{value:"Module"})),ep="phase-failure-relay",tp="断相继电器",np="protection",op="断相 / 缺相保护继电器。",rp="-62 -42 64 44",sp=64,ip=44,ap='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">m &lt; 3</text>',lp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],cp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},cS={id:ep,name:tp,category:np,description:op,viewBox:rp,width:sp,height:ip,svg:ap,terminals:lp,source:cp},dS=Object.freeze(Object.defineProperty({__proto__:null,category:np,default:cS,description:op,height:ip,id:ep,name:tp,source:cp,svg:ap,terminals:lp,viewBox:rp,width:sp},Symbol.toStringTag,{value:"Module"})),dp="plc",up="PLC / 控制器",fp="control",hp="可编程逻辑控制器 (PLC)。",mp="-24 -42 48 84",pp=48,gp=84,yp='<rect x="-22" y="-22" width="44" height="44" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">PLC</text><line x1="0" y1="-40" x2="0" y2="-22" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="22" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',xp=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],bp={kind:"inline"},uS={id:dp,name:up,category:fp,description:hp,viewBox:mp,width:pp,height:gp,svg:yp,terminals:xp,source:bp},fS=Object.freeze(Object.defineProperty({__proto__:null,category:fp,default:uS,description:hp,height:gp,id:dp,name:up,source:bp,svg:yp,terminals:xp,viewBox:mp,width:pp},Symbol.toStringTag,{value:"Module"})),wp="power-factor-meter",vp="功率因数表 (cosφ)",kp="measurement",_p="功率因数表 (cosφ)。",Sp="-22 -42 44 44",$p=44,jp=44,Ep='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-14" y="-6.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">cos φ</text>',Np=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ap={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},hS={id:wp,name:vp,category:kp,description:_p,viewBox:Sp,width:$p,height:jp,svg:Ep,terminals:Np,source:Ap},mS=Object.freeze(Object.defineProperty({__proto__:null,category:kp,default:hS,description:_p,height:jp,id:wp,name:vp,source:Ap,svg:Ep,terminals:Np,viewBox:Sp,width:$p},Symbol.toStringTag,{value:"Module"})),Tp="power-supply",Mp="开关电源 (PS)",Cp="source",Pp="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Ip="-24 -42 48 84",Op=48,Bp=84,Lp='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="8" y="15" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">=</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Dp=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],zp=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Rp={kind:"inline"},pS={id:Tp,name:Mp,category:Cp,description:Pp,viewBox:Ip,width:Op,height:Bp,svg:Lp,terminals:Dp,params:zp,source:Rp},gS=Object.freeze(Object.defineProperty({__proto__:null,category:Cp,default:pS,description:Pp,height:Bp,id:Tp,name:Mp,params:zp,source:Rp,svg:Lp,terminals:Dp,viewBox:Ip,width:Op},Symbol.toStringTag,{value:"Module"})),Fp="protective-relay",Hp="保护继电器",Wp="protection",qp="测量继电器 / 保护继电器通用符号 (IEC 60617)。",Xp="-32 -42 64 44",Yp=64,Gp=44,Kp='<polygon points="-2,-22 2,-22 0,-25" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-22 -2,-19 -6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="2,-22 2,-19 6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-19 0,-17 -3,-15" fill="black" stroke="black" stroke-width="1"/><polygon points="0,-17 2,-19 4,-15" fill="black" stroke="black" stroke-width="1"/><rect x="-2" y="-22" width="4" height="4" rx="0" ry="0" fill="black" stroke="black" stroke-width="1"/><rect x="-30" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Up=[{id:"t_top",x:0,y:-40,orientation:"n"}],Vp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_16/en_60617_07_16_01.elmt",qetEnglishName:"Measuring relay; Device related to a measuring relay"},yS={id:Fp,name:Hp,category:Wp,description:qp,viewBox:Xp,width:Yp,height:Gp,svg:Kp,terminals:Up,source:Vp},xS=Object.freeze(Object.defineProperty({__proto__:null,category:Wp,default:yS,description:qp,height:Gp,id:Fp,name:Hp,source:Vp,svg:Kp,terminals:Up,viewBox:Xp,width:Yp},Symbol.toStringTag,{value:"Module"})),Jp="proximity-switch",Zp="接近开关 (SQ)",Qp="control",e0="接近传感器 / 无触点接近开关。",t0="-12 -32 24 64",n0=24,o0=64,r0='<line x1="0" y1="-30" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 -10,0 0,10 10,0" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-6" x2="-4" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-6" x2="4" y2="6" fill="none" stroke="black" stroke-width="1"/>',s0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],i0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},bS={id:Jp,name:Zp,category:Qp,description:e0,viewBox:t0,width:n0,height:o0,svg:r0,terminals:s0,source:i0},wS=Object.freeze(Object.defineProperty({__proto__:null,category:Qp,default:bS,description:e0,height:o0,id:Jp,name:Zp,source:i0,svg:r0,terminals:s0,viewBox:t0,width:n0},Symbol.toStringTag,{value:"Module"})),a0="pt",l0="电压互感器 (PT)",c0="instrument-transformer",d0="-22 -42 44 115",u0=44,f0=115,h0='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',m0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],p0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},vS={id:a0,name:l0,category:c0,viewBox:d0,width:u0,height:f0,svg:h0,terminals:m0,source:p0},kS=Object.freeze(Object.defineProperty({__proto__:null,category:c0,default:vS,height:f0,id:a0,name:l0,source:p0,svg:h0,terminals:m0,viewBox:d0,width:u0},Symbol.toStringTag,{value:"Module"})),g0="push-button",y0="按钮 (SB)",x0="control",b0="手动按钮, 自动复位 (常开 make)。",w0="-37 -42 39 64",v0=39,k0=64,_0='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',S0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],$0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_02.elmt",qetEnglishName:"Switch, manually operated, push-button, automatic return"},_S={id:g0,name:y0,category:x0,description:b0,viewBox:w0,width:v0,height:k0,svg:_0,terminals:S0,source:$0},SS=Object.freeze(Object.defineProperty({__proto__:null,category:x0,default:_S,description:b0,height:k0,id:g0,name:y0,source:$0,svg:_0,terminals:S0,viewBox:w0,width:v0},Symbol.toStringTag,{value:"Module"})),j0="pv",E0="光伏组件",N0="renewable",A0="-33 -22 85 64",T0=85,M0=64,C0='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',P0=[{id:"t_dc",x:0,y:40,orientation:"s"}],I0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},$S={id:j0,name:E0,category:N0,viewBox:A0,width:T0,height:M0,svg:C0,terminals:P0,source:I0},jS=Object.freeze(Object.defineProperty({__proto__:null,category:N0,default:$S,height:M0,id:j0,name:E0,source:I0,svg:C0,terminals:P0,viewBox:A0,width:T0},Symbol.toStringTag,{value:"Module"})),O0="rcd",B0="剩余电流装置 (RCD)",L0="protection",D0="不带过流保护的剩余电流断路器 (IEC 61008)。",z0="-12 -22 19 44",R0=19,F0=44,H0='<line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="0,20 0,10 -7,-9" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="13" rx="4.5" ry="2" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,0 -10,0 -10,13 -5,13" fill="none" stroke="black" stroke-width="0.4" stroke-dasharray="4 2"/>',W0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],q0=[{name:"open",type:"boolean",default:!1,label:"断开"}],X0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Y0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},ES={id:O0,name:B0,category:L0,description:D0,viewBox:z0,width:R0,height:F0,svg:H0,terminals:W0,state:q0,params:X0,source:Y0},NS=Object.freeze(Object.defineProperty({__proto__:null,category:L0,default:ES,description:D0,height:F0,id:O0,name:B0,params:X0,source:Y0,state:q0,svg:H0,terminals:W0,viewBox:z0,width:R0},Symbol.toStringTag,{value:"Module"})),G0="recloser",K0="重合闸 (Recloser)",U0="protection",V0="中压自动重合闸开关。",J0="-12 -32 36 64",Z0=36,Q0=64,eg='<line x1="0" y1="-30" x2="0" y2="-10" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-13" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-8" x2="2" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-12" x2="2" y2="-8" stroke="black" stroke-width="1" fill="none"/><path d="M 13 -12 A 7 7 0 1 1 6 -5" fill="none" stroke="black" stroke-width="0.8"/><polygon points="4,-7 6,-5 8,-3" fill="black"/><text x="14" y="6" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">AR</text>',tg=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ng=[{name:"open",type:"boolean",default:!1,label:"断开"}],og={kind:"inline"},AS={id:G0,name:K0,category:U0,description:V0,viewBox:J0,width:Z0,height:Q0,svg:eg,terminals:tg,state:ng,source:og},TS=Object.freeze(Object.defineProperty({__proto__:null,category:U0,default:AS,description:V0,height:Q0,id:G0,name:K0,source:og,state:ng,svg:eg,terminals:tg,viewBox:J0,width:Z0},Symbol.toStringTag,{value:"Module"})),rg="rectifier",sg="整流器 (AC→DC)",ig="renewable",ag="-42 -42 44 44",lg=44,cg=44,dg='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/>',ug=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],fg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},MS={id:rg,name:sg,category:ig,viewBox:ag,width:lg,height:cg,svg:dg,terminals:ug,source:fg},CS=Object.freeze(Object.defineProperty({__proto__:null,category:ig,default:MS,height:cg,id:rg,name:sg,source:fg,svg:dg,terminals:ug,viewBox:ag,width:lg},Symbol.toStringTag,{value:"Module"})),hg="relay-coil",mg="继电器线圈 (KA)",pg="control",gg="继电器 / 接触器操作线圈 (方框)。",yg="-22 -22 44 44",xg=44,bg=44,wg='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/>',vg=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],kg={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_01.elmt",qetEnglishName:"Operating device, general symbol; Relay coil, general symbol"},PS={id:hg,name:mg,category:pg,description:gg,viewBox:yg,width:xg,height:bg,svg:wg,terminals:vg,source:kg},IS=Object.freeze(Object.defineProperty({__proto__:null,category:pg,default:PS,description:gg,height:bg,id:hg,name:mg,source:kg,svg:wg,terminals:vg,viewBox:yg,width:xg},Symbol.toStringTag,{value:"Module"})),_g="resistor",Sg="电阻 (R)",$g="passive",jg="通用电阻 / 限流 / 制动电阻。",Eg="-6 -23 12 35",Ng=12,Ag=35,Tg='<line x1="0" y1="-10" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="10" x2="4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-10" x2="-4" y2="10" fill="none" stroke="black" stroke-width="1"/>',Mg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Cg=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],Pg={x:6,y:0,anchor:"start"},Ig={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},OS={id:_g,name:Sg,category:$g,description:jg,viewBox:Eg,width:Ng,height:Ag,svg:Tg,terminals:Mg,params:Cg,label:Pg,source:Ig},BS=Object.freeze(Object.defineProperty({__proto__:null,category:$g,default:OS,description:jg,height:Ag,id:_g,label:Pg,name:Sg,params:Cg,source:Ig,svg:Tg,terminals:Mg,viewBox:Eg,width:Ng},Symbol.toStringTag,{value:"Module"})),Og="reverse-power-relay",Bg="逆功率继电器 (32)",Lg="protection",Dg="逆功率 / 逆流保护继电器 (ANSI 32)。",zg="-62 -42 64 44",Rg=64,Fg=44,Hg='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">I</text><polygon points="-15,-20 -30,-20 -24,-22 -24,-18 -30,-20 -24,-20" fill="black" stroke="black" stroke-width="1"/>',Wg=[{id:"t_top",x:-30,y:-40,orientation:"n"}],qg={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},LS={id:Og,name:Bg,category:Lg,description:Dg,viewBox:zg,width:Rg,height:Fg,svg:Hg,terminals:Wg,source:qg},DS=Object.freeze(Object.defineProperty({__proto__:null,category:Lg,default:LS,description:Dg,height:Fg,id:Og,name:Bg,source:qg,svg:Hg,terminals:Wg,viewBox:zg,width:Rg},Symbol.toStringTag,{value:"Module"})),Xg="selector-switch",Yg="选择开关 (SA)",Gg="switching",Kg="转换 / 选择开关 (旋转操作, 保位)。",Ug="-34 -42 36 64",Vg=36,Jg=64,Zg='<line x1="-32" y1="-10" x2="-2" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-32" y1="-15" x2="-32" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',Qg=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],e1=[{name:"open",type:"boolean",default:!1,label:"断开"}],t1={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_04.elmt",qetEnglishName:"Switch, manually operated, turning, stay-put"},zS={id:Xg,name:Yg,category:Gg,description:Kg,viewBox:Ug,width:Vg,height:Jg,svg:Zg,terminals:Qg,state:e1,source:t1},RS=Object.freeze(Object.defineProperty({__proto__:null,category:Gg,default:zS,description:Kg,height:Jg,id:Xg,name:Yg,source:t1,state:e1,svg:Zg,terminals:Qg,viewBox:Ug,width:Vg},Symbol.toStringTag,{value:"Module"})),n1="series-reactor",o1="串联电抗器",r1="compensation",s1="与并联电抗器同符号;通过用法区分。",i1="-62 -82 64 104",a1=64,l1=104,c1='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',d1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],u1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},FS={id:n1,name:o1,category:r1,description:s1,viewBox:i1,width:a1,height:l1,svg:c1,terminals:d1,source:u1},HS=Object.freeze(Object.defineProperty({__proto__:null,category:r1,default:FS,description:s1,height:l1,id:n1,name:o1,source:u1,svg:c1,terminals:d1,viewBox:i1,width:a1},Symbol.toStringTag,{value:"Module"})),f1="shunt-capacitor",h1="并联电容器",m1="compensation",p1="-7 -23 14 27",g1=14,y1=27,x1='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',b1=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],w1=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],v1={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},WS={id:f1,name:h1,category:m1,viewBox:p1,width:g1,height:y1,svg:x1,terminals:b1,params:w1,source:v1},qS=Object.freeze(Object.defineProperty({__proto__:null,category:m1,default:WS,height:y1,id:f1,name:h1,params:w1,source:v1,svg:x1,terminals:b1,viewBox:p1,width:g1},Symbol.toStringTag,{value:"Module"})),k1="shunt-reactor",_1="并联电抗器",S1="compensation",$1="-62 -82 64 104",j1=64,E1=104,N1='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',A1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],T1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},XS={id:k1,name:_1,category:S1,viewBox:$1,width:j1,height:E1,svg:N1,terminals:A1,source:T1},YS=Object.freeze(Object.defineProperty({__proto__:null,category:S1,default:XS,height:E1,id:k1,name:_1,source:T1,svg:N1,terminals:A1,viewBox:$1,width:j1},Symbol.toStringTag,{value:"Module"})),M1="siren",C1="警笛 (HA)",P1="control",I1="声响警笛 / 报警器。",O1="-32 -42 44 54",B1=44,L1=54,D1='<line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="10,-10 -30,-10 -10,-40" fill="none" stroke="black" stroke-width="1"/>',z1=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],R1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},GS={id:M1,name:C1,category:P1,description:I1,viewBox:O1,width:B1,height:L1,svg:D1,terminals:z1,source:R1},KS=Object.freeze(Object.defineProperty({__proto__:null,category:P1,default:GS,description:I1,height:L1,id:M1,name:C1,source:R1,svg:D1,terminals:z1,viewBox:O1,width:B1},Symbol.toStringTag,{value:"Module"})),F1="socket-outlet",H1="插座 / 连接器",W1="load",q1="电源插座 / 多极连接器。",X1="-7 -2 13 34",Y1=13,G1=34,K1='<line x1="-5" y1="13" x2="4" y2="20" fill="none" stroke="black" stroke-width="0.4"/><line x1="-1" y1="12" x2="-1" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="9" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="12" x2="1" y2="19" fill="none" stroke="black" stroke-width="1"/><path d="M 3 13 A 3 3 0 0 0 -3 13" fill="none" stroke="black" stroke-width="1"/>',U1=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],V1={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
217
- unifilar`},US={id:F1,name:H1,category:W1,description:q1,viewBox:X1,width:Y1,height:G1,svg:K1,terminals:U1,source:V1},VS=Object.freeze(Object.defineProperty({__proto__:null,category:W1,default:US,description:q1,height:G1,id:F1,name:H1,source:V1,svg:K1,terminals:U1,viewBox:X1,width:Y1},Symbol.toStringTag,{value:"Module"})),J1="soft-starter",Z1="软启动器",Q1="motor-control",ey="电机软启动器 (晶闸管降压启动)。",ty="-22 -42 44 84",ny=44,oy=84,ry='<rect x="-20" y="-20" width="40" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-12" y1="-12" x2="12" y2="12" stroke="black" stroke-width="1" fill="none"/><polygon points="4,8 12,12 8,4" fill="none" stroke="black" stroke-width="1"/><text x="-12" y="-2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">SS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',sy=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],iy={kind:"inline"},JS={id:J1,name:Z1,category:Q1,description:ey,viewBox:ty,width:ny,height:oy,svg:ry,terminals:sy,source:iy},ZS=Object.freeze(Object.defineProperty({__proto__:null,category:Q1,default:JS,description:ey,height:oy,id:J1,name:Z1,source:iy,svg:ry,terminals:sy,viewBox:ty,width:ny},Symbol.toStringTag,{value:"Module"})),ay="sync-motor",ly="同步电动机",cy="load",dy="-62 -82 64 114",uy=64,fy=114,hy='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',my=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],py={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},QS={id:ay,name:ly,category:cy,viewBox:dy,width:uy,height:fy,svg:hy,terminals:my,source:py},e$=Object.freeze(Object.defineProperty({__proto__:null,category:cy,default:QS,height:fy,id:ay,name:ly,source:py,svg:hy,terminals:my,viewBox:dy,width:uy},Symbol.toStringTag,{value:"Module"})),gy="synchronoscope",yy="同步表",xy="measurement",by="同步指示器 / 同步表。",wy="-22 -42 44 44",vy=44,ky=44,_y='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',Sy=[{id:"t_top",x:0,y:-40,orientation:"n"}],$y={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},t$={id:gy,name:yy,category:xy,description:by,viewBox:wy,width:vy,height:ky,svg:_y,terminals:Sy,source:$y},n$=Object.freeze(Object.defineProperty({__proto__:null,category:xy,default:t$,description:by,height:ky,id:gy,name:yy,source:$y,svg:_y,terminals:Sy,viewBox:wy,width:vy},Symbol.toStringTag,{value:"Module"})),jy="terminal",Ey="接线端子 / 节点 (X)",Ny="busbar",Ay="接线端子 / 接线盒 / 汇接节点。",Ty="-5 -5 10 10",My=10,Cy=10,Py='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',Iy=[{id:"t_top",x:0,y:-2.5,orientation:"n"},{id:"t_bottom",x:0,y:2.5,orientation:"s"},{id:"t_left",x:-2.5,y:0,orientation:"w"},{id:"t_right",x:2.5,y:0,orientation:"e"}],Oy={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},o$={id:jy,name:Ey,category:Ny,description:Ay,viewBox:Ty,width:My,height:Cy,svg:Py,terminals:Iy,source:Oy},r$=Object.freeze(Object.defineProperty({__proto__:null,category:Ny,default:o$,description:Ay,height:Cy,id:jy,name:Ey,source:Oy,svg:Py,terminals:Iy,viewBox:Ty,width:My},Symbol.toStringTag,{value:"Module"})),By="thermal-overload",Ly="热过载继电器",Dy="motor-control",zy="电机热过载保护继电器, 通常串接在接触器和电机之间。",Ry="-9 -32 19 64",Fy=19,Hy=64,Wy='<line x1="0" y1="-30" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-7" y="-15" width="14" height="30" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,-10 -1,-5 -4,0 -1,5 -4,10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',qy=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Xy=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],Yy={kind:"inline"},s$={id:By,name:Ly,category:Dy,description:zy,viewBox:Ry,width:Fy,height:Hy,svg:Wy,terminals:qy,state:Xy,source:Yy},i$=Object.freeze(Object.defineProperty({__proto__:null,category:Dy,default:s$,description:zy,height:Hy,id:By,name:Ly,source:Yy,state:Xy,svg:Wy,terminals:qy,viewBox:Ry,width:Fy},Symbol.toStringTag,{value:"Module"})),Gy="thermocouple",Ky="热电偶 (BT)",Uy="measurement",Vy="热电偶温度传感器。",Jy="-26 -42 52 46",Zy=52,Qy=46,ex='<ellipse cx="0" cy="0" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/><polyline points="-10,-40 -10,-15 0,0 10,-15 10,-40" fill="none" stroke="black" stroke-width="1"/><line x1="-24" y1="-16" x2="-16" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="16" y1="-16" x2="24" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-20" x2="20" y2="-12" fill="none" stroke="black" stroke-width="1"/>',tx=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],nx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},a$={id:Gy,name:Ky,category:Uy,description:Vy,viewBox:Jy,width:Zy,height:Qy,svg:ex,terminals:tx,source:nx},l$=Object.freeze(Object.defineProperty({__proto__:null,category:Uy,default:a$,description:Vy,height:Qy,id:Gy,name:Ky,source:nx,svg:ex,terminals:tx,viewBox:Jy,width:Zy},Symbol.toStringTag,{value:"Module"})),ox="thyristor",rx="晶闸管 (V)",sx="passive",ix="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ax="-22 -42 34 44",lx=34,cx=44,dx='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-20" x2="-10" y2="-20" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,0 -7,0 -4,-10" fill="none" stroke="black" stroke-width="1"/>',ux=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],fx={x:6,y:-20,anchor:"start"},hx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},c$={id:ox,name:rx,category:sx,description:ix,viewBox:ax,width:lx,height:cx,svg:dx,terminals:ux,label:fx,source:hx},d$=Object.freeze(Object.defineProperty({__proto__:null,category:sx,default:c$,description:ix,height:cx,id:ox,label:fx,name:rx,source:hx,svg:dx,terminals:ux,viewBox:ax,width:lx},Symbol.toStringTag,{value:"Module"})),mx="time-relay",px="时间继电器 (KT)",gx="control",yx="延时 (缓动) 继电器线圈。",xx="-32 -22 54 44",bx=54,wx=44,vx='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><rect x="-30" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="10" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/>',kx=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_x={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},u$={id:mx,name:px,category:gx,description:yx,viewBox:xx,width:bx,height:wx,svg:vx,terminals:kx,source:_x},f$=Object.freeze(Object.defineProperty({__proto__:null,category:gx,default:u$,description:yx,height:wx,id:mx,name:px,source:_x,svg:vx,terminals:kx,viewBox:xx,width:bx},Symbol.toStringTag,{value:"Module"})),Sx="transfer-switch",$x="切换开关 (ATS)",jx="switching",Ex="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Nx="-27 -32 51 64",Ax=51,Tx=64,Mx='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',Cx=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],Px=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Ix={kind:"inline"},h$={id:Sx,name:$x,category:jx,description:Ex,viewBox:Nx,width:Ax,height:Tx,svg:Mx,terminals:Cx,state:Px,source:Ix},m$=Object.freeze(Object.defineProperty({__proto__:null,category:jx,default:h$,description:Ex,height:Tx,id:Sx,name:$x,source:Ix,state:Px,svg:Mx,terminals:Cx,viewBox:Nx,width:Ax},Symbol.toStringTag,{value:"Module"})),Ox="transformer-2w",Bx="双绕组变压器",Lx="transformer",Dx="-62 -142 64 144",zx=64,Rx=144,Fx='<ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-140" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/>',Hx=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Wx=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],qx={x:4,y:-68,anchor:"start"},Xx={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_01.elmt",qetEnglishName:"Transformer with two windings, general symbol"},p$={id:Ox,name:Bx,category:Lx,viewBox:Dx,width:zx,height:Rx,svg:Fx,terminals:Hx,params:Wx,label:qx,source:Xx},g$=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:p$,height:Rx,id:Ox,label:qx,name:Bx,params:Wx,source:Xx,svg:Fx,terminals:Hx,viewBox:Dx,width:zx},Symbol.toStringTag,{value:"Module"})),Yx="transformer-3w",Gx="三绕组变压器",Kx="transformer",Ux="-82 -131 114 133",Vx=114,Jx=133,Zx='<ellipse cx="-30" cy="-80" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-31" y1="-129" x2="-31" y2="-109" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-50" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-20" x2="-50" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',Qx=[{id:"t1",x:-31,y:-129,orientation:"n"},{id:"t_low_left",x:-50,y:0,orientation:"s"},{id:"t_low_right",x:0,y:0,orientation:"s"}],eb={x:4,y:-64,anchor:"start"},tb={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},y$={id:Yx,name:Gx,category:Kx,viewBox:Ux,width:Vx,height:Jx,svg:Zx,terminals:Qx,label:eb,source:tb},x$=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:y$,height:Jx,id:Yx,label:eb,name:Gx,source:tb,svg:Zx,terminals:Qx,viewBox:Ux,width:Vx},Symbol.toStringTag,{value:"Module"})),nb="triac",ob="双向晶闸管 (V)",rb="passive",sb="双向三极晶闸管 (TRIAC)。",ib="-22 -42 44 44",ab=44,lb=44,cb='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,-30 0,-30 -10,-10" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-30" x2="-10" y2="-30" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 10,-30 20,-10" fill="none" stroke="black" stroke-width="1"/><polyline points="20,0 18,0 14,-10" fill="none" stroke="black" stroke-width="1"/>',db=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],ub={x:6,y:-20,anchor:"start"},fb={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},b$={id:nb,name:ob,category:rb,description:sb,viewBox:ib,width:ab,height:lb,svg:cb,terminals:db,label:ub,source:fb},w$=Object.freeze(Object.defineProperty({__proto__:null,category:rb,default:b$,description:sb,height:lb,id:nb,label:ub,name:ob,source:fb,svg:cb,terminals:db,viewBox:ib,width:ab},Symbol.toStringTag,{value:"Module"})),hb="undervoltage-relay",mb="欠压继电器 (27)",pb="protection",gb="欠电压保护继电器 (ANSI 27)。",yb="-62 -82 64 84",xb=64,bb=84,wb='<rect x="-60" y="-80" width="60" height="80" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-49" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">130 %</text><text x="-55" y="-32.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">50...80 V</text><text x="-41" y="-53.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">U &lt;</text>',vb=[{id:"t_top",x:-30,y:-80,orientation:"n"}],kb={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},v$={id:hb,name:mb,category:pb,description:gb,viewBox:yb,width:xb,height:bb,svg:wb,terminals:vb,source:kb},k$=Object.freeze(Object.defineProperty({__proto__:null,category:pb,default:v$,description:gb,height:bb,id:hb,name:mb,source:kb,svg:wb,terminals:vb,viewBox:yb,width:xb},Symbol.toStringTag,{value:"Module"})),_b="ups",Sb="不间断电源 (UPS)",$b="source",jb="在线 / 后备式不间断电源。",Eb="-26 -42 52 84",Nb=52,Ab=84,Tb='<rect x="-24" y="-20" width="48" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">UPS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Mb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Cb=[{name:"S",label:"容量",type:"number",unit:"kVA"}],Pb={kind:"inline"},_$={id:_b,name:Sb,category:$b,description:jb,viewBox:Eb,width:Nb,height:Ab,svg:Tb,terminals:Mb,params:Cb,source:Pb},S$=Object.freeze(Object.defineProperty({__proto__:null,category:$b,default:_$,description:jb,height:Ab,id:_b,name:Sb,params:Cb,source:Pb,svg:Tb,terminals:Mb,viewBox:Eb,width:Nb},Symbol.toStringTag,{value:"Module"})),Ib="varmeter",Ob="无功功率表 (var)",Bb="measurement",Lb="无功功率表 (var)。",Db="-22 -42 44 44",zb=44,Rb=44,Fb='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">var</text>',Hb=[{id:"t_top",x:0,y:-40,orientation:"n"}],Wb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},$$={id:Ib,name:Ob,category:Bb,description:Lb,viewBox:Db,width:zb,height:Rb,svg:Fb,terminals:Hb,source:Wb},j$=Object.freeze(Object.defineProperty({__proto__:null,category:Bb,default:$$,description:Lb,height:Rb,id:Ib,name:Ob,source:Wb,svg:Fb,terminals:Hb,viewBox:Db,width:zb},Symbol.toStringTag,{value:"Module"})),qb="vfd",Xb="变频器 (VFD)",Yb="motor-control",Gb="Variable Frequency Drive — 异步电动机调速。",Kb="-24 -42 48 84",Ub=48,Vb=84,Jb='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="6" y="14" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~f</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Zb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Qb={kind:"inline"},E$={id:qb,name:Xb,category:Yb,description:Gb,viewBox:Kb,width:Ub,height:Vb,svg:Jb,terminals:Zb,source:Qb},N$=Object.freeze(Object.defineProperty({__proto__:null,category:Yb,default:E$,description:Gb,height:Vb,id:qb,name:Xb,source:Qb,svg:Jb,terminals:Zb,viewBox:Kb,width:Ub},Symbol.toStringTag,{value:"Module"})),ew="voltage-regulator",tw="调压器 (T)",nw="transformer",ow="可调感应调压器 / 自耦调压器。",rw="-17 -32 38 64",sw=38,iw=64,aw='<line x1="-5" y1="21" x2="5" y2="17" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-16.05" x2="4.95" y2="-20.05" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-5" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="0" rx="15" ry="15" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-20.05" x2="4.95" y2="-24.05" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="23" x2="5" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-18.05" x2="4.95" y2="-22.05" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="25" x2="5" y2="21" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="15" x2="15" y2="-15" fill="none" stroke="black" stroke-width="1"/><polygon points="13,-16 16,-13 19,-19" fill="black" stroke="black" stroke-width="0.4"/>',lw=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],cw=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],dw={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},A$={id:ew,name:tw,category:nw,description:ow,viewBox:rw,width:sw,height:iw,svg:aw,terminals:lw,params:cw,source:dw},T$=Object.freeze(Object.defineProperty({__proto__:null,category:nw,default:A$,description:ow,height:iw,id:ew,name:tw,params:cw,source:dw,svg:aw,terminals:lw,viewBox:rw,width:sw},Symbol.toStringTag,{value:"Module"})),uw="voltmeter",fw="电压表 (V)",hw="measurement",mw="-22 -42 44 44",pw=44,gw=44,yw='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-4" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">V</text>',xw=[{id:"t_top",x:0,y:-40,orientation:"n"}],bw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},M$={id:uw,name:fw,category:hw,viewBox:mw,width:pw,height:gw,svg:yw,terminals:xw,source:bw},C$=Object.freeze(Object.defineProperty({__proto__:null,category:hw,default:M$,height:gw,id:uw,name:fw,source:bw,svg:yw,terminals:xw,viewBox:mw,width:pw},Symbol.toStringTag,{value:"Module"})),ww="wattmeter",vw="功率表 (W)",kw="measurement",_w="-22 -42 44 44",Sw=44,$w=44,jw='<rect x="-20" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-6" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">W</text>',Ew=[{id:"t_top",x:0,y:-40,orientation:"n"}],Nw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},P$={id:ww,name:vw,category:kw,viewBox:_w,width:Sw,height:$w,svg:jw,terminals:Ew,source:Nw},I$=Object.freeze(Object.defineProperty({__proto__:null,category:kw,default:P$,height:$w,id:ww,name:vw,source:Nw,svg:jw,terminals:Ew,viewBox:_w,width:Sw},Symbol.toStringTag,{value:"Module"})),Aw="wind-turbine",Tw="风力发电机",Mw="renewable",Cw="风机:发电机 + 三叶轮标记",Pw="-22 -46 44 68",Iw=44,Ow=68,Bw='<circle cx="0" cy="0" r="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="16">G</text><line x1="0" y1="-20" x2="0" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-32" x2="-10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="0" y2="-44" fill="none" stroke="black" stroke-width="1.5"/>',Lw=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Dw={kind:"inline"},O$={id:Aw,name:Tw,category:Mw,description:Cw,viewBox:Pw,width:Iw,height:Ow,svg:Bw,terminals:Lw,source:Dw},B$=Object.freeze(Object.defineProperty({__proto__:null,category:Mw,default:O$,description:Cw,height:Ow,id:Aw,name:Tw,source:Dw,svg:Bw,terminals:Lw,viewBox:Pw,width:Iw},Symbol.toStringTag,{value:"Module"})),zw="zener-diode",Rw="稳压二极管 (D)",Fw="passive",Hw="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",Ww="-12 -42 24 44",qw=24,Xw=44,Yw='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-15" x2="-10" y2="-10" fill="none" stroke="black" stroke-width="1"/>',Gw=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Kw={x:6,y:-20,anchor:"start"},Uw={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},L$={id:zw,name:Rw,category:Fw,description:Hw,viewBox:Ww,width:qw,height:Xw,svg:Yw,terminals:Gw,label:Kw,source:Uw},D$=Object.freeze(Object.defineProperty({__proto__:null,category:Fw,default:L$,description:Hw,height:Xw,id:zw,label:Kw,name:Rw,source:Uw,svg:Yw,terminals:Gw,viewBox:Ww,width:qw},Symbol.toStringTag,{value:"Module"})),z$=Object.assign({"./ammeter.json":Sk,"./arc-suppression-coil.json":jk,"./arrester.json":Nk,"./async-motor.json":Tk,"./autotransformer.json":Ck,"./battery.json":Ik,"./bell.json":Bk,"./break-contact.json":Dk,"./breaker.json":Rk,"./buchholz-relay.json":Hk,"./busbar.json":qk,"./buzzer.json":Yk,"./capacitor.json":Kk,"./contactor.json":Vk,"./converter-bidir.json":Zk,"./ct.json":e_,"./dc-combiner.json":n_,"./dc-disconnector.json":r_,"./dc-motor.json":i_,"./diode.json":l_,"./disconnector.json":d_,"./distance-relay.json":f_,"./earth.json":m_,"./earthing-switch.json":g_,"./energy-meter.json":x_,"./ev-charger.json":w_,"./frequency-meter.json":k_,"./fuse-switch-disconnector.json":S_,"./fuse.json":j_,"./generator.json":N_,"./genset.json":T_,"./gfci-breaker.json":C_,"./grid-source.json":I_,"./grounding-transformer.json":B_,"./heater.json":D_,"./igbt.json":R_,"./indicator-light.json":H_,"./inductor.json":q_,"./inverter.json":Y_,"./limit-switch.json":K_,"./load-switch.json":V_,"./load.json":Z_,"./make-contact.json":eS,"./motor-starter.json":nS,"./ngr.json":rS,"./overcurrent-relay.json":iS,"./panelboard.json":lS,"./phase-failure-relay.json":dS,"./plc.json":fS,"./power-factor-meter.json":mS,"./power-supply.json":gS,"./protective-relay.json":xS,"./proximity-switch.json":wS,"./pt.json":kS,"./push-button.json":SS,"./pv.json":jS,"./rcd.json":NS,"./recloser.json":TS,"./rectifier.json":CS,"./relay-coil.json":IS,"./resistor.json":BS,"./reverse-power-relay.json":DS,"./selector-switch.json":RS,"./series-reactor.json":HS,"./shunt-capacitor.json":qS,"./shunt-reactor.json":YS,"./siren.json":KS,"./socket-outlet.json":VS,"./soft-starter.json":ZS,"./sync-motor.json":e$,"./synchronoscope.json":n$,"./terminal.json":r$,"./thermal-overload.json":i$,"./thermocouple.json":l$,"./thyristor.json":d$,"./time-relay.json":f$,"./transfer-switch.json":m$,"./transformer-2w.json":g$,"./transformer-3w.json":x$,"./triac.json":w$,"./undervoltage-relay.json":k$,"./ups.json":S$,"./varmeter.json":j$,"./vfd.json":N$,"./voltage-regulator.json":T$,"./voltmeter.json":C$,"./wattmeter.json":I$,"./wind-turbine.json":B$,"./zener-diode.json":D$}),Vw=Object.values(z$).map(e=>e.default),ot=Object.fromEntries(Vw.map(e=>[e.id,e])),vr=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],R$=(()=>{var t;const e={};for(const n of Vw)(e[t=n.category]??(e[t]=[])).push(n);return e})(),ao=new Map(Object.entries(ot));function Jw(e){return ot[e]}function F$(e){const n=[...e].sort().join("|");let o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const H$=320;function et(e){var v,C,O,F,G;const t=Gs(),n=new Map;e.elements.forEach(($,H)=>{if(n.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/elements/${H}`});return}n.set($.id,$);const W=ao.get($.kind);W||t.diagnostics.push({code:"E003",severity:"error",message:`${ve("compile.unknownKind",{kind:$.kind})} (id=${$.id})`,pointer:`/elements/${H}`}),t.elements.set($.id,{element:$,libraryDef:W})});const o=new Map,r=new Map;(e.buses??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/buses/${H}`});return}if(o.set($.id,$),$.layout){const W=$.layout.rot??0;r.set($.id,{at:$.layout.at,span:$.layout.span,rot:W,axis:so(W)})}});const s=new Map;(e.junctions??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)||s.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/junctions/${H}`});return}s.set($.id,$)});const i=$=>!$.includes(".")&&o.has($),a=$=>!$.includes(".")&&s.has($),l=($,H)=>{if(i($)||a($))return!0;const W=$.indexOf(".");if(W<=0)return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.invalidTermRef",{ref:$}),pointer:H}),!1;const X=$.slice(0,W),P=$.slice(W+1),R=t.elements.get(X);if(!R)return t.diagnostics.push({code:"E002",severity:"error",message:ve("compile.elementMissing",{id:X}),pointer:H}),!1;if(!R.libraryDef)return!1;if(!R.libraryDef.terminals.find(Z=>Z.id===P)){const Z=R.libraryDef.terminals.map(ie=>ie.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.missingPin",{id:X,kind:R.element.kind,pin:P,available:Z}),pointer:H}),!1}return!0},c=[];(e.wires??[]).forEach(($,H)=>{const W=`/wires/${H}`,X=l($.ends[0],W),P=l($.ends[1],W);X&&P&&c.push($)});const u=new Map;if(e.layout)for(const[$,H]of Object.entries(e.layout))t.elements.has($)?u.set($,Ks(H)):t.diagnostics.push({code:"E004",severity:"error",message:ve("compile.layoutMissingElement",{id:$}),pointer:`/layout/${$}`});const f=vk({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:ao,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[$,H]of f.buses){const W=o.get($);W&&t.buses.set($,{bus:W,geometry:H})}for(const[$,H]of o)t.buses.has($)||t.buses.set($,{bus:H,geometry:{at:((v=H.layout)==null?void 0:v.at)??[0,0],span:((C=H.layout)==null?void 0:C.span)??H$,rot:((O=H.layout)==null?void 0:O.rot)??0,axis:so(((F=H.layout)==null?void 0:F.rot)??0)}});for(const $ of t.elements.values()){if(!$.libraryDef)continue;const H=t.layout.get($.element.id);if(!H)continue;const W=[];for(const X of $.libraryDef.terminals){const P=`${$.element.id}.${X.id}`,R=Ie([X.x,X.y],H),Z=Ot(X.orientation,H);t.terminals.set(P,{ref:P,elementId:$.element.id,pin:X.id,world:R,orientation:Z}),W.push(P)}t.elementToTerminals.set($.element.id,W)}const m=new Map,g=new Set;for(const[$,H]of s)(G=H.layout)!=null&&G.at?(m.set($,[H.layout.at[0],H.layout.at[1]]),g.add($)):f.junctions.has($)&&(m.set($,f.junctions.get($)),g.add($));const p=$=>{if(!$.includes(".")){const W=t.buses.get($);return W?W.geometry.at:m.get($)??null}const H=t.terminals.get($);return H?H.world:null},h=new Map;for(const[$]of s)g.has($)||h.set($,[]);for(const $ of c){const[H,W]=$.ends;h.has(H)&&h.get(H).push(W),h.has(W)&&h.get(W).push(H)}for(let $=0;$<12;$++){let H=!1;for(const[W,X]of h){let P=0,R=0,Z=0;for(const ae of X){const me=p(ae);me&&(P+=me[0],R+=me[1],Z++)}if(!Z)continue;const ie=P/Z,ue=R/Z,ee=m.get(W);(!ee||Math.abs(ee[0]-ie)>.01||Math.abs(ee[1]-ue)>.01)&&(m.set(W,[ie,ue]),H=!0)}if(!H)break}const x=new Map;for(const[$]of s)x.set($,0);for(const $ of c)for(const H of $.ends){const W=x.get(H);W!==void 0&&x.set(H,W+1)}for(const[$,H]of s)t.junctions.set($,{junction:H,world:m.get($)??[0,0],degree:x.get($)??0});const w=new Us;for(const $ of c)w.add($.ends[0]),w.add($.ends[1]),w.union($.ends[0],$.ends[1]);for(const[,$]of w.groups()){const H=F$($);t.nodes.set(H,{id:H,terminals:$});for(const W of $)t.terminalToNode.set(W,H)}for(const $ of t.elements.values()){const H=t.elementToTerminals.get($.element.id)??[];if(H.length===0)continue;H.some(X=>t.terminalToNode.has(X))||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$.element.id})})}for(const $ of t.buses.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of t.junctions.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of c){if($.path&&$.path.length>=2){const W=$.path,X=W.length>=2?W[1]:null,P=W.length>=2?W[W.length-2]:null,R=br($.ends[0],X,t),Z=br($.ends[1],P,t);if(R&&Z){const ie=[[R[0],R[1]],...W.slice(1,-1).map(ee=>[ee[0],ee[1]]),[Z[0],Z[1]]],ue=Ys(ie);if(ue.length>=2){t.wireRenders.set($.id,{wireId:$.id,path:ue,userEdited:!0,...$.label?{label:$.label}:{}});continue}}}const H=kk($,t);H&&t.wireRenders.set($.id,$.label?{...H,label:$.label}:H)}return t}const W$={earth:"GND",breaker:"QF",disconnector:"QS","earthing-switch":"QE","load-switch":"QL",fuse:"FU","transformer-2w":"T","transformer-3w":"T",autotransformer:"AT",ct:"CT",pt:"PT",generator:"G","sync-motor":"M","async-motor":"M","grid-source":"L",load:"L",battery:"BAT","shunt-reactor":"LR","series-reactor":"LR","shunt-capacitor":"C",arrester:"FBL","grounding-transformer":"TG",ngr:"NGR","arc-suppression-coil":"ASC",pv:"PV","wind-turbine":"WT",rectifier:"RT",inverter:"INV","converter-bidir":"PCS"},kr="B",_r="J";function Ao(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Rt(e,t){const n=W$[t]??t,o=Ao(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function lo(e){const t=Ao(e);let n=1;for(;t.has(`${kr}${n}`);)n++;return`${kr}${n}`}function co(e){const t=Ao(e);let n=1;for(;t.has(`${_r}${n}`);)n++;return`${_r}${n}`}function hn(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function at(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}function Wn(e,t,n){if(n.length===0)return n;const o=new Set(n.map(a=>a.id)),r=new Set(t.map(a=>a.id)),s=new Set;for(const a of e)if(!r.has(a.id))for(const l of a.ends)o.has(l)&&s.add(l);if(s.size===0)return n;const i=new Set;for(const a of t)for(const l of a.ends)s.has(l)&&i.add(l);return n.filter(a=>!s.has(a.id)||i.has(a.id))}const Sr={version:"1",elements:[]},q$=100,qn=20;function X$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const y=$n()(mk((e,t)=>({diagram:Sr,internal:et(Sr),fileSession:null,activeTool:X$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,readOnly:!1,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:et(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),setReadOnly:n=>e({readOnly:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:et(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=q$?r.slice(1):r;e({diagram:s,internal:et(s),past:[...i,o],future:[],annotationPreview:null})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:et(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:et(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null,annotationDraft:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:Y$(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null,editingCell:n?t().editingCell:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement,editingCell:null}),setEditingCell:n=>e({editingCell:n}),setAnnotationDraft:n=>e({annotationDraft:n}),setAnnotationPreview:n=>e({annotationPreview:n}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var g;const{selection:n,selectedAnnotation:o,diagram:r,internal:s}=t();if(n.length===0){if(!o)return;const p=(r.annotations??[]).find(h=>h.id===o);if(!p)return;e({clipboard:{elements:[],buses:[],junctions:[],placements:{},busLayouts:{},wires:[],annotations:[structuredClone(p)]},clipboardPasteIndex:0});return}const i=new Set(n),a=r.elements.filter(p=>i.has(p.id)).map(p=>structuredClone(p)),l=(r.buses??[]).filter(p=>i.has(p.id)).map(p=>structuredClone(p)),c=(r.junctions??[]).filter(p=>i.has(p.id)).map(p=>{var x;const h=structuredClone(p);if(!h.layout){const w=(x=s.junctions.get(p.id))==null?void 0:x.world;w&&(h.layout={at:[w[0],w[1]]})}return h}),u={};for(const p of n)if(i.has(p)&&!s.buses.has(p)){const h=(g=r.layout)==null?void 0:g[p];if(h){u[p]=structuredClone(h);continue}const x=s.layout.get(p);x&&(u[p]=on(x))}const f={};for(const p of n){const h=s.buses.get(p);h&&(f[p]=ut(h.geometry))}const m=(r.wires??[]).filter(p=>p.ends.every(h=>i.has(Xn(h)))).map(p=>structuredClone(p));e({clipboard:{elements:a,buses:l,junctions:c,placements:u,busLayouts:f,wires:m,annotations:[]},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n,selectedAnnotation:o}=t();n.length===0&&!o||(t().copySelection(),n.length===0&&o?t().deleteAnnotation(o):t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n)return;if(n.elements.length===0&&n.buses.length===0&&n.junctions.length===0){const f=n.annotations??[];if(f.length===0)return;const m=o+1,g=qn*m;let p=null;t().dispatch(h=>{let x=h;for(const w of f){const v=hn(x);p=v;const C={...structuredClone(w),id:v,at:[w.at[0]+g,w.at[1]+g]};x={...x,annotations:[...x.annotations??[],C]}}return x}),p&&e({selectedAnnotation:p,selection:[],selectedWire:null,selectedNode:null,clipboardPasteIndex:m});return}const s=o+1,i=qn*s,a=qn*s,l=new Map;let c=r;for(const f of n.elements){const m=Rt(c,f.kind);l.set(f.id,m),c={...c,elements:[...c.elements,{id:m,kind:f.kind}]}}for(const f of n.buses){const m=lo(c);l.set(f.id,m),c={...c,buses:[...c.buses??[],{id:m}]}}for(const f of n.junctions){const m=co(c);l.set(f.id,m),c={...c,junctions:[...c.junctions??[],{id:m}]}}const u=f=>{const m=f.indexOf("."),g=m<0?f:f.slice(0,m),p=l.get(g);return p?m<0?p:`${p}${f.slice(m)}`:f};t().dispatch(f=>{const m=n.elements.map(v=>{const C=structuredClone(v);return C.id=l.get(v.id),C}),g=n.buses.map(v=>{const C=structuredClone(v);C.id=l.get(v.id);const O=n.busLayouts[v.id];return O&&(C.layout={...O,at:[O.at[0]+i,O.at[1]+a]}),C}),p=n.junctions.map(v=>{const C=structuredClone(v);return C.id=l.get(v.id),C.layout&&(C.layout={at:[C.layout.at[0]+i,C.layout.at[1]+a]}),C}),h={...f.layout??{}};for(const[v,C]of l){const O=n.placements[v];O&&(h[C]={...O,at:[O.at[0]+i,O.at[1]+a]})}const x=n.wires.map(v=>{const C=[u(v.ends[0]),u(v.ends[1])];return{id:at(C[0],C[1]),ends:C,...v.label?{label:v.label}:{}}}),w=$r(f.wires??[],x);return{...f,elements:[...f.elements,...m],buses:g.length?[...f.buses??[],...g]:f.buses,junctions:p.length?[...f.junctions??[],...p]:f.junctions,wires:w.length?w:void 0,layout:Object.keys(h).length?h:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:u,...f}=c;return f});return{...i,buses:a}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const l={};for(const[c,u]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:u,...f}=c;return f}return c});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const c=n.layout.get(l.id);c&&(s[l.id]=on(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,bus:l})}),Object.keys(s).length===0&&i.length===0)return o;let a=o.buses;return i.length>0&&a&&(a=a.map(l=>{const c=n.buses.get(l.id);return!l.layout&&c?{...l,layout:ut(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(c=r.buses)!=null&&c.find(m=>m.id===u&&m.layout)||a.set(u,ut(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=on(f))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const m=o.layout.get(u),g=s[u]??(m?on(m):{at:[0,0]});s[u]={...g,at:[g.at[0]+f[0],g.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const m=u.layout??ut(o.buses.get(u.id).geometry);return{...u,layout:{...m,at:[m.at[0]+f[0],m.at[1]+f[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(u=>{var g,p;const f=a.get(u.id);if(!f)return u;const m=((g=u.layout)==null?void 0:g.at)??((p=o.junctions.get(u.id))==null?void 0:p.world)??[0,0];return{...u,layout:{at:[m[0]+f[0],m[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(f=>!o.has(f.id)),i=(r.buses??[]).filter(f=>!o.has(f.id)),a=(r.junctions??[]).filter(f=>!o.has(f.id)),l=(r.wires??[]).filter(f=>!o.has(Xn(f.ends[0]))&&!o.has(Xn(f.ends[1]))),c=Wn(r.wires??[],l,a),u=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([f])=>!o.has(f))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:c.length?c:void 0,wires:l.length?l:void 0,layout:u&&Object.keys(u).length?u:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const a=i.indexOf(".");a>0&&s.add(i.slice(0,a))}t().dispatch(i=>{const a=i.wires??[],l=a.filter(f=>f.id!==n);if(l.length===a.length)return i;const c={...i.layout??{}};for(const f of s){if(c[f])continue;const m=o.layout.get(f);if(!m)continue;const g={at:m.at};m.rot&&(g.rot=m.rot),m.mirror&&(g.mirror=m.mirror),c[f]=g}const u=Wn(a,l,i.junctions??[]);return{...i,wires:l.length?l:void 0,junctions:u.length?u:void 0,layout:Object.keys(c).length?c:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const a of r.terminals){const l=a.indexOf(".");l>0&&i.add(a.slice(0,l))}t().dispatch(a=>{const l={...a.layout??{}};for(const m of i){if(l[m])continue;const g=o.layout.get(m);if(!g)continue;const p={at:g.at};g.rot&&(p.rot=g.rot),g.mirror&&(p.mirror=g.mirror),l[m]=p}const c=a.wires??[],u=c.filter(m=>!s.has(m.ends[0])&&!s.has(m.ends[1])),f=Wn(c,u,a.junctions??[]);return{...a,wires:u.length?u:void 0,junctions:f.length?f:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var c,u,f,m;const i={...s.layout??{}},a=new Map;for(const g of o){if(r.junctions.has(g))continue;if(r.buses.has(g)){const x=r.buses.get(g),v=(((((f=(u=(c=s.buses)==null?void 0:c.find(C=>C.id===g))==null?void 0:u.layout)==null?void 0:f.rot)??x.geometry.rot??0)+n)%360+360)%360;a.set(g,v);continue}const p=i[g]??{at:((m=r.layout.get(g))==null?void 0:m.at)??[0,0]},h=(((p.rot??0)+n)%360+360)%360;i[g]={...p,rot:h}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(g=>{if(!a.has(g.id))return g;const p=g.layout??ut(r.buses.get(g.id).geometry);return{...g,layout:{...p,rot:a.get(g.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a)||o.junctions.has(a))continue;const l=s[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};s[a]={...l,mirror:!(l.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=Rt(t().diagram,n);return t().dispatch(i=>{const a={id:s,kind:n,...r??{}};return{...i,elements:[...i.elements,a],layout:{...i.layout??{},[s]:{at:o}}}}),e({selection:[s]}),s},addBus:(n,o,r)=>{const s=lo(t().diagram);return t().dispatch(i=>{const a={id:s,layout:r!==void 0?{at:n,span:o,rot:r}:{at:n,span:o}};return{...i,buses:[...i.buses??[],a]}}),e({selection:[s]}),s},addJunction:n=>{const o=co(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=at(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(a=>a.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(p=>p.id),...(s.buses??[]).map(p=>p.id),...(s.junctions??[]).map(p=>p.id)]),a=()=>{let p=1;for(;i.has(`J${p}`);)p++;const h=`J${p}`;return i.add(h),h},l=p=>{const h=a();return s={...s,junctions:[...s.junctions??[],{id:h,layout:{at:p}}]},h},c=p=>{if("end"in p)return p.end;if("junctionAt"in p)return l(p.junctionAt);const h=(s.wires??[]).find(C=>C.id===p.onWire),x=l(p.at);if(!h)return x;const w=(s.wires??[]).filter(C=>C.id!==p.onWire),v=(C,O)=>({id:at(C,O),ends:[C,O],...h.label?{label:h.label}:{}});return s={...s,wires:$r(w,[v(h.ends[0],x),v(x,h.ends[1])])},x},u=c(n),f=c(o);if(u===null||f===null||u===f)return s;const m=at(u,f),g=s.wires??[];return g.some(p=>p.id===m)?s:{...s,wires:[...g,{id:m,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?Ys(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:u,...f}=c;return f});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateWire:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];return s.some(i=>i.id===n)?{...r,wires:s.map(i=>i.id===n?{...i,...o}:i)}:r})},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var a;const s=((a=r.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?ut(a.buses.get(n).geometry):{at:[0,0],span:320}),c={at:o.at??l.at,span:o.span??l.span,...o.rot!==void 0?{rot:o.rot}:l.rot?{rot:l.rot}:{}};return{...i,layout:c}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=hn(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},insertAnnotation:n=>{const o=hn(t().diagram);return t().dispatch(r=>({...r,annotations:[...r.annotations??[],{...n,id:o}]})),o},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const a=s.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...r,annotations:a}:r})},deleteAnnotation:n=>{var o;t().dispatch(r=>{const s=r.annotations??[],i=s.filter(a=>a.id!==n);return i.length===s.length?r:{...r,annotations:i.length?i:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null,editingCell:null}),((o=t().annotationPreview)==null?void 0:o.id)===n&&e({annotationPreview:null})}}),{name:"ole-editor",version:2,storage:Xs(()=>({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>{y.getState().readOnly||localStorage.setItem(e,t)},removeItem:e=>localStorage.removeItem(e)})),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=et(e.diagram))}}));function Y$(e){return Array.from(new Set(e))}function Xn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function $r(e,t){const n=new Set(e.map(r=>r.id)),o=e.slice();for(const r of t)n.has(r.id)||(n.add(r.id),o.push(r));return o}function on(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function ut(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Zw=null;function jr(e){Zw=e}function Xe(){return Zw}const yn=10;function Qw(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function de(e){return Qw()?Math.round(e/yn)*yn:e}function We(e){return[de(e[0]),de(e[1])]}const G$=30,K$=144;function ev(e,t){const n=ot[e],o=y.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=U$(r,t);if(!s){const h=tv(n),x=h?[de(t[0])-h.x,de(t[1])-h.y]:[de(t[0]),de(t[1])];return{newElementId:o.addElement(e,x),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=V$(n,l),u=Rt(r,e),f=n.terminals.find(h=>h.id===c),m=l==="x"?t[0]:a[0],g=l==="y"?t[1]:a[1],p=f?[de(m)-f.x,de(g)-f.y]:[de(t[0]),de(t[1])];return o.dispatch(h=>{const x={id:u,kind:e},w={at:p},v=`${u}.${c}`,C={id:at(i,v),ends:[i,v]};return{...h,elements:[...h.elements,x],wires:[...h.wires??[],C],layout:{...h.layout??{},[u]:w}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function U$(e,t){const n=y.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let c;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,m=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,g=Math.abs(t[1]-a[1]);c=Math.sqrt(m*m+g*g)}else{const u=a[1]-l/2,f=a[1]+l/2,m=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,g=Math.abs(t[0]-a[0]);c=Math.sqrt(g*g+m*m)}c<=G$&&(!o||c<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function V$(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,r)=>t==="x"?o.y-r.y:o.x-r.x)[0].id}function tv(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function nv(e,t){const n=y.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const g=i[0]-a/2,p=i[0]+a/2,h=Math.max(g,Math.min(p,t[0])),x=i[1],w=t[1]>=x?"s":"n";return{ref:e,world:[h,x],orientation:w,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,u=Math.max(l,Math.min(c,t[1])),f=i[0],m=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:m,isBus:!0,busId:e}}if(!e.includes(".")&&n.junctions.has(e)){const r=n.junctions.get(e),[s,i]=r.world,a=t[0]-s,l=t[1]-i,c=Math.abs(a)>=Math.abs(l)?a>=0?"e":"w":l>=0?"s":"n";return{ref:e,world:[s,i],orientation:c,isBus:!1}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const J$={n:"s",s:"n",e:"w",w:"e"};function ov(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=J$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Er(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],u=Er(c,n,t.world);u<a&&(a=u,i=c)}return i}function Er(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function Z$(e,t,n){const o=ot[e],r=y.getState(),s=r.diagram;if(!o)return null;const i=nv(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=K$,u=[de(n[0]),de(n[1])],f=ov(o,i,u),m=c?i.world:u,g=[de(m[0]-f.x),de(m[1]-f.y)],p=Rt(s,e);return r.dispatch(h=>{const x={id:p,kind:e},w={at:g},v=`${p}.${f.id}`,C=i.isBus&&i.busId?i.busId:t,O={id:at(C,v),ends:[C,v]};return{...h,elements:[...h.elements,x],wires:[...h.wires??[],O],layout:{...h.layout??{},[p]:w}}}),r.setSelection([p]),{newElementId:p,attachedToBus:i.isBus}}const Gt=9,ze=7;function jn(e,t){var s,i;const n=[],o=((s=e.element.name)==null?void 0:s.trim())||e.element.id;if(o&&n.push(o),t!=="all"||!((i=e.libraryDef)!=null&&i.params))return n;const r=e.element.params??{};for(const a of e.libraryDef.params){if(!a.showOnCanvas)continue;const l=r[a.name];l==null||l===""||n.push(`${l}${a.unit??""}`)}return n}function En(e){const t=rv(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+t.h/2+ze/3,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Q$(e,t){let n=e.x,o=e.y;switch(t.mirror&&(n=-n),t.rot){case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function Nn(e,t,n,o){const r=Q$(e,n),s=e.anchor??"start",i=rv(t.viewBox);let a=e.x-(i?i.x+i.w/2:0),l=e.y-(i?i.y+i.h/2:0);switch(n.mirror&&(a=-a),n.rot){case 90:[a,l]=[-l,a];break;case 180:[a,l]=[-a,-l];break;case 270:[a,l]=[l,-a];break}return Math.abs(a)<1e-6&&Math.abs(l)<1e-6?{world:r,textAnchor:s,dy:0}:Math.abs(a)>=Math.abs(l)?{world:r,textAnchor:a>=0?"start":"end",dy:0}:l>0?{world:r,textAnchor:"middle",dy:ze}:{world:r,textAnchor:"middle",dy:-(o-1)*Gt}}function rv(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}const Nr=8;function An(e){if(e.length<2)return null;let t=-1,n=0;for(let c=0;c<e.length-1;c++){const u=Math.hypot(e[c+1][0]-e[c][0],e[c+1][1]-e[c][1]);u>n&&(n=u,t=c)}if(t<0||n<=0)return null;const[o,r]=e[t],[s,i]=e[t+1],a=(o+s)/2,l=(r+i)/2;return Math.abs(s-o)>=Math.abs(i-r)?{world:[a,l-Nr],textAnchor:"middle"}:{world:[a+Nr,l+ze/3],textAnchor:"start"}}function ej(){const e=y(s=>s.internal.elements),t=y(s=>s.internal.layout),n=y(s=>s.internal.wireRenders),o=y(s=>{var i;return((i=s.diagram.meta)==null?void 0:i.labelMode)??"all"}),r=y(s=>s.editingElement);return d.jsxs("g",{className:"ole-annotation-layer",pointerEvents:"none",children:[Array.from(e.values()).map(s=>{var m;const i=t.get(s.element.id);if(!i||!s.libraryDef)return null;const a=s.libraryDef.label??En(s.libraryDef),l=jn(s,o),{world:c,textAnchor:u,dy:f}=Nn(a,s.libraryDef,i,Math.max(1,l.length));return r===s.element.id?d.jsx(tj,{elementId:s.element.id,currentName:((m=s.element.name)==null?void 0:m.trim())||s.element.id,world:c,anchor:u},s.element.id):o==="off"||l.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${c[0]} ${c[1]})`,children:l.map((g,p)=>d.jsx("text",{x:0,y:f+p*Gt,textAnchor:u,className:"ole-annotation-text",children:g},p))},s.element.id)}),o!=="off"&&Array.from(n.values()).map(s=>{var l;const i=(l=s.label)==null?void 0:l.trim();if(!i)return null;const a=An(s.path);return a?d.jsx("text",{x:a.world[0],y:a.world[1],textAnchor:a.textAnchor,className:"ole-annotation-text",children:i},`wire-${s.wireId}`):null})]})}const Yn=200,Gn=9;function tj({elementId:e,currentName:t,world:n,anchor:o}){const r=M.useRef(null);M.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(c)},[e]);function s(){var m;const l=y.getState(),c=l.diagram.elements.find(g=>g.id===e);if(!c){l.setEditingElement(null);return}const u=(((m=r.current)==null?void 0:m.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==c.name&&l.updateElement(e,{name:f}),l.setEditingElement(null)}function i(l){if(l.key==="Escape"||l.key==="Enter"&&!l.shiftKey){l.preventDefault(),s();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=Yn/2:o==="end"&&(a-=Yn),d.jsx("foreignObject",{x:a,y:n[1]-Gn,width:Yn,height:Gn*2.2,className:"ole-element-name-editor",children:d.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${Gn}px`,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",display:"inline-block",minWidth:"20px",lineHeight:1.1,textAlign:o==="middle"?"center":o==="end"?"right":"left",whiteSpace:"nowrap",cursor:"text"},children:t})})}function Le(e){return e.type??"text"}function nj(e){return e.type===void 0||e.type==="text"}const qe=8,oj=1.25,Kt="6 4",rj=.05,Ar=8,rn=3,gt=4,Ft=3,Ht=60,Wt=20,uo=16,fo=12,xn=10,sj=10;function ij(e,t){const n=e===""?[""]:e.split(`
218
- `);return[Math.max(20,...n.map(r=>r.length*t*.55)),n.length*t*oj]}function Ut(e){return e.points.map(([t,n])=>[e.at[0]+t,e.at[1]+n])}function To(e,t){if(!t||t==="none"||e.length<2)return[];const n=[];return(t==="end"||t==="both")&&n.push(Tr(e[e.length-2],e[e.length-1])),t==="both"&&n.push(Tr(e[1],e[0])),n}function Tr(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o)||1,s=n/r,i=o/r,a=t[0]-s*Ar,l=t[1]-i*Ar,c=-i,u=s;return[t,[a+c*rn,l+u*rn],[a-c*rn,l-u*rn]]}function Ge(e){return[Cr(e.colWidths),Cr(e.rowHeights)]}function wt(e){return sv(e.colWidths)}function vt(e){return sv(e.rowHeights)}function aj(e,t){const n=t[0]-e.at[0],o=t[1]-e.at[1],[r,s]=Ge(e);if(n<0||o<0||n>r||o>s)return null;const i=Mr(wt(e),n),a=Mr(vt(e),o);return i===null||a===null?null:[a,i]}function Mr(e,t){for(let n=0;n<e.length-1;n++)if(t>=e[n]&&t<=e[n+1])return n;return null}function sv(e){const t=[0];let n=0;for(const o of e)n+=o,t.push(n);return t}function Cr(e){return e.reduce((t,n)=>t+n,0)}function iv(e){let t=e.current[0]-e.start[0],n=e.current[1]-e.start[1];if(e.constrain){const r=Math.max(Math.abs(t),Math.abs(n));t=Math.sign(t||1)*r,n=Math.sign(n||1)*r}return{at:[Math.min(e.start[0],e.start[0]+t),Math.min(e.start[1],e.start[1]+n)],size:[Math.abs(t),Math.abs(n)]}}function av(e){return e.constrain?lv(e.start,e.current):e.current}function lv(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o);if(r===0)return t;const s=Math.PI/4,i=Math.round(Math.atan2(o,n)/s)*s;return[e[0]+Math.cos(i)*r,e[1]+Math.sin(i)*r]}function cv(e){const t=Math.abs(e.current[0]-e.start[0]),n=Math.abs(e.current[1]-e.start[1]),o=Math.min(30,Math.max(1,Math.round(t/Ht))),r=Math.min(60,Math.max(1,Math.round(n/Wt)));return{at:[Math.min(e.start[0],e.current[0]),Math.min(e.start[1],e.current[1])],cols:o,rows:r}}function dv(e,t){return{colWidths:Array.from({length:e},()=>Ht),rowHeights:Array.from({length:t},()=>Wt),cells:Array.from({length:t},()=>Array.from({length:e},()=>""))}}function lj(e){switch(e.type){case"rect":{const t=e;return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+t.size[0],maxY:t.at[1]+t.size[1]}}case"line":{const t=Ut(e),n=t.map(r=>r[0]),o=t.map(r=>r[1]);return{minX:Math.min(...n),minY:Math.min(...o),maxX:Math.max(...n),maxY:Math.max(...o)}}case"table":{const t=e,[n,o]=Ge(t);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+n,maxY:t.at[1]+o}}default:{const t=e,n=t.fontSize??qe,[o,r]=ij(t.text,n);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+o,maxY:t.at[1]+r}}}}const yt=qe,bn=1.25;function cj(){const e=y(s=>s.diagram.annotations),t=y(s=>s.selectedAnnotation),n=y(s=>s.editingAnnotation),o=y(s=>s.editingCell),r=y(s=>s.annotationPreview);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(s=>{const i=(r==null?void 0:r.id)===s.id?r:s,a=t===s.id;switch(Le(i)){case"rect":return d.jsx(dj,{ann:i,isSelected:a},s.id);case"line":return d.jsx(uj,{ann:i,isSelected:a},s.id);case"table":return d.jsx(fj,{ann:i,isSelected:a,editingCell:n===s.id?o:null},s.id);default:return n===s.id?d.jsx(pj,{ann:i},s.id):d.jsx(mj,{ann:i,isSelected:a},s.id)}})})}function dj({ann:e,isSelected:t}){const[n,o]=e.at,[r,s]=e.size,i=(e.stroke??"dashed")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-rect","data-selected":t?"true":void 0,children:[e.fill==="tint"&&d.jsx("rect",{className:"ole-ann-fill",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-shape-hit",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-rect-border",x:n,y:o,width:r,height:s,strokeDasharray:i}),e.label&&d.jsx("text",{className:"ole-ann-label",x:n+gt,y:o+gt+yt*.85,fontSize:yt,children:e.label})]})}function uj({ann:e,isSelected:t}){const n=Ut(e),o=n.map(s=>`${s[0]},${s[1]}`).join(" "),r=(e.stroke??"solid")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-line-group","data-selected":t?"true":void 0,children:[d.jsx("polyline",{className:"ole-ann-shape-hit",points:o}),d.jsx("polyline",{className:"ole-ann-line",points:o,strokeDasharray:r}),To(n,e.arrow).map((s,i)=>d.jsx("polygon",{className:"ole-ann-arrow",points:s.map(a=>`${a[0]},${a[1]}`).join(" ")},i))]})}function fj({ann:e,isSelected:t,editingCell:n}){var g;const[o,r]=e.at,[s,i]=Ge(e),a=wt(e),l=vt(e),c=e.fontSize??yt;let u="";for(let p=1;p<e.colWidths.length;p++)u+=`M${o+a[p]} ${r}V${r+i}`;for(let p=1;p<e.rowHeights.length;p++)u+=`M${o} ${r+l[p]}H${o+s}`;const f=[],m=[];for(let p=0;p<e.rowHeights.length;p++)for(let h=0;h<e.colWidths.length;h++){const x=((g=e.cells[p])==null?void 0:g[h])??"";if(x==="")continue;const w=e.colWidths[h],v=o+a[h]+Ft,C=r+l[p]+e.rowHeights[p]/2+c*.35,O=x.length*c*.55>w-2*Ft,F=`ole-ann-clip-${e.id}-${p}-${h}`;O&&m.push(d.jsx("clipPath",{id:F,children:d.jsx("rect",{x:o+a[h],y:r+l[p],width:w,height:e.rowHeights[p]})},F)),f.push(d.jsx("text",{className:"ole-ann-table-text",x:v,y:C,fontSize:c,clipPath:O?`url(#${F})`:void 0,children:x},`${p}-${h}`))}return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-table","data-selected":t?"true":void 0,children:[m.length>0&&d.jsx("defs",{children:m}),d.jsx("rect",{className:"ole-ann-table-bg",x:o,y:r,width:s,height:i}),u&&d.jsx("path",{className:"ole-ann-table-grid",d:u}),d.jsx("rect",{className:"ole-ann-table-border",x:o,y:r,width:s,height:i}),f,n&&d.jsx(hj,{ann:e,cell:n})]})}function hj({ann:e,cell:t}){var g;const[n,o]=t,r=M.useRef(null),s=wt(e),i=vt(e),a=e.fontSize??yt,l=((g=e.cells[n])==null?void 0:g[o])??"";M.useEffect(()=>{const p=r.current;p&&(p.focus(),p.select())},[n,o]);function c(){var x;const p=y.getState(),h=((x=r.current)==null?void 0:x.value)??"";if(h!==l){const w=e.cells.map(v=>[...v]);for(;w.length<=n;)w.push([]);w[n][o]=h,p.updateAnnotation(e.id,{cells:w})}}function u(){y.getState().setEditingAnnotation(null)}function f(p,h){const x=e.rowHeights.length,w=e.colWidths.length;if(h>=w?(h=0,p+=1):h<0&&(h=w-1,p-=1),p<0||p>=x){u();return}y.getState().setEditingCell([p,h])}function m(p){if(p.key==="Enter"){p.preventDefault(),c(),f(n+1,o);return}if(p.key==="Tab"){p.preventDefault(),c(),f(n,p.shiftKey?o-1:o+1);return}if(p.key==="Escape"){p.preventDefault(),r.current&&(r.current.value=l),c(),u();return}p.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0]+s[o],y:e.at[1]+i[n],width:e.colWidths[o],height:e.rowHeights[n],className:"ole-ann-cell-edit-fo",children:d.jsx("input",{ref:r,defaultValue:l,onBlur:()=>{c(),u()},onKeyDown:m,onPointerDown:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1px solid var(--selection)",outline:"none",background:"var(--canvas-bg)",color:"var(--foreground)",font:`${a}px ui-sans-serif, system-ui, sans-serif`,padding:`0 ${Ft}px`}},`${n}-${o}`)})}function mj({ann:e,isSelected:t}){const n=e.fontSize??yt,o=e.text===""?[""]:e.text.split(`
219
- `),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*bn;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[d.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&d.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,className:"ole-free-annotation-halo"}),o.map((i,a)=>d.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*bn,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function pj({ann:e}){const t=M.useRef(null),n=e.fontSize??yt;M.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)},[e.id]);function o(){var c;const a=y.getState(),l=(((c=t.current)==null?void 0:c.innerText)??"").replace(/\u00a0/g," ").trimEnd();l===""?a.deleteAnnotation(e.id):l!==e.text&&a.updateAnnotation(e.id,{text:l}),a.setEditingAnnotation(null),l!==""&&a.setSelectedAnnotation(e.id),a.activeTool==="text"&&a.setActiveTool("select")}function r(a){if(a.key==="Escape"){a.preventDefault(),t.current&&(t.current.innerText=e.text),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:d.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:bn,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",minWidth:`${n}px`,minHeight:`${n*bn}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}function gj(){const e=y(a=>a.annotationDraft);if(!e)return null;if(e.kind==="rect"){const{at:a,size:l}=iv(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("rect",{x:a[0],y:a[1],width:l[0],height:l[1],strokeDasharray:Kt})})}if(e.kind==="line"){const a=av(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("line",{x1:e.start[0],y1:e.start[1],x2:a[0],y2:a[1]})})}const{at:t,cols:n,rows:o}=cv(e),r=n*Ht,s=o*Wt,i=[];for(let a=1;a<n;a++){const l=t[0]+a*Ht;i.push(d.jsx("line",{x1:l,y1:t[1],x2:l,y2:t[1]+s},`c${a}`))}for(let a=1;a<o;a++){const l=t[1]+a*Wt;i.push(d.jsx("line",{x1:t[0],y1:l,x2:t[0]+r,y2:l},`r${a}`))}return d.jsxs("g",{className:"ole-ann-draft",pointerEvents:"none",children:[d.jsx("rect",{x:t[0],y:t[1],width:r,height:s}),i,d.jsxs("text",{className:"ole-ann-draft-badge",x:e.current[0]+12,y:e.current[1]-8,children:[n," × ",o]})]})}const sn=7,wn=3;function yj(){const e=y(i=>i.selectedAnnotation),t=y(i=>i.diagram.annotations),n=y(i=>i.annotationPreview);if(y(i=>i.readOnly)||!e)return null;const r=(t??[]).find(i=>i.id===e);if(!r)return null;const s=(n==null?void 0:n.id)===e?n:r;switch(Le(s)){case"rect":return d.jsx(xj,{ann:s,model:r});case"table":return d.jsx(wj,{ann:s,model:r});case"line":return d.jsx(Sj,{ann:s,model:r});default:return null}}function Vt(e,t,n){const o=M.useRef(null);return{onPointerDown:l=>{if(l.button!==0)return;l.stopPropagation(),l.preventDefault();const c=Xe();c&&(o.current={pointerId:l.pointerId,startSvg:c.screenToSvg(l.clientX,l.clientY),orig:structuredClone(e)},l.target.setPointerCapture(l.pointerId))},onPointerMove:l=>{const c=o.current,u=Xe();if(!c||l.pointerId!==c.pointerId||!u)return;const f=u.screenToSvg(l.clientX,l.clientY),m=de(f[0]-c.startSvg[0]),g=de(f[1]-c.startSvg[1]);y.getState().setAnnotationPreview(t(c.orig,m,g,l.nativeEvent))},onPointerUp:l=>{const c=o.current;if(!c||l.pointerId!==c.pointerId)return;o.current=null;const u=l.target;u.hasPointerCapture(l.pointerId)&&u.releasePointerCapture(l.pointerId);const f=y.getState(),m=f.annotationPreview;f.setAnnotationPreview(null),m&&m.id===e.id&&f.updateAnnotation(e.id,n(m))},onPointerCancel:l=>{const c=o.current;!c||l.pointerId!==c.pointerId||(o.current=null,y.getState().setAnnotationPreview(null))}}}function uv(e,t,n,o,r,s,i,a){let[l,c]=e,[u,f]=t;return n===1&&(u=Math.max(i,t[0]+r)),n===-1&&(u=Math.max(i,t[0]-r),l=e[0]+t[0]-u),o===1&&(f=Math.max(a,t[1]+s)),o===-1&&(f=Math.max(a,t[1]-s),c=e[1]+t[1]-f),{at:[l,c],size:[u,f]}}const fv=[{dirX:-1,dirY:-1,cursor:"nwse-resize"},{dirX:0,dirY:-1,cursor:"ns-resize"},{dirX:1,dirY:-1,cursor:"nesw-resize"},{dirX:1,dirY:0,cursor:"ew-resize"},{dirX:1,dirY:1,cursor:"nwse-resize"},{dirX:0,dirY:1,cursor:"ns-resize"},{dirX:-1,dirY:1,cursor:"nesw-resize"},{dirX:-1,dirY:0,cursor:"ew-resize"}];function hv(e,t,n,o){const r=n===-1?e[0]:n===1?e[0]+t[0]:e[0]+t[0]/2,s=o===-1?e[1]:o===1?e[1]+t[1]:e[1]+t[1]/2;return[r,s]}function mv({pos:e,cursor:t,handlers:n}){return d.jsx("rect",{className:"ole-annotation-handle",x:e[0]-sn/2,y:e[1]-sn/2,width:sn,height:sn,style:{cursor:t},onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onPointerCancel:n.onPointerCancel})}function xj({ann:e,model:t}){return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:fv.map((n,o)=>d.jsx(bj,{grip:n,ann:e,model:t},o))})}function bj({grip:e,ann:t,model:n}){const o=Vt(n,(r,s,i)=>{const a=uv(r.at,r.size,e.dirX,e.dirY,s,i,xn,xn);return{...r,at:a.at,size:a.size}},r=>({at:r.at,size:r.size}));return d.jsx(mv,{pos:hv(t.at,t.size,e.dirX,e.dirY),cursor:e.cursor,handlers:o})}function wj({ann:e,model:t}){const n=Ge(e),o=wt(e),r=vt(e);return d.jsxs("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:[o.slice(1,-1).map((s,i)=>d.jsx(kj,{index:i,x:e.at[0]+s,ann:e,model:t},`c${i}`)),r.slice(1,-1).map((s,i)=>d.jsx(_j,{index:i,y:e.at[1]+s,ann:e,model:t},`r${i}`)),fv.map((s,i)=>d.jsx(vj,{grip:s,ann:e,model:t,size:n},i))]})}function vj({grip:e,ann:t,model:n,size:o}){const r=Vt(n,(s,i,a)=>{const l=Ge(s),c=uv(s.at,l,e.dirX,e.dirY,i,a,uo*s.colWidths.length,fo*s.rowHeights.length),u=Pr(s.colWidths,c.size[0]/l[0],uo),f=Pr(s.rowHeights,c.size[1]/l[1],fo),m=u.reduce((h,x)=>h+x,0),g=f.reduce((h,x)=>h+x,0),p=[e.dirX===-1?s.at[0]+l[0]-m:s.at[0],e.dirY===-1?s.at[1]+l[1]-g:s.at[1]];return{...s,at:p,colWidths:u,rowHeights:f}},s=>({at:s.at,colWidths:s.colWidths,rowHeights:s.rowHeights}));return d.jsx(mv,{pos:hv(t.at,o,e.dirX,e.dirY),cursor:e.cursor,handlers:r})}function Pr(e,t,n){return e.map(o=>Math.max(n,Math.round(o*t)))}function kj({index:e,x:t,ann:n,model:o}){const[,r]=Ge(n),s=Vt(o,(i,a)=>{const l=[...i.colWidths];return l[e]=Math.max(uo,i.colWidths[e]+a),{...i,colWidths:l}},i=>({colWidths:i.colWidths}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:t-wn,y:n.at[1],width:wn*2,height:r,style:{cursor:"col-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function _j({index:e,y:t,ann:n,model:o}){const[r]=Ge(n),s=Vt(o,(i,a,l)=>{const c=[...i.rowHeights];return c[e]=Math.max(fo,i.rowHeights[e]+l),{...i,rowHeights:c}},i=>({rowHeights:i.rowHeights}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:n.at[0],y:t-wn,width:r,height:wn*2,style:{cursor:"row-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function Sj({ann:e,model:t}){const n=Ut(e);return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:n.map((o,r)=>d.jsx($j,{index:r,pos:o,model:t},r))})}function $j({index:e,pos:t,model:n}){const o=Vt(n,(r,s,i,a)=>{const l=r.points.map(u=>[...u]);let c=[r.points[e][0]+s,r.points[e][1]+i];if(a.shiftKey){const u=r.points[e-1]??r.points[e+1]??[0,0];c=lv(u,c)}return l[e]=c,{...r,points:l}},r=>({points:r.points}));return d.jsx("circle",{className:"ole-annotation-handle",cx:t[0],cy:t[1],r:4.5,style:{cursor:"move"},onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel})}const jj=20;function Ej(){const e=y(u=>u.selection),t=y(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,a=i/2,l=r==="x"?[s[0]-a,s[1]]:[s[0],s[1]-a],c=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(Ir,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(Ir,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function Ir({x:e,y:t,busId:n,side:o,axis:r}){const s=Xe(),i=M.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=y.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const m=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?m[0]-f.startSvg[0]:m[1]-f.startSvg[1],p=Qw()?Math.round(g/yn)*yn:g,h=f.startSpan+(o==="end"?p:-p);if(h<jj)return;const x=r==="x"?[f.startAt[0]+p/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+p/2];y.getState().updateBus(n,{span:h,at:x})},c=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const ho=.5;function Bt(e,t){return Math.abs(e[1]-t[1])<ho?"h":"v"}function Nj(){const e=y(a=>a.selectedWire),t=y(a=>a.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let a=1;a<r-1;a++){const l=Bt(o[a-1],o[a]),c=Bt(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,m=u&&l==="v"||f&&c==="v",g=u&&l==="h"||f&&c==="h";m&&g||s.push(d.jsx(Aj,{wireId:e,index:a,xLocked:m,yLocked:g},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<ho&&Math.abs(l[1]-c[1])<ho||i.push(d.jsx(Tj,{wireId:e,segIndex:a,axis:Bt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function Aj({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Xe(),s=M.useRef(null),i=y(p=>{var h;return(h=p.internal.wireRenders.get(e))==null?void 0:h.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=p=>{if(p.button!==0||(p.stopPropagation(),p.preventDefault(),!r))return;const h=y.getState().internal.wireRenders.get(e);h&&(s.current={pointerId:p.pointerId,startPath:h.path.map(x=>[x[0],x[1]]),startSvg:r.screenToSvg(p.clientX,p.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,p.target.setPointerCapture(p.pointerId))},f=p=>{const h=s.current;if(!h||p.pointerId!==h.pointerId||!r)return;const x=r.screenToSvg(p.clientX,p.clientY),w=h.startPath,v=h.index;if(v<=0||v>=w.length-1)return;const C=w[v],O=[h.xLocked?C[0]:de(C[0]+(x[0]-h.startSvg[0])),h.yLocked?C[1]:de(C[1]+(x[1]-h.startSvg[1]))];if(O[0]===C[0]&&O[1]===C[1])return;const F=w.map(H=>[H[0],H[1]]);F[v]=O;const G=Bt(w[v-1],w[v]);v-1>0&&(G==="h"?F[v-1]=[w[v-1][0],O[1]]:F[v-1]=[O[0],w[v-1][1]]);const $=Bt(w[v],w[v+1]);v+1<w.length-1&&($==="h"?F[v+1]=[w[v+1][0],O[1]]:F[v+1]=[O[0],w[v+1][1]]),y.getState().updateWirePath(e,F)},m=p=>{const h=s.current;!h||p.pointerId!==h.pointerId||(p.target.hasPointerCapture(p.pointerId)&&p.target.releasePointerCapture(p.pointerId),s.current=null,document.body.style.cursor="")},g=p=>{p.stopPropagation(),p.preventDefault();const h=y.getState().internal.wireRenders.get(e);if(!h||h.path.length<=2||t<=0||t>=h.path.length-1)return;const x=h.path.filter((w,v)=>v!==t);y.getState().updateWirePath(e,x)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:u,onPointerMove:f,onPointerUp:m,onPointerCancel:m,onDoubleClick:g})}function Tj({wireId:e,segIndex:t,axis:n}){const o=Xe(),r=M.useRef(null),s=y(p=>{var h;return(h=p.internal.wireRenders.get(e))==null?void 0:h.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,c=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=p=>{if(p.button!==0||(p.stopPropagation(),p.preventDefault(),!o))return;const h=y.getState().internal.wireRenders.get(e);h&&(r.current={pointerId:p.pointerId,startPath:h.path.map(x=>[x[0],x[1]]),startSvg:o.screenToSvg(p.clientX,p.clientY),axis:n,segIndex:t},document.body.style.cursor=u,p.currentTarget.setPointerCapture(p.pointerId))},m=p=>{const h=r.current;if(!h||p.pointerId!==h.pointerId||!o)return;const x=o.screenToSvg(p.clientX,p.clientY),w=h.startPath,v=h.segIndex;if(v>=w.length-1)return;const C=w[v],O=w[v+1],F=[];for(let G=0;G<=v;G++)F.push(w[G]);if(h.axis==="h"){const G=de(C[1]+(x[1]-h.startSvg[1]));F.push([C[0],G]),F.push([O[0],G])}else{const G=de(C[0]+(x[0]-h.startSvg[0]));F.push([G,C[1]]),F.push([G,O[1]])}for(let G=v+1;G<w.length;G++)F.push(w[G]);y.getState().updateWirePath(e,F)},g=p=>{const h=r.current;if(!h||p.pointerId!==h.pointerId)return;const x=p.currentTarget;x.hasPointerCapture(p.pointerId)&&x.releasePointerCapture(p.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:m,onPointerUp:g,onPointerCancel:g,children:[d.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:c,r:8}),d.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:c,r:3.5})]})}const Mj=3,Kn=12;function Cj(){const e=y(a=>a.internal.buses),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)!l.includes(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:u,span:f}=l,m=f/2,g=c==="x"?u[0]-m:u[0],p=c==="x"?u[1]:u[1]-m,h=c==="x"?u[0]+m:u[0],x=c==="x"?u[1]:u[1]+m,w=s.has(a.id),v=i.has(a.id),C=r.get(a.id)??void 0,O=Kn/2,F=c==="x"?u[0]-m:u[0]-O,G=c==="x"?u[1]-O:u[1]-m,$=c==="x"?f:Kn,H=c==="x"?Kn:f;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":C,"data-selected":w?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:F,y:G,width:$,height:H,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:g,y1:p,x2:h,y2:x,stroke:"currentColor",strokeWidth:Mj,strokeLinecap:"round",fill:"none"})]},a.id)})})}function Pj(){const e=y(a=>a.busbarDrawStart),t=y(a=>a.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return d.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[d.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),d.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),d.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const Ij=2.5,Oj=9,Bj=13,Lj=-13,Dj=4.5,zj=8;function Rj(){const e=y(a=>a.internal.junctions),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)i.add(l)}return d.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l,degree:c})=>{const u=r.get(a.id)??void 0,f=t.length===1&&t[0]===a.id,m=l[0]+Bj,g=l[1]+Lj;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":u,"data-solder":c>=3?"true":void 0,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[d.jsx("circle",{cx:l[0],cy:l[1],r:Oj,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:Ij,className:"ole-junction-dot"}),f&&d.jsxs("g",{className:"ole-junction-wire-handle-group",children:[d.jsx("line",{x1:l[0],y1:l[1],x2:m,y2:g,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:m,cy:g,r:zj,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:m,cy:g,r:Dj,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function nt(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function Fj(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function Hj({lib:e}){const t=Fj(e.viewBox);return t?d.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function Wj(){const e=y(a=>a.internal.elements),t=y(a=>a.internal.layout),n=y(a=>a.selection),o=y(a=>a.selectedNode),r=y(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const c=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:nt(l),className:"ole-element",children:[d.jsx(Hj,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}}),a.libraryDef.terminalLabelsSvg&&d.jsx("g",{className:"ole-terminal-labels",dangerouslySetInnerHTML:{__html:a.libraryDef.terminalLabelsSvg}})]},a.element.id):d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:nt(l),className:"ole-element ole-element--unknown",children:[d.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),d.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let pv=null;const mo=new Set;function an(e){pv=e;for(const t of mo)t(e)}function qj(){return pv}function Xj(e){return mo.add(e),()=>{mo.delete(e)}}function Yj(){const[e,t]=M.useState(qj());return M.useEffect(()=>Xj(t),[]),!e||e.w===0&&e.h===0?null:d.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function Gj(){const e=y(c=>c.activeTool),t=y(c=>c.placeKind),n=y(c=>c.cursorSvg),o=y(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Jw(t);if(!r)return null;let s=null,i=null;if(o){const c=nv(o,n);c&&(s=ov(r,c,n),i={source:c.world,pin:n})}else s=tv(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return d.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),d.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),d.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:d.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function Kj(){const e=y(r=>r.selection),t=y(r=>r.internal.elements),n=y(r=>r.internal.layout),o=y(r=>r.internal.buses);return e.length===0?null:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:u,span:f}=s.geometry,m=f/2,g=c==="x"?u[0]-m:u[0]-4,p=c==="x"?u[1]-4:u[1]-m,h=c==="x"?f:8,x=c==="x"?8:f;return d.jsx("rect",{x:g,y:p,width:h,height:x,fill:"none",className:"ole-selection-rect"},r)}const i=t.get(r),a=n.get(r);if(!(i!=null&&i.libraryDef)||!a)return null;const l=Uj(i.libraryDef.viewBox);return l?d.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:nt(a)},r):null})})}function Uj(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function Vj(){const e=y(s=>s.internal.terminals),t=y(s=>s.internal.terminalToNode),n=y(s=>s.wireFromTerminal),o=y(s=>s.selection),r=new Set(o);return d.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),a=i!==void 0,l=n===s.ref,c=r.has(s.elementId);return d.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":a?"true":"false","data-active":l?"true":void 0,"data-on-selected":c?"true":void 0,className:"ole-terminal"},s.ref)})})}const Or=4;function Jj(e,t,n,o){const r=t[0]-e[0],s=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=r*a-s*i;if(Math.abs(l)<1e-9)return null;const c=((n[0]-e[0])*a-(n[1]-e[1])*i)/l,u=((n[0]-e[0])*s-(n[1]-e[1])*r)/l,f=1e-6;return c<=f||c>=1-f||u<=f||u>=1-f?null:[e[0]+c*r,e[1]+c*s]}function Zj(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],u=Math.hypot(l,c)||1,f=l/u,m=c/u,g=h=>(h[0]-s[0])*f+(h[1]-s[1])*m,p=a.slice().sort((h,x)=>g(h)-g(x));for(const h of p){const x=g(h),w=Math.max(0,x-Or),v=Math.min(u,x+Or);o.push([s[0]+f*w,s[1]+m*w]),n.push(o),o=[[s[0]+f*v,s[1]+m*v]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function Qj(){const e=y(c=>c.internal.wireRenders),t=y(c=>c.internal.terminalToNode),n=y(c=>c.diagram.wires),o=y(c=>c.selectedWire),r=y(c=>c.selectedNode),s=new Map;for(const c of n??[]){const u=t.get(c.ends[0]);u&&s.set(c.id,u)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const u=s.get(c.wireId);for(let f=0;f<c.path.length-1;f++)a.push({wireId:c.wireId,node:u,i:f,a:c.path[f],b:c.path[f+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const f=a[c],m=a[u];if(f.wireId===m.wireId||!(f.node&&m.node&&f.node!==m.node))continue;const g=Jj(f.a,f.b,m.a,m.b);if(!g)continue;const p=f.wireId<m.wireId?f:m;let h=l.get(p.wireId);h||(h=new Map,l.set(p.wireId,h));const x=h.get(p.i)??[];x.push(g),h.set(p.i,x)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const u=c.path,f=u.map(v=>`${v[0]},${v[1]}`).join(" "),m=s.get(c.wireId),g=o===c.wireId,p=r!=null&&r===m,h=g||p?"true":void 0,x=l.get(c.wireId),w=x?Zj(u,x):[u];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,className:"ole-wire-hit",points:f},`hit-${c.wireId}`),...w.map((v,C)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":m,"data-manual":c.userEdited?"true":void 0,"data-selected":h,className:"ole-wire",points:v.map(O=>`${O[0]},${O[1]}`).join(" ")},`${c.wireId}-${C}`))]})})}let it=null;const po=new Set;function tt(e){if(!(e===null&&it===null||e&&it&&e.ref===it.ref&&e.world[0]===it.world[0]&&e.world[1]===it.world[1])){it=e;for(const t of po)t(e)}}function e4(){return it}function t4(e){return po.add(e),()=>{po.delete(e)}}function n4(){const e=y(l=>l.wireDragFrom),t=y(l=>l.cursorSvg),[n,o]=M.useState(e4());if(M.useEffect(()=>t4(o),[]),!e||!t)return null;const r=e.world,s=(n==null?void 0:n.world[0])??t[0],i=(n==null?void 0:n.world[1])??t[1],a=(n==null?void 0:n.create)==="junction";return d.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[d.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?7:8,className:"ole-wire-preview-target-ring","data-create":a?"true":void 0}),!a&&d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function lt(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function xt(e){var t;return((t=lt(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function o4(e){var t;return((t=lt(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function r4(e){var t;return((t=lt(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function Tn(e){var r;const t=(r=lt(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=r4(e);if(n)return n;const o=o4(e);return o||null}function Mn(e){var t;return((t=lt(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function go(e){var t;return((t=lt(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function qt(e){var t;return((t=lt(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function gv(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function s4(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function yv(){const e=y.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable], .ole-ann-cell-edit-fo input");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"||t==="rect"||t==="line"||t==="table"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function i4(){M.useEffect(()=>{const e=t=>{if(s4(t.target)||y.getState().readOnly)return;const n=t.metaKey||t.ctrlKey,o=y.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=y.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase(),s=o.selection.length>0||o.selectedAnnotation!=null;if(r==="c"){if(!s)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(!s)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"j":case"J":o.setActiveTool("junction");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"f":case"F":o.setActiveTool("rect");return;case"l":case"L":o.setActiveTool("line");return;case"d":case"D":o.setActiveTool("table");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":yv();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let yo=null;const xo=new Set;function a4(e){if(e!==yo){yo=e;for(const t of xo)t(e)}}function l4(){return yo}function c4(e){return xo.add(e),()=>{xo.delete(e)}}const Br="ole-hover-element-host",d4="ole-hover-terminal-on",u4="ole-hover-node-on";function f4(e){M.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,m,g)=>{for(const p of f)p.classList.remove(g);f.clear();for(const p of m)p.classList.add(g),f.add(p)},a=f=>{var g,p;if(f===n)return;n&&((g=t.querySelector(`[data-element-id="${ln(n)}"]`))==null||g.classList.remove(Br)),f&&((p=t.querySelector(`[data-element-id="${ln(f)}"]`))==null||p.classList.add(Br));const m=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${ln(f)}"]`)):[];i(r,m,d4),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),a4(f)},l=f=>{if(f===o)return;const m=f?Array.from(t.querySelectorAll(`[data-node-id="${ln(f)}"]`)):[];i(s,m,u4),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=f=>{a(xt(f.target));const m=Tn(f.target);let g=null;m?g=y.getState().internal.terminalToNode.get(m)??null:g=Mn(f.target),l(g)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function ln(e){return e.replace(/(["\\])/g,"\\$1")}function h4(e,t){const n=y.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const m=a[0]-l/2,g=a[0]+l/2,p=Math.max(m,Math.min(g,t[0]));return{ref:e,world:[p,a[1]],isBus:!0}}const c=a[1]-l/2,u=a[1]+l/2,f=Math.max(c,Math.min(u,t[1]));return{ref:e,world:[a[0],f],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const Lr=10,cn=e=>Math.round(e/Lr)*Lr,m4=16;function xv(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,u=l-i,f=c*c+u*u,m=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*u)/f)),g=s+m*c,p=i+m*u,h=(g-t[0])**2+(p-t[1])**2;h<o&&(o=h,n=[g,p])}return n}function vn(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function p4(e,t){const n=y.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=xv(s.path,e),a=Math.hypot(i[0]-e[0],i[1]-e[1]);a<=r&&(r=a,o={wireId:s.wireId,at:i})}return o}function Lt(e,t,n){const o=e?Tn(e):null;if(o){const a=h4(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?go(e):null,s=null;if(r){const a=y.getState().internal.wireRenders.get(r);s=a?xv(a.path,t):t}else{const a=p4(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[cn(s[0]),cn(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[cn(t[0]),cn(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Dt(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+m4,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function bv(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function kn(e,t){return e.ref&&t.ref?e.ref===t.ref:!e.ref&&!t.ref?e.world[0]===t.world[0]&&e.world[1]===t.world[1]:!1}const Dr=3;let he=null,Ce=null,Ne=null,pe=null;const g4={id:"select",cursor:"default",onPointerDown(e,t){var p,h,x,w,v,C,O,F,G,$,H,W;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle, .ole-annotation-handle"))return;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const X=(p=n.diagram.annotations)==null?void 0:p.find(R=>R.id===o);if(!X)return;const P=n.selectedAnnotation===o;n.setSelectedAnnotation(o),pe={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[X.at[0],X.at[1]],moved:!1,wasSelected:P};return}const r=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(r){const X=(h=r.closest("[data-junction-id]"))==null?void 0:h.getAttribute("data-junction-id");if(X){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((w=(x=e.target).hasPointerCapture)!=null&&w.call(x,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(X);const P=(v=n.internal.junctions.get(X))==null?void 0:v.world;P&&n.setWireDragFrom({spec:{end:X},world:P,ref:X}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:X};return}}const i=(e.target instanceof Element?(C=e.target.closest("[data-terminal-id]"))==null?void 0:C.getAttribute("data-terminal-id"):null)?Tn(e.target):null;if(i){const X=i.indexOf("."),P=X>0?i.slice(0,X):"";if(P&&n.selection.includes(P)){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(i);const R=(G=n.internal.terminals.get(i))==null?void 0:G.world;R&&n.setWireDragFrom({spec:{end:i},world:R,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:i};return}}let a=xt(e.target);if(!a){const X=go(e.target);if(X&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const R of P){const Z=(H=($=R.closest)==null?void 0:$.call(R,"[data-bus-id]"))==null?void 0:H.getAttribute("data-bus-id");if(!Z)continue;const ie=(W=n.diagram.wires)==null?void 0:W.find(ue=>ue.id===X);ie&&(ie.ends[0]===Z||ie.ends[1]===Z)&&(a=Z);break}}}if(!a){const X=go(e.target);if(X){if(e.preventDefault(),e.altKey){const P=Mn(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(X);return}e.shiftKey||n.clearSelection(),Ce={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const l=n.selection;e.shiftKey?n.toggleInSelection(a):l.includes(a)||n.setSelection([a]);const c=e.shiftKey?y.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const u=y.getState().internal,f=new Map,m=new Map,g=new Map;for(const X of c){const P=u.buses.get(X);if(P){m.set(X,[P.geometry.at[0],P.geometry.at[1]]);continue}const R=u.junctions.get(X);if(R){g.set(X,[R.world[0],R.world[1]]);continue}const Z=u.layout.get(X);Z&&f.set(X,{...Z})}f.size===0&&m.size===0&&g.size===0||(he={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:f,busOriginals:m,junctionOriginals:g,moved:!1},e.preventDefault())},onPointerMove(e,t){if(pe&&e.pointerId===pe.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-pe.startSvg[0]),r=de(n[1]-pe.startSvg[1]);!pe.moved&&(o!==0||r!==0)&&(pe.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Ne&&e.pointerId===Ne.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg(n);const o=vn(e.clientX,e.clientY),r=Lt(o,n,Dt(t,e.clientX,e.clientY)),s={spec:{end:Ne.fromRef},world:[0,0],ref:Ne.fromRef};tt(kn(s,r)?null:bv(r));return}if(he&&e.pointerId===he.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-he.startSvg[0]),r=de(n[1]-he.startSvg[1]);!he.moved&&(o!==0||r!==0)&&(he.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of he.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",nt(l))}for(const s of he.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of he.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Ce&&e.pointerId===Ce.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);an(Rr(Ce.startSvg,n));return}},onPointerUp(e,t){var n;if(pe&&e.pointerId===pe.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-pe.startSvg[0]),s=de(o[1]-pe.startSvg[1]),i=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(i&&i.removeAttribute("transform"),pe.moved&&(r!==0||s!==0))y.getState().updateAnnotation(pe.id,{at:[pe.origin[0]+r,pe.origin[1]+s]});else if(!pe.moved&&pe.wasSelected){const a=y.getState(),l=(n=a.diagram.annotations)==null?void 0:n.find(c=>c.id===pe.id);l&&zr(a,l,o)}pe=null;return}if(Ne&&e.pointerId===Ne.pointerId){const o=y.getState(),r=Ne.fromRef;Ne=null,t.hostEl.classList.remove("tool-wire"),o.setWireFromTerminal(null),o.setWireDragFrom(null),o.setCursorSvg(null),tt(null);const s=t.viewport.screenToSvg(e.clientX,e.clientY),i=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),a=Lt(i,s,Dt(t,e.clientX,e.clientY));if(kn({world:[0,0],ref:r},a))return;o.connectWire({end:r},a.spec);return}if(he&&e.pointerId===he.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),he.moved){const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-he.startSvg[0]),s=de(o[1]-he.startSvg[1]);if(r!==0||s!==0){const i=new Map;for(const a of he.originals.keys())i.set(a,[r,s]);for(const a of he.busOriginals.keys())i.set(a,[r,s]);for(const a of he.junctionOriginals.keys())i.set(a,[r,s]);y.getState().moveElements(i)}for(const i of he.busOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}for(const i of he.junctionOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}}he=null;return}if(Ce&&e.pointerId===Ce.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=Rr(Ce.startSvg,o);if(r.w>=Dr||r.h>=Dr){const s=y4(r);if(Ce.shiftKey){const i=new Set(Ce.baseSelection);for(const a of s)i.has(a)?i.delete(a):i.add(a);y.getState().setSelection([...i])}else y.getState().setSelection(s)}an(null),Ce=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(pe&&e.pointerId===pe.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}pe=null}if(he&&e.pointerId===he.pointerId){for(const[l,c]of he.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",nt(c))}for(const l of he.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of he.junctionOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}he=null}if(Ne&&e.pointerId===Ne.pointerId){t.hostEl.classList.remove("tool-wire");const l=y.getState();l.setWireFromTerminal(null),l.setWireDragFrom(null),l.setCursorSvg(null),tt(null),Ne=null}if(Ce&&e.pointerId===Ce.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}an(null),Ce=null}},onDoubleClick(e,t){var s;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const i=(s=n.diagram.annotations)==null?void 0:s.find(a=>a.id===o);if(!i)return;n.setSelectedAnnotation(o),zr(n,i,t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=xt(e.target);r&&(e.preventDefault(),e.stopPropagation(),n.setEditingElement(r))},onDeactivate(e){if(he=null,Ce=null,pe=null,Ne){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(null),Ne=null}an(null)}};function zr(e,t,n){const o=Le(t);if(o==="table"){const r=aj(t,n);r&&(e.setEditingAnnotation(t.id),e.setEditingCell(r))}else o==="text"&&e.setEditingAnnotation(t.id)}function Rr(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),r=Math.abs(t[0]-e[0]),s=Math.abs(t[1]-e[1]);return{x:n,y:o,w:r,h:s}}function y4(e){const{internal:t}=y.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=b4(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([f,m])=>x4([f,m],r));let a=1/0,l=-1/0,c=1/0,u=-1/0;for(const[f,m]of i)f<a&&(a=f),f>l&&(l=f),m<c&&(c=m),m>u&&(u=m);l>=e.x&&a<=e.x+e.w&&u>=e.y&&c<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,m=s==="x"?i[1]:i[1]+l;u>=e.x&&c<=e.x+e.w&&m>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function x4(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function b4(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function Be(e){return e.replace(/(["\\])/g,"\\$1")}const w4=4;let ce=null;const v4={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=y.getState().readOnly?null:xt(e.target);let r=null;if(o){const s=y.getState();s.selection.includes(o)||s.setSelection([o]);const i=y.getState().selection,a=y.getState().internal,l=new Map,c=new Map;for(const u of i){const f=a.buses.get(u);if(f){c.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const m=a.layout.get(u);m&&l.set(u,{...m})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}ce={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTx:n.tx,startTy:n.ty,startTarget:e.target,moved:!1,elementDrag:r},t.hostEl.style.cursor="grabbing",e.preventDefault()},onPointerMove(e,t){if(!ce||e.pointerId!==ce.pointerId)return;const n=e.clientX-ce.startX,o=e.clientY-ce.startY;if(!ce.moved&&Math.hypot(n,o)>w4){ce.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(ce.moved){if(ce.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=de(r[0]-ce.elementDrag.startSvg[0]),i=de(r[1]-ce.elementDrag.startSvg[1]);for(const[a,l]of ce.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);if(!c)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",nt(u))}for(const a of ce.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:ce.startTx+n,ty:ce.startTy+o})}},onPointerUp(e,t){if(!(!ce||e.pointerId!==ce.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",ce.elementDrag&&ce.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.elementDrag.startSvg[0]),r=de(n[1]-ce.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ce.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of ce.elementDrag.busOriginals.keys())s.set(i,[o,r]);y.getState().moveElements(s)}for(const s of ce.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Mt(s)}"]`);i&&i.removeAttribute("transform")}}else!ce.moved&&!y.getState().readOnly&&k4(ce.startTarget);ce=null}},onPointerCancel(e,t){if(ce!=null&&ce.elementDrag){for(const[n,o]of ce.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);r&&r.setAttribute("transform",nt(o))}for(const n of ce.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);o&&o.removeAttribute("transform")}}ce=null},onDeactivate(){ce=null}};function k4(e){if(!e)return;const t=y.getState(),n=qt(e);if(n){t.setSelectedAnnotation(n);return}const o=xt(e);if(o){t.setSelection([o]);return}const r=Mn(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function Mt(e){return e.replace(/(["\\])/g,"\\$1")}const Pt={tight:1024,compact:720,dense:520,mini:380},Fr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return Fr[e]>=Fr[t]}function _4(e){return e>=Pt.tight?"full":e>=Pt.compact?"tight":e>=Pt.dense?"compact":e>=Pt.mini?"dense":"mini"}const wv=M.createContext("full");function rt(){return M.useContext(wv)}function S4(e){const[t,n]=M.useState(null);return M.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function vv(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<Pt.dense}function ct(){vv()&&y.getState().setActiveTool("pan")}function $4(){vv()&&y.getState().setPlaceKind(null)}const j4={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(null)},onPointerDown(e,t){var i,a;if(e.button!==0)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((a=(i=e.target).hasPointerCapture)!=null&&a.call(i,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Dt(t,e.clientX,e.clientY),r=Lt(e.target instanceof Element?e.target:null,n,o),s=y.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=y.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=vn(e.clientX,e.clientY),i=Lt(s,r,Dt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};tt(kn(a,i)?null:bv(i))},onPointerUp(e,t){const n=y.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),tt(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Lt(s,r,Dt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};kn(a,i)||(n.connectWire(o.spec,i.spec),ct())},onPointerLeave(){const e=y.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),tt(null)}},Hr=10;let Ct=!1;function Wr(){setTimeout(()=>$4(),0)}const E4={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=y.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),Ct=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=y.getState();if(!n)return;e.preventDefault();const o=Tn(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const a=y.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);ev(n,r),Ct=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([qr(n[0]),qr(n[1])])},onPointerUp(e,t){const n=y.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);Z$(r,o,s),Wr();return}Ct&&(Ct=!1,Wr())},onPointerLeave(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),Ct=!1}};function qr(e){return Math.round(e/Hr)*Hr}const Xr=10,Yr=20;function ft(e){return Math.round(e/Xr)*Xr}const N4={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[ft(n[0]),ft(n[1])];y.getState().setBusbarDrawStart(o),y.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([ft(n[0]),ft(n[1])])},onPointerUp(e,t){const n=y.getState().busbarDrawStart;if(y.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=ft(o[0]),s=ft(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,u,f;if(l){if(u=Math.abs(i),u<Yr)return;c=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<Yr)return;c=90,f=[n[0],(n[1]+s)/2]}y.getState().addBus(f,u,c),ct()},onPointerLeave(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},Gr=10,Kr=e=>Math.round(e/Gr)*Gr,A4={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().addJunction([Kr(n[0]),Kr(n[1])]),ct()}},T4={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation(),n.setActiveTool("select"),n.setSelectedAnnotation(o);return}e.preventDefault();const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=n.addAnnotation([r[0],r[1]],"");n.setEditingAnnotation(s),ct()}},M4={id:"rect",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"rect",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),{at:s,size:i}=iv({...o,current:r,constrain:e.shiftKey});if(i[0]<xn||i[1]<xn)return;const a=n.insertAnnotation({type:"rect",at:s,size:i,stroke:"dashed"});n.setSelectedAnnotation(a),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},C4={id:"line",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"line",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=av({...o,current:r,constrain:e.shiftKey}),i=s[0]-o.start[0],a=s[1]-o.start[1];if(Math.hypot(i,a)<sj)return;const l=n.insertAnnotation({type:"line",at:o.start,points:[[0,0],[i,a]]});n.setSelectedAnnotation(l),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Ur=15,P4=3,I4=3,O4={id:"table",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"table",start:n,current:n,constrain:!1})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY))})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=Math.abs(r[0]-o.start[0]),i=Math.abs(r[1]-o.start[1]),a=s<Ur&&i<Ur,{at:l,cols:c,rows:u}=a?{at:o.start,cols:P4,rows:I4}:cv({...o,current:r}),f=n.insertAnnotation({type:"table",at:l,...dv(c,u)});n.setSelectedAnnotation(f),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Vr={select:g4,pan:v4,wire:j4,place:E4,busbar:N4,junction:A4,text:T4,rect:M4,line:C4,table:O4};function B4(e,t){const n=y(r=>r.activeTool),o=y(r=>r.readOnly);M.useEffect(()=>{var p;const r=e.current;if(!r)return;const s=o?"pan":n,i=o?Vr.pan:Vr[n],a={viewport:t,hostEl:r};r.dataset.tool=s,(p=i.onActivate)==null||p.call(i,a),i.cursor&&(r.style.cursor=i.cursor);const l=h=>{var x;return(x=i.onPointerDown)==null?void 0:x.call(i,h,a)},c=h=>{var x;return(x=i.onPointerMove)==null?void 0:x.call(i,h,a)},u=h=>{var x;return(x=i.onPointerUp)==null?void 0:x.call(i,h,a)},f=h=>{var x;return i.onPointerCancel?i.onPointerCancel(h,a):(x=i.onPointerUp)==null?void 0:x.call(i,h,a)},m=h=>{var x;return(x=i.onPointerLeave)==null?void 0:x.call(i,h,a)},g=h=>{var x;return(x=i.onDoubleClick)==null?void 0:x.call(i,h,a)};return r.addEventListener("pointerdown",l),r.addEventListener("pointermove",c),r.addEventListener("pointerup",u),r.addEventListener("pointercancel",f),r.addEventListener("pointerleave",m),r.addEventListener("dblclick",g),()=>{var h;r.removeEventListener("pointerdown",l),r.removeEventListener("pointermove",c),r.removeEventListener("pointerup",u),r.removeEventListener("pointercancel",f),r.removeEventListener("pointerleave",m),r.removeEventListener("dblclick",g),(h=i.onDeactivate)==null||h.call(i,a),r.style.cursor="",delete r.dataset.tool}},[n,o,e,t])}let bo=1;const wo=new Set;function L4(e){if(e!==bo){bo=e;for(const t of wo)t(e)}}function D4(){return bo}function z4(e){return wo.add(e),()=>{wo.delete(e)}}const Un=.1,Vn=8,R4=1.0015,F4=1.02;function H4(e,t,n={tx:0,ty:0,scale:1}){const o=M.useRef({...n}),r=M.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),L4(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return M.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,u=0,f=0,m=0,g=!1;const p=new Map;let h=null,x=!1;const w=()=>{if(p.size<2){h=null;return}const P=[...p.values()],R=P[1].x-P[0].x,Z=P[1].y-P[0].y,ie=Math.hypot(R,Z)||1,ue=i.getBoundingClientRect();h={startDist:ie,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(P[0].x+P[1].x)/2-ue.left,startMidY:(P[0].y+P[1].y)/2-ue.top}},v=P=>{if(P.pointerType==="touch"){if(p.set(P.pointerId,{x:P.clientX,y:P.clientY}),p.size>=2&&!x){x=!0;for(const R of p.keys())R!==P.pointerId&&gv(i,R);w()}if(x){P.stopPropagation(),P.preventDefault();try{i.setPointerCapture(P.pointerId)}catch{}}}},C=P=>{if(P.pointerType!=="touch"||!p.has(P.pointerId)||(p.set(P.pointerId,{x:P.clientX,y:P.clientY}),!x||!h))return;P.stopPropagation();const R=[...p.values()];if(R.length<2)return;const Z=R[1].x-R[0].x,ie=R[1].y-R[0].y,ue=Math.hypot(Z,ie)||1,ee=i.getBoundingClientRect(),ae=(R[0].x+R[1].x)/2-ee.left,me=(R[0].y+R[1].y)/2-ee.top,be=ue/h.startDist,$e=Jn(h.startScale*be,Un,Vn),Me=$e/h.startScale;o.current.tx=h.startMidX-(h.startMidX-h.startTx)*Me+(ae-h.startMidX),o.current.ty=h.startMidY-(h.startMidY-h.startTy)*Me+(me-h.startMidY),o.current.scale=$e,s()},O=P=>{var R;if(P.pointerType==="touch"&&p.has(P.pointerId)&&(p.delete(P.pointerId),x)){if(P.stopPropagation(),(R=i.hasPointerCapture)!=null&&R.call(i,P.pointerId))try{i.releasePointerCapture(P.pointerId)}catch{}p.size>=2?w():h=null,p.size===0&&(x=!1)}},F=P=>{P.preventDefault();const R=i.getBoundingClientRect(),Z=P.clientX-R.left,ie=P.clientY-R.top,ue=P.ctrlKey||P.metaKey;if(P.deltaX===0||ue){const me=Math.pow(ue?F4:R4,-P.deltaY),be=Jn(o.current.scale*me,Un,Vn),$e=be/o.current.scale;o.current.tx=Z-(Z-o.current.tx)*$e,o.current.ty=ie-(ie-o.current.ty)*$e,o.current.scale=be}else o.current.tx-=P.deltaX,o.current.ty-=P.deltaY;s()},G=P=>{const R=P.button===1,Z=g&&P.button===0;!R&&!Z||(P.preventDefault(),a=!0,l=P.pointerId,c=P.clientX,u=P.clientY,f=o.current.tx,m=o.current.ty,i.setPointerCapture(P.pointerId),i.style.cursor="grabbing")},$=P=>{!a||P.pointerId!==l||(o.current.tx=f+(P.clientX-c),o.current.ty=m+(P.clientY-u),s())},H=P=>{a&&P.pointerId===l&&(a=!1,i.releasePointerCapture(P.pointerId),i.style.cursor=g?"grab":"")},W=P=>{if(P.code==="Space"&&!g){const R=P.target;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable))return;g=!0,i.style.cursor="grab",P.preventDefault()}},X=P=>{P.code==="Space"&&(g=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",F,{passive:!1}),i.addEventListener("pointerdown",G),i.addEventListener("pointermove",$),i.addEventListener("pointerup",H),i.addEventListener("pointercancel",H),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",C,{capture:!0}),i.addEventListener("pointerup",O,{capture:!0}),i.addEventListener("pointercancel",O,{capture:!0}),window.addEventListener("keydown",W),window.addEventListener("keyup",X),s(),()=>{i.removeEventListener("wheel",F),i.removeEventListener("pointerdown",G),i.removeEventListener("pointermove",$),i.removeEventListener("pointerup",H),i.removeEventListener("pointercancel",H),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",C,{capture:!0}),i.removeEventListener("pointerup",O,{capture:!0}),i.removeEventListener("pointercancel",O,{capture:!0}),window.removeEventListener("keydown",W),window.removeEventListener("keyup",X)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const c=l.getBoundingClientRect(),u=(i-c.left-o.current.tx)/o.current.scale,f=(a-c.top-o.current.ty)/o.current.scale;return[u,f]},getViewport(){return{...o.current}},setViewport(i){i.tx!==void 0&&(o.current.tx=i.tx),i.ty!==void 0&&(o.current.ty=i.ty),i.scale!==void 0&&(o.current.scale=Jn(i.scale,Un,Vn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function Jn(e,t,n){return e<t?t:e>n?n:e}const kv=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ht=kv?"⌘":"Ctrl+",W4=kv?"⇧":"Shift+",Zn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],q4=18;function X4(e){for(const t of Zn)if(t*e>=q4)return t;return Zn[Zn.length-1]}function Y4(){const e=le(),t=M.useRef(null),n=M.useRef(null),o=M.useRef(null),r=H4(t,n);B4(t,r),f4(t),M.useEffect(()=>(jr(r),()=>jr(null)),[r]),M.useEffect(()=>{const u=f=>{const m=o.current;if(!m)return;const p=X4(f.scale)*f.scale;m.setAttribute("width",String(p)),m.setAttribute("height",String(p)),m.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=ak(),i=M.useCallback((u,f,m)=>{const g=y.getState();if(g.readOnly)return;const p=g.activeTool;if(p==="wire"||p==="busbar"||p==="junction"||p==="place"){yv();return}const h=qt(m),x=h?null:xt(m);if(h)g.selectedAnnotation!==h&&g.setSelectedAnnotation(h);else if(x)g.selection.includes(x)||g.setSelection([x]);else{const W=Mn(m);W&&g.selectedNode!==W&&g.setSelectedNode(W)}const w=y.getState(),v=w.selection.length>0,C=w.selectedAnnotation!=null,O=v||C,F=w.selectedNode!=null,G=!!w.clipboard,$=w.diagram.elements.length>0,H=[{label:e("menu.undo"),shortcut:`${ht}Z`,icon:Eo,onSelect:()=>y.getState().undo(),disabled:w.past.length===0},{label:e("menu.redo"),shortcut:`${ht}${W4}Z`,icon:jo,onSelect:()=>y.getState().redo(),disabled:w.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ht}X`,icon:Ts,onSelect:()=>y.getState().cutSelection(),disabled:!O},{label:e("menu.copy"),shortcut:`${ht}C`,icon:js,onSelect:()=>y.getState().copySelection(),disabled:!O},{label:e("menu.paste"),shortcut:`${ht}V`,icon:$s,onSelect:()=>y.getState().pasteClipboard(),disabled:!G},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:As,onSelect:()=>y.getState().rotateSelection(90),disabled:!v},{label:e("menu.mirror"),shortcut:"M",icon:Es,onSelect:()=>y.getState().mirrorSelection(),disabled:!v},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ht}A`,icon:j2,onSelect:()=>{const W=y.getState();W.setSelection(W.diagram.elements.map(X=>X.id))},disabled:!$},{type:"separator"},{label:e(F&&!O?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Cs,destructive:!0,onSelect:()=>{const W=y.getState();F&&!O?W.deleteSelectedNode():C&&W.selectedAnnotation?W.deleteAnnotation(W.selectedAnnotation):W.deleteSelection()},disabled:!O&&!F}];s.open(u,f,H)},[s,e]);M.useEffect(()=>{const u=t.current;if(!u)return;const f=700,m=4;let g,p=null;const h=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,p=null},x=C=>{C.pointerType==="touch"&&(h(),p={pointerId:C.pointerId,x:C.clientX,y:C.clientY,target:C.target},g=window.setTimeout(()=>{const O=p;p=null,g=void 0,O&&(gv(u,O.pointerId),i(O.x,O.y,O.target))},f))},w=C=>{if(!p||C.pointerId!==p.pointerId)return;const O=C.clientX-p.x,F=C.clientY-p.y;Math.hypot(O,F)>m&&h()},v=C=>{!p||C.pointerId!==p.pointerId||h()};return u.addEventListener("pointerdown",x),u.addEventListener("pointermove",w),u.addEventListener("pointerup",v),u.addEventListener("pointercancel",v),()=>{h(),u.removeEventListener("pointerdown",x),u.removeEventListener("pointermove",w),u.removeEventListener("pointerup",v),u.removeEventListener("pointercancel",v)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{if(y.getState().readOnly)return;const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const m=r.screenToSvg(u.clientX,u.clientY);ev(f,m)},c=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(Cj,{}),d.jsx(Qj,{}),d.jsx(Rj,{}),d.jsx(Wj,{}),d.jsx(ej,{}),d.jsx(cj,{}),d.jsx(Kj,{}),d.jsx(Ej,{}),d.jsx(Nj,{}),d.jsx(yj,{}),d.jsx(Vj,{}),d.jsx(n4,{}),d.jsx(Pj,{}),d.jsx(gj,{}),d.jsx(Gj,{}),d.jsx(Yj,{})]})]})})}const Jr=60,G4=.1,K4=8,U4=8;function V4(e,t,n){return e<t?t:e>n?n:e}function J4(){return document.querySelector(".ole-canvas-root")}function Mo(){const e=Xe(),t=J4();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,a=-1/0;for(const w of o){const v=w.getBoundingClientRect();v.width===0&&v.height===0||(v.left<r&&(r=v.left),v.top<s&&(s=v.top),v.right>i&&(i=v.right),v.bottom>a&&(a=v.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[u,f]=e.screenToSvg(i,a),m=Math.max(u-l,1),g=Math.max(f-c,1),p=V4(Math.min((n.width-Jr*2)/m,(n.height-Jr*2)/g),G4,K4),h=(l+u)/2,x=(c+f)/2;return e.setViewport({tx:n.width/2-p*h,ty:n.height/2-p*x,scale:p}),!0}function Co(){let e=U4;const t=()=>{Mo()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const Zr=10,Z4=100;function Q4(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function Qr(){const[e,t]=M.useState(l4()),[n,o]=M.useState(!1),[r,s]=M.useState(null),i=M.useRef(null),a=M.useRef(void 0),[l]=M.useState(Q4);M.useEffect(()=>c4(p=>t(p)),[]),M.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),Z4),()=>window.clearTimeout(a.current)},[e]);const c=y(p=>e?p.diagram.elements.find(h=>h.id===e)??null:null);if(M.useLayoutEffect(()=>{if(!n||!e)return;let p=0,h=-1,x=-1;const w=()=>{const v=document.querySelector(`[data-element-id="${e6(e)}"]`),C=i.current;if(v&&C){const O=v.getBoundingClientRect();let F=O.bottom+Zr;F+C.offsetHeight>window.innerHeight-4&&(F=O.top-C.offsetHeight-Zr);let G=O.left+O.width/2-C.offsetWidth/2;G=Math.max(4,Math.min(G,window.innerWidth-C.offsetWidth-4)),(F!==h||G!==x)&&(s({top:F,left:G}),h=F,x=G)}p=requestAnimationFrame(w)};return p=requestAnimationFrame(w),()=>cancelAnimationFrame(p)},[n,e]),l||!n||!e||!c)return null;const u=ot[c.kind],f=c.name??c.id,m=(u==null?void 0:u.name)??c.kind,g=c.name&&c.name!==c.id;return typeof document>"u"?null:ks.createPortal(d.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[d.jsx("span",{className:"font-medium text-foreground",children:f}),g&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id}),d.jsx("span",{className:"text-muted-foreground/80",children:"·"}),d.jsx("span",{className:"text-muted-foreground",children:m})]}),document.body)}function e6(e){return e.replace(/(["\\])/g,"\\$1")}function t6({width:e,children:t}){const n=e==null?"full":_4(e);return d.jsx(wv.Provider,{value:n,children:t})}function es(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function n6(...e){return t=>{let n=!1;const o=e.map(r=>{const s=es(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<o.length;r++){const s=o[r];typeof s=="function"?s():es(e[r],null)}}}}var o6=Symbol.for("react.lazy"),_n=_e[" use ".trim().toString()];function r6(e){return typeof e=="object"&&e!==null&&"then"in e}function _v(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===o6&&"_payload"in e&&r6(e._payload)}function s6(e){const t=a6(e),n=_e.forwardRef((o,r)=>{let{children:s,...i}=o;_v(s)&&typeof _n=="function"&&(s=_n(s._payload));const a=_e.Children.toArray(s),l=a.find(c6);if(l){const c=l.props.children,u=a.map(f=>f===l?_e.Children.count(c)>1?_e.Children.only(null):_e.isValidElement(c)?c.props.children:null:f);return d.jsx(t,{...i,ref:r,children:_e.isValidElement(c)?_e.cloneElement(c,void 0,u):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var i6=s6("Slot");function a6(e){const t=_e.forwardRef((n,o)=>{let{children:r,...s}=n;if(_v(r)&&typeof _n=="function"&&(r=_n(r._payload)),_e.isValidElement(r)){const i=u6(r),a=d6(s,r.props);return r.type!==_e.Fragment&&(a.ref=o?n6(o,i):i),_e.cloneElement(r,a)}return _e.Children.count(r)>1?_e.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var l6=Symbol("radix.slottable");function c6(e){return _e.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===l6}function d6(e,t){const n={...t};for(const o in t){const r=e[o],s=t[o];/^on[A-Z]/.test(o)?r&&s?n[o]=(...a)=>{const l=s(...a);return r(...a),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...s}:o==="className"&&(n[o]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}function u6(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const ts=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ns=Os,f6=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return ns(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const u=n==null?void 0:n[c],f=s==null?void 0:s[c];if(u===null)return null;const m=ts(u)||ts(f);return r[c][m]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,m]=u;return m===void 0||(c[f]=m),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:m,...g}=u;return Object.entries(g).every(p=>{let[h,x]=p;return Array.isArray(x)?x.includes({...s,...a}[h]):{...s,...a}[h]===x})?[...c,f,m]:c},[]);return ns(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},h6=f6("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ae=_e.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?i6:"button";return d.jsx(i,{className:Se(h6({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const m6=350;function Te({content:e,children:t,disabled:n,delayMs:o=m6}){const r=M.useRef(null),s=M.useRef(null),[i,a]=M.useState(!1),[l,c]=M.useState(null),u=M.useId(),f=M.useRef(void 0),m=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},g=()=>{window.clearTimeout(f.current),a(!1)};M.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const w=r.current.getBoundingClientRect(),v=s.current.getBoundingClientRect(),C=8;let O="top",F=w.top-v.height-C;F<4&&(O="bottom",F=w.bottom+C);let G=w.left+w.width/2-v.width/2;G=Math.max(4,Math.min(G,window.innerWidth-v.width-4)),c({top:F,left:G,side:O})},[i,e]),M.useEffect(()=>()=>window.clearTimeout(f.current),[]),M.useEffect(()=>{if(!i)return;const w=C=>{C.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",w),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",w),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const p=t,h=p.props,x=M.cloneElement(p,{ref:w=>{r.current=w;const v=p.ref;typeof v=="function"?v(w):v&&typeof v=="object"&&(v.current=w)},onPointerEnter:w=>{var v;(v=h.onPointerEnter)==null||v.call(h,w),m()},onPointerLeave:w=>{var v;(v=h.onPointerLeave)==null||v.call(h,w),g()},onFocus:w=>{var v;(v=h.onFocus)==null||v.call(h,w),m()},onBlur:w=>{var v;(v=h.onBlur)==null||v.call(h,w),g()},"aria-describedby":i?u:h["aria-describedby"]});return d.jsxs(d.Fragment,{children:[x,i&&typeof document<"u"&&ks.createPortal(d.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const os=12,p6=56;function g6(){var w;const e=le(),t=y(v=>v.selection),n=y(v=>v.selectedNode),o=y(v=>v.selectedWire),r=y(v=>v.activeTool),s=y(v=>v.rotateSelection),i=y(v=>v.mirrorSelection),a=y(v=>v.deleteSelection),l=y(v=>v.deleteSelectedNode),c=y(v=>v.deleteSelectedWire),u=y(v=>v.resetWirePath),f=y(v=>v.internal.wireRenders),m=o!=null&&((w=f.get(o))==null?void 0:w.userEdited)===!0,g=M.useRef(null);M.useEffect(()=>{const v=g.current;if(!v)return;const C=t.length>0,O=!C&&o!=null,F=!C&&!O&&n!=null;if(!((C||O||F)&&(r==="select"||r==="pan"))){v.style.display="none";return}v.style.display="flex";let $=0,H="";const W=()=>{let X=1/0,P=-1/0,R=1/0,Z=-1/0,ie=!1;const ue=ee=>{ee.width===0&&ee.height===0||(ee.left<X&&(X=ee.left),ee.right>P&&(P=ee.right),ee.top<R&&(R=ee.top),ee.bottom>Z&&(Z=ee.bottom),ie=!0)};if(C)for(const ee of t){const ae=document.querySelector(`[data-element-id="${CSS.escape(ee)}"]`);ae&&ue(ae.getBoundingClientRect())}else if(O&&o){const ee=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ee&&ue(ee.getBoundingClientRect())}else if(F&&n){const ee=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const ae of ee)ue(ae.getBoundingClientRect())}if(ie){const ee=(X+P)/2;let ae=R-os,me="-100%";ae<p6&&(ae=Z+os,me="0%");const be=`translate3d(${ee}px, ${ae}px, 0) translate(-50%, ${me})`;be!==H&&(v.style.transform=be,H=be)}$=requestAnimationFrame(W)};return $=requestAnimationFrame(W),()=>cancelAnimationFrame($)},[t,n,o,r]);const p=t.length===0&&o!=null,h=t.length===0&&!p&&n!=null,x=h||p;return d.jsxs("div",{ref:g,role:"toolbar","aria-label":e(p?"ctx.ariaWire":h?"ctx.ariaNode":"ctx.ariaElement"),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",children:[p&&m&&o&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{children:d.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx($2,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!x&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:d.jsx(As,{})})}),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Es,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.delete")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),d.jsx("div",{className:"text-muted-foreground",children:e(p?"ctx.deleteHintWire":h?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>p?c():h?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(Cs,{})})})]})}const rs=8,y6=56,vo=".ole-ann-cell-edit-fo",ko=".ole-free-annotation-edit-fo";function ss(){return document.querySelector(`${vo} input`)??document.querySelector(`${ko} [contenteditable]`)}function x6(){const e=le(),t=y(i=>i.editingAnnotation),n=y(i=>i.editingCell),o=M.useRef(null);M.useEffect(()=>{const i=o.current;if(!i)return;if(!t){i.style.display="none";return}i.style.display="flex";let a=0,l="";const c=()=>{const u=ss()??document.querySelector(vo)??document.querySelector(ko)??document.querySelector(`[data-annotation-id="${CSS.escape(t)}"]`);if(u){const f=u.getBoundingClientRect();let m=f.top-rs,g="-100%";m<y6&&(m=f.bottom+rs,g="0%");const p=`translate3d(${f.left}px, ${m}px, 0) translate(0, ${g})`;p!==l&&(i.style.transform=p,l=p)}a=requestAnimationFrame(c)};return a=requestAnimationFrame(c),()=>cancelAnimationFrame(a)},[t,n]);const r=()=>{var i;(i=ss())==null||i.blur()},s=()=>{var c,u;const i=y.getState(),a=i.editingAnnotation,l=(c=i.diagram.annotations)==null?void 0:c.find(f=>f.id===a);if(!l){i.setEditingAnnotation(null);return}if(Le(l)==="table"&&i.editingCell){const f=document.querySelector(`${vo} input`),[m,g]=i.editingCell;if(f){f.value=((u=l.cells[m])==null?void 0:u[g])??"",f.blur();return}}else{const f=document.querySelector(`${ko} [contenteditable]`);if(f){f.innerText=l.text??"",f.blur();return}}i.setEditingAnnotation(null)};return d.jsxs("div",{ref:o,role:"toolbar","aria-label":e("ctx.ariaEdit"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-40 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.done")," · Enter"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-emerald-600 hover:text-emerald-600 dark:text-emerald-400 dark:hover:text-emerald-400",onMouseDown:i=>i.preventDefault(),onClick:r,"aria-label":e("ctx.done"),children:d.jsx(c2,{})})}),d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.cancel")," · Esc"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onMouseDown:i=>i.preventDefault(),onClick:s,"aria-label":e("ctx.cancel"),children:d.jsx(Sn,{})})})]})}function Po({open:e,onOpenChange:t,trigger:n,children:o}){const r=M.useRef(null);return M.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),d.jsxs("div",{ref:r,className:"relative",children:[n,e&&d.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const Sv="ole-panel-open";function b6(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Sv);if(!e)return{outlineOpen:!1};const t=JSON.parse(e);return typeof t!="object"||t===null?{outlineOpen:!1}:{outlineOpen:t.outline===!0}}catch{return{outlineOpen:!1}}}function is(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Sv,JSON.stringify(t))}catch{}}const Xt=$n((e,t)=>({...b6(),setOutlineOpen:n=>{e({outlineOpen:n}),is(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),is(t())}})),mn=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],$v=.1,jv=8,Ev="ole-grid";function w6(){try{const e=window.localStorage.getItem(Ev);return e==null?!0:e==="1"}catch{return!0}}function v6(e){try{window.localStorage.setItem(Ev,e?"1":"0")}catch{}}function k6(e,t,n){return e<t?t:e>n?n:e}function Nv(){return document.querySelector(".ole-canvas-root")}function Io(e){const t=Xe(),n=Nv();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=k6(e,$v,jv),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function _6(){const e=Xe();if(!e)return;const t=e.getViewport().scale,n=mn.find(o=>o>t+1e-6)??jv;Io(n)}function S6(){const e=Xe();if(!e)return;const t=e.getViewport().scale;let n=$v;for(let o=mn.length-1;o>=0;o--)if(mn[o]<t-1e-6){n=mn[o];break}Io(n)}const $6={off:"id",id:"all",all:"off"};function j6(){var o;const e=y.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=$6[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Av(){const[e,t]=M.useState(()=>w6());return M.useEffect(()=>{const n=Nv();n==null||n.classList.toggle("hide-grid",!e),v6(e)},[e]),M.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Tv(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:S6,"aria-label":e("view.zoomOut"),children:d.jsx($o,{})})})}function Mv(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:_6,"aria-label":e("view.zoomIn"),children:d.jsx(k2,{})})})}function Cv(){const e=le(),[t,n]=M.useState(D4);return M.useEffect(()=>z4(n),[]),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.reset")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:d.jsxs("button",{type:"button",onClick:()=>Io(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function Pv(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.fit")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:Mo,"aria-label":e("view.fit"),children:d.jsx(b2,{})})})}function Iv({grid:e,setGrid:t}){const n=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),d.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:Se(!e&&"text-muted-foreground/60"),children:d.jsx(y2,{})})})}function Ov(){const e=le(),t=y(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:j6,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:Se(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Ps,{})})})}function E6({stacked:e}={}){const t=le(),[n,o]=M.useState(!1),[r,s]=Av(),i=d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:t("view.menu")}),d.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?d.jsx(Te,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:Se("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[d.jsx(no,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Te,{content:i,children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:d.jsx(no,{})})});return d.jsx(Po,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(Cv,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Tv,{}),d.jsx(Mv,{})]}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Pv,{}),d.jsx(Iv,{grid:r,setGrid:s}),d.jsx(Ov,{})]})]})})}function as(){const e=rt();return!y(n=>n.readOnly)&&Oe(e,"dense")?null:d.jsx(N6,{tier:e})}function N6({tier:e}){const t=Oe(e,"tight"),n=y(s=>s.readOnly),[o,r]=Av();return d.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:d.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[d.jsx(Tv,{}),!t&&d.jsx(Cv,{}),d.jsx(Mv,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(Pv,{}),d.jsx(Iv,{grid:o,setGrid:r}),!n&&d.jsx(Ov,{})]})})}const ls=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:w2,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:x2,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:$o,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:u2,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Ms,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Ss,switchTo:"wire",groupBreakAfter:!0},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Ps,switchTo:"text",iconOnly:!0},{id:"rect",labelKey:"tool.rect",hotkey:"F",descriptionKey:"tool.rectHint",icon:E2,switchTo:"rect",iconOnly:!0},{id:"line",labelKey:"tool.line",hotkey:"L",descriptionKey:"tool.lineHint",icon:S2,switchTo:"line",iconOnly:!0},{id:"table",labelKey:"tool.table",hotkey:"D",descriptionKey:"tool.tableHint",icon:N2,switchTo:"table",iconOnly:!0}];function A6(){const e=le(),t=y(m=>m.activeTool),n=y(m=>m.placeKind),o=y(m=>m.placeFromTerminal),r=y(m=>m.wireDragFrom),s=y(m=>m.busbarDrawStart),i=y(m=>m.selection.length>0||m.selectedNode!=null),a=y(m=>m.editingAnnotation),l=y(m=>{var h;const g=m.selectedAnnotation;if(!g)return null;const p=(h=m.diagram.annotations)==null?void 0:h.find(x=>x.id===g);return p?Le(p):null});if(a)return d.jsx("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:d.jsx("span",{children:e("mode.annEditing")})});let c=null,u=!1;switch(t){case"select":if(l){c=e(l==="table"?"mode.annTableSel":l==="text"?"mode.annTextSel":"mode.annShapeSel"),u=!0;break}c=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(u=!0);break;case"pan":c=e("mode.pan");break;case"wire":c=e(r?"mode.wireDragging":"mode.wireInit"),u=!0;break;case"busbar":c=e(s?"mode.busDragging":"mode.busInit"),u=!0;break;case"junction":c=e("mode.junction"),u=!0;break;case"place":n?o?c=e("mode.placeFromTerm"):c=e("mode.placeNormal"):c=e("mode.placeNoKind"),u=!0;break;case"text":c=e("mode.text"),u=!0;break;case"rect":c=e("mode.rect"),u=!0;break;case"line":c=e("mode.line"),u=!0;break;case"table":c=e("mode.table"),u=!0;break}if(!c)return null;const f=e(t==="select"?"mode.escSelect":"mode.escOther");return d.jsxs("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:[d.jsx("span",{children:c}),u&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",f]})]})}function T6(){const e=le(),t=y(h=>h.activeTool),n=y(h=>h.placeKind),o=y(h=>h.setActiveTool),r=y(h=>h.past.length),s=y(h=>h.future.length),i=y(h=>h.undo),a=y(h=>h.redo),l=rt(),c=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),m=new Set(["select","text","rect","line","table"]),g=f?ls.filter(h=>!m.has(h.id)):ls,p=h=>t===h.switchTo;return d.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))"},children:[u&&d.jsx(A6,{}),d.jsxs("div",{className:Se("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",f?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[f&&d.jsx(M6,{stacked:!0}),g.map(h=>{const x=h.icon,w=p(h),v=h.id==="place"&&w&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return d.jsxs(M.Fragment,{children:[d.jsx(pt,{icon:x,label:e(h.labelKey),hotkey:h.hotkey,active:w,iconOnly:!f&&(h.iconOnly||c),stacked:f,description:v,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?d.jsx(P6,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(pt,{icon:Eo,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(pt,{icon:jo,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),d.jsx(C6,{iconOnly:c})]}),f&&d.jsx(E6,{stacked:!0})]})]})}function M6({stacked:e}){const t=le(),n=Xt(r=>r.outlineOpen),o=Xt(r=>r.toggleOutline);return d.jsx(pt,{icon:Ns,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function pt({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const c=d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:t}),n&&d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&d.jsx("div",{className:"text-muted-foreground",children:l})]});return d.jsx(Te,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:Se("rounded-md font-medium transition-colors",i?"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",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[d.jsxs("span",{className:"relative inline-flex shrink-0",children:[d.jsx(e,{className:"size-4"}),n&&!i&&d.jsx("span",{"aria-hidden":!0,className:Se("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function Bv(){const e=y(r=>r.diagram.elements),t=y(r=>r.diagram.layout),n=y(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function C6({iconOnly:e}){const t=le(),[n,o]=M.useState(!1),r=Bv(),s=i=>()=>{o(!1),i()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:It,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function P6({stacked:e}){const t=le(),[n,o]=M.useState(!1),r=y(m=>m.past.length),s=y(m=>m.future.length),i=y(m=>m.undo),a=y(m=>m.redo),l=y(m=>m.selection.length>0),c=y(m=>m.clipboard!=null),u=Bv(),f=m=>()=>{o(!1),m()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:no,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(m=>!m)}),children:[d.jsx(Pe,{onClick:f(i),icon:d.jsx(Eo,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Pe,{onClick:f(a),icon:d.jsx(jo,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().cutSelection()),icon:d.jsx(Ts,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Pe,{onClick:f(()=>y.getState().copySelection()),icon:d.jsx(js,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Pe,{onClick:f(()=>y.getState().pasteClipboard()),icon:d.jsx($s,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Pe({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:Se("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",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,d.jsx("span",{className:"flex-1",children:e})]})}function I6(){const e=Xt(r=>r.outlineOpen),t=Xt(r=>r.setOutlineOpen),n=rt();return Oe(n,"dense")?e?d.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px) + 0.75rem)"},children:d.jsx(cs,{onClose:()=>t(!1),sheet:!0})}):null:d.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?d.jsx(cs,{onClose:()=>t(!1)}):d.jsx(O6,{onClick:()=>t(!0)})})}function O6({onClick:e}){const t=le(),n=rt(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:Se("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",o?"w-12 justify-center":"gap-2 px-3"),children:[d.jsx(Ns,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function cs({onClose:e,sheet:t}){const n=le(),o=y(c=>c.diagram.elements),r=y(c=>c.activeTool==="place"),s=rt(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:Se("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:l},children:[d.jsxs("button",{type:"button",onClick:e,"aria-label":n("outline.collapseAria"),title:n("outline.collapse"),className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-muted/40",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&d.jsx(L6,{children:o.length}),d.jsx(v2,{className:"size-3.5 text-muted-foreground"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?d.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):d.jsx("ul",{className:"space-y-px",children:o.map(c=>d.jsx(B6,{element:c},c.id))})})]})}function B6({element:e}){const t=ot[e.kind],n=y(l=>l.selection.includes(e.id)),o=y(l=>l.setSelection),r=y(l=>l.toggleInSelection),s=rt(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function L6({children:e}){return d.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const D6={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","panelboard.name":"配电箱","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","panelboard.desc":"配电箱 / 负荷中心(IEC 分配中心符号):底部进线,箱顶分路示意","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},z6={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","panelboard.name":"Panelboard / load center","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current","resistor.name":"Resistor (R)","capacitor.name":"Capacitor (C)","diode.name":"Diode (D)","indicator-light.name":"Indicator light (HL)","push-button.name":"Push-button (SB)","relay-coil.name":"Relay coil (KA)","make-contact.name":"NO contact (NO)","break-contact.name":"NC contact (NC)","bell.name":"Bell (HA)","terminal.name":"Terminal / junction (X)","fuse-switch-disconnector.name":"Fuse switch-disconnector","socket-outlet.name":"Socket outlet / connector","inductor.name":"Inductor (L)","voltage-regulator.name":"Voltage regulator (T)","dc-motor.name":"DC motor (M)","heater.name":"Heating element (EH)","selector-switch.name":"Selector switch (SA)","limit-switch.name":"Limit switch (SQ)","proximity-switch.name":"Proximity switch (SQ)","time-relay.name":"Time relay (KT)","buzzer.name":"Buzzer (HA)","siren.name":"Siren (HA)","thermocouple.name":"Thermocouple (BT)","thyristor.name":"Thyristor / SCR (V)","triac.name":"Triac (V)","zener-diode.name":"Zener diode (D)","igbt.name":"IGBT","plc.name":"PLC / controller","ups.name":"UPS","power-supply.name":"Power supply (PS)","genset.name":"Generator set (G)","protective-relay.name":"Protective relay","overcurrent-relay.name":"Overcurrent relay (50/51)","undervoltage-relay.name":"Undervoltage relay (27)","reverse-power-relay.name":"Reverse-power relay (32)","distance-relay.name":"Distance relay (21)","phase-failure-relay.name":"Phase-failure relay","buchholz-relay.name":"Buchholz relay (63)","power-factor-meter.name":"Power-factor meter (cosφ)","synchronoscope.name":"Synchronoscope","varmeter.name":"Varmeter (var)","resistor.desc":"General resistor / current-limiting / braking resistor.","capacitor.desc":"General / filter / DC-bus capacitor. Use shunt capacitor for PF correction.","diode.desc":"Rectifier / freewheeling / protection diode. t1 = anode (top), t2 = cathode (bottom).","indicator-light.desc":"Signal / status indicator light.","push-button.desc":"Manual push-button, automatic return (NO make).","relay-coil.desc":"Relay / contactor operating coil (box).","make-contact.desc":"Normally-open auxiliary contact (make).","break-contact.desc":"Normally-closed auxiliary contact (break).","bell.desc":"Signal bell / alarm bell.","terminal.desc":"Terminal / junction box / connection node.","fuse-switch-disconnector.desc":"On-load fuse switch-disconnector.","socket-outlet.desc":"Power socket outlet / multipole connector.","inductor.desc":"General inductor / coil / choke.","voltage-regulator.desc":"Adjustable induction / autotransformer voltage regulator.","dc-motor.desc":"DC motor (series-field general symbol).","heater.desc":"Resistive heating element / heating load.","selector-switch.desc":"Selector / changeover switch (rotary, stay-put).","limit-switch.desc":"Travel / position switch (NO, mechanically operated).","proximity-switch.desc":"Proximity sensor / contactless proximity switch.","time-relay.desc":"Time-delay (slow-operating) relay coil.","buzzer.desc":"Signal buzzer.","siren.desc":"Audible siren / alarm.","thermocouple.desc":"Thermocouple temperature sensor.","thyristor.desc":"Reverse-blocking triode thyristor / SCR. t1 = anode (top), t2 = cathode (bottom).","triac.desc":"Bidirectional triode thyristor (TRIAC).","zener-diode.desc":"Zener / voltage-regulator diode. t1 = anode (top), t2 = cathode (bottom).","igbt.desc":"N-channel enhancement IGBT. t1 = collector (top), t2 = emitter (bottom), t_g = gate.","plc.desc":"Programmable logic controller (PLC).","ups.desc":"Online / standby uninterruptible power supply.","power-supply.desc":"AC→DC switched-mode / DC power supply. t_ac top (~), t_dc bottom (=).","genset.desc":"Diesel / gas generator set.","protective-relay.desc":"Measuring / protective relay, general symbol (IEC 60617).","overcurrent-relay.desc":"Overcurrent protection relay (ANSI 50/51).","undervoltage-relay.desc":"Undervoltage protection relay (ANSI 27).","reverse-power-relay.desc":"Reverse-power / reverse-current protection relay (ANSI 32).","distance-relay.desc":"Distance / under-impedance protection relay (ANSI 21).","phase-failure-relay.desc":"Phase-failure / phase-loss protection relay.","buchholz-relay.desc":"Buchholz / gas relay (ANSI 63).","power-factor-meter.desc":"Power-factor meter (cosφ).","synchronoscope.desc":"Synchronizing indicator / synchronoscope.","varmeter.desc":"Reactive-power meter (var).","make-contact.state.closed":"Closed","break-contact.state.open":"Open","fuse-switch-disconnector.state.open":"Open","selector-switch.state.open":"Open","limit-switch.state.closed":"Closed","resistor.param.R":"Resistance","resistor.param.P":"Rated power","capacitor.param.C":"Capacitance","capacitor.param.Un":"Rated voltage","indicator-light.param.color":"Color","inductor.param.L":"Inductance","inductor.param.In":"Rated current","voltage-regulator.param.ratio":"Regulation range","heater.param.P":"Power","ups.param.S":"Capacity","power-supply.param.Vdc":"Output voltage","genset.param.P":"Power"},ds={zh:D6,en:z6};function R6(e,t){return ds[e][t]??ds.zh[t]}function Jt(){const e=Yt(t=>t.locale);return(t,n)=>R6(e,t)??n??t}const Lv="ole-palette-collapsed",F6=new Set(["busbar"]),zt=(()=>{const e={};for(const[t,n]of Object.entries(R$)){const o=n.filter(r=>!F6.has(r.id));o.length&&(e[t]=o)}return e})(),H6=(()=>{const e=new Set(vr),t=Object.keys(zt).filter(n=>!e.has(n));return[...vr.filter(n=>{var o;return(o=zt[n])==null?void 0:o.length}),...t]})();function W6(){try{const e=window.localStorage.getItem(Lv);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function q6(e){try{window.localStorage.setItem(Lv,JSON.stringify([...e]))}catch{}}function X6(){const e=le(),t=y(f=>f.activeTool==="place"),n=y(f=>f.placeKind),o=y(f=>f.setActiveTool),r=Xt(f=>f.outlineOpen),s=rt(),i=Oe(s,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px) + var(--ole-safe-top, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px) + 0.75rem)"}:{top:a};return d.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:d.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:d.jsx(Sn,{className:"size-3.5"})})]}),d.jsx(Y6,{sheet:i})]})})}function Y6({sheet:e}){const t=le(),n=Jt(),[o,r]=M.useState(""),[s,i]=M.useState(()=>W6()),a=M.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return zt;const m={};for(const[g,p]of Object.entries(zt)){const h=p.filter(x=>{const w=n(`${x.id}.name`,x.name).toLowerCase(),v=n(`${x.id}.desc`,x.description??"").toLowerCase();return w.includes(f)||x.id.toLowerCase().includes(f)||v.includes(f)});h.length&&(m[g]=h)}return m},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=M.useCallback((f,m)=>{i(g=>{const p=new Set(g);return m?p.delete(f):p.add(f),q6(p),p})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(G6,{value:o,onChange:r})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:c?d.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):H6.map(f=>{var x;const m=a[f];if(!(m!=null&&m.length))return null;const g=((x=zt[f])==null?void 0:x.length)??m.length,p=t(`cat.${f}`),h=l||!s.has(f);return d.jsxs("details",{open:h,className:"group mb-2 last:mb-0",onToggle:w=>{l||u(f,w.currentTarget.open)},children:[d.jsxs("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:[d.jsx(d2,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:p}),d.jsx(U6,{children:l&&m.length!==g?`${m.length}/${g}`:g})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:m.map(w=>d.jsx(K6,{entry:w,sheet:e},w.id))})]},f)})})]})}function G6({value:e,onChange:t}){const n=le();return d.jsxs("div",{className:"relative",children:[d.jsx(_2,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),d.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&d.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Sn,{className:"size-3"})})]})}function K6({entry:e,sheet:t}){const n=le(),o=Jt(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=y(f=>f.setActiveTool),a=y(f=>f.activeTool==="place"&&f.placeKind===e.id),l=y(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),c=M.useRef(null);M.useEffect(()=>{var f;l&&((f=c.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const m=document.createElement("div");m.className="ole-glass",m.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),m.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(m),f.dataTransfer.setDragImage(m,32,32),setTimeout(()=>m.remove(),0)};return d.jsxs("li",{ref:c,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function U6({children:e}){return d.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const _o="ole-onboarding-dismissed";function V6(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(_o)==="1"}catch{return!1}}function us(e){try{e?window.localStorage.setItem(_o,"1"):window.localStorage.removeItem(_o)}catch{}}const fs=$n(e=>({dismissed:V6(),dismiss:()=>{us(!0),e({dismissed:!0})},reset:()=>{us(!1),e({dismissed:!1})}}));function J6(){const e=le(),t=fs(o=>o.dismissed),n=fs(o=>o.dismiss);return t?null:d.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),d.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Sn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Qn,{n:1,icon:d.jsx(Ms,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Qn,{n:2,icon:d.jsx(Ss,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Qn,{n:3,icon:d.jsx($o,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),d.jsx("button",{type:"button",onClick:n,className:"pointer-events-auto mt-4 w-full rounded-md bg-primary py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("onboard.dismiss")})]})}function Qn({n:e,icon:t,title:n,body:o}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[d.jsx("span",{className:"mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklch,var(--selection)_18%,transparent)] font-mono text-[10px] font-semibold tabular-nums text-[var(--selection)]","aria-hidden":!0,children:e}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),d.jsx("span",{children:n})]}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function Z6(){const e=le(),t=y(g=>g.selection),n=y(g=>g.diagram.elements),o=y(g=>g.diagram.buses),r=y(g=>g.diagram.junctions),s=y(g=>g.selectedNode),i=y(g=>g.selectedWire),a=y(g=>g.selectedAnnotation);if(i)return d.jsx(dE,{wireId:i});if(s)return d.jsx(fE,{nodeId:s});if(a)return d.jsx(rE,{annId:a});if(t.length===0)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const l=t[0],c=(o??[]).find(g=>g.id===l);if(c)return d.jsx(nE,{bus:c});const u=(r??[]).find(g=>g.id===l);if(u)return d.jsx(uE,{junction:u});const f=n.find(g=>g.id===l);if(!f)return null;const m=ot[f.kind];return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(Ke,{label:e("props.name"),value:f.name??"",placeholder:f.id,onCommit:g=>y.getState().updateElement(l,{name:g.trim()===""?void 0:g.trim()})}),d.jsx(Oo,{label:e("props.note"),value:f.note??"",onCommit:g=>y.getState().updateElement(l,{note:g.trim()===""?void 0:g.trim()})},l),(m==null?void 0:m.state)&&m.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:m.state.map(g=>d.jsx(mE,{id:l,element:f,field:g},g.name))}),d.jsx(Q6,{id:l,element:f,schema:(m==null?void 0:m.params)??[]})]})}function Q6({id:e,element:t,schema:n}){const o=new Set(n.map(s=>s.name)),r=t.params?Object.entries(t.params).filter(([s])=>!o.has(s)):[];return n.length===0&&r.length===0?null:d.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>d.jsx(eE,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(tE,{id:e,element:t,fieldKey:s,value:i},s))]})}function eE({id:e,element:t,field:n}){var l;const o=le(),r=Jt(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const u={...t.params??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:i,children:d.jsx(Bo,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?d.jsx(Cn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):d.jsx(Ke,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function tE({id:e,element:t,fieldKey:n,value:o}){const r=le(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,y.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?d.jsx(st,{label:n,children:d.jsx(Bo,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(Cn,{label:n,value:o,onCommit:s}):d.jsx(Ke,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function nE({bus:e}){const t=le(),n=e.id,o=r=>{const s=r.trim();So(n,{name:s===""?void 0:s})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:r=>So(n,{note:r.trim()===""?void 0:r.trim()})},n),d.jsx(oE,{bus:e})]})}function oE({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,So(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.jsx(Cn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function So(e,t){y.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function rE({annId:e}){const t=le(),n=y(r=>(r.diagram.annotations??[]).find(s=>s.id===e));if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.annNotFound",{id:e})});const o=r=>y.getState().updateAnnotation(e,r);switch(Le(n)){case"rect":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(Ke,{label:t("props.annLabel"),value:r.label??"",placeholder:t("props.annLabelPlaceholder"),onCommit:s=>o({label:s.trim()===""?void 0:s.trim()})}),d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"dashed",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annFill"),value:r.fill??"none",options:[{value:"none",label:t("props.annFillNone")},{value:"tint",label:t("props.annFillTint")}],onChange:s=>o({fill:s==="none"?void 0:s})})]})}case"line":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"solid",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annArrow"),value:r.arrow??"none",options:[{value:"none",label:t("props.annArrowNone")},{value:"end",label:t("props.annArrowEnd")},{value:"both",label:t("props.annArrowBoth")}],onChange:s=>o({arrow:s==="none"?void 0:s})})]})}case"table":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(hs,{label:t("props.annRows"),value:r.rowHeights.length,min:1,onChange:s=>o(sE(r,s))}),d.jsx(hs,{label:t("props.annCols"),value:r.colWidths.length,min:1,onChange:s=>o(iE(r,s))}),d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})]})}default:{const r=n;return d.jsx("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})})}}}function sE(e,t){const n=e.colWidths.length,o=e.rowHeights[e.rowHeights.length-1]??Wt,r=e.rowHeights.slice(0,t);for(;r.length<t;)r.push(o);const s=e.cells.slice(0,t).map(i=>[...i]);for(;s.length<t;)s.push(dv(n,1).cells[0]);return{rowHeights:r,cells:s}}function iE(e,t){const n=e.colWidths[e.colWidths.length-1]??Ht,o=e.colWidths.slice(0,t);for(;o.length<t;)o.push(n);const r=e.cells.map(s=>{const i=s.slice(0,t);for(;i.length<t;)i.push("");return i});return{colWidths:o,cells:r}}function dn({label:e,value:t,options:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsx("div",{className:"flex overflow-hidden rounded-md border border-border/60",children:n.map(r=>d.jsx("button",{type:"button","aria-pressed":t===r.value,onClick:()=>o(r.value),className:Se("h-7 flex-1 truncate px-1.5 text-[11px] transition-colors",t===r.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:r.label},r.value))})})}function hs({label:e,value:t,min:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button","aria-label":`${e} −`,disabled:t<=n,onClick:()=>o(t-1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40",children:"−"}),d.jsx("span",{className:"w-8 text-center font-mono text-[11px] tabular-nums",children:t}),d.jsx("button",{type:"button","aria-label":`${e} +`,onClick:()=>o(t+1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent",children:"+"})]})})}const aE=5,lE=32,cE=8;function ms({label:e,value:t,onCommit:n}){return d.jsx(Ke,{label:e,value:t!=null?String(t):"",placeholder:String(cE),unit:"px",onCommit:o=>{const r=o.trim();if(r===""){n(void 0);return}const s=Number(r);Number.isFinite(s)&&n(Math.min(lE,Math.max(aE,Math.round(s))))}})}function dE({wireId:e}){const t=le(),n=y(x=>x.diagram.wires),o=y(x=>x.diagram.elements),r=y(x=>x.diagram.buses),s=y(x=>x.diagram.junctions),i=y(x=>x.internal.terminalToNode),a=y(x=>x.setSelectedNode),l=(n??[]).find(x=>x.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),u=new Map(o.map(x=>[x.id,x])),f=new Map((r??[]).map(x=>[x.id,x])),m=new Map((s??[]).map(x=>[x.id,x])),g=x=>{if(!x.includes(".")){const F=f.get(x);if(F)return{id:x,label:F.name??x};const G=m.get(x);return{id:x,label:(G==null?void 0:G.name)??x}}const w=x.indexOf("."),v=x.slice(0,w),C=x.slice(w+1),O=u.get(v);return{id:v,label:(O==null?void 0:O.name)??v,pin:C}},p=g(l.ends[0]),h=g(l.ends[1]);return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),d.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),d.jsx(Ke,{label:t("props.label"),value:l.label??"",placeholder:t("props.labelPlaceholder"),onCommit:x=>y.getState().updateWire(e,{label:x.trim()===""?void 0:x.trim()})}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[p,h].map((x,w)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>y.getState().setSelection([x.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:x.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:x.label}),x.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:x.pin})]},w))}),c&&d.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>a(c),children:t("props.selectWholeNode")})]})}function uE({junction:e}){var r;const t=le(),n=y(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),d.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),d.jsx(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>y.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:s=>y.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})},e.id),o&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[d.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),d.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function fE({nodeId:e}){const t=le(),n=y(a=>a.internal.nodes.get(e)),o=y(a=>a.diagram.elements),r=y(a=>a.setSelection);if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const c=a.slice(0,l),u=a.slice(l+1),f=s.get(c)??[];f.push(u),s.set(c,f)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function st({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Ke({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=M.useState(t),a=M.useRef(null);return M.useEffect(()=>i(t),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:Se("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",o&&"pr-8")}),o&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}const hE=350;function Oo({label:e,value:t,onCommit:n}){const[o,r]=M.useState(t),s=M.useRef(!1),i=M.useRef(null),a=M.useRef({local:o,value:t,onCommit:n});a.current={local:o,value:t,onCommit:n};const l=M.useRef(null);M.useEffect(()=>{s.current||(r(t),l.current=null)},[t]);const c=()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null);const f=a.current;f.local===f.value||f.local===l.current||(l.current=f.local,f.onCommit(f.local))},u=M.useRef(c);return u.current=c,M.useEffect(()=>()=>u.current(),[]),d.jsx(st,{label:e,children:d.jsx("textarea",{rows:2,value:o,onFocus:()=>{s.current=!0},onChange:f=>{r(f.target.value),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,u.current()},hE)},onBlur:()=>{s.current=!1,c()},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function Cn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=M.useState(String(t)),a=M.useRef(null);return M.useEffect(()=>i(String(t)),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:Se("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",o&&"pr-8")}),o&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Bo({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:Se("flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",e?"border-[var(--selection)] bg-[var(--selection)]/15 text-foreground":"border-border/60 text-muted-foreground hover:bg-accent"),"aria-pressed":e,children:n})}function mE({id:e,element:t,field:n}){var l;const o=le(),s=Jt()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const u={...t.state??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:s,children:d.jsx(Bo,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(Cn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(Ke,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function pE(){const e=le(),t=Jt(),n=y(g=>g.selection),o=y(g=>g.selectedNode),r=y(g=>g.selectedWire),s=y(g=>g.selectedAnnotation),i=y(g=>g.diagram.annotations),a=y(g=>g.diagram.elements),l=y(g=>g.diagram.buses),c=rt(),u=Oe(c,"dense");if(n.length===0&&!o&&!r&&!s)return null;let f=e("props.title"),m=null;if(r)f=e("props.wire");else if(o)f=e("props.node");else if(s){const g=(i??[]).find(h=>h.id===s),p=g?Le(g):"text";f=e(p==="rect"?"props.annRect":p==="line"?"props.annLine":p==="table"?"props.annTable":"props.annText")}else if(n.length===1){const g=n[0],p=(l??[]).find(h=>h.id===g);if(p)f=p.name??e("props.bus");else{const h=a.find(x=>x.id===g);if(h){const x=ot[h.kind];f=x?t(`${x.id}.name`,x.name):h.kind}}}else m=n.length;return d.jsxs("aside",{className:Se("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",u?"w-48":"w-56"),style:{top:`calc(${u?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px) + var(--ole-safe-top, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",maxHeight:`calc(100% - ${u?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-safe-top, 0px) - var(--ole-bottom-inset, 0px) - var(--ole-safe-bottom, 0px) - 4.5rem)`},children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:f}),m!=null&&d.jsx("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})})]}),d.jsx(Z6,{})]})}function gE(){M.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function yE(){gE();const e=y(o=>o.readOnly),t=M.useRef(null),n=S4(t);return d.jsx(lk,{children:d.jsx("div",{ref:t,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(t6,{width:n,children:[d.jsx(Y4,{}),e?d.jsxs(d.Fragment,{children:[d.jsx(as,{}),d.jsx(Qr,{})]}):d.jsxs(d.Fragment,{children:[d.jsx(I6,{}),d.jsx(pE,{}),d.jsx(T6,{}),d.jsx(as,{}),d.jsx(g6,{}),d.jsx(x6,{}),d.jsx(X6,{}),d.jsx(J6,{}),d.jsx(Qr,{})]})]})})})}const xE="ole-theme";function bE(){try{const e=window.localStorage.getItem(xE);return e==="light"||e==="dark"?e:null}catch{return null}}function wE(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function vE(){return typeof window>"u"?"light":bE()??(wE()?"dark":"light")}function Dv(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function kE({className:e,diagram:t,readOnly:n,locale:o,theme:r}){return M.useEffect(()=>{y.getState().setReadOnly(!!n)},[n]),M.useEffect(()=>{if(!t)return;if(n){y.getState().setDiagram(t),y.getState().setActiveTool("pan");return}y.getState().diagram.elements.length===0&&y.getState().setDiagram(t)},[t,n]),M.useEffect(()=>{o&&Yt.getState().setLocale(o)},[o]),M.useEffect(()=>{r&&Dv(r)},[r]),M.useEffect(()=>{Co()},[]),i4(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(yE,{})})}const zv={"application/json":[".json"]},Rv=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",Fv=e=>e instanceof DOMException&&e.name==="AbortError";function ps(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(ve("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(ve("io.notObject"));const n=t;if(n.version!=="1")throw new Error(ve("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(ve("io.elementsMissing"));return n}function _E(e){return JSON.stringify(e,null,2)+`
220
- `}async function SE(){if(Rv()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:ve("topbar.file.fileDescription"),accept:zv}]})}catch(n){if(Fv(n))return null;throw n}const t=await e.getFile();return{diagram:ps(await t.text()),session:{handle:e,name:t.name}}}return new Promise((e,t)=>{const n=document.createElement("input");n.type="file",n.accept=".json,application/json",n.addEventListener("change",async()=>{var r;const o=(r=n.files)==null?void 0:r[0];if(!o)return e(null);try{e({diagram:ps(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function gs(e,t,n={}){const o=_E(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(Rv()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:ve("topbar.file.fileDescription"),accept:zv}]})}catch(l){if(Fv(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const r=URL.createObjectURL(new Blob([o],{type:"application/json"})),s=document.createElement("a");return s.href=r,s.download=(t==null?void 0:t.name)??"diagram.json",s.click(),URL.revokeObjectURL(r),t??{name:"diagram.json"}}function $E(){const e=le(),t=y(f=>f.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=jE(),[a,l]=M.useState(!1),c=M.useRef(null);M.useEffect(()=>{const f=m=>{if(!(m.metaKey||m.ctrlKey))return;const g=m.key.toLowerCase();g==="o"?(m.preventDefault(),r()):g==="s"&&(m.preventDefault(),m.shiftKey?i():s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,s,i]),M.useEffect(()=>{if(!a)return;const f=g=>{c.current&&!c.current.contains(g.target)&&l(!1)},m=g=>{g.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",m),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",m)}},[a]);const u=f=>()=>{l(!1),f()};return d.jsxs("div",{ref:c,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(f=>!f),children:[d.jsx(rr,{}),e("topbar.file.label")]}),a&&d.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-44 rounded-md border border-border p-1 shadow-md",children:[d.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),d.jsx(un,{onClick:u(o),icon:d.jsx(p2,{}),children:e("topbar.file.new")}),d.jsx(un,{onClick:u(r),icon:d.jsx(rr,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(un,{onClick:u(s),icon:d.jsx(sr,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(un,{onClick:u(i),icon:d.jsx(sr,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function un({children:e,icon:t,hint:n,onClick:o}){return d.jsxs("button",{type:"button",role:"menuitem",onClick:o,className:"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",children:[t,d.jsx("span",{className:"flex-1",children:e}),n&&d.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function jE(){const e=le(),t=y(l=>l.loadDiagramFromFile),n=y(l=>l.setFileSession),o=y(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=y.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await SE();l&&(t(l.diagram,l.session),Co())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const eo="WIRES",Ue="ELEMENTS",to="LABELS",De="ANNOTATIONS",ys=32,xs=64,EE=8,NE=1.25,AE=6;function Hv(e,t={}){var r,s;const n=new HE(t.precision??6);n.header(t.title),n.tables([{name:eo,color:7},{name:Ue,color:7},{name:to,color:8},{name:De,color:3}]),n.beginEntities();for(const i of e.wireRenders.values())i.path.length<2||n.lwpolyline(eo,i.path.map(ye),!1);for(const{geometry:i}of e.buses.values()){const{axis:a,at:l,span:c}=i,u=c/2,f=a==="x"?[l[0]-u,l[1]]:[l[0],l[1]-u],m=a==="x"?[l[0]+u,l[1]]:[l[0],l[1]+u];n.lwpolyline(eo,[f,m].map(ye),!1)}for(const i of e.elements.values()){const a=e.layout.get(i.element.id),l=i.libraryDef;!a||!l||TE(n,l.svg,a)}const o=t.labelMode??"all";if(o!=="off"){for(const i of e.elements.values()){const a=e.layout.get(i.element.id);if(!a||!i.libraryDef)continue;const l=jn(i,o);if(l.length===0)continue;const c=i.libraryDef.label??En(i.libraryDef),{world:[u,f],textAnchor:m,dy:g}=Nn(c,i.libraryDef,a,l.length);for(let p=0;p<l.length;p++){const[h,x]=ye([u,f+g+p*Gt]);n.text(to,[h,x],l[p],ze,0,!1,m)}}for(const i of e.wireRenders.values()){const a=(r=i.label)==null?void 0:r.trim();if(!a)continue;const l=An(i.path);if(!l)continue;const c=ye(l.world);n.text(to,c,a,ze,0,!1,l.textAnchor)}}for(const i of t.annotations??[])switch(Le(i)){case"rect":{const a=i,[l,c]=a.at,[u,f]=a.size;if(n.lwpolyline(De,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0),a.label){const m=ye([l+gt,c+gt+qe]);n.text(De,m,a.label,qe,0,!1)}break}case"line":{const a=i,l=Ut(a);if(l.length<2)break;n.lwpolyline(De,l.map(ye),!1);for(const c of To(l,a.arrow))n.lwpolyline(De,c.map(ye),!0);break}case"table":{const a=i,[l,c]=a.at,[u,f]=Ge(a),m=wt(a),g=vt(a),p=a.fontSize??qe;n.lwpolyline(De,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0);for(let h=1;h<a.colWidths.length;h++)n.line(De,ye([l+m[h],c]),ye([l+m[h],c+f]));for(let h=1;h<a.rowHeights.length;h++)n.line(De,ye([l,c+g[h]]),ye([l+u,c+g[h]]));for(let h=0;h<a.rowHeights.length;h++)for(let x=0;x<a.colWidths.length;x++){const w=((s=a.cells[h])==null?void 0:s[x])??"";if(w==="")continue;const v=ye([l+m[x]+Ft,c+g[h]+a.rowHeights[h]/2+p*.35]);n.text(De,v,w,p,0,!1)}break}default:{const a=i;if(!a.text)break;const l=a.fontSize??EE,c=a.text.split(`
221
- `);for(let u=0;u<c.length;u++){const[f,m]=ye([a.at[0],a.at[1]+(u+1)*l*NE]);n.text(De,[f,m],c[u],l,0,!1)}break}}return n.endEntities(),n.toString()}async function Wv(e,t="diagram.dxf",n){const o=Hv(e,n),r=URL.createObjectURL(new Blob([o],{type:"application/dxf;charset=utf-8"})),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}function TE(e,t,n){const o=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,s=new DOMParser().parseFromString(o,"image/svg+xml").documentElement;if(!(!s||s.querySelector("parsererror")))for(const i of Array.from(s.children))switch(i.tagName.toLowerCase()){case"line":ME(e,i,n);break;case"polyline":bs(e,i,n,!1);break;case"polygon":bs(e,i,n,!0);break;case"rect":CE(e,i,n);break;case"circle":PE(e,i,n);break;case"ellipse":IE(e,i,n);break;case"path":DE(e,i,n);break;case"text":LE(e,i,n);break}}function ME(e,t,n){const o=ke(t,"x1"),r=ke(t,"y1"),s=ke(t,"x2"),i=ke(t,"y2"),a=ye(Ye([o,r],n)),l=ye(Ye([s,i],n));e.line(Ue,a,l)}function bs(e,t,n,o){const r=FE(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>ye(Ye(i,n)));e.lwpolyline(Ue,s,o)}function CE(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=ke(t,"width"),i=ke(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(c=>ye(Ye(c,n)));e.lwpolyline(Ue,l,!0)}function PE(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"r"),i=ye(Ye([o,r],n));e.circle(Ue,i,s)}function IE(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"rx"),i=ke(t,"ry");if(Math.abs(s-i)<1e-6){OE(e,o,r,s,n);return}BE(e,o,r,s,i,n)}function OE(e,t,n,o,r){const s=ye(Ye([t,n],r));e.circle(Ue,s,o)}function BE(e,t,n,o,r,s){const i=[];for(let a=0;a<xs;a++){const l=a/xs*Math.PI*2;i.push(ye(Ye([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Ue,i,!0)}function LE(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||AE,i=(t.textContent??"").trim();if(!i)return;const a=ye(Ye([o,r],n));e.text(Ue,a,i,s,n.rot,n.mirror)}function DE(e,t,n){const o=t.getAttribute("d")??"",r=zE(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Ue,i.map(l=>ye(Ye(l,n))),!1),i=[]};for(const l of r)if(l.cmd==="M")a(),s=[l.args[0],l.args[1]],i.push(s);else if(l.cmd==="A"&&s){const[c,u,,f,m,g,p]=l.args,h=RE(s,[g,p],c,u,f!==0,m!==0);if(h)for(let x=1;x<=ys;x++){const w=h.theta1+h.delta*x/ys;i.push([h.cx+c*Math.cos(w),h.cy+u*Math.sin(w)])}else i.push([g,p]);s=[g,p]}a()}function zE(e){const t=[],n=/([MmAa])([^MmAa]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1].toUpperCase(),s=o[2].trim().split(/[\s,]+/).filter(i=>i.length>0).map(Number);t.push({cmd:r,args:s})}return t}function RE(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,c]=t;if(i===l&&a===c)return null;const u=(i-l)/2,f=(a-c)/2;let m=Math.abs(n),g=Math.abs(o);const p=m*m,h=g*g,x=u*u/p+f*f/h;if(x>1){const R=Math.sqrt(x);m*=R,g*=R}const w=r===s?-1:1,v=m*m*g*g-m*m*f*f-g*g*u*u,C=m*m*f*f+g*g*u*u,O=w*Math.sqrt(Math.max(0,v/C)),F=O*(m*f)/g,G=O*-(g*u)/m,$=F+(i+l)/2,H=G+(a+c)/2,W=(R,Z,ie,ue)=>{const ee=R*ie+Z*ue,ae=Math.hypot(R,Z)*Math.hypot(ie,ue);let me=Math.acos(Math.max(-1,Math.min(1,ee/ae)));return R*ue-Z*ie<0&&(me=-me),me},X=W(1,0,(u-F)/m,(f-G)/g);let P=W((u-F)/m,(f-G)/g,(-u-F)/m,(-f-G)/g);return!s&&P>0?P-=2*Math.PI:s&&P<0&&(P+=2*Math.PI),{cx:$,cy:H,theta1:X,delta:P}}function Ye(e,t){return Ie(e,t)}function ye(e){return[e[0],-e[1]]}function ke(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function FE(e){const t=e.trim().split(/[\s,]+/).map(Number).filter(o=>Number.isFinite(o)),n=[];for(let o=0;o+1<t.length;o+=2)n.push([t[o],t[o+1]]);return n}class HE{constructor(t){jt(this,"out",[]);jt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
216
+ */const Sn=se("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Is(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Is(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Os(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Is(e))&&(o&&(o+=" "),o+=t);return o}const No="-",J2=e=>{const t=Q2(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(No);return a[0]===""&&a.length!==1&&a.shift(),Bs(a,t)||Z2(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Bs=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Bs(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(No);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},ir=/^\[(.+)\]$/,Z2=e=>{if(ir.test(e)){const t=ir.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Q2=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return tk(Object.entries(e.classGroups),n).forEach(([s,i])=>{oo(i,o,s,t)}),o},oo=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:ar(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(ek(r)){oo(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{oo(i,ar(t,s),n,o)})})},ar=(e,t)=>{let n=e;return t.split(No).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},ek=e=>e.isThemeGetter,tk=(e,t)=>t?e.map(([n,o])=>{const r=o.map(s=>typeof s=="string"?t+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([i,a])=>[t+i,a])):s);return[n,r]}):e,nk=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(s,i)=>{n.set(s,i),t++,t>e&&(t=0,o=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=o.get(s))!==void 0)return r(s,i),i},set(s,i){n.has(s)?n.set(s,i):r(s,i)}}},Ds="!",ok=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let c=0,u=0,f;for(let x=0;x<a.length;x++){let w=a[x];if(c===0){if(w===r&&(o||a.slice(x,x+s)===t)){l.push(a.slice(u,x)),u=x+s;continue}if(w==="/"){f=x;continue}}w==="["?c++:w==="]"&&c--}const h=l.length===0?a:a.substring(u),g=h.startsWith(Ds),m=g?h.substring(1):h,p=f&&f>u?f-u:void 0;return{modifiers:l,hasImportantModifier:g,baseClassName:m,maybePostfixModifierPosition:p}};return n?a=>n({className:a,parseClassName:i}):i},rk=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},sk=e=>({cache:nk(e.cacheSize),parseClassName:ok(e),...J2(e)}),ik=/\s+/,ak=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(ik);let a="";for(let l=i.length-1;l>=0;l-=1){const c=i[l],{modifiers:u,hasImportantModifier:f,baseClassName:h,maybePostfixModifierPosition:g}=n(c);let m=!!g,p=o(m?h.substring(0,g):h);if(!p){if(!m){a=c+(a.length>0?" "+a:a);continue}if(p=o(h),!p){a=c+(a.length>0?" "+a:a);continue}m=!1}const x=rk(u).join(":"),w=f?x+Ds:x,v=w+p;if(s.includes(v))continue;s.push(v);const M=r(p,m);for(let I=0;I<M.length;++I){const F=M[I];s.push(w+F)}a=c+(a.length>0?" "+a:a)}return a};function lk(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Ls(t))&&(o&&(o+=" "),o+=n);return o}const Ls=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Ls(e[o]))&&(n&&(n+=" "),n+=t);return n};function ck(e,...t){let n,o,r,s=i;function i(l){const c=t.reduce((u,f)=>f(u),e());return n=sk(c),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const c=o(l);if(c)return c;const u=ak(l,n);return r(l,u),u}return function(){return s(lk.apply(null,arguments))}}const ge=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},zs=/^\[(?:([a-z-]+):)?(.+)\]$/i,dk=/^\d+\/\d+$/,uk=new Set(["px","full","screen"]),fk=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hk=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,mk=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pk=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gk=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Re=e=>mt(e)||uk.has(e)||dk.test(e),Je=e=>bt(e,"length",Sk),mt=e=>!!e&&!Number.isNaN(Number(e)),zn=e=>bt(e,"number",mt),Et=e=>!!e&&Number.isInteger(Number(e)),yk=e=>e.endsWith("%")&&mt(e.slice(0,-1)),re=e=>zs.test(e),Ze=e=>fk.test(e),xk=new Set(["length","size","percentage"]),bk=e=>bt(e,xk,Rs),wk=e=>bt(e,"position",Rs),vk=new Set(["image","url"]),kk=e=>bt(e,vk,jk),_k=e=>bt(e,"",$k),Nt=()=>!0,bt=(e,t,n)=>{const o=zs.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},Sk=e=>hk.test(e)&&!mk.test(e),Rs=()=>!1,$k=e=>pk.test(e),jk=e=>gk.test(e),Ek=()=>{const e=ge("colors"),t=ge("spacing"),n=ge("blur"),o=ge("brightness"),r=ge("borderColor"),s=ge("borderRadius"),i=ge("borderSpacing"),a=ge("borderWidth"),l=ge("contrast"),c=ge("grayscale"),u=ge("hueRotate"),f=ge("invert"),h=ge("gap"),g=ge("gradientColorStops"),m=ge("gradientColorStopPositions"),p=ge("inset"),x=ge("margin"),w=ge("opacity"),v=ge("padding"),M=ge("saturate"),I=ge("scale"),F=ge("sepia"),G=ge("skew"),$=ge("space"),H=ge("translate"),W=()=>["auto","contain","none"],X=()=>["auto","hidden","clip","visible","scroll"],P=()=>["auto",re,t],R=()=>[re,t],Z=()=>["",Re,Je],ie=()=>["auto",mt,re],ue=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ee=()=>["solid","dashed","dotted","double","none"],ae=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],me=()=>["start","end","center","between","around","evenly","stretch"],be=()=>["","0",re],$e=()=>["auto","avoid","all","avoid-page","page","left","right","column"],Me=()=>[mt,re];return{cacheSize:500,separator:":",theme:{colors:[Nt],spacing:[Re,Je],blur:["none","",Ze,re],brightness:Me(),borderColor:[e],borderRadius:["none","","full",Ze,re],borderSpacing:R(),borderWidth:Z(),contrast:Me(),grayscale:be(),hueRotate:Me(),invert:be(),gap:R(),gradientColorStops:[e],gradientColorStopPositions:[yk,Je],inset:P(),margin:P(),opacity:Me(),padding:R(),saturate:Me(),scale:Me(),sepia:be(),skew:Me(),space:R(),translate:R()},classGroups:{aspect:[{aspect:["auto","square","video",re]}],container:["container"],columns:[{columns:[Ze]}],"break-after":[{"break-after":$e()}],"break-before":[{"break-before":$e()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ue(),re]}],overflow:[{overflow:X()}],"overflow-x":[{"overflow-x":X()}],"overflow-y":[{"overflow-y":X()}],overscroll:[{overscroll:W()}],"overscroll-x":[{"overscroll-x":W()}],"overscroll-y":[{"overscroll-y":W()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Et,re]}],basis:[{basis:P()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",re]}],grow:[{grow:be()}],shrink:[{shrink:be()}],order:[{order:["first","last","none",Et,re]}],"grid-cols":[{"grid-cols":[Nt]}],"col-start-end":[{col:["auto",{span:["full",Et,re]},re]}],"col-start":[{"col-start":ie()}],"col-end":[{"col-end":ie()}],"grid-rows":[{"grid-rows":[Nt]}],"row-start-end":[{row:["auto",{span:[Et,re]},re]}],"row-start":[{"row-start":ie()}],"row-end":[{"row-end":ie()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",re]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",re]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...me()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...me(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...me(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",re,t]}],"min-w":[{"min-w":[re,t,"min","max","fit"]}],"max-w":[{"max-w":[re,t,"none","full","min","max","fit","prose",{screen:[Ze]},Ze]}],h:[{h:[re,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[re,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[re,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Ze,Je]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",zn]}],"font-family":[{font:[Nt]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",re]}],"line-clamp":[{"line-clamp":["none",mt,zn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Re,re]}],"list-image":[{"list-image":["none",re]}],"list-style-type":[{list:["none","disc","decimal",re]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[w]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[w]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ee(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Re,Je]}],"underline-offset":[{"underline-offset":["auto",Re,re]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[w]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ue(),wk]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",bk]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},kk]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[g]}],"gradient-via":[{via:[g]}],"gradient-to":[{to:[g]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[w]}],"border-style":[{border:[...ee(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[w]}],"divide-style":[{divide:ee()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...ee()]}],"outline-offset":[{"outline-offset":[Re,re]}],"outline-w":[{outline:[Re,Je]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[w]}],"ring-offset-w":[{"ring-offset":[Re,Je]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Ze,_k]}],"shadow-color":[{shadow:[Nt]}],opacity:[{opacity:[w]}],"mix-blend":[{"mix-blend":[...ae(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ae()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Ze,re]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[F]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[w]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[F]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",re]}],duration:[{duration:Me()}],ease:[{ease:["linear","in","out","in-out",re]}],delay:[{delay:Me()}],animate:[{animate:["none","spin","ping","pulse","bounce",re]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[Et,re]}],"translate-x":[{"translate-x":[H]}],"translate-y":[{"translate-y":[H]}],"skew-x":[{"skew-x":[G]}],"skew-y":[{"skew-y":[G]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",re]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",re]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",re]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Re,Je,zn]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Nk=ck(Ek);function _e(...e){return Nk(Os(e))}const Fs=C.createContext(null);function Ak(){const e=C.useContext(Fs);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const en=8;function Tk({children:e}){const[t,n]=C.useState({open:!1,x:0,y:0,items:[]}),[o,r]=C.useState(null),s=C.useRef(null),i=C.useCallback(()=>{n(c=>c.open?{...c,open:!1}:c)},[]),a=C.useCallback((c,u,f)=>{r(null),n({open:!0,x:c,y:u,items:f})},[]),l=C.useMemo(()=>({open:a,close:i}),[a,i]);return C.useLayoutEffect(()=>{if(!t.open||!s.current)return;const c=s.current.getBoundingClientRect();let u=t.x,f=t.y;u+c.width>window.innerWidth-en&&(u=Math.max(en,t.x-c.width)),f+c.height>window.innerHeight-en&&(f=Math.max(en,t.y-c.height)),r({left:u,top:f})},[t]),C.useEffect(()=>{if(!t.open)return;const c=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},f=()=>i(),h=()=>i();return document.addEventListener("pointerdown",c,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",f,{passive:!0}),window.addEventListener("blur",h),()=>{document.removeEventListener("pointerdown",c,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",f),window.removeEventListener("blur",h)}},[t.open,i]),d.jsxs(Fs.Provider,{value:l,children:[e,t.open&&d.jsx("div",{ref:s,role:"menu","aria-orientation":"vertical",className:"ole-glass fixed z-50 min-w-[200px] rounded-md border border-border p-1 text-sm shadow-md",style:{left:(o==null?void 0:o.left)??t.x,top:(o==null?void 0:o.top)??t.y,visibility:o?"visible":"hidden"},onContextMenu:c=>c.preventDefault(),children:t.items.map((c,u)=>{if(c.type==="separator")return d.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const f=c.icon;return d.jsxs("button",{type:"button",role:"menuitem",disabled:c.disabled,className:_e("flex w-full items-center justify-between gap-3 rounded-sm px-2 py-1.5 text-left","hover:bg-accent hover:text-accent-foreground","focus-visible:bg-accent focus-visible:text-accent-foreground focus-visible:outline-none",c.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",c.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),c.onSelect()},children:[d.jsxs("span",{className:"flex items-center gap-2",children:[f?d.jsx(f,{className:"size-4"}):null,d.jsx("span",{children:c.label})]}),c.shortcut?d.jsx("span",{className:"text-xs text-muted-foreground",children:c.shortcut}):null]},`${c.label}-${u}`)})})]})}const lr=e=>{let t;const n=new Set,o=(c,u)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(o,r,a);return a},Mk=(e=>e?lr(e):lr),Ck=e=>e;function Pk(e,t=Ck){const n=C.useSyncExternalStore(e.subscribe,C.useCallback(()=>t(e.getState()),[e,t]),C.useCallback(()=>t(e.getInitialState()),[e,t]));return C.useDebugValue(n),n}const cr=e=>{const t=Mk(e),n=o=>Pk(t,o);return Object.assign(n,t),n},$n=(e=>e?cr(e):cr),dr={zh:{"common.unnamed":"未命名","common.close":"关闭","common.yes":"是","common.no":"否","topbar.theme.toLight":"切换到亮色","topbar.theme.toDark":"切换到暗色","topbar.theme.currentDark":"当前:暗色主题","topbar.theme.currentLight":"当前:亮色主题","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"当前:中文","topbar.export.label":"导出","topbar.export.tooltip":"SVG 矢量(可编辑)、PNG 位图(2× 高清)或 DXF(CAD)","topbar.export.pngFailed":"导出 PNG 失败:{err}","topbar.export.dxfFailed":"导出 DXF 失败:{err}","topbar.file.label":"文件","topbar.file.tooltip":"打开本地 .json 图、保存、或另存为","topbar.file.current":"当前:{name}","topbar.file.new":"新建","topbar.file.open":"打开…","topbar.file.save":"保存","topbar.file.saveAs":"另存为…","topbar.file.newConfirm":"新建会清空当前未保存的内容,是否继续?","topbar.file.openFailed":"打开失败:{err}","topbar.file.saveFailed":"保存失败:{err}","topbar.file.fileDescription":"OneLineEditor 图纸","outline.title":"大纲","outline.collapse":"折叠","outline.collapseAria":"折叠大纲","outline.empty":"(无设备 — 从元件库拖入开始)","props.title":"属性","props.node":"电气节点","props.wire":"连线","props.bus":"母线","props.junction":"接线柱","props.junctionPos":"位置","props.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.label":"标注","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","props.annText":"文字","props.annRect":"矩形","props.annLine":"线条","props.annTable":"表格","props.annNotFound":"标注 {id} 不存在","props.annLabel":"标签","props.annLabelPlaceholder":"如:1#配电柜","props.annStroke":"线型","props.annStrokeSolid":"实线","props.annStrokeDashed":"虚线","props.annFill":"填充","props.annFillNone":"无","props.annFillTint":"浅色","props.annArrow":"箭头","props.annArrowNone":"无","props.annArrowEnd":"单向","props.annArrowBoth":"双向","props.annFontSize":"字号","props.annRows":"行数","props.annCols":"列数","view.zoomOut":"缩小","view.zoomOutHint":"按预设档位缩小;也可滚轮 ↓ 或 ⌘−","view.reset":"重置到 100%","view.current":"当前 {z}%","view.zoomIn":"放大","view.zoomInHint":"按预设档位放大;也可滚轮 ↑ 或 ⌘+","view.fit":"适配视图","view.fitHint":"自动缩放并居中所有元件","view.gridHide":"隐藏网格","view.gridShow":"显示网格","view.gridHotkey":"G","view.gridHideHint":"同时关闭对齐吸附(拖动可自由放置)","view.gridShowHint":"同时开启对齐吸附(拖动会贴到 10px 网格)","view.gridHideAria":"隐藏网格并关闭吸附","view.gridShowAria":"显示网格并开启吸附","view.label":"标签","view.labelOff":"关闭标签","view.labelId":"仅显示 ID","view.labelAll":"ID + 参数","view.labelHint":"点击循环切换:关闭 → 仅 ID → ID + 参数","library.title":"元件库","library.empty":"没有匹配的元件","library.searchPlaceholder":"搜索元件…","library.searchAria":"搜索元件","library.clearSearch":"清除搜索","library.itemHint":"单击进入放置模式或拖到画布","tool.select":"选择","tool.selectHint":"点选元件,框选多个,或右键打开菜单","tool.pan":"平移","tool.panHint":"拖动画布;空格键可临时切换","tool.wire":"连线","tool.wireHint":"从端子/母线/接线柱拖出;拖到空白处会自动新建接线柱,拖到已有连线上可打接点","tool.bus":"母线","tool.busHint":"画布上拖动一段母线,按下定起点、释放定终点","tool.junction":"接线柱","tool.junctionHint":"点击画布放置一个接线柱(接点),连线可自由连到它","tool.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","tool.rect":"矩形","tool.rectHint":"拖动绘制矩形 / 分组框(默认虚线);按住 Shift 画正方形","tool.line":"线条","tool.lineHint":"拖动绘制标注线;按住 Shift 按 45° 约束;箭头在属性面板设置","tool.table":"表格","tool.tableHint":"拖动扫出行列(实时显示 列×行),或单击放置默认表格;双击单元格填写","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到端子/母线/接线柱释放;空白处释放会新建接线柱","mode.wireInit":"从任意连接点或空白处按下,拖到目标释放;空白处会新建接线柱","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.junction":"点击画布放置一个接线柱","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","mode.rect":"拖动绘制矩形;Shift 正方形;释放后可拉伸并在属性面板加标签","mode.line":"拖动绘制线条;Shift 按 45° 约束;释放后可在属性面板加箭头","mode.table":"拖动扫出表格行列,或单击放置 3×3 表格;双击单元格填写内容","mode.annTextSel":"单击文字即可编辑 · 拖动移动 · Del 删除","mode.annTableSel":"单击单元格填写内容 · 拖动移动 · Del 删除","mode.annShapeSel":"拖动移动 · 拖动手柄缩放 · 右侧面板改样式 · Del 删除","mode.annEditing":"输入内容 · Enter 确认 · Esc 取消 · 或用 ✓ / ✕ 按钮","mode.escSelect":"Esc 清除选择","mode.escOther":"右键 / Esc 取消","tool.placeNoKindTooltip":"从左侧元件库选择一个元件后点击画布放置","tool.undo":"撤销","tool.undoHint":"撤销上一次编辑(移动 / 旋转 / 删除等)","tool.redo":"重做","tool.redoHint":"重做被撤销的操作","layout.label":"布局","layout.hint":"自动排版整个图或仅选中范围,并填补空缺","layout.allAuto":"重新自动布局","layout.selAuto":"重新自动布局选区","layout.allFill":"填补未排版位置","layout.selFill":"填补未排版选区","tool.more":"更多","tool.moreHint":"撤销 / 重做 / 布局","view.menu":"视图","view.menuHint":"缩放、适配、网格","ctx.ariaNode":"选中节点操作","ctx.ariaWire":"选中连线操作","ctx.ariaElement":"选中元件操作","ctx.ariaEdit":"编辑操作","ctx.done":"完成","ctx.cancel":"取消","ctx.rotate":"旋转 90°","ctx.rotateHint":"顺时针旋转选中元件,连线随端子自动重排","ctx.mirror":"水平镜像","ctx.mirrorTitle":"镜像","ctx.mirrorHint":"左右翻转选中元件","ctx.delete":"删除","ctx.deleteHintNode":"断开此电气节点上的所有连接(保留元件)","ctx.deleteHintWire":"移除这一根连线(其它同节点连线保留)","ctx.deleteHintElement":"移除选中元件及其连接的连线","ctx.resetWirePath":"恢复自动走线","ctx.resetWirePathHint":"清除手动调整的拐点,让连线回到自动路由","menu.undo":"撤销","menu.redo":"重做","menu.cut":"剪切","menu.copy":"复制","menu.paste":"粘贴","menu.rotate":"旋转 90°","menu.mirror":"镜像","menu.selectAll":"全选","menu.disconnect":"断开此连线","menu.delete":"删除","io.parseFailed":"JSON 解析失败:{err}","io.notObject":"文件不是 JSON 对象","io.versionMismatch":'版本不兼容:期望 "1",实际 {actual}',"io.elementsMissing":"elements 字段缺失或不是数组","compile.duplicateId":'元件 ID 重复:"{id}"',"compile.unknownKind":'未知元件类型 kind="{kind}"',"compile.invalidTermRef":'非法端子引用 "{ref}"',"compile.elementMissing":'引用了不存在的元件 "{id}"',"compile.missingPin":'元件 "{id}" (kind={kind}) 没有引脚 "{pin}",可用引脚: {available}',"compile.singleTerminal":"节点只包含一个端子,已忽略","compile.layoutMissingElement":'layout 键 "{id}" 引用了不存在的元件',"compile.elementUnconnected":'元件 "{id}" 没有任何连接',"cat.busbar":"母线 / 接线","cat.switching":"开关","cat.protection":"保护","cat.motor-control":"电机控制","cat.transformer":"变压器","cat.instrument-transformer":"互感器","cat.measurement":"测量仪表","cat.source":"电源","cat.load":"负荷","cat.storage":"储能","cat.compensation":"无功补偿","cat.grounding":"中性点接地","cat.renewable":"新能源 / 电力电子","onboard.title":"上手三步","onboard.step1.title":"放一个器件","onboard.step1.body":"切到 元件 工具(P),从左侧元件库选一种拖到画布","onboard.step2.title":"拉线连接","onboard.step2.body":"用 连线 工具(W)从一个引脚拖到另一个引脚;拖到空白处会自动新建接线柱","onboard.step3.title":"母线是共用排,不是连线","onboard.step3.body":"几条回路共用一排时才用 母线 工具(B)。别拿母线连两个器件——点对点直接拉线(W)就行。","onboard.dismiss":"知道了"},en:{"common.unnamed":"Untitled","common.close":"Close","common.yes":"Yes","common.no":"No","topbar.theme.toLight":"Switch to light","topbar.theme.toDark":"Switch to dark","topbar.theme.currentDark":"Current: dark theme","topbar.theme.currentLight":"Current: light theme","topbar.lang.toEnglish":"Switch to English","topbar.lang.toChinese":"切换到中文","topbar.lang.currentEnglish":"Current: English","topbar.lang.currentChinese":"Current: Chinese","topbar.export.label":"Export","topbar.export.tooltip":"SVG vector (editable), PNG bitmap (2× HiDPI), or DXF (CAD)","topbar.export.pngFailed":"PNG export failed: {err}","topbar.export.dxfFailed":"DXF export failed: {err}","topbar.file.label":"File","topbar.file.tooltip":"Open a local .json diagram, save, or save as","topbar.file.current":"Current: {name}","topbar.file.new":"New","topbar.file.open":"Open…","topbar.file.save":"Save","topbar.file.saveAs":"Save as…","topbar.file.newConfirm":"New will discard any unsaved changes. Continue?","topbar.file.openFailed":"Open failed: {err}","topbar.file.saveFailed":"Save failed: {err}","topbar.file.fileDescription":"OneLineEditor diagram","outline.title":"Outline","outline.collapse":"Collapse","outline.collapseAria":"Collapse outline","outline.empty":"(No elements — drag from the library to start)","props.title":"Properties","props.node":"Electrical node","props.wire":"Wire","props.bus":"Bus","props.junction":"Junction","props.junctionPos":"Position","props.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","props.label":"Label","props.labelPlaceholder":"L1 / L2 / L3 / N / PE","props.nodeNotFound":"Electrical node {id} not found","props.wireNotFound":"Wire {id} not found","props.nodeStats":"{terminals} terminals · {elements} elements","props.selectElement":"Select {label}","props.selectWholeNode":"Select whole electrical node","props.annText":"Text","props.annRect":"Rectangle","props.annLine":"Line","props.annTable":"Table","props.annNotFound":"Annotation {id} not found","props.annLabel":"Label","props.annLabelPlaceholder":"e.g. Panel #1","props.annStroke":"Stroke","props.annStrokeSolid":"Solid","props.annStrokeDashed":"Dashed","props.annFill":"Fill","props.annFillNone":"None","props.annFillTint":"Tint","props.annArrow":"Arrows","props.annArrowNone":"None","props.annArrowEnd":"End","props.annArrowBoth":"Both","props.annFontSize":"Font size","props.annRows":"Rows","props.annCols":"Columns","view.zoomOut":"Zoom out","view.zoomOutHint":"Step zoom out; also wheel ↓ or ⌘−","view.reset":"Reset to 100%","view.current":"Current {z}%","view.zoomIn":"Zoom in","view.zoomInHint":"Step zoom in; also wheel ↑ or ⌘+","view.fit":"Fit view","view.fitHint":"Auto-zoom and center all elements","view.gridHide":"Hide grid","view.gridShow":"Show grid","view.gridHotkey":"G","view.gridHideHint":"Also disables snap-to-grid (free placement)","view.gridShowHint":"Also enables snap-to-grid (snaps to 10px on drag)","view.gridHideAria":"Hide grid and disable snap","view.gridShowAria":"Show grid and enable snap","view.label":"Labels","view.labelOff":"Hide labels","view.labelId":"ID only","view.labelAll":"ID + params","view.labelHint":"Cycle: off → ID → ID + params","library.title":"Library","library.empty":"No matching elements","library.searchPlaceholder":"Search elements…","library.searchAria":"Search elements","library.clearSearch":"Clear search","library.itemHint":"Click to enter place mode, or drag onto the canvas","tool.select":"Select","tool.selectHint":"Click to pick, marquee for multiple, right-click for menu","tool.pan":"Pan","tool.panHint":"Drag the canvas; Space toggles temporarily","tool.wire":"Wire","tool.wireHint":"Drag from a pin/bus/junction; into empty space drops a junction, onto a wire taps it","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","tool.junction":"Junction","tool.junctionHint":"Click the canvas to drop a junction (node); wires attach to it freely","tool.place":"Place","tool.placeHint":"Click to place; or drag from a terminal/bus to place and connect","tool.text":"Text","tool.textHint":"Click the canvas to drop a text note; double-click an existing one to edit","tool.rect":"Rectangle","tool.rectHint":"Drag to draw a rectangle / group frame (dashed by default); Shift for a square","tool.line":"Line","tool.lineHint":"Drag to draw an annotation line; Shift snaps to 45°; arrows live in the panel","tool.table":"Table","tool.tableHint":"Drag to sweep out cols × rows (live count), or click for a default table; double-click cells to type","mode.selectWithSel":"Drag elements · drag terminals to wire · right-click for menu","mode.selectEmpty":"Click to pick · drag to move · marquee for multiple · right-click for menu","mode.pan":"Drag the canvas · scroll to zoom · hold Space to pan in any tool","mode.wireDragging":"Release on a pin/bus/junction; release in empty space drops a junction","mode.wireInit":"Press on any connection point or empty space, drag to a target and release","mode.busDragging":"Drag sets bus direction; release sets the end","mode.busInit":"Press on the canvas to set start, drag, release to set end","mode.junction":"Click the canvas to drop a junction","mode.placeNoKind":"Pick an element kind from the library on the left","mode.placeFromTerm":"Release at the target — the new element will connect back to the source terminal","mode.placeNormal":"Click empty space to place; or drag from a terminal / bus to place and connect","mode.text":"Click to drop text · double-click to edit · drag selected to move · Del to remove","mode.rect":"Drag to draw a rectangle · Shift for square · resize and label it after release","mode.line":"Drag to draw a line · Shift snaps to 45° · add arrows in the panel after release","mode.table":"Drag to sweep out the grid, or click for a 3×3 table · double-click cells to type","mode.annTextSel":"Click the text to edit · drag to move · Del to remove","mode.annTableSel":"Click a cell to fill it in · drag to move · Del to remove","mode.annShapeSel":"Drag to move · drag handles to resize · restyle in the panel · Del to remove","mode.annEditing":"Type · Enter to confirm · Esc to cancel · or the ✓ / ✕ buttons","mode.escSelect":"Esc clears selection","mode.escOther":"Right-click / Esc to cancel","tool.placeNoKindTooltip":"Pick a kind in the library on the left, then click the canvas","tool.undo":"Undo","tool.undoHint":"Undo the last edit (move / rotate / delete, etc.)","tool.redo":"Redo","tool.redoHint":"Redo the last undone edit","layout.label":"Layout","layout.hint":"Auto-layout the whole diagram or just the selection, fill gaps","layout.allAuto":"Auto-layout all","layout.selAuto":"Auto-layout selection","layout.allFill":"Fill unplaced","layout.selFill":"Fill unplaced in selection","tool.more":"More","tool.moreHint":"Undo / redo / layout","view.menu":"View","view.menuHint":"Zoom, fit, grid","ctx.ariaNode":"Node actions","ctx.ariaWire":"Wire actions","ctx.ariaElement":"Element actions","ctx.ariaEdit":"Editing actions","ctx.done":"Done","ctx.cancel":"Cancel","ctx.rotate":"Rotate 90°","ctx.rotateHint":"Rotate selection clockwise; wires re-route through new terminals","ctx.mirror":"Mirror horizontally","ctx.mirrorTitle":"Mirror","ctx.mirrorHint":"Flip selection left-right","ctx.delete":"Delete","ctx.deleteHintNode":"Disconnect every wire on this node (elements stay)","ctx.deleteHintWire":"Remove only this wire (siblings on the same node stay)","ctx.deleteHintElement":"Remove the selection and its wires","ctx.resetWirePath":"Reset to auto-route","ctx.resetWirePathHint":"Drop manual corners and let the router re-draw this wire","menu.undo":"Undo","menu.redo":"Redo","menu.cut":"Cut","menu.copy":"Copy","menu.paste":"Paste","menu.rotate":"Rotate 90°","menu.mirror":"Mirror","menu.selectAll":"Select all","menu.disconnect":"Disconnect this wire","menu.delete":"Delete","io.parseFailed":"JSON parse failed: {err}","io.notObject":"File is not a JSON object","io.versionMismatch":'Version mismatch: expected "1", got {actual}',"io.elementsMissing":"`elements` is missing or not an array","compile.duplicateId":'Duplicate element id: "{id}"',"compile.unknownKind":'Unknown element kind="{kind}"',"compile.invalidTermRef":'Invalid terminal reference "{ref}"',"compile.elementMissing":'Reference to unknown element "{id}"',"compile.missingPin":'Element "{id}" (kind={kind}) has no pin "{pin}"; available: {available}',"compile.singleTerminal":"Node has only one terminal — ignored","compile.layoutMissingElement":'layout key "{id}" references an unknown element',"compile.elementUnconnected":'Element "{id}" has no connections',"cat.busbar":"Busbar / wiring","cat.switching":"Switching","cat.protection":"Protection","cat.motor-control":"Motor control","cat.transformer":"Transformer","cat.instrument-transformer":"Instrument transformer","cat.measurement":"Measurement","cat.source":"Source","cat.load":"Load","cat.storage":"Storage","cat.compensation":"Compensation","cat.grounding":"Grounding","cat.renewable":"Renewables / power electronics","onboard.title":"Quick start","onboard.step1.title":"Place a component","onboard.step1.body":"Pick the Place tool (P) and drag a kind from the library onto the canvas","onboard.step2.title":"Wire it up","onboard.step2.body":"Use the Wire tool (W): drag from one pin to another — drag into empty space to drop a junction","onboard.step3.title":"A busbar is a shared rail, not a wire","onboard.step3.body":"Use the Busbar tool (B) only when several circuits share one rail. Don't use a bus to join two devices — just wire the pins (W).","onboard.dismiss":"Got it"}},Hs="ole-locale";function Ik(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Hs);if(e==="zh"||e==="en")return e}catch{}return typeof navigator<"u"&&typeof navigator.language=="string"?navigator.language.toLowerCase().startsWith("zh")?"zh":"en":"zh"}function ur(e){try{window.localStorage.setItem(Hs,e)}catch{}}const Yt=$n((e,t)=>({locale:Ik(),setLocale:n=>{ur(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";ur(n),e({locale:n})}}));function Ws(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function qs(e,t){return dr[e][t]??dr.zh[t]??t}function ve(e,t){return Ws(qs(Yt.getState().locale,e),t)}function le(){const e=Yt(t=>t.locale);return(t,n)=>Ws(qs(e,t),n)}function Xs(e,t){let n;try{n=e()}catch{return}return{getItem:r=>{var s;const i=l=>l===null?null:JSON.parse(l,void 0),a=(s=n.getItem(r))!=null?s:null;return a instanceof Promise?a.then(i):i(a)},setItem:(r,s)=>n.setItem(r,JSON.stringify(s,void 0)),removeItem:r=>n.removeItem(r)}}const ro=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return ro(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return ro(o)(n)}}}},Ok=(e,t)=>(n,o,r)=>{let s={storage:Xs(()=>window.localStorage),partialize:x=>x,version:0,merge:(x,w)=>({...w,...x}),...t},i=!1,a=0;const l=new Set,c=new Set;let u=s.storage;if(!u)return e((...x)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...x)},o,r);const f=()=>{const x=s.partialize({...o()});return u.setItem(s.name,{state:x,version:s.version})},h=r.setState;r.setState=(x,w)=>(h(x,w),f());const g=e((...x)=>(n(...x),f()),o,r);r.getInitialState=()=>g;let m;const p=()=>{var x,w;if(!u)return;const v=++a;i=!1,l.forEach(I=>{var F;return I((F=o())!=null?F:g)});const M=((w=s.onRehydrateStorage)==null?void 0:w.call(s,(x=o())!=null?x:g))||void 0;return ro(u.getItem.bind(u))(s.name).then(I=>{if(I)if(typeof I.version=="number"&&I.version!==s.version){if(s.migrate){const F=s.migrate(I.state,I.version);return F instanceof Promise?F.then(G=>[!0,G]):[!0,F]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,I.state];return[!1,void 0]}).then(I=>{var F;if(v!==a)return;const[G,$]=I;if(m=s.merge($,(F=o())!=null?F:g),n(m,!0),G)return f()}).then(()=>{v===a&&(M==null||M(o(),void 0),m=o(),i=!0,c.forEach(I=>I(m)))}).catch(I=>{v===a&&(M==null||M(void 0,I))})};return r.persist={setOptions:x=>{s={...s,...x},x.storage&&(u=x.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>p(),hasHydrated:()=>i,onHydrate:x=>(l.add(x),()=>{l.delete(x)}),onFinishHydration:x=>(c.add(x),()=>{c.delete(x)})},s.skipHydration||p(),m||g},Bk=Ok,Fe=.5;function Ys(e){if(e.length<2)return e.map(r=>[r[0],r[1]]);const t=[[e[0][0],e[0][1]]];for(let r=1;r<e.length;r++){const s=t[t.length-1];Math.abs(s[0]-e[r][0])<Fe&&Math.abs(s[1]-e[r][1])<Fe||t.push([e[r][0],e[r][1]])}if(t.length<2)return t;const n=[t[0]];for(let r=1;r<t.length;r++){const s=n[n.length-1],i=t[r],a=Math.abs(s[0]-i[0]),l=Math.abs(s[1]-i[1]);if(a>Fe&&l>Fe){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Fe?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(u)}n.push(i)}const o=[n[0]];for(let r=1;r<n.length-1;r++){const s=o[o.length-1],i=n[r],a=n[r+1],l=Math.abs(s[0]-i[0])<Fe&&Math.abs(i[0]-a[0])<Fe,c=Math.abs(s[1]-i[1])<Fe&&Math.abs(i[1]-a[1])<Fe;l||c||o.push(i)}return o.push(n[n.length-1]),o}function Gs(){return{elements:new Map,buses:new Map,junctions:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function Ks(e){return{at:(e==null?void 0:e.at)??[0,0],rot:(e==null?void 0:e.rot)??0,mirror:(e==null?void 0:e.mirror)??!1}}function so(e){return e===90||e===270?"y":"x"}function Ie(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}const Dk={n:"e",e:"s",s:"w",w:"n"},Lk={n:"n",s:"s",e:"w",w:"e"};function Ot(e,t){let n=t.mirror?Lk[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=Dk[n];return n}function io(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class Us{constructor(){jt(this,"parent",new Map);jt(this,"rank",new Map)}add(t){this.parent.has(t)||(this.parent.set(t,t),this.rank.set(t,0))}find(t){this.add(t);let n=t;for(;this.parent.get(n)!==n;){const o=this.parent.get(n),r=this.parent.get(o);this.parent.set(n,r),n=r}return n}union(t,n){const o=this.find(t),r=this.find(n);if(o===r)return;const s=this.rank.get(o),i=this.rank.get(r);s<i?this.parent.set(o,r):s>i?this.parent.set(r,o):(this.parent.set(r,o),this.rank.set(o,s+1))}groups(){const t=new Map;for(const n of this.parent.keys()){const o=this.find(n),r=t.get(o);r?r.push(n):t.set(o,[n])}return t}}const fr=["n","e","s","w"],hr={n:"s",s:"n",e:"w",w:"e"};function tn(e,t){const n=fr.indexOf(e),r=((fr.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const Rn=320,nn=220,At=260,Fn=720,Tt=30,mr=30,Qe=80,pr=10,zk=60,Rk=520,Fk=80,Hk=80,gr=8,yr=new Set(["source","renewable"]);function Wk(e){var Jo,Zo,Qo,er,tr,nr;const{elements:t,buses:n,junctions:o,wires:r,library:s,userLayout:i,userBusLayout:a}=e,l=new Map(i),c=new Map(a),u=new Map,f=new Set(i.keys()),h=new Set(a.keys()),g=new Map;for(const b of t)g.set(b.id,b);const m=new Map;for(const b of n)m.set(b.id,b);const p=b=>{const k=g.get(b);if(k)return s.get(k.kind)},x=new Set(n.map(b=>b.id)),w=b=>x.has(b),v=new Set(o.map(b=>b.id)),M=new Set(o.filter(b=>{var k;return(k=b.layout)==null?void 0:k.at}).map(b=>b.id)),I=new Us;for(const b of r)I.add(b.ends[0]),I.add(b.ends[1]),I.union(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(k)for(const S of k.terminals)I.add(`${b.id}.${S.id}`)}for(const b of n)I.add(b.id);const F=[];for(const[,b]of I.groups())b.length>=2&&F.push(b);const G=new Map;for(const b of F)for(const k of b)G.set(k,[b]);const $=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of k){const E=b.filter(_=>_!==S),j=$.get(S)??[];j.push(...E),$.set(S,j)}}{const S=T=>g.has(T)&&!!p(T),E=T=>{if(w(T))return null;if(v.has(T))return T;const N=T.indexOf(".");return N>0?T.slice(0,N):null},j=new Map,_=new Set,A=(T,N)=>{j.has(T)||j.set(T,new Set),j.has(N)||j.set(N,new Set),T!==N&&(j.get(T).add(N),j.get(N).add(T))};for(const T of F){const N=[];let D=!1;for(const Y of T){if(w(Y)){D=!0;continue}const te=E(Y);te&&N.push(te)}const L=[...new Set(N)];for(const Y of L)j.has(Y)||j.set(Y,new Set),D&&_.add(Y);const q=L.filter(Y=>v.has(Y)),K=L.filter(Y=>!v.has(Y));if(q.length>0){for(const Y of q)for(const te of K)A(Y,te);for(let Y=0;Y<q.length;Y++)for(let te=Y+1;te<q.length;te++)A(q[Y],q[te])}else for(let Y=0;Y<K.length;Y++)for(let te=Y+1;te<K.length;te++)A(K[Y],K[te])}const z=(T,N)=>{const D=p(T);if(!D)return null;for(const L of D.terminals){const q=`${T}.${L.id}`;for(const K of G.get(q)??[])for(const Y of K)if(E(Y)===N)return L}return null},O=T=>{const N=J=>{var oe;return((oe=j.get(J))==null?void 0:oe.size)??0},D=J=>{var oe;return((oe=p(J))==null?void 0:oe.category)??""},L=J=>{const oe=D(J);return oe==="source"?0:oe==="renewable"?1:2+Math.min(N(J),9)/10},q=T.filter(S).sort((J,oe)=>L(J)-L(oe)||J.localeCompare(oe))[0];if(!q)return;const K=new Map([[q,null]]),Y=new Map([[q,0]]),te=new Map,ne=[],U=[q],V=new Set([q]);for(;U.length;){const J=U.shift();ne.push(J);for(const oe of[...j.get(J)??[]].sort((je,Ee)=>je.localeCompare(Ee)))V.has(oe)||(V.add(oe),K.set(oe,J),Y.set(oe,(Y.get(J)??0)+1),te.has(J)||te.set(J,[]),te.get(J).push(oe),U.push(oe))}let Q=0;const fe=new Map,we=J=>{const oe=te.get(J)??[];if(oe.length===0){fe.set(J,Q++);return}for(const Ee of oe)we(Ee);const je=oe.map(Ee=>fe.get(Ee));fe.set(J,je.reduce((Ee,Qt)=>Ee+Qt,0)/je.length)};we(q);for(const J of ne){const oe=xe(Rn+(fe.get(J)??0)*160),je=xe(nn+(Y.get(J)??0)*140);if(v.has(J)){u.set(J,[oe,je]);continue}let Ee=0;const Qt=K.get(J)??null;if(Qt){const $t=z(J,Qt);$t&&(Ee=tn($t.orientation,"n"))}else{const $t=(te.get(J)??[])[0],or=$t?z(J,$t):null;or&&(Ee=tn(or.orientation,"s"))}l.set(J,{at:[oe,je],rot:Ee,mirror:!1}),f.add(J)}},B=new Set;for(const T of j.keys()){if(B.has(T))continue;const N=[],D=[T];for(B.add(T);D.length;){const L=D.pop();N.push(L);for(const q of j.get(L)??[])B.has(q)||(B.add(q),D.push(q))}N.length<2||N.some(L=>_.has(L))||N.some(L=>l.has(L)||M.has(L))||N.some(S)&&O(N)}}const H=new Map;for(const b of F){const k=b.filter(w);if(k.length!==0)for(const S of b){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=S.slice(E+1),A=H.get(j)??[];for(const z of k)A.some(O=>O.busId===z&&O.pin===_)||A.push({busId:z,pin:_});H.set(j,A)}}const W=[],X=new Set;for(const[b,k]of H)if(new Set(k.map(E=>E.busId)).size>=2){const E=((Zo=s.get(((Jo=g.get(b))==null?void 0:Jo.kind)??""))==null?void 0:Zo.category)==="transformer"?"vertical":"horizontal";W.push({elementId:b,attachments:k,orientation:E}),E==="vertical"&&X.add(b)}const P=new Map,R=(b,k)=>{b!==k&&(P.has(b)||P.set(b,new Set),P.has(k)||P.set(k,new Set),P.get(b).add(k),P.get(k).add(b))};for(const b of r)R(b.ends[0],b.ends[1]);for(const b of t){const k=s.get(b.kind);if(!k||k.terminals.length<2)continue;const S=k.terminals.map(E=>`${b.id}.${E.id}`);for(let E=0;E<S.length;E++)for(let j=E+1;j<S.length;j++)R(S[E],S[j])}for(const b of t){if(X.has(b.id))continue;const k=s.get(b.kind);if(!k||k.category!=="transformer"||k.terminals.length<2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1);E.set(A,new Set);const z=new Set(S.filter(T=>T!==_)),O=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.get(A).add(T);continue}const N=P.get(T);if(N)for(const D of N)O.has(D)||z.has(D)||(O.add(D),B.push(D))}}const j=new Set;for(const _ of E.values())for(const A of _)j.add(A);if(j.size>=2){const _=[];for(const[A,z]of E)for(const O of z)_.push({busId:O,pin:A});W.push({elementId:b.id,attachments:_,orientation:"vertical"}),X.add(b.id)}}const Z=(b,k)=>{var z;const S=p(k),E=S?S.terminals.map(O=>`${k}.${O.id}`):[],j=b,_=new Set([j,...E]),A=[j];for(;A.length>0;){const O=A.shift(),B=O.indexOf(".");if(B>0){const N=O.slice(0,B),D=g.get(N);if(D){const L=(z=s.get(D.kind))==null?void 0:z.category;if(L&&yr.has(L))return!0}}const T=P.get(O);if(T)for(const N of T)_.has(N)||(_.add(N),A.push(N))}return!1};for(const b of W){if(b.orientation!=="horizontal")continue;const k=new Set(b.attachments.map(E=>E.busId));let S=0;for(const E of k)Z(E,b.elementId)&&S++;S===1&&(b.orientation="vertical",X.add(b.elementId))}for(const b of t){if(X.has(b.id)||b.kind!=="breaker")continue;const k=s.get(b.kind);if(!k||k.terminals.length!==2)continue;const S=k.terminals.map(_=>`${b.id}.${_.id}`),E=new Map;for(const _ of S){const A=_.slice(b.id.length+1),z=new Set(S.filter(T=>T!==_)),O=new Set([_]),B=[_];for(;B.length>0;){const T=B.shift();if(w(T)){E.set(A,T);break}const N=P.get(T);if(N)for(const D of N){if(O.has(D)||z.has(D))continue;const L=D.indexOf(".");if(L>0){const q=D.slice(0,L);if(q!==b.id){const K=g.get(q),Y=K?s.get(K.kind):void 0;if((Y==null?void 0:Y.category)==="transformer")continue}}O.add(D),B.push(D)}}}if(new Set(E.values()).size>=2){const _=[];for(const[A,z]of E)_.push({busId:z,pin:A});W.push({elementId:b.id,attachments:_,orientation:"horizontal"})}}const ie=new Map;for(const b of n)ie.set(b.id,new Map);for(const b of W){const k=Array.from(new Set(b.attachments.map(S=>S.busId)));for(const S of k)for(const E of k)S!==E&&((Qo=ie.get(S))==null||Qo.set(E,b))}const ue=b=>{var S;const k=(S=s.get(b))==null?void 0:S.category;return k?yr.has(k):!1},ee=[];for(const b of n){const k=$.get(b.id);if(k)for(const S of k){if(w(S))continue;const E=S.indexOf(".");if(E<0)continue;const j=S.slice(0,E),_=g.get(j);if(_&&ue(_.kind)){ee.push(b.id);break}}}ee.length===0&&n.length>0&&ee.push(n[0].id);const ae=new Map;for(const b of ee)ae.set(b,0);{const b=[...ee];for(;b.length>0;){const k=b.shift(),S=ae.get(k),E=ie.get(k);if(E)for(const[j,_]of E){if(ae.has(j))continue;const A=_.orientation==="horizontal"?S:S+1;ae.set(j,A),b.push(j)}}}for(const b of n){if(ae.has(b.id))continue;const k=ae.size===0?-1:Math.max(...Array.from(ae.values()));ae.set(b.id,k+1)}const me=new Map;for(const b of n){const k=ae.get(b.id),S=me.get(k)??[];S.push(b.id),me.set(k,S)}const be=[...me.keys()].sort((b,k)=>b-k),$e=(b,k,S)=>{const E=`${b.elementId}.${S}`,j=k,_=p(b.elementId),A=new Set;if(_)for(const N of _.terminals)N.id!==S&&A.add(`${b.elementId}.${N.id}`);const z=new Set([E]),O=[{ref:E,dist:0}],B=new Map,T=(N,D,L,q)=>{z.add(N),B.set(N,D),O.push({ref:N,dist:q+L})};for(;O.length>0;){const{ref:N,dist:D}=O.shift();if(N===j){const Y=B.get(j);let te;if(Y){const ne=Y.indexOf(".");if(ne>0){const U=Y.slice(0,ne);U!==b.elementId&&(te=U)}}return{extent:D,head:te}}const L=N.indexOf(".");if(L<0)continue;const q=N.slice(0,L),K=N.slice(L+1);if(!w(q)&&!X.has(q)){const Y=p(q),te=Y==null?void 0:Y.terminals.find(ne=>ne.id===K);if(Y&&te)for(const ne of Y.terminals){if(ne.id===K)continue;const U=`${q}.${ne.id}`;z.has(U)||A.has(U)||T(U,N,Math.abs(te.y-ne.y),D)}}for(const Y of G.get(N)??[])for(const te of Y){if(te===N||z.has(te)||A.has(te))continue;const ne=w(N)||w(te);T(te,N,ne?mr:Tt,D)}}return{extent:0}},Me=(b,k)=>{var N,D,L;const S=(N=ie.get(b))==null?void 0:N.get(k);if(!S||S.orientation==="horizontal")return At;const E=p(S.elementId);if(!E)return At;const j=(D=S.attachments.find(q=>q.busId===b))==null?void 0:D.pin,_=(L=S.attachments.find(q=>q.busId===k))==null?void 0:L.pin;if(!j||!_)return At;const A=E.terminals.find(q=>q.id===j),z=E.terminals.find(q=>q.id===_);if(!A||!z)return At;const O=Math.abs(z.y-A.y),B=$e(S,b,j).extent,T=$e(S,k,_).extent;return B+O+T},Pn=new Map;for(const b of W){if(b.orientation!=="vertical")continue;const k=b.attachments.slice().sort((z,O)=>(ae.get(z.busId)??0)-(ae.get(O.busId)??0));if(k.length<2)continue;const S=k[0].busId,E=k[1].busId,j=k[0].pin,A=$e(b,S,j).head??b.elementId;Pn.set(A,{lowerBusId:E})}const Lo=30,zo=b=>{const k=p(b);return Math.max((k==null?void 0:k.width)??Qe,Qe)},p2=2,Ro=(b,k,S,E=0)=>{const j=p(k);let _=zo(k);if(j&&!S.has(k)&&E<p2){S.add(k);let A=0;for(const z of j.terminals){const O=`${k}.${z.id}`;if(O!==b)for(const B of G.get(O)??[]){const T=new Set;let N=!1;for(const L of B){if(L===O)continue;if(w(L)){N=!0;continue}const q=L.indexOf(".");if(q<0)continue;const K=L.slice(0,q);K===k||S.has(K)||X.has(K)||T.add(K)}if(N||T.size===0)continue;let D=0;for(const L of T){const q=[...B].find(K=>K.indexOf(".")>0&&K.slice(0,K.indexOf("."))===L);D+=(q?Ro(q,L,S,E+1):zo(L))+Lo}A=Math.max(A,D-Lo)}}S.delete(k),_=Math.max(_,A)}return _},kt=320,dt=new Map,Fo=(b,k)=>{if(!X.has(b))return!1;const S=W.find(A=>A.elementId===b),E=S==null?void 0:S.attachments.find(A=>A.busId!==k);if(!E)return!1;const j=ae.get(k)??0;return(ae.get(E.busId)??0)<j},_t=(b,k,S)=>{const E=Pn.get(b);if(E){const _=dt.get(E.lowerBusId);if(_!==void 0)return Math.max(k,_+Qe)}let j=0;return S&&(j=Ro(S,b,new Set)),Math.max(k,Qe,j)},Ho=(b,k)=>{if(dt.has(b))return dt.get(b);if(k.has(b))return kt;k.add(b);const S=$.get(b)??[];let E=0,j=0;for(const A of S){if(w(A))continue;const z=A.indexOf(".");if(z<0)continue;const O=A.slice(0,z),B=A.slice(z+1);if(Fo(O,b))continue;const T=p(O);if(!T)continue;const N=T.terminals.find(q=>q.id===B);if(!N)continue;const D=Pn.get(O);D&&Ho(D.lowerBusId,k);const L=_t(O,T.width,`${O}.${B}`);N.y>0?E+=L:j+=L}const _=Math.max(kt,Math.max(E,j)+Qe);return dt.set(b,_),k.delete(b),_};for(const b of n)Ho(b.id,new Set);const Ve=new Map,g2=(b,k,S)=>{const E=p(k);if(!E)return;const j=`${k}.${S}`,_=E.terminals.filter(O=>O.id!==S).map(O=>`${k}.${O.id}`);if(_.length===0)return;const A=new Set([j,..._]),z=_.slice();for(;z.length>0;){const O=z.shift();if(w(O)&&O!==b){const T=c.get(O);return T?T.at[0]:void 0}for(const T of G.get(O)??[])for(const N of T)N===O||A.has(N)||(A.add(N),z.push(N));const B=O.indexOf(".");if(B>0){const T=O.slice(0,B);if(!w(T)){const N=p(T);if(N)for(const D of N.terminals){const L=`${T}.${D.id}`;A.has(L)||(A.add(L),z.push(L))}}}}},y2=b=>{const k=$.get(b);if(!k||k.length===0)return;const S=c.get(b);if(!S)return;const E=k.flatMap(N=>{if(w(N))return[];const D=N.indexOf(".");if(D<0)return[];const L=N.slice(0,D),q=N.slice(D+1);if(l.has(L))return[];if(Fo(L,b))return[];const K=p(L);if(!K)return[];const Y=K.terminals.find(te=>te.id===q);return Y?[{elId:L,lib:K,localTerm:Y,isLinker:X.has(L),busFacingRef:`${L}.${q}`}]:[]});if(E.length===0)return;const j=[],_=[];for(const N of E)N.localTerm.y>0?j.push(N):_.push(N);const A=N=>N.reduce((D,L)=>D+_t(L.elId,L.lib.width,L.busFacingRef),0),z=Math.max(A(j),A(_))+Qe,O=Math.max(S.span,z);O!==S.span&&!h.has(b)&&c.set(b,{...S,span:O});const B=c.get(b),T=(N,D)=>{if(N.length===0)return;const L=new Map;for(const V of N){const Q=g2(b,V.elId,V.localTerm.id);Q!==void 0&&L.set(V.elId,Q)}N.sort((V,Q)=>{const fe=L.get(V.elId)??B.at[0],we=L.get(Q.elId)??B.at[0];if(fe!==we)return fe-we;const J=_t(V.elId,V.lib.width,V.busFacingRef);return _t(Q.elId,Q.lib.width,Q.busFacingRef)-J});const q=N.map(V=>_t(V.elId,V.lib.width,V.busFacingRef)),K=q.reduce((V,Q)=>V+Q,0),Y=Math.max(O,K),te=(Y-K)/(N.length+1);let ne=B.at[0]-Y/2+te;const U=B.at[1]+D*mr;for(let V=0;V<N.length;V++){const Q=N[V],fe=q[V],we=ne+fe/2;Q.isLinker?Ve.has(Q.elId)||Ve.set(Q.elId,we):l.set(Q.elId,{at:[xe(we-Q.localTerm.x),xe(U-Q.localTerm.y)],rot:0,mirror:!1}),ne+=fe+te}};T(j,-1),T(_,1)},x2=b=>{if(l.has(b.elementId)||b.orientation==="horizontal")return;const k=p(b.elementId);if(!k)return;const S=b.attachments.filter(ne=>c.has(ne.busId));if(S.length<2)return;const E=S.slice().sort((ne,U)=>(ae.get(ne.busId)??0)-(ae.get(U.busId)??0)),j=E[0].busId,_=c.get(j),A=E[0].pin,z=E[E.length-1].pin,O=k.terminals.find(ne=>ne.id===A),B=k.terminals.find(ne=>ne.id===z);if(!O||!B)return;const T=O.y<=B.y?0:180,N=ae.get(j)??0,D=S.filter(ne=>(ae.get(ne.busId)??0)===N),L=[];let q=0;for(const ne of D){const U=$e(b,ne.busId,ne.pin);q=Math.max(q,U.extent);const V=U.head?l.get(U.head):void 0;V?L.push(V.at[0]):Ve.has(b.elementId)?L.push(Ve.get(b.elementId)):L.push(c.get(ne.busId).at[0])}let K;L.length>0?K=L.reduce((ne,U)=>ne+U,0)/L.length:Ve.has(b.elementId)?K=Ve.get(b.elementId):K=_.at[0];const Y=_.at[1]+q,te=T===0?[xe(K-O.x),xe(Y-O.y)]:[xe(K+O.x),xe(Y+O.y)];if(l.set(b.elementId,{at:te,rot:T,mirror:!1}),D.length>1){const ne=l.get(b.elementId),U=Ie([O.x,O.y],ne),V=Ot(O.orientation,ne);b2(`${b.elementId}.${A}`,U,V,K)}},b2=(b,k,S,E)=>{const j=new Set([b]);let _=b,A=k,z=S;for(;;){const O=G.get(_)??[];let B,T=!1;for(const oe of O){if(oe.length>=3){T=!0;break}const je=oe.find(Ee=>Ee!==_);if(!(!je||j.has(je))){if(w(je)){T=!0;break}B=je;break}}if(T||!B)break;const N=B.indexOf(".");if(N<0)break;const D=B.slice(0,N),L=B.slice(N+1);if(w(D)||X.has(D)||l.has(D))break;const q=p(D);if(!q)break;const K=q.terminals.find(oe=>oe.id===L);if(!K)break;const Y=io(z),te=[A[0]+Y[0]*Tt,A[1]+Y[1]*Tt],ne=hr[z],U=tn(K.orientation,ne),V=Ie([K.x,K.y],{at:[0,0],rot:U,mirror:!1}),Q=[xe(E-V[0]),xe(te[1]-V[1])];l.set(D,{at:Q,rot:U,mirror:!1}),j.add(B);const fe=q.terminals.find(oe=>oe.id!==L);if(!fe)break;const we=`${D}.${fe.id}`;j.add(we);const J={at:Q,rot:U,mirror:!1};A=Ie([fe.x,fe.y],J),z=Ot(fe.orientation,J),_=we}},w2=b=>{if(l.has(b.elementId)||b.orientation!=="horizontal")return;const k=p(b.elementId);if(!k)return;const S=b.attachments.filter(D=>c.has(D.busId));if(S.length<2)return;const E=S.map(D=>{const L=$e(b,D.busId,D.pin),q=L.head?l.get(L.head):void 0,K=q?q.at[0]:c.get(D.busId).at[0];return{att:D,x:K,extent:L.extent}});E.sort((D,L)=>D.x-L.x);const j=E[0],_=E[E.length-1],A=k.terminals.find(D=>D.id===j.att.pin),z=k.terminals.find(D=>D.id===_.att.pin);if(!A||!z)return;const O=A.y<=z.y?270:90,B=(j.x+_.x)/2,N=c.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);l.set(b.elementId,{at:[xe(B),xe(N)],rot:O,mirror:!1})},Wo=100;let Zt=nn;for(let b=0;b<be.length;b++){const k=be[b],S=me.get(k);let E;if(b===0)E=nn;else{const _=me.get(be[b-1]);let A=0;for(const z of _)for(const O of S)(er=ie.get(z))!=null&&er.get(O)&&(A=Math.max(A,Me(z,O)));A===0&&(A=At),E=Zt+A}Zt=E;let j=Rn;for(const _ of S){if(c.has(_)){Zt=Math.max(Zt,c.get(_).at[1]);continue}let A;if(b>0){const O=me.get(be[b-1]),B=[];for(const T of O){const N=(tr=ie.get(T))==null?void 0:tr.get(_);if(!N||N.orientation!=="vertical")continue;const D=(nr=N.attachments.find(q=>q.busId===T))==null?void 0:nr.pin;if(!D)continue;const L=$e(N,T,D);L.head&&l.has(L.head)?B.push(l.get(L.head).at[0]):Ve.has(N.elementId)?B.push(Ve.get(N.elementId)):B.push(c.get(T).at[0])}B.length>0&&(A=B.reduce((T,N)=>T+N,0)/B.length)}if(A===void 0){const O=dt.get(_)??Fn;A=j+O/2,j+=O+Wo}const z=dt.get(_)??Fn;c.set(_,{at:[xe(A),xe(E)],rot:0,span:z,axis:so(0)})}for(const _ of S)y2(_);if(b>0)for(const _ of W)l.has(_.elementId)||!_.attachments.some(z=>S.includes(z.busId))||x2(_);for(const _ of W)_.orientation!=="horizontal"||l.has(_.elementId)||!_.attachments.every(z=>S.includes(z.busId))||w2(_)}if(n.length===0&&l.size<t.length){const b=j=>{const _=new Set,A=p(j);if(!A)return _;for(const z of A.terminals){const O=`${j}.${z.id}`;for(const B of G.get(O)??[])for(const T of B){if(T===O||w(T))continue;const N=T.indexOf(".");if(N<0)continue;const D=T.slice(0,N);D!==j&&_.add(D)}}return _},k=new Set,S=[];for(const j of t){if(k.has(j.id)||!p(j.id))continue;const _=[],A=[j.id];for(k.add(j.id);A.length>0;){const z=A.pop();_.push(z);for(const O of b(z))k.has(O)||(k.add(O),A.push(O))}_.length>=2&&S.push(_)}let E=Rn;for(const j of S){if(j.some(B=>l.has(B)))continue;j.sort((B,T)=>{var K,Y;const N=ue(((K=g.get(B))==null?void 0:K.kind)??"")?0:1,D=ue(((Y=g.get(T))==null?void 0:Y.kind)??"")?0:1;if(N!==D)return N-D;const L=b(B).size,q=b(T).size;return L!==q?L-q:B.localeCompare(T)});const _=j[0],A=p(_);if(!A)continue;const z=A.terminals.slice().sort((B,T)=>T.y-B.y)[0],O=z?Ie([z.x,z.y],{at:[0,0],rot:0,mirror:!1}):[0,0];l.set(_,{at:[xe(E-O[0]),xe(nn-O[1])],rot:0,mirror:!1}),E+=Math.max(Fn,j.length*Qe)+Wo}}const v2=b=>{if(w(b))return c.has(b);const k=b.indexOf(".");return k<0?!1:l.has(b.slice(0,k))};let In=!0,k2=t.length+4;for(;In&&k2-- >0;){In=!1;for(const b of F){if(b.length<2)continue;const k=[],S=new Map;for(const U of b){if(w(U))continue;const V=U.indexOf(".");if(V<0)continue;const Q=U.slice(0,V),fe=U.slice(V+1);if(l.has(Q)){k.push(U);continue}if(X.has(Q)||S.has(Q))continue;const we=p(Q);if(!we)continue;const J=we.terminals.find(oe=>oe.id===fe);J&&S.set(Q,{ref:U,elId:Q,lib:we,localTerm:J})}if(S.size===0||k.length===0)continue;const E=[...S.values()],j=new Map;for(const U of E)for(const V of G.get(U.ref)??[])for(const Q of V){if(Q===U.ref||w(Q)||!v2(Q))continue;const fe=Q;j.set(fe,(j.get(fe)??0)+1)}let _;if(j.size>0){let U=-1;for(const[V,Q]of j)(Q>U||Q===U&&(_===void 0||V<_))&&(U=Q,_=V)}if(_||(_=[...k].sort()[0]),!_)continue;const A=_.indexOf("."),z=_.slice(0,A),O=_.slice(A+1),B=p(z),T=l.get(z);if(!B||!T)continue;const N=B.terminals.find(U=>U.id===O);if(!N)continue;const D=Ie([N.x,N.y],T),L=Ot(N.orientation,T),q=io(L),K=[-q[1],q[0]];E.sort((U,V)=>U.elId.localeCompare(V.elId));const Y=E.map(U=>Math.max(U.lib.width,Qe));let ne=-Y.reduce((U,V)=>U+V,0)/2;for(let U=0;U<E.length;U++){const V=E[U],Q=Y[U],fe=ne+Q/2;ne+=Q;const we=hr[L],J=tn(V.localTerm.orientation,we),oe=Ie([V.localTerm.x,V.localTerm.y],{at:[0,0],rot:J,mirror:!1}),je=[D[0]+q[0]*Tt+K[0]*fe,D[1]+q[1]*Tt+K[1]*fe],Ee=[xe(je[0]-oe[0]),xe(je[1]-oe[1])];l.set(V.elId,{at:Ee,rot:J,mirror:!1}),In=!0}}}const St=b=>{const k=l.get(b),S=p(b);if(!k||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.width/2;return{min:k.at[0]-N,max:k.at[0]+N}}const[j,_,A,z]=E,O=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of O){const D=Ie(N,k);B=Math.min(B,D[0]),T=Math.max(T,D[0])}return{min:B,max:T}},On=b=>{const k=new Set,S=p(b);if(!S)return k;for(const E of S.terminals){const j=`${b}.${E.id}`;for(const _ of G.get(j)??[])for(const A of _){if(A===j||w(A))continue;const z=A.indexOf(".");if(z<0)continue;const O=A.slice(0,z);O!==b&&k.add(O)}}return k},qo=40,Bn=b=>{const k=l.get(b),S=p(b);if(!k||!S)return null;const E=S.viewBox.split(/\s+/).map(Number);if(E.length<4||E.some(N=>Number.isNaN(N))){const N=S.height/2;return{min:k.at[1]-N,max:k.at[1]+N}}const[j,_,A,z]=E,O=[[j,_],[j+A,_],[j,_+z],[j+A,_+z]];let B=1/0,T=-1/0;for(const N of O){const D=Ie(N,k);B=Math.min(B,D[1]),T=Math.max(T,D[1])}return{min:B,max:T}},_2=(b,k)=>{const S=new Set,E=[];for(const j of $.get(b)??[]){if(w(j))continue;const _=j.indexOf(".");if(_<0)continue;const A=j.slice(0,_),z=l.get(A);!z||z.at[1]>=k-1||S.has(A)||(S.add(A),E.push(A))}for(;E.length>0;){const j=E.pop();for(const _ of On(j)){if(S.has(_))continue;const A=l.get(_);!A||A.at[1]>=k-1||(S.add(_),E.push(_))}}return S},Xo=(b,k,S)=>{const E=new Set([b]),j=[b];for(;j.length>0;){const _=j.pop();for(const A of On(_))A===k||E.has(A)||!S.has(A)||(E.add(A),j.push(A))}return E},Yo=(b,k)=>{let S=b.length*b.length+8,E=!1,j=!0;for(;j&&S-- >0;){j=!1;for(let _=0;_<b.length&&!j;_++)for(let A=_+1;A<b.length;A++){const z=b[_],O=b[A],B=St(z),T=St(O),N=Bn(z),D=Bn(O);if(!B||!T||!N||!D)continue;const L=Math.min(B.max,T.max)-Math.max(B.min,T.min),q=Math.min(N.max,D.max)-Math.max(N.min,D.min);if(L<=0||q<=0)continue;const K=Xo(z,O,k),Y=Xo(O,z,k);if(K.has(O)||Y.has(z))continue;const te=![...K].some(J=>f.has(J)),ne=![...Y].some(J=>f.has(J));if(!te&&!ne)continue;const U=(B.min+B.max)/2,V=(T.min+T.max)/2;let Q,fe;te&&(!ne||K.size<=Y.size)?(Q=K,fe=U<=V?-1:1):(Q=Y,fe=V<=U?-1:1);const we=xe(fe*(L+qo));if(we!==0){for(const J of Q){const oe=l.get(J);oe&&l.set(J,{...oe,at:[oe.at[0]+we,oe.at[1]]})}E=!0,j=!0;break}}}return E};for(const b of n){const k=c.get(b.id);if(!k)continue;const S=_2(b.id,k.at[1]);if(S.size<2)continue;const E=[...S];if(Yo(E,S)){let _=1/0,A=-1/0;for(const z of E){const O=St(z);O&&(_=Math.min(_,O.min),A=Math.max(A,O.max))}if(Number.isFinite(_)){const O=E.some(T=>f.has(T))?0:xe(k.at[0]-(_+A)/2);if(O!==0)for(const T of E){const N=l.get(T);N&&l.set(T,{...N,at:[N.at[0]+O,N.at[1]]})}const B=A-_+qo;if(B>k.span&&!h.has(b.id)){const T=c.get(b.id);c.set(b.id,{...T,span:B})}}}}const Go=()=>{const k=t.map(E=>E.id).filter(E=>l.has(E)).map(E=>({x:St(E),y:Bn(E)})).filter(E=>E.x&&E.y);let S=0;for(let E=0;E<k.length;E++)for(let j=E+1;j<k.length;j++){const _=Math.min(k[E].x.max,k[j].x.max)-Math.max(k[E].x.min,k[j].x.min),A=Math.min(k[E].y.max,k[j].y.max)-Math.max(k[E].y.min,k[j].y.min);_>1&&A>1&&S++}return S},S2=Go(),Ko=new Map;for(const[b,k]of l)Ko.set(b,{...k,at:[...k.at]});const Uo=new Map;for(const[b,k]of c)Uo.set(b,{...k,at:[...k.at]});const Dn=120,Vo=new Map;{const b=new Map,k=new Map,S=[];for(const j of n)for(const _ of $.get(j.id)??[]){if(w(_))continue;const A=_.indexOf(".");if(A<0)continue;const z=_.slice(0,A);l.has(z)&&S.push({el:z,bus:j.id,d:1})}S.sort((j,_)=>j.d-_.d);let E=0;for(;E<S.length;){const{el:j,bus:_,d:A}=S[E++],z=b.get(j);if(z===void 0)b.set(j,A),k.set(j,_);else if(A===z&&k.get(j)!==_){k.set(j,null);continue}else continue;for(const O of On(j))l.has(O)&&(b.has(O)||S.push({el:O,bus:_,d:A+1}))}for(const[j,_]of k)_&&Vo.set(j,_)}for(const b of be){const k=(me.get(b)??[]).filter(B=>c.has(B));if(k.length<2||k.some(B=>h.has(B)))continue;const S=[];let E=0;for(const B of k){const T=c.get(B),N=[];let D=1/0,L=-1/0;for(const[q,K]of Vo){if(K!==B)continue;const Y=St(q);Y&&(N.push(q),D=Math.min(D,Y.min),L=Math.max(L,Y.max))}Number.isFinite(D)||(D=T.at[0]-kt/2,L=T.at[0]+kt/2),S.push({busId:B,min:D,max:L,members:N}),E+=L-D}if(S.some(B=>B.members.some(T=>f.has(T))))continue;let j=1/0,_=-1/0;for(const B of S)j=Math.min(j,B.min),_=Math.max(_,B.max);const A=_-j,z=E+Dn*(S.length-1);if(!(A>z+Dn))continue;S.sort((B,T)=>(B.min+B.max)/2-(T.min+T.max)/2);let O=j;for(const B of S){const T=xe(O-B.min);if(T!==0){const N=c.get(B.busId);c.set(B.busId,{...N,at:[N.at[0]+T,N.at[1]]});for(const D of B.members){const L=l.get(D);L&&l.set(D,{...L,at:[L.at[0]+T,L.at[1]]})}B.min+=T,B.max+=T}O=B.max+Dn}for(const B of S){const T=c.get(B.busId),N=Math.max(kt,B.max-B.min);N<T.span&&c.set(B.busId,{...T,span:N})}}{const b=t.map(S=>S.id).filter(S=>l.has(S)),k=new Set(b);Yo(b,k)}if(Go()>S2){l.clear();for(const[b,k]of Ko)l.set(b,k);c.clear();for(const[b,k]of Uo)c.set(b,k)}let Ln=0;for(const b of t){if(l.has(b.id))continue;const k=Ln%gr,S=Math.floor(Ln/gr);l.set(b.id,{at:[xe(zk+k*Fk),xe(Rk+S*Hk)],rot:0,mirror:!1}),Ln++}return{devices:l,buses:c,junctions:u}}function xe(e){return Math.round(e/pr)*pr}function qk(e,t){const n=e.ends[0],o=e.ends[1],r=xr(n,t),s=xr(o,t);if(r||s){const l=r?n:o,u=Hn(r?o:n,t);if(!u)return null;const f=t.buses.get(l);if(!f)return null;const{axis:h,at:g,span:m}=f.geometry,p=m/2;let x;if(h==="x")x=[gn(u[0],g[0]-p,g[0]+p),g[1]];else{const w=gn(u[1],g[1]-p,g[1]+p);x=[g[0],w]}return{wireId:e.id,path:wr(u,x)}}const i=Hn(n,t),a=Hn(o,t);return!i||!a?null:{wireId:e.id,path:wr(i,a)}}function xr(e,t){return!e.includes(".")&&t.buses.has(e)}function Hn(e,t){if(!e.includes(".")){const o=t.buses.get(e);if(o)return o.geometry.at;const r=t.junctions.get(e);return r?r.world:null}const n=t.terminals.get(e);return n?n.world:null}function br(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const u=n.junctions.get(e);return u?[u.world[0],u.world[1]]:null}const{axis:s,at:i,span:a}=r.geometry;if(!t)return[i[0],i[1]];const l=a/2;if(s==="x")return[gn(t[0],i[0]-l,i[0]+l),i[1]];const c=gn(t[1],i[1]-l,i[1]+l);return[i[0],c]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function wr(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function gn(e,t,n){return e<t?t:e>n?n:e}const Vs="ammeter",Js="电流表 (A)",Zs="measurement",Qs="-22 -42 44 44",ei=44,ti=44,ni='<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>',oi=[{id:"t_top",x:0,y:-40,orientation:"n"}],ri={kind:"inline"},Xk={id:Vs,name:Js,category:Zs,viewBox:Qs,width:ei,height:ti,svg:ni,terminals:oi,source:ri},Yk=Object.freeze(Object.defineProperty({__proto__:null,category:Zs,default:Xk,height:ti,id:Vs,name:Js,source:ri,svg:ni,terminals:oi,viewBox:Qs,width:ei},Symbol.toStringTag,{value:"Module"})),si="arc-suppression-coil",ii="消弧线圈",ai="grounding",li="中性点谐振接地:电感线圈连接到地",ci="-12 -32 24 67",di=24,ui=67,fi='<line x1="0" y1="-30" x2="0" y2="-12" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -12 A 4 4 0 0 1 0 -4 A 4 4 0 0 1 0 4 A 4 4 0 0 1 0 12" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="20" x2="10" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="24" x2="7" y2="24" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="28" x2="4" y2="28" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="32" x2="1.5" y2="32" fill="none" stroke="black" stroke-width="1"/>',hi=[{id:"t_top",x:0,y:-30,orientation:"n"}],mi={kind:"inline"},Gk={id:si,name:ii,category:ai,description:li,viewBox:ci,width:di,height:ui,svg:fi,terminals:hi,source:mi},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:ai,default:Gk,description:li,height:ui,id:si,name:ii,source:mi,svg:fi,terminals:hi,viewBox:ci,width:di},Symbol.toStringTag,{value:"Module"})),pi="arrester",gi="避雷器 (FBL)",yi="protection",xi="-7 -22 14 44",bi=14,wi=44,vi='<line x1="0" y1="-20" x2="0" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><polygon points="-2,-8 2,-8 0,-2" fill="black" stroke="black" stroke-width="1"/><rect x="-5" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',ki=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],_i={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},Uk={id:pi,name:gi,category:yi,viewBox:xi,width:bi,height:wi,svg:vi,terminals:ki,source:_i},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:yi,default:Uk,height:wi,id:pi,name:gi,source:_i,svg:vi,terminals:ki,viewBox:xi,width:bi},Symbol.toStringTag,{value:"Module"})),Si="async-motor",$i="异步电动机",ji="load",Ei="-62 -82 64 84",Ni=64,Ai=84,Ti='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">3</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-60" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-80" x2="-10" y2="-53" fill="none" stroke="black" stroke-width="1"/>',Mi=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Ci={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_08/en_60617_06_08_01.elmt",qetEnglishName:"Induction motor, three-phase, squirrel cage"},Jk={id:Si,name:$i,category:ji,viewBox:Ei,width:Ni,height:Ai,svg:Ti,terminals:Mi,source:Ci},Zk=Object.freeze(Object.defineProperty({__proto__:null,category:ji,default:Jk,height:Ai,id:Si,name:$i,source:Ci,svg:Ti,terminals:Mi,viewBox:Ei,width:Ni},Symbol.toStringTag,{value:"Module"})),Pi="autotransformer",Ii="自耦变压器",Oi="transformer",Bi="-62 -112 64 144",Di=64,Li=144,zi='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-110" x2="-30" y2="-90" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -30 A 30 60 0 0 0 -30 -90" fill="none" stroke="black" stroke-width="1"/>',Ri=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Fi={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},Qk={id:Pi,name:Ii,category:Oi,viewBox:Bi,width:Di,height:Li,svg:zi,terminals:Ri,source:Fi},e_=Object.freeze(Object.defineProperty({__proto__:null,category:Oi,default:Qk,height:Li,id:Pi,name:Ii,source:Fi,svg:zi,terminals:Ri,viewBox:Bi,width:Di},Symbol.toStringTag,{value:"Module"})),Hi="battery",Wi="电池储能",qi="storage",Xi="-12 -12 29 24",Yi=29,Gi=24,Ki='<line x1="-10" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-10" x2="5" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="0" x2="15" y2="0" fill="none" stroke="black" stroke-width="1"/>',Ui=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],Vi=[{name:"E",label:"容量",type:"number",unit:"kWh"}],Ji={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},t_={id:Hi,name:Wi,category:qi,viewBox:Xi,width:Yi,height:Gi,svg:Ki,terminals:Ui,params:Vi,source:Ji},n_=Object.freeze(Object.defineProperty({__proto__:null,category:qi,default:t_,height:Gi,id:Hi,name:Wi,params:Vi,source:Ji,svg:Ki,terminals:Ui,viewBox:Xi,width:Yi},Symbol.toStringTag,{value:"Module"})),Zi="bell",Qi="电铃 (HA)",ea="control",ta="信号电铃 / 警铃。",na="-32 -32 44 44",oa=44,ra=44,sa='<line x1="-30" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -10 A 20 20 0 0 0 -30 -10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',ia=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],aa={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},o_={id:Zi,name:Qi,category:ea,description:ta,viewBox:na,width:oa,height:ra,svg:sa,terminals:ia,source:aa},r_=Object.freeze(Object.defineProperty({__proto__:null,category:ea,default:o_,description:ta,height:ra,id:Zi,name:Qi,source:aa,svg:sa,terminals:ia,viewBox:na,width:oa},Symbol.toStringTag,{value:"Module"})),la="break-contact",ca="常闭触点 (NC)",da="control",ua="常闭辅助触点 (break contact)。",fa="-2 -42 14 64",ha=14,ma=64,pa='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/>',ga=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ya=[{name:"open",type:"boolean",default:!1,label:"断开"}],xa={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},s_={id:la,name:ca,category:da,description:ua,viewBox:fa,width:ha,height:ma,svg:pa,terminals:ga,state:ya,source:xa},i_=Object.freeze(Object.defineProperty({__proto__:null,category:da,default:s_,description:ua,height:ma,id:la,name:ca,source:xa,state:ya,svg:pa,terminals:ga,viewBox:fa,width:ha},Symbol.toStringTag,{value:"Module"})),ba="breaker",wa="断路器 (QF)",va="switching",ka="-7 -22 15 46",_a=15,Sa=46,$a='<polyline points="0,20 0,10 -5,-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-8" x2="-2" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/>',ja='<text x="2" y="-10.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">1</text><text x="3" y="21.2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">2</text>',Ea=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Na=[{name:"open",type:"boolean",default:!1,label:"断开"}],Aa={x:6,y:-2,anchor:"start"},Ta={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},a_={id:ba,name:wa,category:va,viewBox:ka,width:_a,height:Sa,svg:$a,terminalLabelsSvg:ja,terminals:Ea,state:Na,label:Aa,source:Ta},l_=Object.freeze(Object.defineProperty({__proto__:null,category:va,default:a_,height:Sa,id:ba,label:Aa,name:wa,source:Ta,state:Na,svg:$a,terminalLabelsSvg:ja,terminals:Ea,viewBox:ka,width:_a},Symbol.toStringTag,{value:"Module"})),Ma="buchholz-relay",Ca="瓦斯继电器 (63)",Pa="protection",Ia="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",Oa="-22 -62 44 64",Ba=44,Da=64,La='<rect x="-20" y="-60" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-20" width="10" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-20" x2="10" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-55" x2="0" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -50 A 10 5 0 0 0 0 -40" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -40 A 10 5 0 0 0 0 -50" fill="none" stroke="black" stroke-width="1"/>',za=[{id:"t_top",x:0,y:-60,orientation:"n"}],Ra={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_18/en_60617_07_18_01.elmt",qetEnglishName:"Buchholz protective device; Gas relay"},c_={id:Ma,name:Ca,category:Pa,description:Ia,viewBox:Oa,width:Ba,height:Da,svg:La,terminals:za,source:Ra},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Pa,default:c_,description:Ia,height:Da,id:Ma,name:Ca,source:Ra,svg:La,terminals:za,viewBox:Oa,width:Ba},Symbol.toStringTag,{value:"Module"})),Fa="busbar",Ha="母线段",Wa="busbar",qa="可拉伸单母线段,多设备挂接",Xa="-42 -4 84 8",Ya=84,Ga=8,Ka='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',Ua=[{id:"tap",x:0,y:0,orientation:"n"}],Va={axis:"x",minLength:20,naturalSpan:80},Ja=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],Za={x:0,y:-6,anchor:"middle"},Qa={kind:"inline"},u_={id:Fa,name:Ha,category:Wa,description:qa,viewBox:Xa,width:Ya,height:Ga,svg:Ka,terminals:Ua,stretchable:Va,params:Ja,label:Za,source:Qa},f_=Object.freeze(Object.defineProperty({__proto__:null,category:Wa,default:u_,description:qa,height:Ga,id:Fa,label:Za,name:Ha,params:Ja,source:Qa,stretchable:Va,svg:Ka,terminals:Ua,viewBox:Xa,width:Ya},Symbol.toStringTag,{value:"Module"})),el="buzzer",tl="蜂鸣器 (HA)",nl="control",ol="信号蜂鸣器。",rl="-32 -52 44 64",sl=44,il=64,al='<line x1="-30" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><path d="M -30 -30 A 20 20 0 0 0 10 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-12" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-12" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/>',ll=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],cl={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},h_={id:el,name:tl,category:nl,description:ol,viewBox:rl,width:sl,height:il,svg:al,terminals:ll,source:cl},m_=Object.freeze(Object.defineProperty({__proto__:null,category:nl,default:h_,description:ol,height:il,id:el,name:tl,source:cl,svg:al,terminals:ll,viewBox:rl,width:sl},Symbol.toStringTag,{value:"Module"})),dl="capacitor",ul="电容 (C)",fl="passive",hl="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",ml="-7 -23 14 27",pl=14,gl=27,yl='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',xl=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],bl=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],wl={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},p_={id:dl,name:ul,category:fl,description:hl,viewBox:ml,width:pl,height:gl,svg:yl,terminals:xl,params:bl,source:wl},g_=Object.freeze(Object.defineProperty({__proto__:null,category:fl,default:p_,description:hl,height:gl,id:dl,name:ul,params:bl,source:wl,svg:yl,terminals:xl,viewBox:ml,width:pl},Symbol.toStringTag,{value:"Module"})),vl="contactor",kl="接触器 (KM)",_l="motor-control",Sl="主回路接触器, 通常配热继电器和电机使用。",$l="-10 -42 15 64",jl=15,El=64,Nl='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><path d="M 0 -24.5 A 2.5 2.5 0 0 0 0 -19.5" fill="none" stroke="black" stroke-width="1"/>',Al=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Tl=[{name:"open",type:"boolean",default:!0,label:"断开"}],Ml={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_02.elmt",qetEnglishName:"Contactor; Main make contact of a contactor"},y_={id:vl,name:kl,category:_l,description:Sl,viewBox:$l,width:jl,height:El,svg:Nl,terminals:Al,state:Tl,source:Ml},x_=Object.freeze(Object.defineProperty({__proto__:null,category:_l,default:y_,description:Sl,height:El,id:vl,name:kl,source:Ml,state:Tl,svg:Nl,terminals:Al,viewBox:$l,width:jl},Symbol.toStringTag,{value:"Module"})),Cl="converter-bidir",Pl="双向变流器 (PCS)",Il="renewable",Ol="储能变流器:双向 AC ↔ DC",Bl="-42 -42 44 48",Dl=44,Ll=48,zl='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-6" x2="-14" y2="-6" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-6" x2="-4" y2="-6" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/><polyline points="-28,-4 -32,0 -28,4" fill="none" stroke="black" stroke-width="1"/><polyline points="-16,-4 -12,0 -16,4" fill="none" stroke="black" stroke-width="1"/>',Rl=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Fl=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Hl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},b_={id:Cl,name:Pl,category:Il,description:Ol,viewBox:Bl,width:Dl,height:Ll,svg:zl,terminals:Rl,params:Fl,source:Hl},w_=Object.freeze(Object.defineProperty({__proto__:null,category:Il,default:b_,description:Ol,height:Ll,id:Cl,name:Pl,params:Fl,source:Hl,svg:zl,terminals:Rl,viewBox:Bl,width:Dl},Symbol.toStringTag,{value:"Module"})),Wl="ct",ql="电流互感器 (CT)",Xl="instrument-transformer",Yl="-42 -62 54 64",Gl=54,Kl=64,Ul='<line x1="-30" y1="-60" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-30" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-20" x2="5" y2="-40" fill="none" stroke="black" stroke-width="1"/>',Vl=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],Jl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},v_={id:Wl,name:ql,category:Xl,viewBox:Yl,width:Gl,height:Kl,svg:Ul,terminals:Vl,source:Jl},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Xl,default:v_,height:Kl,id:Wl,name:ql,source:Jl,svg:Ul,terminals:Vl,viewBox:Yl,width:Gl},Symbol.toStringTag,{value:"Module"})),Zl="dc-combiner",Ql="直流汇流箱",ec="renewable",tc="光伏组串汇流箱 (4 路输入示例)。",nc="-27 -32 54 64",oc=54,rc=64,sc='<rect x="-25" y="-15" width="50" height="30" fill="none" stroke="black" stroke-width="1"/><line x1="-18" y1="-30" x2="-18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="-6" y1="-30" x2="-6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-30" x2="6" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="18" y1="-30" x2="18" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><text x="-9" y="5" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">DC</text>',ic=[{id:"t_s1",x:-18,y:-30,orientation:"n"},{id:"t_s2",x:-6,y:-30,orientation:"n"},{id:"t_s3",x:6,y:-30,orientation:"n"},{id:"t_s4",x:18,y:-30,orientation:"n"},{id:"t_dc",x:0,y:30,orientation:"s"}],ac={kind:"inline"},__={id:Zl,name:Ql,category:ec,description:tc,viewBox:nc,width:oc,height:rc,svg:sc,terminals:ic,source:ac},S_=Object.freeze(Object.defineProperty({__proto__:null,category:ec,default:__,description:tc,height:rc,id:Zl,name:Ql,source:ac,svg:sc,terminals:ic,viewBox:nc,width:oc},Symbol.toStringTag,{value:"Module"})),lc="dc-dc-converter",cc="DC/DC 变换器",dc="renewable",uc="DC/DC 变换器 / 直流充电器(IEC 60617)",fc="-42 -42 44 44",hc=44,mc=44,pc='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/>',gc=[{id:"t_in",x:-20,y:-40,orientation:"n"},{id:"t_out",x:-20,y:0,orientation:"s"}],yc=[{name:"P",label:"功率",type:"number",unit:"kW"}],xc={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_02.elmt",qetEnglishName:"DC/DC converter"},$_={id:lc,name:cc,category:dc,description:uc,viewBox:fc,width:hc,height:mc,svg:pc,terminals:gc,params:yc,source:xc},j_=Object.freeze(Object.defineProperty({__proto__:null,category:dc,default:$_,description:uc,height:mc,id:lc,name:cc,params:yc,source:xc,svg:pc,terminals:gc,viewBox:fc,width:hc},Symbol.toStringTag,{value:"Module"})),bc="dc-disconnector",wc="直流隔离开关",vc="switching",kc="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",_c="-12 -32 30 64",Sc=30,$c=64,jc='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-15" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-4" x2="14" y2="-4" stroke="black" stroke-width="1" fill="none"/><line x1="6" y1="-1" x2="9" y2="-1" stroke="black" stroke-width="0.8" fill="none"/><line x1="11" y1="-1" x2="14" y2="-1" stroke="black" stroke-width="0.8" fill="none"/>',Ec=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Nc=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ac={kind:"inline"},E_={id:bc,name:wc,category:vc,description:kc,viewBox:_c,width:Sc,height:$c,svg:jc,terminals:Ec,state:Nc,source:Ac},N_=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:E_,description:kc,height:$c,id:bc,name:wc,source:Ac,state:Nc,svg:jc,terminals:Ec,viewBox:_c,width:Sc},Symbol.toStringTag,{value:"Module"})),Tc="dc-motor",Mc="直流电机 (M)",Cc="load",Pc="直流电动机 (串励通用符号)。",Ic="-72 -82 89 84",Oc=89,Bc=84,Dc='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-40" y1="-20" x2="-20" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-15" x2="-32" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-29" y1="-15" x2="-20" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-80" x2="-70" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-70" y1="-30" x2="-60" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="10" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-30" x2="10" y2="-50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -60 A 5 5 0 0 0 10 -50" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -70 A 5 5 0 0 0 10 -60" fill="none" stroke="black" stroke-width="1"/><path d="M 10 -80 A 5 5 0 0 0 10 -70" fill="none" stroke="black" stroke-width="1"/>',Lc=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],zc={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},A_={id:Tc,name:Mc,category:Cc,description:Pc,viewBox:Ic,width:Oc,height:Bc,svg:Dc,terminals:Lc,source:zc},T_=Object.freeze(Object.defineProperty({__proto__:null,category:Cc,default:A_,description:Pc,height:Bc,id:Tc,name:Mc,source:zc,svg:Dc,terminals:Lc,viewBox:Ic,width:Oc},Symbol.toStringTag,{value:"Module"})),Rc="diode",Fc="二极管 (D)",Hc="passive",Wc="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",qc="-12 -42 24 44",Xc=24,Yc=44,Gc='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/>',Kc=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Uc={x:6,y:-20,anchor:"start"},Vc={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},M_={id:Rc,name:Fc,category:Hc,description:Wc,viewBox:qc,width:Xc,height:Yc,svg:Gc,terminals:Kc,label:Uc,source:Vc},C_=Object.freeze(Object.defineProperty({__proto__:null,category:Hc,default:M_,description:Wc,height:Yc,id:Rc,label:Uc,name:Fc,source:Vc,svg:Gc,terminals:Kc,viewBox:qc,width:Xc},Symbol.toStringTag,{value:"Module"})),Jc="disconnector",Zc="隔离开关 (QS)",Qc="switching",ed="-10 -42 15 64",td=15,nd=64,od='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="-20" x2="3" y2="-20" fill="none" stroke="black" stroke-width="1"/>',rd=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],sd=[{name:"open",type:"boolean",default:!1,label:"断开"}],id={x:6,y:-10,anchor:"start"},ad={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},P_={id:Jc,name:Zc,category:Qc,viewBox:ed,width:td,height:nd,svg:od,terminals:rd,state:sd,label:id,source:ad},I_=Object.freeze(Object.defineProperty({__proto__:null,category:Qc,default:P_,height:nd,id:Jc,label:id,name:Zc,source:ad,state:sd,svg:od,terminals:rd,viewBox:ed,width:td},Symbol.toStringTag,{value:"Module"})),ld="distance-relay",cd="距离继电器 (21)",dd="protection",ud="距离 / 低阻抗保护继电器 (ANSI 21)。",fd="-62 -42 64 44",hd=64,md=44,pd='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-42" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Z &lt;</text>',gd=[{id:"t_top",x:-30,y:-40,orientation:"n"}],yd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},O_={id:ld,name:cd,category:dd,description:ud,viewBox:fd,width:hd,height:md,svg:pd,terminals:gd,source:yd},B_=Object.freeze(Object.defineProperty({__proto__:null,category:dd,default:O_,description:ud,height:md,id:ld,name:cd,source:yd,svg:pd,terminals:gd,viewBox:fd,width:hd},Symbol.toStringTag,{value:"Module"})),xd="earth",bd="接地",wd="busbar",vd="-12 -17 24 34",kd=24,_d=34,Sd='<line x1="-10" y1="0" x2="10" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="5" x2="7" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0.5" y1="15" x2="-0.5" y2="15" fill="none" stroke="black" stroke-width="1"/>',$d=[{id:"t1",x:0,y:-15,orientation:"n"}],jd={kind:"elmt",path:"91_en_60617/en_60617_02/en_60617_02_15/en_60617_02_15_01.elmt",qetEnglishName:"Earth or ground, general symbol"},D_={id:xd,name:bd,category:wd,viewBox:vd,width:kd,height:_d,svg:Sd,terminals:$d,source:jd},L_=Object.freeze(Object.defineProperty({__proto__:null,category:wd,default:D_,height:_d,id:xd,name:bd,source:jd,svg:Sd,terminals:$d,viewBox:vd,width:kd},Symbol.toStringTag,{value:"Module"})),Ed="earthing-switch",Nd="接地刀闸 (QE)",Ad="switching",Td="隔离开关 + 接地连接,单端口",Md="-12 -32 24 64",Cd=24,Pd=64,Id='<line x1="0" y1="-30" x2="0" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="-12" x2="-9" y2="9" stroke="black" stroke-width="1" fill="none"/><line x1="-3" y1="-12" x2="3" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-10" y1="14" x2="10" y2="14" stroke="black" stroke-width="1" fill="none"/><line x1="-7" y1="19" x2="7" y2="19" stroke="black" stroke-width="1" fill="none"/><line x1="-4" y1="24" x2="4" y2="24" stroke="black" stroke-width="1" fill="none"/><line x1="-1.5" y1="29" x2="1.5" y2="29" stroke="black" stroke-width="1" fill="none"/>',Od=[{id:"t_top",x:0,y:-30,orientation:"n"}],Bd=[{name:"open",type:"boolean",default:!0,label:"断开"}],Dd={x:12,y:-8,anchor:"start"},Ld={kind:"inline"},z_={id:Ed,name:Nd,category:Ad,description:Td,viewBox:Md,width:Cd,height:Pd,svg:Id,terminals:Od,state:Bd,label:Dd,source:Ld},R_=Object.freeze(Object.defineProperty({__proto__:null,category:Ad,default:z_,description:Td,height:Pd,id:Ed,label:Dd,name:Nd,source:Ld,state:Bd,svg:Id,terminals:Od,viewBox:Md,width:Cd},Symbol.toStringTag,{value:"Module"})),zd="energy-meter",Rd="电能表 (Wh)",Fd="measurement",Hd="有功电能表 (kWh) — 服务入口 / 子表。",Wd="-22 -36 44 72",qd=44,Xd=72,Yd='<text x="-10" y="19.2" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Wh</text><rect x="-20" y="-10" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><rect x="-20" y="-30" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Gd=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Kd={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},F_={id:zd,name:Rd,category:Fd,description:Hd,viewBox:Wd,width:qd,height:Xd,svg:Yd,terminals:Gd,source:Kd},H_=Object.freeze(Object.defineProperty({__proto__:null,category:Fd,default:F_,description:Hd,height:Xd,id:zd,name:Rd,source:Kd,svg:Yd,terminals:Gd,viewBox:Wd,width:qd},Symbol.toStringTag,{value:"Module"})),Ud="ev-charger",Vd="EV 充电桩",Jd="load",Zd="电动汽车充电站 / 充电桩。",Qd="-17 -27 34 49",eu=34,tu=49,nu='<line x1="0" y1="-25" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-15" y="-15" width="30" height="35" fill="none" stroke="black" stroke-width="1"/><rect x="-9" y="-8" width="14" height="6" fill="none" stroke="black" stroke-width="0.8"/><rect x="5" y="-7" width="2" height="4" fill="black"/><text x="-9" y="13" font-family="Liberation Sans, Arial, sans-serif" font-size="7" fill="#000000">EV</text>',ou=[{id:"t_top",x:0,y:-25,orientation:"n"}],ru={kind:"inline"},W_={id:Ud,name:Vd,category:Jd,description:Zd,viewBox:Qd,width:eu,height:tu,svg:nu,terminals:ou,source:ru},q_=Object.freeze(Object.defineProperty({__proto__:null,category:Jd,default:W_,description:Zd,height:tu,id:Ud,name:Vd,source:ru,svg:nu,terminals:ou,viewBox:Qd,width:eu},Symbol.toStringTag,{value:"Module"})),su="frequency-meter",iu="频率表 (Hz)",au="measurement",lu="-22 -42 44 44",cu=44,du=44,uu='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">Hz</text>',fu=[{id:"t_top",x:0,y:-40,orientation:"n"}],hu={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},X_={id:su,name:iu,category:au,viewBox:lu,width:cu,height:du,svg:uu,terminals:fu,source:hu},Y_=Object.freeze(Object.defineProperty({__proto__:null,category:au,default:X_,height:du,id:su,name:iu,source:hu,svg:uu,terminals:fu,viewBox:lu,width:cu},Symbol.toStringTag,{value:"Module"})),mu="fuse-switch-disconnector",pu="熔断器式隔离开关",gu="switching",yu="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",xu="-8 -32 12 64",bu=12,wu=64,vu='<line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="-5" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-13" x2="0" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-3" y1="6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="1" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="5" x2="-3" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-6" x2="-6" y2="-5" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-11" rx="1" ry="1" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-13" x2="2" y2="-13" fill="none" stroke="black" stroke-width="1"/>',ku=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],_u=[{name:"open",type:"boolean",default:!1,label:"断开"}],Su={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_09.elmt",qetEnglishName:"Fuse switch-disconnector; On-load isolating fuse switch"},G_={id:mu,name:pu,category:gu,description:yu,viewBox:xu,width:bu,height:wu,svg:vu,terminals:ku,state:_u,source:Su},K_=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:G_,description:yu,height:wu,id:mu,name:pu,source:Su,state:_u,svg:vu,terminals:ku,viewBox:xu,width:bu},Symbol.toStringTag,{value:"Module"})),$u="fuse",ju="熔断器 (FU)",Eu="switching",Nu="-7 -32 14 64",Au=14,Tu=64,Mu='<line x1="0" y1="-30" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><rect x="-5" y="-15" width="10" height="30" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',Cu=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Pu=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],Iu={x:7,y:-2,anchor:"start"},Ou={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},U_={id:$u,name:ju,category:Eu,viewBox:Nu,width:Au,height:Tu,svg:Mu,terminals:Cu,state:Pu,label:Iu,source:Ou},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Eu,default:U_,height:Tu,id:$u,label:Iu,name:ju,source:Ou,state:Pu,svg:Mu,terminals:Cu,viewBox:Nu,width:Au},Symbol.toStringTag,{value:"Module"})),Bu="generator",Du="发电机 (G)",Lu="source",zu="-42 -42 44 44",Ru=44,Fu=44,Hu='<rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-24" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text>',Wu=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],qu={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},J_={id:Bu,name:Du,category:Lu,viewBox:zu,width:Ru,height:Fu,svg:Hu,terminals:Wu,source:qu},Z_=Object.freeze(Object.defineProperty({__proto__:null,category:Lu,default:J_,height:Fu,id:Bu,name:Du,source:qu,svg:Hu,terminals:Wu,viewBox:zu,width:Ru},Symbol.toStringTag,{value:"Module"})),Xu="genset",Yu="发电机组 (G)",Gu="source",Ku="柴油 / 燃气发电机组。",Uu="-28 -22 56 64",Vu=56,Ju=64,Zu='<rect x="-26" y="-20" width="52" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">GEN</text><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Qu=[{id:"t_out",x:0,y:40,orientation:"s"}],ef=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],tf={kind:"inline"},Q_={id:Xu,name:Yu,category:Gu,description:Ku,viewBox:Uu,width:Vu,height:Ju,svg:Zu,terminals:Qu,params:ef,source:tf},eS=Object.freeze(Object.defineProperty({__proto__:null,category:Gu,default:Q_,description:Ku,height:Ju,id:Xu,name:Yu,params:ef,source:tf,svg:Zu,terminals:Qu,viewBox:Uu,width:Vu},Symbol.toStringTag,{value:"Module"})),nf="gfci-breaker",of="GFCI 断路器 (RCBO)",rf="protection",sf="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",af="-18 -22 22 44",lf=22,cf=44,df='<text x="-14" y="13.8" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">IΔ</text><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="-5,-10 0,10 0,20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-4" x2="-8" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="-4" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-8" y2="-8" fill="none" stroke="black" stroke-width="0.4"/><line x1="-13" y1="-8" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="-4" x2="-13" y2="-4" fill="none" stroke="black" stroke-width="0.4"/><path d="M -8 1 A 2.5 3.5 0 0 0 -13 1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-8" y1="1" x2="-2" y2="1" fill="none" stroke="black" stroke-width="0.4"/><line x1="-16" y1="1" x2="-13" y2="1" fill="none" stroke="black" stroke-width="0.4"/>',uf=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ff=[{name:"open",type:"boolean",default:!1,label:"断开"}],hf=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],mf={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},tS={id:nf,name:of,category:rf,description:sf,viewBox:af,width:lf,height:cf,svg:df,terminals:uf,state:ff,params:hf,source:mf},nS=Object.freeze(Object.defineProperty({__proto__:null,category:rf,default:tS,description:sf,height:cf,id:nf,name:of,params:hf,source:mf,state:ff,svg:df,terminals:uf,viewBox:af,width:lf},Symbol.toStringTag,{value:"Module"})),pf="grid-source",gf="系统电源",yf="source",xf="无穷大母线 / 外部电网",bf="-16 -31 32 53",wf=32,vf=53,kf='<circle cx="0" cy="-15" r="14" fill="none" stroke="black" stroke-width="1"/><text x="0" y="-12" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="14">~</text><line x1="0" y1="-1" x2="0" y2="20" stroke="black" stroke-width="1" fill="none"/>',_f=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Sf={kind:"inline"},oS={id:pf,name:gf,category:yf,description:xf,viewBox:bf,width:wf,height:vf,svg:kf,terminals:_f,source:Sf},rS=Object.freeze(Object.defineProperty({__proto__:null,category:yf,default:oS,description:xf,height:vf,id:pf,name:gf,source:Sf,svg:kf,terminals:_f,viewBox:bf,width:wf},Symbol.toStringTag,{value:"Module"})),$f="grounding-transformer",jf="接地变 (Z形)",Ef="grounding",Nf="星-曲折接线变压器,中性点接地用",Af="-62 -152 64 164",Tf=64,Mf=164,Cf='<line x1="-30" y1="-40" x2="-35" y2="-35" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-25" y2="-35" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-35" x2="-40" y2="-38" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-150" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-35" x2="-25" y2="-30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-30" y2="-45" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-45" x2="-25" y2="-48" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-130" x2="-20" y2="-140" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-135" x2="-20" y2="-145" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="5" x2="-20" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-85" x2="-30" y2="-95" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-20" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-95" x2="-40" y2="-100" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-40" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-40" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/>',Pf=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],If={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_10/en_60617_06_10_15.elmt",qetEnglishName:"Three-phase transformer, connection star-zigzag with the neutral brought out"},sS={id:$f,name:jf,category:Ef,description:Nf,viewBox:Af,width:Tf,height:Mf,svg:Cf,terminals:Pf,source:If},iS=Object.freeze(Object.defineProperty({__proto__:null,category:Ef,default:sS,description:Nf,height:Mf,id:$f,name:jf,source:If,svg:Cf,terminals:Pf,viewBox:Af,width:Tf},Symbol.toStringTag,{value:"Module"})),Of="heater",Bf="电加热器 (EH)",Df="load",Lf="电阻加热元件 / 电热负荷。",zf="-22 -7 54 14",Rf=54,Ff=14,Hf='<line x1="-20" y1="0" x2="-10" y2="0" fill="none" stroke="black" stroke-width="1"/><rect x="-10" y="-5" width="30" height="10" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="0" x2="30" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-5" x2="-5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="5" y1="-5" x2="5" y2="5" fill="none" stroke="black" stroke-width="1"/><line x1="15" y1="-5" x2="15" y2="5" fill="none" stroke="black" stroke-width="1"/>',Wf=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],qf=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Xf={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},aS={id:Of,name:Bf,category:Df,description:Lf,viewBox:zf,width:Rf,height:Ff,svg:Hf,terminals:Wf,params:qf,source:Xf},lS=Object.freeze(Object.defineProperty({__proto__:null,category:Df,default:aS,description:Lf,height:Ff,id:Of,name:Bf,params:qf,source:Xf,svg:Hf,terminals:Wf,viewBox:zf,width:Rf},Symbol.toStringTag,{value:"Module"})),Yf="igbt",Gf="绝缘栅双极晶体管 (IGBT)",Kf="passive",Uf="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Vf="-32 -32 54 74",Jf=54,Zf=74,Qf='<line x1="0" y1="25" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polyline points="-30,20 -5,20 -5,-20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-15" x2="20" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="20" y2="40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="15" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-25" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-8" x2="0" y2="8" fill="none" stroke="black" stroke-width="1"/><polyline points="10,-24 8,-21 12,-22" fill="none" stroke="black" stroke-width="1"/><polyline points="10,25 11,29 8,27" fill="none" stroke="black" stroke-width="1"/>',eh=[{id:"t1",x:20,y:-30,orientation:"n"},{id:"t2",x:20,y:40,orientation:"s"},{id:"t_g",x:-30,y:20,orientation:"w"}],th={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_05/en_60617_05_05_19.elmt",qetEnglishName:"Insulated-gate bipolar transistor (IGBT) enhancement type, N channel"},cS={id:Yf,name:Gf,category:Kf,description:Uf,viewBox:Vf,width:Jf,height:Zf,svg:Qf,terminals:eh,source:th},dS=Object.freeze(Object.defineProperty({__proto__:null,category:Kf,default:cS,description:Uf,height:Zf,id:Yf,name:Gf,source:th,svg:Qf,terminals:eh,viewBox:Vf,width:Jf},Symbol.toStringTag,{value:"Module"})),nh="indicator-light",oh="指示灯 (HL)",rh="control",sh="信号 / 状态指示灯。",ih="-12 -22 24 24",ah=24,lh=24,ch='<ellipse cx="0" cy="-10" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-3" x2="7" y2="-17" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-17" x2="7" y2="-3" fill="none" stroke="black" stroke-width="1"/>',dh=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],uh=[{name:"color",label:"颜色",type:"string"}],fh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},uS={id:nh,name:oh,category:rh,description:sh,viewBox:ih,width:ah,height:lh,svg:ch,terminals:dh,params:uh,source:fh},fS=Object.freeze(Object.defineProperty({__proto__:null,category:rh,default:uS,description:sh,height:lh,id:nh,name:oh,params:uh,source:fh,svg:ch,terminals:dh,viewBox:ih,width:ah},Symbol.toStringTag,{value:"Module"})),hh="inductor",mh="电感 (L)",ph="passive",gh="通用电感 / 线圈 / 扼流圈。",yh="-17 -32 34 64",xh=34,bh=64,wh='<line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><path d="M 0 15 A 15 15 0 1 0 -15 0" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="0" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',vh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],kh=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],_h={x:6,y:0,anchor:"start"},Sh={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},hS={id:hh,name:mh,category:ph,description:gh,viewBox:yh,width:xh,height:bh,svg:wh,terminals:vh,params:kh,label:_h,source:Sh},mS=Object.freeze(Object.defineProperty({__proto__:null,category:ph,default:hS,description:gh,height:bh,id:hh,label:_h,name:mh,params:kh,source:Sh,svg:wh,terminals:vh,viewBox:yh,width:xh},Symbol.toStringTag,{value:"Module"})),$h="inverter",jh="逆变器 (DC→AC)",Eh="renewable",Nh="-42 -42 44 44",Ah=44,Th=44,Mh='<g transform="matrix(1 0 0 -1 0 -40)"><path d="M -15 -8 A 5 2.5 0 0 0 -25 -8" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><path d="M -15 -8 A 5 2.5 0 0 0 -5 -8" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/></g>',Ch=[{id:"t_dc",x:-20,y:0,orientation:"s"},{id:"t_ac",x:-20,y:-40,orientation:"n"}],Ph={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},pS={id:$h,name:jh,category:Eh,viewBox:Nh,width:Ah,height:Th,svg:Mh,terminals:Ch,source:Ph},gS=Object.freeze(Object.defineProperty({__proto__:null,category:Eh,default:pS,height:Th,id:$h,name:jh,source:Ph,svg:Mh,terminals:Ch,viewBox:Nh,width:Ah},Symbol.toStringTag,{value:"Module"})),Ih="limit-switch",Oh="限位开关 (SQ)",Bh="control",Dh="行程 / 位置开关 (常开, 机械操作)。",Lh="-10 -42 12 64",zh=12,Rh=64,Fh='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-13" x2="-7" y2="-12" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="-12" x2="-3" y2="-8" fill="none" stroke="black" stroke-width="1"/>',Hh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Wh=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],qh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},yS={id:Ih,name:Oh,category:Bh,description:Dh,viewBox:Lh,width:zh,height:Rh,svg:Fh,terminals:Hh,state:Wh,source:qh},xS=Object.freeze(Object.defineProperty({__proto__:null,category:Bh,default:yS,description:Dh,height:Rh,id:Ih,name:Oh,source:qh,state:Wh,svg:Fh,terminals:Hh,viewBox:Lh,width:zh},Symbol.toStringTag,{value:"Module"})),Xh="load-switch",Yh="负荷开关",Gh="switching",Kh="-10 -42 14 64",Uh=14,Vh=64,Jh='<line x1="0" y1="-24" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-22" rx="2" ry="2" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-24" x2="2" y2="-24" fill="none" stroke="black" stroke-width="1"/>',Zh=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Qh=[{name:"open",type:"boolean",default:!1,label:"断开"}],em={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_08.elmt",qetEnglishName:"Switch-disconnector; On-load isolating switch"},bS={id:Xh,name:Yh,category:Gh,viewBox:Kh,width:Uh,height:Vh,svg:Jh,terminals:Zh,state:Qh,source:em},wS=Object.freeze(Object.defineProperty({__proto__:null,category:Gh,default:bS,height:Vh,id:Xh,name:Yh,source:em,state:Qh,svg:Jh,terminals:Zh,viewBox:Kh,width:Uh},Symbol.toStringTag,{value:"Module"})),tm="load",nm="负荷",om="load",rm="抽象负荷(电流流出箭头)",sm="-8 -22 16 46",im=16,am=46,lm='<line x1="0" y1="-20" x2="0" y2="10" stroke="black" stroke-width="1" fill="none"/><polygon points="-6,10 6,10 0,22" fill="black" stroke="black" stroke-width="1"/>',cm=[{id:"t_top",x:0,y:-20,orientation:"n"}],dm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],um={x:6,y:0,anchor:"start"},fm={kind:"inline"},vS={id:tm,name:nm,category:om,description:rm,viewBox:sm,width:im,height:am,svg:lm,terminals:cm,params:dm,label:um,source:fm},kS=Object.freeze(Object.defineProperty({__proto__:null,category:om,default:vS,description:rm,height:am,id:tm,label:um,name:nm,params:dm,source:fm,svg:lm,terminals:cm,viewBox:sm,width:im},Symbol.toStringTag,{value:"Module"})),hm="make-contact",mm="常开触点 (NO)",pm="control",gm="常开辅助触点 (make contact)。",ym="-10 -42 12 64",xm=12,bm=64,wm='<line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',vm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],km=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],_m={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_01.elmt",qetEnglishName:"Make contact, general symbol; Switch, general symbol"},_S={id:hm,name:mm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,state:km,source:_m},SS=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:_S,description:gm,height:bm,id:hm,name:mm,source:_m,state:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),Sm="motor-starter",$m="电机启动器",jm="motor-control",Em="电机启动器 (IEC 60617 通用符号)。",Nm="-22 -27 44 54",Am=44,Tm=54,Mm='<rect x="-20" y="-20" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,-20 0,-10 20,-20" fill="none" stroke="black" stroke-width="1"/>',Cm=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Pm={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},$S={id:Sm,name:$m,category:jm,description:Em,viewBox:Nm,width:Am,height:Tm,svg:Mm,terminals:Cm,source:Pm},jS=Object.freeze(Object.defineProperty({__proto__:null,category:jm,default:$S,description:Em,height:Tm,id:Sm,name:$m,source:Pm,svg:Mm,terminals:Cm,viewBox:Nm,width:Am},Symbol.toStringTag,{value:"Module"})),Im="mppt",Om="MPPT 控制器",Bm="renewable",Dm="MPPT 太阳能充电控制器(DC/DC,最大功率点跟踪)",Lm="-42 -42 44 44",zm=44,Rm=44,Fm='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-36" x2="-20" y2="-36" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-36" y1="-32" x2="-30" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="-26" y1="-32" x2="-20" y2="-32" fill="none" stroke="black" stroke-width="1"/>',Hm=[{id:"t_pv",x:-20,y:-40,orientation:"n"},{id:"t_bat",x:-20,y:0,orientation:"s"}],Wm=[{name:"I",label:"额定电流",type:"number",unit:"A"}],qm={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_02.elmt",qetEnglishName:"DC/DC converter"},ES={id:Im,name:Om,category:Bm,description:Dm,viewBox:Lm,width:zm,height:Rm,svg:Fm,terminals:Hm,params:Wm,source:qm},NS=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:ES,description:Dm,height:Rm,id:Im,name:Om,params:Wm,source:qm,svg:Fm,terminals:Hm,viewBox:Lm,width:zm},Symbol.toStringTag,{value:"Module"})),Xm="ngr",Ym="中性点电阻 (NGR)",Gm="grounding",Km="小电阻接地:连接变压器中性点到地",Um="-12 -32 24 62",Vm=24,Jm=62,Zm='<line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><rect x="-6" y="-15" width="12" height="22" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="7" x2="0" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="15" x2="10" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-7" y1="19" x2="7" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="23" x2="4" y2="23" fill="none" stroke="black" stroke-width="1"/><line x1="-1.5" y1="27" x2="1.5" y2="27" fill="none" stroke="black" stroke-width="1"/>',Qm=[{id:"t_top",x:0,y:-30,orientation:"n"}],ep=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],tp={kind:"inline"},AS={id:Xm,name:Ym,category:Gm,description:Km,viewBox:Um,width:Vm,height:Jm,svg:Zm,terminals:Qm,params:ep,source:tp},TS=Object.freeze(Object.defineProperty({__proto__:null,category:Gm,default:AS,description:Km,height:Jm,id:Xm,name:Ym,params:ep,source:tp,svg:Zm,terminals:Qm,viewBox:Um,width:Vm},Symbol.toStringTag,{value:"Module"})),np="overcurrent-relay",op="过流继电器 (50/51)",rp="protection",sp="过电流保护继电器 (ANSI 50/51)。",ip="-62 -62 64 64",ap=64,lp=64,cp='<rect x="-60" y="-60" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-48" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">5...10A</text>',dp=[{id:"t_top",x:-30,y:-60,orientation:"n"}],up={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},MS={id:np,name:op,category:rp,description:sp,viewBox:ip,width:ap,height:lp,svg:cp,terminals:dp,source:up},CS=Object.freeze(Object.defineProperty({__proto__:null,category:rp,default:MS,description:sp,height:lp,id:np,name:op,source:up,svg:cp,terminals:dp,viewBox:ip,width:ap},Symbol.toStringTag,{value:"Module"})),fp="panelboard",hp="配电箱",mp="load",pp="配电箱 / 负荷中心(IEC 60617 分配中心符号):顶部进线,底部分路示意",gp="-52 -62 54 64",yp=54,xp=64,bp='<g transform="matrix(1 0 0 -1 0 -60)"><rect x="-50" y="-40" width="50" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="-60" x2="-40" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-60" x2="-30" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-60" x2="-20" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-60" x2="-10" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-25" y1="-20" x2="-25" y2="0" fill="none" stroke="black" stroke-width="1"/></g>',wp=[{id:"t_in",x:-25,y:-60,orientation:"n"}],vp={kind:"elmt",path:"91_en_60617/en_60617_11/en_60617_11_12/en_60617_11_12_07.elmt",qetEnglishName:"Distribution centre"},PS={id:fp,name:hp,category:mp,description:pp,viewBox:gp,width:yp,height:xp,svg:bp,terminals:wp,source:vp},IS=Object.freeze(Object.defineProperty({__proto__:null,category:mp,default:PS,description:pp,height:xp,id:fp,name:hp,source:vp,svg:bp,terminals:wp,viewBox:gp,width:yp},Symbol.toStringTag,{value:"Module"})),kp="phase-failure-relay",_p="断相继电器",Sp="protection",$p="断相 / 缺相保护继电器。",jp="-62 -42 64 44",Ep=64,Np=44,Ap='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">m &lt; 3</text>',Tp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Mp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},OS={id:kp,name:_p,category:Sp,description:$p,viewBox:jp,width:Ep,height:Np,svg:Ap,terminals:Tp,source:Mp},BS=Object.freeze(Object.defineProperty({__proto__:null,category:Sp,default:OS,description:$p,height:Np,id:kp,name:_p,source:Mp,svg:Ap,terminals:Tp,viewBox:jp,width:Ep},Symbol.toStringTag,{value:"Module"})),Cp="plc",Pp="PLC / 控制器",Ip="control",Op="可编程逻辑控制器 (PLC)。",Bp="-24 -42 48 84",Dp=48,Lp=84,zp='<rect x="-22" y="-22" width="44" height="44" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">PLC</text><line x1="0" y1="-40" x2="0" y2="-22" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="22" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Rp=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],Fp={kind:"inline"},DS={id:Cp,name:Pp,category:Ip,description:Op,viewBox:Bp,width:Dp,height:Lp,svg:zp,terminals:Rp,source:Fp},LS=Object.freeze(Object.defineProperty({__proto__:null,category:Ip,default:DS,description:Op,height:Lp,id:Cp,name:Pp,source:Fp,svg:zp,terminals:Rp,viewBox:Bp,width:Dp},Symbol.toStringTag,{value:"Module"})),Hp="power-factor-meter",Wp="功率因数表 (cosφ)",qp="measurement",Xp="功率因数表 (cosφ)。",Yp="-22 -42 44 44",Gp=44,Kp=44,Up='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-14" y="-6.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">cos φ</text>',Vp=[{id:"t_top",x:0,y:-40,orientation:"n"}],Jp={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},zS={id:Hp,name:Wp,category:qp,description:Xp,viewBox:Yp,width:Gp,height:Kp,svg:Up,terminals:Vp,source:Jp},RS=Object.freeze(Object.defineProperty({__proto__:null,category:qp,default:zS,description:Xp,height:Kp,id:Hp,name:Wp,source:Jp,svg:Up,terminals:Vp,viewBox:Yp,width:Gp},Symbol.toStringTag,{value:"Module"})),Zp="power-supply",Qp="开关电源 (PS)",e0="source",t0="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",n0="-24 -42 48 84",o0=48,r0=84,s0='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="8" y="15" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">=</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',i0=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],a0=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],l0={kind:"inline"},FS={id:Zp,name:Qp,category:e0,description:t0,viewBox:n0,width:o0,height:r0,svg:s0,terminals:i0,params:a0,source:l0},HS=Object.freeze(Object.defineProperty({__proto__:null,category:e0,default:FS,description:t0,height:r0,id:Zp,name:Qp,params:a0,source:l0,svg:s0,terminals:i0,viewBox:n0,width:o0},Symbol.toStringTag,{value:"Module"})),c0="protective-relay",d0="保护继电器",u0="protection",f0="测量继电器 / 保护继电器通用符号 (IEC 60617)。",h0="-32 -42 64 44",m0=64,p0=44,g0='<polygon points="-2,-22 2,-22 0,-25" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-22 -2,-19 -6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="2,-22 2,-19 6,-20" fill="black" stroke="black" stroke-width="1"/><polygon points="-2,-19 0,-17 -3,-15" fill="black" stroke="black" stroke-width="1"/><polygon points="0,-17 2,-19 4,-15" fill="black" stroke="black" stroke-width="1"/><rect x="-2" y="-22" width="4" height="4" rx="0" ry="0" fill="black" stroke="black" stroke-width="1"/><rect x="-30" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/>',y0=[{id:"t_top",x:0,y:-40,orientation:"n"}],x0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_16/en_60617_07_16_01.elmt",qetEnglishName:"Measuring relay; Device related to a measuring relay"},WS={id:c0,name:d0,category:u0,description:f0,viewBox:h0,width:m0,height:p0,svg:g0,terminals:y0,source:x0},qS=Object.freeze(Object.defineProperty({__proto__:null,category:u0,default:WS,description:f0,height:p0,id:c0,name:d0,source:x0,svg:g0,terminals:y0,viewBox:h0,width:m0},Symbol.toStringTag,{value:"Module"})),b0="proximity-switch",w0="接近开关 (SQ)",v0="control",k0="接近传感器 / 无触点接近开关。",_0="-12 -32 24 64",S0=24,$0=64,j0='<line x1="0" y1="-30" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="30" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 -10,0 0,10 10,0" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-6" x2="-4" y2="6" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-6" x2="4" y2="6" fill="none" stroke="black" stroke-width="1"/>',E0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],N0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},XS={id:b0,name:w0,category:v0,description:k0,viewBox:_0,width:S0,height:$0,svg:j0,terminals:E0,source:N0},YS=Object.freeze(Object.defineProperty({__proto__:null,category:v0,default:XS,description:k0,height:$0,id:b0,name:w0,source:N0,svg:j0,terminals:E0,viewBox:_0,width:S0},Symbol.toStringTag,{value:"Module"})),A0="pt",T0="电压互感器 (PT)",M0="instrument-transformer",C0="-22 -42 44 115",P0=44,I0=115,O0='<ellipse cx="0" cy="1" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-40" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="30" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="-0.13" y1="51" x2="-0.13" y2="71" fill="none" stroke="black" stroke-width="1"/>',B0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],D0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},GS={id:A0,name:T0,category:M0,viewBox:C0,width:P0,height:I0,svg:O0,terminals:B0,source:D0},KS=Object.freeze(Object.defineProperty({__proto__:null,category:M0,default:GS,height:I0,id:A0,name:T0,source:D0,svg:O0,terminals:B0,viewBox:C0,width:P0},Symbol.toStringTag,{value:"Module"})),L0="push-button",z0="按钮 (SB)",R0="control",F0="手动按钮, 自动复位 (常开 make)。",H0="-37 -42 39 64",W0=39,q0=64,X0='<line x1="-35" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/><line x1="-35" y1="-15" x2="-30" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-5" x2="-35" y2="-5" fill="none" stroke="black" stroke-width="1"/>',Y0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],G0={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_02.elmt",qetEnglishName:"Switch, manually operated, push-button, automatic return"},US={id:L0,name:z0,category:R0,description:F0,viewBox:H0,width:W0,height:q0,svg:X0,terminals:Y0,source:G0},VS=Object.freeze(Object.defineProperty({__proto__:null,category:R0,default:US,description:F0,height:q0,id:L0,name:z0,source:G0,svg:X0,terminals:Y0,viewBox:H0,width:W0},Symbol.toStringTag,{value:"Module"})),K0="pv",U0="光伏组件",V0="renewable",J0="-33 -22 85 64",Z0=85,Q0=64,eg='<line x1="-16" y1="24" x2="-26" y2="14" fill="none" stroke="black" stroke-width="1"/><line x1="-21" y1="29" x2="-31" y2="19" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,23 -17,20 -15,25" fill="black" stroke="black" stroke-width="1"/><polygon points="-22,25 -25,28 -20,30" fill="black" stroke="black" stroke-width="1"/><rect x="-10" y="-20" width="60" height="60" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="15" y="7.2" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">G</text><line x1="10" y1="20" x2="20" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="15" x2="20" y2="25" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="10" x2="25" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="25" y1="20" x2="35" y2="20" fill="none" stroke="black" stroke-width="1"/>',tg=[{id:"t_dc",x:0,y:40,orientation:"s"}],ng={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},JS={id:K0,name:U0,category:V0,viewBox:J0,width:Z0,height:Q0,svg:eg,terminals:tg,source:ng},ZS=Object.freeze(Object.defineProperty({__proto__:null,category:V0,default:JS,height:Q0,id:K0,name:U0,source:ng,svg:eg,terminals:tg,viewBox:J0,width:Z0},Symbol.toStringTag,{value:"Module"})),og="rcd",rg="剩余电流装置 (RCD)",sg="protection",ig="不带过流保护的剩余电流断路器 (IEC 61008)。",ag="-12 -22 19 44",lg=19,cg=44,dg='<line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="2" y1="-12" x2="-2" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-2" y1="-12" x2="2" y2="-8" fill="none" stroke="black" stroke-width="1"/><polyline points="0,20 0,10 -7,-9" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="13" rx="4.5" ry="2" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,0 -10,0 -10,13 -5,13" fill="none" stroke="black" stroke-width="0.4" stroke-dasharray="4 2"/>',ug=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],fg=[{name:"open",type:"boolean",default:!1,label:"断开"}],hg=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],mg={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},QS={id:og,name:rg,category:sg,description:ig,viewBox:ag,width:lg,height:cg,svg:dg,terminals:ug,state:fg,params:hg,source:mg},e$=Object.freeze(Object.defineProperty({__proto__:null,category:sg,default:QS,description:ig,height:cg,id:og,name:rg,params:hg,source:mg,state:fg,svg:dg,terminals:ug,viewBox:ag,width:lg},Symbol.toStringTag,{value:"Module"})),pg="recloser",gg="重合闸 (Recloser)",yg="protection",xg="中压自动重合闸开关。",bg="-12 -32 36 64",wg=36,vg=64,kg='<line x1="0" y1="-30" x2="0" y2="-10" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="0" x2="-8" y2="-13" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-8" x2="2" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="-2" y1="-12" x2="2" y2="-8" stroke="black" stroke-width="1" fill="none"/><path d="M 13 -12 A 7 7 0 1 1 6 -5" fill="none" stroke="black" stroke-width="0.8"/><polygon points="4,-7 6,-5 8,-3" fill="black"/><text x="14" y="6" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">AR</text>',_g=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Sg=[{name:"open",type:"boolean",default:!1,label:"断开"}],$g={kind:"inline"},t$={id:pg,name:gg,category:yg,description:xg,viewBox:bg,width:wg,height:vg,svg:kg,terminals:_g,state:Sg,source:$g},n$=Object.freeze(Object.defineProperty({__proto__:null,category:yg,default:t$,description:xg,height:vg,id:pg,name:gg,source:$g,state:Sg,svg:kg,terminals:_g,viewBox:bg,width:wg},Symbol.toStringTag,{value:"Module"})),jg="rectifier",Eg="整流器 (AC→DC)",Ng="renewable",Ag="-42 -42 44 44",Tg=44,Mg=44,Cg='<line x1="-40" y1="0" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><rect x="-40" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-8" x2="-4" y2="-8" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-4" x2="-14" y2="-4" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-4" x2="-4" y2="-4" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -35 -30" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -30 A 5 2.5 0 0 0 -15 -30" fill="none" stroke="black" stroke-width="1"/>',Pg=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Ig={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},o$={id:jg,name:Eg,category:Ng,viewBox:Ag,width:Tg,height:Mg,svg:Cg,terminals:Pg,source:Ig},r$=Object.freeze(Object.defineProperty({__proto__:null,category:Ng,default:o$,height:Mg,id:jg,name:Eg,source:Ig,svg:Cg,terminals:Pg,viewBox:Ag,width:Tg},Symbol.toStringTag,{value:"Module"})),Og="relay-coil",Bg="继电器线圈 (KA)",Dg="control",Lg="继电器 / 接触器操作线圈 (方框)。",zg="-22 -22 44 44",Rg=44,Fg=44,Hg='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/>',Wg=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],qg={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_01.elmt",qetEnglishName:"Operating device, general symbol; Relay coil, general symbol"},s$={id:Og,name:Bg,category:Dg,description:Lg,viewBox:zg,width:Rg,height:Fg,svg:Hg,terminals:Wg,source:qg},i$=Object.freeze(Object.defineProperty({__proto__:null,category:Dg,default:s$,description:Lg,height:Fg,id:Og,name:Bg,source:qg,svg:Hg,terminals:Wg,viewBox:zg,width:Rg},Symbol.toStringTag,{value:"Module"})),Xg="resistor",Yg="电阻 (R)",Gg="passive",Kg="通用电阻 / 限流 / 制动电阻。",Ug="-6 -23 12 35",Vg=12,Jg=35,Zg='<line x1="0" y1="-10" x2="0" y2="-20" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="10" x2="4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="10" x2="4" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="4" y1="-10" x2="-4" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="-4" y1="-10" x2="-4" y2="10" fill="none" stroke="black" stroke-width="1"/>',Qg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],e1=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],t1={x:6,y:0,anchor:"start"},n1={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},a$={id:Xg,name:Yg,category:Gg,description:Kg,viewBox:Ug,width:Vg,height:Jg,svg:Zg,terminals:Qg,params:e1,label:t1,source:n1},l$=Object.freeze(Object.defineProperty({__proto__:null,category:Gg,default:a$,description:Kg,height:Jg,id:Xg,label:t1,name:Yg,params:e1,source:n1,svg:Zg,terminals:Qg,viewBox:Ug,width:Vg},Symbol.toStringTag,{value:"Module"})),o1="reverse-power-relay",r1="逆功率继电器 (32)",s1="protection",i1="逆功率 / 逆流保护继电器 (ANSI 32)。",a1="-62 -42 64 44",l1=64,c1=44,d1='<rect x="-60" y="-40" width="60" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-46" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">I</text><polygon points="-15,-20 -30,-20 -24,-22 -24,-18 -30,-20 -24,-20" fill="black" stroke="black" stroke-width="1"/>',u1=[{id:"t_top",x:-30,y:-40,orientation:"n"}],f1={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},c$={id:o1,name:r1,category:s1,description:i1,viewBox:a1,width:l1,height:c1,svg:d1,terminals:u1,source:f1},d$=Object.freeze(Object.defineProperty({__proto__:null,category:s1,default:c$,description:i1,height:c1,id:o1,name:r1,source:f1,svg:d1,terminals:u1,viewBox:a1,width:l1},Symbol.toStringTag,{value:"Module"})),h1="selector-switch",m1="选择开关 (SA)",p1="switching",g1="转换 / 选择开关 (旋转操作, 保位)。",y1="-34 -42 36 64",x1=36,b1=64,w1='<line x1="-32" y1="-10" x2="-2" y2="-10" fill="none" stroke="black" stroke-width="1" stroke-dasharray="4 2"/><line x1="0" y1="-20" x2="0" y2="-40" fill="none" stroke="black" stroke-width="1"/><line x1="-32" y1="-15" x2="-32" y2="-5" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="0" x2="-8" y2="-23" fill="none" stroke="black" stroke-width="1"/>',v1=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],k1=[{name:"open",type:"boolean",default:!1,label:"断开"}],_1={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_07/en_60617_07_07_04.elmt",qetEnglishName:"Switch, manually operated, turning, stay-put"},u$={id:h1,name:m1,category:p1,description:g1,viewBox:y1,width:x1,height:b1,svg:w1,terminals:v1,state:k1,source:_1},f$=Object.freeze(Object.defineProperty({__proto__:null,category:p1,default:u$,description:g1,height:b1,id:h1,name:m1,source:_1,state:k1,svg:w1,terminals:v1,viewBox:y1,width:x1},Symbol.toStringTag,{value:"Module"})),S1="series-reactor",$1="串联电抗器",j1="compensation",E1="与并联电抗器同符号;通过用法区分。",N1="-62 -82 64 104",A1=64,T1=104,M1='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',C1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],P1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},h$={id:S1,name:$1,category:j1,description:E1,viewBox:N1,width:A1,height:T1,svg:M1,terminals:C1,source:P1},m$=Object.freeze(Object.defineProperty({__proto__:null,category:j1,default:h$,description:E1,height:T1,id:S1,name:$1,source:P1,svg:M1,terminals:C1,viewBox:N1,width:A1},Symbol.toStringTag,{value:"Module"})),I1="shunt-capacitor",O1="并联电容器",B1="compensation",D1="-7 -23 14 27",L1=14,z1=27,R1='<line x1="-5" y1="2" x2="5" y2="2" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="-2" x2="5" y2="-2" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-2" fill="none" stroke="black" stroke-width="1"/>',F1=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],H1=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],W1={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},p$={id:I1,name:O1,category:B1,viewBox:D1,width:L1,height:z1,svg:R1,terminals:F1,params:H1,source:W1},g$=Object.freeze(Object.defineProperty({__proto__:null,category:B1,default:p$,height:z1,id:I1,name:O1,params:H1,source:W1,svg:R1,terminals:F1,viewBox:D1,width:L1},Symbol.toStringTag,{value:"Module"})),q1="shunt-reactor",X1="并联电抗器",Y1="compensation",G1="-62 -82 64 104",K1=64,U1=104,V1='<line x1="-30" y1="0" x2="-30" y2="20" fill="none" stroke="black" stroke-width="1"/><path d="M -30 0 A 30 30 0 1 0 -60 -30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-80" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/><line x1="-60" y1="-30" x2="-30" y2="-30" fill="none" stroke="black" stroke-width="1"/>',J1=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Z1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},y$={id:q1,name:X1,category:Y1,viewBox:G1,width:K1,height:U1,svg:V1,terminals:J1,source:Z1},x$=Object.freeze(Object.defineProperty({__proto__:null,category:Y1,default:y$,height:U1,id:q1,name:X1,source:Z1,svg:V1,terminals:J1,viewBox:G1,width:K1},Symbol.toStringTag,{value:"Module"})),Q1="siren",ey="警笛 (HA)",ty="control",ny="声响警笛 / 报警器。",oy="-32 -42 44 54",ry=44,sy=54,iy='<line x1="-20" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-10" x2="0" y2="10" fill="none" stroke="black" stroke-width="1"/><polygon points="10,-10 -30,-10 -10,-40" fill="none" stroke="black" stroke-width="1"/>',ay=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ly={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},b$={id:Q1,name:ey,category:ty,description:ny,viewBox:oy,width:ry,height:sy,svg:iy,terminals:ay,source:ly},w$=Object.freeze(Object.defineProperty({__proto__:null,category:ty,default:b$,description:ny,height:sy,id:Q1,name:ey,source:ly,svg:iy,terminals:ay,viewBox:oy,width:ry},Symbol.toStringTag,{value:"Module"})),cy="socket-outlet",dy="插座 / 连接器",uy="load",fy="电源插座 / 多极连接器。",hy="-7 -2 13 34",my=13,py=34,gy='<line x1="-5" y1="13" x2="4" y2="20" fill="none" stroke="black" stroke-width="0.4"/><line x1="-1" y1="12" x2="-1" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="12" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="9" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="1" y1="12" x2="1" y2="19" fill="none" stroke="black" stroke-width="1"/><path d="M 3 13 A 3 3 0 0 0 -3 13" fill="none" stroke="black" stroke-width="1"/>',yy=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],xy={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
217
+ unifilar`},v$={id:cy,name:dy,category:uy,description:fy,viewBox:hy,width:my,height:py,svg:gy,terminals:yy,source:xy},k$=Object.freeze(Object.defineProperty({__proto__:null,category:uy,default:v$,description:fy,height:py,id:cy,name:dy,source:xy,svg:gy,terminals:yy,viewBox:hy,width:my},Symbol.toStringTag,{value:"Module"})),by="soft-starter",wy="软启动器",vy="motor-control",ky="电机软启动器 (晶闸管降压启动)。",_y="-22 -42 44 84",Sy=44,$y=84,jy='<rect x="-20" y="-20" width="40" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-12" y1="-12" x2="12" y2="12" stroke="black" stroke-width="1" fill="none"/><polygon points="4,8 12,12 8,4" fill="none" stroke="black" stroke-width="1"/><text x="-12" y="-2" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">SS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Ey=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Ny={kind:"inline"},_$={id:by,name:wy,category:vy,description:ky,viewBox:_y,width:Sy,height:$y,svg:jy,terminals:Ey,source:Ny},S$=Object.freeze(Object.defineProperty({__proto__:null,category:vy,default:_$,description:ky,height:$y,id:by,name:wy,source:Ny,svg:jy,terminals:Ey,viewBox:_y,width:Sy},Symbol.toStringTag,{value:"Module"})),Ay="sync-motor",Ty="同步电动机",My="load",Cy="-62 -82 64 114",Py=64,Iy=114,Oy='<ellipse cx="-30" cy="-30" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><text x="-34" y="-24.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">M</text><line x1="-50" y1="-80" x2="-50" y2="-53" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-53" x2="-10" y2="-80" fill="none" stroke="black" stroke-width="1"/><text x="-45" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="14" fill="#000000">1</text><path d="M -25 -20 A 5 2.5 0 0 0 -35 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -25 -20 A 5 2.5 0 0 0 -15 -20" fill="none" stroke="black" stroke-width="1"/><path d="M -40 10 A 5 5 0 0 0 -50 10" fill="none" stroke="black" stroke-width="1"/><path d="M -30 10 A 5 5 0 0 0 -40 10" fill="none" stroke="black" stroke-width="1"/><path d="M -20 10 A 5 5 0 0 0 -30 10" fill="none" stroke="black" stroke-width="1"/><path d="M -10 10 A 5 5 0 0 0 -20 10" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="10" x2="-50" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="10" x2="-10" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="15" x2="-20" y2="15" fill="none" stroke="black" stroke-width="1"/><line x1="-40" y1="20" x2="-32" y2="20" fill="none" stroke="black" stroke-width="1"/><line x1="-27" y1="20" x2="-20" y2="20" fill="none" stroke="black" stroke-width="1"/>',By=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],Dy={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},$$={id:Ay,name:Ty,category:My,viewBox:Cy,width:Py,height:Iy,svg:Oy,terminals:By,source:Dy},j$=Object.freeze(Object.defineProperty({__proto__:null,category:My,default:$$,height:Iy,id:Ay,name:Ty,source:Dy,svg:Oy,terminals:By,viewBox:Cy,width:Py},Symbol.toStringTag,{value:"Module"})),Ly="synchronoscope",zy="同步表",Ry="measurement",Fy="同步指示器 / 同步表。",Hy="-22 -42 44 44",Wy=44,qy=44,Xy='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-5" x2="0" y2="-35" fill="none" stroke="black" stroke-width="1"/><path d="M 12.374 -30.374 A 17.5 17.5 0 0 0 -12.374 -30.374" fill="none" stroke="black" stroke-width="1"/><polygon points="-13,-30 -11,-33 -10,-31" fill="none" stroke="black" stroke-width="1"/><polygon points="11,-33 13,-30 10,-31" fill="none" stroke="black" stroke-width="1"/>',Yy=[{id:"t_top",x:0,y:-40,orientation:"n"}],Gy={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},E$={id:Ly,name:zy,category:Ry,description:Fy,viewBox:Hy,width:Wy,height:qy,svg:Xy,terminals:Yy,source:Gy},N$=Object.freeze(Object.defineProperty({__proto__:null,category:Ry,default:E$,description:Fy,height:qy,id:Ly,name:zy,source:Gy,svg:Xy,terminals:Yy,viewBox:Hy,width:Wy},Symbol.toStringTag,{value:"Module"})),Ky="terminal",Uy="接线端子 / 节点 (X)",Vy="busbar",Jy="接线端子 / 接线盒 / 汇接节点。",Zy="-5 -5 10 10",Qy=10,ex=10,tx='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',nx=[{id:"t_top",x:0,y:-2.5,orientation:"n"},{id:"t_bottom",x:0,y:2.5,orientation:"s"},{id:"t_left",x:-2.5,y:0,orientation:"w"},{id:"t_right",x:2.5,y:0,orientation:"e"}],ox={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},A$={id:Ky,name:Uy,category:Vy,description:Jy,viewBox:Zy,width:Qy,height:ex,svg:tx,terminals:nx,source:ox},T$=Object.freeze(Object.defineProperty({__proto__:null,category:Vy,default:A$,description:Jy,height:ex,id:Ky,name:Uy,source:ox,svg:tx,terminals:nx,viewBox:Zy,width:Qy},Symbol.toStringTag,{value:"Module"})),rx="thermal-overload",sx="热过载继电器",ix="motor-control",ax="电机热过载保护继电器, 通常串接在接触器和电机之间。",lx="-9 -32 19 64",cx=19,dx=64,ux='<line x1="0" y1="-30" x2="0" y2="-15" stroke="black" stroke-width="1" fill="none"/><rect x="-7" y="-15" width="14" height="30" fill="none" stroke="black" stroke-width="1"/><polyline points="-4,-10 -1,-5 -4,0 -1,5 -4,10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',fx=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],hx=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],mx={kind:"inline"},M$={id:rx,name:sx,category:ix,description:ax,viewBox:lx,width:cx,height:dx,svg:ux,terminals:fx,state:hx,source:mx},C$=Object.freeze(Object.defineProperty({__proto__:null,category:ix,default:M$,description:ax,height:dx,id:rx,name:sx,source:mx,state:hx,svg:ux,terminals:fx,viewBox:lx,width:cx},Symbol.toStringTag,{value:"Module"})),px="thermocouple",gx="热电偶 (BT)",yx="measurement",xx="热电偶温度传感器。",bx="-26 -42 52 46",wx=52,vx=46,kx='<ellipse cx="0" cy="0" rx="2" ry="2" fill="black" stroke="black" stroke-width="1"/><polyline points="-10,-40 -10,-15 0,0 10,-15 10,-40" fill="none" stroke="black" stroke-width="1"/><line x1="-24" y1="-16" x2="-16" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="16" y1="-16" x2="24" y2="-16" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-20" x2="20" y2="-12" fill="none" stroke="black" stroke-width="1"/>',_x=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],Sx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},P$={id:px,name:gx,category:yx,description:xx,viewBox:bx,width:wx,height:vx,svg:kx,terminals:_x,source:Sx},I$=Object.freeze(Object.defineProperty({__proto__:null,category:yx,default:P$,description:xx,height:vx,id:px,name:gx,source:Sx,svg:kx,terminals:_x,viewBox:bx,width:wx},Symbol.toStringTag,{value:"Module"})),$x="thyristor",jx="晶闸管 (V)",Ex="passive",Nx="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",Ax="-22 -42 34 44",Tx=34,Mx=44,Cx='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="10" y1="-20" x2="-10" y2="-20" fill="none" stroke="black" stroke-width="1"/><polyline points="-20,0 -7,0 -4,-10" fill="none" stroke="black" stroke-width="1"/>',Px=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ix={x:6,y:-20,anchor:"start"},Ox={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_06.elmt",qetEnglishName:"Reverse blocking triode thyristor, P-gate (cathode-side controlled)"},O$={id:$x,name:jx,category:Ex,description:Nx,viewBox:Ax,width:Tx,height:Mx,svg:Cx,terminals:Px,label:Ix,source:Ox},B$=Object.freeze(Object.defineProperty({__proto__:null,category:Ex,default:O$,description:Nx,height:Mx,id:$x,label:Ix,name:jx,source:Ox,svg:Cx,terminals:Px,viewBox:Ax,width:Tx},Symbol.toStringTag,{value:"Module"})),Bx="time-relay",Dx="时间继电器 (KT)",Lx="control",zx="延时 (缓动) 继电器线圈。",Rx="-32 -22 54 44",Fx=54,Hx=44,Wx='<rect x="-20" y="-10" width="40" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="-10" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="10" x2="0" y2="20" fill="none" stroke="black" stroke-width="1"/><rect x="-30" y="-10" width="10" height="20" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-10" x2="-20" y2="10" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="10" x2="-20" y2="-10" fill="none" stroke="black" stroke-width="1"/>',qx=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Xx={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_15/en_60617_07_15_08.elmt",qetEnglishName:"Relay coil of a slow-operating relay"},D$={id:Bx,name:Dx,category:Lx,description:zx,viewBox:Rx,width:Fx,height:Hx,svg:Wx,terminals:qx,source:Xx},L$=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:D$,description:zx,height:Hx,id:Bx,name:Dx,source:Xx,svg:Wx,terminals:qx,viewBox:Rx,width:Fx},Symbol.toStringTag,{value:"Module"})),Yx="transfer-switch",Gx="切换开关 (ATS)",Kx="switching",Ux="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",Vx="-27 -32 51 64",Jx=51,Zx=64,Qx='<line x1="-15" y1="-30" x2="-15" y2="-12" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-30" x2="15" y2="-12" stroke="black" stroke-width="1" fill="none"/><text x="-25" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">N</text><text x="19" y="-20" font-family="Liberation Sans, Arial, sans-serif" font-size="6" fill="#000000">E</text><circle cx="-15" cy="-10" r="1.5" fill="black"/><circle cx="15" cy="-10" r="1.5" fill="black"/><circle cx="0" cy="6" r="1.5" fill="black"/><line x1="-15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="1" fill="none"/><line x1="15" y1="-10" x2="0" y2="6" stroke="black" stroke-width="0.6" fill="none" stroke-dasharray="2 1.5"/><line x1="0" y1="6" x2="0" y2="30" stroke="black" stroke-width="1" fill="none"/>',eb=[{id:"t_normal",x:-15,y:-30,orientation:"n"},{id:"t_emergency",x:15,y:-30,orientation:"n"},{id:"t_load",x:0,y:30,orientation:"s"}],tb=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],nb={kind:"inline"},z$={id:Yx,name:Gx,category:Kx,description:Ux,viewBox:Vx,width:Jx,height:Zx,svg:Qx,terminals:eb,state:tb,source:nb},R$=Object.freeze(Object.defineProperty({__proto__:null,category:Kx,default:z$,description:Ux,height:Zx,id:Yx,name:Gx,source:nb,state:tb,svg:Qx,terminals:eb,viewBox:Vx,width:Jx},Symbol.toStringTag,{value:"Module"})),ob="transformer-2w",rb="双绕组变压器",sb="transformer",ib="-62 -142 64 144",ab=64,lb=144,cb='<ellipse cx="-30" cy="-90" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-140" x2="-30" y2="-120" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-30" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-30" y1="-20" x2="-30" y2="0" fill="none" stroke="black" stroke-width="1"/>',db=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],ub=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],fb={x:4,y:-68,anchor:"start"},hb={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_01.elmt",qetEnglishName:"Transformer with two windings, general symbol"},F$={id:ob,name:rb,category:sb,viewBox:ib,width:ab,height:lb,svg:cb,terminals:db,params:ub,label:fb,source:hb},H$=Object.freeze(Object.defineProperty({__proto__:null,category:sb,default:F$,height:lb,id:ob,label:fb,name:rb,params:ub,source:hb,svg:cb,terminals:db,viewBox:ib,width:ab},Symbol.toStringTag,{value:"Module"})),mb="transformer-3w",pb="三绕组变压器",gb="transformer",yb="-82 -131 114 133",xb=114,bb=133,wb='<ellipse cx="-30" cy="-80" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-31" y1="-129" x2="-31" y2="-109" fill="none" stroke="black" stroke-width="1"/><ellipse cx="-50" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-50" rx="30" ry="30" fill="none" stroke="black" stroke-width="1"/><line x1="-50" y1="-20" x2="-50" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-20" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/>',vb=[{id:"t1",x:-31,y:-129,orientation:"n"},{id:"t_low_left",x:-50,y:0,orientation:"s"},{id:"t_low_right",x:0,y:0,orientation:"s"}],kb={x:4,y:-64,anchor:"start"},_b={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_04.elmt",qetEnglishName:"Transformer with three windings, general symbol"},W$={id:mb,name:pb,category:gb,viewBox:yb,width:xb,height:bb,svg:wb,terminals:vb,label:kb,source:_b},q$=Object.freeze(Object.defineProperty({__proto__:null,category:gb,default:W$,height:bb,id:mb,label:kb,name:pb,source:_b,svg:wb,terminals:vb,viewBox:yb,width:xb},Symbol.toStringTag,{value:"Module"})),Sb="triac",$b="双向晶闸管 (V)",jb="passive",Eb="双向三极晶闸管 (TRIAC)。",Nb="-22 -42 44 44",Ab=44,Tb=44,Mb='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-20" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-20,-30 0,-30 -10,-10" fill="none" stroke="black" stroke-width="1"/><line x1="20" y1="-30" x2="-10" y2="-30" fill="none" stroke="black" stroke-width="1"/><polygon points="0,-10 10,-30 20,-10" fill="none" stroke="black" stroke-width="1"/><polyline points="20,0 18,0 14,-10" fill="none" stroke="black" stroke-width="1"/>',Cb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Pb={x:6,y:-20,anchor:"start"},Ib={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},X$={id:Sb,name:$b,category:jb,description:Eb,viewBox:Nb,width:Ab,height:Tb,svg:Mb,terminals:Cb,label:Pb,source:Ib},Y$=Object.freeze(Object.defineProperty({__proto__:null,category:jb,default:X$,description:Eb,height:Tb,id:Sb,label:Pb,name:$b,source:Ib,svg:Mb,terminals:Cb,viewBox:Nb,width:Ab},Symbol.toStringTag,{value:"Module"})),Ob="undervoltage-relay",Bb="欠压继电器 (27)",Db="protection",Lb="欠电压保护继电器 (ANSI 27)。",zb="-62 -82 64 84",Rb=64,Fb=84,Hb='<rect x="-60" y="-80" width="60" height="80" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-49" y="-7.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">130 %</text><text x="-55" y="-32.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">50...80 V</text><text x="-41" y="-53.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">U &lt;</text>',Wb=[{id:"t_top",x:-30,y:-80,orientation:"n"}],qb={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},G$={id:Ob,name:Bb,category:Db,description:Lb,viewBox:zb,width:Rb,height:Fb,svg:Hb,terminals:Wb,source:qb},K$=Object.freeze(Object.defineProperty({__proto__:null,category:Db,default:G$,description:Lb,height:Fb,id:Ob,name:Bb,source:qb,svg:Hb,terminals:Wb,viewBox:zb,width:Rb},Symbol.toStringTag,{value:"Module"})),Xb="ups",Yb="不间断电源 (UPS)",Gb="source",Kb="在线 / 后备式不间断电源。",Ub="-26 -42 52 84",Vb=52,Jb=84,Zb='<rect x="-24" y="-20" width="48" height="40" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="11" fill="#000000">UPS</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',Qb=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],ew=[{name:"S",label:"容量",type:"number",unit:"kVA"}],tw={kind:"inline"},U$={id:Xb,name:Yb,category:Gb,description:Kb,viewBox:Ub,width:Vb,height:Jb,svg:Zb,terminals:Qb,params:ew,source:tw},V$=Object.freeze(Object.defineProperty({__proto__:null,category:Gb,default:U$,description:Kb,height:Jb,id:Xb,name:Yb,params:ew,source:tw,svg:Zb,terminals:Qb,viewBox:Ub,width:Vb},Symbol.toStringTag,{value:"Module"})),nw="varmeter",ow="无功功率表 (var)",rw="measurement",sw="无功功率表 (var)。",iw="-22 -42 44 44",aw=44,lw=44,cw='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-8" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">var</text>',dw=[{id:"t_top",x:0,y:-40,orientation:"n"}],uw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},J$={id:nw,name:ow,category:rw,description:sw,viewBox:iw,width:aw,height:lw,svg:cw,terminals:dw,source:uw},Z$=Object.freeze(Object.defineProperty({__proto__:null,category:rw,default:J$,description:sw,height:lw,id:nw,name:ow,source:uw,svg:cw,terminals:dw,viewBox:iw,width:aw},Symbol.toStringTag,{value:"Module"})),fw="vfd",hw="变频器 (VFD)",mw="motor-control",pw="Variable Frequency Drive — 异步电动机调速。",gw="-24 -42 48 84",yw=48,xw=84,bw='<rect x="-22" y="-20" width="44" height="40" fill="none" stroke="black" stroke-width="1"/><line x1="-22" y1="20" x2="22" y2="-20" stroke="black" stroke-width="1" fill="none"/><text x="-15" y="-5" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~</text><text x="6" y="14" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">~f</text><line x1="0" y1="-40" x2="0" y2="-20" stroke="black" stroke-width="1" fill="none"/><line x1="0" y1="20" x2="0" y2="40" stroke="black" stroke-width="1" fill="none"/>',ww=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],vw={kind:"inline"},Q$={id:fw,name:hw,category:mw,description:pw,viewBox:gw,width:yw,height:xw,svg:bw,terminals:ww,source:vw},ej=Object.freeze(Object.defineProperty({__proto__:null,category:mw,default:Q$,description:pw,height:xw,id:fw,name:hw,source:vw,svg:bw,terminals:ww,viewBox:gw,width:yw},Symbol.toStringTag,{value:"Module"})),kw="voltage-regulator",_w="调压器 (T)",Sw="transformer",$w="可调感应调压器 / 自耦调压器。",jw="-17 -32 38 64",Ew=38,Nw=64,Aw='<line x1="-5" y1="21" x2="5" y2="17" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-16.05" x2="4.95" y2="-20.05" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="-5" rx="10" ry="10" fill="none" stroke="black" stroke-width="1"/><ellipse cx="0" cy="0" rx="15" ry="15" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-20.05" x2="4.95" y2="-24.05" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="23" x2="5" y2="19" fill="none" stroke="black" stroke-width="1"/><line x1="-5.05" y1="-18.05" x2="4.95" y2="-22.05" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-30" x2="0" y2="-15" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="15" x2="0" y2="30" fill="none" stroke="black" stroke-width="1"/><line x1="-5" y1="25" x2="5" y2="21" fill="none" stroke="black" stroke-width="1"/><line x1="-15" y1="15" x2="15" y2="-15" fill="none" stroke="black" stroke-width="1"/><polygon points="13,-16 16,-13 19,-19" fill="black" stroke="black" stroke-width="0.4"/>',Tw=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Mw=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],Cw={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},tj={id:kw,name:_w,category:Sw,description:$w,viewBox:jw,width:Ew,height:Nw,svg:Aw,terminals:Tw,params:Mw,source:Cw},nj=Object.freeze(Object.defineProperty({__proto__:null,category:Sw,default:tj,description:$w,height:Nw,id:kw,name:_w,params:Mw,source:Cw,svg:Aw,terminals:Tw,viewBox:jw,width:Ew},Symbol.toStringTag,{value:"Module"})),Pw="voltmeter",Iw="电压表 (V)",Ow="measurement",Bw="-22 -42 44 44",Dw=44,Lw=44,zw='<ellipse cx="0" cy="-20" rx="20" ry="20" fill="none" stroke="black" stroke-width="1"/><text x="-4" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">V</text>',Rw=[{id:"t_top",x:0,y:-40,orientation:"n"}],Fw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},oj={id:Pw,name:Iw,category:Ow,viewBox:Bw,width:Dw,height:Lw,svg:zw,terminals:Rw,source:Fw},rj=Object.freeze(Object.defineProperty({__proto__:null,category:Ow,default:oj,height:Lw,id:Pw,name:Iw,source:Fw,svg:zw,terminals:Rw,viewBox:Bw,width:Dw},Symbol.toStringTag,{value:"Module"})),Hw="wattmeter",Ww="功率表 (W)",qw="measurement",Xw="-22 -42 44 44",Yw=44,Gw=44,Kw='<rect x="-20" y="-40" width="40" height="40" rx="0" ry="0" fill="none" stroke="black" stroke-width="1"/><text x="-6" y="-8.8" font-family="Liberation Sans, Arial, sans-serif" font-size="9" fill="#000000">W</text>',Uw=[{id:"t_top",x:0,y:-40,orientation:"n"}],Vw={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},sj={id:Hw,name:Ww,category:qw,viewBox:Xw,width:Yw,height:Gw,svg:Kw,terminals:Uw,source:Vw},ij=Object.freeze(Object.defineProperty({__proto__:null,category:qw,default:sj,height:Gw,id:Hw,name:Ww,source:Vw,svg:Kw,terminals:Uw,viewBox:Xw,width:Yw},Symbol.toStringTag,{value:"Module"})),Jw="wind-turbine",Zw="风力发电机",Qw="renewable",ev="风机:发电机 + 三叶轮标记",tv="-22 -46 44 68",nv=44,ov=68,rv='<circle cx="0" cy="0" r="20" fill="none" stroke="black" stroke-width="1"/><text x="0" y="4" text-anchor="middle" font-family="Liberation Sans, Arial, sans-serif" font-size="16">G</text><line x1="0" y1="-20" x2="0" y2="-32" fill="none" stroke="black" stroke-width="1"/><line x1="0" y1="-32" x2="-10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="10" y2="-39" fill="none" stroke="black" stroke-width="1.5"/><line x1="0" y1="-32" x2="0" y2="-44" fill="none" stroke="black" stroke-width="1.5"/>',sv=[{id:"t_bottom",x:0,y:20,orientation:"s"}],iv={kind:"inline"},aj={id:Jw,name:Zw,category:Qw,description:ev,viewBox:tv,width:nv,height:ov,svg:rv,terminals:sv,source:iv},lj=Object.freeze(Object.defineProperty({__proto__:null,category:Qw,default:aj,description:ev,height:ov,id:Jw,name:Zw,source:iv,svg:rv,terminals:sv,viewBox:tv,width:nv},Symbol.toStringTag,{value:"Module"})),av="zener-diode",lv="稳压二极管 (D)",cv="passive",dv="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",uv="-12 -42 24 44",fv=24,hv=44,mv='<line x1="0" y1="-40" x2="0" y2="0" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-10" x2="10" y2="-10" fill="none" stroke="black" stroke-width="1"/><polygon points="-10,-30 10,-30 0,-10" fill="none" stroke="black" stroke-width="1"/><line x1="-10" y1="-15" x2="-10" y2="-10" fill="none" stroke="black" stroke-width="1"/>',pv=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],gv={x:6,y:-20,anchor:"start"},yv={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_06.elmt",qetEnglishName:"Breakdown diode, unidirectional; Zener diode"},cj={id:av,name:lv,category:cv,description:dv,viewBox:uv,width:fv,height:hv,svg:mv,terminals:pv,label:gv,source:yv},dj=Object.freeze(Object.defineProperty({__proto__:null,category:cv,default:cj,description:dv,height:hv,id:av,label:gv,name:lv,source:yv,svg:mv,terminals:pv,viewBox:uv,width:fv},Symbol.toStringTag,{value:"Module"})),uj=Object.assign({"./ammeter.json":Yk,"./arc-suppression-coil.json":Kk,"./arrester.json":Vk,"./async-motor.json":Zk,"./autotransformer.json":e_,"./battery.json":n_,"./bell.json":r_,"./break-contact.json":i_,"./breaker.json":l_,"./buchholz-relay.json":d_,"./busbar.json":f_,"./buzzer.json":m_,"./capacitor.json":g_,"./contactor.json":x_,"./converter-bidir.json":w_,"./ct.json":k_,"./dc-combiner.json":S_,"./dc-dc-converter.json":j_,"./dc-disconnector.json":N_,"./dc-motor.json":T_,"./diode.json":C_,"./disconnector.json":I_,"./distance-relay.json":B_,"./earth.json":L_,"./earthing-switch.json":R_,"./energy-meter.json":H_,"./ev-charger.json":q_,"./frequency-meter.json":Y_,"./fuse-switch-disconnector.json":K_,"./fuse.json":V_,"./generator.json":Z_,"./genset.json":eS,"./gfci-breaker.json":nS,"./grid-source.json":rS,"./grounding-transformer.json":iS,"./heater.json":lS,"./igbt.json":dS,"./indicator-light.json":fS,"./inductor.json":mS,"./inverter.json":gS,"./limit-switch.json":xS,"./load-switch.json":wS,"./load.json":kS,"./make-contact.json":SS,"./motor-starter.json":jS,"./mppt.json":NS,"./ngr.json":TS,"./overcurrent-relay.json":CS,"./panelboard.json":IS,"./phase-failure-relay.json":BS,"./plc.json":LS,"./power-factor-meter.json":RS,"./power-supply.json":HS,"./protective-relay.json":qS,"./proximity-switch.json":YS,"./pt.json":KS,"./push-button.json":VS,"./pv.json":ZS,"./rcd.json":e$,"./recloser.json":n$,"./rectifier.json":r$,"./relay-coil.json":i$,"./resistor.json":l$,"./reverse-power-relay.json":d$,"./selector-switch.json":f$,"./series-reactor.json":m$,"./shunt-capacitor.json":g$,"./shunt-reactor.json":x$,"./siren.json":w$,"./socket-outlet.json":k$,"./soft-starter.json":S$,"./sync-motor.json":j$,"./synchronoscope.json":N$,"./terminal.json":T$,"./thermal-overload.json":C$,"./thermocouple.json":I$,"./thyristor.json":B$,"./time-relay.json":L$,"./transfer-switch.json":R$,"./transformer-2w.json":H$,"./transformer-3w.json":q$,"./triac.json":Y$,"./undervoltage-relay.json":K$,"./ups.json":V$,"./varmeter.json":Z$,"./vfd.json":ej,"./voltage-regulator.json":nj,"./voltmeter.json":rj,"./wattmeter.json":ij,"./wind-turbine.json":lj,"./zener-diode.json":dj}),xv=Object.values(uj).map(e=>e.default),ot=Object.fromEntries(xv.map(e=>[e.id,e])),vr=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],fj=(()=>{var t;const e={};for(const n of xv)(e[t=n.category]??(e[t]=[])).push(n);return e})(),ao=new Map(Object.entries(ot));function bv(e){return ot[e]}function hj(e){const n=[...e].sort().join("|");let o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return`n_${(o>>>0).toString(36)}`}const mj=320;function et(e){var v,M,I,F,G;const t=Gs(),n=new Map;e.elements.forEach(($,H)=>{if(n.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/elements/${H}`});return}n.set($.id,$);const W=ao.get($.kind);W||t.diagnostics.push({code:"E003",severity:"error",message:`${ve("compile.unknownKind",{kind:$.kind})} (id=${$.id})`,pointer:`/elements/${H}`}),t.elements.set($.id,{element:$,libraryDef:W})});const o=new Map,r=new Map;(e.buses??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/buses/${H}`});return}if(o.set($.id,$),$.layout){const W=$.layout.rot??0;r.set($.id,{at:$.layout.at,span:$.layout.span,rot:W,axis:so(W)})}});const s=new Map;(e.junctions??[]).forEach(($,H)=>{if(n.has($.id)||o.has($.id)||s.has($.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:$.id}),pointer:`/junctions/${H}`});return}s.set($.id,$)});const i=$=>!$.includes(".")&&o.has($),a=$=>!$.includes(".")&&s.has($),l=($,H)=>{if(i($)||a($))return!0;const W=$.indexOf(".");if(W<=0)return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.invalidTermRef",{ref:$}),pointer:H}),!1;const X=$.slice(0,W),P=$.slice(W+1),R=t.elements.get(X);if(!R)return t.diagnostics.push({code:"E002",severity:"error",message:ve("compile.elementMissing",{id:X}),pointer:H}),!1;if(!R.libraryDef)return!1;if(!R.libraryDef.terminals.find(Z=>Z.id===P)){const Z=R.libraryDef.terminals.map(ie=>ie.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.missingPin",{id:X,kind:R.element.kind,pin:P,available:Z}),pointer:H}),!1}return!0},c=[];(e.wires??[]).forEach(($,H)=>{const W=`/wires/${H}`,X=l($.ends[0],W),P=l($.ends[1],W);X&&P&&c.push($)});const u=new Map;if(e.layout)for(const[$,H]of Object.entries(e.layout))t.elements.has($)?u.set($,Ks(H)):t.diagnostics.push({code:"E004",severity:"error",message:ve("compile.layoutMissingElement",{id:$}),pointer:`/layout/${$}`});const f=Wk({elements:e.elements,buses:e.buses??[],junctions:e.junctions??[],wires:c,library:ao,userLayout:u,userBusLayout:r});t.layout=f.devices;for(const[$,H]of f.buses){const W=o.get($);W&&t.buses.set($,{bus:W,geometry:H})}for(const[$,H]of o)t.buses.has($)||t.buses.set($,{bus:H,geometry:{at:((v=H.layout)==null?void 0:v.at)??[0,0],span:((M=H.layout)==null?void 0:M.span)??mj,rot:((I=H.layout)==null?void 0:I.rot)??0,axis:so(((F=H.layout)==null?void 0:F.rot)??0)}});for(const $ of t.elements.values()){if(!$.libraryDef)continue;const H=t.layout.get($.element.id);if(!H)continue;const W=[];for(const X of $.libraryDef.terminals){const P=`${$.element.id}.${X.id}`,R=Ie([X.x,X.y],H),Z=Ot(X.orientation,H);t.terminals.set(P,{ref:P,elementId:$.element.id,pin:X.id,world:R,orientation:Z}),W.push(P)}t.elementToTerminals.set($.element.id,W)}const h=new Map,g=new Set;for(const[$,H]of s)(G=H.layout)!=null&&G.at?(h.set($,[H.layout.at[0],H.layout.at[1]]),g.add($)):f.junctions.has($)&&(h.set($,f.junctions.get($)),g.add($));const m=$=>{if(!$.includes(".")){const W=t.buses.get($);return W?W.geometry.at:h.get($)??null}const H=t.terminals.get($);return H?H.world:null},p=new Map;for(const[$]of s)g.has($)||p.set($,[]);for(const $ of c){const[H,W]=$.ends;p.has(H)&&p.get(H).push(W),p.has(W)&&p.get(W).push(H)}for(let $=0;$<12;$++){let H=!1;for(const[W,X]of p){let P=0,R=0,Z=0;for(const ae of X){const me=m(ae);me&&(P+=me[0],R+=me[1],Z++)}if(!Z)continue;const ie=P/Z,ue=R/Z,ee=h.get(W);(!ee||Math.abs(ee[0]-ie)>.01||Math.abs(ee[1]-ue)>.01)&&(h.set(W,[ie,ue]),H=!0)}if(!H)break}const x=new Map;for(const[$]of s)x.set($,0);for(const $ of c)for(const H of $.ends){const W=x.get(H);W!==void 0&&x.set(H,W+1)}for(const[$,H]of s)t.junctions.set($,{junction:H,world:h.get($)??[0,0],degree:x.get($)??0});const w=new Us;for(const $ of c)w.add($.ends[0]),w.add($.ends[1]),w.union($.ends[0],$.ends[1]);for(const[,$]of w.groups()){const H=hj($);t.nodes.set(H,{id:H,terminals:$});for(const W of $)t.terminalToNode.set(W,H)}for(const $ of t.elements.values()){const H=t.elementToTerminals.get($.element.id)??[];if(H.length===0)continue;H.some(X=>t.terminalToNode.has(X))||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$.element.id})})}for(const $ of t.buses.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of t.junctions.keys())t.terminalToNode.has($)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:$})});for(const $ of c){if($.path&&$.path.length>=2){const W=$.path,X=W.length>=2?W[1]:null,P=W.length>=2?W[W.length-2]:null,R=br($.ends[0],X,t),Z=br($.ends[1],P,t);if(R&&Z){const ie=[[R[0],R[1]],...W.slice(1,-1).map(ee=>[ee[0],ee[1]]),[Z[0],Z[1]]],ue=Ys(ie);if(ue.length>=2){t.wireRenders.set($.id,{wireId:$.id,path:ue,userEdited:!0,...$.label?{label:$.label}:{}});continue}}}const H=qk($,t);H&&t.wireRenders.set($.id,$.label?{...H,label:$.label}:H)}return t}const pj={earth:"GND",breaker:"QF",disconnector:"QS","earthing-switch":"QE","load-switch":"QL",fuse:"FU","transformer-2w":"T","transformer-3w":"T",autotransformer:"AT",ct:"CT",pt:"PT",generator:"G","sync-motor":"M","async-motor":"M","grid-source":"L",load:"L",battery:"BAT","shunt-reactor":"LR","series-reactor":"LR","shunt-capacitor":"C",arrester:"FBL","grounding-transformer":"TG",ngr:"NGR","arc-suppression-coil":"ASC",pv:"PV","wind-turbine":"WT",rectifier:"RT",inverter:"INV","converter-bidir":"PCS"},kr="B",_r="J";function Ao(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function Rt(e,t){const n=pj[t]??t,o=Ao(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function lo(e){const t=Ao(e);let n=1;for(;t.has(`${kr}${n}`);)n++;return`${kr}${n}`}function co(e){const t=Ao(e);let n=1;for(;t.has(`${_r}${n}`);)n++;return`${_r}${n}`}function hn(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function at(e,t){const n=[e,t].sort(),o=`${n[0]}|${n[1]}`;let r=2166136261;for(let s=0;s<o.length;s++)r^=o.charCodeAt(s),r=Math.imul(r,16777619);return`w_${(r>>>0).toString(36)}`}function Wn(e,t,n){if(n.length===0)return n;const o=new Set(n.map(a=>a.id)),r=new Set(t.map(a=>a.id)),s=new Set;for(const a of e)if(!r.has(a.id))for(const l of a.ends)o.has(l)&&s.add(l);if(s.size===0)return n;const i=new Set;for(const a of t)for(const l of a.ends)s.has(l)&&i.add(l);return n.filter(a=>!s.has(a.id)||i.has(a.id))}const Sr={version:"1",elements:[]},gj=100,qn=20;function yj(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const y=$n()(Bk((e,t)=>({diagram:Sr,internal:et(Sr),fileSession:null,activeTool:yj(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,readOnly:!1,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:et(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),setReadOnly:n=>e({readOnly:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:et(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,annotationDraft:null,annotationPreview:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=gj?r.slice(1):r;e({diagram:s,internal:et(s),past:[...i,o],future:[],annotationPreview:null})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:et(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview:null})},redo:()=>{const{past:n,future:o,diagram:r}=t();if(o.length===0)return;const s=o[o.length-1];e({diagram:s,internal:et(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,annotationPreview:null})},setActiveTool:(n,o)=>{const r=t();let s;(o==null?void 0:o.placeKind)!==void 0?s=o.placeKind:n==="place"?s=r.placeKind??r.lastPlaceKind:s=null,e({activeTool:n,placeKind:s,lastPlaceKind:s??r.lastPlaceKind,wireFromTerminal:n==="wire"?r.wireFromTerminal:null,wireDragFrom:n==="wire"?r.wireDragFrom:null,placeFromTerminal:n==="place"?r.placeFromTerminal:null,annotationDraft:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setWireDragFrom:n=>e({wireDragFrom:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:xj(n),selectedWire:null,selectedNode:null,selectedAnnotation:n.length?null:t().selectedAnnotation}),toggleInSelection:n=>{const o=t().selection;e({selection:o.includes(n)?o.filter(r=>r!==n):[...o,n],selectedWire:null,selectedNode:null,selectedAnnotation:null})},clearSelection:()=>e({selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingCell:null,editingElement:null}),setSelectedWire:n=>e({selectedWire:n,selection:n?[]:t().selection,selectedNode:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedNode:n=>e({selectedNode:n,selection:n?[]:t().selection,selectedWire:null,selectedAnnotation:n?null:t().selectedAnnotation}),setSelectedAnnotation:n=>e({selectedAnnotation:n,selection:n?[]:t().selection,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode,editingAnnotation:n?t().editingAnnotation:null,editingCell:n?t().editingCell:null}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement,editingCell:null}),setEditingCell:n=>e({editingCell:n}),setAnnotationDraft:n=>e({annotationDraft:n}),setAnnotationPreview:n=>e({annotationPreview:n}),setEditingElement:n=>e({editingElement:n,selection:n?[n]:t().selection,editingAnnotation:n?null:t().editingAnnotation,selectedAnnotation:n?null:t().selectedAnnotation,selectedWire:n?null:t().selectedWire,selectedNode:n?null:t().selectedNode}),copySelection:()=>{var g;const{selection:n,selectedAnnotation:o,diagram:r,internal:s}=t();if(n.length===0){if(!o)return;const m=(r.annotations??[]).find(p=>p.id===o);if(!m)return;e({clipboard:{elements:[],buses:[],junctions:[],placements:{},busLayouts:{},wires:[],annotations:[structuredClone(m)]},clipboardPasteIndex:0});return}const i=new Set(n),a=r.elements.filter(m=>i.has(m.id)).map(m=>structuredClone(m)),l=(r.buses??[]).filter(m=>i.has(m.id)).map(m=>structuredClone(m)),c=(r.junctions??[]).filter(m=>i.has(m.id)).map(m=>{var x;const p=structuredClone(m);if(!p.layout){const w=(x=s.junctions.get(m.id))==null?void 0:x.world;w&&(p.layout={at:[w[0],w[1]]})}return p}),u={};for(const m of n)if(i.has(m)&&!s.buses.has(m)){const p=(g=r.layout)==null?void 0:g[m];if(p){u[m]=structuredClone(p);continue}const x=s.layout.get(m);x&&(u[m]=on(x))}const f={};for(const m of n){const p=s.buses.get(m);p&&(f[m]=ut(p.geometry))}const h=(r.wires??[]).filter(m=>m.ends.every(p=>i.has(Xn(p)))).map(m=>structuredClone(m));e({clipboard:{elements:a,buses:l,junctions:c,placements:u,busLayouts:f,wires:h,annotations:[]},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n,selectedAnnotation:o}=t();n.length===0&&!o||(t().copySelection(),n.length===0&&o?t().deleteAnnotation(o):t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n)return;if(n.elements.length===0&&n.buses.length===0&&n.junctions.length===0){const f=n.annotations??[];if(f.length===0)return;const h=o+1,g=qn*h;let m=null;t().dispatch(p=>{let x=p;for(const w of f){const v=hn(x);m=v;const M={...structuredClone(w),id:v,at:[w.at[0]+g,w.at[1]+g]};x={...x,annotations:[...x.annotations??[],M]}}return x}),m&&e({selectedAnnotation:m,selection:[],selectedWire:null,selectedNode:null,clipboardPasteIndex:h});return}const s=o+1,i=qn*s,a=qn*s,l=new Map;let c=r;for(const f of n.elements){const h=Rt(c,f.kind);l.set(f.id,h),c={...c,elements:[...c.elements,{id:h,kind:f.kind}]}}for(const f of n.buses){const h=lo(c);l.set(f.id,h),c={...c,buses:[...c.buses??[],{id:h}]}}for(const f of n.junctions){const h=co(c);l.set(f.id,h),c={...c,junctions:[...c.junctions??[],{id:h}]}}const u=f=>{const h=f.indexOf("."),g=h<0?f:f.slice(0,h),m=l.get(g);return m?h<0?m:`${m}${f.slice(h)}`:f};t().dispatch(f=>{const h=n.elements.map(v=>{const M=structuredClone(v);return M.id=l.get(v.id),M}),g=n.buses.map(v=>{const M=structuredClone(v);M.id=l.get(v.id);const I=n.busLayouts[v.id];return I&&(M.layout={...I,at:[I.at[0]+i,I.at[1]+a]}),M}),m=n.junctions.map(v=>{const M=structuredClone(v);return M.id=l.get(v.id),M.layout&&(M.layout={at:[M.layout.at[0]+i,M.layout.at[1]+a]}),M}),p={...f.layout??{}};for(const[v,M]of l){const I=n.placements[v];I&&(p[M]={...I,at:[I.at[0]+i,I.at[1]+a]})}const x=n.wires.map(v=>{const M=[u(v.ends[0]),u(v.ends[1])];return{id:at(M[0],M[1]),ends:M,...v.label?{label:v.label}:{}}}),w=$r(f.wires??[],x);return{...f,elements:[...f.elements,...h],buses:g.length?[...f.buses??[],...g]:f.buses,junctions:m.length?[...f.junctions??[],...m]:f.junctions,wires:w.length?w:void 0,layout:Object.keys(p).length?p:void 0}}),e({selection:Array.from(l.values()),clipboardPasteIndex:s})},autoArrangeAll:()=>{t().dispatch(n=>{var l;const o=n.layout&&Object.keys(n.layout).length>0,r=(n.buses??[]).some(c=>c.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(c=>{const{layout:u,...f}=c;return f});return{...i,buses:a}})},autoArrangeSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{let s=!1,i=r.layout;if(i){const l={};for(const[c,u]of Object.entries(i)){if(o.has(c)){s=!0;continue}l[c]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(c=>{if(o.has(c.id)&&c.layout){s=!0;const{layout:u,...f}=c;return f}return c});s&&(a=l)}return s?{...r,layout:i,buses:a}:r})},fillUnplacedAll:()=>{const n=t().internal;t().dispatch(o=>{const r=o.layout??{},s={};for(const l of o.elements){if(r[l.id])continue;const c=n.layout.get(l.id);c&&(s[l.id]=on(c))}const i=[];if((o.buses??[]).forEach((l,c)=>{l.layout||n.buses.has(l.id)&&i.push({idx:c,bus:l})}),Object.keys(s).length===0&&i.length===0)return o;let a=o.buses;return i.length>0&&a&&(a=a.map(l=>{const c=n.buses.get(l.id);return!l.layout&&c?{...l,layout:ut(c.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var c;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const f=o.buses.get(u);(c=r.buses)!=null&&c.find(h=>h.id===u&&h.layout)||a.set(u,ut(f.geometry))}else{if(s[u])continue;const f=o.layout.get(u);f&&(i[u]=on(f))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(u=>a.has(u.id)?{...u,layout:a.get(u.id)}:u)),{...r,layout:{...s,...i},buses:l}})},moveElements:n=>{if(n.size===0)return;const o=t().internal;t().dispatch(r=>{const s={...r.layout??{}},i=new Map,a=new Map;for(const[u,f]of n){if(o.buses.has(u)){i.set(u,f);continue}if(o.junctions.has(u)){a.set(u,f);continue}const h=o.layout.get(u),g=s[u]??(h?on(h):{at:[0,0]});s[u]={...g,at:[g.at[0]+f[0],g.at[1]+f[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(u=>{const f=i.get(u.id);if(!f)return u;const h=u.layout??ut(o.buses.get(u.id).geometry);return{...u,layout:{...h,at:[h.at[0]+f[0],h.at[1]+f[1]]}}}));let c=r.junctions;return a.size>0&&(c=(r.junctions??[]).map(u=>{var g,m;const f=a.get(u.id);if(!f)return u;const h=((g=u.layout)==null?void 0:g.at)??((m=o.junctions.get(u.id))==null?void 0:m.world)??[0,0];return{...u,layout:{at:[h[0]+f[0],h[1]+f[1]]}}})),{...r,layout:s,buses:l,junctions:c}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(f=>!o.has(f.id)),i=(r.buses??[]).filter(f=>!o.has(f.id)),a=(r.junctions??[]).filter(f=>!o.has(f.id)),l=(r.wires??[]).filter(f=>!o.has(Xn(f.ends[0]))&&!o.has(Xn(f.ends[1]))),c=Wn(r.wires??[],l,a),u=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([f])=>!o.has(f))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:c.length?c:void 0,wires:l.length?l:void 0,layout:u&&Object.keys(u).length?u:void 0}}),e({selection:[]})},deleteSelectedWire:()=>{const{selectedWire:n,internal:o}=t();if(!n)return;const r=(t().diagram.wires??[]).find(i=>i.id===n),s=new Set;if(r)for(const i of r.ends){const a=i.indexOf(".");a>0&&s.add(i.slice(0,a))}t().dispatch(i=>{const a=i.wires??[],l=a.filter(f=>f.id!==n);if(l.length===a.length)return i;const c={...i.layout??{}};for(const f of s){if(c[f])continue;const h=o.layout.get(f);if(!h)continue;const g={at:h.at};h.rot&&(g.rot=h.rot),h.mirror&&(g.mirror=h.mirror),c[f]=g}const u=Wn(a,l,i.junctions??[]);return{...i,wires:l.length?l:void 0,junctions:u.length?u:void 0,layout:Object.keys(c).length?c:void 0}}),e({selectedWire:null})},deleteSelectedNode:()=>{const{selectedNode:n,internal:o}=t();if(!n)return;const r=o.nodes.get(n);if(!r)return;const s=new Set(r.terminals),i=new Set;for(const a of r.terminals){const l=a.indexOf(".");l>0&&i.add(a.slice(0,l))}t().dispatch(a=>{const l={...a.layout??{}};for(const h of i){if(l[h])continue;const g=o.layout.get(h);if(!g)continue;const m={at:g.at};g.rot&&(m.rot=g.rot),g.mirror&&(m.mirror=g.mirror),l[h]=m}const c=a.wires??[],u=c.filter(h=>!s.has(h.ends[0])&&!s.has(h.ends[1])),f=Wn(c,u,a.junctions??[]);return{...a,wires:u.length?u:void 0,junctions:f.length?f:void 0,layout:Object.keys(l).length?l:void 0}}),e({selectedNode:null})},rotateSelection:n=>{const{selection:o,internal:r}=t();o.length!==0&&t().dispatch(s=>{var c,u,f,h;const i={...s.layout??{}},a=new Map;for(const g of o){if(r.junctions.has(g))continue;if(r.buses.has(g)){const x=r.buses.get(g),v=(((((f=(u=(c=s.buses)==null?void 0:c.find(M=>M.id===g))==null?void 0:u.layout)==null?void 0:f.rot)??x.geometry.rot??0)+n)%360+360)%360;a.set(g,v);continue}const m=i[g]??{at:((h=r.layout.get(g))==null?void 0:h.at)??[0,0]},p=(((m.rot??0)+n)%360+360)%360;i[g]={...m,rot:p}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(g=>{if(!a.has(g.id))return g;const m=g.layout??ut(r.buses.get(g.id).geometry);return{...g,layout:{...m,rot:a.get(g.id)}}})),{...s,layout:i,buses:l}})},mirrorSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var i;const s={...r.layout??{}};for(const a of n){if(o.buses.has(a)||o.junctions.has(a))continue;const l=s[a]??{at:((i=o.layout.get(a))==null?void 0:i.at)??[0,0]};s[a]={...l,mirror:!(l.mirror??!1)}}return{...r,layout:s}})},addElement:(n,o,r)=>{if(n==="busbar")return t().addBus(o,320);const s=Rt(t().diagram,n);return t().dispatch(i=>{const a={id:s,kind:n,...r??{}};return{...i,elements:[...i.elements,a],layout:{...i.layout??{},[s]:{at:o}}}}),e({selection:[s]}),s},addBus:(n,o,r)=>{const s=lo(t().diagram);return t().dispatch(i=>{const a={id:s,layout:r!==void 0?{at:n,span:o,rot:r}:{at:n,span:o}};return{...i,buses:[...i.buses??[],a]}}),e({selection:[s]}),s},addJunction:n=>{const o=co(t().diagram);return t().dispatch(r=>{const s={id:o,layout:{at:n}};return{...r,junctions:[...r.junctions??[],s]}}),e({selection:[o]}),o},updateJunction:(n,o)=>{t().dispatch(r=>({...r,junctions:(r.junctions??[]).map(s=>s.id===n?{...s,...o}:s)}))},addWire:(n,o)=>{if(n===o)return;const r=at(n,o);t().dispatch(s=>{const i=s.wires??[];return i.some(a=>a.id===r)?s:{...s,wires:[...i,{id:r,ends:[n,o]}]}})},connectWire:(n,o)=>{t().dispatch(r=>{let s=r;const i=new Set([...s.elements.map(m=>m.id),...(s.buses??[]).map(m=>m.id),...(s.junctions??[]).map(m=>m.id)]),a=()=>{let m=1;for(;i.has(`J${m}`);)m++;const p=`J${m}`;return i.add(p),p},l=m=>{const p=a();return s={...s,junctions:[...s.junctions??[],{id:p,layout:{at:m}}]},p},c=m=>{if("end"in m)return m.end;if("junctionAt"in m)return l(m.junctionAt);const p=(s.wires??[]).find(M=>M.id===m.onWire),x=l(m.at);if(!p)return x;const w=(s.wires??[]).filter(M=>M.id!==m.onWire),v=(M,I)=>({id:at(M,I),ends:[M,I],...p.label?{label:p.label}:{}});return s={...s,wires:$r(w,[v(p.ends[0],x),v(x,p.ends[1])])},x},u=c(n),f=c(o);if(u===null||f===null||u===f)return s;const h=at(u,f),g=s.wires??[];return g.some(m=>m.id===h)?s:{...s,wires:[...g,{id:h,ends:[u,f]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(c=>c.id===n))return r;const i=o&&o.length>=2?Ys(o):null,a=i&&i.length>=2?i:null,l=s.map(c=>{if(c.id!==n)return c;if(a)return{...c,path:a};const{path:u,...f}=c;return f});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},updateWire:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];return s.some(i=>i.id===n)?{...r,wires:s.map(i=>i.id===n?{...i,...o}:i)}:r})},updateElement:(n,o)=>{t().dispatch(r=>({...r,elements:r.elements.map(s=>s.id===n?{...s,...o}:s)}))},updatePlacement:(n,o)=>{t().dispatch(r=>{var a;const s=((a=r.layout)==null?void 0:a[n])??t().internal.layout.get(n),i={at:o.at??(s==null?void 0:s.at)??[0,0],...o.rot!==void 0?{rot:o.rot}:s!=null&&s.rot?{rot:s.rot}:{},...o.mirror!==void 0?{mirror:o.mirror}:s!=null&&s.mirror?{mirror:s.mirror}:{}};return{...r,layout:{...r.layout??{},[n]:i}}})},updateBus:(n,o)=>{t().dispatch(r=>{const s=(r.buses??[]).map(i=>{if(i.id!==n)return i;const a=t().internal,l=i.layout??(a.buses.has(n)?ut(a.buses.get(n).geometry):{at:[0,0],span:320}),c={at:o.at??l.at,span:o.span??l.span,...o.rot!==void 0?{rot:o.rot}:l.rot?{rot:l.rot}:{}};return{...i,layout:c}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=hn(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},insertAnnotation:n=>{const o=hn(t().diagram);return t().dispatch(r=>({...r,annotations:[...r.annotations??[],{...n,id:o}]})),o},updateAnnotation:(n,o)=>{t().dispatch(r=>{const s=r.annotations??[];let i=!1;const a=s.map(l=>l.id!==n?l:(i=!0,{...l,...o,id:l.id}));return i?{...r,annotations:a}:r})},deleteAnnotation:n=>{var o;t().dispatch(r=>{const s=r.annotations??[],i=s.filter(a=>a.id!==n);return i.length===s.length?r:{...r,annotations:i.length?i:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null,editingCell:null}),((o=t().annotationPreview)==null?void 0:o.id)===n&&e({annotationPreview:null})}}),{name:"ole-editor",version:2,storage:Xs(()=>({getItem:e=>localStorage.getItem(e),setItem:(e,t)=>{y.getState().readOnly||localStorage.setItem(e,t)},removeItem:e=>localStorage.removeItem(e)})),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=et(e.diagram))}}));function xj(e){return Array.from(new Set(e))}function Xn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function $r(e,t){const n=new Set(e.map(r=>r.id)),o=e.slice();for(const r of t)n.has(r.id)||(n.add(r.id),o.push(r));return o}function on(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function ut(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let wv=null;function jr(e){wv=e}function Xe(){return wv}const yn=10;function vv(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function de(e){return vv()?Math.round(e/yn)*yn:e}function We(e){return[de(e[0]),de(e[1])]}const bj=30,wj=144;function kv(e,t){const n=ot[e],o=y.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=vj(r,t);if(!s){const p=_v(n),x=p?[de(t[0])-p.x,de(t[1])-p.y]:[de(t[0]),de(t[1])];return{newElementId:o.addElement(e,x),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,c=kj(n,l),u=Rt(r,e),f=n.terminals.find(p=>p.id===c),h=l==="x"?t[0]:a[0],g=l==="y"?t[1]:a[1],m=f?[de(h)-f.x,de(g)-f.y]:[de(t[0]),de(t[1])];return o.dispatch(p=>{const x={id:u,kind:e},w={at:m},v=`${u}.${c}`,M={id:at(i,v),ends:[i,v]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],M],layout:{...p.layout??{},[u]:w}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function vj(e,t){const n=y.getState().internal;let o=null;for(const r of e.buses??[]){const s=n.buses.get(r.id);if(!s)continue;const{axis:i,at:a,span:l}=s.geometry;let c;if(i==="x"){const u=a[0]-l/2,f=a[0]+l/2,h=t[0]<u?u-t[0]:t[0]>f?t[0]-f:0,g=Math.abs(t[1]-a[1]);c=Math.sqrt(h*h+g*g)}else{const u=a[1]-l/2,f=a[1]+l/2,h=t[1]<u?u-t[1]:t[1]>f?t[1]-f:0,g=Math.abs(t[0]-a[0]);c=Math.sqrt(g*g+h*h)}c<=bj&&(!o||c<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:c})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function kj(e,t){return e.terminals.length===0?"t":[...e.terminals].sort((o,r)=>t==="x"?o.y-r.y:o.x-r.x)[0].id}function _v(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function Sv(e,t){const n=y.getState().internal;if(!e.includes(".")&&n.buses.has(e)){const r=n.buses.get(e),{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const g=i[0]-a/2,m=i[0]+a/2,p=Math.max(g,Math.min(m,t[0])),x=i[1],w=t[1]>=x?"s":"n";return{ref:e,world:[p,x],orientation:w,isBus:!0,busId:e}}const l=i[1]-a/2,c=i[1]+a/2,u=Math.max(l,Math.min(c,t[1])),f=i[0],h=t[0]>=f?"e":"w";return{ref:e,world:[f,u],orientation:h,isBus:!0,busId:e}}if(!e.includes(".")&&n.junctions.has(e)){const r=n.junctions.get(e),[s,i]=r.world,a=t[0]-s,l=t[1]-i,c=Math.abs(a)>=Math.abs(l)?a>=0?"e":"w":l>=0?"s":"n";return{ref:e,world:[s,i],orientation:c,isBus:!1}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const _j={n:"s",s:"n",e:"w",w:"e"};function $v(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=_j[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Er(i,n,t.world);for(let l=1;l<s.length;l++){const c=s[l],u=Er(c,n,t.world);u<a&&(a=u,i=c)}return i}function Er(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function Sj(e,t,n){const o=ot[e],r=y.getState(),s=r.diagram;if(!o)return null;const i=Sv(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],c=a*a+l*l<=wj,u=[de(n[0]),de(n[1])],f=$v(o,i,u),h=c?i.world:u,g=[de(h[0]-f.x),de(h[1]-f.y)],m=Rt(s,e);return r.dispatch(p=>{const x={id:m,kind:e},w={at:g},v=`${m}.${f.id}`,M=i.isBus&&i.busId?i.busId:t,I={id:at(M,v),ends:[M,v]};return{...p,elements:[...p.elements,x],wires:[...p.wires??[],I],layout:{...p.layout??{},[m]:w}}}),r.setSelection([m]),{newElementId:m,attachedToBus:i.isBus}}const Gt=9,ze=7;function jn(e,t){var s,i;const n=[],o=((s=e.element.name)==null?void 0:s.trim())||e.element.id;if(o&&n.push(o),t!=="all"||!((i=e.libraryDef)!=null&&i.params))return n;const r=e.element.params??{};for(const a of e.libraryDef.params){if(!a.showOnCanvas)continue;const l=r[a.name];l==null||l===""||n.push(`${l}${a.unit??""}`)}return n}function En(e){const t=jv(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+t.h/2+ze/3,anchor:"start"}:{x:0,y:0,anchor:"start"}}function $j(e,t){let n=e.x,o=e.y;switch(t.mirror&&(n=-n),t.rot){case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function Nn(e,t,n,o){const r=$j(e,n),s=e.anchor??"start",i=jv(t.viewBox);let a=e.x-(i?i.x+i.w/2:0),l=e.y-(i?i.y+i.h/2:0);switch(n.mirror&&(a=-a),n.rot){case 90:[a,l]=[-l,a];break;case 180:[a,l]=[-a,-l];break;case 270:[a,l]=[l,-a];break}return Math.abs(a)<1e-6&&Math.abs(l)<1e-6?{world:r,textAnchor:s,dy:0}:Math.abs(a)>=Math.abs(l)?{world:r,textAnchor:a>=0?"start":"end",dy:0}:l>0?{world:r,textAnchor:"middle",dy:ze}:{world:r,textAnchor:"middle",dy:-(o-1)*Gt}}function jv(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}const Nr=8;function An(e){if(e.length<2)return null;let t=-1,n=0;for(let c=0;c<e.length-1;c++){const u=Math.hypot(e[c+1][0]-e[c][0],e[c+1][1]-e[c][1]);u>n&&(n=u,t=c)}if(t<0||n<=0)return null;const[o,r]=e[t],[s,i]=e[t+1],a=(o+s)/2,l=(r+i)/2;return Math.abs(s-o)>=Math.abs(i-r)?{world:[a,l-Nr],textAnchor:"middle"}:{world:[a+Nr,l+ze/3],textAnchor:"start"}}function jj(){const e=y(s=>s.internal.elements),t=y(s=>s.internal.layout),n=y(s=>s.internal.wireRenders),o=y(s=>{var i;return((i=s.diagram.meta)==null?void 0:i.labelMode)??"all"}),r=y(s=>s.editingElement);return d.jsxs("g",{className:"ole-annotation-layer",pointerEvents:"none",children:[Array.from(e.values()).map(s=>{var h;const i=t.get(s.element.id);if(!i||!s.libraryDef)return null;const a=s.libraryDef.label??En(s.libraryDef),l=jn(s,o),{world:c,textAnchor:u,dy:f}=Nn(a,s.libraryDef,i,Math.max(1,l.length));return r===s.element.id?d.jsx(Ej,{elementId:s.element.id,currentName:((h=s.element.name)==null?void 0:h.trim())||s.element.id,world:c,anchor:u},s.element.id):o==="off"||l.length===0?null:d.jsx("g",{className:"ole-annotation",transform:`translate(${c[0]} ${c[1]})`,children:l.map((g,m)=>d.jsx("text",{x:0,y:f+m*Gt,textAnchor:u,className:"ole-annotation-text",children:g},m))},s.element.id)}),o!=="off"&&Array.from(n.values()).map(s=>{var l;const i=(l=s.label)==null?void 0:l.trim();if(!i)return null;const a=An(s.path);return a?d.jsx("text",{x:a.world[0],y:a.world[1],textAnchor:a.textAnchor,className:"ole-annotation-text",children:i},`wire-${s.wireId}`):null})]})}const Yn=200,Gn=9;function Ej({elementId:e,currentName:t,world:n,anchor:o}){const r=C.useRef(null);C.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const c=document.createRange();c.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(c)},[e]);function s(){var h;const l=y.getState(),c=l.diagram.elements.find(g=>g.id===e);if(!c){l.setEditingElement(null);return}const u=(((h=r.current)==null?void 0:h.innerText)??"").replace(/\u00a0/g," ").trim(),f=u===""||u===e?void 0:u;f!==c.name&&l.updateElement(e,{name:f}),l.setEditingElement(null)}function i(l){if(l.key==="Escape"||l.key==="Enter"&&!l.shiftKey){l.preventDefault(),s();return}l.stopPropagation()}let a=n[0];return o==="middle"?a-=Yn/2:o==="end"&&(a-=Yn),d.jsx("foreignObject",{x:a,y:n[1]-Gn,width:Yn,height:Gn*2.2,className:"ole-element-name-editor",children:d.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${Gn}px`,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",display:"inline-block",minWidth:"20px",lineHeight:1.1,textAlign:o==="middle"?"center":o==="end"?"right":"left",whiteSpace:"nowrap",cursor:"text"},children:t})})}function De(e){return e.type??"text"}function Nj(e){return e.type===void 0||e.type==="text"}const qe=8,Aj=1.25,Kt="6 4",Tj=.05,Ar=8,rn=3,gt=4,Ft=3,Ht=60,Wt=20,uo=16,fo=12,xn=10,Mj=10;function Cj(e,t){const n=e===""?[""]:e.split(`
218
+ `);return[Math.max(20,...n.map(r=>r.length*t*.55)),n.length*t*Aj]}function Ut(e){return e.points.map(([t,n])=>[e.at[0]+t,e.at[1]+n])}function To(e,t){if(!t||t==="none"||e.length<2)return[];const n=[];return(t==="end"||t==="both")&&n.push(Tr(e[e.length-2],e[e.length-1])),t==="both"&&n.push(Tr(e[1],e[0])),n}function Tr(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o)||1,s=n/r,i=o/r,a=t[0]-s*Ar,l=t[1]-i*Ar,c=-i,u=s;return[t,[a+c*rn,l+u*rn],[a-c*rn,l-u*rn]]}function Ge(e){return[Cr(e.colWidths),Cr(e.rowHeights)]}function wt(e){return Ev(e.colWidths)}function vt(e){return Ev(e.rowHeights)}function Pj(e,t){const n=t[0]-e.at[0],o=t[1]-e.at[1],[r,s]=Ge(e);if(n<0||o<0||n>r||o>s)return null;const i=Mr(wt(e),n),a=Mr(vt(e),o);return i===null||a===null?null:[a,i]}function Mr(e,t){for(let n=0;n<e.length-1;n++)if(t>=e[n]&&t<=e[n+1])return n;return null}function Ev(e){const t=[0];let n=0;for(const o of e)n+=o,t.push(n);return t}function Cr(e){return e.reduce((t,n)=>t+n,0)}function Nv(e){let t=e.current[0]-e.start[0],n=e.current[1]-e.start[1];if(e.constrain){const r=Math.max(Math.abs(t),Math.abs(n));t=Math.sign(t||1)*r,n=Math.sign(n||1)*r}return{at:[Math.min(e.start[0],e.start[0]+t),Math.min(e.start[1],e.start[1]+n)],size:[Math.abs(t),Math.abs(n)]}}function Av(e){return e.constrain?Tv(e.start,e.current):e.current}function Tv(e,t){const n=t[0]-e[0],o=t[1]-e[1],r=Math.hypot(n,o);if(r===0)return t;const s=Math.PI/4,i=Math.round(Math.atan2(o,n)/s)*s;return[e[0]+Math.cos(i)*r,e[1]+Math.sin(i)*r]}function Mv(e){const t=Math.abs(e.current[0]-e.start[0]),n=Math.abs(e.current[1]-e.start[1]),o=Math.min(30,Math.max(1,Math.round(t/Ht))),r=Math.min(60,Math.max(1,Math.round(n/Wt)));return{at:[Math.min(e.start[0],e.current[0]),Math.min(e.start[1],e.current[1])],cols:o,rows:r}}function Cv(e,t){return{colWidths:Array.from({length:e},()=>Ht),rowHeights:Array.from({length:t},()=>Wt),cells:Array.from({length:t},()=>Array.from({length:e},()=>""))}}function Ij(e){switch(e.type){case"rect":{const t=e;return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+t.size[0],maxY:t.at[1]+t.size[1]}}case"line":{const t=Ut(e),n=t.map(r=>r[0]),o=t.map(r=>r[1]);return{minX:Math.min(...n),minY:Math.min(...o),maxX:Math.max(...n),maxY:Math.max(...o)}}case"table":{const t=e,[n,o]=Ge(t);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+n,maxY:t.at[1]+o}}default:{const t=e,n=t.fontSize??qe,[o,r]=Cj(t.text,n);return{minX:t.at[0],minY:t.at[1],maxX:t.at[0]+o,maxY:t.at[1]+r}}}}const yt=qe,bn=1.25;function Oj(){const e=y(s=>s.diagram.annotations),t=y(s=>s.selectedAnnotation),n=y(s=>s.editingAnnotation),o=y(s=>s.editingCell),r=y(s=>s.annotationPreview);return!e||e.length===0?null:d.jsx("g",{className:"ole-free-annotation-layer",children:e.map(s=>{const i=(r==null?void 0:r.id)===s.id?r:s,a=t===s.id;switch(De(i)){case"rect":return d.jsx(Bj,{ann:i,isSelected:a},s.id);case"line":return d.jsx(Dj,{ann:i,isSelected:a},s.id);case"table":return d.jsx(Lj,{ann:i,isSelected:a,editingCell:n===s.id?o:null},s.id);default:return n===s.id?d.jsx(Fj,{ann:i},s.id):d.jsx(Rj,{ann:i,isSelected:a},s.id)}})})}function Bj({ann:e,isSelected:t}){const[n,o]=e.at,[r,s]=e.size,i=(e.stroke??"dashed")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-rect","data-selected":t?"true":void 0,children:[e.fill==="tint"&&d.jsx("rect",{className:"ole-ann-fill",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-shape-hit",x:n,y:o,width:r,height:s}),d.jsx("rect",{className:"ole-ann-rect-border",x:n,y:o,width:r,height:s,strokeDasharray:i}),e.label&&d.jsx("text",{className:"ole-ann-label",x:n+gt,y:o+gt+yt*.85,fontSize:yt,children:e.label})]})}function Dj({ann:e,isSelected:t}){const n=Ut(e),o=n.map(s=>`${s[0]},${s[1]}`).join(" "),r=(e.stroke??"solid")==="dashed"?Kt:void 0;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-line-group","data-selected":t?"true":void 0,children:[d.jsx("polyline",{className:"ole-ann-shape-hit",points:o}),d.jsx("polyline",{className:"ole-ann-line",points:o,strokeDasharray:r}),To(n,e.arrow).map((s,i)=>d.jsx("polygon",{className:"ole-ann-arrow",points:s.map(a=>`${a[0]},${a[1]}`).join(" ")},i))]})}function Lj({ann:e,isSelected:t,editingCell:n}){var g;const[o,r]=e.at,[s,i]=Ge(e),a=wt(e),l=vt(e),c=e.fontSize??yt;let u="";for(let m=1;m<e.colWidths.length;m++)u+=`M${o+a[m]} ${r}V${r+i}`;for(let m=1;m<e.rowHeights.length;m++)u+=`M${o} ${r+l[m]}H${o+s}`;const f=[],h=[];for(let m=0;m<e.rowHeights.length;m++)for(let p=0;p<e.colWidths.length;p++){const x=((g=e.cells[m])==null?void 0:g[p])??"";if(x==="")continue;const w=e.colWidths[p],v=o+a[p]+Ft,M=r+l[m]+e.rowHeights[m]/2+c*.35,I=x.length*c*.55>w-2*Ft,F=`ole-ann-clip-${e.id}-${m}-${p}`;I&&h.push(d.jsx("clipPath",{id:F,children:d.jsx("rect",{x:o+a[p],y:r+l[m],width:w,height:e.rowHeights[m]})},F)),f.push(d.jsx("text",{className:"ole-ann-table-text",x:v,y:M,fontSize:c,clipPath:I?`url(#${F})`:void 0,children:x},`${m}-${p}`))}return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-ann ole-ann-table","data-selected":t?"true":void 0,children:[h.length>0&&d.jsx("defs",{children:h}),d.jsx("rect",{className:"ole-ann-table-bg",x:o,y:r,width:s,height:i}),u&&d.jsx("path",{className:"ole-ann-table-grid",d:u}),d.jsx("rect",{className:"ole-ann-table-border",x:o,y:r,width:s,height:i}),f,n&&d.jsx(zj,{ann:e,cell:n})]})}function zj({ann:e,cell:t}){var g;const[n,o]=t,r=C.useRef(null),s=wt(e),i=vt(e),a=e.fontSize??yt,l=((g=e.cells[n])==null?void 0:g[o])??"";C.useEffect(()=>{const m=r.current;m&&(m.focus(),m.select())},[n,o]);function c(){var x;const m=y.getState(),p=((x=r.current)==null?void 0:x.value)??"";if(p!==l){const w=e.cells.map(v=>[...v]);for(;w.length<=n;)w.push([]);w[n][o]=p,m.updateAnnotation(e.id,{cells:w})}}function u(){y.getState().setEditingAnnotation(null)}function f(m,p){const x=e.rowHeights.length,w=e.colWidths.length;if(p>=w?(p=0,m+=1):p<0&&(p=w-1,m-=1),m<0||m>=x){u();return}y.getState().setEditingCell([m,p])}function h(m){if(m.key==="Enter"){m.preventDefault(),c(),f(n+1,o);return}if(m.key==="Tab"){m.preventDefault(),c(),f(n,m.shiftKey?o-1:o+1);return}if(m.key==="Escape"){m.preventDefault(),r.current&&(r.current.value=l),c(),u();return}m.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0]+s[o],y:e.at[1]+i[n],width:e.colWidths[o],height:e.rowHeights[n],className:"ole-ann-cell-edit-fo",children:d.jsx("input",{ref:r,defaultValue:l,onBlur:()=>{c(),u()},onKeyDown:h,onPointerDown:m=>m.stopPropagation(),onMouseDown:m=>m.stopPropagation(),style:{width:"100%",height:"100%",boxSizing:"border-box",border:"1px solid var(--selection)",outline:"none",background:"var(--canvas-bg)",color:"var(--foreground)",font:`${a}px ui-sans-serif, system-ui, sans-serif`,padding:`0 ${Ft}px`}},`${n}-${o}`)})}function Rj({ann:e,isSelected:t}){const n=e.fontSize??yt,o=e.text===""?[""]:e.text.split(`
219
+ `),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*bn;return d.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[d.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,fill:"transparent",className:"ole-free-annotation-hit"}),t&&d.jsx("rect",{x:e.at[0]-1,y:e.at[1]-1,width:r+2,height:s+2,className:"ole-free-annotation-halo"}),o.map((i,a)=>d.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*bn,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function Fj({ann:e}){const t=C.useRef(null),n=e.fontSize??yt;C.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const c=window.getSelection();c==null||c.removeAllRanges(),c==null||c.addRange(l)},[e.id]);function o(){var c;const a=y.getState(),l=(((c=t.current)==null?void 0:c.innerText)??"").replace(/\u00a0/g," ").trimEnd();l===""?a.deleteAnnotation(e.id):l!==e.text&&a.updateAnnotation(e.id,{text:l}),a.setEditingAnnotation(null),l!==""&&a.setSelectedAnnotation(e.id),a.activeTool==="text"&&a.setActiveTool("select")}function r(a){if(a.key==="Escape"){a.preventDefault(),t.current&&(t.current.innerText=e.text),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return d.jsx("foreignObject",{x:e.at[0],y:e.at[1],width:320,height:200,"data-annotation-id":e.id,className:"ole-free-annotation-edit-fo",children:d.jsx("div",{ref:t,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:o,onKeyDown:r,onPointerDown:a=>a.stopPropagation(),onMouseDown:a=>a.stopPropagation(),style:{fontSize:`${n}px`,lineHeight:bn,fontFamily:"ui-sans-serif, system-ui, sans-serif",color:"var(--foreground)",background:"var(--canvas-bg)",outline:"1px dashed var(--selection)",padding:"0 2px",minWidth:`${n}px`,minHeight:`${n*bn}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}function Hj(){const e=y(a=>a.annotationDraft);if(!e)return null;if(e.kind==="rect"){const{at:a,size:l}=Nv(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("rect",{x:a[0],y:a[1],width:l[0],height:l[1],strokeDasharray:Kt})})}if(e.kind==="line"){const a=Av(e);return d.jsx("g",{className:"ole-ann-draft",pointerEvents:"none",children:d.jsx("line",{x1:e.start[0],y1:e.start[1],x2:a[0],y2:a[1]})})}const{at:t,cols:n,rows:o}=Mv(e),r=n*Ht,s=o*Wt,i=[];for(let a=1;a<n;a++){const l=t[0]+a*Ht;i.push(d.jsx("line",{x1:l,y1:t[1],x2:l,y2:t[1]+s},`c${a}`))}for(let a=1;a<o;a++){const l=t[1]+a*Wt;i.push(d.jsx("line",{x1:t[0],y1:l,x2:t[0]+r,y2:l},`r${a}`))}return d.jsxs("g",{className:"ole-ann-draft",pointerEvents:"none",children:[d.jsx("rect",{x:t[0],y:t[1],width:r,height:s}),i,d.jsxs("text",{className:"ole-ann-draft-badge",x:e.current[0]+12,y:e.current[1]-8,children:[n," × ",o]})]})}const sn=7,wn=3;function Wj(){const e=y(i=>i.selectedAnnotation),t=y(i=>i.diagram.annotations),n=y(i=>i.annotationPreview);if(y(i=>i.readOnly)||!e)return null;const r=(t??[]).find(i=>i.id===e);if(!r)return null;const s=(n==null?void 0:n.id)===e?n:r;switch(De(s)){case"rect":return d.jsx(qj,{ann:s,model:r});case"table":return d.jsx(Yj,{ann:s,model:r});case"line":return d.jsx(Vj,{ann:s,model:r});default:return null}}function Vt(e,t,n){const o=C.useRef(null);return{onPointerDown:l=>{if(l.button!==0)return;l.stopPropagation(),l.preventDefault();const c=Xe();c&&(o.current={pointerId:l.pointerId,startSvg:c.screenToSvg(l.clientX,l.clientY),orig:structuredClone(e)},l.target.setPointerCapture(l.pointerId))},onPointerMove:l=>{const c=o.current,u=Xe();if(!c||l.pointerId!==c.pointerId||!u)return;const f=u.screenToSvg(l.clientX,l.clientY),h=de(f[0]-c.startSvg[0]),g=de(f[1]-c.startSvg[1]);y.getState().setAnnotationPreview(t(c.orig,h,g,l.nativeEvent))},onPointerUp:l=>{const c=o.current;if(!c||l.pointerId!==c.pointerId)return;o.current=null;const u=l.target;u.hasPointerCapture(l.pointerId)&&u.releasePointerCapture(l.pointerId);const f=y.getState(),h=f.annotationPreview;f.setAnnotationPreview(null),h&&h.id===e.id&&f.updateAnnotation(e.id,n(h))},onPointerCancel:l=>{const c=o.current;!c||l.pointerId!==c.pointerId||(o.current=null,y.getState().setAnnotationPreview(null))}}}function Pv(e,t,n,o,r,s,i,a){let[l,c]=e,[u,f]=t;return n===1&&(u=Math.max(i,t[0]+r)),n===-1&&(u=Math.max(i,t[0]-r),l=e[0]+t[0]-u),o===1&&(f=Math.max(a,t[1]+s)),o===-1&&(f=Math.max(a,t[1]-s),c=e[1]+t[1]-f),{at:[l,c],size:[u,f]}}const Iv=[{dirX:-1,dirY:-1,cursor:"nwse-resize"},{dirX:0,dirY:-1,cursor:"ns-resize"},{dirX:1,dirY:-1,cursor:"nesw-resize"},{dirX:1,dirY:0,cursor:"ew-resize"},{dirX:1,dirY:1,cursor:"nwse-resize"},{dirX:0,dirY:1,cursor:"ns-resize"},{dirX:-1,dirY:1,cursor:"nesw-resize"},{dirX:-1,dirY:0,cursor:"ew-resize"}];function Ov(e,t,n,o){const r=n===-1?e[0]:n===1?e[0]+t[0]:e[0]+t[0]/2,s=o===-1?e[1]:o===1?e[1]+t[1]:e[1]+t[1]/2;return[r,s]}function Bv({pos:e,cursor:t,handlers:n}){return d.jsx("rect",{className:"ole-annotation-handle",x:e[0]-sn/2,y:e[1]-sn/2,width:sn,height:sn,style:{cursor:t},onPointerDown:n.onPointerDown,onPointerMove:n.onPointerMove,onPointerUp:n.onPointerUp,onPointerCancel:n.onPointerCancel})}function qj({ann:e,model:t}){return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:Iv.map((n,o)=>d.jsx(Xj,{grip:n,ann:e,model:t},o))})}function Xj({grip:e,ann:t,model:n}){const o=Vt(n,(r,s,i)=>{const a=Pv(r.at,r.size,e.dirX,e.dirY,s,i,xn,xn);return{...r,at:a.at,size:a.size}},r=>({at:r.at,size:r.size}));return d.jsx(Bv,{pos:Ov(t.at,t.size,e.dirX,e.dirY),cursor:e.cursor,handlers:o})}function Yj({ann:e,model:t}){const n=Ge(e),o=wt(e),r=vt(e);return d.jsxs("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:[o.slice(1,-1).map((s,i)=>d.jsx(Kj,{index:i,x:e.at[0]+s,ann:e,model:t},`c${i}`)),r.slice(1,-1).map((s,i)=>d.jsx(Uj,{index:i,y:e.at[1]+s,ann:e,model:t},`r${i}`)),Iv.map((s,i)=>d.jsx(Gj,{grip:s,ann:e,model:t,size:n},i))]})}function Gj({grip:e,ann:t,model:n,size:o}){const r=Vt(n,(s,i,a)=>{const l=Ge(s),c=Pv(s.at,l,e.dirX,e.dirY,i,a,uo*s.colWidths.length,fo*s.rowHeights.length),u=Pr(s.colWidths,c.size[0]/l[0],uo),f=Pr(s.rowHeights,c.size[1]/l[1],fo),h=u.reduce((p,x)=>p+x,0),g=f.reduce((p,x)=>p+x,0),m=[e.dirX===-1?s.at[0]+l[0]-h:s.at[0],e.dirY===-1?s.at[1]+l[1]-g:s.at[1]];return{...s,at:m,colWidths:u,rowHeights:f}},s=>({at:s.at,colWidths:s.colWidths,rowHeights:s.rowHeights}));return d.jsx(Bv,{pos:Ov(t.at,o,e.dirX,e.dirY),cursor:e.cursor,handlers:r})}function Pr(e,t,n){return e.map(o=>Math.max(n,Math.round(o*t)))}function Kj({index:e,x:t,ann:n,model:o}){const[,r]=Ge(n),s=Vt(o,(i,a)=>{const l=[...i.colWidths];return l[e]=Math.max(uo,i.colWidths[e]+a),{...i,colWidths:l}},i=>({colWidths:i.colWidths}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:t-wn,y:n.at[1],width:wn*2,height:r,style:{cursor:"col-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function Uj({index:e,y:t,ann:n,model:o}){const[r]=Ge(n),s=Vt(o,(i,a,l)=>{const c=[...i.rowHeights];return c[e]=Math.max(fo,i.rowHeights[e]+l),{...i,rowHeights:c}},i=>({rowHeights:i.rowHeights}));return d.jsx("rect",{className:"ole-annotation-handle ole-annotation-handle-strip",x:n.at[0],y:t-wn,width:r,height:wn*2,style:{cursor:"row-resize"},onPointerDown:s.onPointerDown,onPointerMove:s.onPointerMove,onPointerUp:s.onPointerUp,onPointerCancel:s.onPointerCancel})}function Vj({ann:e,model:t}){const n=Ut(e);return d.jsx("g",{className:"ole-annotation-handles",pointerEvents:"auto",children:n.map((o,r)=>d.jsx(Jj,{index:r,pos:o,model:t},r))})}function Jj({index:e,pos:t,model:n}){const o=Vt(n,(r,s,i,a)=>{const l=r.points.map(u=>[...u]);let c=[r.points[e][0]+s,r.points[e][1]+i];if(a.shiftKey){const u=r.points[e-1]??r.points[e+1]??[0,0];c=Tv(u,c)}return l[e]=c,{...r,points:l}},r=>({points:r.points}));return d.jsx("circle",{className:"ole-annotation-handle",cx:t[0],cy:t[1],r:4.5,style:{cursor:"move"},onPointerDown:o.onPointerDown,onPointerMove:o.onPointerMove,onPointerUp:o.onPointerUp,onPointerCancel:o.onPointerCancel})}const Zj=20;function Qj(){const e=y(u=>u.selection),t=y(u=>u.internal);if(e.length!==1)return null;const n=e[0],o=t.buses.get(n);if(!o)return null;const{axis:r,at:s,span:i}=o.geometry,a=i/2,l=r==="x"?[s[0]-a,s[1]]:[s[0],s[1]-a],c=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return d.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[d.jsx(Ir,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),d.jsx(Ir,{x:c[0],y:c[1],busId:n,side:"end",axis:r})]})}function Ir({x:e,y:t,busId:n,side:o,axis:r}){const s=Xe(),i=C.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const f=y.getState().internal.buses.get(n);f&&(i.current={pointerId:u.pointerId,startSpan:f.geometry.span,startAt:[...f.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const f=i.current;if(!f||u.pointerId!==f.pointerId||!s)return;const h=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?h[0]-f.startSvg[0]:h[1]-f.startSvg[1],m=vv()?Math.round(g/yn)*yn:g,p=f.startSpan+(o==="end"?m:-m);if(p<Zj)return;const x=r==="x"?[f.startAt[0]+m/2,f.startAt[1]]:[f.startAt[0],f.startAt[1]+m/2];y.getState().updateBus(n,{span:p,at:x})},c=u=>{const f=i.current;!f||u.pointerId!==f.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return d.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:c,onPointerCancel:c})}const ho=.5;function Bt(e,t){return Math.abs(e[1]-t[1])<ho?"h":"v"}function e4(){const e=y(a=>a.selectedWire),t=y(a=>a.internal.wireRenders);if(!e)return null;const n=t.get(e);if(!n||n.path.length<2)return null;const o=n.path,r=o.length,s=[];for(let a=1;a<r-1;a++){const l=Bt(o[a-1],o[a]),c=Bt(o[a],o[a+1]),u=a-1===0,f=a+1===r-1,h=u&&l==="v"||f&&c==="v",g=u&&l==="h"||f&&c==="h";h&&g||s.push(d.jsx(t4,{wireId:e,index:a,xLocked:h,yLocked:g},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],c=o[a+1];Math.abs(l[0]-c[0])<ho&&Math.abs(l[1]-c[1])<ho||i.push(d.jsx(n4,{wireId:e,segIndex:a,axis:Bt(l,c)},`m-${a}`))}return d.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function t4({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Xe(),s=C.useRef(null),i=y(m=>{var p;return(p=m.internal.wireRenders.get(e))==null?void 0:p.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],c=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=m=>{if(m.button!==0||(m.stopPropagation(),m.preventDefault(),!r))return;const p=y.getState().internal.wireRenders.get(e);p&&(s.current={pointerId:m.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:r.screenToSvg(m.clientX,m.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=c,m.target.setPointerCapture(m.pointerId))},f=m=>{const p=s.current;if(!p||m.pointerId!==p.pointerId||!r)return;const x=r.screenToSvg(m.clientX,m.clientY),w=p.startPath,v=p.index;if(v<=0||v>=w.length-1)return;const M=w[v],I=[p.xLocked?M[0]:de(M[0]+(x[0]-p.startSvg[0])),p.yLocked?M[1]:de(M[1]+(x[1]-p.startSvg[1]))];if(I[0]===M[0]&&I[1]===M[1])return;const F=w.map(H=>[H[0],H[1]]);F[v]=I;const G=Bt(w[v-1],w[v]);v-1>0&&(G==="h"?F[v-1]=[w[v-1][0],I[1]]:F[v-1]=[I[0],w[v-1][1]]);const $=Bt(w[v],w[v+1]);v+1<w.length-1&&($==="h"?F[v+1]=[w[v+1][0],I[1]]:F[v+1]=[I[0],w[v+1][1]]),y.getState().updateWirePath(e,F)},h=m=>{const p=s.current;!p||m.pointerId!==p.pointerId||(m.target.hasPointerCapture(m.pointerId)&&m.target.releasePointerCapture(m.pointerId),s.current=null,document.body.style.cursor="")},g=m=>{m.stopPropagation(),m.preventDefault();const p=y.getState().internal.wireRenders.get(e);if(!p||p.path.length<=2||t<=0||t>=p.path.length-1)return;const x=p.path.filter((w,v)=>v!==t);y.getState().updateWirePath(e,x)};return d.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:c},onPointerDown:u,onPointerMove:f,onPointerUp:h,onPointerCancel:h,onDoubleClick:g})}function n4({wireId:e,segIndex:t,axis:n}){const o=Xe(),r=C.useRef(null),s=y(m=>{var p;return(p=m.internal.wireRenders.get(e))==null?void 0:p.path});if(!s||t<0||t>=s.length-1)return null;const i=s[t],a=s[t+1],l=(i[0]+a[0])/2,c=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",f=m=>{if(m.button!==0||(m.stopPropagation(),m.preventDefault(),!o))return;const p=y.getState().internal.wireRenders.get(e);p&&(r.current={pointerId:m.pointerId,startPath:p.path.map(x=>[x[0],x[1]]),startSvg:o.screenToSvg(m.clientX,m.clientY),axis:n,segIndex:t},document.body.style.cursor=u,m.currentTarget.setPointerCapture(m.pointerId))},h=m=>{const p=r.current;if(!p||m.pointerId!==p.pointerId||!o)return;const x=o.screenToSvg(m.clientX,m.clientY),w=p.startPath,v=p.segIndex;if(v>=w.length-1)return;const M=w[v],I=w[v+1],F=[];for(let G=0;G<=v;G++)F.push(w[G]);if(p.axis==="h"){const G=de(M[1]+(x[1]-p.startSvg[1]));F.push([M[0],G]),F.push([I[0],G])}else{const G=de(M[0]+(x[0]-p.startSvg[0]));F.push([G,M[1]]),F.push([G,I[1]])}for(let G=v+1;G<w.length;G++)F.push(w[G]);y.getState().updateWirePath(e,F)},g=m=>{const p=r.current;if(!p||m.pointerId!==p.pointerId)return;const x=m.currentTarget;x.hasPointerCapture(m.pointerId)&&x.releasePointerCapture(m.pointerId),r.current=null,document.body.style.cursor=""};return d.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:f,onPointerMove:h,onPointerUp:g,onPointerCancel:g,children:[d.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:c,r:8}),d.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:c,r:3.5})]})}const o4=3,Kn=12;function r4(){const e=y(a=>a.internal.buses),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)!l.includes(".")&&e.has(l)&&i.add(l)}return d.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:c,at:u,span:f}=l,h=f/2,g=c==="x"?u[0]-h:u[0],m=c==="x"?u[1]:u[1]-h,p=c==="x"?u[0]+h:u[0],x=c==="x"?u[1]:u[1]+h,w=s.has(a.id),v=i.has(a.id),M=r.get(a.id)??void 0,I=Kn/2,F=c==="x"?u[0]-h:u[0]-I,G=c==="x"?u[1]-I:u[1]-h,$=c==="x"?f:Kn,H=c==="x"?Kn:f;return d.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":M,"data-selected":w?"true":void 0,"data-node-related":v?"true":void 0,className:"ole-bus",children:[d.jsx("rect",{x:F,y:G,width:$,height:H,fill:"transparent",className:"ole-bus-hit"}),d.jsx("line",{x1:g,y1:m,x2:p,y2:x,stroke:"currentColor",strokeWidth:o4,strokeLinecap:"round",fill:"none"})]},a.id)})})}function s4(){const e=y(a=>a.busbarDrawStart),t=y(a=>a.cursorSvg);if(!e||!t)return null;const n=t[0]-e[0],o=t[1]-e[1],r=Math.abs(n)>=Math.abs(o),s=r?t[0]:e[0],i=r?e[1]:t[1];return d.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[d.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),d.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),d.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const i4=2.5,a4=9,l4=13,c4=-13,d4=4.5,u4=8;function f4(){const e=y(a=>a.internal.junctions),t=y(a=>a.selection),n=y(a=>a.selectedNode),o=y(a=>a.internal.nodes),r=y(a=>a.internal.terminalToNode),s=new Set(t),i=new Set;if(n){const a=o.get(n);if(a)for(const l of a.terminals)i.add(l)}return d.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l,degree:c})=>{const u=r.get(a.id)??void 0,f=t.length===1&&t[0]===a.id,h=l[0]+l4,g=l[1]+c4;return d.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":u,"data-solder":c>=3?"true":void 0,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[d.jsx("circle",{cx:l[0],cy:l[1],r:a4,fill:"transparent",className:"ole-junction-hit"}),d.jsx("circle",{cx:l[0],cy:l[1],r:i4,className:"ole-junction-dot"}),f&&d.jsxs("g",{className:"ole-junction-wire-handle-group",children:[d.jsx("line",{x1:l[0],y1:l[1],x2:h,y2:g,className:"ole-junction-wire-handle-stem"}),d.jsx("circle",{cx:h,cy:g,r:u4,fill:"transparent",className:"ole-junction-wire-handle"}),d.jsx("circle",{cx:h,cy:g,r:d4,className:"ole-junction-wire-handle-dot"})]})]},a.id)})})}function nt(e){const t=[`translate(${e.at[0]} ${e.at[1]})`];return e.rot&&t.push(`rotate(${e.rot})`),e.mirror&&t.push("scale(-1 1)"),t.join(" ")}function h4(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function m4({lib:e}){const t=h4(e.viewBox);return t?d.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function p4(){const e=y(a=>a.internal.elements),t=y(a=>a.internal.layout),n=y(a=>a.selection),o=y(a=>a.selectedNode),r=y(a=>a.internal.nodes),s=new Set(n),i=new Set;if(o){const a=r.get(o);if(a)for(const l of a.terminals){const c=l.indexOf(".");c>0&&i.add(l.slice(0,c))}}return d.jsx("g",{className:"ole-element-layer",children:Array.from(e.values()).map(a=>{const l=t.get(a.element.id);if(!l)return null;const c=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:nt(l),className:"ole-element",children:[d.jsx(m4,{lib:a.libraryDef}),d.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}}),a.libraryDef.terminalLabelsSvg&&d.jsx("g",{className:"ole-terminal-labels",dangerouslySetInnerHTML:{__html:a.libraryDef.terminalLabelsSvg}})]},a.element.id):d.jsxs("g",{"data-element-id":a.element.id,"data-selected":c?"true":void 0,"data-node-related":u?"true":void 0,transform:nt(l),className:"ole-element ole-element--unknown",children:[d.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),d.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let Dv=null;const mo=new Set;function an(e){Dv=e;for(const t of mo)t(e)}function g4(){return Dv}function y4(e){return mo.add(e),()=>{mo.delete(e)}}function x4(){const[e,t]=C.useState(g4());return C.useEffect(()=>y4(t),[]),!e||e.w===0&&e.h===0?null:d.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function b4(){const e=y(c=>c.activeTool),t=y(c=>c.placeKind),n=y(c=>c.cursorSvg),o=y(c=>c.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=bv(t);if(!r)return null;let s=null,i=null;if(o){const c=Sv(o,n);c&&(s=$v(r,c,n),i={source:c.world,pin:n})}else s=_v(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return d.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&d.jsxs(d.Fragment,{children:[d.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),d.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),d.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:d.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function w4(){const e=y(r=>r.selection),t=y(r=>r.internal.elements),n=y(r=>r.internal.layout),o=y(r=>r.internal.buses);return e.length===0?null:d.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:c,at:u,span:f}=s.geometry,h=f/2,g=c==="x"?u[0]-h:u[0]-4,m=c==="x"?u[1]-4:u[1]-h,p=c==="x"?f:8,x=c==="x"?8:f;return d.jsx("rect",{x:g,y:m,width:p,height:x,fill:"none",className:"ole-selection-rect"},r)}const i=t.get(r),a=n.get(r);if(!(i!=null&&i.libraryDef)||!a)return null;const l=v4(i.libraryDef.viewBox);return l?d.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:nt(a)},r):null})})}function v4(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function k4(){const e=y(s=>s.internal.terminals),t=y(s=>s.internal.terminalToNode),n=y(s=>s.wireFromTerminal),o=y(s=>s.selection),r=new Set(o);return d.jsx("g",{className:"ole-terminal-layer",children:Array.from(e.values()).map(s=>{const i=t.get(s.ref),a=i!==void 0,l=n===s.ref,c=r.has(s.elementId);return d.jsx("circle",{cx:s.world[0],cy:s.world[1],r:3,"data-element-id":s.elementId,"data-terminal-id":s.ref,"data-node-id":i,"data-connected":a?"true":"false","data-active":l?"true":void 0,"data-on-selected":c?"true":void 0,className:"ole-terminal"},s.ref)})})}const Or=4;function _4(e,t,n,o){const r=t[0]-e[0],s=t[1]-e[1],i=o[0]-n[0],a=o[1]-n[1],l=r*a-s*i;if(Math.abs(l)<1e-9)return null;const c=((n[0]-e[0])*a-(n[1]-e[1])*i)/l,u=((n[0]-e[0])*s-(n[1]-e[1])*r)/l,f=1e-6;return c<=f||c>=1-f||u<=f||u>=1-f?null:[e[0]+c*r,e[1]+c*s]}function S4(e,t){const n=[];let o=[e[0]];for(let r=0;r<e.length-1;r++){const s=e[r],i=e[r+1],a=t.get(r);if(!a||a.length===0){o.push(i);continue}const l=i[0]-s[0],c=i[1]-s[1],u=Math.hypot(l,c)||1,f=l/u,h=c/u,g=p=>(p[0]-s[0])*f+(p[1]-s[1])*h,m=a.slice().sort((p,x)=>g(p)-g(x));for(const p of m){const x=g(p),w=Math.max(0,x-Or),v=Math.min(u,x+Or);o.push([s[0]+f*w,s[1]+h*w]),n.push(o),o=[[s[0]+f*v,s[1]+h*v]]}o.push(i)}return n.push(o),n.filter(r=>r.length>=2)}function $4(){const e=y(c=>c.internal.wireRenders),t=y(c=>c.internal.terminalToNode),n=y(c=>c.diagram.wires),o=y(c=>c.selectedWire),r=y(c=>c.selectedNode),s=new Map;for(const c of n??[]){const u=t.get(c.ends[0]);u&&s.set(c.id,u)}const i=Array.from(e.values()).filter(c=>c.path.length>=2),a=[];for(const c of i){const u=s.get(c.wireId);for(let f=0;f<c.path.length-1;f++)a.push({wireId:c.wireId,node:u,i:f,a:c.path[f],b:c.path[f+1]})}const l=new Map;for(let c=0;c<a.length;c++)for(let u=c+1;u<a.length;u++){const f=a[c],h=a[u];if(f.wireId===h.wireId||!(f.node&&h.node&&f.node!==h.node))continue;const g=_4(f.a,f.b,h.a,h.b);if(!g)continue;const m=f.wireId<h.wireId?f:h;let p=l.get(m.wireId);p||(p=new Map,l.set(m.wireId,p));const x=p.get(m.i)??[];x.push(g),p.set(m.i,x)}return d.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:i.flatMap(c=>{const u=c.path,f=u.map(v=>`${v[0]},${v[1]}`).join(" "),h=s.get(c.wireId),g=o===c.wireId,m=r!=null&&r===h,p=g||m?"true":void 0,x=l.get(c.wireId),w=x?S4(u,x):[u];return[d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":h,className:"ole-wire-hit",points:f},`hit-${c.wireId}`),...w.map((v,M)=>d.jsx("polyline",{"data-wire-id":c.wireId,"data-node-id":h,"data-manual":c.userEdited?"true":void 0,"data-selected":p,className:"ole-wire",points:v.map(I=>`${I[0]},${I[1]}`).join(" ")},`${c.wireId}-${M}`))]})})}let it=null;const po=new Set;function tt(e){if(!(e===null&&it===null||e&&it&&e.ref===it.ref&&e.world[0]===it.world[0]&&e.world[1]===it.world[1])){it=e;for(const t of po)t(e)}}function j4(){return it}function E4(e){return po.add(e),()=>{po.delete(e)}}function N4(){const e=y(l=>l.wireDragFrom),t=y(l=>l.cursorSvg),[n,o]=C.useState(j4());if(C.useEffect(()=>E4(o),[]),!e||!t)return null;const r=e.world,s=(n==null?void 0:n.world[0])??t[0],i=(n==null?void 0:n.world[1])??t[1],a=(n==null?void 0:n.create)==="junction";return d.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[d.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),d.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&d.jsxs(d.Fragment,{children:[d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?7:8,className:"ole-wire-preview-target-ring","data-create":a?"true":void 0}),!a&&d.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function lt(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function xt(e){var t;return((t=lt(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function A4(e){var t;return((t=lt(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function T4(e){var t;return((t=lt(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function Tn(e){var r;const t=(r=lt(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=T4(e);if(n)return n;const o=A4(e);return o||null}function Mn(e){var t;return((t=lt(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function go(e){var t;return((t=lt(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function qt(e){var t;return((t=lt(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function Lv(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function M4(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function zv(){const e=y.getState(),t=e.activeTool;if(e.editingAnnotation||e.editingElement){if(typeof document<"u"){const n=document.querySelector(".ole-free-annotation-edit-fo div[contenteditable], .ole-element-name-editor div[contenteditable], .ole-ann-cell-edit-fo input");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"||t==="rect"||t==="line"||t==="table"){e.setActiveTool("select");return}if(t==="place"){e.placeFromTerminal?e.setPlaceFromTerminal(null):e.placeKind?e.setPlaceKind(null):e.setActiveTool("select");return}(e.selectedNode||e.selectedWire||e.selection.length>0||e.selectedAnnotation)&&e.clearSelection()}function C4(){C.useEffect(()=>{const e=t=>{if(M4(t.target)||y.getState().readOnly)return;const n=t.metaKey||t.ctrlKey,o=y.getState();if(n&&t.key.toLowerCase()==="z"){t.preventDefault(),t.shiftKey?o.redo():o.undo();return}if(n&&!t.shiftKey&&t.key.toLowerCase()==="y"){t.preventDefault(),o.redo();return}if(n&&t.key.toLowerCase()==="a"){t.preventDefault();const r=y.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase(),s=o.selection.length>0||o.selectedAnnotation!=null;if(r==="c"){if(!s)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(!s)return;t.preventDefault(),o.cutSelection();return}if(r==="v"){if(!o.clipboard)return;t.preventDefault(),o.pasteClipboard();return}}if(!n)switch(t.key){case"v":case"V":o.setActiveTool("select");return;case"h":case"H":o.setActiveTool("pan");return;case"w":case"W":o.setActiveTool("wire");return;case"b":case"B":o.setActiveTool("busbar");return;case"j":case"J":o.setActiveTool("junction");return;case"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");return;case"f":case"F":o.setActiveTool("rect");return;case"l":case"L":o.setActiveTool("line");return;case"d":case"D":o.setActiveTool("table");return;case"r":case"R":o.selection.length>0&&(t.preventDefault(),o.rotateSelection(90));return;case"m":case"M":o.selection.length>0&&(t.preventDefault(),o.mirrorSelection());return;case"Delete":case"Backspace":o.selectedAnnotation?(t.preventDefault(),o.deleteAnnotation(o.selectedAnnotation)):o.selectedWire?(t.preventDefault(),o.deleteSelectedWire()):o.selectedNode?(t.preventDefault(),o.deleteSelectedNode()):o.selection.length>0&&(t.preventDefault(),o.deleteSelection());return;case"Escape":zv();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let yo=null;const xo=new Set;function P4(e){if(e!==yo){yo=e;for(const t of xo)t(e)}}function I4(){return yo}function O4(e){return xo.add(e),()=>{xo.delete(e)}}const Br="ole-hover-element-host",B4="ole-hover-terminal-on",D4="ole-hover-node-on";function L4(e){C.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(f,h,g)=>{for(const m of f)m.classList.remove(g);f.clear();for(const m of h)m.classList.add(g),f.add(m)},a=f=>{var g,m;if(f===n)return;n&&((g=t.querySelector(`[data-element-id="${ln(n)}"]`))==null||g.classList.remove(Br)),f&&((m=t.querySelector(`[data-element-id="${ln(f)}"]`))==null||m.classList.add(Br));const h=f?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${ln(f)}"]`)):[];i(r,h,B4),n=f,f?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),P4(f)},l=f=>{if(f===o)return;const h=f?Array.from(t.querySelectorAll(`[data-node-id="${ln(f)}"]`)):[];i(s,h,D4),o=f,f?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},c=f=>{a(xt(f.target));const h=Tn(f.target);let g=null;h?g=y.getState().internal.terminalToNode.get(h)??null:g=Mn(f.target),l(g)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",c),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",c),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function ln(e){return e.replace(/(["\\])/g,"\\$1")}function z4(e,t){const n=y.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(r){const{axis:i,at:a,span:l}=r.geometry;if(i==="x"){const h=a[0]-l/2,g=a[0]+l/2,m=Math.max(h,Math.min(g,t[0]));return{ref:e,world:[m,a[1]],isBus:!0}}const c=a[1]-l/2,u=a[1]+l/2,f=Math.max(c,Math.min(u,t[1]));return{ref:e,world:[a[0],f],isBus:!0}}const s=n.junctions.get(e);return s?{ref:e,world:[s.world[0],s.world[1]],isBus:!1}:null}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const Dr=10,cn=e=>Math.round(e/Dr)*Dr,R4=16;function Rv(e,t){let n=e[0],o=1/0;for(let r=0;r<e.length-1;r++){const[s,i]=e[r],[a,l]=e[r+1],c=a-s,u=l-i,f=c*c+u*u,h=f===0?0:Math.max(0,Math.min(1,((t[0]-s)*c+(t[1]-i)*u)/f)),g=s+h*c,m=i+h*u,p=(g-t[0])**2+(m-t[1])**2;p<o&&(o=p,n=[g,m])}return n}function vn(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function F4(e,t){const n=y.getState().internal.wireRenders;let o=null,r=t;for(const s of n.values()){if(s.path.length<2)continue;const i=Rv(s.path,e),a=Math.hypot(i[0]-e[0],i[1]-e[1]);a<=r&&(r=a,o={wireId:s.wireId,at:i})}return o}function Dt(e,t,n){const o=e?Tn(e):null;if(o){const a=z4(o,t);if(a)return{spec:{end:o},world:a.world,ref:o,isBus:a.isBus,create:!1}}let r=e?go(e):null,s=null;if(r){const a=y.getState().internal.wireRenders.get(r);s=a?Rv(a.path,t):t}else{const a=F4(t,n);a&&(r=a.wireId,s=a.at)}if(r&&s){const a=[cn(s[0]),cn(s[1])];return{spec:{onWire:r,at:a},world:a,ref:null,isBus:!1,create:!0}}const i=[cn(t[0]),cn(t[1])];return{spec:{junctionAt:i},world:i,ref:null,isBus:!1,create:!0}}function Lt(e,t,n){const o=e.viewport.screenToSvg(t,n),r=e.viewport.screenToSvg(t+R4,n);return Math.hypot(r[0]-o[0],r[1]-o[1])}function Fv(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function kn(e,t){return e.ref&&t.ref?e.ref===t.ref:!e.ref&&!t.ref?e.world[0]===t.world[0]&&e.world[1]===t.world[1]:!1}const Lr=3;let he=null,Ce=null,Ne=null,pe=null;const H4={id:"select",cursor:"default",onPointerDown(e,t){var m,p,x,w,v,M,I,F,G,$,H,W;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle, .ole-annotation-handle"))return;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const X=(m=n.diagram.annotations)==null?void 0:m.find(R=>R.id===o);if(!X)return;const P=n.selectedAnnotation===o;n.setSelectedAnnotation(o),pe={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[X.at[0],X.at[1]],moved:!1,wasSelected:P};return}const r=e.target instanceof Element?e.target.closest(".ole-junction-wire-handle"):null;if(r){const X=(p=r.closest("[data-junction-id]"))==null?void 0:p.getAttribute("data-junction-id");if(X){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((w=(x=e.target).hasPointerCapture)!=null&&w.call(x,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(X);const P=(v=n.internal.junctions.get(X))==null?void 0:v.world;P&&n.setWireDragFrom({spec:{end:X},world:P,ref:X}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:X};return}}const i=(e.target instanceof Element?(M=e.target.closest("[data-terminal-id]"))==null?void 0:M.getAttribute("data-terminal-id"):null)?Tn(e.target):null;if(i){const X=i.indexOf("."),P=X>0?i.slice(0,X):"";if(P&&n.selection.includes(P)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((F=(I=e.target).hasPointerCapture)!=null&&F.call(I,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(i);const R=(G=n.internal.terminals.get(i))==null?void 0:G.world;R&&n.setWireDragFrom({spec:{end:i},world:R,ref:i}),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),Ne={pointerId:e.pointerId,fromRef:i};return}}let a=xt(e.target);if(!a){const X=go(e.target);if(X&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const R of P){const Z=(H=($=R.closest)==null?void 0:$.call(R,"[data-bus-id]"))==null?void 0:H.getAttribute("data-bus-id");if(!Z)continue;const ie=(W=n.diagram.wires)==null?void 0:W.find(ue=>ue.id===X);ie&&(ie.ends[0]===Z||ie.ends[1]===Z)&&(a=Z);break}}}if(!a){const X=go(e.target);if(X){if(e.preventDefault(),e.altKey){const P=Mn(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(X);return}e.shiftKey||n.clearSelection(),Ce={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),shiftKey:e.shiftKey,baseSelection:e.shiftKey?n.selection.slice():[]},t.hostEl.setPointerCapture(e.pointerId),e.preventDefault();return}const l=n.selection;e.shiftKey?n.toggleInSelection(a):l.includes(a)||n.setSelection([a]);const c=e.shiftKey?y.getState().selection:l.includes(a)?l:[a];if(c.length===0)return;const u=y.getState().internal,f=new Map,h=new Map,g=new Map;for(const X of c){const P=u.buses.get(X);if(P){h.set(X,[P.geometry.at[0],P.geometry.at[1]]);continue}const R=u.junctions.get(X);if(R){g.set(X,[R.world[0],R.world[1]]);continue}const Z=u.layout.get(X);Z&&f.set(X,{...Z})}f.size===0&&h.size===0&&g.size===0||(he={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:f,busOriginals:h,junctionOriginals:g,moved:!1},e.preventDefault())},onPointerMove(e,t){if(pe&&e.pointerId===pe.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-pe.startSvg[0]),r=de(n[1]-pe.startSvg[1]);!pe.moved&&(o!==0||r!==0)&&(pe.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(Ne&&e.pointerId===Ne.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg(n);const o=vn(e.clientX,e.clientY),r=Dt(o,n,Lt(t,e.clientX,e.clientY)),s={spec:{end:Ne.fromRef},world:[0,0],ref:Ne.fromRef};tt(kn(s,r)?null:Fv(r));return}if(he&&e.pointerId===he.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-he.startSvg[0]),r=de(n[1]-he.startSvg[1]);!he.moved&&(o!==0||r!==0)&&(he.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of he.originals){const a=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",nt(l))}for(const s of he.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of he.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Be(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Ce&&e.pointerId===Ce.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);an(Rr(Ce.startSvg,n));return}},onPointerUp(e,t){var n;if(pe&&e.pointerId===pe.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-pe.startSvg[0]),s=de(o[1]-pe.startSvg[1]),i=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(i&&i.removeAttribute("transform"),pe.moved&&(r!==0||s!==0))y.getState().updateAnnotation(pe.id,{at:[pe.origin[0]+r,pe.origin[1]+s]});else if(!pe.moved&&pe.wasSelected){const a=y.getState(),l=(n=a.diagram.annotations)==null?void 0:n.find(c=>c.id===pe.id);l&&zr(a,l,o)}pe=null;return}if(Ne&&e.pointerId===Ne.pointerId){const o=y.getState(),r=Ne.fromRef;Ne=null,t.hostEl.classList.remove("tool-wire"),o.setWireFromTerminal(null),o.setWireDragFrom(null),o.setCursorSvg(null),tt(null);const s=t.viewport.screenToSvg(e.clientX,e.clientY),i=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),a=Dt(i,s,Lt(t,e.clientX,e.clientY));if(kn({world:[0,0],ref:r},a))return;o.connectWire({end:r},a.spec);return}if(he&&e.pointerId===he.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),he.moved){const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=de(o[0]-he.startSvg[0]),s=de(o[1]-he.startSvg[1]);if(r!==0||s!==0){const i=new Map;for(const a of he.originals.keys())i.set(a,[r,s]);for(const a of he.busOriginals.keys())i.set(a,[r,s]);for(const a of he.junctionOriginals.keys())i.set(a,[r,s]);y.getState().moveElements(i)}for(const i of he.busOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}for(const i of he.junctionOriginals.keys()){const a=t.hostEl.querySelector(`[data-element-id="${Be(i)}"]`);a&&a.removeAttribute("transform")}}he=null;return}if(Ce&&e.pointerId===Ce.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=Rr(Ce.startSvg,o);if(r.w>=Lr||r.h>=Lr){const s=W4(r);if(Ce.shiftKey){const i=new Set(Ce.baseSelection);for(const a of s)i.has(a)?i.delete(a):i.add(a);y.getState().setSelection([...i])}else y.getState().setSelection(s)}an(null),Ce=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(pe&&e.pointerId===pe.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Be(pe.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}pe=null}if(he&&e.pointerId===he.pointerId){for(const[l,c]of he.originals){const u=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);u&&u.setAttribute("transform",nt(c))}for(const l of he.busOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}for(const l of he.junctionOriginals.keys()){const c=t.hostEl.querySelector(`[data-element-id="${Be(l)}"]`);c&&c.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}he=null}if(Ne&&e.pointerId===Ne.pointerId){t.hostEl.classList.remove("tool-wire");const l=y.getState();l.setWireFromTerminal(null),l.setWireDragFrom(null),l.setCursorSvg(null),tt(null),Ne=null}if(Ce&&e.pointerId===Ce.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}an(null),Ce=null}},onDoubleClick(e,t){var s;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const i=(s=n.diagram.annotations)==null?void 0:s.find(a=>a.id===o);if(!i)return;n.setSelectedAnnotation(o),zr(n,i,t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=xt(e.target);r&&(e.preventDefault(),e.stopPropagation(),n.setEditingElement(r))},onDeactivate(e){if(he=null,Ce=null,pe=null,Ne){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(null),Ne=null}an(null)}};function zr(e,t,n){const o=De(t);if(o==="table"){const r=Pj(t,n);r&&(e.setEditingAnnotation(t.id),e.setEditingCell(r))}else o==="text"&&e.setEditingAnnotation(t.id)}function Rr(e,t){const n=Math.min(e[0],t[0]),o=Math.min(e[1],t[1]),r=Math.abs(t[0]-e[0]),s=Math.abs(t[1]-e[1]);return{x:n,y:o,w:r,h:s}}function W4(e){const{internal:t}=y.getState(),n=[];for(const o of t.elements.values()){if(!o.libraryDef)continue;const r=t.layout.get(o.element.id);if(!r)continue;const s=X4(o.libraryDef.viewBox);if(!s)continue;const i=[[s.x,s.y],[s.x+s.w,s.y],[s.x,s.y+s.h],[s.x+s.w,s.y+s.h]].map(([f,h])=>q4([f,h],r));let a=1/0,l=-1/0,c=1/0,u=-1/0;for(const[f,h]of i)f<a&&(a=f),f>l&&(l=f),h<c&&(c=h),h>u&&(u=h);l>=e.x&&a<=e.x+e.w&&u>=e.y&&c<=e.y+e.h&&n.push(o.element.id)}for(const{bus:o,geometry:r}of t.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,c=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],f=s==="x"?i[1]:i[1]-l,h=s==="x"?i[1]:i[1]+l;u>=e.x&&c<=e.x+e.w&&h>=e.y&&f<=e.y+e.h&&n.push(o.id)}for(const{junction:o,world:r}of t.junctions.values())r[0]>=e.x&&r[0]<=e.x+e.w&&r[1]>=e.y&&r[1]<=e.y+e.h&&n.push(o.id);return n}function q4(e,t){let[n,o]=e;switch(t.mirror&&(n=-n),t.rot){case 0:break;case 90:[n,o]=[-o,n];break;case 180:[n,o]=[-n,-o];break;case 270:[n,o]=[o,-n];break}return[n+t.at[0],o+t.at[1]]}function X4(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function Be(e){return e.replace(/(["\\])/g,"\\$1")}const Y4=4;let ce=null;const G4={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=y.getState().readOnly?null:xt(e.target);let r=null;if(o){const s=y.getState();s.selection.includes(o)||s.setSelection([o]);const i=y.getState().selection,a=y.getState().internal,l=new Map,c=new Map;for(const u of i){const f=a.buses.get(u);if(f){c.set(u,[f.geometry.at[0],f.geometry.at[1]]);continue}const h=a.layout.get(u);h&&l.set(u,{...h})}(l.size>0||c.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:c})}ce={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startTx:n.tx,startTy:n.ty,startTarget:e.target,moved:!1,elementDrag:r},t.hostEl.style.cursor="grabbing",e.preventDefault()},onPointerMove(e,t){if(!ce||e.pointerId!==ce.pointerId)return;const n=e.clientX-ce.startX,o=e.clientY-ce.startY;if(!ce.moved&&Math.hypot(n,o)>Y4){ce.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(ce.moved){if(ce.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=de(r[0]-ce.elementDrag.startSvg[0]),i=de(r[1]-ce.elementDrag.startSvg[1]);for(const[a,l]of ce.elementDrag.originals){const c=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);if(!c)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};c.setAttribute("transform",nt(u))}for(const a of ce.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${Mt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:ce.startTx+n,ty:ce.startTy+o})}},onPointerUp(e,t){if(!(!ce||e.pointerId!==ce.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",ce.elementDrag&&ce.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=de(n[0]-ce.elementDrag.startSvg[0]),r=de(n[1]-ce.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of ce.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of ce.elementDrag.busOriginals.keys())s.set(i,[o,r]);y.getState().moveElements(s)}for(const s of ce.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Mt(s)}"]`);i&&i.removeAttribute("transform")}}else!ce.moved&&!y.getState().readOnly&&K4(ce.startTarget);ce=null}},onPointerCancel(e,t){if(ce!=null&&ce.elementDrag){for(const[n,o]of ce.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);r&&r.setAttribute("transform",nt(o))}for(const n of ce.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${Mt(n)}"]`);o&&o.removeAttribute("transform")}}ce=null},onDeactivate(){ce=null}};function K4(e){if(!e)return;const t=y.getState(),n=qt(e);if(n){t.setSelectedAnnotation(n);return}const o=xt(e);if(o){t.setSelection([o]);return}const r=Mn(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function Mt(e){return e.replace(/(["\\])/g,"\\$1")}const Pt={tight:1024,compact:720,dense:520,mini:380},Fr={full:0,tight:1,compact:2,dense:3,mini:4};function Oe(e,t){return Fr[e]>=Fr[t]}function U4(e){return e>=Pt.tight?"full":e>=Pt.compact?"tight":e>=Pt.dense?"compact":e>=Pt.mini?"dense":"mini"}const Hv=C.createContext("full");function rt(){return C.useContext(Hv)}function V4(e){const[t,n]=C.useState(null);return C.useLayoutEffect(()=>{const o=e.current;if(!o)return;const r=()=>{const i=o.clientWidth;n(a=>a===i?a:i)};if(r(),typeof ResizeObserver>"u")return;const s=new ResizeObserver(r);return s.observe(o),()=>s.disconnect()},[e]),t}function Wv(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<Pt.dense}function ct(){Wv()&&y.getState().setActiveTool("pan")}function J4(){Wv()&&y.getState().setPlaceKind(null)}const Z4={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=y.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),tt(null)},onPointerDown(e,t){var i,a;if(e.button!==0)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((a=(i=e.target).hasPointerCapture)!=null&&a.call(i,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Lt(t,e.clientX,e.clientY),r=Dt(e.target instanceof Element?e.target:null,n,o),s=y.getState();s.setWireDragFrom({spec:r.spec,world:r.world,ref:r.ref}),s.setWireFromTerminal(r.ref),s.setCursorSvg(n)},onPointerMove(e,t){const n=y.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=vn(e.clientX,e.clientY),i=Dt(s,r,Lt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};tt(kn(a,i)?null:Fv(i))},onPointerUp(e,t){const n=y.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),tt(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=vn(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=Dt(s,r,Lt(t,e.clientX,e.clientY)),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};kn(a,i)||(n.connectWire(o.spec,i.spec),ct())},onPointerLeave(){const e=y.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),tt(null)}},Hr=10;let Ct=!1;function Wr(){setTimeout(()=>J4(),0)}const Q4={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=y.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),Ct=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=y.getState();if(!n)return;e.preventDefault();const o=Tn(e.target);if(o){e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const a=y.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);kv(n,r),Ct=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([qr(n[0]),qr(n[1])])},onPointerUp(e,t){const n=y.getState(),o=n.placeFromTerminal;if(o){n.setPlaceFromTerminal(null);const{placeKind:r}=n;if(!r)return;const s=t.viewport.screenToSvg(e.clientX,e.clientY);Sj(r,o,s),Wr();return}Ct&&(Ct=!1,Wr())},onPointerLeave(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),Ct=!1}};function qr(e){return Math.round(e/Hr)*Hr}const Xr=10,Yr=20;function ft(e){return Math.round(e/Xr)*Xr}const e6={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[ft(n[0]),ft(n[1])];y.getState().setBusbarDrawStart(o),y.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().setCursorSvg([ft(n[0]),ft(n[1])])},onPointerUp(e,t){const n=y.getState().busbarDrawStart;if(y.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=ft(o[0]),s=ft(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let c,u,f;if(l){if(u=Math.abs(i),u<Yr)return;c=0,f=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<Yr)return;c=90,f=[n[0],(n[1]+s)/2]}y.getState().addBus(f,u,c),ct()},onPointerLeave(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=y.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},Gr=10,Kr=e=>Math.round(e/Gr)*Gr,t6={id:"junction",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault(),e.stopPropagation();const n=t.viewport.screenToSvg(e.clientX,e.clientY);y.getState().addJunction([Kr(n[0]),Kr(n[1])]),ct()}},n6={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=y.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation(),n.setActiveTool("select"),n.setSelectedAnnotation(o);return}e.preventDefault();const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=n.addAnnotation([r[0],r[1]],"");n.setEditingAnnotation(s),ct()}},o6={id:"rect",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"rect",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),{at:s,size:i}=Nv({...o,current:r,constrain:e.shiftKey});if(i[0]<xn||i[1]<xn)return;const a=n.insertAnnotation({type:"rect",at:s,size:i,stroke:"dashed"});n.setSelectedAnnotation(a),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},r6={id:"line",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"line",start:n,current:n,constrain:e.shiftKey})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY)),constrain:e.shiftKey})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=Av({...o,current:r,constrain:e.shiftKey}),i=s[0]-o.start[0],a=s[1]-o.start[1];if(Math.hypot(i,a)<Mj)return;const l=n.insertAnnotation({type:"line",at:o.start,points:[[0,0],[i,a]]});n.setSelectedAnnotation(l),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Ur=15,s6=3,i6=3,a6={id:"table",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=We(t.viewport.screenToSvg(e.clientX,e.clientY));y.getState().setAnnotationDraft({kind:"table",start:n,current:n,constrain:!1})},onPointerMove(e,t){const n=y.getState(),o=n.annotationDraft;o&&n.setAnnotationDraft({...o,current:We(t.viewport.screenToSvg(e.clientX,e.clientY))})},onPointerUp(e,t){const n=y.getState(),o=n.annotationDraft;if(n.setAnnotationDraft(null),!o)return;const r=We(t.viewport.screenToSvg(e.clientX,e.clientY)),s=Math.abs(r[0]-o.start[0]),i=Math.abs(r[1]-o.start[1]),a=s<Ur&&i<Ur,{at:l,cols:c,rows:u}=a?{at:o.start,cols:s6,rows:i6}:Mv({...o,current:r}),f=n.insertAnnotation({type:"table",at:l,...Cv(c,u)});n.setSelectedAnnotation(f),n.setActiveTool("select"),ct()},onPointerLeave(){y.getState().setAnnotationDraft(null)},onPointerCancel(){y.getState().setAnnotationDraft(null)},onDeactivate(){y.getState().setAnnotationDraft(null)}},Vr={select:H4,pan:G4,wire:Z4,place:Q4,busbar:e6,junction:t6,text:n6,rect:o6,line:r6,table:a6};function l6(e,t){const n=y(r=>r.activeTool),o=y(r=>r.readOnly);C.useEffect(()=>{var m;const r=e.current;if(!r)return;const s=o?"pan":n,i=o?Vr.pan:Vr[n],a={viewport:t,hostEl:r};r.dataset.tool=s,(m=i.onActivate)==null||m.call(i,a),i.cursor&&(r.style.cursor=i.cursor);const l=p=>{var x;return(x=i.onPointerDown)==null?void 0:x.call(i,p,a)},c=p=>{var x;return(x=i.onPointerMove)==null?void 0:x.call(i,p,a)},u=p=>{var x;return(x=i.onPointerUp)==null?void 0:x.call(i,p,a)},f=p=>{var x;return i.onPointerCancel?i.onPointerCancel(p,a):(x=i.onPointerUp)==null?void 0:x.call(i,p,a)},h=p=>{var x;return(x=i.onPointerLeave)==null?void 0:x.call(i,p,a)},g=p=>{var x;return(x=i.onDoubleClick)==null?void 0:x.call(i,p,a)};return r.addEventListener("pointerdown",l),r.addEventListener("pointermove",c),r.addEventListener("pointerup",u),r.addEventListener("pointercancel",f),r.addEventListener("pointerleave",h),r.addEventListener("dblclick",g),()=>{var p;r.removeEventListener("pointerdown",l),r.removeEventListener("pointermove",c),r.removeEventListener("pointerup",u),r.removeEventListener("pointercancel",f),r.removeEventListener("pointerleave",h),r.removeEventListener("dblclick",g),(p=i.onDeactivate)==null||p.call(i,a),r.style.cursor="",delete r.dataset.tool}},[n,o,e,t])}let bo=1;const wo=new Set;function c6(e){if(e!==bo){bo=e;for(const t of wo)t(e)}}function d6(){return bo}function u6(e){return wo.add(e),()=>{wo.delete(e)}}const Un=.1,Vn=8,f6=1.0015,h6=1.02;function m6(e,t,n={tx:0,ty:0,scale:1}){const o=C.useRef({...n}),r=C.useRef(new Set),s=()=>{const i=t.current,a=e.current;if(i&&i.setAttribute("transform",`translate(${o.current.tx} ${o.current.ty}) scale(${o.current.scale})`),a&&a.style.setProperty("--canvas-scale",String(o.current.scale)),c6(o.current.scale),r.current.size>0){const l={...o.current};for(const c of r.current)c(l)}};return C.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,c=0,u=0,f=0,h=0,g=!1;const m=new Map;let p=null,x=!1;const w=()=>{if(m.size<2){p=null;return}const P=[...m.values()],R=P[1].x-P[0].x,Z=P[1].y-P[0].y,ie=Math.hypot(R,Z)||1,ue=i.getBoundingClientRect();p={startDist:ie,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(P[0].x+P[1].x)/2-ue.left,startMidY:(P[0].y+P[1].y)/2-ue.top}},v=P=>{if(P.pointerType==="touch"){if(m.set(P.pointerId,{x:P.clientX,y:P.clientY}),m.size>=2&&!x){x=!0;for(const R of m.keys())R!==P.pointerId&&Lv(i,R);w()}if(x){P.stopPropagation(),P.preventDefault();try{i.setPointerCapture(P.pointerId)}catch{}}}},M=P=>{if(P.pointerType!=="touch"||!m.has(P.pointerId)||(m.set(P.pointerId,{x:P.clientX,y:P.clientY}),!x||!p))return;P.stopPropagation();const R=[...m.values()];if(R.length<2)return;const Z=R[1].x-R[0].x,ie=R[1].y-R[0].y,ue=Math.hypot(Z,ie)||1,ee=i.getBoundingClientRect(),ae=(R[0].x+R[1].x)/2-ee.left,me=(R[0].y+R[1].y)/2-ee.top,be=ue/p.startDist,$e=Jn(p.startScale*be,Un,Vn),Me=$e/p.startScale;o.current.tx=p.startMidX-(p.startMidX-p.startTx)*Me+(ae-p.startMidX),o.current.ty=p.startMidY-(p.startMidY-p.startTy)*Me+(me-p.startMidY),o.current.scale=$e,s()},I=P=>{var R;if(P.pointerType==="touch"&&m.has(P.pointerId)&&(m.delete(P.pointerId),x)){if(P.stopPropagation(),(R=i.hasPointerCapture)!=null&&R.call(i,P.pointerId))try{i.releasePointerCapture(P.pointerId)}catch{}m.size>=2?w():p=null,m.size===0&&(x=!1)}},F=P=>{P.preventDefault();const R=i.getBoundingClientRect(),Z=P.clientX-R.left,ie=P.clientY-R.top,ue=P.ctrlKey||P.metaKey;if(P.deltaX===0||ue){const me=Math.pow(ue?h6:f6,-P.deltaY),be=Jn(o.current.scale*me,Un,Vn),$e=be/o.current.scale;o.current.tx=Z-(Z-o.current.tx)*$e,o.current.ty=ie-(ie-o.current.ty)*$e,o.current.scale=be}else o.current.tx-=P.deltaX,o.current.ty-=P.deltaY;s()},G=P=>{const R=P.button===1,Z=g&&P.button===0;!R&&!Z||(P.preventDefault(),a=!0,l=P.pointerId,c=P.clientX,u=P.clientY,f=o.current.tx,h=o.current.ty,i.setPointerCapture(P.pointerId),i.style.cursor="grabbing")},$=P=>{!a||P.pointerId!==l||(o.current.tx=f+(P.clientX-c),o.current.ty=h+(P.clientY-u),s())},H=P=>{a&&P.pointerId===l&&(a=!1,i.releasePointerCapture(P.pointerId),i.style.cursor=g?"grab":"")},W=P=>{if(P.code==="Space"&&!g){const R=P.target;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable))return;g=!0,i.style.cursor="grab",P.preventDefault()}},X=P=>{P.code==="Space"&&(g=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",F,{passive:!1}),i.addEventListener("pointerdown",G),i.addEventListener("pointermove",$),i.addEventListener("pointerup",H),i.addEventListener("pointercancel",H),i.addEventListener("pointerdown",v,{capture:!0}),i.addEventListener("pointermove",M,{capture:!0}),i.addEventListener("pointerup",I,{capture:!0}),i.addEventListener("pointercancel",I,{capture:!0}),window.addEventListener("keydown",W),window.addEventListener("keyup",X),s(),()=>{i.removeEventListener("wheel",F),i.removeEventListener("pointerdown",G),i.removeEventListener("pointermove",$),i.removeEventListener("pointerup",H),i.removeEventListener("pointercancel",H),i.removeEventListener("pointerdown",v,{capture:!0}),i.removeEventListener("pointermove",M,{capture:!0}),i.removeEventListener("pointerup",I,{capture:!0}),i.removeEventListener("pointercancel",I,{capture:!0}),window.removeEventListener("keydown",W),window.removeEventListener("keyup",X)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const c=l.getBoundingClientRect(),u=(i-c.left-o.current.tx)/o.current.scale,f=(a-c.top-o.current.ty)/o.current.scale;return[u,f]},getViewport(){return{...o.current}},setViewport(i){i.tx!==void 0&&(o.current.tx=i.tx),i.ty!==void 0&&(o.current.ty=i.ty),i.scale!==void 0&&(o.current.scale=Jn(i.scale,Un,Vn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function Jn(e,t,n){return e<t?t:e>n?n:e}const qv=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),ht=qv?"⌘":"Ctrl+",p6=qv?"⇧":"Shift+",Zn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],g6=18;function y6(e){for(const t of Zn)if(t*e>=g6)return t;return Zn[Zn.length-1]}function x6(){const e=le(),t=C.useRef(null),n=C.useRef(null),o=C.useRef(null),r=m6(t,n);l6(t,r),L4(t),C.useEffect(()=>(jr(r),()=>jr(null)),[r]),C.useEffect(()=>{const u=f=>{const h=o.current;if(!h)return;const m=y6(f.scale)*f.scale;h.setAttribute("width",String(m)),h.setAttribute("height",String(m)),h.setAttribute("patternTransform",`translate(${f.tx} ${f.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Ak(),i=C.useCallback((u,f,h)=>{const g=y.getState();if(g.readOnly)return;const m=g.activeTool;if(m==="wire"||m==="busbar"||m==="junction"||m==="place"){zv();return}const p=qt(h),x=p?null:xt(h);if(p)g.selectedAnnotation!==p&&g.setSelectedAnnotation(p);else if(x)g.selection.includes(x)||g.setSelection([x]);else{const W=Mn(h);W&&g.selectedNode!==W&&g.setSelectedNode(W)}const w=y.getState(),v=w.selection.length>0,M=w.selectedAnnotation!=null,I=v||M,F=w.selectedNode!=null,G=!!w.clipboard,$=w.diagram.elements.length>0,H=[{label:e("menu.undo"),shortcut:`${ht}Z`,icon:Eo,onSelect:()=>y.getState().undo(),disabled:w.past.length===0},{label:e("menu.redo"),shortcut:`${ht}${p6}Z`,icon:jo,onSelect:()=>y.getState().redo(),disabled:w.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${ht}X`,icon:Ts,onSelect:()=>y.getState().cutSelection(),disabled:!I},{label:e("menu.copy"),shortcut:`${ht}C`,icon:js,onSelect:()=>y.getState().copySelection(),disabled:!I},{label:e("menu.paste"),shortcut:`${ht}V`,icon:$s,onSelect:()=>y.getState().pasteClipboard(),disabled:!G},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:As,onSelect:()=>y.getState().rotateSelection(90),disabled:!v},{label:e("menu.mirror"),shortcut:"M",icon:Es,onSelect:()=>y.getState().mirrorSelection(),disabled:!v},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${ht}A`,icon:K2,onSelect:()=>{const W=y.getState();W.setSelection(W.diagram.elements.map(X=>X.id))},disabled:!$},{type:"separator"},{label:e(F&&!I?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Cs,destructive:!0,onSelect:()=>{const W=y.getState();F&&!I?W.deleteSelectedNode():M&&W.selectedAnnotation?W.deleteAnnotation(W.selectedAnnotation):W.deleteSelection()},disabled:!I&&!F}];s.open(u,f,H)},[s,e]);C.useEffect(()=>{const u=t.current;if(!u)return;const f=700,h=4;let g,m=null;const p=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,m=null},x=M=>{M.pointerType==="touch"&&(p(),m={pointerId:M.pointerId,x:M.clientX,y:M.clientY,target:M.target},g=window.setTimeout(()=>{const I=m;m=null,g=void 0,I&&(Lv(u,I.pointerId),i(I.x,I.y,I.target))},f))},w=M=>{if(!m||M.pointerId!==m.pointerId)return;const I=M.clientX-m.x,F=M.clientY-m.y;Math.hypot(I,F)>h&&p()},v=M=>{!m||M.pointerId!==m.pointerId||p()};return u.addEventListener("pointerdown",x),u.addEventListener("pointermove",w),u.addEventListener("pointerup",v),u.addEventListener("pointercancel",v),()=>{p(),u.removeEventListener("pointerdown",x),u.removeEventListener("pointermove",w),u.removeEventListener("pointerup",v),u.removeEventListener("pointercancel",v)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{if(y.getState().readOnly)return;const f=u.dataTransfer.getData("application/x-oneline-kind");if(!f)return;u.preventDefault();const h=r.screenToSvg(u.clientX,u.clientY);kv(f,h)},c=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return d.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:c,children:d.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("defs",{children:d.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:d.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),d.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),d.jsxs("g",{ref:n,className:"ole-viewport",children:[d.jsx(r4,{}),d.jsx($4,{}),d.jsx(f4,{}),d.jsx(p4,{}),d.jsx(jj,{}),d.jsx(Oj,{}),d.jsx(w4,{}),d.jsx(Qj,{}),d.jsx(e4,{}),d.jsx(Wj,{}),d.jsx(k4,{}),d.jsx(N4,{}),d.jsx(s4,{}),d.jsx(Hj,{}),d.jsx(b4,{}),d.jsx(x4,{})]})]})})}const Jr=60,b6=.1,w6=8,v6=8;function k6(e,t,n){return e<t?t:e>n?n:e}function _6(){return document.querySelector(".ole-canvas-root")}function Mo(){const e=Xe(),t=_6();if(!e||!t)return!1;const n=t.getBoundingClientRect();if(n.width===0||n.height===0)return!1;const o=t.querySelectorAll("[data-element-id]");if(o.length===0)return e.setViewport({tx:n.width/2,ty:n.height/2,scale:1}),!0;let r=1/0,s=1/0,i=-1/0,a=-1/0;for(const w of o){const v=w.getBoundingClientRect();v.width===0&&v.height===0||(v.left<r&&(r=v.left),v.top<s&&(s=v.top),v.right>i&&(i=v.right),v.bottom>a&&(a=v.bottom))}if(r===1/0)return!1;const[l,c]=e.screenToSvg(r,s),[u,f]=e.screenToSvg(i,a),h=Math.max(u-l,1),g=Math.max(f-c,1),m=k6(Math.min((n.width-Jr*2)/h,(n.height-Jr*2)/g),b6,w6),p=(l+u)/2,x=(c+f)/2;return e.setViewport({tx:n.width/2-m*p,ty:n.height/2-m*x,scale:m}),!0}function Co(){let e=v6;const t=()=>{Mo()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const Zr=10,S6=100;function $6(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function Qr(){const[e,t]=C.useState(I4()),[n,o]=C.useState(!1),[r,s]=C.useState(null),i=C.useRef(null),a=C.useRef(void 0),[l]=C.useState($6);C.useEffect(()=>O4(m=>t(m)),[]),C.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),S6),()=>window.clearTimeout(a.current)},[e]);const c=y(m=>e?m.diagram.elements.find(p=>p.id===e)??null:null);if(C.useLayoutEffect(()=>{if(!n||!e)return;let m=0,p=-1,x=-1;const w=()=>{const v=document.querySelector(`[data-element-id="${j6(e)}"]`),M=i.current;if(v&&M){const I=v.getBoundingClientRect();let F=I.bottom+Zr;F+M.offsetHeight>window.innerHeight-4&&(F=I.top-M.offsetHeight-Zr);let G=I.left+I.width/2-M.offsetWidth/2;G=Math.max(4,Math.min(G,window.innerWidth-M.offsetWidth-4)),(F!==p||G!==x)&&(s({top:F,left:G}),p=F,x=G)}m=requestAnimationFrame(w)};return m=requestAnimationFrame(w),()=>cancelAnimationFrame(m)},[n,e]),l||!n||!e||!c)return null;const u=ot[c.kind],f=c.name??c.id,h=(u==null?void 0:u.name)??c.kind,g=c.name&&c.name!==c.id;return typeof document>"u"?null:ks.createPortal(d.jsxs("div",{ref:i,role:"tooltip",className:"ole-root ole-glass pointer-events-none fixed z-[100] flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] leading-snug shadow-md",style:{top:(r==null?void 0:r.top)??-9999,left:(r==null?void 0:r.left)??-9999,opacity:r?1:0,transition:"opacity 80ms ease-out"},children:[d.jsx("span",{className:"font-medium text-foreground",children:f}),g&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:c.id}),d.jsx("span",{className:"text-muted-foreground/80",children:"·"}),d.jsx("span",{className:"text-muted-foreground",children:h})]}),document.body)}function j6(e){return e.replace(/(["\\])/g,"\\$1")}function E6({width:e,children:t}){const n=e==null?"full":U4(e);return d.jsx(Hv.Provider,{value:n,children:t})}function es(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function N6(...e){return t=>{let n=!1;const o=e.map(r=>{const s=es(r,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let r=0;r<o.length;r++){const s=o[r];typeof s=="function"?s():es(e[r],null)}}}}var A6=Symbol.for("react.lazy"),_n=Se[" use ".trim().toString()];function T6(e){return typeof e=="object"&&e!==null&&"then"in e}function Xv(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===A6&&"_payload"in e&&T6(e._payload)}function M6(e){const t=P6(e),n=Se.forwardRef((o,r)=>{let{children:s,...i}=o;Xv(s)&&typeof _n=="function"&&(s=_n(s._payload));const a=Se.Children.toArray(s),l=a.find(O6);if(l){const c=l.props.children,u=a.map(f=>f===l?Se.Children.count(c)>1?Se.Children.only(null):Se.isValidElement(c)?c.props.children:null:f);return d.jsx(t,{...i,ref:r,children:Se.isValidElement(c)?Se.cloneElement(c,void 0,u):null})}return d.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var C6=M6("Slot");function P6(e){const t=Se.forwardRef((n,o)=>{let{children:r,...s}=n;if(Xv(r)&&typeof _n=="function"&&(r=_n(r._payload)),Se.isValidElement(r)){const i=D6(r),a=B6(s,r.props);return r.type!==Se.Fragment&&(a.ref=o?N6(o,i):i),Se.cloneElement(r,a)}return Se.Children.count(r)>1?Se.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var I6=Symbol("radix.slottable");function O6(e){return Se.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===I6}function B6(e,t){const n={...t};for(const o in t){const r=e[o],s=t[o];/^on[A-Z]/.test(o)?r&&s?n[o]=(...a)=>{const l=s(...a);return r(...a),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...s}:o==="className"&&(n[o]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}function D6(e){var o,r;let t=(o=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(r=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const ts=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ns=Os,L6=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return ns(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(c=>{const u=n==null?void 0:n[c],f=s==null?void 0:s[c];if(u===null)return null;const h=ts(u)||ts(f);return r[c][h]}),a=n&&Object.entries(n).reduce((c,u)=>{let[f,h]=u;return h===void 0||(c[f]=h),c},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((c,u)=>{let{class:f,className:h,...g}=u;return Object.entries(g).every(m=>{let[p,x]=m;return Array.isArray(x)?x.includes({...s,...a}[p]):{...s,...a}[p]===x})?[...c,f,h]:c},[]);return ns(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},z6=L6("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),Ae=Se.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?C6:"button";return d.jsx(i,{className:_e(z6({variant:t,size:n,className:e})),ref:s,...r})});Ae.displayName="Button";const R6=350;function Te({content:e,children:t,disabled:n,delayMs:o=R6}){const r=C.useRef(null),s=C.useRef(null),[i,a]=C.useState(!1),[l,c]=C.useState(null),u=C.useId(),f=C.useRef(void 0),h=()=>{n||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>a(!0),o))},g=()=>{window.clearTimeout(f.current),a(!1)};C.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const w=r.current.getBoundingClientRect(),v=s.current.getBoundingClientRect(),M=8;let I="top",F=w.top-v.height-M;F<4&&(I="bottom",F=w.bottom+M);let G=w.left+w.width/2-v.width/2;G=Math.max(4,Math.min(G,window.innerWidth-v.width-4)),c({top:F,left:G,side:I})},[i,e]),C.useEffect(()=>()=>window.clearTimeout(f.current),[]),C.useEffect(()=>{if(!i)return;const w=M=>{M.key==="Escape"&&a(!1)},v=()=>a(!1);return window.addEventListener("keydown",w),window.addEventListener("scroll",v,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("keydown",w),window.removeEventListener("scroll",v,!0),window.removeEventListener("resize",v)}},[i]);const m=t,p=m.props,x=C.cloneElement(m,{ref:w=>{r.current=w;const v=m.ref;typeof v=="function"?v(w):v&&typeof v=="object"&&(v.current=w)},onPointerEnter:w=>{var v;(v=p.onPointerEnter)==null||v.call(p,w),h()},onPointerLeave:w=>{var v;(v=p.onPointerLeave)==null||v.call(p,w),g()},onFocus:w=>{var v;(v=p.onFocus)==null||v.call(p,w),h()},onBlur:w=>{var v;(v=p.onBlur)==null||v.call(p,w),g()},"aria-describedby":i?u:p["aria-describedby"]});return d.jsxs(d.Fragment,{children:[x,i&&typeof document<"u"&&ks.createPortal(d.jsx("div",{ref:s,id:u,role:"tooltip","data-side":(l==null?void 0:l.side)??"top",className:"ole-root ole-glass pointer-events-none fixed z-[100] max-w-[280px] rounded-md border border-border px-2 py-1 text-[11px] leading-snug text-foreground shadow-md",style:{top:(l==null?void 0:l.top)??-9999,left:(l==null?void 0:l.left)??-9999,opacity:l?1:0,transition:"opacity 80ms ease-out"},children:e}),document.body)]})}const os=12,F6=56;function H6(){var w;const e=le(),t=y(v=>v.selection),n=y(v=>v.selectedNode),o=y(v=>v.selectedWire),r=y(v=>v.activeTool),s=y(v=>v.rotateSelection),i=y(v=>v.mirrorSelection),a=y(v=>v.deleteSelection),l=y(v=>v.deleteSelectedNode),c=y(v=>v.deleteSelectedWire),u=y(v=>v.resetWirePath),f=y(v=>v.internal.wireRenders),h=o!=null&&((w=f.get(o))==null?void 0:w.userEdited)===!0,g=C.useRef(null);C.useEffect(()=>{const v=g.current;if(!v)return;const M=t.length>0,I=!M&&o!=null,F=!M&&!I&&n!=null;if(!((M||I||F)&&(r==="select"||r==="pan"))){v.style.display="none";return}v.style.display="flex";let $=0,H="";const W=()=>{let X=1/0,P=-1/0,R=1/0,Z=-1/0,ie=!1;const ue=ee=>{ee.width===0&&ee.height===0||(ee.left<X&&(X=ee.left),ee.right>P&&(P=ee.right),ee.top<R&&(R=ee.top),ee.bottom>Z&&(Z=ee.bottom),ie=!0)};if(M)for(const ee of t){const ae=document.querySelector(`[data-element-id="${CSS.escape(ee)}"]`);ae&&ue(ae.getBoundingClientRect())}else if(I&&o){const ee=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);ee&&ue(ee.getBoundingClientRect())}else if(F&&n){const ee=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const ae of ee)ue(ae.getBoundingClientRect())}if(ie){const ee=(X+P)/2;let ae=R-os,me="-100%";ae<F6&&(ae=Z+os,me="0%");const be=`translate3d(${ee}px, ${ae}px, 0) translate(-50%, ${me})`;be!==H&&(v.style.transform=be,H=be)}$=requestAnimationFrame(W)};return $=requestAnimationFrame(W),()=>cancelAnimationFrame($)},[t,n,o,r]);const m=t.length===0&&o!=null,p=t.length===0&&!m&&n!=null,x=p||m;return d.jsxs("div",{ref:g,role:"toolbar","aria-label":e(m?"ctx.ariaWire":p?"ctx.ariaNode":"ctx.ariaElement"),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",children:[m&&h&&o&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{children:d.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:d.jsx(G2,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!x&&d.jsxs(d.Fragment,{children:[d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:d.jsx(As,{})})}),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),d.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:d.jsx(Es,{})})}),d.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:e("ctx.delete")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),d.jsx("div",{className:"text-muted-foreground",children:e(m?"ctx.deleteHintWire":p?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>m?c():p?l():a(),"aria-label":e("ctx.delete"),children:d.jsx(Cs,{})})})]})}const rs=8,W6=56,vo=".ole-ann-cell-edit-fo",ko=".ole-free-annotation-edit-fo";function ss(){return document.querySelector(`${vo} input`)??document.querySelector(`${ko} [contenteditable]`)}function q6(){const e=le(),t=y(i=>i.editingAnnotation),n=y(i=>i.editingCell),o=C.useRef(null);C.useEffect(()=>{const i=o.current;if(!i)return;if(!t){i.style.display="none";return}i.style.display="flex";let a=0,l="";const c=()=>{const u=ss()??document.querySelector(vo)??document.querySelector(ko)??document.querySelector(`[data-annotation-id="${CSS.escape(t)}"]`);if(u){const f=u.getBoundingClientRect();let h=f.top-rs,g="-100%";h<W6&&(h=f.bottom+rs,g="0%");const m=`translate3d(${f.left}px, ${h}px, 0) translate(0, ${g})`;m!==l&&(i.style.transform=m,l=m)}a=requestAnimationFrame(c)};return a=requestAnimationFrame(c),()=>cancelAnimationFrame(a)},[t,n]);const r=()=>{var i;(i=ss())==null||i.blur()},s=()=>{var c,u;const i=y.getState(),a=i.editingAnnotation,l=(c=i.diagram.annotations)==null?void 0:c.find(f=>f.id===a);if(!l){i.setEditingAnnotation(null);return}if(De(l)==="table"&&i.editingCell){const f=document.querySelector(`${vo} input`),[h,g]=i.editingCell;if(f){f.value=((u=l.cells[h])==null?void 0:u[g])??"",f.blur();return}}else{const f=document.querySelector(`${ko} [contenteditable]`);if(f){f.innerText=l.text??"",f.blur();return}}i.setEditingAnnotation(null)};return d.jsxs("div",{ref:o,role:"toolbar","aria-label":e("ctx.ariaEdit"),className:"ole-glass pointer-events-auto fixed left-0 top-0 z-40 hidden items-center gap-0.5 rounded-2xl border border-border p-1 shadow-md",children:[d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.done")," · Enter"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-emerald-600 hover:text-emerald-600 dark:text-emerald-400 dark:hover:text-emerald-400",onMouseDown:i=>i.preventDefault(),onClick:r,"aria-label":e("ctx.done"),children:d.jsx(M2,{})})}),d.jsx(Te,{content:d.jsxs("span",{className:"font-medium",children:[e("ctx.cancel")," · Esc"]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",onMouseDown:i=>i.preventDefault(),onClick:s,"aria-label":e("ctx.cancel"),children:d.jsx(Sn,{})})})]})}function Po({open:e,onOpenChange:t,trigger:n,children:o}){const r=C.useRef(null);return C.useEffect(()=>{if(!e)return;const s=a=>{r.current&&!r.current.contains(a.target)&&t(!1)},i=a=>{a.key==="Escape"&&t(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[e,t]),d.jsxs("div",{ref:r,className:"relative",children:[n,e&&d.jsx("div",{role:"menu",className:"ole-glass absolute bottom-full right-0 mb-1.5 min-w-52 rounded-md border border-border p-1 shadow-md",children:o})]})}const Yv="ole-panel-open";function X6(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Yv);if(!e)return{outlineOpen:!1};const t=JSON.parse(e);return typeof t!="object"||t===null?{outlineOpen:!1}:{outlineOpen:t.outline===!0}}catch{return{outlineOpen:!1}}}function is(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Yv,JSON.stringify(t))}catch{}}const Xt=$n((e,t)=>({...X6(),setOutlineOpen:n=>{e({outlineOpen:n}),is(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),is(t())}})),mn=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Gv=.1,Kv=8,Uv="ole-grid";function Y6(){try{const e=window.localStorage.getItem(Uv);return e==null?!0:e==="1"}catch{return!0}}function G6(e){try{window.localStorage.setItem(Uv,e?"1":"0")}catch{}}function K6(e,t,n){return e<t?t:e>n?n:e}function Vv(){return document.querySelector(".ole-canvas-root")}function Io(e){const t=Xe(),n=Vv();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=K6(e,Gv,Kv),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function U6(){const e=Xe();if(!e)return;const t=e.getViewport().scale,n=mn.find(o=>o>t+1e-6)??Kv;Io(n)}function V6(){const e=Xe();if(!e)return;const t=e.getViewport().scale;let n=Gv;for(let o=mn.length-1;o>=0;o--)if(mn[o]<t-1e-6){n=mn[o];break}Io(n)}const J6={off:"id",id:"all",all:"off"};function Z6(){var o;const e=y.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=J6[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function Jv(){const[e,t]=C.useState(()=>Y6());return C.useEffect(()=>{const n=Vv();n==null||n.classList.toggle("hide-grid",!e),G6(e)},[e]),C.useEffect(()=>{const n=o=>{if(o.metaKey||o.ctrlKey||o.altKey||o.key!=="g"&&o.key!=="G")return;const r=o.target;r&&(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)||(o.preventDefault(),t(s=>!s))};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),[e,t]}function Zv(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:V6,"aria-label":e("view.zoomOut"),children:d.jsx($o,{})})})}function Qv(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:U6,"aria-label":e("view.zoomIn"),children:d.jsx(q2,{})})})}function e2(){const e=le(),[t,n]=C.useState(d6);return C.useEffect(()=>u6(n),[]),d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.reset")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:d.jsxs("button",{type:"button",onClick:()=>Io(1),className:"min-w-12 rounded-md px-2 py-1 text-center text-xs tabular-nums text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("view.reset"),children:[Math.round(t*100),"%"]})})}function t2(){const e=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e("view.fit")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:Mo,"aria-label":e("view.fit"),children:d.jsx(F2,{})})})}function n2({grid:e,setGrid:t}){const n=le();return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),d.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:_e(!e&&"text-muted-foreground/60"),children:d.jsx(z2,{})})})}function o2(){const e=le(),t=y(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return d.jsx(Te,{content:d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),d.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:Z6,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:_e(t==="off"&&"text-muted-foreground/60"),children:d.jsx(Ps,{})})})}function Q6({stacked:e}={}){const t=le(),[n,o]=C.useState(!1),[r,s]=Jv(),i=d.jsxs("div",{className:"space-y-0.5",children:[d.jsx("div",{className:"font-medium",children:t("view.menu")}),d.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?d.jsx(Te,{content:i,children:d.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:_e("flex h-12 w-12 flex-col items-center justify-center gap-0.5 rounded-md text-[10px] font-medium leading-tight transition-colors",n?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[d.jsx(no,{className:"size-4"}),d.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):d.jsx(Te,{content:i,children:d.jsx(Ae,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:d.jsx(no,{})})});return d.jsx(Po,{open:n,onOpenChange:o,trigger:a,children:d.jsxs("div",{className:"flex flex-col gap-0.5",children:[d.jsx(e2,{}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(Zv,{}),d.jsx(Qv,{})]}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsxs("div",{className:"flex items-center gap-0.5",children:[d.jsx(t2,{}),d.jsx(n2,{grid:r,setGrid:s}),d.jsx(o2,{})]})]})})}function as(){const e=rt();return!y(n=>n.readOnly)&&Oe(e,"dense")?null:d.jsx(eE,{tier:e})}function eE({tier:e}){const t=Oe(e,"tight"),n=y(s=>s.readOnly),[o,r]=Jv();return d.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:d.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[d.jsx(Zv,{}),!t&&d.jsx(e2,{}),d.jsx(Qv,{}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),d.jsx(t2,{}),d.jsx(n2,{grid:o,setGrid:r}),!n&&d.jsx(o2,{})]})})}const ls=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:H2,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:R2,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:$o,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:P2,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Ms,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Ss,switchTo:"wire",groupBreakAfter:!0},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Ps,switchTo:"text",iconOnly:!0},{id:"rect",labelKey:"tool.rect",hotkey:"F",descriptionKey:"tool.rectHint",icon:U2,switchTo:"rect",iconOnly:!0},{id:"line",labelKey:"tool.line",hotkey:"L",descriptionKey:"tool.lineHint",icon:Y2,switchTo:"line",iconOnly:!0},{id:"table",labelKey:"tool.table",hotkey:"D",descriptionKey:"tool.tableHint",icon:V2,switchTo:"table",iconOnly:!0}];function tE(){const e=le(),t=y(h=>h.activeTool),n=y(h=>h.placeKind),o=y(h=>h.placeFromTerminal),r=y(h=>h.wireDragFrom),s=y(h=>h.busbarDrawStart),i=y(h=>h.selection.length>0||h.selectedNode!=null),a=y(h=>h.editingAnnotation),l=y(h=>{var p;const g=h.selectedAnnotation;if(!g)return null;const m=(p=h.diagram.annotations)==null?void 0:p.find(x=>x.id===g);return m?De(m):null});if(a)return d.jsx("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:d.jsx("span",{children:e("mode.annEditing")})});let c=null,u=!1;switch(t){case"select":if(l){c=e(l==="table"?"mode.annTableSel":l==="text"?"mode.annTextSel":"mode.annShapeSel"),u=!0;break}c=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(u=!0);break;case"pan":c=e("mode.pan");break;case"wire":c=e(r?"mode.wireDragging":"mode.wireInit"),u=!0;break;case"busbar":c=e(s?"mode.busDragging":"mode.busInit"),u=!0;break;case"junction":c=e("mode.junction"),u=!0;break;case"place":n?o?c=e("mode.placeFromTerm"):c=e("mode.placeNormal"):c=e("mode.placeNoKind"),u=!0;break;case"text":c=e("mode.text"),u=!0;break;case"rect":c=e("mode.rect"),u=!0;break;case"line":c=e("mode.line"),u=!0;break;case"table":c=e("mode.table"),u=!0;break}if(!c)return null;const f=e(t==="select"?"mode.escSelect":"mode.escOther");return d.jsxs("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:[d.jsx("span",{children:c}),u&&d.jsxs("span",{className:"text-muted-foreground/70",children:["· ",f]})]})}function nE(){const e=le(),t=y(w=>w.activeTool),n=y(w=>w.placeKind),o=y(w=>w.setActiveTool),r=y(w=>w.past.length),s=y(w=>w.future.length),i=y(w=>w.undo),a=y(w=>w.redo),l=rt(),c=Oe(l,"tight"),u=!Oe(l,"dense"),f=Oe(l,"dense"),h=new Set(["select","text","rect","line","table"]),g=f?ls.filter(w=>!h.has(w.id)):ls,m=w=>t===w.switchTo,[p,x]=C.useState(!1);return d.jsxs("div",{className:"absolute left-1/2 z-20 flex -translate-x-1/2 flex-col items-center gap-1.5",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))"},children:[u&&d.jsx("div",{className:_e("transition-opacity duration-150",p&&"pointer-events-none opacity-0"),children:d.jsx(tE,{})}),d.jsxs("div",{onPointerEnter:()=>x(!0),onPointerLeave:()=>x(!1),className:_e("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",f?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[f&&d.jsx(oE,{stacked:!0}),g.map(w=>{const v=w.icon,M=m(w),I=w.id==="place"&&M&&n==null?e("tool.placeNoKindTooltip"):e(w.descriptionKey);return d.jsxs(C.Fragment,{children:[d.jsx(pt,{icon:v,label:e(w.labelKey),hotkey:w.hotkey,active:M,iconOnly:!f&&(w.iconOnly||c),stacked:f,description:I,onClick:()=>{o(w.switchTo,{placeKind:w.presetPlaceKind!==void 0?w.presetPlaceKind:void 0})}}),w.groupBreakAfter&&!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},w.id)}),!f&&d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),f?d.jsx(sE,{stacked:!0}):d.jsxs(d.Fragment,{children:[d.jsx(pt,{icon:Eo,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),d.jsx(pt,{icon:jo,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),d.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),d.jsx(rE,{iconOnly:c})]}),f&&d.jsx(Q6,{stacked:!0})]})]})}function oE({stacked:e}){const t=le(),n=Xt(r=>r.outlineOpen),o=Xt(r=>r.toggleOutline);return d.jsx(pt,{icon:Ns,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function pt({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const c=d.jsxs("div",{className:"space-y-0.5",children:[d.jsxs("div",{children:[d.jsx("span",{className:"font-medium",children:t}),n&&d.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&d.jsx("div",{className:"text-muted-foreground",children:l})]});return d.jsx(Te,{content:c,disabled:r,children:d.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:_e("rounded-md font-medium transition-colors",i?"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",!i&&(s?"w-9 justify-center":"px-2.5"),o?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground",r&&"pointer-events-none opacity-40"),children:[d.jsxs("span",{className:"relative inline-flex shrink-0",children:[d.jsx(e,{className:"size-4"}),n&&!i&&d.jsx("span",{"aria-hidden":!0,className:_e("pointer-events-none absolute -right-1.5 -top-1.5 rounded-sm px-1 font-mono text-[8px] leading-[1.1]",o?"bg-primary-foreground/20 text-primary-foreground/85":"bg-foreground/10 text-muted-foreground"),children:n})]}),i?d.jsx("span",{className:"max-w-full truncate",children:t}):!s&&d.jsx("span",{children:t})]})})}function r2(){const e=y(r=>r.diagram.elements),t=y(r=>r.diagram.layout),n=y(r=>r.selection),o=t??{};return{hasAnyElement:e.length>0,hasArrangedAny:Object.keys(o).length>0,hasGapsAll:e.some(r=>!o[r.id]),hasSelection:n.length>0,selectionHasArranged:n.some(r=>!!o[r]),selectionHasGaps:n.some(r=>!o[r])}}function rE({iconOnly:e}){const t=le(),[n,o]=C.useState(!1),r=r2(),s=i=>()=>{o(!1),i()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:It,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:s(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:s(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function sE({stacked:e}){const t=le(),[n,o]=C.useState(!1),r=y(h=>h.past.length),s=y(h=>h.future.length),i=y(h=>h.undo),a=y(h=>h.redo),l=y(h=>h.selection.length>0),c=y(h=>h.clipboard!=null),u=r2(),f=h=>()=>{o(!1),h()};return d.jsxs(Po,{open:n,onOpenChange:o,trigger:d.jsx(pt,{icon:no,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(h=>!h)}),children:[d.jsx(Pe,{onClick:f(i),icon:d.jsx(Eo,{}),disabled:r===0,children:t("tool.undo")}),d.jsx(Pe,{onClick:f(a),icon:d.jsx(jo,{}),disabled:s===0,children:t("tool.redo")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().cutSelection()),icon:d.jsx(Ts,{}),disabled:!l,children:t("menu.cut")}),d.jsx(Pe,{onClick:f(()=>y.getState().copySelection()),icon:d.jsx(js,{}),disabled:!l,children:t("menu.copy")}),d.jsx(Pe,{onClick:f(()=>y.getState().pasteClipboard()),icon:d.jsx($s,{}),disabled:!c,children:t("menu.paste")}),d.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeAll()),icon:d.jsx(It,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().autoArrangeSelection()),icon:d.jsx(It,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedAll()),icon:d.jsx(pn,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),d.jsx(Pe,{onClick:f(()=>y.getState().fillUnplacedSelection()),icon:d.jsx(pn,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Pe({children:e,icon:t,onClick:n,disabled:o}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:_e("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",o&&"pointer-events-none text-muted-foreground opacity-60 hover:bg-transparent"),children:[t,d.jsx("span",{className:"flex-1",children:e})]})}function iE(){const e=Xt(r=>r.outlineOpen),t=Xt(r=>r.setOutlineOpen),n=rt();return Oe(n,"dense")?e?d.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px) + 0.75rem)"},children:d.jsx(cs,{onClose:()=>t(!1),sheet:!0})}):null:d.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?d.jsx(cs,{onClose:()=>t(!1)}):d.jsx(aE,{onClick:()=>t(!0)})})}function aE({onClick:e}){const t=le(),n=rt(),o=Oe(n,"compact");return d.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:_e("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",o?"w-12 justify-center":"gap-2 px-3"),children:[d.jsx(Ns,{className:"size-4 shrink-0"}),!o&&d.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function cs({onClose:e,sheet:t}){const n=le(),o=y(c=>c.diagram.elements),r=y(c=>c.activeTool==="place"),s=rt(),i=Oe(s,"compact"),a=Oe(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return d.jsxs("aside",{className:_e("ole-glass flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",t?"w-full":i?"w-52":"w-64"),style:{height:l},children:[d.jsxs("button",{type:"button",onClick:e,"aria-label":n("outline.collapseAria"),title:n("outline.collapse"),className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-muted/40",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&d.jsx(cE,{children:o.length}),d.jsx(W2,{className:"size-3.5 text-muted-foreground"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?d.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):d.jsx("ul",{className:"space-y-px",children:o.map(c=>d.jsx(lE,{element:c},c.id))})})]})}function lE({element:e}){const t=ot[e.kind],n=y(l=>l.selection.includes(e.id)),o=y(l=>l.setSelection),r=y(l=>l.toggleInSelection),s=rt(),i=!Oe(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return d.jsxs("li",{className:"group flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 hover:bg-accent data-[selected=true]:bg-[color-mix(in_oklch,var(--selection)_18%,transparent)]",title:e.note??`${e.name??e.id} (${e.kind})`,"data-element-id":e.id,"data-selected":n?"true":void 0,onClick:a,children:[d.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&d.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),d.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function cE({children:e}){return d.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const dE={"arc-suppression-coil.name":"消弧线圈","arrester.name":"避雷器 (FBL)","async-motor.name":"异步电动机","autotransformer.name":"自耦变压器","battery.name":"电池储能","breaker.name":"断路器 (QF)","busbar.name":"母线段","converter-bidir.name":"双向变流器 (PCS)","dc-dc-converter.name":"DC/DC 变换器","mppt.name":"MPPT 控制器","ct.name":"电流互感器 (CT)","disconnector.name":"隔离开关 (QS)","earth.name":"接地","earthing-switch.name":"接地刀闸 (QE)","fuse.name":"熔断器 (FU)","generator.name":"发电机 (G)","grid-source.name":"系统电源","grounding-transformer.name":"接地变 (Z形)","inverter.name":"逆变器 (DC→AC)","load-switch.name":"负荷开关","load.name":"负荷","panelboard.name":"配电箱","ngr.name":"中性点电阻 (NGR)","pt.name":"电压互感器 (PT)","pv.name":"光伏组件","rectifier.name":"整流器 (AC→DC)","series-reactor.name":"串联电抗器","shunt-capacitor.name":"并联电容器","shunt-reactor.name":"并联电抗器","sync-motor.name":"同步电动机","transformer-2w.name":"双绕组变压器","transformer-3w.name":"三绕组变压器","wind-turbine.name":"风力发电机","gfci-breaker.name":"GFCI 断路器 (RCBO)","rcd.name":"剩余电流装置 (RCD)","recloser.name":"重合闸 (Recloser)","energy-meter.name":"电能表 (Wh)","voltmeter.name":"电压表 (V)","ammeter.name":"电流表 (A)","wattmeter.name":"功率表 (W)","frequency-meter.name":"频率表 (Hz)","contactor.name":"接触器 (KM)","motor-starter.name":"电机启动器","thermal-overload.name":"热过载继电器","vfd.name":"变频器 (VFD)","soft-starter.name":"软启动器","transfer-switch.name":"切换开关 (ATS)","dc-disconnector.name":"直流隔离开关","dc-combiner.name":"直流汇流箱","ev-charger.name":"EV 充电桩","arc-suppression-coil.desc":"中性点谐振接地:电感线圈连接到地","busbar.desc":"可拉伸单母线段,多设备挂接","converter-bidir.desc":"储能变流器:双向 AC ↔ DC","dc-dc-converter.desc":"DC/DC 变换器 / 直流充电器(IEC 60617)","mppt.desc":"MPPT 太阳能充电控制器(DC/DC,最大功率点跟踪)","earthing-switch.desc":"隔离开关 + 接地连接,单端口","grid-source.desc":"无穷大母线 / 外部电网","grounding-transformer.desc":"星-曲折接线变压器,中性点接地用","load.desc":"抽象负荷(电流流出箭头)","panelboard.desc":"配电箱 / 负荷中心(IEC 分配中心符号):底部进线,箱顶分路示意","ngr.desc":"小电阻接地:连接变压器中性点到地","series-reactor.desc":"与并联电抗器同符号;通过用法区分","wind-turbine.desc":"风机:发电机 + 三叶轮标记","gfci-breaker.desc":"剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。","rcd.desc":"不带过流保护的剩余电流断路器 (IEC 61008)。","recloser.desc":"中压自动重合闸开关。","energy-meter.desc":"有功电能表 (kWh) — 服务入口 / 子表。","contactor.desc":"主回路接触器, 通常配热继电器和电机使用。","motor-starter.desc":"电机启动器 (IEC 60617 通用符号)。","thermal-overload.desc":"电机热过载保护继电器, 通常串接在接触器和电机之间。","vfd.desc":"Variable Frequency Drive — 异步电动机调速。","soft-starter.desc":"电机软启动器 (晶闸管降压启动)。","transfer-switch.desc":"双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。","dc-disconnector.desc":"DC 隔离开关 — 光伏组串 / 储能 直流侧隔离。","dc-combiner.desc":"光伏组串汇流箱 (4 路输入示例)。","ev-charger.desc":"电动汽车充电站 / 充电桩。","breaker.state.open":"断开","disconnector.state.open":"断开","earthing-switch.state.open":"断开","fuse.state.blown":"熔断","load-switch.state.open":"断开","gfci-breaker.state.open":"断开","rcd.state.open":"断开","recloser.state.open":"断开","contactor.state.open":"断开","thermal-overload.state.tripped":"动作","transfer-switch.state.position":"位置 (normal/emergency/off)","dc-disconnector.state.open":"断开","battery.param.E":"容量","busbar.param.Un":"额定电压","converter-bidir.param.S":"容量","dc-dc-converter.param.P":"功率","mppt.param.I":"额定电流","load.param.P":"有功功率","load.param.cosphi":"功率因数","ngr.param.R":"电阻","shunt-capacitor.param.Q":"无功容量","shunt-capacitor.param.stages":"分组数","transformer-2w.param.S":"容量","transformer-2w.param.ratio":"变比","gfci-breaker.param.In":"额定电流","gfci-breaker.param.IDn":"剩余动作电流","rcd.param.IDn":"剩余动作电流"},uE={"arc-suppression-coil.name":"Arc-suppression coil","arrester.name":"Surge arrester (FBL)","async-motor.name":"Asynchronous motor","autotransformer.name":"Autotransformer","battery.name":"Battery storage","breaker.name":"Circuit breaker (QF)","busbar.name":"Busbar segment","converter-bidir.name":"Bidirectional converter (PCS)","dc-dc-converter.name":"DC/DC converter","mppt.name":"MPPT controller","ct.name":"Current transformer (CT)","disconnector.name":"Disconnector (QS)","earth.name":"Earth","earthing-switch.name":"Earthing switch (QE)","fuse.name":"Fuse (FU)","generator.name":"Generator (G)","grid-source.name":"Grid source","grounding-transformer.name":"Grounding transformer (zig-zag)","inverter.name":"Inverter (DC→AC)","load-switch.name":"Load break switch","load.name":"Load","panelboard.name":"Panelboard / load center","ngr.name":"Neutral grounding resistor (NGR)","pt.name":"Voltage transformer (PT)","pv.name":"PV module","rectifier.name":"Rectifier (AC→DC)","series-reactor.name":"Series reactor","shunt-capacitor.name":"Shunt capacitor","shunt-reactor.name":"Shunt reactor","sync-motor.name":"Synchronous motor","transformer-2w.name":"Two-winding transformer","transformer-3w.name":"Three-winding transformer","wind-turbine.name":"Wind turbine","gfci-breaker.name":"GFCI breaker (RCBO)","rcd.name":"Residual current device (RCD)","recloser.name":"Recloser","energy-meter.name":"Energy meter (Wh)","voltmeter.name":"Voltmeter (V)","ammeter.name":"Ammeter (A)","wattmeter.name":"Wattmeter (W)","frequency-meter.name":"Frequency meter (Hz)","contactor.name":"Contactor (KM)","motor-starter.name":"Motor starter","thermal-overload.name":"Thermal overload relay","vfd.name":"Variable frequency drive (VFD)","soft-starter.name":"Soft starter","transfer-switch.name":"Transfer switch (ATS)","dc-disconnector.name":"DC disconnector","dc-combiner.name":"DC combiner box","ev-charger.name":"EV charger","arc-suppression-coil.desc":"Resonant neutral grounding: inductor to earth","busbar.desc":"Stretchable single-bus segment with multiple taps","converter-bidir.desc":"Storage converter: bidirectional AC ↔ DC","dc-dc-converter.desc":"DC/DC converter / DC charger (IEC 60617)","mppt.desc":"MPPT solar charge controller (DC/DC, maximum power point tracking)","earthing-switch.desc":"Disconnector + earth connection, single port","grid-source.desc":"Infinite bus / external grid","grounding-transformer.desc":"Wye-zigzag transformer for neutral grounding","load.desc":"Abstract load (current-out arrow)","ngr.desc":"Low-resistance grounding: transformer neutral to earth","series-reactor.desc":"Same symbol as shunt reactor; distinguished by usage","wind-turbine.desc":"Wind turbine: generator + three-blade rotor mark","gfci-breaker.desc":"Residual-current breaker with overcurrent (UL943 / IEC 61009). NA GFCI / EU RCBO.","rcd.desc":"Residual-current breaker without overcurrent (IEC 61008).","recloser.desc":"Medium-voltage automatic recloser.","energy-meter.desc":"Active energy meter (kWh) — service entrance / submeter.","contactor.desc":"Main-circuit contactor; typically used with a thermal overload and a motor.","motor-starter.desc":"Motor starter (IEC 60617 general symbol).","thermal-overload.desc":"Motor thermal-overload relay; sits between the contactor and the motor.","vfd.desc":"Variable Frequency Drive for induction motor speed control.","soft-starter.desc":"Motor soft-starter (thyristor-based reduced-voltage starting).","transfer-switch.desc":"Two-source transfer switch (ATS / manual). Two source inputs + one load output, mechanically interlocked.","dc-disconnector.desc":"DC isolating switch — PV string / battery DC-side isolation.","dc-combiner.desc":"PV string combiner box (4-input example).","ev-charger.desc":"Electric vehicle charging station.","breaker.state.open":"Open","disconnector.state.open":"Open","earthing-switch.state.open":"Open","fuse.state.blown":"Blown","load-switch.state.open":"Open","gfci-breaker.state.open":"Open","rcd.state.open":"Open","recloser.state.open":"Open","contactor.state.open":"Open","thermal-overload.state.tripped":"Tripped","transfer-switch.state.position":"Position (normal/emergency/off)","dc-disconnector.state.open":"Open","battery.param.E":"Capacity","busbar.param.Un":"Rated voltage","converter-bidir.param.S":"Capacity","dc-dc-converter.param.P":"Power","mppt.param.I":"Rated current","load.param.P":"Active power","load.param.cosphi":"Power factor","ngr.param.R":"Resistance","shunt-capacitor.param.Q":"Reactive capacity","shunt-capacitor.param.stages":"Stages","transformer-2w.param.S":"Capacity","transformer-2w.param.ratio":"Ratio","gfci-breaker.param.In":"Rated current","gfci-breaker.param.IDn":"Residual operating current","rcd.param.IDn":"Residual operating current","resistor.name":"Resistor (R)","capacitor.name":"Capacitor (C)","diode.name":"Diode (D)","indicator-light.name":"Indicator light (HL)","push-button.name":"Push-button (SB)","relay-coil.name":"Relay coil (KA)","make-contact.name":"NO contact (NO)","break-contact.name":"NC contact (NC)","bell.name":"Bell (HA)","terminal.name":"Terminal / junction (X)","fuse-switch-disconnector.name":"Fuse switch-disconnector","socket-outlet.name":"Socket outlet / connector","inductor.name":"Inductor (L)","voltage-regulator.name":"Voltage regulator (T)","dc-motor.name":"DC motor (M)","heater.name":"Heating element (EH)","selector-switch.name":"Selector switch (SA)","limit-switch.name":"Limit switch (SQ)","proximity-switch.name":"Proximity switch (SQ)","time-relay.name":"Time relay (KT)","buzzer.name":"Buzzer (HA)","siren.name":"Siren (HA)","thermocouple.name":"Thermocouple (BT)","thyristor.name":"Thyristor / SCR (V)","triac.name":"Triac (V)","zener-diode.name":"Zener diode (D)","igbt.name":"IGBT","plc.name":"PLC / controller","ups.name":"UPS","power-supply.name":"Power supply (PS)","genset.name":"Generator set (G)","protective-relay.name":"Protective relay","overcurrent-relay.name":"Overcurrent relay (50/51)","undervoltage-relay.name":"Undervoltage relay (27)","reverse-power-relay.name":"Reverse-power relay (32)","distance-relay.name":"Distance relay (21)","phase-failure-relay.name":"Phase-failure relay","buchholz-relay.name":"Buchholz relay (63)","power-factor-meter.name":"Power-factor meter (cosφ)","synchronoscope.name":"Synchronoscope","varmeter.name":"Varmeter (var)","resistor.desc":"General resistor / current-limiting / braking resistor.","capacitor.desc":"General / filter / DC-bus capacitor. Use shunt capacitor for PF correction.","diode.desc":"Rectifier / freewheeling / protection diode. t1 = anode (top), t2 = cathode (bottom).","indicator-light.desc":"Signal / status indicator light.","push-button.desc":"Manual push-button, automatic return (NO make).","relay-coil.desc":"Relay / contactor operating coil (box).","make-contact.desc":"Normally-open auxiliary contact (make).","break-contact.desc":"Normally-closed auxiliary contact (break).","bell.desc":"Signal bell / alarm bell.","terminal.desc":"Terminal / junction box / connection node.","fuse-switch-disconnector.desc":"On-load fuse switch-disconnector.","socket-outlet.desc":"Power socket outlet / multipole connector.","inductor.desc":"General inductor / coil / choke.","voltage-regulator.desc":"Adjustable induction / autotransformer voltage regulator.","dc-motor.desc":"DC motor (series-field general symbol).","heater.desc":"Resistive heating element / heating load.","selector-switch.desc":"Selector / changeover switch (rotary, stay-put).","limit-switch.desc":"Travel / position switch (NO, mechanically operated).","proximity-switch.desc":"Proximity sensor / contactless proximity switch.","time-relay.desc":"Time-delay (slow-operating) relay coil.","buzzer.desc":"Signal buzzer.","siren.desc":"Audible siren / alarm.","thermocouple.desc":"Thermocouple temperature sensor.","thyristor.desc":"Reverse-blocking triode thyristor / SCR. t1 = anode (top), t2 = cathode (bottom).","triac.desc":"Bidirectional triode thyristor (TRIAC).","zener-diode.desc":"Zener / voltage-regulator diode. t1 = anode (top), t2 = cathode (bottom).","igbt.desc":"N-channel enhancement IGBT. t1 = collector (top), t2 = emitter (bottom), t_g = gate.","plc.desc":"Programmable logic controller (PLC).","ups.desc":"Online / standby uninterruptible power supply.","power-supply.desc":"AC→DC switched-mode / DC power supply. t_ac top (~), t_dc bottom (=).","genset.desc":"Diesel / gas generator set.","protective-relay.desc":"Measuring / protective relay, general symbol (IEC 60617).","overcurrent-relay.desc":"Overcurrent protection relay (ANSI 50/51).","undervoltage-relay.desc":"Undervoltage protection relay (ANSI 27).","reverse-power-relay.desc":"Reverse-power / reverse-current protection relay (ANSI 32).","distance-relay.desc":"Distance / under-impedance protection relay (ANSI 21).","phase-failure-relay.desc":"Phase-failure / phase-loss protection relay.","buchholz-relay.desc":"Buchholz / gas relay (ANSI 63).","power-factor-meter.desc":"Power-factor meter (cosφ).","synchronoscope.desc":"Synchronizing indicator / synchronoscope.","varmeter.desc":"Reactive-power meter (var).","make-contact.state.closed":"Closed","break-contact.state.open":"Open","fuse-switch-disconnector.state.open":"Open","selector-switch.state.open":"Open","limit-switch.state.closed":"Closed","resistor.param.R":"Resistance","resistor.param.P":"Rated power","capacitor.param.C":"Capacitance","capacitor.param.Un":"Rated voltage","indicator-light.param.color":"Color","inductor.param.L":"Inductance","inductor.param.In":"Rated current","voltage-regulator.param.ratio":"Regulation range","heater.param.P":"Power","ups.param.S":"Capacity","power-supply.param.Vdc":"Output voltage","genset.param.P":"Power"},ds={zh:dE,en:uE};function fE(e,t){return ds[e][t]??ds.zh[t]}function Jt(){const e=Yt(t=>t.locale);return(t,n)=>fE(e,t)??n??t}const s2="ole-palette-collapsed",hE=new Set(["busbar"]),zt=(()=>{const e={};for(const[t,n]of Object.entries(fj)){const o=n.filter(r=>!hE.has(r.id));o.length&&(e[t]=o)}return e})(),mE=(()=>{const e=new Set(vr),t=Object.keys(zt).filter(n=>!e.has(n));return[...vr.filter(n=>{var o;return(o=zt[n])==null?void 0:o.length}),...t]})();function pE(){try{const e=window.localStorage.getItem(s2);if(!e)return new Set;const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string")):new Set}catch{return new Set}}function gE(e){try{window.localStorage.setItem(s2,JSON.stringify([...e]))}catch{}}function yE(){const e=le(),t=y(f=>f.activeTool==="place"),n=y(f=>f.placeKind),o=y(f=>f.setActiveTool),r=Xt(f=>f.outlineOpen),s=rt(),i=Oe(s,"dense"),a=68,c=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const u=i?{top:`calc(${a}px + var(--ole-top-inset, 0px) + var(--ole-safe-top, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px) + var(--ole-safe-left, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + var(--ole-safe-bottom, 0px) + 0.75rem)"}:{top:a};return d.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:d.jsxs("aside",{className:i?"ole-glass flex h-full w-full flex-col overflow-hidden rounded-2xl border border-border shadow-md":"ole-glass flex w-72 flex-col overflow-hidden rounded-2xl border border-border shadow-md",style:c?{maxHeight:c}:void 0,children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),d.jsx("button",{type:"button",onClick:()=>o(i?"pan":"select"),className:"rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground","aria-label":e("common.close"),title:e("common.close"),children:d.jsx(Sn,{className:"size-3.5"})})]}),d.jsx(xE,{sheet:i})]})})}function xE({sheet:e}){const t=le(),n=Jt(),[o,r]=C.useState(""),[s,i]=C.useState(()=>pE()),a=C.useMemo(()=>{const f=o.trim().toLowerCase();if(!f)return zt;const h={};for(const[g,m]of Object.entries(zt)){const p=m.filter(x=>{const w=n(`${x.id}.name`,x.name).toLowerCase(),v=n(`${x.id}.desc`,x.description??"").toLowerCase();return w.includes(f)||x.id.toLowerCase().includes(f)||v.includes(f)});p.length&&(h[g]=p)}return h},[o,n]),l=o.trim().length>0,c=l&&Object.values(a).every(f=>!(f!=null&&f.length)),u=C.useCallback((f,h)=>{i(g=>{const m=new Set(g);return h?m.delete(f):m.add(f),gE(m),m})},[]);return d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"px-2 pb-1.5 pt-2",children:d.jsx(bE,{value:o,onChange:r})}),d.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:c?d.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):mE.map(f=>{var x;const h=a[f];if(!(h!=null&&h.length))return null;const g=((x=zt[f])==null?void 0:x.length)??h.length,m=t(`cat.${f}`),p=l||!s.has(f);return d.jsxs("details",{open:p,className:"group mb-2 last:mb-0",onToggle:w=>{l||u(f,w.currentTarget.open)},children:[d.jsxs("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:[d.jsx(C2,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),d.jsx("span",{className:"flex-1",children:m}),d.jsx(vE,{children:l&&h.length!==g?`${h.length}/${g}`:g})]}),d.jsx("ul",{className:"mt-0.5 space-y-px",children:h.map(w=>d.jsx(wE,{entry:w,sheet:e},w.id))})]},f)})})]})}function bE({value:e,onChange:t}){const n=le();return d.jsxs("div",{className:"relative",children:[d.jsx(X2,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),d.jsx("input",{type:"text",value:e,onChange:o=>t(o.target.value),placeholder:n("library.searchPlaceholder"),className:"h-7 w-full rounded-md border border-border/60 bg-background/50 pl-7 pr-7 text-xs placeholder:text-muted-foreground focus:border-border focus:outline-none focus:ring-1 focus:ring-ring","aria-label":n("library.searchAria")}),e&&d.jsx("button",{type:"button","aria-label":n("library.clearSearch"),onClick:()=>t(""),className:"absolute right-1 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Sn,{className:"size-3"})})]})}function wE({entry:e,sheet:t}){const n=le(),o=Jt(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=y(f=>f.setActiveTool),a=y(f=>f.activeTool==="place"&&f.placeKind===e.id),l=y(f=>t&&f.activeTool==="place"&&f.placeKind==null&&f.lastPlaceKind===e.id),c=C.useRef(null);C.useEffect(()=>{var f;l&&((f=c.current)==null||f.scrollIntoView({block:"nearest"}))},[l]);const u=f=>{f.dataTransfer.effectAllowed="copy",f.dataTransfer.setData("application/x-oneline-kind",e.id),f.dataTransfer.setData("text/plain",e.id);const h=document.createElement("div");h.className="ole-glass",h.style.cssText=["position:absolute","top:-9999px","left:-9999px","width:64px","height:64px","display:flex","align-items:center","justify-content:center","border-radius:12px","border:1px solid var(--border)","box-shadow:0 4px 12px rgba(0,0,0,0.12)","color:var(--foreground)","padding:8px"].join(";"),h.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(h),f.dataTransfer.setDragImage(h,32,32),setTimeout(()=>h.remove(),0)};return d.jsxs("li",{ref:c,className:`group flex cursor-grab items-center gap-2.5 rounded-md px-2 py-1.5 transition-colors hover:bg-accent active:cursor-grabbing ${a?"bg-accent ring-1 ring-[var(--selection)]/60":l?"ring-1 ring-[var(--selection)]/30":""}`,draggable:!0,onDragStart:u,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[d.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:d.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),d.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function vE({children:e}){return d.jsx("span",{className:"rounded bg-muted/50 px-1.5 py-0.5 font-mono text-[10px] tabular-nums text-muted-foreground/80",children:e})}const _o="ole-onboarding-dismissed";function kE(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(_o)==="1"}catch{return!1}}function us(e){try{e?window.localStorage.setItem(_o,"1"):window.localStorage.removeItem(_o)}catch{}}const fs=$n(e=>({dismissed:kE(),dismiss:()=>{us(!0),e({dismissed:!0})},reset:()=>{us(!1),e({dismissed:!1})}}));function _E(){const e=le(),t=fs(o=>o.dismissed),n=fs(o=>o.dismiss);return t?null:d.jsxs("div",{role:"dialog","aria-label":e("onboard.title"),className:"ole-glass pointer-events-none absolute left-1/2 top-1/2 z-10 w-[min(420px,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-2xl border border-border p-5 shadow-md",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),d.jsx("button",{type:"button",onClick:n,"aria-label":e("onboard.dismiss"),className:"pointer-events-auto rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground",children:d.jsx(Sn,{className:"size-3.5"})})]}),d.jsxs("ol",{className:"mt-3 space-y-2.5",children:[d.jsx(Qn,{n:1,icon:d.jsx(Ms,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),d.jsx(Qn,{n:2,icon:d.jsx(Ss,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),d.jsx(Qn,{n:3,icon:d.jsx($o,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),d.jsx("button",{type:"button",onClick:n,className:"pointer-events-auto mt-4 w-full rounded-md bg-primary py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e("onboard.dismiss")})]})}function Qn({n:e,icon:t,title:n,body:o}){return d.jsxs("li",{className:"flex items-start gap-2.5",children:[d.jsx("span",{className:"mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full bg-[color-mix(in_oklch,var(--selection)_18%,transparent)] font-mono text-[10px] font-semibold tabular-nums text-[var(--selection)]","aria-hidden":!0,children:e}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[d.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),d.jsx("span",{children:n})]}),d.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function SE(){const e=le(),t=y(g=>g.selection),n=y(g=>g.diagram.elements),o=y(g=>g.diagram.buses),r=y(g=>g.diagram.junctions),s=y(g=>g.selectedNode),i=y(g=>g.selectedWire),a=y(g=>g.selectedAnnotation);if(i)return d.jsx(BE,{wireId:i});if(s)return d.jsx(LE,{nodeId:s});if(a)return d.jsx(TE,{annId:a});if(t.length===0)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const l=t[0],c=(o??[]).find(g=>g.id===l);if(c)return d.jsx(NE,{bus:c});const u=(r??[]).find(g=>g.id===l);if(u)return d.jsx(DE,{junction:u});const f=n.find(g=>g.id===l);if(!f)return null;const h=ot[f.kind];return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(Ke,{label:e("props.name"),value:f.name??"",placeholder:f.id,onCommit:g=>y.getState().updateElement(l,{name:g.trim()===""?void 0:g.trim()})}),d.jsx(Oo,{label:e("props.note"),value:f.note??"",onCommit:g=>y.getState().updateElement(l,{note:g.trim()===""?void 0:g.trim()})},l),(h==null?void 0:h.state)&&h.state.length>0&&d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:h.state.map(g=>d.jsx(RE,{id:l,element:f,field:g},g.name))}),d.jsx($E,{id:l,element:f,schema:(h==null?void 0:h.params)??[]})]})}function $E({id:e,element:t,schema:n}){const o=new Set(n.map(s=>s.name)),r=t.params?Object.entries(t.params).filter(([s])=>!o.has(s)):[];return n.length===0&&r.length===0?null:d.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>d.jsx(jE,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>d.jsx(EE,{id:e,element:t,fieldKey:s,value:i},s))]})}function jE({id:e,element:t,field:n}){var l;const o=le(),r=Jt(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=c=>{const u={...t.params??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:i,children:d.jsx(Bo,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?d.jsx(Cn,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):d.jsx(Ke,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:c=>a(c.trim()===""?void 0:c)})}function EE({id:e,element:t,fieldKey:n,value:o}){const r=le(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,y.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?d.jsx(st,{label:n,children:d.jsx(Bo,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?d.jsx(Cn,{label:n,value:o,onCommit:s}):d.jsx(Ke,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function NE({bus:e}){const t=le(),n=e.id,o=r=>{const s=r.trim();So(n,{name:s===""?void 0:s})};return d.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[d.jsx(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:r=>So(n,{note:r.trim()===""?void 0:r.trim()})},n),d.jsx(AE,{bus:e})]})}function AE({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,So(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return d.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.jsx(Cn,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function So(e,t){y.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function TE({annId:e}){const t=le(),n=y(r=>(r.diagram.annotations??[]).find(s=>s.id===e));if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.annNotFound",{id:e})});const o=r=>y.getState().updateAnnotation(e,r);switch(De(n)){case"rect":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(Ke,{label:t("props.annLabel"),value:r.label??"",placeholder:t("props.annLabelPlaceholder"),onCommit:s=>o({label:s.trim()===""?void 0:s.trim()})}),d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"dashed",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annFill"),value:r.fill??"none",options:[{value:"none",label:t("props.annFillNone")},{value:"tint",label:t("props.annFillTint")}],onChange:s=>o({fill:s==="none"?void 0:s})})]})}case"line":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(dn,{label:t("props.annStroke"),value:r.stroke??"solid",options:[{value:"solid",label:t("props.annStrokeSolid")},{value:"dashed",label:t("props.annStrokeDashed")}],onChange:s=>o({stroke:s})}),d.jsx(dn,{label:t("props.annArrow"),value:r.arrow??"none",options:[{value:"none",label:t("props.annArrowNone")},{value:"end",label:t("props.annArrowEnd")},{value:"both",label:t("props.annArrowBoth")}],onChange:s=>o({arrow:s==="none"?void 0:s})})]})}case"table":{const r=n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsx(hs,{label:t("props.annRows"),value:r.rowHeights.length,min:1,onChange:s=>o(ME(r,s))}),d.jsx(hs,{label:t("props.annCols"),value:r.colWidths.length,min:1,onChange:s=>o(CE(r,s))}),d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})]})}default:{const r=n;return d.jsx("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:d.jsx(ms,{label:t("props.annFontSize"),value:r.fontSize,onCommit:s=>o({fontSize:s})})})}}}function ME(e,t){const n=e.colWidths.length,o=e.rowHeights[e.rowHeights.length-1]??Wt,r=e.rowHeights.slice(0,t);for(;r.length<t;)r.push(o);const s=e.cells.slice(0,t).map(i=>[...i]);for(;s.length<t;)s.push(Cv(n,1).cells[0]);return{rowHeights:r,cells:s}}function CE(e,t){const n=e.colWidths[e.colWidths.length-1]??Ht,o=e.colWidths.slice(0,t);for(;o.length<t;)o.push(n);const r=e.cells.map(s=>{const i=s.slice(0,t);for(;i.length<t;)i.push("");return i});return{colWidths:o,cells:r}}function dn({label:e,value:t,options:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsx("div",{className:"flex overflow-hidden rounded-md border border-border/60",children:n.map(r=>d.jsx("button",{type:"button","aria-pressed":t===r.value,onClick:()=>o(r.value),className:_e("h-7 flex-1 truncate px-1.5 text-[11px] transition-colors",t===r.value?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:r.label},r.value))})})}function hs({label:e,value:t,min:n,onChange:o}){return d.jsx(st,{label:e,children:d.jsxs("div",{className:"flex items-center gap-1",children:[d.jsx("button",{type:"button","aria-label":`${e} −`,disabled:t<=n,onClick:()=>o(t-1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent disabled:pointer-events-none disabled:opacity-40",children:"−"}),d.jsx("span",{className:"w-8 text-center font-mono text-[11px] tabular-nums",children:t}),d.jsx("button",{type:"button","aria-label":`${e} +`,onClick:()=>o(t+1),className:"h-7 w-7 rounded-md border border-border/60 text-[13px] leading-none text-muted-foreground hover:bg-accent",children:"+"})]})})}const PE=5,IE=32,OE=8;function ms({label:e,value:t,onCommit:n}){return d.jsx(Ke,{label:e,value:t!=null?String(t):"",placeholder:String(OE),unit:"px",onCommit:o=>{const r=o.trim();if(r===""){n(void 0);return}const s=Number(r);Number.isFinite(s)&&n(Math.min(IE,Math.max(PE,Math.round(s))))}})}function BE({wireId:e}){const t=le(),n=y(x=>x.diagram.wires),o=y(x=>x.diagram.elements),r=y(x=>x.diagram.buses),s=y(x=>x.diagram.junctions),i=y(x=>x.internal.terminalToNode),a=y(x=>x.setSelectedNode),l=(n??[]).find(x=>x.id===e);if(!l)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const c=i.get(l.ends[0]),u=new Map(o.map(x=>[x.id,x])),f=new Map((r??[]).map(x=>[x.id,x])),h=new Map((s??[]).map(x=>[x.id,x])),g=x=>{if(!x.includes(".")){const F=f.get(x);if(F)return{id:x,label:F.name??x};const G=h.get(x);return{id:x,label:(G==null?void 0:G.name)??x}}const w=x.indexOf("."),v=x.slice(0,w),M=x.slice(w+1),I=u.get(v);return{id:v,label:(I==null?void 0:I.name)??v,pin:M}},m=g(l.ends[0]),p=g(l.ends[1]);return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),d.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),d.jsx(Ke,{label:t("props.label"),value:l.label??"",placeholder:t("props.labelPlaceholder"),onCommit:x=>y.getState().updateWire(e,{label:x.trim()===""?void 0:x.trim()})}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[m,p].map((x,w)=>d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>y.getState().setSelection([x.id]),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:x.id}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:x.label}),x.pin&&d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:x.pin})]},w))}),c&&d.jsx("button",{type:"button",className:"self-start rounded-md border border-border/60 px-2 py-1 text-[11px] text-muted-foreground hover:bg-accent",onClick:()=>a(c),children:t("props.selectWholeNode")})]})}function DE({junction:e}){var r;const t=le(),n=y(s=>{var i;return(i=s.internal.junctions.get(e.id))==null?void 0:i.world}),o=((r=e.layout)==null?void 0:r.at)??n;return d.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),d.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),d.jsx(Ke,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>y.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),d.jsx(Oo,{label:t("props.note"),value:e.note??"",onCommit:s=>y.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})},e.id),o&&d.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[d.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),d.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function LE({nodeId:e}){const t=le(),n=y(a=>a.internal.nodes.get(e)),o=y(a=>a.diagram.elements),r=y(a=>a.setSelection);if(!n)return d.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.nodeNotFound",{id:e})});const s=new Map;for(const a of n.terminals){const l=a.indexOf(".");if(l<0)continue;const c=a.slice(0,l),u=a.slice(l+1),f=s.get(c)??[];f.push(u),s.set(c,f)}const i=new Map(o.map(a=>[a.id,a]));return d.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[d.jsxs("div",{className:"space-y-1",children:[d.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),d.jsx("div",{className:"font-mono text-[12px]",children:n.id}),d.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),d.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const c=i.get(a);return d.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>r([a]),title:t("props.selectElement",{label:a}),children:[d.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),d.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(c==null?void 0:c.name)??""}),d.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function st({label:e,children:t}){return d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),d.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Ke({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=C.useState(t),a=C.useRef(null);return C.useEffect(()=>i(t),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:_e("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",o&&"pr-8")}),o&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}const zE=350;function Oo({label:e,value:t,onCommit:n}){const[o,r]=C.useState(t),s=C.useRef(!1),i=C.useRef(null),a=C.useRef({local:o,value:t,onCommit:n});a.current={local:o,value:t,onCommit:n};const l=C.useRef(null);C.useEffect(()=>{s.current||(r(t),l.current=null)},[t]);const c=()=>{i.current!==null&&(window.clearTimeout(i.current),i.current=null);const f=a.current;f.local===f.value||f.local===l.current||(l.current=f.local,f.onCommit(f.local))},u=C.useRef(c);return u.current=c,C.useEffect(()=>()=>u.current(),[]),d.jsx(st,{label:e,children:d.jsx("textarea",{rows:2,value:o,onFocus:()=>{s.current=!0},onChange:f=>{r(f.target.value),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{i.current=null,u.current()},zE)},onBlur:()=>{s.current=!1,c()},className:"w-full resize-none rounded-md border border-border/60 bg-background/50 px-2 py-1 text-[11px] focus:border-border focus:outline-none focus:ring-1 focus:ring-ring"})})}function Cn({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=C.useState(String(t)),a=C.useRef(null);return C.useEffect(()=>i(String(t)),[t]),d.jsx(st,{label:e,children:d.jsxs("div",{className:"relative",children:[d.jsx("input",{ref:a,type:"number",value:s,onChange:l=>i(l.target.value),onBlur:()=>{const l=Number(s);Number.isFinite(l)&&l!==t?r(l):i(String(t))},onKeyDown:l=>{var c,u;l.key==="Enter"&&((c=a.current)==null||c.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:_e("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",o&&"pr-8")}),o&&d.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Bo({active:e,onClick:t,children:n}){return d.jsx("button",{type:"button",onClick:t,className:_e("flex h-6 w-full items-center justify-center gap-1.5 rounded border text-[10px] transition-colors",e?"border-[var(--selection)] bg-[var(--selection)]/15 text-foreground":"border-border/60 text-muted-foreground hover:bg-accent"),"aria-pressed":e,children:n})}function RE({id:e,element:t,field:n}){var l;const o=le(),s=Jt()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=c=>{const u={...t.state??{}};c===void 0||c===n.default?delete u[n.name]:u[n.name]=c,y.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?d.jsx(st,{label:s,children:d.jsx(Bo,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?d.jsx(Cn,{label:s,value:typeof i=="number"?i:0,onCommit:a}):d.jsx(Ke,{label:s,value:typeof i=="string"?i:"",onCommit:c=>a(c.trim()===""?void 0:c)})}function FE(){const e=le(),t=Jt(),n=y(g=>g.selection),o=y(g=>g.selectedNode),r=y(g=>g.selectedWire),s=y(g=>g.selectedAnnotation),i=y(g=>g.diagram.annotations),a=y(g=>g.diagram.elements),l=y(g=>g.diagram.buses),c=rt(),u=Oe(c,"dense");if(n.length===0&&!o&&!r&&!s)return null;let f=e("props.title"),h=null;if(r)f=e("props.wire");else if(o)f=e("props.node");else if(s){const g=(i??[]).find(p=>p.id===s),m=g?De(g):"text";f=e(m==="rect"?"props.annRect":m==="line"?"props.annLine":m==="table"?"props.annTable":"props.annText")}else if(n.length===1){const g=n[0],m=(l??[]).find(p=>p.id===g);if(m)f=m.name??e("props.bus");else{const p=a.find(x=>x.id===g);if(p){const x=ot[p.kind];f=x?t(`${x.id}.name`,x.name):p.kind}}}else h=n.length;return d.jsxs("aside",{className:_e("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",u?"w-48":"w-56"),style:{top:`calc(${u?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px) + var(--ole-safe-top, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px) + var(--ole-safe-right, 0px))",maxHeight:`calc(100% - ${u?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-safe-top, 0px) - var(--ole-bottom-inset, 0px) - var(--ole-safe-bottom, 0px) - 4.5rem)`},children:[d.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[d.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:f}),h!=null&&d.jsx("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})})]}),d.jsx(SE,{})]})}function HE(){C.useEffect(()=>{const e=n=>{const o=n.target;if(!o||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.isContentEditable)return;const r=o.closest("button");r&&r.closest(".ole-glass")&&n.preventDefault()},t=n=>{const o=n.target;if(!o||!o.closest(".ole-canvas-root"))return;const r=document.activeElement;!r||r===document.body||r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable||r.blur()};return window.addEventListener("mousedown",e),window.addEventListener("pointerdown",t,!0),()=>{window.removeEventListener("mousedown",e),window.removeEventListener("pointerdown",t,!0)}},[])}function WE(){HE();const e=y(o=>o.readOnly),t=C.useRef(null),n=V4(t);return d.jsx(Tk,{children:d.jsx("div",{ref:t,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:d.jsxs(E6,{width:n,children:[d.jsx(x6,{}),e?d.jsxs(d.Fragment,{children:[d.jsx(as,{}),d.jsx(Qr,{})]}):d.jsxs(d.Fragment,{children:[d.jsx(iE,{}),d.jsx(FE,{}),d.jsx(nE,{}),d.jsx(as,{}),d.jsx(H6,{}),d.jsx(q6,{}),d.jsx(yE,{}),d.jsx(_E,{}),d.jsx(Qr,{})]})]})})})}const qE="ole-theme";function XE(){try{const e=window.localStorage.getItem(qE);return e==="light"||e==="dark"?e:null}catch{return null}}function YE(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function GE(){return typeof window>"u"?"light":XE()??(YE()?"dark":"light")}function i2(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function KE({className:e,diagram:t,readOnly:n,locale:o,theme:r}){return C.useEffect(()=>{y.getState().setReadOnly(!!n)},[n]),C.useEffect(()=>{if(!t)return;if(n){y.getState().setDiagram(t),y.getState().setActiveTool("pan");return}y.getState().diagram.elements.length===0&&y.getState().setDiagram(t)},[t,n]),C.useEffect(()=>{o&&Yt.getState().setLocale(o)},[o]),C.useEffect(()=>{r&&i2(r)},[r]),C.useEffect(()=>{Co()},[]),C4(),d.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:d.jsx(WE,{})})}const a2={"application/json":[".json"]},l2=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",c2=e=>e instanceof DOMException&&e.name==="AbortError";function ps(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(ve("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(ve("io.notObject"));const n=t;if(n.version!=="1")throw new Error(ve("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(ve("io.elementsMissing"));return n}function UE(e){return JSON.stringify(e,null,2)+`
220
+ `}async function VE(){if(l2()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:ve("topbar.file.fileDescription"),accept:a2}]})}catch(n){if(c2(n))return null;throw n}const t=await e.getFile();return{diagram:ps(await t.text()),session:{handle:e,name:t.name}}}return new Promise((e,t)=>{const n=document.createElement("input");n.type="file",n.accept=".json,application/json",n.addEventListener("change",async()=>{var r;const o=(r=n.files)==null?void 0:r[0];if(!o)return e(null);try{e({diagram:ps(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function gs(e,t,n={}){const o=UE(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(l2()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:ve("topbar.file.fileDescription"),accept:a2}]})}catch(l){if(c2(l))return null;throw l}const a=await i.createWritable();return await a.write(o),await a.close(),{handle:i,name:i.name}}const r=URL.createObjectURL(new Blob([o],{type:"application/json"})),s=document.createElement("a");return s.href=r,s.download=(t==null?void 0:t.name)??"diagram.json",s.click(),URL.revokeObjectURL(r),t??{name:"diagram.json"}}function JE(){const e=le(),t=y(f=>f.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=ZE(),[a,l]=C.useState(!1),c=C.useRef(null);C.useEffect(()=>{const f=h=>{if(!(h.metaKey||h.ctrlKey))return;const g=h.key.toLowerCase();g==="o"?(h.preventDefault(),r()):g==="s"&&(h.preventDefault(),h.shiftKey?i():s())};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r,s,i]),C.useEffect(()=>{if(!a)return;const f=g=>{c.current&&!c.current.contains(g.target)&&l(!1)},h=g=>{g.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",h)}},[a]);const u=f=>()=>{l(!1),f()};return d.jsxs("div",{ref:c,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(f=>!f),children:[d.jsx(rr,{}),e("topbar.file.label")]}),a&&d.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-44 rounded-md border border-border p-1 shadow-md",children:[d.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),d.jsx(un,{onClick:u(o),icon:d.jsx(D2,{}),children:e("topbar.file.new")}),d.jsx(un,{onClick:u(r),icon:d.jsx(rr,{}),hint:"⌘O",children:e("topbar.file.open")}),d.jsx(un,{onClick:u(s),icon:d.jsx(sr,{}),hint:"⌘S",children:e("topbar.file.save")}),d.jsx(un,{onClick:u(i),icon:d.jsx(sr,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function un({children:e,icon:t,hint:n,onClick:o}){return d.jsxs("button",{type:"button",role:"menuitem",onClick:o,className:"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",children:[t,d.jsx("span",{className:"flex-1",children:e}),n&&d.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function ZE(){const e=le(),t=y(l=>l.loadDiagramFromFile),n=y(l=>l.setFileSession),o=y(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=y.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await VE();l&&(t(l.diagram,l.session),Co())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c);u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:c}=y.getState(),u=await gs(l,c,{saveAs:!0});u&&n(u)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const eo="WIRES",Ue="ELEMENTS",to="LABELS",Le="ANNOTATIONS",ys=32,xs=64,QE=8,eN=1.25,tN=6;function d2(e,t={}){var r,s;const n=new mN(t.precision??6);n.header(t.title),n.tables([{name:eo,color:7},{name:Ue,color:7},{name:to,color:8},{name:Le,color:3}]),n.beginEntities();for(const i of e.wireRenders.values())i.path.length<2||n.lwpolyline(eo,i.path.map(ye),!1);for(const{geometry:i}of e.buses.values()){const{axis:a,at:l,span:c}=i,u=c/2,f=a==="x"?[l[0]-u,l[1]]:[l[0],l[1]-u],h=a==="x"?[l[0]+u,l[1]]:[l[0],l[1]+u];n.lwpolyline(eo,[f,h].map(ye),!1)}for(const i of e.elements.values()){const a=e.layout.get(i.element.id),l=i.libraryDef;!a||!l||nN(n,l.svg,a)}const o=t.labelMode??"all";if(o!=="off"){for(const i of e.elements.values()){const a=e.layout.get(i.element.id);if(!a||!i.libraryDef)continue;const l=jn(i,o);if(l.length===0)continue;const c=i.libraryDef.label??En(i.libraryDef),{world:[u,f],textAnchor:h,dy:g}=Nn(c,i.libraryDef,a,l.length);for(let m=0;m<l.length;m++){const[p,x]=ye([u,f+g+m*Gt]);n.text(to,[p,x],l[m],ze,0,!1,h)}}for(const i of e.wireRenders.values()){const a=(r=i.label)==null?void 0:r.trim();if(!a)continue;const l=An(i.path);if(!l)continue;const c=ye(l.world);n.text(to,c,a,ze,0,!1,l.textAnchor)}}for(const i of t.annotations??[])switch(De(i)){case"rect":{const a=i,[l,c]=a.at,[u,f]=a.size;if(n.lwpolyline(Le,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0),a.label){const h=ye([l+gt,c+gt+qe]);n.text(Le,h,a.label,qe,0,!1)}break}case"line":{const a=i,l=Ut(a);if(l.length<2)break;n.lwpolyline(Le,l.map(ye),!1);for(const c of To(l,a.arrow))n.lwpolyline(Le,c.map(ye),!0);break}case"table":{const a=i,[l,c]=a.at,[u,f]=Ge(a),h=wt(a),g=vt(a),m=a.fontSize??qe;n.lwpolyline(Le,[[l,c],[l+u,c],[l+u,c+f],[l,c+f]].map(ye),!0);for(let p=1;p<a.colWidths.length;p++)n.line(Le,ye([l+h[p],c]),ye([l+h[p],c+f]));for(let p=1;p<a.rowHeights.length;p++)n.line(Le,ye([l,c+g[p]]),ye([l+u,c+g[p]]));for(let p=0;p<a.rowHeights.length;p++)for(let x=0;x<a.colWidths.length;x++){const w=((s=a.cells[p])==null?void 0:s[x])??"";if(w==="")continue;const v=ye([l+h[x]+Ft,c+g[p]+a.rowHeights[p]/2+m*.35]);n.text(Le,v,w,m,0,!1)}break}default:{const a=i;if(!a.text)break;const l=a.fontSize??QE,c=a.text.split(`
221
+ `);for(let u=0;u<c.length;u++){const[f,h]=ye([a.at[0],a.at[1]+(u+1)*l*eN]);n.text(Le,[f,h],c[u],l,0,!1)}break}}return n.endEntities(),n.toString()}async function u2(e,t="diagram.dxf",n){const o=d2(e,n),r=URL.createObjectURL(new Blob([o],{type:"application/dxf;charset=utf-8"})),s=document.createElement("a");s.href=r,s.download=t,s.click(),URL.revokeObjectURL(r)}function nN(e,t,n){const o=`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`,s=new DOMParser().parseFromString(o,"image/svg+xml").documentElement;if(!(!s||s.querySelector("parsererror")))for(const i of Array.from(s.children))switch(i.tagName.toLowerCase()){case"line":oN(e,i,n);break;case"polyline":bs(e,i,n,!1);break;case"polygon":bs(e,i,n,!0);break;case"rect":rN(e,i,n);break;case"circle":sN(e,i,n);break;case"ellipse":iN(e,i,n);break;case"path":dN(e,i,n);break;case"text":cN(e,i,n);break}}function oN(e,t,n){const o=ke(t,"x1"),r=ke(t,"y1"),s=ke(t,"x2"),i=ke(t,"y2"),a=ye(Ye([o,r],n)),l=ye(Ye([s,i],n));e.line(Ue,a,l)}function bs(e,t,n,o){const r=hN(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>ye(Ye(i,n)));e.lwpolyline(Ue,s,o)}function rN(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=ke(t,"width"),i=ke(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(c=>ye(Ye(c,n)));e.lwpolyline(Ue,l,!0)}function sN(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"r"),i=ye(Ye([o,r],n));e.circle(Ue,i,s)}function iN(e,t,n){const o=ke(t,"cx"),r=ke(t,"cy"),s=ke(t,"rx"),i=ke(t,"ry");if(Math.abs(s-i)<1e-6){aN(e,o,r,s,n);return}lN(e,o,r,s,i,n)}function aN(e,t,n,o,r){const s=ye(Ye([t,n],r));e.circle(Ue,s,o)}function lN(e,t,n,o,r,s){const i=[];for(let a=0;a<xs;a++){const l=a/xs*Math.PI*2;i.push(ye(Ye([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Ue,i,!0)}function cN(e,t,n){const o=ke(t,"x"),r=ke(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||tN,i=(t.textContent??"").trim();if(!i)return;const a=ye(Ye([o,r],n));e.text(Ue,a,i,s,n.rot,n.mirror)}function dN(e,t,n){const o=t.getAttribute("d")??"",r=uN(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Ue,i.map(l=>ye(Ye(l,n))),!1),i=[]};for(const l of r)if(l.cmd==="M")a(),s=[l.args[0],l.args[1]],i.push(s);else if(l.cmd==="A"&&s){const[c,u,,f,h,g,m]=l.args,p=fN(s,[g,m],c,u,f!==0,h!==0);if(p)for(let x=1;x<=ys;x++){const w=p.theta1+p.delta*x/ys;i.push([p.cx+c*Math.cos(w),p.cy+u*Math.sin(w)])}else i.push([g,m]);s=[g,m]}a()}function uN(e){const t=[],n=/([MmAa])([^MmAa]*)/g;let o;for(;(o=n.exec(e))!==null;){const r=o[1].toUpperCase(),s=o[2].trim().split(/[\s,]+/).filter(i=>i.length>0).map(Number);t.push({cmd:r,args:s})}return t}function fN(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,c]=t;if(i===l&&a===c)return null;const u=(i-l)/2,f=(a-c)/2;let h=Math.abs(n),g=Math.abs(o);const m=h*h,p=g*g,x=u*u/m+f*f/p;if(x>1){const R=Math.sqrt(x);h*=R,g*=R}const w=r===s?-1:1,v=h*h*g*g-h*h*f*f-g*g*u*u,M=h*h*f*f+g*g*u*u,I=w*Math.sqrt(Math.max(0,v/M)),F=I*(h*f)/g,G=I*-(g*u)/h,$=F+(i+l)/2,H=G+(a+c)/2,W=(R,Z,ie,ue)=>{const ee=R*ie+Z*ue,ae=Math.hypot(R,Z)*Math.hypot(ie,ue);let me=Math.acos(Math.max(-1,Math.min(1,ee/ae)));return R*ue-Z*ie<0&&(me=-me),me},X=W(1,0,(u-F)/h,(f-G)/g);let P=W((u-F)/h,(f-G)/g,(-u-F)/h,(-f-G)/g);return!s&&P>0?P-=2*Math.PI:s&&P<0&&(P+=2*Math.PI),{cx:$,cy:H,theta1:X,delta:P}}function Ye(e,t){return Ie(e,t)}function ye(e){return[e[0],-e[1]]}function ke(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function hN(e){const t=e.trim().split(/[\s,]+/).map(Number).filter(o=>Number.isFinite(o)),n=[];for(let o=0;o+1<t.length;o+=2)n.push([t[o],t[o+1]]);return n}class mN{constructor(t){jt(this,"out",[]);jt(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
222
222
  ${this.fmt(n)}
223
- `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,ws(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i,a="start"){this.g(0,"TEXT"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,ws(o)),s!==0&&this.g(50,s),i&&this.g(71,2),a!=="start"&&(this.g(72,a==="middle"?1:2),this.g(11,n[0]),this.g(21,n[1]),this.g(31,0))}}function ws(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const WE="http://www.w3.org/2000/svg",fn=24,qE=1.25;function Lo(e,t={}){var f;const n=UE(e,t),o=Math.floor(n.minX-fn),r=Math.floor(n.minY-fn),s=Math.ceil(n.maxX+fn)-o,i=Math.ceil(n.maxY+fn)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${WE}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${He(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const m of e.wireRenders.values()){if(m.path.length<2)continue;const g=m.path.map(([p,h])=>`${p},${h}`).join(" ");l.push(` <polyline points="${g}"/>`)}l.push(" </g>");for(const{bus:m,geometry:g}of e.buses.values()){const{axis:p,at:h,span:x}=g,w=x/2,v=p==="x"?h[0]-w:h[0],C=p==="x"?h[1]:h[1]-w,O=p==="x"?h[0]+w:h[0],F=p==="x"?h[1]:h[1]+w;l.push(` <line id="${He(m.id)}" x1="${v}" y1="${C}" x2="${O}" y2="${F}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:m,world:g,degree:p}of e.junctions.values())p<3||l.push(` <circle id="${He(m.id)}" cx="${g[0]}" cy="${g[1]}" r="3.5" fill="black"/>`);for(const m of e.elements.values()){if(!m.libraryDef)continue;const g=e.layout.get(m.element.id);g&&(l.push(` <g id="${He(m.element.id)}" transform="${nt(g)}">`),l.push(` ${m.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${ze}" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const g of e.elements.values()){const p=e.layout.get(g.element.id);if(!p||!g.libraryDef)continue;const h=jn(g,c);if(h.length===0)continue;const x=g.libraryDef.label??En(g.libraryDef),{world:[w,v],textAnchor:C,dy:O}=Nn(x,g.libraryDef,p,h.length);for(let F=0;F<h.length;F++)l.push(` <text x="${w}" y="${v+O+F*Gt}" text-anchor="${C}">${He(h[F])}</text>`)}for(const g of e.wireRenders.values()){const p=(f=g.label)==null?void 0:f.trim();if(!p)continue;const h=An(g.path);h&&l.push(` <text x="${h.world[0]}" y="${h.world[1]}" text-anchor="${h.textAnchor}">${He(p)}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){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"`;for(const h of u)switch(Le(h)){case"rect":YE(l,h,p);break;case"line":GE(l,h);break;case"table":KE(l,h,g);break;default:XE(l,h,p);break}}return l.push("</svg>"),l.join(`
224
- `)}function XE(e,t,n){if(!t.text)return;const o=t.fontSize??qe,r=t.text.split(`
225
- `);e.push(` <g fill="black" ${n}>`);for(let s=0;s<r.length;s++){const i=t.at[1]+o*.85+s*o*qE;e.push(` <text x="${t.at[0]}" y="${i}" font-size="${o}">${He(r[s])}</text>`)}e.push(" </g>")}function YE(e,t,n){const[o,r]=t.at,[s,i]=t.size,a=(t.stroke??"dashed")==="dashed"?` stroke-dasharray="${Kt}"`:"";t.fill==="tint"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="black" fill-opacity="${rj}"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"${a}/>`),t.label&&(e.push(` <g fill="black" ${n}>`),e.push(` <text x="${o+gt}" y="${r+gt+qe*.85}" font-size="${qe}">${He(t.label)}</text>`),e.push(" </g>"))}function GE(e,t){const n=Ut(t);if(n.length<2)return;const o=(t.stroke??"solid")==="dashed"?` stroke-dasharray="${Kt}"`:"",r=n.map(([s,i])=>`${s},${i}`).join(" ");e.push(` <polyline points="${r}" fill="none" stroke="black" stroke-width="1"${o}/>`);for(const s of To(n,t.arrow))e.push(` <polygon points="${s.map(([i,a])=>`${i},${a}`).join(" ")}" fill="black"/>`)}function KE(e,t,n){var m;const[o,r]=t.at,[s,i]=Ge(t),a=wt(t),l=vt(t),c=t.fontSize??qe;n!=="none"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${n}"/>`);let u="";for(let g=1;g<t.colWidths.length;g++)u+=`M${o+a[g]} ${r}V${r+i}`;for(let g=1;g<t.rowHeights.length;g++)u+=`M${o} ${r+l[g]}H${o+s}`;u&&e.push(` <path d="${u}" fill="none" stroke="black" stroke-width="0.5"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"/>`);const f=[];for(let g=0;g<t.rowHeights.length;g++)for(let p=0;p<t.colWidths.length;p++){const h=((m=t.cells[g])==null?void 0:m[p])??"";if(h==="")continue;const x=o+a[p]+Ft,w=r+l[g]+t.rowHeights[g]/2+c*.35;f.push(` <text x="${x}" y="${w}" font-size="${c}">${He(h)}</text>`)}f.length>0&&(e.push(' <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif">'),e.push(...f),e.push(" </g>"))}function UE(e,t){var l;let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(c,u)=>{c<n&&(n=c),c>r&&(r=c),u<o&&(o=u),u>s&&(s=u)};for(const c of e.terminals.values())i(c.world[0],c.world[1]);for(const c of e.junctions.values())i(c.world[0],c.world[1]);for(const c of e.elements.values()){const u=e.layout.get(c.element.id),f=c.libraryDef;if(!u||!f)continue;const m=VE(f.viewBox);if(!m){i(u.at[0],u.at[1]);continue}const g=[[m.x,m.y],[m.x+m.w,m.y],[m.x,m.y+m.h],[m.x+m.w,m.y+m.h]];for(const p of g){const[h,x]=Ie(p,u);i(h,x)}}for(const{geometry:c}of e.buses.values()){const{axis:u,at:f,span:m}=c,g=m/2;u==="x"?(i(f[0]-g,f[1]),i(f[0]+g,f[1])):(i(f[0],f[1]-g),i(f[0],f[1]+g))}for(const c of e.wireRenders.values())for(const[u,f]of c.path)i(u,f);const a=t.labelMode??"all";if(a!=="off"){for(const c of e.elements.values()){const u=e.layout.get(c.element.id);if(!u||!c.libraryDef)continue;const f=jn(c,a);if(f.length===0)continue;const m=c.libraryDef.label??En(c.libraryDef),{world:[g,p],textAnchor:h,dy:x}=Nn(m,c.libraryDef,u,f.length),w=vs(f,ze),v=f.length*Gt,C=h==="middle"?g-w/2:h==="end"?g-w:g;i(C,p+x-ze),i(C+w,p+x+v)}for(const c of e.wireRenders.values()){const u=(l=c.label)==null?void 0:l.trim();if(!u)continue;const f=An(c.path);if(!f)continue;const[m,g]=f.world,p=vs([u],ze),h=f.textAnchor==="middle"?m-p/2:m;i(h,g-ze),i(h+p,g)}}for(const c of t.annotations??[]){if(Le(c)==="text"&&!c.text)continue;const u=lj(c);i(u.minX,u.minY),i(u.maxX,u.maxY)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function vs(e,t){let n=0;for(const o of e){const r=o.length*t*.55;r>n&&(n=r)}return Math.max(20,n)}function VE(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function He(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function qv(e,t="diagram.svg",n){const o=Lo(e,n);Yv(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function Xv(e,t="diagram.png",n){const o=Lo(e,n),r=(n==null?void 0:n.scale)??2,s=URL.createObjectURL(new Blob([o],{type:"image/svg+xml;charset=utf-8"}));try{const i=await JE(s),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*r),a.height=Math.round(i.naturalHeight*r);const l=a.getContext("2d");if(!l)throw new Error("canvas 2d context unavailable");n!=null&&n.background&&n.background!=="transparent"&&(l.fillStyle=n.background,l.fillRect(0,0,a.width,a.height)),l.drawImage(i,0,0,a.width,a.height);const c=await new Promise((u,f)=>{a.toBlob(m=>m?u(m):f(new Error("toBlob failed")),"image/png")});Yv(c,t)}finally{URL.revokeObjectURL(s)}}function JE(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>n(new Error("failed to load SVG into image")),o.src=e})}function Yv(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function ZE(){const e=le(),[t,n]=M.useState(!1),o=M.useRef(null);M.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var f,m,g,p;n(!1);const{internal:i,diagram:a,fileSession:l}=y.getState(),c=((f=l==null?void 0:l.name)==null?void 0:f.replace(/\.json$/i,""))??((m=a.meta)==null?void 0:m.title)??"diagram",u={title:(g=a.meta)==null?void 0:g.title,labelMode:(p=a.meta)==null?void 0:p.labelMode,annotations:a.annotations};s==="svg"?qv(i,`${c}.svg`,u):s==="png"?Xv(i,`${c}.png`,{...u,scale:2}).catch(h=>{console.error(h),alert(e("topbar.export.pngFailed",{err:h.message}))}):Wv(i,`${c}.dxf`,u).catch(h=>{console.error(h),alert(e("topbar.export.dxfFailed",{err:h.message}))})};return d.jsxs("div",{ref:o,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[d.jsx(f2,{}),e("topbar.export.label")]}),t&&d.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[d.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"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",children:[d.jsx(g2,{}),d.jsx("span",{className:"flex-1",children:"SVG"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"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",children:[d.jsx(m2,{}),d.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"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",children:[d.jsx(h2,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=ZE;exports.FileMenu=$E;exports.LIBRARY=ao;exports.OneLineEditor=kE;exports.annotationKind=Le;exports.applyTheme=Dv;exports.buildExportDxf=Hv;exports.buildExportSvg=Lo;exports.compile=et;exports.downloadDxf=Wv;exports.downloadPng=Xv;exports.downloadSvg=qv;exports.emptyInternalModel=Gs;exports.fitToContent=Mo;exports.fitToContentSoon=Co;exports.getInitialTheme=vE;exports.getLibraryEntry=Jw;exports.isTextAnnotation=nj;exports.newAnnotationId=hn;exports.newBusId=lo;exports.newElementId=Rt;exports.newJunctionId=co;exports.orientationVec=io;exports.resolvePlacement=Ks;exports.transformOrientation=Ot;exports.transformPoint=Ie;exports.useEditorStore=y;exports.useLocale=Yt;exports.wireIdFromEnds=at;
223
+ `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),t&&(this.g(9,"$PROJECTNAME"),this.g(1,ws(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0)}lwpolyline(t,n,o){if(!(n.length<2)){this.g(0,"LWPOLYLINE"),this.g(8,t),this.g(90,n.length),this.g(70,o?1:0);for(const[r,s]of n)this.g(10,r),this.g(20,s)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o)}text(t,n,o,r,s,i,a="start"){this.g(0,"TEXT"),this.g(8,t),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,ws(o)),s!==0&&this.g(50,s),i&&this.g(71,2),a!=="start"&&(this.g(72,a==="middle"?1:2),this.g(11,n[0]),this.g(21,n[1]),this.g(31,0))}}function ws(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const pN="http://www.w3.org/2000/svg",fn=24,gN=1.25;function Do(e,t={}){var f;const n=vN(e,t),o=Math.floor(n.minX-fn),r=Math.floor(n.minY-fn),s=Math.ceil(n.maxX+fn)-o,i=Math.ceil(n.maxY+fn)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${pN}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${He(t.title)}</title>`),a!=="transparent"&&l.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${a}"/>`),l.push(' <g fill="none" stroke="black" stroke-width="1">');for(const h of e.wireRenders.values()){if(h.path.length<2)continue;const g=h.path.map(([m,p])=>`${m},${p}`).join(" ");l.push(` <polyline points="${g}"/>`)}l.push(" </g>");for(const{bus:h,geometry:g}of e.buses.values()){const{axis:m,at:p,span:x}=g,w=x/2,v=m==="x"?p[0]-w:p[0],M=m==="x"?p[1]:p[1]-w,I=m==="x"?p[0]+w:p[0],F=m==="x"?p[1]:p[1]+w;l.push(` <line id="${He(h.id)}" x1="${v}" y1="${M}" x2="${I}" y2="${F}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:h,world:g,degree:m}of e.junctions.values())m<3||l.push(` <circle id="${He(h.id)}" cx="${g[0]}" cy="${g[1]}" r="3.5" fill="black"/>`);for(const h of e.elements.values()){if(!h.libraryDef)continue;const g=e.layout.get(h.element.id);g&&(l.push(` <g id="${He(h.element.id)}" transform="${nt(g)}">`),l.push(` ${h.libraryDef.svg}`),l.push(" </g>"))}const c=t.labelMode??"all";if(c!=="off"){const h=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${ze}" paint-order="stroke" stroke="${h}" stroke-width="2" stroke-linejoin="round">`);for(const g of e.elements.values()){const m=e.layout.get(g.element.id);if(!m||!g.libraryDef)continue;const p=jn(g,c);if(p.length===0)continue;const x=g.libraryDef.label??En(g.libraryDef),{world:[w,v],textAnchor:M,dy:I}=Nn(x,g.libraryDef,m,p.length);for(let F=0;F<p.length;F++)l.push(` <text x="${w}" y="${v+I+F*Gt}" text-anchor="${M}">${He(p[F])}</text>`)}for(const g of e.wireRenders.values()){const m=(f=g.label)==null?void 0:f.trim();if(!m)continue;const p=An(g.path);p&&l.push(` <text x="${p.world[0]}" y="${p.world[1]}" text-anchor="${p.textAnchor}">${He(m)}</text>`)}l.push(" </g>")}const u=t.annotations??[];if(u.length>0){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"`;for(const p of u)switch(De(p)){case"rect":xN(l,p,m);break;case"line":bN(l,p);break;case"table":wN(l,p,g);break;default:yN(l,p,m);break}}return l.push("</svg>"),l.join(`
224
+ `)}function yN(e,t,n){if(!t.text)return;const o=t.fontSize??qe,r=t.text.split(`
225
+ `);e.push(` <g fill="black" ${n}>`);for(let s=0;s<r.length;s++){const i=t.at[1]+o*.85+s*o*gN;e.push(` <text x="${t.at[0]}" y="${i}" font-size="${o}">${He(r[s])}</text>`)}e.push(" </g>")}function xN(e,t,n){const[o,r]=t.at,[s,i]=t.size,a=(t.stroke??"dashed")==="dashed"?` stroke-dasharray="${Kt}"`:"";t.fill==="tint"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="black" fill-opacity="${Tj}"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"${a}/>`),t.label&&(e.push(` <g fill="black" ${n}>`),e.push(` <text x="${o+gt}" y="${r+gt+qe*.85}" font-size="${qe}">${He(t.label)}</text>`),e.push(" </g>"))}function bN(e,t){const n=Ut(t);if(n.length<2)return;const o=(t.stroke??"solid")==="dashed"?` stroke-dasharray="${Kt}"`:"",r=n.map(([s,i])=>`${s},${i}`).join(" ");e.push(` <polyline points="${r}" fill="none" stroke="black" stroke-width="1"${o}/>`);for(const s of To(n,t.arrow))e.push(` <polygon points="${s.map(([i,a])=>`${i},${a}`).join(" ")}" fill="black"/>`)}function wN(e,t,n){var h;const[o,r]=t.at,[s,i]=Ge(t),a=wt(t),l=vt(t),c=t.fontSize??qe;n!=="none"&&e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="${n}"/>`);let u="";for(let g=1;g<t.colWidths.length;g++)u+=`M${o+a[g]} ${r}V${r+i}`;for(let g=1;g<t.rowHeights.length;g++)u+=`M${o} ${r+l[g]}H${o+s}`;u&&e.push(` <path d="${u}" fill="none" stroke="black" stroke-width="0.5"/>`),e.push(` <rect x="${o}" y="${r}" width="${s}" height="${i}" fill="none" stroke="black" stroke-width="1"/>`);const f=[];for(let g=0;g<t.rowHeights.length;g++)for(let m=0;m<t.colWidths.length;m++){const p=((h=t.cells[g])==null?void 0:h[m])??"";if(p==="")continue;const x=o+a[m]+Ft,w=r+l[g]+t.rowHeights[g]/2+c*.35;f.push(` <text x="${x}" y="${w}" font-size="${c}">${He(p)}</text>`)}f.length>0&&(e.push(' <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif">'),e.push(...f),e.push(" </g>"))}function vN(e,t){var l;let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(c,u)=>{c<n&&(n=c),c>r&&(r=c),u<o&&(o=u),u>s&&(s=u)};for(const c of e.terminals.values())i(c.world[0],c.world[1]);for(const c of e.junctions.values())i(c.world[0],c.world[1]);for(const c of e.elements.values()){const u=e.layout.get(c.element.id),f=c.libraryDef;if(!u||!f)continue;const h=kN(f.viewBox);if(!h){i(u.at[0],u.at[1]);continue}const g=[[h.x,h.y],[h.x+h.w,h.y],[h.x,h.y+h.h],[h.x+h.w,h.y+h.h]];for(const m of g){const[p,x]=Ie(m,u);i(p,x)}}for(const{geometry:c}of e.buses.values()){const{axis:u,at:f,span:h}=c,g=h/2;u==="x"?(i(f[0]-g,f[1]),i(f[0]+g,f[1])):(i(f[0],f[1]-g),i(f[0],f[1]+g))}for(const c of e.wireRenders.values())for(const[u,f]of c.path)i(u,f);const a=t.labelMode??"all";if(a!=="off"){for(const c of e.elements.values()){const u=e.layout.get(c.element.id);if(!u||!c.libraryDef)continue;const f=jn(c,a);if(f.length===0)continue;const h=c.libraryDef.label??En(c.libraryDef),{world:[g,m],textAnchor:p,dy:x}=Nn(h,c.libraryDef,u,f.length),w=vs(f,ze),v=f.length*Gt,M=p==="middle"?g-w/2:p==="end"?g-w:g;i(M,m+x-ze),i(M+w,m+x+v)}for(const c of e.wireRenders.values()){const u=(l=c.label)==null?void 0:l.trim();if(!u)continue;const f=An(c.path);if(!f)continue;const[h,g]=f.world,m=vs([u],ze),p=f.textAnchor==="middle"?h-m/2:h;i(p,g-ze),i(p+m,g)}}for(const c of t.annotations??[]){if(De(c)==="text"&&!c.text)continue;const u=Ij(c);i(u.minX,u.minY),i(u.maxX,u.maxY)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function vs(e,t){let n=0;for(const o of e){const r=o.length*t*.55;r>n&&(n=r)}return Math.max(20,n)}function kN(e){const t=e.trim().split(/\s+/).map(Number);return t.length!==4||t.some(n=>Number.isNaN(n))?null:{x:t[0],y:t[1],w:t[2],h:t[3]}}function He(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}async function f2(e,t="diagram.svg",n){const o=Do(e,n);m2(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function h2(e,t="diagram.png",n){const o=Do(e,n),r=(n==null?void 0:n.scale)??2,s=URL.createObjectURL(new Blob([o],{type:"image/svg+xml;charset=utf-8"}));try{const i=await _N(s),a=document.createElement("canvas");a.width=Math.round(i.naturalWidth*r),a.height=Math.round(i.naturalHeight*r);const l=a.getContext("2d");if(!l)throw new Error("canvas 2d context unavailable");n!=null&&n.background&&n.background!=="transparent"&&(l.fillStyle=n.background,l.fillRect(0,0,a.width,a.height)),l.drawImage(i,0,0,a.width,a.height);const c=await new Promise((u,f)=>{a.toBlob(h=>h?u(h):f(new Error("toBlob failed")),"image/png")});m2(c,t)}finally{URL.revokeObjectURL(s)}}function _N(e){return new Promise((t,n)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>n(new Error("failed to load SVG into image")),o.src=e})}function m2(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function SN(){const e=le(),[t,n]=C.useState(!1),o=C.useRef(null);C.useEffect(()=>{if(!t)return;const s=a=>{o.current&&!o.current.contains(a.target)&&n(!1)},i=a=>{a.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r=s=>()=>{var f,h,g,m;n(!1);const{internal:i,diagram:a,fileSession:l}=y.getState(),c=((f=l==null?void 0:l.name)==null?void 0:f.replace(/\.json$/i,""))??((h=a.meta)==null?void 0:h.title)??"diagram",u={title:(g=a.meta)==null?void 0:g.title,labelMode:(m=a.meta)==null?void 0:m.labelMode,annotations:a.annotations};s==="svg"?f2(i,`${c}.svg`,u):s==="png"?h2(i,`${c}.png`,{...u,scale:2}).catch(p=>{console.error(p),alert(e("topbar.export.pngFailed",{err:p.message}))}):u2(i,`${c}.dxf`,u).catch(p=>{console.error(p),alert(e("topbar.export.dxfFailed",{err:p.message}))})};return d.jsxs("div",{ref:o,className:"relative",children:[d.jsxs(Ae,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[d.jsx(I2,{}),e("topbar.export.label")]}),t&&d.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[d.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"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",children:[d.jsx(L2,{}),d.jsx("span",{className:"flex-1",children:"SVG"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"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",children:[d.jsx(B2,{}),d.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),d.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"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",children:[d.jsx(O2,{}),d.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=SN;exports.FileMenu=JE;exports.LIBRARY=ao;exports.OneLineEditor=KE;exports.annotationKind=De;exports.applyTheme=i2;exports.buildExportDxf=d2;exports.buildExportSvg=Do;exports.compile=et;exports.downloadDxf=u2;exports.downloadPng=h2;exports.downloadSvg=f2;exports.emptyInternalModel=Gs;exports.fitToContent=Mo;exports.fitToContentSoon=Co;exports.getInitialTheme=GE;exports.getLibraryEntry=bv;exports.isTextAnnotation=Nj;exports.newAnnotationId=hn;exports.newBusId=lo;exports.newElementId=Rt;exports.newJunctionId=co;exports.orientationVec=io;exports.resolvePlacement=Ks;exports.transformOrientation=Ot;exports.transformPoint=Ie;exports.useEditorStore=y;exports.useLocale=Yt;exports.wireIdFromEnds=at;
226
226
  //# sourceMappingURL=sldeditor.cjs.map