sldeditor 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas/BusLayer.d.ts.map +1 -1
- package/dist/canvas/CanvasSvg.d.ts.map +1 -1
- package/dist/canvas/JunctionLayer.d.ts +12 -0
- package/dist/canvas/JunctionLayer.d.ts.map +1 -0
- package/dist/canvas/WirePreview.d.ts +5 -4
- package/dist/canvas/WirePreview.d.ts.map +1 -1
- package/dist/canvas/hit-test.d.ts +6 -5
- package/dist/canvas/hit-test.d.ts.map +1 -1
- package/dist/canvas/resolve-wire-target.d.ts.map +1 -1
- package/dist/canvas/tools/JunctionTool.d.ts +3 -0
- package/dist/canvas/tools/JunctionTool.d.ts.map +1 -0
- package/dist/canvas/tools/SelectTool.d.ts.map +1 -1
- package/dist/canvas/tools/WireTool.d.ts.map +1 -1
- package/dist/canvas/tools/index.d.ts.map +1 -1
- package/dist/canvas/useKeyboardShortcuts.d.ts.map +1 -1
- package/dist/canvas/wire-target-bus.d.ts +4 -1
- package/dist/canvas/wire-target-bus.d.ts.map +1 -1
- package/dist/compiler/auto-route.d.ts.map +1 -1
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/index.d.ts +1 -1
- package/dist/compiler/index.d.ts.map +1 -1
- package/dist/compiler/internal-model.d.ts +7 -1
- package/dist/compiler/internal-model.d.ts.map +1 -1
- package/dist/components/FloatingToolbar.d.ts.map +1 -1
- package/dist/components/PropertyPanel.d.ts.map +1 -1
- package/dist/i18n/messages.d.ts +16 -6
- package/dist/i18n/messages.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/export-image.d.ts.map +1 -1
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/types.d.ts +25 -4
- package/dist/model/types.d.ts.map +1 -1
- package/dist/sldeditor.cjs +52 -47
- package/dist/sldeditor.cjs.map +1 -1
- package/dist/sldeditor.js +5596 -5245
- package/dist/sldeditor.js.map +1 -1
- package/dist/store/id-allocator.d.ts +1 -0
- package/dist/store/id-allocator.d.ts.map +1 -1
- package/dist/store/index.d.ts +2 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/store.d.ts +36 -2
- package/dist/store/store.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/sldeditor.cjs
CHANGED
|
@@ -1,201 +1,206 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Dw=Object.defineProperty;var Fw=(e,t,n)=>t in e?Dw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ht=(e,t,n)=>Fw(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),O=require("react"),jr=require("react-dom");function Hw(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 ke=Hw(O);/**
|
|
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
|
|
6
|
+
*/const Ww=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Er=(...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
|
|
11
|
+
*/var qw={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
|
|
16
|
+
*/const Gw=O.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:s,iconNode:i,...a},l)=>O.createElement("svg",{ref:l,...qw,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:Er("lucide",r),...a},[...i.map(([u,d])=>O.createElement(u,d)),...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 ee=(e,t)=>{const n=
|
|
21
|
+
*/const ee=(e,t)=>{const n=O.forwardRef(({className:o,...r},s)=>O.createElement(Gw,{ref:s,iconNode:t,className:Er(`lucide-${Ww(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.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const
|
|
26
|
+
*/const Nr=ee("Cable",[["path",{d:"M17 21v-2a1 1 0 0 1-1-1v-1a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v1a1 1 0 0 1-1 1",key:"10bnsj"}],["path",{d:"M19 15V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V9",key:"1eqmu1"}],["path",{d:"M21 21v-2h-4",key:"14zm7j"}],["path",{d:"M3 5h4V3",key:"z442eg"}],["path",{d:"M7 5a1 1 0 0 1 1 1v1a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1V3",key:"ebdjd7"}]]);/**
|
|
27
27
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
31
|
+
*/const Xw=ee("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
|
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
|
|
36
|
+
*/const Kw=ee("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
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
|
|
41
|
+
*/const Mr=ee("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
42
42
|
* @license lucide-react v0.469.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Tr=ee("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
|
47
47
|
* @license lucide-react v0.469.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const Yw=ee("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"}]]);/**
|
|
52
52
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
56
|
+
*/const kn=ee("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
57
57
|
* @license lucide-react v0.469.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const Vw=ee("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"}]]);/**
|
|
62
62
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
66
|
+
*/const Uw=ee("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"}]]);/**
|
|
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
|
|
71
|
+
*/const Jw=ee("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"}]]);/**
|
|
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
|
|
76
|
+
*/const Zw=ee("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"}]]);/**
|
|
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
|
|
81
|
+
*/const Ar=ee("FlipHorizontal",[["path",{d:"M8 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h3",key:"1i73f7"}],["path",{d:"M16 3h3a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-3",key:"saxlbk"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]);/**
|
|
82
82
|
* @license lucide-react v0.469.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const yo=ee("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
|
87
87
|
* @license lucide-react v0.469.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const Qw=ee("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"}]]);/**
|
|
92
92
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
96
|
+
*/const ev=ee("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"}]]);/**
|
|
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
|
|
101
|
+
*/const Rt=ee("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
102
102
|
* @license lucide-react v0.469.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const Cr=ee("ListTree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]);/**
|
|
107
107
|
* @license lucide-react v0.469.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const tv=ee("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"}]]);/**
|
|
112
112
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
116
|
+
*/const Dn=ee("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
117
117
|
* @license lucide-react v0.469.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const nv=ee("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"}]]);/**
|
|
122
122
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
126
|
+
*/const ov=ee("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"}]]);/**
|
|
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
|
|
131
|
+
*/const rv=ee("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
|
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
|
|
136
|
+
*/const Fn=ee("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
|
|
137
137
|
* @license lucide-react v0.469.0 - ISC
|
|
138
138
|
*
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
140
140
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const
|
|
141
|
+
*/const Ir=ee("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);/**
|
|
142
142
|
* @license lucide-react v0.469.0 - ISC
|
|
143
143
|
*
|
|
144
144
|
* This source code is licensed under the ISC license.
|
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const
|
|
146
|
+
*/const xo=ee("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
|
|
147
147
|
* @license lucide-react v0.469.0 - ISC
|
|
148
148
|
*
|
|
149
149
|
* This source code is licensed under the ISC license.
|
|
150
150
|
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const
|
|
151
|
+
*/const Pr=ee("Scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]);/**
|
|
152
152
|
* @license lucide-react v0.469.0 - ISC
|
|
153
153
|
*
|
|
154
154
|
* This source code is licensed under the ISC license.
|
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const
|
|
156
|
+
*/const sv=ee("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
|
|
157
157
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
161
|
+
*/const Or=ee("Shapes",[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]]);/**
|
|
162
162
|
* @license lucide-react v0.469.0 - ISC
|
|
163
163
|
*
|
|
164
164
|
* This source code is licensed under the ISC license.
|
|
165
165
|
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const
|
|
166
|
+
*/const iv=ee("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"}]]);/**
|
|
167
167
|
* @license lucide-react v0.469.0 - ISC
|
|
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
|
|
171
|
+
*/const av=ee("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"}]]);/**
|
|
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
|
|
176
|
+
*/const Br=ee("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
|
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
|
|
181
|
+
*/const Lr=ee("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
|
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
|
|
186
|
+
*/const Hn=ee("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
|
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 zn=ee("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function jr(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=jr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Er(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=jr(e))&&(o&&(o+=" "),o+=t);return o}const Rn="-",Zw=e=>{const t=Jw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(Rn);return a[0]===""&&a.length!==1&&a.shift(),Nr(a,t)||Qw(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Nr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Nr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(Rn);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},fo=/^\[(.+)\]$/,Qw=e=>{if(fo.test(e)){const t=fo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Jw=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return tv(Object.entries(e.classGroups),n).forEach(([s,i])=>{wn(i,o,s,t)}),o},wn=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:ho(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(ev(r)){wn(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{wn(i,ho(t,s),n,o)})})},ho=(e,t)=>{let n=e;return t.split(Rn).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},ev=e=>e.isThemeGetter,tv=(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,nv=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)}}},Mr="!",ov=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let d=0,u=0,m;for(let b=0;b<a.length;b++){let k=a[b];if(d===0){if(k===r&&(o||a.slice(b,b+s)===t)){l.push(a.slice(u,b)),u=b+s;continue}if(k==="/"){m=b;continue}}k==="["?d++:k==="]"&&d--}const p=l.length===0?a:a.substring(u),g=p.startsWith(Mr),f=g?p.substring(1):p,h=m&&m>u?m-u:void 0;return{modifiers:l,hasImportantModifier:g,baseClassName:f,maybePostfixModifierPosition:h}};return n?a=>n({className:a,parseClassName:i}):i},rv=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},sv=e=>({cache:nv(e.cacheSize),parseClassName:ov(e),...Zw(e)}),iv=/\s+/,av=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(iv);let a="";for(let l=i.length-1;l>=0;l-=1){const d=i[l],{modifiers:u,hasImportantModifier:m,baseClassName:p,maybePostfixModifierPosition:g}=n(d);let f=!!g,h=o(f?p.substring(0,g):p);if(!h){if(!f){a=d+(a.length>0?" "+a:a);continue}if(h=o(p),!h){a=d+(a.length>0?" "+a:a);continue}f=!1}const b=rv(u).join(":"),k=m?b+Mr:b,w=k+h;if(s.includes(w))continue;s.push(w);const M=r(h,f);for(let P=0;P<M.length;++P){const z=M[P];s.push(k+z)}a=d+(a.length>0?" "+a:a)}return a};function lv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Tr(t))&&(o&&(o+=" "),o+=n);return o}const Tr=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Tr(e[o]))&&(n&&(n+=" "),n+=t);return n};function cv(e,...t){let n,o,r,s=i;function i(l){const d=t.reduce((u,m)=>m(u),e());return n=sv(d),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const d=o(l);if(d)return d;const u=av(l,n);return r(l,u),u}return function(){return s(lv.apply(null,arguments))}}const se=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Ar=/^\[(?:([a-z-]+):)?(.+)\]$/i,dv=/^\d+\/\d+$/,uv=new Set(["px","full","screen"]),mv=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,fv=/\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$/,hv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,pv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,gv=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oe=e=>nt(e)||uv.has(e)||dv.test(e),De=e=>st(e,"length",$v),nt=e=>!!e&&!Number.isNaN(Number(e)),rn=e=>st(e,"number",nt),mt=e=>!!e&&Number.isInteger(Number(e)),yv=e=>e.endsWith("%")&&nt(e.slice(0,-1)),V=e=>Ar.test(e),Fe=e=>mv.test(e),xv=new Set(["length","size","percentage"]),bv=e=>st(e,xv,Cr),wv=e=>st(e,"position",Cr),vv=new Set(["image","url"]),kv=e=>st(e,vv,jv),_v=e=>st(e,"",Sv),ft=()=>!0,st=(e,t,n)=>{const o=Ar.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},$v=e=>fv.test(e)&&!hv.test(e),Cr=()=>!1,Sv=e=>pv.test(e),jv=e=>gv.test(e),Ev=()=>{const e=se("colors"),t=se("spacing"),n=se("blur"),o=se("brightness"),r=se("borderColor"),s=se("borderRadius"),i=se("borderSpacing"),a=se("borderWidth"),l=se("contrast"),d=se("grayscale"),u=se("hueRotate"),m=se("invert"),p=se("gap"),g=se("gradientColorStops"),f=se("gradientColorStopPositions"),h=se("inset"),b=se("margin"),k=se("opacity"),w=se("padding"),M=se("saturate"),P=se("scale"),z=se("sepia"),D=se("skew"),Q=se("space"),re=se("translate"),_e=()=>["auto","contain","none"],me=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",V,t],F=()=>[V,t],U=()=>["",Oe,De],oe=()=>["auto",nt,V],ie=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Z=()=>["solid","dashed","dotted","double","none"],fe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],he=()=>["start","end","center","between","around","evenly","stretch"],pe=()=>["","0",V],Ie=()=>["auto","avoid","all","avoid-page","page","left","right","column"],$e=()=>[nt,V];return{cacheSize:500,separator:":",theme:{colors:[ft],spacing:[Oe,De],blur:["none","",Fe,V],brightness:$e(),borderColor:[e],borderRadius:["none","","full",Fe,V],borderSpacing:F(),borderWidth:U(),contrast:$e(),grayscale:pe(),hueRotate:$e(),invert:pe(),gap:F(),gradientColorStops:[e],gradientColorStopPositions:[yv,De],inset:R(),margin:R(),opacity:$e(),padding:F(),saturate:$e(),scale:$e(),sepia:pe(),skew:$e(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",V]}],container:["container"],columns:[{columns:[Fe]}],"break-after":[{"break-after":Ie()}],"break-before":[{"break-before":Ie()}],"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:[...ie(),V]}],overflow:[{overflow:me()}],"overflow-x":[{"overflow-x":me()}],"overflow-y":[{"overflow-y":me()}],overscroll:[{overscroll:_e()}],"overscroll-x":[{"overscroll-x":_e()}],"overscroll-y":[{"overscroll-y":_e()}],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",mt,V]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",V]}],grow:[{grow:pe()}],shrink:[{shrink:pe()}],order:[{order:["first","last","none",mt,V]}],"grid-cols":[{"grid-cols":[ft]}],"col-start-end":[{col:["auto",{span:["full",mt,V]},V]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[ft]}],"row-start-end":[{row:["auto",{span:[mt,V]},V]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",V]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",V]}],gap:[{gap:[p]}],"gap-x":[{"gap-x":[p]}],"gap-y":[{"gap-y":[p]}],"justify-content":[{justify:["normal",...he()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...he(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...he(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[w]}],px:[{px:[w]}],py:[{py:[w]}],ps:[{ps:[w]}],pe:[{pe:[w]}],pt:[{pt:[w]}],pr:[{pr:[w]}],pb:[{pb:[w]}],pl:[{pl:[w]}],m:[{m:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"space-x":[{"space-x":[Q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",V,t]}],"min-w":[{"min-w":[V,t,"min","max","fit"]}],"max-w":[{"max-w":[V,t,"none","full","min","max","fit","prose",{screen:[Fe]},Fe]}],h:[{h:[V,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[V,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[V,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[V,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Fe,De]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",rn]}],"font-family":[{font:[ft]}],"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",V]}],"line-clamp":[{"line-clamp":["none",nt,rn]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oe,V]}],"list-image":[{"list-image":["none",V]}],"list-style-type":[{list:["none","disc","decimal",V]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[k]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[k]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oe,De]}],"underline-offset":[{"underline-offset":["auto",Oe,V]}],"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:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",V]}],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",V]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[k]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ie(),wv]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",bv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},kv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[f]}],"gradient-via-pos":[{via:[f]}],"gradient-to-pos":[{to:[f]}],"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":[k]}],"border-style":[{border:[...Z(),"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":[k]}],"divide-style":[{divide:Z()}],"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:["",...Z()]}],"outline-offset":[{"outline-offset":[Oe,V]}],"outline-w":[{outline:[Oe,De]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[k]}],"ring-offset-w":[{"ring-offset":[Oe,De]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Fe,_v]}],"shadow-color":[{shadow:[ft]}],opacity:[{opacity:[k]}],"mix-blend":[{"mix-blend":[...fe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":fe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Fe,V]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[m]}],saturate:[{saturate:[M]}],sepia:[{sepia:[z]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[k]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[z]}],"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",V]}],duration:[{duration:$e()}],ease:[{ease:["linear","in","out","in-out",V]}],delay:[{delay:$e()}],animate:[{animate:["none","spin","ping","pulse","bounce",V]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[P]}],"scale-x":[{"scale-x":[P]}],"scale-y":[{"scale-y":[P]}],rotate:[{rotate:[mt,V]}],"translate-x":[{"translate-x":[re]}],"translate-y":[{"translate-y":[re]}],"skew-x":[{"skew-x":[D]}],"skew-y":[{"skew-y":[D]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",V]}],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",V]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"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",V]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Oe,De,rn]}],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"]}}},Nv=cv(Ev);function ke(...e){return Nv(Er(e))}const Ir=I.createContext(null);function Mv(){const e=I.useContext(Ir);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const At=8;function Tv({children:e}){const[t,n]=I.useState({open:!1,x:0,y:0,items:[]}),[o,r]=I.useState(null),s=I.useRef(null),i=I.useCallback(()=>{n(d=>d.open?{...d,open:!1}:d)},[]),a=I.useCallback((d,u,m)=>{r(null),n({open:!0,x:d,y:u,items:m})},[]),l=I.useMemo(()=>({open:a,close:i}),[a,i]);return I.useLayoutEffect(()=>{if(!t.open||!s.current)return;const d=s.current.getBoundingClientRect();let u=t.x,m=t.y;u+d.width>window.innerWidth-At&&(u=Math.max(At,t.x-d.width)),m+d.height>window.innerHeight-At&&(m=Math.max(At,t.y-d.height)),r({left:u,top:m})},[t]),I.useEffect(()=>{if(!t.open)return;const d=g=>{s.current&&!s.current.contains(g.target)&&i()},u=g=>{g.key==="Escape"&&(g.preventDefault(),i())},m=()=>i(),p=()=>i();return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",u,!0),window.addEventListener("wheel",m,{passive:!0}),window.addEventListener("blur",p),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",u,!0),window.removeEventListener("wheel",m),window.removeEventListener("blur",p)}},[t.open,i]),c.jsxs(Ir.Provider,{value:l,children:[e,t.open&&c.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:d=>d.preventDefault(),children:t.items.map((d,u)=>{if(d.type==="separator")return c.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${u}`);const m=d.icon;return c.jsxs("button",{type:"button",role:"menuitem",disabled:d.disabled,className:ke("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",d.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",d.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),d.onSelect()},children:[c.jsxs("span",{className:"flex items-center gap-2",children:[m?c.jsx(m,{className:"size-4"}):null,c.jsx("span",{children:d.label})]}),d.shortcut?c.jsx("span",{className:"text-xs text-muted-foreground",children:d.shortcut}):null]},`${d.label}-${u}`)})})]})}const po=e=>{let t;const n=new Set,o=(d,u)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const p=t;t=u??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(g=>g(t,p))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d))},l=t=e(o,r,a);return a},Av=(e=>e?po(e):po),Cv=e=>e;function Iv(e,t=Cv){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const go=e=>{const t=Av(e),n=o=>Iv(t,o);return Object.assign(n,t),n},Gt=(e=>e?go(e):go),yo={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.nSelected":"{n} 选中","props.empty":"未选中","props.multi":"已选中 {n} 个元件","props.name":"名称","props.note":"备注","props.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","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.place":"元件","tool.placeHint":"点击画布放置;或从端子/母线拖出,同时放置并连接","tool.text":"文字","tool.textHint":"点击画布放置一段文字注释;双击文字可重新编辑","mode.selectWithSel":"拖动元件移动 · 拖端子连线 · 右键打开菜单","mode.selectEmpty":"点选元件 · 拖动移动 · 框选多个 · 右键打开菜单","mode.pan":"拖动画布 · 滚轮缩放 · 按住空格可在其他工具下临时平移","mode.wireDragging":"拖到另一个端子或母线上释放完成连线","mode.wireInit":"从端子按下,拖动到另一个端子或母线上释放","mode.busDragging":"拖动决定母线方向,释放定终点","mode.busInit":"在画布按下定起点,拖动后释放定终点","mode.placeNoKind":"从左侧元件库选择一种元件","mode.placeFromTerm":"拖到目标位置释放,新元件将连接到起点端子","mode.placeNormal":"点击空白放置;或从已有端子 / 母线拖出,同时放置并连接","mode.text":"点击画布放置文字;双击已有文字可编辑;选中后可拖动 / 删除","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.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":"选择 母线 工具(B),在画布上按下拖动","onboard.step2.title":"从母线拖出元件","onboard.step2.body":"切到 元件(P)选一种,按住母线拖到目标位置 — 自动连接","onboard.step3.title":"继续串接","onboard.step3.body":"从任意端子拖出,落到目标即与该端子相连","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.nSelected":"{n} selected","props.empty":"Nothing selected","props.multi":"{n} elements selected","props.name":"Name","props.note":"Note","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","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 one terminal to another to wire","tool.bus":"Busbar","tool.busHint":"Drag on the canvas — press to set start, release to set end","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","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 another terminal or busbar to complete the wire","mode.wireInit":"Press on a terminal, drag to another terminal or busbar, 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.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.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.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":"Draw a busbar","onboard.step1.body":"Pick the busbar tool (B), then press and drag on the canvas","onboard.step2.title":"Drag elements from the bus","onboard.step2.body":"Switch to Place (P), pick a kind, then drag from the bus — it auto-connects","onboard.step3.title":"Chain the next one","onboard.step3.body":"Drag from any terminal — the new element drops pre-connected","onboard.dismiss":"Got it"}},Pr="ole-locale";function Pv(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Pr);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 xo(e){try{window.localStorage.setItem(Pr,e)}catch{}}const Et=Gt((e,t)=>({locale:Pv(),setLocale:n=>{xo(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";xo(n),e({locale:n})}}));function Or(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function Br(e,t){return yo[e][t]??yo.zh[t]??t}function ve(e,t){return Or(Br(Et.getState().locale,e),t)}function te(){const e=Et(t=>t.locale);return(t,n)=>Or(Br(e,t),n)}function Lr(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 vn=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return vn(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return vn(o)(n)}}}},Ov=(e,t)=>(n,o,r)=>{let s={storage:Lr(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,k)=>({...k,...b}),...t},i=!1,a=0;const l=new Set,d=new Set;let u=s.storage;if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...b)},o,r);const m=()=>{const b=s.partialize({...o()});return u.setItem(s.name,{state:b,version:s.version})},p=r.setState;r.setState=(b,k)=>(p(b,k),m());const g=e((...b)=>(n(...b),m()),o,r);r.getInitialState=()=>g;let f;const h=()=>{var b,k;if(!u)return;const w=++a;i=!1,l.forEach(P=>{var z;return P((z=o())!=null?z:g)});const M=((k=s.onRehydrateStorage)==null?void 0:k.call(s,(b=o())!=null?b:g))||void 0;return vn(u.getItem.bind(u))(s.name).then(P=>{if(P)if(typeof P.version=="number"&&P.version!==s.version){if(s.migrate){const z=s.migrate(P.state,P.version);return z instanceof Promise?z.then(D=>[!0,D]):[!0,z]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,P.state];return[!1,void 0]}).then(P=>{var z;if(w!==a)return;const[D,Q]=P;if(f=s.merge(Q,(z=o())!=null?z:g),n(f,!0),D)return m()}).then(()=>{w===a&&(M==null||M(o(),void 0),f=o(),i=!0,d.forEach(P=>P(f)))}).catch(P=>{w===a&&(M==null||M(void 0,P))})};return r.persist={setOptions:b=>{s={...s,...b},b.storage&&(u=b.storage)},clearStorage:()=>{u==null||u.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>h(),hasHydrated:()=>i,onHydrate:b=>(l.add(b),()=>{l.delete(b)}),onFinishHydration:b=>(d.add(b),()=>{d.delete(b)})},s.skipHydration||h(),f||g},Bv=Ov,Be=.5;function zr(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])<Be&&Math.abs(s[1]-e[r][1])<Be||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>Be&&l>Be){const u=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Be?"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])<Be&&Math.abs(i[0]-a[0])<Be,d=Math.abs(s[1]-i[1])<Be&&Math.abs(i[1]-a[1])<Be;l||d||o.push(i)}return o.push(n[n.length-1]),o}function Rr(){return{elements:new Map,buses:new Map,terminals:new Map,nodes:new Map,layout:new Map,wireRenders:new Map,terminalToNode:new Map,elementToTerminals:new Map,diagnostics:[]}}function Dr(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 kn(e){return e===90||e===270?"y":"x"}function Ae(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 Lv={n:"e",e:"s",s:"w",w:"n"},zv={n:"n",s:"s",e:"w",w:"e"};function vt(e,t){let n=t.mirror?zv[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=Lv[n];return n}function _n(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class Fr{constructor(){ut(this,"parent",new Map);ut(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 bo=["n","e","s","w"],wo={n:"s",s:"n",e:"w",w:"e"};function vo(e,t){const n=bo.indexOf(e),r=((bo.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const ko=320,sn=220,ht=260,an=720,pt=30,_o=30,He=80,$o=10,Rv=60,Dv=520,Fv=80,Hv=80,So=8,jo=new Set(["source","renewable"]);function Wv(e){var ro,so,io,ao,lo,co;const{elements:t,buses:n,wires:o,library:r,userLayout:s,userBusLayout:i}=e,a=new Map(s),l=new Map(i),d=new Set(s.keys()),u=new Set(i.keys()),m=new Map;for(const y of t)m.set(y.id,y);const p=new Map;for(const y of n)p.set(y.id,y);const g=y=>{const v=m.get(y);if(v)return r.get(v.kind)},f=new Set(n.map(y=>y.id)),h=y=>f.has(y),b=new Fr;for(const y of o)b.add(y.ends[0]),b.add(y.ends[1]),b.union(y.ends[0],y.ends[1]);for(const y of t){const v=r.get(y.kind);if(v)for(const $ of v.terminals)b.add(`${y.id}.${$.id}`)}for(const y of n)b.add(y.id);const k=[];for(const[,y]of b.groups())y.length>=2&&k.push(y);const w=new Map;for(const y of k)for(const v of y)w.set(v,[y]);const M=new Map;for(const y of k){const v=y.filter(h);if(v.length!==0)for(const $ of v){const S=y.filter(_=>_!==$),j=M.get($)??[];j.push(...S),M.set($,j)}}const P=new Map;for(const y of k){const v=y.filter(h);if(v.length!==0)for(const $ of y){if(h($))continue;const S=$.indexOf(".");if(S<0)continue;const j=$.slice(0,S),_=$.slice(S+1),E=P.get(j)??[];for(const O of v)E.some(T=>T.busId===O&&T.pin===_)||E.push({busId:O,pin:_});P.set(j,E)}}const z=[],D=new Set;for(const[y,v]of P)if(new Set(v.map(S=>S.busId)).size>=2){const S=((so=r.get(((ro=m.get(y))==null?void 0:ro.kind)??""))==null?void 0:so.category)==="transformer"?"vertical":"horizontal";z.push({elementId:y,attachments:v,orientation:S}),S==="vertical"&&D.add(y)}const Q=new Map,re=(y,v)=>{y!==v&&(Q.has(y)||Q.set(y,new Set),Q.has(v)||Q.set(v,new Set),Q.get(y).add(v),Q.get(v).add(y))};for(const y of o)re(y.ends[0],y.ends[1]);for(const y of t){const v=r.get(y.kind);if(!v||v.terminals.length<2)continue;const $=v.terminals.map(S=>`${y.id}.${S.id}`);for(let S=0;S<$.length;S++)for(let j=S+1;j<$.length;j++)re($[S],$[j])}for(const y of t){if(D.has(y.id))continue;const v=r.get(y.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const $=v.terminals.map(_=>`${y.id}.${_.id}`),S=new Map;for(const _ of $){const E=_.slice(y.id.length+1);S.set(E,new Set);const O=new Set($.filter(C=>C!==_)),T=new Set([_]),A=[_];for(;A.length>0;){const C=A.shift();if(h(C)){S.get(E).add(C);continue}const N=Q.get(C);if(N)for(const B of N)T.has(B)||O.has(B)||(T.add(B),A.push(B))}}const j=new Set;for(const _ of S.values())for(const E of _)j.add(E);if(j.size>=2){const _=[];for(const[E,O]of S)for(const T of O)_.push({busId:T,pin:E});z.push({elementId:y.id,attachments:_,orientation:"vertical"}),D.add(y.id)}}const _e=(y,v)=>{var O;const $=g(v),S=$?$.terminals.map(T=>`${v}.${T.id}`):[],j=y,_=new Set([j,...S]),E=[j];for(;E.length>0;){const T=E.shift(),A=T.indexOf(".");if(A>0){const N=T.slice(0,A),B=m.get(N);if(B){const L=(O=r.get(B.kind))==null?void 0:O.category;if(L&&jo.has(L))return!0}}const C=Q.get(T);if(C)for(const N of C)_.has(N)||(_.add(N),E.push(N))}return!1};for(const y of z){if(y.orientation!=="horizontal")continue;const v=new Set(y.attachments.map(S=>S.busId));let $=0;for(const S of v)_e(S,y.elementId)&&$++;$===1&&(y.orientation="vertical",D.add(y.elementId))}for(const y of t){if(D.has(y.id)||y.kind!=="breaker")continue;const v=r.get(y.kind);if(!v||v.terminals.length!==2)continue;const $=v.terminals.map(_=>`${y.id}.${_.id}`),S=new Map;for(const _ of $){const E=_.slice(y.id.length+1),O=new Set($.filter(C=>C!==_)),T=new Set([_]),A=[_];for(;A.length>0;){const C=A.shift();if(h(C)){S.set(E,C);break}const N=Q.get(C);if(N)for(const B of N){if(T.has(B)||O.has(B))continue;const L=B.indexOf(".");if(L>0){const H=B.slice(0,L);if(H!==y.id){const q=m.get(H),K=q?r.get(q.kind):void 0;if((K==null?void 0:K.category)==="transformer")continue}}T.add(B),A.push(B)}}}if(new Set(S.values()).size>=2){const _=[];for(const[E,O]of S)_.push({busId:O,pin:E});z.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const me=new Map;for(const y of n)me.set(y.id,new Map);for(const y of z){const v=Array.from(new Set(y.attachments.map($=>$.busId)));for(const $ of v)for(const S of v)$!==S&&((io=me.get($))==null||io.set(S,y))}const R=y=>{var $;const v=($=r.get(y))==null?void 0:$.category;return v?jo.has(v):!1},F=[];for(const y of n){const v=M.get(y.id);if(v)for(const $ of v){if(h($))continue;const S=$.indexOf(".");if(S<0)continue;const j=$.slice(0,S),_=m.get(j);if(_&&R(_.kind)){F.push(y.id);break}}}F.length===0&&n.length>0&&F.push(n[0].id);const U=new Map;for(const y of F)U.set(y,0);{const y=[...F];for(;y.length>0;){const v=y.shift(),$=U.get(v),S=me.get(v);if(S)for(const[j,_]of S){if(U.has(j))continue;const E=_.orientation==="horizontal"?$:$+1;U.set(j,E),y.push(j)}}}for(const y of n){if(U.has(y.id))continue;const v=U.size===0?-1:Math.max(...Array.from(U.values()));U.set(y.id,v+1)}const oe=new Map;for(const y of n){const v=U.get(y.id),$=oe.get(v)??[];$.push(y.id),oe.set(v,$)}const ie=[...oe.keys()].sort((y,v)=>y-v),Z=(y,v,$)=>{const S=`${y.elementId}.${$}`,j=v,_=g(y.elementId),E=new Set;if(_)for(const N of _.terminals)N.id!==$&&E.add(`${y.elementId}.${N.id}`);const O=new Set([S]),T=[{ref:S,dist:0}],A=new Map,C=(N,B,L,H)=>{O.add(N),A.set(N,B),T.push({ref:N,dist:H+L})};for(;T.length>0;){const{ref:N,dist:B}=T.shift();if(N===j){const K=A.get(j);let ae;if(K){const Y=K.indexOf(".");if(Y>0){const W=K.slice(0,Y);W!==y.elementId&&(ae=W)}}return{extent:B,head:ae}}const L=N.indexOf(".");if(L<0)continue;const H=N.slice(0,L),q=N.slice(L+1);if(!h(H)&&!D.has(H)){const K=g(H),ae=K==null?void 0:K.terminals.find(Y=>Y.id===q);if(K&&ae)for(const Y of K.terminals){if(Y.id===q)continue;const W=`${H}.${Y.id}`;O.has(W)||E.has(W)||C(W,N,Math.abs(ae.y-Y.y),B)}}for(const K of w.get(N)??[])for(const ae of K){if(ae===N||O.has(ae)||E.has(ae))continue;const Y=h(N)||h(ae);C(ae,N,Y?_o:pt,B)}}return{extent:0}},fe=(y,v)=>{var N,B,L;const $=(N=me.get(y))==null?void 0:N.get(v);if(!$||$.orientation==="horizontal")return ht;const S=g($.elementId);if(!S)return ht;const j=(B=$.attachments.find(H=>H.busId===y))==null?void 0:B.pin,_=(L=$.attachments.find(H=>H.busId===v))==null?void 0:L.pin;if(!j||!_)return ht;const E=S.terminals.find(H=>H.id===j),O=S.terminals.find(H=>H.id===_);if(!E||!O)return ht;const T=Math.abs(O.y-E.y),A=Z($,y,j).extent,C=Z($,v,_).extent;return A+T+C},he=new Map;for(const y of z){if(y.orientation!=="vertical")continue;const v=y.attachments.slice().sort((O,T)=>(U.get(O.busId)??0)-(U.get(T.busId)??0));if(v.length<2)continue;const $=v[0].busId,S=v[1].busId,j=v[0].pin,E=Z(y,$,j).head??y.elementId;he.set(E,{lowerBusId:S})}const pe=30,Ie=y=>{const v=g(y);return Math.max((v==null?void 0:v.width)??He,He)},$e=2,Xn=(y,v,$,S=0)=>{const j=g(v);let _=Ie(v);if(j&&!$.has(v)&&S<$e){$.add(v);let E=0;for(const O of j.terminals){const T=`${v}.${O.id}`;if(T!==y)for(const A of w.get(T)??[]){const C=new Set;let N=!1;for(const L of A){if(L===T)continue;if(h(L)){N=!0;continue}const H=L.indexOf(".");if(H<0)continue;const q=L.slice(0,H);q===v||$.has(q)||D.has(q)||C.add(q)}if(N||C.size===0)continue;let B=0;for(const L of C){const H=[...A].find(q=>q.indexOf(".")>0&&q.slice(0,q.indexOf("."))===L);B+=(H?Xn(H,L,$,S+1):Ie(L))+pe}E=Math.max(E,B-pe)}}$.delete(v),_=Math.max(_,E)}return _},lt=320,Qe=new Map,Vn=(y,v)=>{if(!D.has(y))return!1;const $=z.find(E=>E.elementId===y),S=$==null?void 0:$.attachments.find(E=>E.busId!==v);if(!S)return!1;const j=U.get(v)??0;return(U.get(S.busId)??0)<j},ct=(y,v,$)=>{const S=he.get(y);if(S){const _=Qe.get(S.lowerBusId);if(_!==void 0)return Math.max(v,_+He)}let j=0;return $&&(j=Xn($,y,new Set)),Math.max(v,He,j)},Yn=(y,v)=>{if(Qe.has(y))return Qe.get(y);if(v.has(y))return lt;v.add(y);const $=M.get(y)??[];let S=0,j=0;for(const E of $){if(h(E))continue;const O=E.indexOf(".");if(O<0)continue;const T=E.slice(0,O),A=E.slice(O+1);if(Vn(T,y))continue;const C=g(T);if(!C)continue;const N=C.terminals.find(H=>H.id===A);if(!N)continue;const B=he.get(T);B&&Yn(B.lowerBusId,v);const L=ct(T,C.width,`${T}.${A}`);N.y>0?S+=L:j+=L}const _=Math.max(lt,Math.max(S,j)+He);return Qe.set(y,_),v.delete(y),_};for(const y of n)Yn(y.id,new Set);const Re=new Map,vw=(y,v,$)=>{const S=g(v);if(!S)return;const j=`${v}.${$}`,_=S.terminals.filter(T=>T.id!==$).map(T=>`${v}.${T.id}`);if(_.length===0)return;const E=new Set([j,..._]),O=_.slice();for(;O.length>0;){const T=O.shift();if(h(T)&&T!==y){const C=l.get(T);return C?C.at[0]:void 0}for(const C of w.get(T)??[])for(const N of C)N===T||E.has(N)||(E.add(N),O.push(N));const A=T.indexOf(".");if(A>0){const C=T.slice(0,A);if(!h(C)){const N=g(C);if(N)for(const B of N.terminals){const L=`${C}.${B.id}`;E.has(L)||(E.add(L),O.push(L))}}}}},kw=y=>{const v=M.get(y);if(!v||v.length===0)return;const $=l.get(y);if(!$)return;const S=v.flatMap(N=>{if(h(N))return[];const B=N.indexOf(".");if(B<0)return[];const L=N.slice(0,B),H=N.slice(B+1);if(a.has(L))return[];if(Vn(L,y))return[];const q=g(L);if(!q)return[];const K=q.terminals.find(ae=>ae.id===H);return K?[{elId:L,lib:q,localTerm:K,isLinker:D.has(L),busFacingRef:`${L}.${H}`}]:[]});if(S.length===0)return;const j=[],_=[];for(const N of S)N.localTerm.y>0?j.push(N):_.push(N);const E=N=>N.reduce((B,L)=>B+ct(L.elId,L.lib.width,L.busFacingRef),0),O=Math.max(E(j),E(_))+He,T=Math.max($.span,O);T!==$.span&&!u.has(y)&&l.set(y,{...$,span:T});const A=l.get(y),C=(N,B)=>{if(N.length===0)return;const L=new Map;for(const G of N){const X=vw(y,G.elId,G.localTerm.id);X!==void 0&&L.set(G.elId,X)}N.sort((G,X)=>{const ce=L.get(G.elId)??A.at[0],ge=L.get(X.elId)??A.at[0];if(ce!==ge)return ce-ge;const ye=ct(G.elId,G.lib.width,G.busFacingRef);return ct(X.elId,X.lib.width,X.busFacingRef)-ye});const H=N.map(G=>ct(G.elId,G.lib.width,G.busFacingRef)),q=H.reduce((G,X)=>G+X,0),K=Math.max(T,q),ae=(K-q)/(N.length+1);let Y=A.at[0]-K/2+ae;const W=A.at[1]+B*_o;for(let G=0;G<N.length;G++){const X=N[G],ce=H[G],ge=Y+ce/2;X.isLinker?Re.has(X.elId)||Re.set(X.elId,ge):a.set(X.elId,{at:[ue(ge-X.localTerm.x),ue(W-X.localTerm.y)],rot:0,mirror:!1}),Y+=ce+ae}};C(j,-1),C(_,1)},_w=y=>{if(a.has(y.elementId)||y.orientation==="horizontal")return;const v=g(y.elementId);if(!v)return;const $=y.attachments.filter(Y=>l.has(Y.busId));if($.length<2)return;const S=$.slice().sort((Y,W)=>(U.get(Y.busId)??0)-(U.get(W.busId)??0)),j=S[0].busId,_=l.get(j),E=S[0].pin,O=S[S.length-1].pin,T=v.terminals.find(Y=>Y.id===E),A=v.terminals.find(Y=>Y.id===O);if(!T||!A)return;const C=T.y<=A.y?0:180,N=U.get(j)??0,B=$.filter(Y=>(U.get(Y.busId)??0)===N),L=[];let H=0;for(const Y of B){const W=Z(y,Y.busId,Y.pin);H=Math.max(H,W.extent);const G=W.head?a.get(W.head):void 0;G?L.push(G.at[0]):Re.has(y.elementId)?L.push(Re.get(y.elementId)):L.push(l.get(Y.busId).at[0])}let q;L.length>0?q=L.reduce((Y,W)=>Y+W,0)/L.length:Re.has(y.elementId)?q=Re.get(y.elementId):q=_.at[0];const K=_.at[1]+H,ae=C===0?[ue(q-T.x),ue(K-T.y)]:[ue(q+T.x),ue(K+T.y)];if(a.set(y.elementId,{at:ae,rot:C,mirror:!1}),B.length>1){const Y=a.get(y.elementId),W=Ae([T.x,T.y],Y),G=vt(T.orientation,Y);$w(`${y.elementId}.${E}`,W,G,q)}},$w=(y,v,$,S)=>{const j=new Set([y]);let _=y,E=v,O=$;for(;;){const T=w.get(_)??[];let A,C=!1;for(const xe of T){if(xe.length>=3){C=!0;break}const Ye=xe.find(on=>on!==_);if(!(!Ye||j.has(Ye))){if(h(Ye)){C=!0;break}A=Ye;break}}if(C||!A)break;const N=A.indexOf(".");if(N<0)break;const B=A.slice(0,N),L=A.slice(N+1);if(h(B)||D.has(B)||a.has(B))break;const H=g(B);if(!H)break;const q=H.terminals.find(xe=>xe.id===L);if(!q)break;const K=_n(O),ae=[E[0]+K[0]*pt,E[1]+K[1]*pt],Y=wo[O],W=vo(q.orientation,Y),G=Ae([q.x,q.y],{at:[0,0],rot:W,mirror:!1}),X=[ue(S-G[0]),ue(ae[1]-G[1])];a.set(B,{at:X,rot:W,mirror:!1}),j.add(A);const ce=H.terminals.find(xe=>xe.id!==L);if(!ce)break;const ge=`${B}.${ce.id}`;j.add(ge);const ye={at:X,rot:W,mirror:!1};E=Ae([ce.x,ce.y],ye),O=vt(ce.orientation,ye),_=ge}},Sw=y=>{if(a.has(y.elementId)||y.orientation!=="horizontal")return;const v=g(y.elementId);if(!v)return;const $=y.attachments.filter(B=>l.has(B.busId));if($.length<2)return;const S=$.map(B=>{const L=Z(y,B.busId,B.pin),H=L.head?a.get(L.head):void 0,q=H?H.at[0]:l.get(B.busId).at[0];return{att:B,x:q,extent:L.extent}});S.sort((B,L)=>B.x-L.x);const j=S[0],_=S[S.length-1],E=v.terminals.find(B=>B.id===j.att.pin),O=v.terminals.find(B=>B.id===_.att.pin);if(!E||!O)return;const T=E.y<=O.y?270:90,A=(j.x+_.x)/2,N=l.get(j.att.busId).at[1]+Math.max(j.extent,_.extent);a.set(y.elementId,{at:[ue(A),ue(N)],rot:T,mirror:!1})},Un=100;let Tt=sn;for(let y=0;y<ie.length;y++){const v=ie[y],$=oe.get(v);let S;if(y===0)S=sn;else{const _=oe.get(ie[y-1]);let E=0;for(const O of _)for(const T of $)(ao=me.get(O))!=null&&ao.get(T)&&(E=Math.max(E,fe(O,T)));E===0&&(E=ht),S=Tt+E}Tt=S;let j=ko;for(const _ of $){if(l.has(_)){Tt=Math.max(Tt,l.get(_).at[1]);continue}let E;if(y>0){const T=oe.get(ie[y-1]),A=[];for(const C of T){const N=(lo=me.get(C))==null?void 0:lo.get(_);if(!N||N.orientation!=="vertical")continue;const B=(co=N.attachments.find(H=>H.busId===C))==null?void 0:co.pin;if(!B)continue;const L=Z(N,C,B);L.head&&a.has(L.head)?A.push(a.get(L.head).at[0]):Re.has(N.elementId)?A.push(Re.get(N.elementId)):A.push(l.get(C).at[0])}A.length>0&&(E=A.reduce((C,N)=>C+N,0)/A.length)}if(E===void 0){const T=Qe.get(_)??an;E=j+T/2,j+=T+Un}const O=Qe.get(_)??an;l.set(_,{at:[ue(E),ue(S)],rot:0,span:O,axis:kn(0)})}for(const _ of $)kw(_);if(y>0)for(const _ of z)a.has(_.elementId)||!_.attachments.some(O=>$.includes(O.busId))||_w(_);for(const _ of z)_.orientation!=="horizontal"||a.has(_.elementId)||!_.attachments.every(O=>$.includes(O.busId))||Sw(_)}if(n.length===0&&a.size<t.length){const y=j=>{const _=new Set,E=g(j);if(!E)return _;for(const O of E.terminals){const T=`${j}.${O.id}`;for(const A of w.get(T)??[])for(const C of A){if(C===T||h(C))continue;const N=C.indexOf(".");if(N<0)continue;const B=C.slice(0,N);B!==j&&_.add(B)}}return _},v=new Set,$=[];for(const j of t){if(v.has(j.id)||!g(j.id))continue;const _=[],E=[j.id];for(v.add(j.id);E.length>0;){const O=E.pop();_.push(O);for(const T of y(O))v.has(T)||(v.add(T),E.push(T))}_.length>=2&&$.push(_)}let S=ko;for(const j of $){if(j.some(A=>a.has(A)))continue;j.sort((A,C)=>{var q,K;const N=R(((q=m.get(A))==null?void 0:q.kind)??"")?0:1,B=R(((K=m.get(C))==null?void 0:K.kind)??"")?0:1;if(N!==B)return N-B;const L=y(A).size,H=y(C).size;return L!==H?L-H:A.localeCompare(C)});const _=j[0],E=g(_);if(!E)continue;const O=E.terminals.slice().sort((A,C)=>C.y-A.y)[0],T=O?Ae([O.x,O.y],{at:[0,0],rot:0,mirror:!1}):[0,0];a.set(_,{at:[ue(S-T[0]),ue(sn-T[1])],rot:0,mirror:!1}),S+=Math.max(an,j.length*He)+Un}}const jw=y=>{if(h(y))return l.has(y);const v=y.indexOf(".");return v<0?!1:a.has(y.slice(0,v))};let Qt=!0,Ew=t.length+4;for(;Qt&&Ew-- >0;){Qt=!1;for(const y of k){if(y.length<2)continue;const v=[],$=new Map;for(const W of y){if(h(W))continue;const G=W.indexOf(".");if(G<0)continue;const X=W.slice(0,G),ce=W.slice(G+1);if(a.has(X)){v.push(W);continue}if(D.has(X)||$.has(X))continue;const ge=g(X);if(!ge)continue;const ye=ge.terminals.find(xe=>xe.id===ce);ye&&$.set(X,{ref:W,elId:X,lib:ge,localTerm:ye})}if($.size===0||v.length===0)continue;const S=[...$.values()],j=new Map;for(const W of S)for(const G of w.get(W.ref)??[])for(const X of G){if(X===W.ref||h(X)||!jw(X))continue;const ce=X;j.set(ce,(j.get(ce)??0)+1)}let _;if(j.size>0){let W=-1;for(const[G,X]of j)(X>W||X===W&&(_===void 0||G<_))&&(W=X,_=G)}if(_||(_=[...v].sort()[0]),!_)continue;const E=_.indexOf("."),O=_.slice(0,E),T=_.slice(E+1),A=g(O),C=a.get(O);if(!A||!C)continue;const N=A.terminals.find(W=>W.id===T);if(!N)continue;const B=Ae([N.x,N.y],C),L=vt(N.orientation,C),H=_n(L),q=[-H[1],H[0]];S.sort((W,G)=>W.elId.localeCompare(G.elId));const K=S.map(W=>Math.max(W.lib.width,He));let Y=-K.reduce((W,G)=>W+G,0)/2;for(let W=0;W<S.length;W++){const G=S[W],X=K[W],ce=Y+X/2;Y+=X;const ge=wo[L],ye=vo(G.localTerm.orientation,ge),xe=Ae([G.localTerm.x,G.localTerm.y],{at:[0,0],rot:ye,mirror:!1}),Ye=[B[0]+H[0]*pt+q[0]*ce,B[1]+H[1]*pt+q[1]*ce],on=[ue(Ye[0]-xe[0]),ue(Ye[1]-xe[1])];a.set(G.elId,{at:on,rot:ye,mirror:!1}),Qt=!0}}}const dt=y=>{const v=a.get(y),$=g(y);if(!v||!$)return null;const S=$.viewBox.split(/\s+/).map(Number);if(S.length<4||S.some(N=>Number.isNaN(N))){const N=$.width/2;return{min:v.at[0]-N,max:v.at[0]+N}}const[j,_,E,O]=S,T=[[j,_],[j+E,_],[j,_+O],[j+E,_+O]];let A=1/0,C=-1/0;for(const N of T){const B=Ae(N,v);A=Math.min(A,B[0]),C=Math.max(C,B[0])}return{min:A,max:C}},Jt=y=>{const v=new Set,$=g(y);if(!$)return v;for(const S of $.terminals){const j=`${y}.${S.id}`;for(const _ of w.get(j)??[])for(const E of _){if(E===j||h(E))continue;const O=E.indexOf(".");if(O<0)continue;const T=E.slice(0,O);T!==y&&v.add(T)}}return v},Zn=40,en=y=>{const v=a.get(y),$=g(y);if(!v||!$)return null;const S=$.viewBox.split(/\s+/).map(Number);if(S.length<4||S.some(N=>Number.isNaN(N))){const N=$.height/2;return{min:v.at[1]-N,max:v.at[1]+N}}const[j,_,E,O]=S,T=[[j,_],[j+E,_],[j,_+O],[j+E,_+O]];let A=1/0,C=-1/0;for(const N of T){const B=Ae(N,v);A=Math.min(A,B[1]),C=Math.max(C,B[1])}return{min:A,max:C}},Nw=(y,v)=>{const $=new Set,S=[];for(const j of M.get(y)??[]){if(h(j))continue;const _=j.indexOf(".");if(_<0)continue;const E=j.slice(0,_),O=a.get(E);!O||O.at[1]>=v-1||$.has(E)||($.add(E),S.push(E))}for(;S.length>0;){const j=S.pop();for(const _ of Jt(j)){if($.has(_))continue;const E=a.get(_);!E||E.at[1]>=v-1||($.add(_),S.push(_))}}return $},Qn=(y,v,$)=>{const S=new Set([y]),j=[y];for(;j.length>0;){const _=j.pop();for(const E of Jt(_))E===v||S.has(E)||!$.has(E)||(S.add(E),j.push(E))}return S},Jn=(y,v)=>{let $=y.length*y.length+8,S=!1,j=!0;for(;j&&$-- >0;){j=!1;for(let _=0;_<y.length&&!j;_++)for(let E=_+1;E<y.length;E++){const O=y[_],T=y[E],A=dt(O),C=dt(T),N=en(O),B=en(T);if(!A||!C||!N||!B)continue;const L=Math.min(A.max,C.max)-Math.max(A.min,C.min),H=Math.min(N.max,B.max)-Math.max(N.min,B.min);if(L<=0||H<=0)continue;const q=Qn(O,T,v),K=Qn(T,O,v);if(q.has(T)||K.has(O))continue;const ae=![...q].some(ye=>d.has(ye)),Y=![...K].some(ye=>d.has(ye));if(!ae&&!Y)continue;const W=(A.min+A.max)/2,G=(C.min+C.max)/2;let X,ce;ae&&(!Y||q.size<=K.size)?(X=q,ce=W<=G?-1:1):(X=K,ce=G<=W?-1:1);const ge=ue(ce*(L+Zn));if(ge!==0){for(const ye of X){const xe=a.get(ye);xe&&a.set(ye,{...xe,at:[xe.at[0]+ge,xe.at[1]]})}S=!0,j=!0;break}}}return S};for(const y of n){const v=l.get(y.id);if(!v)continue;const $=Nw(y.id,v.at[1]);if($.size<2)continue;const S=[...$];if(Jn(S,$)){let _=1/0,E=-1/0;for(const O of S){const T=dt(O);T&&(_=Math.min(_,T.min),E=Math.max(E,T.max))}if(Number.isFinite(_)){const T=S.some(C=>d.has(C))?0:ue(v.at[0]-(_+E)/2);if(T!==0)for(const C of S){const N=a.get(C);N&&a.set(C,{...N,at:[N.at[0]+T,N.at[1]]})}const A=E-_+Zn;if(A>v.span&&!u.has(y.id)){const C=l.get(y.id);l.set(y.id,{...C,span:A})}}}}const eo=()=>{const v=t.map(S=>S.id).filter(S=>a.has(S)).map(S=>({x:dt(S),y:en(S)})).filter(S=>S.x&&S.y);let $=0;for(let S=0;S<v.length;S++)for(let j=S+1;j<v.length;j++){const _=Math.min(v[S].x.max,v[j].x.max)-Math.max(v[S].x.min,v[j].x.min),E=Math.min(v[S].y.max,v[j].y.max)-Math.max(v[S].y.min,v[j].y.min);_>1&&E>1&&$++}return $},Mw=eo(),to=new Map;for(const[y,v]of a)to.set(y,{...v,at:[...v.at]});const no=new Map;for(const[y,v]of l)no.set(y,{...v,at:[...v.at]});const tn=120,oo=new Map;{const y=new Map,v=new Map,$=[];for(const j of n)for(const _ of M.get(j.id)??[]){if(h(_))continue;const E=_.indexOf(".");if(E<0)continue;const O=_.slice(0,E);a.has(O)&&$.push({el:O,bus:j.id,d:1})}$.sort((j,_)=>j.d-_.d);let S=0;for(;S<$.length;){const{el:j,bus:_,d:E}=$[S++],O=y.get(j);if(O===void 0)y.set(j,E),v.set(j,_);else if(E===O&&v.get(j)!==_){v.set(j,null);continue}else continue;for(const T of Jt(j))a.has(T)&&(y.has(T)||$.push({el:T,bus:_,d:E+1}))}for(const[j,_]of v)_&&oo.set(j,_)}for(const y of ie){const v=(oe.get(y)??[]).filter(A=>l.has(A));if(v.length<2||v.some(A=>u.has(A)))continue;const $=[];let S=0;for(const A of v){const C=l.get(A),N=[];let B=1/0,L=-1/0;for(const[H,q]of oo){if(q!==A)continue;const K=dt(H);K&&(N.push(H),B=Math.min(B,K.min),L=Math.max(L,K.max))}Number.isFinite(B)||(B=C.at[0]-lt/2,L=C.at[0]+lt/2),$.push({busId:A,min:B,max:L,members:N}),S+=L-B}if($.some(A=>A.members.some(C=>d.has(C))))continue;let j=1/0,_=-1/0;for(const A of $)j=Math.min(j,A.min),_=Math.max(_,A.max);const E=_-j,O=S+tn*($.length-1);if(!(E>O+tn))continue;$.sort((A,C)=>(A.min+A.max)/2-(C.min+C.max)/2);let T=j;for(const A of $){const C=ue(T-A.min);if(C!==0){const N=l.get(A.busId);l.set(A.busId,{...N,at:[N.at[0]+C,N.at[1]]});for(const B of A.members){const L=a.get(B);L&&a.set(B,{...L,at:[L.at[0]+C,L.at[1]]})}A.min+=C,A.max+=C}T=A.max+tn}for(const A of $){const C=l.get(A.busId),N=Math.max(lt,A.max-A.min);N<C.span&&l.set(A.busId,{...C,span:N})}}{const y=t.map($=>$.id).filter($=>a.has($)),v=new Set(y);Jn(y,v)}if(eo()>Mw){a.clear();for(const[y,v]of to)a.set(y,v);l.clear();for(const[y,v]of no)l.set(y,v)}let nn=0;for(const y of t){if(a.has(y.id))continue;const v=nn%So,$=Math.floor(nn/So);a.set(y.id,{at:[ue(Rv+v*Fv),ue(Dv+$*Hv)],rot:0,mirror:!1}),nn++}return{devices:a,buses:l}}function ue(e){return Math.round(e/$o)*$o}function qv(e,t){const n=e.ends[0],o=e.ends[1],r=Eo(n,t),s=Eo(o,t);if(r||s){const l=r?n:o,u=ln(r?o:n,t);if(!u)return null;const m=t.buses.get(l);if(!m)return null;const{axis:p,at:g,span:f}=m.geometry,h=f/2;let b;if(p==="x")b=[Rt(u[0],g[0]-h,g[0]+h),g[1]];else{const k=Rt(u[1],g[1]-h,g[1]+h);b=[g[0],k]}return{wireId:e.id,path:Mo(u,b)}}const i=ln(n,t),a=ln(o,t);return!i||!a?null:{wireId:e.id,path:Mo(i,a)}}function Eo(e,t){return!e.includes(".")&&t.buses.has(e)}function ln(e,t){if(!e.includes(".")){const o=t.buses.get(e);return o?o.geometry.at:null}const n=t.terminals.get(e);return n?n.world:null}function No(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r)return 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[Rt(t[0],i[0]-l,i[0]+l),i[1]];const d=Rt(t[1],i[1]-l,i[1]+l);return[i[0],d]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function Mo(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Rt(e,t,n){return e<t?t:e>n?n:e}const Hr="ammeter",Wr="电流表 (A)",qr="measurement",Gr="-22 -42 44 44",Kr=44,Xr=44,Vr='<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>',Yr=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ur={kind:"inline"},Gv={id:Hr,name:Wr,category:qr,viewBox:Gr,width:Kr,height:Xr,svg:Vr,terminals:Yr,source:Ur},Kv=Object.freeze(Object.defineProperty({__proto__:null,category:qr,default:Gv,height:Xr,id:Hr,name:Wr,source:Ur,svg:Vr,terminals:Yr,viewBox:Gr,width:Kr},Symbol.toStringTag,{value:"Module"})),Zr="arc-suppression-coil",Qr="消弧线圈",Jr="grounding",es="中性点谐振接地:电感线圈连接到地",ts="-12 -32 24 67",ns=24,os=67,rs='<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"/>',ss=[{id:"t_top",x:0,y:-30,orientation:"n"}],is={kind:"inline"},Xv={id:Zr,name:Qr,category:Jr,description:es,viewBox:ts,width:ns,height:os,svg:rs,terminals:ss,source:is},Vv=Object.freeze(Object.defineProperty({__proto__:null,category:Jr,default:Xv,description:es,height:os,id:Zr,name:Qr,source:is,svg:rs,terminals:ss,viewBox:ts,width:ns},Symbol.toStringTag,{value:"Module"})),as="arrester",ls="避雷器 (FBL)",cs="protection",ds="-7 -22 14 44",us=14,ms=44,fs='<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"/>',hs=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ps={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},Yv={id:as,name:ls,category:cs,viewBox:ds,width:us,height:ms,svg:fs,terminals:hs,source:ps},Uv=Object.freeze(Object.defineProperty({__proto__:null,category:cs,default:Yv,height:ms,id:as,name:ls,source:ps,svg:fs,terminals:hs,viewBox:ds,width:us},Symbol.toStringTag,{value:"Module"})),gs="async-motor",ys="异步电动机",xs="load",bs="-62 -82 64 84",ws=64,vs=84,ks='<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"/>',_s=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],$s={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"},Zv={id:gs,name:ys,category:xs,viewBox:bs,width:ws,height:vs,svg:ks,terminals:_s,source:$s},Qv=Object.freeze(Object.defineProperty({__proto__:null,category:xs,default:Zv,height:vs,id:gs,name:ys,source:$s,svg:ks,terminals:_s,viewBox:bs,width:ws},Symbol.toStringTag,{value:"Module"})),Ss="autotransformer",js="自耦变压器",Es="transformer",Ns="-62 -112 64 144",Ms=64,Ts=144,As='<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"/>',Cs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Is={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},Jv={id:Ss,name:js,category:Es,viewBox:Ns,width:Ms,height:Ts,svg:As,terminals:Cs,source:Is},e2=Object.freeze(Object.defineProperty({__proto__:null,category:Es,default:Jv,height:Ts,id:Ss,name:js,source:Is,svg:As,terminals:Cs,viewBox:Ns,width:Ms},Symbol.toStringTag,{value:"Module"})),Ps="battery",Os="电池储能",Bs="storage",Ls="-12 -12 29 24",zs=29,Rs=24,Ds='<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"/>',Fs=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],Hs=[{name:"E",label:"容量",type:"number",unit:"kWh"}],Ws={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},t2={id:Ps,name:Os,category:Bs,viewBox:Ls,width:zs,height:Rs,svg:Ds,terminals:Fs,params:Hs,source:Ws},n2=Object.freeze(Object.defineProperty({__proto__:null,category:Bs,default:t2,height:Rs,id:Ps,name:Os,params:Hs,source:Ws,svg:Ds,terminals:Fs,viewBox:Ls,width:zs},Symbol.toStringTag,{value:"Module"})),qs="bell",Gs="电铃 (HA)",Ks="control",Xs="信号电铃 / 警铃。",Vs="-32 -32 44 44",Ys=44,Us=44,Zs='<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"/>',Qs=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Js={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},o2={id:qs,name:Gs,category:Ks,description:Xs,viewBox:Vs,width:Ys,height:Us,svg:Zs,terminals:Qs,source:Js},r2=Object.freeze(Object.defineProperty({__proto__:null,category:Ks,default:o2,description:Xs,height:Us,id:qs,name:Gs,source:Js,svg:Zs,terminals:Qs,viewBox:Vs,width:Ys},Symbol.toStringTag,{value:"Module"})),ei="break-contact",ti="常闭触点 (NC)",ni="control",oi="常闭辅助触点 (break contact)。",ri="-2 -42 14 64",si=14,ii=64,ai='<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"/>',li=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ci=[{name:"open",type:"boolean",default:!1,label:"断开"}],di={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},s2={id:ei,name:ti,category:ni,description:oi,viewBox:ri,width:si,height:ii,svg:ai,terminals:li,state:ci,source:di},i2=Object.freeze(Object.defineProperty({__proto__:null,category:ni,default:s2,description:oi,height:ii,id:ei,name:ti,source:di,state:ci,svg:ai,terminals:li,viewBox:ri,width:si},Symbol.toStringTag,{value:"Module"})),ui="breaker",mi="断路器 (QF)",fi="switching",hi="-7 -22 15 46",pi=15,gi=46,yi='<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"/><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>',xi=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],bi=[{name:"open",type:"boolean",default:!1,label:"断开"}],wi={x:6,y:-2,anchor:"start"},vi={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},a2={id:ui,name:mi,category:fi,viewBox:hi,width:pi,height:gi,svg:yi,terminals:xi,state:bi,label:wi,source:vi},l2=Object.freeze(Object.defineProperty({__proto__:null,category:fi,default:a2,height:gi,id:ui,label:wi,name:mi,source:vi,state:bi,svg:yi,terminals:xi,viewBox:hi,width:pi},Symbol.toStringTag,{value:"Module"})),ki="buchholz-relay",_i="瓦斯继电器 (63)",$i="protection",Si="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",ji="-22 -62 44 64",Ei=44,Ni=64,Mi='<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"/>',Ti=[{id:"t_top",x:0,y:-60,orientation:"n"}],Ai={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"},c2={id:ki,name:_i,category:$i,description:Si,viewBox:ji,width:Ei,height:Ni,svg:Mi,terminals:Ti,source:Ai},d2=Object.freeze(Object.defineProperty({__proto__:null,category:$i,default:c2,description:Si,height:Ni,id:ki,name:_i,source:Ai,svg:Mi,terminals:Ti,viewBox:ji,width:Ei},Symbol.toStringTag,{value:"Module"})),Ci="busbar",Ii="母线段",Pi="busbar",Oi="可拉伸单母线段,多设备挂接",Bi="-42 -4 84 8",Li=84,zi=8,Ri='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',Di=[{id:"tap",x:0,y:0,orientation:"n"}],Fi={axis:"x",minLength:20,naturalSpan:80},Hi=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],Wi={x:0,y:-6,anchor:"middle"},qi={kind:"inline"},u2={id:Ci,name:Ii,category:Pi,description:Oi,viewBox:Bi,width:Li,height:zi,svg:Ri,terminals:Di,stretchable:Fi,params:Hi,label:Wi,source:qi},m2=Object.freeze(Object.defineProperty({__proto__:null,category:Pi,default:u2,description:Oi,height:zi,id:Ci,label:Wi,name:Ii,params:Hi,source:qi,stretchable:Fi,svg:Ri,terminals:Di,viewBox:Bi,width:Li},Symbol.toStringTag,{value:"Module"})),Gi="buzzer",Ki="蜂鸣器 (HA)",Xi="control",Vi="信号蜂鸣器。",Yi="-32 -52 44 64",Ui=44,Zi=64,Qi='<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"/>',Ji=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ea={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},f2={id:Gi,name:Ki,category:Xi,description:Vi,viewBox:Yi,width:Ui,height:Zi,svg:Qi,terminals:Ji,source:ea},h2=Object.freeze(Object.defineProperty({__proto__:null,category:Xi,default:f2,description:Vi,height:Zi,id:Gi,name:Ki,source:ea,svg:Qi,terminals:Ji,viewBox:Yi,width:Ui},Symbol.toStringTag,{value:"Module"})),ta="capacitor",na="电容 (C)",oa="passive",ra="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",sa="-7 -23 14 27",ia=14,aa=27,la='<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"/>',ca=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],da=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],ua={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},p2={id:ta,name:na,category:oa,description:ra,viewBox:sa,width:ia,height:aa,svg:la,terminals:ca,params:da,source:ua},g2=Object.freeze(Object.defineProperty({__proto__:null,category:oa,default:p2,description:ra,height:aa,id:ta,name:na,params:da,source:ua,svg:la,terminals:ca,viewBox:sa,width:ia},Symbol.toStringTag,{value:"Module"})),ma="contactor",fa="接触器 (KM)",ha="motor-control",pa="主回路接触器, 通常配热继电器和电机使用。",ga="-10 -42 15 64",ya=15,xa=64,ba='<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"/>',wa=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],va=[{name:"open",type:"boolean",default:!0,label:"断开"}],ka={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"},y2={id:ma,name:fa,category:ha,description:pa,viewBox:ga,width:ya,height:xa,svg:ba,terminals:wa,state:va,source:ka},x2=Object.freeze(Object.defineProperty({__proto__:null,category:ha,default:y2,description:pa,height:xa,id:ma,name:fa,source:ka,state:va,svg:ba,terminals:wa,viewBox:ga,width:ya},Symbol.toStringTag,{value:"Module"})),_a="converter-bidir",$a="双向变流器 (PCS)",Sa="renewable",ja="储能变流器:双向 AC ↔ DC",Ea="-42 -42 44 48",Na=44,Ma=48,Ta='<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"/>',Aa=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],Ca=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Ia={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},b2={id:_a,name:$a,category:Sa,description:ja,viewBox:Ea,width:Na,height:Ma,svg:Ta,terminals:Aa,params:Ca,source:Ia},w2=Object.freeze(Object.defineProperty({__proto__:null,category:Sa,default:b2,description:ja,height:Ma,id:_a,name:$a,params:Ca,source:Ia,svg:Ta,terminals:Aa,viewBox:Ea,width:Na},Symbol.toStringTag,{value:"Module"})),Pa="ct",Oa="电流互感器 (CT)",Ba="instrument-transformer",La="-42 -62 54 64",za=54,Ra=64,Da='<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"/>',Fa=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-60,orientation:"n"}],Ha={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},v2={id:Pa,name:Oa,category:Ba,viewBox:La,width:za,height:Ra,svg:Da,terminals:Fa,source:Ha},k2=Object.freeze(Object.defineProperty({__proto__:null,category:Ba,default:v2,height:Ra,id:Pa,name:Oa,source:Ha,svg:Da,terminals:Fa,viewBox:La,width:za},Symbol.toStringTag,{value:"Module"})),Wa="dc-combiner",qa="直流汇流箱",Ga="renewable",Ka="光伏组串汇流箱 (4 路输入示例)。",Xa="-27 -32 54 64",Va=54,Ya=64,Ua='<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>',Za=[{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"}],Qa={kind:"inline"},_2={id:Wa,name:qa,category:Ga,description:Ka,viewBox:Xa,width:Va,height:Ya,svg:Ua,terminals:Za,source:Qa},$2=Object.freeze(Object.defineProperty({__proto__:null,category:Ga,default:_2,description:Ka,height:Ya,id:Wa,name:qa,source:Qa,svg:Ua,terminals:Za,viewBox:Xa,width:Va},Symbol.toStringTag,{value:"Module"})),Ja="dc-disconnector",el="直流隔离开关",tl="switching",nl="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",ol="-12 -32 30 64",rl=30,sl=64,il='<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"/>',al=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],ll=[{name:"open",type:"boolean",default:!1,label:"断开"}],cl={kind:"inline"},S2={id:Ja,name:el,category:tl,description:nl,viewBox:ol,width:rl,height:sl,svg:il,terminals:al,state:ll,source:cl},j2=Object.freeze(Object.defineProperty({__proto__:null,category:tl,default:S2,description:nl,height:sl,id:Ja,name:el,source:cl,state:ll,svg:il,terminals:al,viewBox:ol,width:rl},Symbol.toStringTag,{value:"Module"})),dl="dc-motor",ul="直流电机 (M)",ml="load",fl="直流电动机 (串励通用符号)。",hl="-72 -82 89 84",pl=89,gl=84,yl='<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"/>',xl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],bl={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},E2={id:dl,name:ul,category:ml,description:fl,viewBox:hl,width:pl,height:gl,svg:yl,terminals:xl,source:bl},N2=Object.freeze(Object.defineProperty({__proto__:null,category:ml,default:E2,description:fl,height:gl,id:dl,name:ul,source:bl,svg:yl,terminals:xl,viewBox:hl,width:pl},Symbol.toStringTag,{value:"Module"})),wl="diode",vl="二极管 (D)",kl="passive",_l="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",$l="-12 -42 24 44",Sl=24,jl=44,El='<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"/>',Nl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ml={x:6,y:-20,anchor:"start"},Tl={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},M2={id:wl,name:vl,category:kl,description:_l,viewBox:$l,width:Sl,height:jl,svg:El,terminals:Nl,label:Ml,source:Tl},T2=Object.freeze(Object.defineProperty({__proto__:null,category:kl,default:M2,description:_l,height:jl,id:wl,label:Ml,name:vl,source:Tl,svg:El,terminals:Nl,viewBox:$l,width:Sl},Symbol.toStringTag,{value:"Module"})),Al="disconnector",Cl="隔离开关 (QS)",Il="switching",Pl="-10 -42 15 64",Ol=15,Bl=64,Ll='<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"/>',zl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Rl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Dl={x:6,y:-10,anchor:"start"},Fl={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},A2={id:Al,name:Cl,category:Il,viewBox:Pl,width:Ol,height:Bl,svg:Ll,terminals:zl,state:Rl,label:Dl,source:Fl},C2=Object.freeze(Object.defineProperty({__proto__:null,category:Il,default:A2,height:Bl,id:Al,label:Dl,name:Cl,source:Fl,state:Rl,svg:Ll,terminals:zl,viewBox:Pl,width:Ol},Symbol.toStringTag,{value:"Module"})),Hl="distance-relay",Wl="距离继电器 (21)",ql="protection",Gl="距离 / 低阻抗保护继电器 (ANSI 21)。",Kl="-62 -42 64 44",Xl=64,Vl=44,Yl='<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 <</text>',Ul=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Zl={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},I2={id:Hl,name:Wl,category:ql,description:Gl,viewBox:Kl,width:Xl,height:Vl,svg:Yl,terminals:Ul,source:Zl},P2=Object.freeze(Object.defineProperty({__proto__:null,category:ql,default:I2,description:Gl,height:Vl,id:Hl,name:Wl,source:Zl,svg:Yl,terminals:Ul,viewBox:Kl,width:Xl},Symbol.toStringTag,{value:"Module"})),Ql="earth",Jl="接地",ec="busbar",tc="-12 -17 24 34",nc=24,oc=34,rc='<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"/>',sc=[{id:"t1",x:0,y:-15,orientation:"n"}],ic={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"},O2={id:Ql,name:Jl,category:ec,viewBox:tc,width:nc,height:oc,svg:rc,terminals:sc,source:ic},B2=Object.freeze(Object.defineProperty({__proto__:null,category:ec,default:O2,height:oc,id:Ql,name:Jl,source:ic,svg:rc,terminals:sc,viewBox:tc,width:nc},Symbol.toStringTag,{value:"Module"})),ac="earthing-switch",lc="接地刀闸 (QE)",cc="switching",dc="隔离开关 + 接地连接,单端口",uc="-12 -32 24 64",mc=24,fc=64,hc='<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"/>',pc=[{id:"t_top",x:0,y:-30,orientation:"n"}],gc=[{name:"open",type:"boolean",default:!0,label:"断开"}],yc={x:12,y:-8,anchor:"start"},xc={kind:"inline"},L2={id:ac,name:lc,category:cc,description:dc,viewBox:uc,width:mc,height:fc,svg:hc,terminals:pc,state:gc,label:yc,source:xc},z2=Object.freeze(Object.defineProperty({__proto__:null,category:cc,default:L2,description:dc,height:fc,id:ac,label:yc,name:lc,source:xc,state:gc,svg:hc,terminals:pc,viewBox:uc,width:mc},Symbol.toStringTag,{value:"Module"})),bc="energy-meter",wc="电能表 (Wh)",vc="measurement",kc="有功电能表 (kWh) — 服务入口 / 子表。",_c="-22 -36 44 72",$c=44,Sc=72,jc='<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"/>',Ec=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Nc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},R2={id:bc,name:wc,category:vc,description:kc,viewBox:_c,width:$c,height:Sc,svg:jc,terminals:Ec,source:Nc},D2=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:R2,description:kc,height:Sc,id:bc,name:wc,source:Nc,svg:jc,terminals:Ec,viewBox:_c,width:$c},Symbol.toStringTag,{value:"Module"})),Mc="ev-charger",Tc="EV 充电桩",Ac="load",Cc="电动汽车充电站 / 充电桩。",Ic="-17 -27 34 49",Pc=34,Oc=49,Bc='<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>',Lc=[{id:"t_top",x:0,y:-25,orientation:"n"}],zc={kind:"inline"},F2={id:Mc,name:Tc,category:Ac,description:Cc,viewBox:Ic,width:Pc,height:Oc,svg:Bc,terminals:Lc,source:zc},H2=Object.freeze(Object.defineProperty({__proto__:null,category:Ac,default:F2,description:Cc,height:Oc,id:Mc,name:Tc,source:zc,svg:Bc,terminals:Lc,viewBox:Ic,width:Pc},Symbol.toStringTag,{value:"Module"})),Rc="frequency-meter",Dc="频率表 (Hz)",Fc="measurement",Hc="-22 -42 44 44",Wc=44,qc=44,Gc='<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>',Kc=[{id:"t_top",x:0,y:-40,orientation:"n"}],Xc={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},W2={id:Rc,name:Dc,category:Fc,viewBox:Hc,width:Wc,height:qc,svg:Gc,terminals:Kc,source:Xc},q2=Object.freeze(Object.defineProperty({__proto__:null,category:Fc,default:W2,height:qc,id:Rc,name:Dc,source:Xc,svg:Gc,terminals:Kc,viewBox:Hc,width:Wc},Symbol.toStringTag,{value:"Module"})),Vc="fuse-switch-disconnector",Yc="熔断器式隔离开关",Uc="switching",Zc="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",Qc="-8 -32 12 64",Jc=12,ed=64,td='<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"/>',nd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],od=[{name:"open",type:"boolean",default:!1,label:"断开"}],rd={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"},G2={id:Vc,name:Yc,category:Uc,description:Zc,viewBox:Qc,width:Jc,height:ed,svg:td,terminals:nd,state:od,source:rd},K2=Object.freeze(Object.defineProperty({__proto__:null,category:Uc,default:G2,description:Zc,height:ed,id:Vc,name:Yc,source:rd,state:od,svg:td,terminals:nd,viewBox:Qc,width:Jc},Symbol.toStringTag,{value:"Module"})),sd="fuse",id="熔断器 (FU)",ad="switching",ld="-7 -32 14 64",cd=14,dd=64,ud='<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"/>',md=[{id:"t1",x:0,y:30,orientation:"s"},{id:"t2",x:0,y:-30,orientation:"n"}],fd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],hd={x:7,y:-2,anchor:"start"},pd={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},X2={id:sd,name:id,category:ad,viewBox:ld,width:cd,height:dd,svg:ud,terminals:md,state:fd,label:hd,source:pd},V2=Object.freeze(Object.defineProperty({__proto__:null,category:ad,default:X2,height:dd,id:sd,label:hd,name:id,source:pd,state:fd,svg:ud,terminals:md,viewBox:ld,width:cd},Symbol.toStringTag,{value:"Module"})),gd="generator",yd="发电机 (G)",xd="source",bd="-42 -42 44 44",wd=44,vd=44,kd='<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>',_d=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],$d={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},Y2={id:gd,name:yd,category:xd,viewBox:bd,width:wd,height:vd,svg:kd,terminals:_d,source:$d},U2=Object.freeze(Object.defineProperty({__proto__:null,category:xd,default:Y2,height:vd,id:gd,name:yd,source:$d,svg:kd,terminals:_d,viewBox:bd,width:wd},Symbol.toStringTag,{value:"Module"})),Sd="genset",jd="发电机组 (G)",Ed="source",Nd="柴油 / 燃气发电机组。",Md="-28 -22 56 64",Td=56,Ad=64,Cd='<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"/>',Id=[{id:"t_out",x:0,y:40,orientation:"s"}],Pd=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Od={kind:"inline"},Z2={id:Sd,name:jd,category:Ed,description:Nd,viewBox:Md,width:Td,height:Ad,svg:Cd,terminals:Id,params:Pd,source:Od},Q2=Object.freeze(Object.defineProperty({__proto__:null,category:Ed,default:Z2,description:Nd,height:Ad,id:Sd,name:jd,params:Pd,source:Od,svg:Cd,terminals:Id,viewBox:Md,width:Td},Symbol.toStringTag,{value:"Module"})),Bd="gfci-breaker",Ld="GFCI 断路器 (RCBO)",zd="protection",Rd="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",Dd="-18 -22 22 44",Fd=22,Hd=44,Wd='<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"/>',qd=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Gd=[{name:"open",type:"boolean",default:!1,label:"断开"}],Kd=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],Xd={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},J2={id:Bd,name:Ld,category:zd,description:Rd,viewBox:Dd,width:Fd,height:Hd,svg:Wd,terminals:qd,state:Gd,params:Kd,source:Xd},ek=Object.freeze(Object.defineProperty({__proto__:null,category:zd,default:J2,description:Rd,height:Hd,id:Bd,name:Ld,params:Kd,source:Xd,state:Gd,svg:Wd,terminals:qd,viewBox:Dd,width:Fd},Symbol.toStringTag,{value:"Module"})),Vd="grid-source",Yd="系统电源",Ud="source",Zd="无穷大母线 / 外部电网",Qd="-16 -31 32 53",Jd=32,eu=53,tu='<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"/>',nu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],ou={kind:"inline"},tk={id:Vd,name:Yd,category:Ud,description:Zd,viewBox:Qd,width:Jd,height:eu,svg:tu,terminals:nu,source:ou},nk=Object.freeze(Object.defineProperty({__proto__:null,category:Ud,default:tk,description:Zd,height:eu,id:Vd,name:Yd,source:ou,svg:tu,terminals:nu,viewBox:Qd,width:Jd},Symbol.toStringTag,{value:"Module"})),ru="grounding-transformer",su="接地变 (Z形)",iu="grounding",au="星-曲折接线变压器,中性点接地用",lu="-62 -152 64 164",cu=64,du=164,uu='<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"/>',mu=[{id:"t1",x:-30,y:10,orientation:"s"},{id:"t2",x:-30,y:-150,orientation:"n"}],fu={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"},ok={id:ru,name:su,category:iu,description:au,viewBox:lu,width:cu,height:du,svg:uu,terminals:mu,source:fu},rk=Object.freeze(Object.defineProperty({__proto__:null,category:iu,default:ok,description:au,height:du,id:ru,name:su,source:fu,svg:uu,terminals:mu,viewBox:lu,width:cu},Symbol.toStringTag,{value:"Module"})),hu="heater",pu="电加热器 (EH)",gu="load",yu="电阻加热元件 / 电热负荷。",xu="-22 -7 54 14",bu=54,wu=14,vu='<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"/>',ku=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],_u=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],$u={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},sk={id:hu,name:pu,category:gu,description:yu,viewBox:xu,width:bu,height:wu,svg:vu,terminals:ku,params:_u,source:$u},ik=Object.freeze(Object.defineProperty({__proto__:null,category:gu,default:sk,description:yu,height:wu,id:hu,name:pu,params:_u,source:$u,svg:vu,terminals:ku,viewBox:xu,width:bu},Symbol.toStringTag,{value:"Module"})),Su="igbt",ju="绝缘栅双极晶体管 (IGBT)",Eu="passive",Nu="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Mu="-32 -32 54 74",Tu=54,Au=74,Cu='<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"/>',Iu=[{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"}],Pu={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"},ak={id:Su,name:ju,category:Eu,description:Nu,viewBox:Mu,width:Tu,height:Au,svg:Cu,terminals:Iu,source:Pu},lk=Object.freeze(Object.defineProperty({__proto__:null,category:Eu,default:ak,description:Nu,height:Au,id:Su,name:ju,source:Pu,svg:Cu,terminals:Iu,viewBox:Mu,width:Tu},Symbol.toStringTag,{value:"Module"})),Ou="indicator-light",Bu="指示灯 (HL)",Lu="control",zu="信号 / 状态指示灯。",Ru="-12 -22 24 24",Du=24,Fu=24,Hu='<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"/>',Wu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],qu=[{name:"color",label:"颜色",type:"string"}],Gu={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},ck={id:Ou,name:Bu,category:Lu,description:zu,viewBox:Ru,width:Du,height:Fu,svg:Hu,terminals:Wu,params:qu,source:Gu},dk=Object.freeze(Object.defineProperty({__proto__:null,category:Lu,default:ck,description:zu,height:Fu,id:Ou,name:Bu,params:qu,source:Gu,svg:Hu,terminals:Wu,viewBox:Ru,width:Du},Symbol.toStringTag,{value:"Module"})),Ku="inductor",Xu="电感 (L)",Vu="passive",Yu="通用电感 / 线圈 / 扼流圈。",Uu="-17 -32 34 64",Zu=34,Qu=64,Ju='<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"/>',em=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],tm=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],nm={x:6,y:0,anchor:"start"},om={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},uk={id:Ku,name:Xu,category:Vu,description:Yu,viewBox:Uu,width:Zu,height:Qu,svg:Ju,terminals:em,params:tm,label:nm,source:om},mk=Object.freeze(Object.defineProperty({__proto__:null,category:Vu,default:uk,description:Yu,height:Qu,id:Ku,label:nm,name:Xu,params:tm,source:om,svg:Ju,terminals:em,viewBox:Uu,width:Zu},Symbol.toStringTag,{value:"Module"})),rm="inverter",sm="逆变器 (DC→AC)",im="renewable",am="-42 -42 44 44",lm=44,cm=44,dm='<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"/>',um=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],mm={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},fk={id:rm,name:sm,category:im,viewBox:am,width:lm,height:cm,svg:dm,terminals:um,source:mm},hk=Object.freeze(Object.defineProperty({__proto__:null,category:im,default:fk,height:cm,id:rm,name:sm,source:mm,svg:dm,terminals:um,viewBox:am,width:lm},Symbol.toStringTag,{value:"Module"})),fm="limit-switch",hm="限位开关 (SQ)",pm="control",gm="行程 / 位置开关 (常开, 机械操作)。",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"/><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"/>',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_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},pk={id:fm,name:hm,category:pm,description:gm,viewBox:ym,width:xm,height:bm,svg:wm,terminals:vm,state:km,source:_m},gk=Object.freeze(Object.defineProperty({__proto__:null,category:pm,default:pk,description:gm,height:bm,id:fm,name:hm,source:_m,state:km,svg:wm,terminals:vm,viewBox:ym,width:xm},Symbol.toStringTag,{value:"Module"})),$m="load-switch",Sm="负荷开关",jm="switching",Em="-10 -42 14 64",Nm=14,Mm=64,Tm='<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"/>',Am=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Cm=[{name:"open",type:"boolean",default:!1,label:"断开"}],Im={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"},yk={id:$m,name:Sm,category:jm,viewBox:Em,width:Nm,height:Mm,svg:Tm,terminals:Am,state:Cm,source:Im},xk=Object.freeze(Object.defineProperty({__proto__:null,category:jm,default:yk,height:Mm,id:$m,name:Sm,source:Im,state:Cm,svg:Tm,terminals:Am,viewBox:Em,width:Nm},Symbol.toStringTag,{value:"Module"})),Pm="load",Om="负荷",Bm="load",Lm="抽象负荷(电流流出箭头)",zm="-8 -22 16 46",Rm=16,Dm=46,Fm='<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"/>',Hm=[{id:"t_top",x:0,y:-20,orientation:"n"}],Wm=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],qm={x:6,y:0,anchor:"start"},Gm={kind:"inline"},bk={id:Pm,name:Om,category:Bm,description:Lm,viewBox:zm,width:Rm,height:Dm,svg:Fm,terminals:Hm,params:Wm,label:qm,source:Gm},wk=Object.freeze(Object.defineProperty({__proto__:null,category:Bm,default:bk,description:Lm,height:Dm,id:Pm,label:qm,name:Om,params:Wm,source:Gm,svg:Fm,terminals:Hm,viewBox:zm,width:Rm},Symbol.toStringTag,{value:"Module"})),Km="make-contact",Xm="常开触点 (NO)",Vm="control",Ym="常开辅助触点 (make contact)。",Um="-10 -42 12 64",Zm=12,Qm=64,Jm='<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"/>',ef=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],tf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],nf={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"},vk={id:Km,name:Xm,category:Vm,description:Ym,viewBox:Um,width:Zm,height:Qm,svg:Jm,terminals:ef,state:tf,source:nf},kk=Object.freeze(Object.defineProperty({__proto__:null,category:Vm,default:vk,description:Ym,height:Qm,id:Km,name:Xm,source:nf,state:tf,svg:Jm,terminals:ef,viewBox:Um,width:Zm},Symbol.toStringTag,{value:"Module"})),of="motor-starter",rf="电机启动器",sf="motor-control",af="电机启动器 (IEC 60617 通用符号)。",lf="-22 -27 44 54",cf=44,df=54,uf='<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"/>',mf=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],ff={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},_k={id:of,name:rf,category:sf,description:af,viewBox:lf,width:cf,height:df,svg:uf,terminals:mf,source:ff},$k=Object.freeze(Object.defineProperty({__proto__:null,category:sf,default:_k,description:af,height:df,id:of,name:rf,source:ff,svg:uf,terminals:mf,viewBox:lf,width:cf},Symbol.toStringTag,{value:"Module"})),hf="ngr",pf="中性点电阻 (NGR)",gf="grounding",yf="小电阻接地:连接变压器中性点到地",xf="-12 -32 24 62",bf=24,wf=62,vf='<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"/>',kf=[{id:"t_top",x:0,y:-30,orientation:"n"}],_f=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],$f={kind:"inline"},Sk={id:hf,name:pf,category:gf,description:yf,viewBox:xf,width:bf,height:wf,svg:vf,terminals:kf,params:_f,source:$f},jk=Object.freeze(Object.defineProperty({__proto__:null,category:gf,default:Sk,description:yf,height:wf,id:hf,name:pf,params:_f,source:$f,svg:vf,terminals:kf,viewBox:xf,width:bf},Symbol.toStringTag,{value:"Module"})),Sf="overcurrent-relay",jf="过流继电器 (50/51)",Ef="protection",Nf="过电流保护继电器 (ANSI 50/51)。",Mf="-62 -62 64 64",Tf=64,Af=64,Cf='<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>',If=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Pf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},Ek={id:Sf,name:jf,category:Ef,description:Nf,viewBox:Mf,width:Tf,height:Af,svg:Cf,terminals:If,source:Pf},Nk=Object.freeze(Object.defineProperty({__proto__:null,category:Ef,default:Ek,description:Nf,height:Af,id:Sf,name:jf,source:Pf,svg:Cf,terminals:If,viewBox:Mf,width:Tf},Symbol.toStringTag,{value:"Module"})),Of="phase-failure-relay",Bf="断相继电器",Lf="protection",zf="断相 / 缺相保护继电器。",Rf="-62 -42 64 44",Df=64,Ff=44,Hf='<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 < 3</text>',Wf=[{id:"t_top",x:-30,y:-40,orientation:"n"}],qf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Mk={id:Of,name:Bf,category:Lf,description:zf,viewBox:Rf,width:Df,height:Ff,svg:Hf,terminals:Wf,source:qf},Tk=Object.freeze(Object.defineProperty({__proto__:null,category:Lf,default:Mk,description:zf,height:Ff,id:Of,name:Bf,source:qf,svg:Hf,terminals:Wf,viewBox:Rf,width:Df},Symbol.toStringTag,{value:"Module"})),Gf="plc",Kf="PLC / 控制器",Xf="control",Vf="可编程逻辑控制器 (PLC)。",Yf="-24 -42 48 84",Uf=48,Zf=84,Qf='<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"/>',Jf=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],eh={kind:"inline"},Ak={id:Gf,name:Kf,category:Xf,description:Vf,viewBox:Yf,width:Uf,height:Zf,svg:Qf,terminals:Jf,source:eh},Ck=Object.freeze(Object.defineProperty({__proto__:null,category:Xf,default:Ak,description:Vf,height:Zf,id:Gf,name:Kf,source:eh,svg:Qf,terminals:Jf,viewBox:Yf,width:Uf},Symbol.toStringTag,{value:"Module"})),th="power-factor-meter",nh="功率因数表 (cosφ)",oh="measurement",rh="功率因数表 (cosφ)。",sh="-22 -42 44 44",ih=44,ah=44,lh='<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>',ch=[{id:"t_top",x:0,y:-40,orientation:"n"}],dh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},Ik={id:th,name:nh,category:oh,description:rh,viewBox:sh,width:ih,height:ah,svg:lh,terminals:ch,source:dh},Pk=Object.freeze(Object.defineProperty({__proto__:null,category:oh,default:Ik,description:rh,height:ah,id:th,name:nh,source:dh,svg:lh,terminals:ch,viewBox:sh,width:ih},Symbol.toStringTag,{value:"Module"})),uh="power-supply",mh="开关电源 (PS)",fh="source",hh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",ph="-24 -42 48 84",gh=48,yh=84,xh='<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"/>',bh=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],wh=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],vh={kind:"inline"},Ok={id:uh,name:mh,category:fh,description:hh,viewBox:ph,width:gh,height:yh,svg:xh,terminals:bh,params:wh,source:vh},Bk=Object.freeze(Object.defineProperty({__proto__:null,category:fh,default:Ok,description:hh,height:yh,id:uh,name:mh,params:wh,source:vh,svg:xh,terminals:bh,viewBox:ph,width:gh},Symbol.toStringTag,{value:"Module"})),kh="protective-relay",_h="保护继电器",$h="protection",Sh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",jh="-32 -42 64 44",Eh=64,Nh=44,Mh='<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"/>',Th=[{id:"t_top",x:0,y:-40,orientation:"n"}],Ah={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"},Lk={id:kh,name:_h,category:$h,description:Sh,viewBox:jh,width:Eh,height:Nh,svg:Mh,terminals:Th,source:Ah},zk=Object.freeze(Object.defineProperty({__proto__:null,category:$h,default:Lk,description:Sh,height:Nh,id:kh,name:_h,source:Ah,svg:Mh,terminals:Th,viewBox:jh,width:Eh},Symbol.toStringTag,{value:"Module"})),Ch="proximity-switch",Ih="接近开关 (SQ)",Ph="control",Oh="接近传感器 / 无触点接近开关。",Bh="-12 -32 24 64",Lh=24,zh=64,Rh='<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"/>',Dh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Fh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},Rk={id:Ch,name:Ih,category:Ph,description:Oh,viewBox:Bh,width:Lh,height:zh,svg:Rh,terminals:Dh,source:Fh},Dk=Object.freeze(Object.defineProperty({__proto__:null,category:Ph,default:Rk,description:Oh,height:zh,id:Ch,name:Ih,source:Fh,svg:Rh,terminals:Dh,viewBox:Bh,width:Lh},Symbol.toStringTag,{value:"Module"})),Hh="pt",Wh="电压互感器 (PT)",qh="instrument-transformer",Gh="-22 -42 44 115",Kh=44,Xh=115,Vh='<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"/>',Yh=[{id:"t1",x:0,y:71,orientation:"s"},{id:"t2",x:0,y:-40,orientation:"n"}],Uh={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},Fk={id:Hh,name:Wh,category:qh,viewBox:Gh,width:Kh,height:Xh,svg:Vh,terminals:Yh,source:Uh},Hk=Object.freeze(Object.defineProperty({__proto__:null,category:qh,default:Fk,height:Xh,id:Hh,name:Wh,source:Uh,svg:Vh,terminals:Yh,viewBox:Gh,width:Kh},Symbol.toStringTag,{value:"Module"})),Zh="push-button",Qh="按钮 (SB)",Jh="control",e0="手动按钮, 自动复位 (常开 make)。",t0="-37 -42 39 64",n0=39,o0=64,r0='<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"}],i0={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"},Wk={id:Zh,name:Qh,category:Jh,description:e0,viewBox:t0,width:n0,height:o0,svg:r0,terminals:s0,source:i0},qk=Object.freeze(Object.defineProperty({__proto__:null,category:Jh,default:Wk,description:e0,height:o0,id:Zh,name:Qh,source:i0,svg:r0,terminals:s0,viewBox:t0,width:n0},Symbol.toStringTag,{value:"Module"})),a0="pv",l0="光伏组件",c0="renewable",d0="-33 -22 85 64",u0=85,m0=64,f0='<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"/>',h0=[{id:"t_dc",x:50,y:10,orientation:"e"}],p0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},Gk={id:a0,name:l0,category:c0,viewBox:d0,width:u0,height:m0,svg:f0,terminals:h0,source:p0},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:c0,default:Gk,height:m0,id:a0,name:l0,source:p0,svg:f0,terminals:h0,viewBox:d0,width:u0},Symbol.toStringTag,{value:"Module"})),g0="rcd",y0="剩余电流装置 (RCD)",x0="protection",b0="不带过流保护的剩余电流断路器 (IEC 61008)。",w0="-12 -22 19 44",v0=19,k0=44,_0='<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"/>',$0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],S0=[{name:"open",type:"boolean",default:!1,label:"断开"}],j0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],E0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},Xk={id:g0,name:y0,category:x0,description:b0,viewBox:w0,width:v0,height:k0,svg:_0,terminals:$0,state:S0,params:j0,source:E0},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:x0,default:Xk,description:b0,height:k0,id:g0,name:y0,params:j0,source:E0,state:S0,svg:_0,terminals:$0,viewBox:w0,width:v0},Symbol.toStringTag,{value:"Module"})),N0="recloser",M0="重合闸 (Recloser)",T0="protection",A0="中压自动重合闸开关。",C0="-12 -32 36 64",I0=36,P0=64,O0='<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>',B0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],L0=[{name:"open",type:"boolean",default:!1,label:"断开"}],z0={kind:"inline"},Yk={id:N0,name:M0,category:T0,description:A0,viewBox:C0,width:I0,height:P0,svg:O0,terminals:B0,state:L0,source:z0},Uk=Object.freeze(Object.defineProperty({__proto__:null,category:T0,default:Yk,description:A0,height:P0,id:N0,name:M0,source:z0,state:L0,svg:O0,terminals:B0,viewBox:C0,width:I0},Symbol.toStringTag,{value:"Module"})),R0="rectifier",D0="整流器 (AC→DC)",F0="renewable",H0="-42 -42 44 44",W0=44,q0=44,G0='<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"/>',K0=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],X0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},Zk={id:R0,name:D0,category:F0,viewBox:H0,width:W0,height:q0,svg:G0,terminals:K0,source:X0},Qk=Object.freeze(Object.defineProperty({__proto__:null,category:F0,default:Zk,height:q0,id:R0,name:D0,source:X0,svg:G0,terminals:K0,viewBox:H0,width:W0},Symbol.toStringTag,{value:"Module"})),V0="relay-coil",Y0="继电器线圈 (KA)",U0="control",Z0="继电器 / 接触器操作线圈 (方框)。",Q0="-22 -22 44 44",J0=44,ep=44,tp='<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"/>',np=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],op={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"},Jk={id:V0,name:Y0,category:U0,description:Z0,viewBox:Q0,width:J0,height:ep,svg:tp,terminals:np,source:op},e_=Object.freeze(Object.defineProperty({__proto__:null,category:U0,default:Jk,description:Z0,height:ep,id:V0,name:Y0,source:op,svg:tp,terminals:np,viewBox:Q0,width:J0},Symbol.toStringTag,{value:"Module"})),rp="resistor",sp="电阻 (R)",ip="passive",ap="通用电阻 / 限流 / 制动电阻。",lp="-6 -23 12 35",cp=12,dp=35,up='<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"/>',mp=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],fp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],hp={x:6,y:0,anchor:"start"},pp={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},t_={id:rp,name:sp,category:ip,description:ap,viewBox:lp,width:cp,height:dp,svg:up,terminals:mp,params:fp,label:hp,source:pp},n_=Object.freeze(Object.defineProperty({__proto__:null,category:ip,default:t_,description:ap,height:dp,id:rp,label:hp,name:sp,params:fp,source:pp,svg:up,terminals:mp,viewBox:lp,width:cp},Symbol.toStringTag,{value:"Module"})),gp="reverse-power-relay",yp="逆功率继电器 (32)",xp="protection",bp="逆功率 / 逆流保护继电器 (ANSI 32)。",wp="-62 -42 64 44",vp=64,kp=44,_p='<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"/>',$p=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Sp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},o_={id:gp,name:yp,category:xp,description:bp,viewBox:wp,width:vp,height:kp,svg:_p,terminals:$p,source:Sp},r_=Object.freeze(Object.defineProperty({__proto__:null,category:xp,default:o_,description:bp,height:kp,id:gp,name:yp,source:Sp,svg:_p,terminals:$p,viewBox:wp,width:vp},Symbol.toStringTag,{value:"Module"})),jp="selector-switch",Ep="选择开关 (SA)",Np="switching",Mp="转换 / 选择开关 (旋转操作, 保位)。",Tp="-34 -42 36 64",Ap=36,Cp=64,Ip='<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"/>',Pp=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Op=[{name:"open",type:"boolean",default:!1,label:"断开"}],Bp={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"},s_={id:jp,name:Ep,category:Np,description:Mp,viewBox:Tp,width:Ap,height:Cp,svg:Ip,terminals:Pp,state:Op,source:Bp},i_=Object.freeze(Object.defineProperty({__proto__:null,category:Np,default:s_,description:Mp,height:Cp,id:jp,name:Ep,source:Bp,state:Op,svg:Ip,terminals:Pp,viewBox:Tp,width:Ap},Symbol.toStringTag,{value:"Module"})),Lp="series-reactor",zp="串联电抗器",Rp="compensation",Dp="与并联电抗器同符号;通过用法区分。",Fp="-62 -82 64 104",Hp=64,Wp=104,qp='<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"/>',Gp=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Kp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},a_={id:Lp,name:zp,category:Rp,description:Dp,viewBox:Fp,width:Hp,height:Wp,svg:qp,terminals:Gp,source:Kp},l_=Object.freeze(Object.defineProperty({__proto__:null,category:Rp,default:a_,description:Dp,height:Wp,id:Lp,name:zp,source:Kp,svg:qp,terminals:Gp,viewBox:Fp,width:Hp},Symbol.toStringTag,{value:"Module"})),Xp="shunt-capacitor",Vp="并联电容器",Yp="compensation",Up="-7 -23 14 27",Zp=14,Qp=27,Jp='<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"/>',eg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],tg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],ng={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},c_={id:Xp,name:Vp,category:Yp,viewBox:Up,width:Zp,height:Qp,svg:Jp,terminals:eg,params:tg,source:ng},d_=Object.freeze(Object.defineProperty({__proto__:null,category:Yp,default:c_,height:Qp,id:Xp,name:Vp,params:tg,source:ng,svg:Jp,terminals:eg,viewBox:Up,width:Zp},Symbol.toStringTag,{value:"Module"})),og="shunt-reactor",rg="并联电抗器",sg="compensation",ig="-62 -82 64 104",ag=64,lg=104,cg='<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"/>',dg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],ug={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},u_={id:og,name:rg,category:sg,viewBox:ig,width:ag,height:lg,svg:cg,terminals:dg,source:ug},m_=Object.freeze(Object.defineProperty({__proto__:null,category:sg,default:u_,height:lg,id:og,name:rg,source:ug,svg:cg,terminals:dg,viewBox:ig,width:ag},Symbol.toStringTag,{value:"Module"})),mg="siren",fg="警笛 (HA)",hg="control",pg="声响警笛 / 报警器。",gg="-32 -42 44 54",yg=44,xg=54,bg='<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"/>',wg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],vg={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},f_={id:mg,name:fg,category:hg,description:pg,viewBox:gg,width:yg,height:xg,svg:bg,terminals:wg,source:vg},h_=Object.freeze(Object.defineProperty({__proto__:null,category:hg,default:f_,description:pg,height:xg,id:mg,name:fg,source:vg,svg:bg,terminals:wg,viewBox:gg,width:yg},Symbol.toStringTag,{value:"Module"})),kg="socket-outlet",_g="插座 / 连接器",$g="load",Sg="电源插座 / 多极连接器。",jg="-7 -2 13 34",Eg=13,Ng=34,Mg='<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"/>',Tg=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Ag={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
192
|
-
unifilar`},p_={id:kg,name:_g,category:$g,description:Sg,viewBox:jg,width:Eg,height:Ng,svg:Mg,terminals:Tg,source:Ag},g_=Object.freeze(Object.defineProperty({__proto__:null,category:$g,default:p_,description:Sg,height:Ng,id:kg,name:_g,source:Ag,svg:Mg,terminals:Tg,viewBox:jg,width:Eg},Symbol.toStringTag,{value:"Module"})),Cg="soft-starter",Ig="软启动器",Pg="motor-control",Og="电机软启动器 (晶闸管降压启动)。",Bg="-22 -42 44 84",Lg=44,zg=84,Rg='<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"/>',Dg=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Fg={kind:"inline"},y_={id:Cg,name:Ig,category:Pg,description:Og,viewBox:Bg,width:Lg,height:zg,svg:Rg,terminals:Dg,source:Fg},x_=Object.freeze(Object.defineProperty({__proto__:null,category:Pg,default:y_,description:Og,height:zg,id:Cg,name:Ig,source:Fg,svg:Rg,terminals:Dg,viewBox:Bg,width:Lg},Symbol.toStringTag,{value:"Module"})),Hg="sync-motor",Wg="同步电动机",qg="load",Gg="-62 -82 64 114",Kg=64,Xg=114,Vg='<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"/>',Yg=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],Ug={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},b_={id:Hg,name:Wg,category:qg,viewBox:Gg,width:Kg,height:Xg,svg:Vg,terminals:Yg,source:Ug},w_=Object.freeze(Object.defineProperty({__proto__:null,category:qg,default:b_,height:Xg,id:Hg,name:Wg,source:Ug,svg:Vg,terminals:Yg,viewBox:Gg,width:Kg},Symbol.toStringTag,{value:"Module"})),Zg="synchronoscope",Qg="同步表",Jg="measurement",e1="同步指示器 / 同步表。",t1="-22 -42 44 44",n1=44,o1=44,r1='<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"/>',s1=[{id:"t_top",x:0,y:-40,orientation:"n"}],i1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},v_={id:Zg,name:Qg,category:Jg,description:e1,viewBox:t1,width:n1,height:o1,svg:r1,terminals:s1,source:i1},k_=Object.freeze(Object.defineProperty({__proto__:null,category:Jg,default:v_,description:e1,height:o1,id:Zg,name:Qg,source:i1,svg:r1,terminals:s1,viewBox:t1,width:n1},Symbol.toStringTag,{value:"Module"})),a1="terminal",l1="接线端子 / 节点 (X)",c1="busbar",d1="接线端子 / 接线盒 / 汇接节点。",u1="-5 -5 10 10",m1=10,f1=10,h1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',p1=[{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"}],g1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},__={id:a1,name:l1,category:c1,description:d1,viewBox:u1,width:m1,height:f1,svg:h1,terminals:p1,source:g1},$_=Object.freeze(Object.defineProperty({__proto__:null,category:c1,default:__,description:d1,height:f1,id:a1,name:l1,source:g1,svg:h1,terminals:p1,viewBox:u1,width:m1},Symbol.toStringTag,{value:"Module"})),y1="thermal-overload",x1="热过载继电器",b1="motor-control",w1="电机热过载保护继电器, 通常串接在接触器和电机之间。",v1="-9 -32 19 64",k1=19,_1=64,$1='<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"/>',S1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],j1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],E1={kind:"inline"},S_={id:y1,name:x1,category:b1,description:w1,viewBox:v1,width:k1,height:_1,svg:$1,terminals:S1,state:j1,source:E1},j_=Object.freeze(Object.defineProperty({__proto__:null,category:b1,default:S_,description:w1,height:_1,id:y1,name:x1,source:E1,state:j1,svg:$1,terminals:S1,viewBox:v1,width:k1},Symbol.toStringTag,{value:"Module"})),N1="thermocouple",M1="热电偶 (BT)",T1="measurement",A1="热电偶温度传感器。",C1="-26 -42 52 46",I1=52,P1=46,O1='<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"/>',B1=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],L1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},E_={id:N1,name:M1,category:T1,description:A1,viewBox:C1,width:I1,height:P1,svg:O1,terminals:B1,source:L1},N_=Object.freeze(Object.defineProperty({__proto__:null,category:T1,default:E_,description:A1,height:P1,id:N1,name:M1,source:L1,svg:O1,terminals:B1,viewBox:C1,width:I1},Symbol.toStringTag,{value:"Module"})),z1="thyristor",R1="晶闸管 (V)",D1="passive",F1="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",H1="-22 -42 34 44",W1=34,q1=44,G1='<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"/>',K1=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],X1={x:6,y:-20,anchor:"start"},V1={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)"},M_={id:z1,name:R1,category:D1,description:F1,viewBox:H1,width:W1,height:q1,svg:G1,terminals:K1,label:X1,source:V1},T_=Object.freeze(Object.defineProperty({__proto__:null,category:D1,default:M_,description:F1,height:q1,id:z1,label:X1,name:R1,source:V1,svg:G1,terminals:K1,viewBox:H1,width:W1},Symbol.toStringTag,{value:"Module"})),Y1="time-relay",U1="时间继电器 (KT)",Z1="control",Q1="延时 (缓动) 继电器线圈。",J1="-32 -22 54 44",ey=54,ty=44,ny='<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"/>',oy=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ry={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"},A_={id:Y1,name:U1,category:Z1,description:Q1,viewBox:J1,width:ey,height:ty,svg:ny,terminals:oy,source:ry},C_=Object.freeze(Object.defineProperty({__proto__:null,category:Z1,default:A_,description:Q1,height:ty,id:Y1,name:U1,source:ry,svg:ny,terminals:oy,viewBox:J1,width:ey},Symbol.toStringTag,{value:"Module"})),sy="transfer-switch",iy="切换开关 (ATS)",ay="switching",ly="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",cy="-27 -32 51 64",dy=51,uy=64,my='<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"/>',fy=[{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"}],hy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],py={kind:"inline"},I_={id:sy,name:iy,category:ay,description:ly,viewBox:cy,width:dy,height:uy,svg:my,terminals:fy,state:hy,source:py},P_=Object.freeze(Object.defineProperty({__proto__:null,category:ay,default:I_,description:ly,height:uy,id:sy,name:iy,source:py,state:hy,svg:my,terminals:fy,viewBox:cy,width:dy},Symbol.toStringTag,{value:"Module"})),gy="transformer-2w",yy="双绕组变压器",xy="transformer",by="-62 -142 64 144",wy=64,vy=144,ky='<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"/>',_y=[{id:"t1",x:-30,y:0,orientation:"s"},{id:"t2",x:-30,y:-140,orientation:"n"}],$y=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],Sy={x:4,y:-68,anchor:"start"},jy={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"},O_={id:gy,name:yy,category:xy,viewBox:by,width:wy,height:vy,svg:ky,terminals:_y,params:$y,label:Sy,source:jy},B_=Object.freeze(Object.defineProperty({__proto__:null,category:xy,default:O_,height:vy,id:gy,label:Sy,name:yy,params:$y,source:jy,svg:ky,terminals:_y,viewBox:by,width:wy},Symbol.toStringTag,{value:"Module"})),Ey="transformer-3w",Ny="三绕组变压器",My="transformer",Ty="-82 -131 114 133",Ay=114,Cy=133,Iy='<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"/>',Py=[{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"}],Oy={x:4,y:-64,anchor:"start"},By={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"},L_={id:Ey,name:Ny,category:My,viewBox:Ty,width:Ay,height:Cy,svg:Iy,terminals:Py,label:Oy,source:By},z_=Object.freeze(Object.defineProperty({__proto__:null,category:My,default:L_,height:Cy,id:Ey,label:Oy,name:Ny,source:By,svg:Iy,terminals:Py,viewBox:Ty,width:Ay},Symbol.toStringTag,{value:"Module"})),Ly="triac",zy="双向晶闸管 (V)",Ry="passive",Dy="双向三极晶闸管 (TRIAC)。",Fy="-22 -42 44 44",Hy=44,Wy=44,qy='<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"/>',Gy=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Ky={x:6,y:-20,anchor:"start"},Xy={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},R_={id:Ly,name:zy,category:Ry,description:Dy,viewBox:Fy,width:Hy,height:Wy,svg:qy,terminals:Gy,label:Ky,source:Xy},D_=Object.freeze(Object.defineProperty({__proto__:null,category:Ry,default:R_,description:Dy,height:Wy,id:Ly,label:Ky,name:zy,source:Xy,svg:qy,terminals:Gy,viewBox:Fy,width:Hy},Symbol.toStringTag,{value:"Module"})),Vy="undervoltage-relay",Yy="欠压继电器 (27)",Uy="protection",Zy="欠电压保护继电器 (ANSI 27)。",Qy="-62 -82 64 84",Jy=64,ex=84,tx='<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 <</text>',nx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],ox={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},F_={id:Vy,name:Yy,category:Uy,description:Zy,viewBox:Qy,width:Jy,height:ex,svg:tx,terminals:nx,source:ox},H_=Object.freeze(Object.defineProperty({__proto__:null,category:Uy,default:F_,description:Zy,height:ex,id:Vy,name:Yy,source:ox,svg:tx,terminals:nx,viewBox:Qy,width:Jy},Symbol.toStringTag,{value:"Module"})),rx="ups",sx="不间断电源 (UPS)",ix="source",ax="在线 / 后备式不间断电源。",lx="-26 -42 52 84",cx=52,dx=84,ux='<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"/>',mx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],fx=[{name:"S",label:"容量",type:"number",unit:"kVA"}],hx={kind:"inline"},W_={id:rx,name:sx,category:ix,description:ax,viewBox:lx,width:cx,height:dx,svg:ux,terminals:mx,params:fx,source:hx},q_=Object.freeze(Object.defineProperty({__proto__:null,category:ix,default:W_,description:ax,height:dx,id:rx,name:sx,params:fx,source:hx,svg:ux,terminals:mx,viewBox:lx,width:cx},Symbol.toStringTag,{value:"Module"})),px="varmeter",gx="无功功率表 (var)",yx="measurement",xx="无功功率表 (var)。",bx="-22 -42 44 44",wx=44,vx=44,kx='<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>',_x=[{id:"t_top",x:0,y:-40,orientation:"n"}],$x={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},G_={id:px,name:gx,category:yx,description:xx,viewBox:bx,width:wx,height:vx,svg:kx,terminals:_x,source:$x},K_=Object.freeze(Object.defineProperty({__proto__:null,category:yx,default:G_,description:xx,height:vx,id:px,name:gx,source:$x,svg:kx,terminals:_x,viewBox:bx,width:wx},Symbol.toStringTag,{value:"Module"})),Sx="vfd",jx="变频器 (VFD)",Ex="motor-control",Nx="Variable Frequency Drive — 异步电动机调速。",Mx="-24 -42 48 84",Tx=48,Ax=84,Cx='<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"/>',Ix=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Px={kind:"inline"},X_={id:Sx,name:jx,category:Ex,description:Nx,viewBox:Mx,width:Tx,height:Ax,svg:Cx,terminals:Ix,source:Px},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Ex,default:X_,description:Nx,height:Ax,id:Sx,name:jx,source:Px,svg:Cx,terminals:Ix,viewBox:Mx,width:Tx},Symbol.toStringTag,{value:"Module"})),Ox="voltage-regulator",Bx="调压器 (T)",Lx="transformer",zx="可调感应调压器 / 自耦调压器。",Rx="-17 -32 38 64",Dx=38,Fx=64,Hx='<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"/>',Wx=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],qx=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],Gx={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},Y_={id:Ox,name:Bx,category:Lx,description:zx,viewBox:Rx,width:Dx,height:Fx,svg:Hx,terminals:Wx,params:qx,source:Gx},U_=Object.freeze(Object.defineProperty({__proto__:null,category:Lx,default:Y_,description:zx,height:Fx,id:Ox,name:Bx,params:qx,source:Gx,svg:Hx,terminals:Wx,viewBox:Rx,width:Dx},Symbol.toStringTag,{value:"Module"})),Kx="voltmeter",Xx="电压表 (V)",Vx="measurement",Yx="-22 -42 44 44",Ux=44,Zx=44,Qx='<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>',Jx=[{id:"t_top",x:0,y:-40,orientation:"n"}],eb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},Z_={id:Kx,name:Xx,category:Vx,viewBox:Yx,width:Ux,height:Zx,svg:Qx,terminals:Jx,source:eb},Q_=Object.freeze(Object.defineProperty({__proto__:null,category:Vx,default:Z_,height:Zx,id:Kx,name:Xx,source:eb,svg:Qx,terminals:Jx,viewBox:Yx,width:Ux},Symbol.toStringTag,{value:"Module"})),tb="wattmeter",nb="功率表 (W)",ob="measurement",rb="-22 -42 44 44",sb=44,ib=44,ab='<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>',lb=[{id:"t_top",x:0,y:-40,orientation:"n"}],cb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},J_={id:tb,name:nb,category:ob,viewBox:rb,width:sb,height:ib,svg:ab,terminals:lb,source:cb},e$=Object.freeze(Object.defineProperty({__proto__:null,category:ob,default:J_,height:ib,id:tb,name:nb,source:cb,svg:ab,terminals:lb,viewBox:rb,width:sb},Symbol.toStringTag,{value:"Module"})),db="wind-turbine",ub="风力发电机",mb="renewable",fb="风机:发电机 + 三叶轮标记",hb="-22 -46 44 68",pb=44,gb=68,yb='<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"/>',xb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],bb={kind:"inline"},t$={id:db,name:ub,category:mb,description:fb,viewBox:hb,width:pb,height:gb,svg:yb,terminals:xb,source:bb},n$=Object.freeze(Object.defineProperty({__proto__:null,category:mb,default:t$,description:fb,height:gb,id:db,name:ub,source:bb,svg:yb,terminals:xb,viewBox:hb,width:pb},Symbol.toStringTag,{value:"Module"})),wb="zener-diode",vb="稳压二极管 (D)",kb="passive",_b="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",$b="-12 -42 24 44",Sb=24,jb=44,Eb='<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"/>',Nb=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Mb={x:6,y:-20,anchor:"start"},Tb={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"},o$={id:wb,name:vb,category:kb,description:_b,viewBox:$b,width:Sb,height:jb,svg:Eb,terminals:Nb,label:Mb,source:Tb},r$=Object.freeze(Object.defineProperty({__proto__:null,category:kb,default:o$,description:_b,height:jb,id:wb,label:Mb,name:vb,source:Tb,svg:Eb,terminals:Nb,viewBox:$b,width:Sb},Symbol.toStringTag,{value:"Module"})),s$=Object.assign({"./ammeter.json":Kv,"./arc-suppression-coil.json":Vv,"./arrester.json":Uv,"./async-motor.json":Qv,"./autotransformer.json":e2,"./battery.json":n2,"./bell.json":r2,"./break-contact.json":i2,"./breaker.json":l2,"./buchholz-relay.json":d2,"./busbar.json":m2,"./buzzer.json":h2,"./capacitor.json":g2,"./contactor.json":x2,"./converter-bidir.json":w2,"./ct.json":k2,"./dc-combiner.json":$2,"./dc-disconnector.json":j2,"./dc-motor.json":N2,"./diode.json":T2,"./disconnector.json":C2,"./distance-relay.json":P2,"./earth.json":B2,"./earthing-switch.json":z2,"./energy-meter.json":D2,"./ev-charger.json":H2,"./frequency-meter.json":q2,"./fuse-switch-disconnector.json":K2,"./fuse.json":V2,"./generator.json":U2,"./genset.json":Q2,"./gfci-breaker.json":ek,"./grid-source.json":nk,"./grounding-transformer.json":rk,"./heater.json":ik,"./igbt.json":lk,"./indicator-light.json":dk,"./inductor.json":mk,"./inverter.json":hk,"./limit-switch.json":gk,"./load-switch.json":xk,"./load.json":wk,"./make-contact.json":kk,"./motor-starter.json":$k,"./ngr.json":jk,"./overcurrent-relay.json":Nk,"./phase-failure-relay.json":Tk,"./plc.json":Ck,"./power-factor-meter.json":Pk,"./power-supply.json":Bk,"./protective-relay.json":zk,"./proximity-switch.json":Dk,"./pt.json":Hk,"./push-button.json":qk,"./pv.json":Kk,"./rcd.json":Vk,"./recloser.json":Uk,"./rectifier.json":Qk,"./relay-coil.json":e_,"./resistor.json":n_,"./reverse-power-relay.json":r_,"./selector-switch.json":i_,"./series-reactor.json":l_,"./shunt-capacitor.json":d_,"./shunt-reactor.json":m_,"./siren.json":h_,"./socket-outlet.json":g_,"./soft-starter.json":x_,"./sync-motor.json":w_,"./synchronoscope.json":k_,"./terminal.json":$_,"./thermal-overload.json":j_,"./thermocouple.json":N_,"./thyristor.json":T_,"./time-relay.json":C_,"./transfer-switch.json":P_,"./transformer-2w.json":B_,"./transformer-3w.json":z_,"./triac.json":D_,"./undervoltage-relay.json":H_,"./ups.json":q_,"./varmeter.json":K_,"./vfd.json":V_,"./voltage-regulator.json":U_,"./voltmeter.json":Q_,"./wattmeter.json":e$,"./wind-turbine.json":n$,"./zener-diode.json":r$}),Ab=Object.values(s$).map(e=>e.default),Xe=Object.fromEntries(Ab.map(e=>[e.id,e])),To=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],i$=(()=>{var t;const e={};for(const n of Ab)(e[t=n.category]??(e[t]=[])).push(n);return e})(),$n=new Map(Object.entries(Xe));function Cb(e){return Xe[e]}function a$(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 l$=320;function qe(e){var m,p,g,f;const t=Rr(),n=new Map;e.elements.forEach((h,b)=>{if(n.has(h.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:h.id}),pointer:`/elements/${b}`});return}n.set(h.id,h);const k=$n.get(h.kind);k||t.diagnostics.push({code:"E003",severity:"error",message:`${ve("compile.unknownKind",{kind:h.kind})} (id=${h.id})`,pointer:`/elements/${b}`}),t.elements.set(h.id,{element:h,libraryDef:k})});const o=new Map,r=new Map;(e.buses??[]).forEach((h,b)=>{if(n.has(h.id)||o.has(h.id)){t.diagnostics.push({code:"E001",severity:"error",message:ve("compile.duplicateId",{id:h.id}),pointer:`/buses/${b}`});return}if(o.set(h.id,h),h.layout){const k=h.layout.rot??0;r.set(h.id,{at:h.layout.at,span:h.layout.span,rot:k,axis:kn(k)})}});const s=h=>!h.includes(".")&&o.has(h),i=(h,b)=>{if(s(h))return!0;const k=h.indexOf(".");if(k<=0)return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.invalidTermRef",{ref:h}),pointer:b}),!1;const w=h.slice(0,k),M=h.slice(k+1),P=t.elements.get(w);if(!P)return t.diagnostics.push({code:"E002",severity:"error",message:ve("compile.elementMissing",{id:w}),pointer:b}),!1;if(!P.libraryDef)return!1;if(!P.libraryDef.terminals.find(z=>z.id===M)){const z=P.libraryDef.terminals.map(D=>D.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:ve("compile.missingPin",{id:w,kind:P.element.kind,pin:M,available:z}),pointer:b}),!1}return!0},a=[];(e.wires??[]).forEach((h,b)=>{const k=`/wires/${b}`,w=i(h.ends[0],k),M=i(h.ends[1],k);w&&M&&a.push(h)});const l=new Map;if(e.layout)for(const[h,b]of Object.entries(e.layout))t.elements.has(h)?l.set(h,Dr(b)):t.diagnostics.push({code:"E004",severity:"error",message:ve("compile.layoutMissingElement",{id:h}),pointer:`/layout/${h}`});const d=Wv({elements:e.elements,buses:e.buses??[],wires:a,library:$n,userLayout:l,userBusLayout:r});t.layout=d.devices;for(const[h,b]of d.buses){const k=o.get(h);k&&t.buses.set(h,{bus:k,geometry:b})}for(const[h,b]of o)t.buses.has(h)||t.buses.set(h,{bus:b,geometry:{at:((m=b.layout)==null?void 0:m.at)??[0,0],span:((p=b.layout)==null?void 0:p.span)??l$,rot:((g=b.layout)==null?void 0:g.rot)??0,axis:kn(((f=b.layout)==null?void 0:f.rot)??0)}});for(const h of t.elements.values()){if(!h.libraryDef)continue;const b=t.layout.get(h.element.id);if(!b)continue;const k=[];for(const w of h.libraryDef.terminals){const M=`${h.element.id}.${w.id}`,P=Ae([w.x,w.y],b),z=vt(w.orientation,b);t.terminals.set(M,{ref:M,elementId:h.element.id,pin:w.id,world:P,orientation:z}),k.push(M)}t.elementToTerminals.set(h.element.id,k)}const u=new Fr;for(const h of a)u.add(h.ends[0]),u.add(h.ends[1]),u.union(h.ends[0],h.ends[1]);for(const[,h]of u.groups()){const b=a$(h);t.nodes.set(b,{id:b,terminals:h});for(const k of h)t.terminalToNode.set(k,b)}for(const h of t.elements.values()){const b=t.elementToTerminals.get(h.element.id)??[];if(b.length===0)continue;b.some(w=>t.terminalToNode.has(w))||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:h.element.id})})}for(const h of t.buses.keys())t.terminalToNode.has(h)||t.diagnostics.push({code:"W001",severity:"warning",message:ve("compile.elementUnconnected",{id:h})});for(const h of a){if(h.path&&h.path.length>=2){const k=h.path,w=k.length>=2?k[1]:null,M=k.length>=2?k[k.length-2]:null,P=No(h.ends[0],w,t),z=No(h.ends[1],M,t);if(P&&z){const D=[[P[0],P[1]],...k.slice(1,-1).map(re=>[re[0],re[1]]),[z[0],z[1]]],Q=zr(D);if(Q.length>=2){t.wireRenders.set(h.id,{wireId:h.id,path:Q,userEdited:!0});continue}}}const b=qv(h,t);b&&t.wireRenders.set(h.id,b)}return t}const c$={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"},Ao="B";function Ib(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id)])}function $t(e,t){const n=c$[t]??t,o=Ib(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Sn(e){const t=Ib(e);let n=1;for(;t.has(`${Ao}${n}`);)n++;return`${Ao}${n}`}function d$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function St(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)}`}const Co={version:"1",elements:[]},u$=100,Io=20;function m$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=Gt()(Bv((e,t)=>({diagram:Co,internal:qe(Co),fileSession:null,activeTool:m$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:qe(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:qe(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,placeFromTerminal:null}),dispatch:n=>{const{diagram:o,past:r}=t(),s=n(o);if(s===o)return;const i=r.length>=u$?r.slice(1):r;e({diagram:s,internal:qe(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:qe(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,placeFromTerminal: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:qe(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,placeFromTerminal: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,placeFromTerminal:n==="place"?r.placeFromTerminal:null})},setPlaceKind:n=>e(o=>({placeKind:n,lastPlaceKind:n??o.lastPlaceKind})),setWireFromTerminal:n=>e({wireFromTerminal:n}),setPlaceFromTerminal:n=>e({placeFromTerminal:n}),setBusbarDrawStart:n=>e({busbarDrawStart:n}),setCursorSvg:n=>e({cursorSvg:n}),setSelection:n=>e({selection:f$(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,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}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),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 m;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const g=(m=o.layout)==null?void 0:m[p];if(g){l[p]=structuredClone(g);continue}const f=r.layout.get(p);f&&(l[p]=Ct(f))}const d={};for(const p of n){const g=r.buses.get(p);g&&(d[p]=Je(g.geometry))}const u=(o.wires??[]).filter(p=>p.ends.every(g=>s.has(cn(g)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,placements:l,busLayouts:d,wires:u},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0)return;const s=o+1,i=Io*s,a=Io*s,l=new Map;let d=r;for(const m of n.elements){const p=$t(d,m.kind);l.set(m.id,p),d={...d,elements:[...d.elements,{id:p,kind:m.kind}]}}for(const m of n.buses){const p=Sn(d);l.set(m.id,p),d={...d,buses:[...d.buses??[],{id:p}]}}const u=m=>{const p=m.indexOf("."),g=p<0?m:m.slice(0,p),f=l.get(g);return f?p<0?f:`${f}${m.slice(p)}`:m};t().dispatch(m=>{const p=n.elements.map(k=>{const w=structuredClone(k);return w.id=l.get(k.id),w}),g=n.buses.map(k=>{const w=structuredClone(k);w.id=l.get(k.id);const M=n.busLayouts[k.id];return M&&(w.layout={...M,at:[M.at[0]+i,M.at[1]+a]}),w}),f={...m.layout??{}};for(const[k,w]of l){const M=n.placements[k];M&&(f[w]={...M,at:[M.at[0]+i,M.at[1]+a]})}const h=n.wires.map(k=>{const w=[u(k.ends[0]),u(k.ends[1])];return{id:St(w[0],w[1]),ends:w}}),b=h$(m.wires??[],h);return{...m,elements:[...m.elements,...p],buses:g.length?[...m.buses??[],...g]:m.buses,wires:b.length?b:void 0,layout:Object.keys(f).length?f: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(d=>d.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(d=>{const{layout:u,...m}=d;return m});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[d,u]of Object.entries(i)){if(o.has(d)){s=!0;continue}l[d]=u}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(d=>{if(o.has(d.id)&&d.layout){s=!0;const{layout:u,...m}=d;return m}return d});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 d=n.layout.get(l.id);d&&(s[l.id]=Ct(d))}const i=[];if((o.buses??[]).forEach((l,d)=>{l.layout||n.buses.has(l.id)&&i.push({idx:d,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 d=n.buses.get(l.id);return!l.layout&&d?{...l,layout:Je(d.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var d;const s=r.layout??{},i={},a=new Map;for(const u of n)if(o.buses.has(u)){const m=o.buses.get(u);(d=r.buses)!=null&&d.find(p=>p.id===u&&p.layout)||a.set(u,Je(m.geometry))}else{if(s[u])continue;const m=o.layout.get(u);m&&(i[u]=Ct(m))}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;for(const[l,d]of n){if(o.buses.has(l)){i.set(l,d);continue}const u=o.layout.get(l),m=s[l]??(u?Ct(u):{at:[0,0]});s[l]={...m,at:[m.at[0]+d[0],m.at[1]+d[1]]}}let a=r.buses;return i.size>0&&(a=(r.buses??[]).map(l=>{const d=i.get(l.id);if(!d)return l;const u=l.layout??Je(o.buses.get(l.id).geometry);return{...l,layout:{...u,at:[u.at[0]+d[0],u.at[1]+d[1]]}}})),{...r,layout:s,buses:a}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(d=>!o.has(d.id)),i=(r.buses??[]).filter(d=>!o.has(d.id)),a=(r.wires??[]).filter(d=>!o.has(cn(d.ends[0]))&&!o.has(cn(d.ends[1]))),l=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([d])=>!o.has(d))):void 0;return{...r,elements:s,buses:i.length?i:void 0,wires:a.length?a:void 0,layout:l&&Object.keys(l).length?l: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??[]).filter(d=>d.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const d of s){if(l[d])continue;const u=o.layout.get(d);if(!u)continue;const m={at:u.at};u.rot&&(m.rot=u.rot),u.mirror&&(m.mirror=u.mirror),l[d]=m}return{...i,wires:a.length?a:void 0,layout:Object.keys(l).length?l: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 u of i){if(l[u])continue;const m=o.layout.get(u);if(!m)continue;const p={at:m.at};m.rot&&(p.rot=m.rot),m.mirror&&(p.mirror=m.mirror),l[u]=p}const d=(a.wires??[]).filter(u=>!s.has(u.ends[0])&&!s.has(u.ends[1]));return{...a,wires:d.length?d: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 d,u,m,p;const i={...s.layout??{}},a=new Map;for(const g of o){if(r.buses.has(g)){const b=r.buses.get(g),w=(((((m=(u=(d=s.buses)==null?void 0:d.find(M=>M.id===g))==null?void 0:u.layout)==null?void 0:m.rot)??b.geometry.rot??0)+n)%360+360)%360;a.set(g,w);continue}const f=i[g]??{at:((p=r.layout.get(g))==null?void 0:p.at)??[0,0]},h=(((f.rot??0)+n)%360+360)%360;i[g]={...f,rot:h}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(g=>{if(!a.has(g.id))return g;const f=g.layout??Je(r.buses.get(g.id).geometry);return{...g,layout:{...f,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))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=$t(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=Sn(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},addWire:(n,o)=>{if(n===o)return;const r=St(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]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(d=>d.id===n))return r;const i=o&&o.length>=2?zr(o):null,a=i&&i.length>=2?i:null,l=s.map(d=>{if(d.id!==n)return d;if(a)return{...d,path:a};const{path:u,...m}=d;return m});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},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)?Je(a.buses.get(n).geometry):{at:[0,0],span:320}),d={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:d}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=d$(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},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=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:Lr(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=qe(e.diagram))}}));function f$(e){return Array.from(new Set(e))}function cn(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function h$(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 Ct(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function Je(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Pb=null;function Po(e){Pb=e}function Ze(){return Pb}const Dt=10;function Ob(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function ne(e){return Ob()?Math.round(e/Dt)*Dt:e}const p$=30,g$=144;function Bb(e,t){const n=Xe[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=y$(r,t);if(!s){const h=Lb(n),b=h?[ne(t[0])-h.x,ne(t[1])-h.y]:[ne(t[0]),ne(t[1])];return{newElementId:o.addElement(e,b),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,d=x$(n,l),u=$t(r,e),m=n.terminals.find(h=>h.id===d),p=l==="x"?t[0]:a[0],g=l==="y"?t[1]:a[1],f=m?[ne(p)-m.x,ne(g)-m.y]:[ne(t[0]),ne(t[1])];return o.dispatch(h=>{const b={id:u,kind:e},k={at:f},w=`${u}.${d}`,M={id:St(i,w),ends:[i,w]};return{...h,elements:[...h.elements,b],wires:[...h.wires??[],M],layout:{...h.layout??{},[u]:k}}}),o.setSelection([u]),{newElementId:u,attachedToBus:!0}}function y$(e,t){const n=x.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 d;if(i==="x"){const u=a[0]-l/2,m=a[0]+l/2,p=t[0]<u?u-t[0]:t[0]>m?t[0]-m:0,g=Math.abs(t[1]-a[1]);d=Math.sqrt(p*p+g*g)}else{const u=a[1]-l/2,m=a[1]+l/2,p=t[1]<u?u-t[1]:t[1]>m?t[1]-m:0,g=Math.abs(t[0]-a[0]);d=Math.sqrt(g*g+p*p)}d<=p$&&(!o||d<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:d})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function x$(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 Lb(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function zb(e,t){const n=x.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,f=i[0]+a/2,h=Math.max(g,Math.min(f,t[0])),b=i[1],k=t[1]>=b?"s":"n";return{ref:e,world:[h,b],orientation:k,isBus:!0,busId:e}}const l=i[1]-a/2,d=i[1]+a/2,u=Math.max(l,Math.min(d,t[1])),m=i[0],p=t[0]>=m?"e":"w";return{ref:e,world:[m,u],orientation:p,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const b$={n:"s",s:"n",e:"w",w:"e"};function Rb(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=b$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Oo(i,n,t.world);for(let l=1;l<s.length;l++){const d=s[l],u=Oo(d,n,t.world);u<a&&(a=u,i=d)}return i}function Oo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function w$(e,t,n){const o=Xe[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=zb(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],d=a*a+l*l<=g$,u=[ne(n[0]),ne(n[1])],m=Rb(o,i,u),p=d?i.world:u,g=[ne(p[0]-m.x),ne(p[1]-m.y)],f=$t(s,e);return r.dispatch(h=>{const b={id:f,kind:e},k={at:g},w=`${f}.${m.id}`,M=i.isBus&&i.busId?i.busId:t,P={id:St(M,w),ends:[M,w]};return{...h,elements:[...h.elements,b],wires:[...h.wires??[],P],layout:{...h.layout??{},[f]:k}}}),r.setSelection([f]),{newElementId:f,attachedToBus:i.isBus}}const Kt=9,Ft=7;function Xt(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 Vt(e){const t=v$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Yt(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 v$(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 k$(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=x(r=>r.editingElement);return c.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var u;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??Vt(r.libraryDef),a=Yt(i,s),l=i.anchor??"start";if(o===r.element.id)return c.jsx(_$,{elementId:r.element.id,currentName:((u=r.element.name)==null?void 0:u.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const d=Xt(r,n);return d.length===0?null:c.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:d.map((m,p)=>c.jsx("text",{x:0,y:p*Kt,textAnchor:l,className:"ole-annotation-text",children:m},p))},r.element.id)})})}const dn=200,un=9;function _$({elementId:e,currentName:t,world:n,anchor:o}){const r=I.useRef(null);I.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const d=document.createRange();d.selectNodeContents(l);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(d)},[e]);function s(){var p;const l=x.getState(),d=l.diagram.elements.find(g=>g.id===e);if(!d){l.setEditingElement(null);return}const u=(((p=r.current)==null?void 0:p.innerText)??"").replace(/\u00a0/g," ").trim(),m=u===""||u===e?void 0:u;m!==d.name&&l.updateElement(e,{name:m}),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-=dn/2:o==="end"&&(a-=dn),c.jsx("foreignObject",{x:a,y:n[1]-un,width:dn,height:un*2.2,className:"ole-element-name-editor",children:c.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${un}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})})}const Db=8,Ht=1.25;function $$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:c.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?c.jsx(j$,{ann:o},o.id):c.jsx(S$,{ann:o,isSelected:t===o.id},o.id))})}function S$({ann:e,isSelected:t}){const n=e.fontSize??Db,o=e.text===""?[""]:e.text.split(`
|
|
193
|
-
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Ht;return c.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[c.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&&c.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)=>c.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Ht,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function j$({ann:e}){const t=I.useRef(null),n=e.fontSize??Db;I.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(l)},[e.id]);function o(){var d;const a=x.getState(),l=(((d=t.current)==null?void 0:d.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(),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return c.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:c.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:Ht,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*Ht}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const E$=20;function N$(){const e=x(u=>u.selection),t=x(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],d=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return c.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[c.jsx(Bo,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),c.jsx(Bo,{x:d[0],y:d[1],busId:n,side:"end",axis:r})]})}function Bo({x:e,y:t,busId:n,side:o,axis:r}){const s=Ze(),i=I.useRef(null),a=u=>{if(u.button!==0||(u.stopPropagation(),u.preventDefault(),!s))return;const m=x.getState().internal.buses.get(n);m&&(i.current={pointerId:u.pointerId,startSpan:m.geometry.span,startAt:[...m.geometry.at],startSvg:s.screenToSvg(u.clientX,u.clientY)},u.target.setPointerCapture(u.pointerId))},l=u=>{const m=i.current;if(!m||u.pointerId!==m.pointerId||!s)return;const p=s.screenToSvg(u.clientX,u.clientY),g=r==="x"?p[0]-m.startSvg[0]:p[1]-m.startSvg[1],f=Ob()?Math.round(g/Dt)*Dt:g,h=m.startSpan+(o==="end"?f:-f);if(h<E$)return;const b=r==="x"?[m.startAt[0]+f/2,m.startAt[1]]:[m.startAt[0],m.startAt[1]+f/2];x.getState().updateBus(n,{span:h,at:b})},d=u=>{const m=i.current;!m||u.pointerId!==m.pointerId||(u.target.hasPointerCapture(u.pointerId)&&u.target.releasePointerCapture(u.pointerId),i.current=null)};return c.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:d,onPointerCancel:d})}const jn=.5;function kt(e,t){return Math.abs(e[1]-t[1])<jn?"h":"v"}function M$(){const e=x(a=>a.selectedWire),t=x(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=kt(o[a-1],o[a]),d=kt(o[a],o[a+1]),u=a-1===0,m=a+1===r-1,p=u&&l==="v"||m&&d==="v",g=u&&l==="h"||m&&d==="h";p&&g||s.push(c.jsx(T$,{wireId:e,index:a,xLocked:p,yLocked:g},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],d=o[a+1];Math.abs(l[0]-d[0])<jn&&Math.abs(l[1]-d[1])<jn||i.push(c.jsx(A$,{wireId:e,segIndex:a,axis:kt(l,d)},`m-${a}`))}return c.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function T$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Ze(),s=I.useRef(null),i=x(f=>{var h;return(h=f.internal.wireRenders.get(e))==null?void 0:h.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],d=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",u=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!r))return;const h=x.getState().internal.wireRenders.get(e);h&&(s.current={pointerId:f.pointerId,startPath:h.path.map(b=>[b[0],b[1]]),startSvg:r.screenToSvg(f.clientX,f.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=d,f.target.setPointerCapture(f.pointerId))},m=f=>{const h=s.current;if(!h||f.pointerId!==h.pointerId||!r)return;const b=r.screenToSvg(f.clientX,f.clientY),k=h.startPath,w=h.index;if(w<=0||w>=k.length-1)return;const M=k[w],P=[h.xLocked?M[0]:ne(M[0]+(b[0]-h.startSvg[0])),h.yLocked?M[1]:ne(M[1]+(b[1]-h.startSvg[1]))];if(P[0]===M[0]&&P[1]===M[1])return;const z=k.map(re=>[re[0],re[1]]);z[w]=P;const D=kt(k[w-1],k[w]);w-1>0&&(D==="h"?z[w-1]=[k[w-1][0],P[1]]:z[w-1]=[P[0],k[w-1][1]]);const Q=kt(k[w],k[w+1]);w+1<k.length-1&&(Q==="h"?z[w+1]=[k[w+1][0],P[1]]:z[w+1]=[P[0],k[w+1][1]]),x.getState().updateWirePath(e,z)},p=f=>{const h=s.current;!h||f.pointerId!==h.pointerId||(f.target.hasPointerCapture(f.pointerId)&&f.target.releasePointerCapture(f.pointerId),s.current=null,document.body.style.cursor="")},g=f=>{f.stopPropagation(),f.preventDefault();const h=x.getState().internal.wireRenders.get(e);if(!h||h.path.length<=2||t<=0||t>=h.path.length-1)return;const b=h.path.filter((k,w)=>w!==t);x.getState().updateWirePath(e,b)};return c.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:d},onPointerDown:u,onPointerMove:m,onPointerUp:p,onPointerCancel:p,onDoubleClick:g})}function A$({wireId:e,segIndex:t,axis:n}){const o=Ze(),r=I.useRef(null),s=x(f=>{var h;return(h=f.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,d=(i[1]+a[1])/2,u=n==="h"?"ns-resize":"ew-resize",m=f=>{if(f.button!==0||(f.stopPropagation(),f.preventDefault(),!o))return;const h=x.getState().internal.wireRenders.get(e);h&&(r.current={pointerId:f.pointerId,startPath:h.path.map(b=>[b[0],b[1]]),startSvg:o.screenToSvg(f.clientX,f.clientY),axis:n,segIndex:t},document.body.style.cursor=u,f.currentTarget.setPointerCapture(f.pointerId))},p=f=>{const h=r.current;if(!h||f.pointerId!==h.pointerId||!o)return;const b=o.screenToSvg(f.clientX,f.clientY),k=h.startPath,w=h.segIndex;if(w>=k.length-1)return;const M=k[w],P=k[w+1],z=[];for(let D=0;D<=w;D++)z.push(k[D]);if(h.axis==="h"){const D=ne(M[1]+(b[1]-h.startSvg[1]));z.push([M[0],D]),z.push([P[0],D])}else{const D=ne(M[0]+(b[0]-h.startSvg[0]));z.push([D,M[1]]),z.push([D,P[1]])}for(let D=w+1;D<k.length;D++)z.push(k[D]);x.getState().updateWirePath(e,z)},g=f=>{const h=r.current;if(!h||f.pointerId!==h.pointerId)return;const b=f.currentTarget;b.hasPointerCapture(f.pointerId)&&b.releasePointerCapture(f.pointerId),r.current=null,document.body.style.cursor=""};return c.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:u},onPointerDown:m,onPointerMove:p,onPointerUp:g,onPointerCancel:g,children:[c.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:d,r:8}),c.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:d,r:3.5})]})}const C$=3,mn=12;function I$(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(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(".")||i.add(l)}return c.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:d,at:u,span:m}=l,p=m/2,g=d==="x"?u[0]-p:u[0],f=d==="x"?u[1]:u[1]-p,h=d==="x"?u[0]+p:u[0],b=d==="x"?u[1]:u[1]+p,k=s.has(a.id),w=i.has(a.id),M=r.get(a.id)??void 0,P=mn/2,z=d==="x"?u[0]-p:u[0]-P,D=d==="x"?u[1]-P:u[1]-p,Q=d==="x"?m:mn,re=d==="x"?mn:m;return c.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":M,"data-selected":k?"true":void 0,"data-node-related":w?"true":void 0,className:"ole-bus",children:[c.jsx("rect",{x:z,y:D,width:Q,height:re,fill:"transparent",className:"ole-bus-hit"}),c.jsx("line",{x1:g,y1:f,x2:h,y2:b,stroke:"currentColor",strokeWidth:C$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function P$(){const e=x(a=>a.busbarDrawStart),t=x(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 c.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[c.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),c.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),c.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}function Ke(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 O$(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 B$({lib:e}){const t=O$(e.viewBox);return t?c.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function L$(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),r=x(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 d=l.indexOf(".");d>0&&i.add(l.slice(0,d))}}return c.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 d=s.has(a.element.id),u=i.has(a.element.id);return a.libraryDef?c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ke(l),className:"ole-element",children:[c.jsx(B$,{lib:a.libraryDef}),c.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):c.jsxs("g",{"data-element-id":a.element.id,"data-selected":d?"true":void 0,"data-node-related":u?"true":void 0,transform:Ke(l),className:"ole-element ole-element--unknown",children:[c.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),c.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let Fb=null;const En=new Set;function It(e){Fb=e;for(const t of En)t(e)}function z$(){return Fb}function R$(e){return En.add(e),()=>{En.delete(e)}}function D$(){const[e,t]=I.useState(z$());return I.useEffect(()=>R$(t),[]),!e||e.w===0&&e.h===0?null:c.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function F$(){const e=x(d=>d.activeTool),t=x(d=>d.placeKind),n=x(d=>d.cursorSvg),o=x(d=>d.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=Cb(t);if(!r)return null;let s=null,i=null;if(o){const d=zb(o,n);d&&(s=Rb(r,d,n),i={source:d.world,pin:n})}else s=Lb(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return c.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),c.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:c.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function H$(){const e=x(r=>r.selection),t=x(r=>r.internal.elements),n=x(r=>r.internal.layout),o=x(r=>r.internal.buses);return e.length===0?null:c.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:d,at:u,span:m}=s.geometry,p=m/2,g=d==="x"?u[0]-p:u[0]-4,f=d==="x"?u[1]-4:u[1]-p,h=d==="x"?m:8,b=d==="x"?8:m;return c.jsx("rect",{x:g,y:f,width:h,height:b,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=W$(i.libraryDef.viewBox);return l?c.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ke(a)},r):null})})}function W$(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 q$(){const e=x(s=>s.internal.terminals),t=x(s=>s.internal.terminalToNode),n=x(s=>s.wireFromTerminal),o=x(s=>s.selection),r=new Set(o);return c.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,d=r.has(s.elementId);return c.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":d?"true":void 0,className:"ole-terminal"},s.ref)})})}function G$(){const e=x(i=>i.internal.wireRenders),t=x(i=>i.internal.terminalToNode),n=x(i=>i.diagram.wires),o=x(i=>i.selectedWire),r=x(i=>i.selectedNode),s=new Map;for(const i of n??[]){const a=t.get(i.ends[0]);a&&s.set(i.id,a)}return c.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:Array.from(e.values()).flatMap(i=>{const a=i.path;if(a.length<2)return[];const l=a.map(p=>`${p[0]},${p[1]}`).join(" "),d=s.get(i.wireId),u=o===i.wireId,m=r!=null&&r===d;return[c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,className:"ole-wire-hit",points:l},`hit-${i.wireId}`),c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":d,"data-manual":i.userEdited?"true":void 0,"data-selected":u||m?"true":void 0,className:"ole-wire",points:l},i.wireId)]})})}let Ue=null;const Nn=new Set;function Pe(e){if(!(e===null&&Ue===null||e&&Ue&&e.ref===Ue.ref&&e.world[0]===Ue.world[0]&&e.world[1]===Ue.world[1])){Ue=e;for(const t of Nn)t(e)}}function K$(){return Ue}function X$(e){return Nn.add(e),()=>{Nn.delete(e)}}function V$(){var d,u;const e=x(m=>m.wireFromTerminal),t=x(m=>m.cursorSvg),n=x(m=>m.internal.terminals),[o,r]=I.useState(K$());I.useEffect(()=>X$(r),[]);const s=x(m=>m.internal.buses);if(!e||!t)return null;let i;if(e.includes(".")?i=(d=n.get(e))==null?void 0:d.world:i=(u=s.get(e))==null?void 0:u.geometry.at,!i)return null;const a=(o==null?void 0:o.world[0])??t[0],l=(o==null?void 0:o.world[1])??t[1];return c.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[c.jsx("line",{x1:i[0],y1:i[1],x2:a,y2:l,className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i[0],cy:i[1],r:4,className:"ole-wire-preview-anchor"}),o&&c.jsxs(c.Fragment,{children:[c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?7:8,className:"ole-wire-preview-target-ring"}),c.jsx("circle",{cx:o.world[0],cy:o.world[1],r:o.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function it(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function rt(e){var t;return((t=it(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function Y$(e){var t;return((t=it(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function Ge(e){var o;const t=(o=it(e,"data-terminal-id"))==null?void 0:o.getAttribute("data-terminal-id");if(t)return t;const n=Y$(e);return n||null}function Ut(e){var t;return((t=it(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function Lo(e){var t;return((t=it(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function Wt(e){var t;return((t=it(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function Hb(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function U$(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function Wb(){const e=x.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]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="text"){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 Z$(){I.useEffect(()=>{const e=t=>{if(U$(t.target))return;const n=t.metaKey||t.ctrlKey,o=x.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=x.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)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"p":case"P":o.setActiveTool("place");return;case"t":case"T":o.setActiveTool("text");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":Wb();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Mn=null;const Tn=new Set;function Q$(e){if(e!==Mn){Mn=e;for(const t of Tn)t(e)}}function J$(){return Mn}function eS(e){return Tn.add(e),()=>{Tn.delete(e)}}const zo="ole-hover-element-host",tS="ole-hover-terminal-on",nS="ole-hover-node-on";function oS(e){I.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(m,p,g)=>{for(const f of m)f.classList.remove(g);m.clear();for(const f of p)f.classList.add(g),m.add(f)},a=m=>{var g,f;if(m===n)return;n&&((g=t.querySelector(`[data-element-id="${Pt(n)}"]`))==null||g.classList.remove(zo)),m&&((f=t.querySelector(`[data-element-id="${Pt(m)}"]`))==null||f.classList.add(zo));const p=m?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Pt(m)}"]`)):[];i(r,p,tS),n=m,m?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),Q$(m)},l=m=>{if(m===o)return;const p=m?Array.from(t.querySelectorAll(`[data-node-id="${Pt(m)}"]`)):[];i(s,p,nS),o=m,m?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},d=m=>{a(rt(m.target));const p=Ge(m.target);let g=null;p?g=x.getState().internal.terminalToNode.get(p)??null:g=Ut(m.target),l(g)},u=()=>{a(null),l(null)};return t.addEventListener("pointermove",d),t.addEventListener("pointerleave",u),()=>{t.removeEventListener("pointermove",d),t.removeEventListener("pointerleave",u),a(null),l(null)}},[e])}function Pt(e){return e.replace(/(["\\])/g,"\\$1")}function qb(e,t){const n=x.getState().internal;if(!e.includes(".")){const r=n.buses.get(e);if(!r)return null;const{axis:s,at:i,span:a}=r.geometry;if(s==="x"){const m=i[0]-a/2,p=i[0]+a/2,g=Math.max(m,Math.min(p,t[0]));return{ref:e,world:[g,i[1]],isBus:!0}}const l=i[1]-a/2,d=i[1]+a/2,u=Math.max(l,Math.min(d,t[1]));return{ref:e,world:[i[0],u],isBus:!0}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,isBus:!1}:null}const Ro=3;let le=null,Se=null,je=null,de=null;const rS={id:"select",cursor:"default",onPointerDown(e,t){var p,g,f,h,b,k,w;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=Wt(e.target);if(o){e.preventDefault(),e.stopPropagation();const M=(p=n.diagram.annotations)==null?void 0:p.find(P=>P.id===o);if(!M)return;n.setSelectedAnnotation(o),de={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[M.at[0],M.at[1]],moved:!1};return}const s=(e.target instanceof Element?(g=e.target.closest("[data-terminal-id]"))==null?void 0:g.getAttribute("data-terminal-id"):null)?Ge(e.target):null;if(s){const M=s.indexOf("."),P=M>0?s.slice(0,M):"";if(P&&n.selection.includes(P)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((h=(f=e.target).hasPointerCapture)!=null&&h.call(f,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:s};return}}let i=rt(e.target);if(!i){const M=Lo(e.target);if(M&&typeof document<"u"){const P=document.elementsFromPoint(e.clientX,e.clientY);for(const z of P){const D=(k=(b=z.closest)==null?void 0:b.call(z,"[data-bus-id]"))==null?void 0:k.getAttribute("data-bus-id");if(!D)continue;const Q=(w=n.diagram.wires)==null?void 0:w.find(re=>re.id===M);Q&&(Q.ends[0]===D||Q.ends[1]===D)&&(i=D);break}}}if(!i){const M=Lo(e.target);if(M){if(e.preventDefault(),e.altKey){const P=Ut(e.target);if(P){n.setSelectedNode(P);return}}n.setSelectedWire(M);return}e.shiftKey||n.clearSelection(),Se={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 a=n.selection;e.shiftKey?n.toggleInSelection(i):a.includes(i)||n.setSelection([i]);const l=e.shiftKey?x.getState().selection:a.includes(i)?a:[i];if(l.length===0)return;const d=x.getState().internal,u=new Map,m=new Map;for(const M of l){const P=d.buses.get(M);if(P){m.set(M,[P.geometry.at[0],P.geometry.at[1]]);continue}const z=d.layout.get(M);z&&u.set(M,{...z})}u.size===0&&m.size===0||(le={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:u,busOriginals:m,moved:!1},e.preventDefault())},onPointerMove(e,t){if(de&&e.pointerId===de.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-de.startSvg[0]),r=ne(n[1]-de.startSvg[1]);!de.moved&&(o!==0||r!==0)&&(de.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${We(de.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?Ge(o):null;if(!r||r===je.fromRef){Pe(null);return}Pe(qb(r,n));return}if(le&&e.pointerId===le.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]);!le.moved&&(o!==0||r!==0)&&(le.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of le.originals){const a=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ke(l))}for(const s of le.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Se&&e.pointerId===Se.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);It(Do(Se.startSvg,n));return}},onPointerUp(e,t){if(de&&e.pointerId===de.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-de.startSvg[0]),r=ne(n[1]-de.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${We(de.id)}"]`);s&&s.removeAttribute("transform"),de.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(de.id,{at:[de.origin[0]+o,de.origin[1]+r]}),de=null;return}if(je&&e.pointerId===je.pointerId){const n=x.getState(),o=je.fromRef;je=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Pe(null);const r=Ge(e.target);r&&r!==o&&n.addWire(o,r);return}if(le&&e.pointerId===le.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),le.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-le.startSvg[0]),r=ne(n[1]-le.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of le.originals.keys())s.set(i,[o,r]);for(const i of le.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of le.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${We(s)}"]`);i&&i.removeAttribute("transform")}}le=null;return}if(Se&&e.pointerId===Se.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Do(Se.startSvg,n);if(o.w>=Ro||o.h>=Ro){const r=sS(o);if(Se.shiftKey){const s=new Set(Se.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}It(null),Se=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(de&&e.pointerId===de.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${We(de.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}de=null}if(le&&e.pointerId===le.pointerId){for(const[l,d]of le.originals){const u=t.hostEl.querySelector(`[data-element-id="${We(l)}"]`);u&&u.setAttribute("transform",Ke(d))}for(const l of le.busOriginals.keys()){const d=t.hostEl.querySelector(`[data-element-id="${We(l)}"]`);d&&d.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}le=null}if(je&&e.pointerId===je.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setCursorSvg(null),Pe(null),je=null}if(Se&&e.pointerId===Se.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}It(null),Se=null}},onDoubleClick(e){const t=x.getState(),n=Wt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=rt(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(le=null,Se=null,de=null,je){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null),je=null}It(null)}};function Do(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 sS(e){const{internal:t}=x.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=aS(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(([m,p])=>iS([m,p],r));let a=1/0,l=-1/0,d=1/0,u=-1/0;for(const[m,p]of i)m<a&&(a=m),m>l&&(l=m),p<d&&(d=p),p>u&&(u=p);l>=e.x&&a<=e.x+e.w&&u>=e.y&&d<=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,d=s==="x"?i[0]-l:i[0],u=s==="x"?i[0]+l:i[0],m=s==="x"?i[1]:i[1]-l,p=s==="x"?i[1]:i[1]+l;u>=e.x&&d<=e.x+e.w&&p>=e.y&&m<=e.y+e.h&&n.push(o.id)}return n}function iS(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 aS(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 We(e){return e.replace(/(["\\])/g,"\\$1")}const lS=4;let J=null;const cS={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=rt(e.target);let r=null;if(o){const s=x.getState();s.selection.includes(o)||s.setSelection([o]);const i=x.getState().selection,a=x.getState().internal,l=new Map,d=new Map;for(const u of i){const m=a.buses.get(u);if(m){d.set(u,[m.geometry.at[0],m.geometry.at[1]]);continue}const p=a.layout.get(u);p&&l.set(u,{...p})}(l.size>0||d.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:d})}J={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(!J||e.pointerId!==J.pointerId)return;const n=e.clientX-J.startX,o=e.clientY-J.startY;if(!J.moved&&Math.hypot(n,o)>lS){J.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(J.moved){if(J.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=ne(r[0]-J.elementDrag.startSvg[0]),i=ne(r[1]-J.elementDrag.startSvg[1]);for(const[a,l]of J.elementDrag.originals){const d=t.hostEl.querySelector(`[data-element-id="${gt(a)}"]`);if(!d)continue;const u={...l,at:[l.at[0]+s,l.at[1]+i]};d.setAttribute("transform",Ke(u))}for(const a of J.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${gt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:J.startTx+n,ty:J.startTy+o})}},onPointerUp(e,t){if(!(!J||e.pointerId!==J.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",J.elementDrag&&J.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=ne(n[0]-J.elementDrag.startSvg[0]),r=ne(n[1]-J.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of J.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of J.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of J.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${gt(s)}"]`);i&&i.removeAttribute("transform")}}else J.moved||dS(J.startTarget);J=null}},onPointerCancel(e,t){if(J!=null&&J.elementDrag){for(const[n,o]of J.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${gt(n)}"]`);r&&r.setAttribute("transform",Ke(o))}for(const n of J.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${gt(n)}"]`);o&&o.removeAttribute("transform")}}J=null},onDeactivate(){J=null}};function dS(e){if(!e)return;const t=x.getState(),n=Wt(e);if(n){t.setSelectedAnnotation(n);return}const o=rt(e);if(o){t.setSelection([o]);return}const r=Ut(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function gt(e){return e.replace(/(["\\])/g,"\\$1")}const bt={tight:1024,compact:720,dense:520,mini:380},Fo={full:0,tight:1,compact:2,dense:3,mini:4};function Ce(e,t){return Fo[e]>=Fo[t]}function uS(e){return e>=bt.tight?"full":e>=bt.compact?"tight":e>=bt.dense?"compact":e>=bt.mini?"dense":"mini"}const Gb=I.createContext("full");function Ve(){return I.useContext(Gb)}function mS(e){const[t,n]=I.useState(null);return I.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 Kb(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<bt.dense}function Dn(){Kb()&&x.getState().setActiveTool("pan")}function fS(){Kb()&&x.getState().setPlaceKind(null)}const hS={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null)},onPointerDown(e,t){var r,s;if(e.button!==0)return;const n=Ge(e.target);if(!n)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((s=(r=e.target).hasPointerCapture)!=null&&s.call(r,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const o=x.getState();o.setWireFromTerminal(n),o.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY))},onPointerMove(e,t){const n=x.getState().wireFromTerminal;if(!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(o);const r=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,s=r?Ge(r):null;if(!s||s===n){Pe(null);return}Pe(qb(s,o))},onPointerUp(e){const t=x.getState(),n=t.wireFromTerminal;if(!n)return;t.setWireFromTerminal(null),t.setCursorSvg(null),Pe(null);const o=Ge(e.target);!o||o===n||(t.addWire(n,o),Dn())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setCursorSvg(null),Pe(null)}},Ho=10;let yt=!1;function Wo(){setTimeout(()=>fS(),0)}const pS={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=x.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),yt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=Ge(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=x.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);Bb(n,r),yt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([qo(n[0]),qo(n[1])])},onPointerUp(e,t){const n=x.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);w$(r,o,s),Wo();return}yt&&(yt=!1,Wo())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),yt=!1}};function qo(e){return Math.round(e/Ho)*Ho}const Go=10,Ko=20;function et(e){return Math.round(e/Go)*Go}const gS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[et(n[0]),et(n[1])];x.getState().setBusbarDrawStart(o),x.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([et(n[0]),et(n[1])])},onPointerUp(e,t){const n=x.getState().busbarDrawStart;if(x.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=et(o[0]),s=et(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let d,u,m;if(l){if(u=Math.abs(i),u<Ko)return;d=0,m=[(n[0]+r)/2,n[1]]}else{if(u=Math.abs(a),u<Ko)return;d=90,m=[n[0],(n[1]+s)/2]}x.getState().addBus(m,u,d),Dn()},onPointerLeave(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},yS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.getState(),o=Wt(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),Dn()}},xS={select:rS,pan:cS,wire:hS,place:pS,busbar:gS,text:yS};function bS(e,t){const n=x(o=>o.activeTool);I.useEffect(()=>{var p;const o=e.current;if(!o)return;const r=xS[n],s={viewport:t,hostEl:o};(p=r.onActivate)==null||p.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=g=>{var f;return(f=r.onPointerDown)==null?void 0:f.call(r,g,s)},a=g=>{var f;return(f=r.onPointerMove)==null?void 0:f.call(r,g,s)},l=g=>{var f;return(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},d=g=>{var f;return r.onPointerCancel?r.onPointerCancel(g,s):(f=r.onPointerUp)==null?void 0:f.call(r,g,s)},u=g=>{var f;return(f=r.onPointerLeave)==null?void 0:f.call(r,g,s)},m=g=>{var f;return(f=r.onDoubleClick)==null?void 0:f.call(r,g,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",d),o.addEventListener("pointerleave",u),o.addEventListener("dblclick",m),()=>{var g;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",d),o.removeEventListener("pointerleave",u),o.removeEventListener("dblclick",m),(g=r.onDeactivate)==null||g.call(r,s),o.style.cursor=""}},[n,e,t])}let An=1;const Cn=new Set;function wS(e){if(e!==An){An=e;for(const t of Cn)t(e)}}function vS(){return An}function kS(e){return Cn.add(e),()=>{Cn.delete(e)}}const fn=.1,hn=8,_S=1.0015,$S=1.02;function SS(e,t,n={tx:0,ty:0,scale:1}){const o=I.useRef({...n}),r=I.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)),wS(o.current.scale),r.current.size>0){const l={...o.current};for(const d of r.current)d(l)}};return I.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,d=0,u=0,m=0,p=0,g=!1;const f=new Map;let h=null,b=!1;const k=()=>{if(f.size<2){h=null;return}const R=[...f.values()],F=R[1].x-R[0].x,U=R[1].y-R[0].y,oe=Math.hypot(F,U)||1,ie=i.getBoundingClientRect();h={startDist:oe,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(R[0].x+R[1].x)/2-ie.left,startMidY:(R[0].y+R[1].y)/2-ie.top}},w=R=>{if(R.pointerType==="touch"){if(f.set(R.pointerId,{x:R.clientX,y:R.clientY}),f.size>=2&&!b){b=!0;for(const F of f.keys())F!==R.pointerId&&Hb(i,F);k()}if(b){R.stopPropagation(),R.preventDefault();try{i.setPointerCapture(R.pointerId)}catch{}}}},M=R=>{if(R.pointerType!=="touch"||!f.has(R.pointerId)||(f.set(R.pointerId,{x:R.clientX,y:R.clientY}),!b||!h))return;R.stopPropagation();const F=[...f.values()];if(F.length<2)return;const U=F[1].x-F[0].x,oe=F[1].y-F[0].y,ie=Math.hypot(U,oe)||1,Z=i.getBoundingClientRect(),fe=(F[0].x+F[1].x)/2-Z.left,he=(F[0].y+F[1].y)/2-Z.top,pe=ie/h.startDist,Ie=pn(h.startScale*pe,fn,hn),$e=Ie/h.startScale;o.current.tx=h.startMidX-(h.startMidX-h.startTx)*$e+(fe-h.startMidX),o.current.ty=h.startMidY-(h.startMidY-h.startTy)*$e+(he-h.startMidY),o.current.scale=Ie,s()},P=R=>{var F;if(R.pointerType==="touch"&&f.has(R.pointerId)&&(f.delete(R.pointerId),b)){if(R.stopPropagation(),(F=i.hasPointerCapture)!=null&&F.call(i,R.pointerId))try{i.releasePointerCapture(R.pointerId)}catch{}f.size>=2?k():h=null,f.size===0&&(b=!1)}},z=R=>{R.preventDefault();const F=i.getBoundingClientRect(),U=R.clientX-F.left,oe=R.clientY-F.top,ie=R.ctrlKey||R.metaKey;if(R.deltaX===0||ie){const he=Math.pow(ie?$S:_S,-R.deltaY),pe=pn(o.current.scale*he,fn,hn),Ie=pe/o.current.scale;o.current.tx=U-(U-o.current.tx)*Ie,o.current.ty=oe-(oe-o.current.ty)*Ie,o.current.scale=pe}else o.current.tx-=R.deltaX,o.current.ty-=R.deltaY;s()},D=R=>{const F=R.button===1,U=g&&R.button===0;!F&&!U||(R.preventDefault(),a=!0,l=R.pointerId,d=R.clientX,u=R.clientY,m=o.current.tx,p=o.current.ty,i.setPointerCapture(R.pointerId),i.style.cursor="grabbing")},Q=R=>{!a||R.pointerId!==l||(o.current.tx=m+(R.clientX-d),o.current.ty=p+(R.clientY-u),s())},re=R=>{a&&R.pointerId===l&&(a=!1,i.releasePointerCapture(R.pointerId),i.style.cursor=g?"grab":"")},_e=R=>{if(R.code==="Space"&&!g){const F=R.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;g=!0,i.style.cursor="grab",R.preventDefault()}},me=R=>{R.code==="Space"&&(g=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",z,{passive:!1}),i.addEventListener("pointerdown",D),i.addEventListener("pointermove",Q),i.addEventListener("pointerup",re),i.addEventListener("pointercancel",re),i.addEventListener("pointerdown",w,{capture:!0}),i.addEventListener("pointermove",M,{capture:!0}),i.addEventListener("pointerup",P,{capture:!0}),i.addEventListener("pointercancel",P,{capture:!0}),window.addEventListener("keydown",_e),window.addEventListener("keyup",me),s(),()=>{i.removeEventListener("wheel",z),i.removeEventListener("pointerdown",D),i.removeEventListener("pointermove",Q),i.removeEventListener("pointerup",re),i.removeEventListener("pointercancel",re),i.removeEventListener("pointerdown",w,{capture:!0}),i.removeEventListener("pointermove",M,{capture:!0}),i.removeEventListener("pointerup",P,{capture:!0}),i.removeEventListener("pointercancel",P,{capture:!0}),window.removeEventListener("keydown",_e),window.removeEventListener("keyup",me)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const d=l.getBoundingClientRect(),u=(i-d.left-o.current.tx)/o.current.scale,m=(a-d.top-o.current.ty)/o.current.scale;return[u,m]},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=pn(i.scale,fn,hn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function pn(e,t,n){return e<t?t:e>n?n:e}const Xb=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),tt=Xb?"⌘":"Ctrl+",jS=Xb?"⇧":"Shift+",gn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],ES=18;function NS(e){for(const t of gn)if(t*e>=ES)return t;return gn[gn.length-1]}function MS(){const e=te(),t=I.useRef(null),n=I.useRef(null),o=I.useRef(null),r=SS(t,n);bS(t,r),oS(t),I.useEffect(()=>(Po(r),()=>Po(null)),[r]),I.useEffect(()=>{const u=m=>{const p=o.current;if(!p)return;const f=NS(m.scale)*m.scale;p.setAttribute("width",String(f)),p.setAttribute("height",String(f)),p.setAttribute("patternTransform",`translate(${m.tx} ${m.ty})`)};return u(r.getViewport()),r.subscribe(u)},[r]);const s=Mv(),i=I.useCallback((u,m,p)=>{const g=x.getState(),f=g.activeTool;if(f==="wire"||f==="busbar"||f==="place"){Wb();return}const h=rt(p);if(h)g.selection.includes(h)||g.setSelection([h]);else{const D=Ut(p);D&&g.selectedNode!==D&&g.setSelectedNode(D)}const b=x.getState(),k=b.selection.length>0,w=b.selectedNode!=null,M=!!b.clipboard,P=b.diagram.elements.length>0,z=[{label:e("menu.undo"),shortcut:`${tt}Z`,icon:Ln,onSelect:()=>x.getState().undo(),disabled:b.past.length===0},{label:e("menu.redo"),shortcut:`${tt}${jS}Z`,icon:Bn,onSelect:()=>x.getState().redo(),disabled:b.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${tt}X`,icon:kr,onSelect:()=>x.getState().cutSelection(),disabled:!k},{label:e("menu.copy"),shortcut:`${tt}C`,icon:xr,onSelect:()=>x.getState().copySelection(),disabled:!k},{label:e("menu.paste"),shortcut:`${tt}V`,icon:yr,onSelect:()=>x.getState().pasteClipboard(),disabled:!M},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:vr,onSelect:()=>x.getState().rotateSelection(90),disabled:!k},{label:e("menu.mirror"),shortcut:"M",icon:br,onSelect:()=>x.getState().mirrorSelection(),disabled:!k},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${tt}A`,icon:Uw,onSelect:()=>{const D=x.getState();D.setSelection(D.diagram.elements.map(Q=>Q.id))},disabled:!P},{type:"separator"},{label:e(w&&!k?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:$r,destructive:!0,onSelect:()=>w&&!k?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!k&&!w}];s.open(u,m,z)},[s,e]);I.useEffect(()=>{const u=t.current;if(!u)return;const m=700,p=4;let g,f=null;const h=()=>{g!==void 0&&window.clearTimeout(g),g=void 0,f=null},b=M=>{M.pointerType==="touch"&&(h(),f={pointerId:M.pointerId,x:M.clientX,y:M.clientY,target:M.target},g=window.setTimeout(()=>{const P=f;f=null,g=void 0,P&&(Hb(u,P.pointerId),i(P.x,P.y,P.target))},m))},k=M=>{if(!f||M.pointerId!==f.pointerId)return;const P=M.clientX-f.x,z=M.clientY-f.y;Math.hypot(P,z)>p&&h()},w=M=>{!f||M.pointerId!==f.pointerId||h()};return u.addEventListener("pointerdown",b),u.addEventListener("pointermove",k),u.addEventListener("pointerup",w),u.addEventListener("pointercancel",w),()=>{h(),u.removeEventListener("pointerdown",b),u.removeEventListener("pointermove",k),u.removeEventListener("pointerup",w),u.removeEventListener("pointercancel",w)}},[i]);const a=u=>{u.dataTransfer.types.includes("application/x-oneline-kind")&&(u.preventDefault(),u.dataTransfer.dropEffect="copy")},l=u=>{const m=u.dataTransfer.getData("application/x-oneline-kind");if(!m)return;u.preventDefault();const p=r.screenToSvg(u.clientX,u.clientY);Bb(m,p)},d=u=>{u.preventDefault(),i(u.clientX,u.clientY,u.target)};return c.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:d,children:c.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("defs",{children:c.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:c.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),c.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),c.jsxs("g",{ref:n,className:"ole-viewport",children:[c.jsx(I$,{}),c.jsx(G$,{}),c.jsx(L$,{}),c.jsx(k$,{}),c.jsx($$,{}),c.jsx(H$,{}),c.jsx(N$,{}),c.jsx(M$,{}),c.jsx(q$,{}),c.jsx(V$,{}),c.jsx(P$,{}),c.jsx(F$,{}),c.jsx(D$,{})]})]})})}const Xo=60,TS=.1,AS=8,CS=8;function IS(e,t,n){return e<t?t:e>n?n:e}function PS(){return document.querySelector(".ole-canvas-root")}function Fn(){const e=Ze(),t=PS();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 k of o){const w=k.getBoundingClientRect();w.width===0&&w.height===0||(w.left<r&&(r=w.left),w.top<s&&(s=w.top),w.right>i&&(i=w.right),w.bottom>a&&(a=w.bottom))}if(r===1/0)return!1;const[l,d]=e.screenToSvg(r,s),[u,m]=e.screenToSvg(i,a),p=Math.max(u-l,1),g=Math.max(m-d,1),f=IS(Math.min((n.width-Xo*2)/p,(n.height-Xo*2)/g),TS,AS),h=(l+u)/2,b=(d+m)/2;return e.setViewport({tx:n.width/2-f*h,ty:n.height/2-f*b,scale:f}),!0}function Hn(){let e=CS;const t=()=>{Fn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const Vo=10,OS=100;function BS(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function LS(){const[e,t]=I.useState(J$()),[n,o]=I.useState(!1),[r,s]=I.useState(null),i=I.useRef(null),a=I.useRef(void 0),[l]=I.useState(BS);I.useEffect(()=>eS(f=>t(f)),[]),I.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),OS),()=>window.clearTimeout(a.current)},[e]);const d=x(f=>e?f.diagram.elements.find(h=>h.id===e)??null:null);if(I.useLayoutEffect(()=>{if(!n||!e)return;let f=0,h=-1,b=-1;const k=()=>{const w=document.querySelector(`[data-element-id="${zS(e)}"]`),M=i.current;if(w&&M){const P=w.getBoundingClientRect();let z=P.bottom+Vo;z+M.offsetHeight>window.innerHeight-4&&(z=P.top-M.offsetHeight-Vo);let D=P.left+P.width/2-M.offsetWidth/2;D=Math.max(4,Math.min(D,window.innerWidth-M.offsetWidth-4)),(z!==h||D!==b)&&(s({top:z,left:D}),h=z,b=D)}f=requestAnimationFrame(k)};return f=requestAnimationFrame(k),()=>cancelAnimationFrame(f)},[n,e]),l||!n||!e||!d)return null;const u=Xe[d.kind],m=d.name??d.id,p=(u==null?void 0:u.name)??d.kind,g=d.name&&d.name!==d.id;return typeof document>"u"?null:hr.createPortal(c.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:[c.jsx("span",{className:"font-medium text-foreground",children:m}),g&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:d.id}),c.jsx("span",{className:"text-muted-foreground/80",children:"·"}),c.jsx("span",{className:"text-muted-foreground",children:p})]}),document.body)}function zS(e){return e.replace(/(["\\])/g,"\\$1")}function RS({width:e,children:t}){const n=e==null?"full":uS(e);return c.jsx(Gb.Provider,{value:n,children:t})}function Yo(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function DS(...e){return t=>{let n=!1;const o=e.map(r=>{const s=Yo(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():Yo(e[r],null)}}}}var FS=Symbol.for("react.lazy"),qt=we[" use ".trim().toString()];function HS(e){return typeof e=="object"&&e!==null&&"then"in e}function Vb(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===FS&&"_payload"in e&&HS(e._payload)}function WS(e){const t=GS(e),n=we.forwardRef((o,r)=>{let{children:s,...i}=o;Vb(s)&&typeof qt=="function"&&(s=qt(s._payload));const a=we.Children.toArray(s),l=a.find(XS);if(l){const d=l.props.children,u=a.map(m=>m===l?we.Children.count(d)>1?we.Children.only(null):we.isValidElement(d)?d.props.children:null:m);return c.jsx(t,{...i,ref:r,children:we.isValidElement(d)?we.cloneElement(d,void 0,u):null})}return c.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var qS=WS("Slot");function GS(e){const t=we.forwardRef((n,o)=>{let{children:r,...s}=n;if(Vb(r)&&typeof qt=="function"&&(r=qt(r._payload)),we.isValidElement(r)){const i=YS(r),a=VS(s,r.props);return r.type!==we.Fragment&&(a.ref=o?DS(o,i):i),we.cloneElement(r,a)}return we.Children.count(r)>1?we.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var KS=Symbol("radix.slottable");function XS(e){return we.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===KS}function VS(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 YS(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 Uo=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Zo=Er,US=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return Zo(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(d=>{const u=n==null?void 0:n[d],m=s==null?void 0:s[d];if(u===null)return null;const p=Uo(u)||Uo(m);return r[d][p]}),a=n&&Object.entries(n).reduce((d,u)=>{let[m,p]=u;return p===void 0||(d[m]=p),d},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((d,u)=>{let{class:m,className:p,...g}=u;return Object.entries(g).every(f=>{let[h,b]=f;return Array.isArray(b)?b.includes({...s,...a}[h]):{...s,...a}[h]===b})?[...d,m,p]:d},[]);return Zo(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},ZS=US("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"}}),Ne=we.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?qS:"button";return c.jsx(i,{className:ke(ZS({variant:t,size:n,className:e})),ref:s,...r})});Ne.displayName="Button";const QS=350;function Me({content:e,children:t,disabled:n,delayMs:o=QS}){const r=I.useRef(null),s=I.useRef(null),[i,a]=I.useState(!1),[l,d]=I.useState(null),u=I.useId(),m=I.useRef(void 0),p=()=>{n||(window.clearTimeout(m.current),m.current=window.setTimeout(()=>a(!0),o))},g=()=>{window.clearTimeout(m.current),a(!1)};I.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const k=r.current.getBoundingClientRect(),w=s.current.getBoundingClientRect(),M=8;let P="top",z=k.top-w.height-M;z<4&&(P="bottom",z=k.bottom+M);let D=k.left+k.width/2-w.width/2;D=Math.max(4,Math.min(D,window.innerWidth-w.width-4)),d({top:z,left:D,side:P})},[i,e]),I.useEffect(()=>()=>window.clearTimeout(m.current),[]),I.useEffect(()=>{if(!i)return;const k=M=>{M.key==="Escape"&&a(!1)},w=()=>a(!1);return window.addEventListener("keydown",k),window.addEventListener("scroll",w,!0),window.addEventListener("resize",w),()=>{window.removeEventListener("keydown",k),window.removeEventListener("scroll",w,!0),window.removeEventListener("resize",w)}},[i]);const f=t,h=f.props,b=I.cloneElement(f,{ref:k=>{r.current=k;const w=f.ref;typeof w=="function"?w(k):w&&typeof w=="object"&&(w.current=k)},onPointerEnter:k=>{var w;(w=h.onPointerEnter)==null||w.call(h,k),p()},onPointerLeave:k=>{var w;(w=h.onPointerLeave)==null||w.call(h,k),g()},onFocus:k=>{var w;(w=h.onFocus)==null||w.call(h,k),p()},onBlur:k=>{var w;(w=h.onBlur)==null||w.call(h,k),g()},"aria-describedby":i?u:h["aria-describedby"]});return c.jsxs(c.Fragment,{children:[b,i&&typeof document<"u"&&hr.createPortal(c.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 Qo=12,JS=56;function e4(){var k;const e=te(),t=x(w=>w.selection),n=x(w=>w.selectedNode),o=x(w=>w.selectedWire),r=x(w=>w.activeTool),s=x(w=>w.rotateSelection),i=x(w=>w.mirrorSelection),a=x(w=>w.deleteSelection),l=x(w=>w.deleteSelectedNode),d=x(w=>w.deleteSelectedWire),u=x(w=>w.resetWirePath),m=x(w=>w.internal.wireRenders),p=o!=null&&((k=m.get(o))==null?void 0:k.userEdited)===!0,g=I.useRef(null);I.useEffect(()=>{const w=g.current;if(!w)return;const M=t.length>0,P=!M&&o!=null,z=!M&&!P&&n!=null;if(!((M||P||z)&&(r==="select"||r==="pan"))){w.style.display="none";return}w.style.display="flex";let Q=0,re="";const _e=()=>{let me=1/0,R=-1/0,F=1/0,U=-1/0,oe=!1;const ie=Z=>{Z.width===0&&Z.height===0||(Z.left<me&&(me=Z.left),Z.right>R&&(R=Z.right),Z.top<F&&(F=Z.top),Z.bottom>U&&(U=Z.bottom),oe=!0)};if(M)for(const Z of t){const fe=document.querySelector(`[data-element-id="${CSS.escape(Z)}"]`);fe&&ie(fe.getBoundingClientRect())}else if(P&&o){const Z=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);Z&&ie(Z.getBoundingClientRect())}else if(z&&n){const Z=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const fe of Z)ie(fe.getBoundingClientRect())}if(oe){const Z=(me+R)/2;let fe=F-Qo,he="-100%";fe<JS&&(fe=U+Qo,he="0%");const pe=`translate3d(${Z}px, ${fe}px, 0) translate(-50%, ${he})`;pe!==re&&(w.style.transform=pe,re=pe)}Q=requestAnimationFrame(_e)};return Q=requestAnimationFrame(_e),()=>cancelAnimationFrame(Q)},[t,n,o,r]);const f=t.length===0&&o!=null,h=t.length===0&&!f&&n!=null,b=h||f;return c.jsxs("div",{ref:g,role:"toolbar","aria-label":e(f?"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:[f&&p&&o&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{children:c.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>u(o),"aria-label":e("ctx.resetWirePath"),children:c.jsx(Yw,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!b&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:c.jsx(vr,{})})}),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:c.jsx(br,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.delete")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),c.jsx("div",{className:"text-muted-foreground",children:e(f?"ctx.deleteHintWire":h?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>f?d():h?l():a(),"aria-label":e("ctx.delete"),children:c.jsx($r,{})})})]})}function Wn({open:e,onOpenChange:t,trigger:n,children:o}){const r=I.useRef(null);return I.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]),c.jsxs("div",{ref:r,className:"relative",children:[n,e&&c.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 Yb="ole-panel-open";function t4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(Yb);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 Jo(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(Yb,JSON.stringify(t))}catch{}}const jt=Gt((e,t)=>({...t4(),setOutlineOpen:n=>{e({outlineOpen:n}),Jo(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),Jo(t())}})),Lt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],Ub=.1,Zb=8,Qb="ole-grid";function n4(){try{const e=window.localStorage.getItem(Qb);return e==null?!0:e==="1"}catch{return!0}}function o4(e){try{window.localStorage.setItem(Qb,e?"1":"0")}catch{}}function r4(e,t,n){return e<t?t:e>n?n:e}function Jb(){return document.querySelector(".ole-canvas-root")}function qn(e){const t=Ze(),n=Jb();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=r4(e,Ub,Zb),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function s4(){const e=Ze();if(!e)return;const t=e.getViewport().scale,n=Lt.find(o=>o>t+1e-6)??Zb;qn(n)}function i4(){const e=Ze();if(!e)return;const t=e.getViewport().scale;let n=Ub;for(let o=Lt.length-1;o>=0;o--)if(Lt[o]<t-1e-6){n=Lt[o];break}qn(n)}const a4={off:"id",id:"all",all:"off"};function l4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=a4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function ew(){const[e,t]=I.useState(()=>n4());return I.useEffect(()=>{const n=Jb();n==null||n.classList.toggle("hide-grid",!e),o4(e)},[e]),I.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 tw(){const e=te();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:i4,"aria-label":e("view.zoomOut"),children:c.jsx(On,{})})})}function nw(){const e=te();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:s4,"aria-label":e("view.zoomIn"),children:c.jsx(Xw,{})})})}function ow(){const e=te(),[t,n]=I.useState(vS);return I.useEffect(()=>kS(n),[]),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.reset")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:c.jsxs("button",{type:"button",onClick:()=>qn(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 rw(){const e=te();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.fit")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:Fn,"aria-label":e("view.fit"),children:c.jsx(qw,{})})})}function sw({grid:e,setGrid:t}){const n=te();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),c.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:()=>t(o=>!o),"aria-label":n(e?"view.gridHideAria":"view.gridShowAria"),"aria-pressed":e,className:ke(!e&&"text-muted-foreground/60"),children:c.jsx(Hw,{})})})}function iw(){const e=te(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:l4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:ke(t==="off"&&"text-muted-foreground/60"),children:c.jsx(Sr,{})})})}function c4({stacked:e}={}){const t=te(),[n,o]=I.useState(!1),[r,s]=ew(),i=c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:t("view.menu")}),c.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?c.jsx(Me,{content:i,children:c.jsxs("button",{type:"button",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,className:ke("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:[c.jsx(bn,{className:"size-4"}),c.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):c.jsx(Me,{content:i,children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:c.jsx(bn,{})})});return c.jsx(Wn,{open:n,onOpenChange:o,trigger:a,children:c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx(ow,{}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(tw,{}),c.jsx(nw,{})]}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(rw,{}),c.jsx(sw,{grid:r,setGrid:s}),c.jsx(iw,{})]})]})})}function d4(){const e=Ve();return Ce(e,"dense")?null:c.jsx(u4,{tier:e})}function u4({tier:e}){const t=Ce(e,"tight"),[n,o]=ew();return c.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:c.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[c.jsx(tw,{}),!t&&c.jsx(ow,{}),c.jsx(nw,{}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),c.jsx(rw,{}),c.jsx(sw,{grid:n,setGrid:o}),c.jsx(iw,{})]})})}const er=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:Gw,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:Ww,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:On,switchTo:"busbar"},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:_r,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:gr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Sr,switchTo:"text",iconOnly:!0}];function m4(){const e=te(),t=x(u=>u.activeTool),n=x(u=>u.placeKind),o=x(u=>u.placeFromTerminal),r=x(u=>u.wireFromTerminal),s=x(u=>u.busbarDrawStart),i=x(u=>u.selection.length>0||u.selectedNode!=null);let a=null,l=!1;switch(t){case"select":a=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(l=!0);break;case"pan":a=e("mode.pan");break;case"wire":a=e(r?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(s?"mode.busDragging":"mode.busInit"),l=!0;break;case"place":n?o?a=e("mode.placeFromTerm"):a=e("mode.placeNormal"):a=e("mode.placeNoKind"),l=!0;break;case"text":a=e("mode.text"),l=!0;break}if(!a)return null;const d=e(t==="select"?"mode.escSelect":"mode.escOther");return c.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:[c.jsx("span",{children:a}),l&&c.jsxs("span",{className:"text-muted-foreground/70",children:["· ",d]})]})}function f4(){const e=te(),t=x(f=>f.activeTool),n=x(f=>f.placeKind),o=x(f=>f.setActiveTool),r=x(f=>f.past.length),s=x(f=>f.future.length),i=x(f=>f.undo),a=x(f=>f.redo),l=Ve(),d=Ce(l,"tight"),u=!Ce(l,"dense"),m=Ce(l,"dense"),p=m?er.filter(f=>f.id!=="select"&&f.id!=="text"):er,g=f=>t===f.switchTo;return c.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))"},children:[u&&c.jsx(m4,{}),c.jsxs("div",{className:ke("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",m?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[m&&c.jsx(h4,{stacked:!0}),p.map(f=>{const h=f.icon,b=g(f),k=f.id==="place"&&b&&n==null?e("tool.placeNoKindTooltip"):e(f.descriptionKey);return c.jsxs(I.Fragment,{children:[c.jsx(ot,{icon:h,label:e(f.labelKey),hotkey:f.hotkey,active:b,iconOnly:!m&&(f.iconOnly||d),stacked:m,description:k,onClick:()=>{o(f.switchTo,{placeKind:f.presetPlaceKind!==void 0?f.presetPlaceKind:void 0})}}),f.groupBreakAfter&&!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},f.id)}),!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),m?c.jsx(g4,{stacked:!0}):c.jsxs(c.Fragment,{children:[c.jsx(ot,{icon:Ln,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),c.jsx(ot,{icon:Bn,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),c.jsx(p4,{iconOnly:d})]}),m&&c.jsx(c4,{stacked:!0})]})]})}function h4({stacked:e}){const t=te(),n=jt(r=>r.outlineOpen),o=jt(r=>r.toggleOutline);return c.jsx(ot,{icon:wr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function ot({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const d=c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:t}),n&&c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&c.jsx("div",{className:"text-muted-foreground",children:l})]});return c.jsx(Me,{content:d,disabled:r,children:c.jsxs("button",{type:"button",onClick:a,disabled:r,"aria-label":t,"aria-pressed":o,className:ke("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:[c.jsxs("span",{className:"relative inline-flex shrink-0",children:[c.jsx(e,{className:"size-4"}),n&&!i&&c.jsx("span",{"aria-hidden":!0,className:ke("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?c.jsx("span",{className:"max-w-full truncate",children:t}):!s&&c.jsx("span",{children:t})]})})}function aw(){const e=x(r=>r.diagram.elements),t=x(r=>r.diagram.layout),n=x(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 p4({iconOnly:e}){const t=te(),[n,o]=I.useState(!1),r=aw(),s=i=>()=>{o(!1),i()};return c.jsxs(Wn,{open:n,onOpenChange:o,trigger:c.jsx(ot,{icon:wt,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[c.jsx(Ee,{onClick:s(()=>x.getState().autoArrangeAll()),icon:c.jsx(wt,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Ee,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:c.jsx(wt,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:c.jsx(zt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),c.jsx(Ee,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(zt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function g4({stacked:e}){const t=te(),[n,o]=I.useState(!1),r=x(p=>p.past.length),s=x(p=>p.future.length),i=x(p=>p.undo),a=x(p=>p.redo),l=x(p=>p.selection.length>0),d=x(p=>p.clipboard!=null),u=aw(),m=p=>()=>{o(!1),p()};return c.jsxs(Wn,{open:n,onOpenChange:o,trigger:c.jsx(ot,{icon:bn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(p=>!p)}),children:[c.jsx(Ee,{onClick:m(i),icon:c.jsx(Ln,{}),disabled:r===0,children:t("tool.undo")}),c.jsx(Ee,{onClick:m(a),icon:c.jsx(Bn,{}),disabled:s===0,children:t("tool.redo")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:m(()=>x.getState().cutSelection()),icon:c.jsx(kr,{}),disabled:!l,children:t("menu.cut")}),c.jsx(Ee,{onClick:m(()=>x.getState().copySelection()),icon:c.jsx(xr,{}),disabled:!l,children:t("menu.copy")}),c.jsx(Ee,{onClick:m(()=>x.getState().pasteClipboard()),icon:c.jsx(yr,{}),disabled:!d,children:t("menu.paste")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:m(()=>x.getState().autoArrangeAll()),icon:c.jsx(wt,{}),disabled:!u.hasAnyElement||!u.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Ee,{onClick:m(()=>x.getState().autoArrangeSelection()),icon:c.jsx(wt,{}),disabled:!u.hasSelection||!u.selectionHasArranged,children:t("layout.selAuto")}),c.jsx(Ee,{onClick:m(()=>x.getState().fillUnplacedAll()),icon:c.jsx(zt,{}),disabled:!u.hasGapsAll,children:t("layout.allFill")}),c.jsx(Ee,{onClick:m(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(zt,{}),disabled:!u.hasSelection||!u.selectionHasGaps,children:t("layout.selFill")})]})}function Ee({children:e,icon:t,onClick:n,disabled:o}){return c.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,className:ke("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,c.jsx("span",{className:"flex-1",children:e})]})}function y4(){const e=jt(r=>r.outlineOpen),t=jt(r=>r.setOutlineOpen),n=Ve();return Ce(n,"dense")?e?c.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:c.jsx(tr,{onClose:()=>t(!1),sheet:!0})}):null:c.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?c.jsx(tr,{onClose:()=>t(!1)}):c.jsx(x4,{onClick:()=>t(!0)})})}function x4({onClick:e}){const t=te(),n=Ve(),o=Ce(n,"compact");return c.jsxs("button",{type:"button",onClick:e,"aria-label":t("outline.title"),title:t("outline.title"),className:ke("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:[c.jsx(wr,{className:"size-4 shrink-0"}),!o&&c.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function tr({onClose:e,sheet:t}){const n=te(),o=x(d=>d.diagram.elements),r=x(d=>d.activeTool==="place"),s=Ve(),i=Ce(s,"compact"),a=Ce(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return c.jsxs("aside",{className:ke("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:[c.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:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&c.jsx(w4,{children:o.length}),c.jsx(Kw,{className:"size-3.5 text-muted-foreground"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?c.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):c.jsx("ul",{className:"space-y-px",children:o.map(d=>c.jsx(b4,{element:d},d.id))})})]})}function b4({element:e}){const t=Xe[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ve(),i=!Ce(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return c.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:[c.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&c.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),c.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function w4({children:e}){return c.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 v4={"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":"负荷","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":"抽象负荷(电流流出箭头)","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":"剩余动作电流"},k4={"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","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"},nr={zh:v4,en:k4};function _4(e,t){return nr[e][t]??nr.zh[t]}function Nt(){const e=Et(t=>t.locale);return(t,n)=>_4(e,t)??n??t}const lw="ole-palette-collapsed",$4=new Set(["busbar"]),_t=(()=>{const e={};for(const[t,n]of Object.entries(i$)){const o=n.filter(r=>!$4.has(r.id));o.length&&(e[t]=o)}return e})(),S4=(()=>{const e=new Set(To),t=Object.keys(_t).filter(n=>!e.has(n));return[...To.filter(n=>{var o;return(o=_t[n])==null?void 0:o.length}),...t]})();function j4(){try{const e=window.localStorage.getItem(lw);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 E4(e){try{window.localStorage.setItem(lw,JSON.stringify([...e]))}catch{}}function N4(){const e=te(),t=x(m=>m.activeTool==="place"),n=x(m=>m.placeKind),o=x(m=>m.setActiveTool),r=jt(m=>m.outlineOpen),s=Ve(),i=Ce(s,"dense"),a=68,d=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))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:a};return c.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:u,role:"dialog","aria-label":e("library.title"),children:c.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:d?{maxHeight:d}:void 0,children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),c.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:c.jsx(zn,{className:"size-3.5"})})]}),c.jsx(M4,{sheet:i})]})})}function M4({sheet:e}){const t=te(),n=Nt(),[o,r]=I.useState(""),[s,i]=I.useState(()=>j4()),a=I.useMemo(()=>{const m=o.trim().toLowerCase();if(!m)return _t;const p={};for(const[g,f]of Object.entries(_t)){const h=f.filter(b=>{const k=n(`${b.id}.name`,b.name).toLowerCase(),w=n(`${b.id}.desc`,b.description??"").toLowerCase();return k.includes(m)||b.id.toLowerCase().includes(m)||w.includes(m)});h.length&&(p[g]=h)}return p},[o,n]),l=o.trim().length>0,d=l&&Object.values(a).every(m=>!(m!=null&&m.length)),u=I.useCallback((m,p)=>{i(g=>{const f=new Set(g);return p?f.delete(m):f.add(m),E4(f),f})},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-2 pb-1.5 pt-2",children:c.jsx(T4,{value:o,onChange:r})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:d?c.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):S4.map(m=>{var b;const p=a[m];if(!(p!=null&&p.length))return null;const g=((b=_t[m])==null?void 0:b.length)??p.length,f=t(`cat.${m}`),h=l||!s.has(m);return c.jsxs("details",{open:h,className:"group mb-2 last:mb-0",onToggle:k=>{l||u(m,k.currentTarget.open)},children:[c.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:[c.jsx(Bw,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),c.jsx("span",{className:"flex-1",children:f}),c.jsx(C4,{children:l&&p.length!==g?`${p.length}/${g}`:g})]}),c.jsx("ul",{className:"mt-0.5 space-y-px",children:p.map(k=>c.jsx(A4,{entry:k,sheet:e},k.id))})]},m)})})]})}function T4({value:e,onChange:t}){const n=te();return c.jsxs("div",{className:"relative",children:[c.jsx(Vw,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),c.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&&c.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:c.jsx(zn,{className:"size-3"})})]})}function A4({entry:e,sheet:t}){const n=te(),o=Nt(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(m=>m.setActiveTool),a=x(m=>m.activeTool==="place"&&m.placeKind===e.id),l=x(m=>t&&m.activeTool==="place"&&m.placeKind==null&&m.lastPlaceKind===e.id),d=I.useRef(null);I.useEffect(()=>{var m;l&&((m=d.current)==null||m.scrollIntoView({block:"nearest"}))},[l]);const u=m=>{m.dataTransfer.effectAllowed="copy",m.dataTransfer.setData("application/x-oneline-kind",e.id),m.dataTransfer.setData("text/plain",e.id);const p=document.createElement("div");p.className="ole-glass",p.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(";"),p.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(p),m.dataTransfer.setDragImage(p,32,32),setTimeout(()=>p.remove(),0)};return c.jsxs("li",{ref:d,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:[c.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:c.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),c.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function C4({children:e}){return c.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 In="ole-onboarding-dismissed";function I4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(In)==="1"}catch{return!1}}function or(e){try{e?window.localStorage.setItem(In,"1"):window.localStorage.removeItem(In)}catch{}}const rr=Gt(e=>({dismissed:I4(),dismiss:()=>{or(!0),e({dismissed:!0})},reset:()=>{or(!1),e({dismissed:!1})}}));function P4(){const e=te(),t=rr(o=>o.dismissed),n=rr(o=>o.dismiss);return t?null:c.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:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),c.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:c.jsx(zn,{className:"size-3.5"})})]}),c.jsxs("ol",{className:"mt-3 space-y-2.5",children:[c.jsx(yn,{n:1,icon:c.jsx(On,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),c.jsx(yn,{n:2,icon:c.jsx(_r,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),c.jsx(yn,{n:3,icon:c.jsx(gr,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),c.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 yn({n:e,icon:t,title:n,body:o}){return c.jsxs("li",{className:"flex items-start gap-2.5",children:[c.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}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[c.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),c.jsx("span",{children:n})]}),c.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function O4(){const e=te(),t=x(u=>u.selection),n=x(u=>u.diagram.elements),o=x(u=>u.diagram.buses),r=x(u=>u.selectedNode),s=x(u=>u.selectedWire);if(s)return c.jsx(F4,{wireId:s});if(r)return c.jsx(H4,{nodeId:r});if(t.length===0)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const i=t[0],a=(o??[]).find(u=>u.id===i);if(a)return c.jsx(R4,{bus:a});const l=n.find(u=>u.id===i);if(!l)return null;const d=Xe[l.kind];return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(Mt,{label:e("props.name"),value:l.name??"",placeholder:l.id,onCommit:u=>x.getState().updateElement(i,{name:u.trim()===""?void 0:u.trim()})}),c.jsx(cw,{label:e("props.note"),value:l.note??"",onCommit:u=>x.getState().updateElement(i,{note:u.trim()===""?void 0:u.trim()})}),(d==null?void 0:d.state)&&d.state.length>0&&c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:d.state.map(u=>c.jsx(W4,{id:i,element:l,field:u},u.name))}),c.jsx(B4,{id:i,element:l,schema:(d==null?void 0:d.params)??[]})]})}function B4({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:c.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>c.jsx(L4,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>c.jsx(z4,{id:e,element:t,fieldKey:s,value:i},s))]})}function L4({id:e,element:t,field:n}){var l;const o=te(),r=Nt(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=d=>{const u={...t.params??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{params:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(at,{label:i,children:c.jsx(Gn,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Zt,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):c.jsx(Mt,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:d=>a(d.trim()===""?void 0:d)})}function z4({id:e,element:t,fieldKey:n,value:o}){const r=te(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,x.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?c.jsx(at,{label:n,children:c.jsx(Gn,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?c.jsx(Zt,{label:n,value:o,onCommit:s}):c.jsx(Mt,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function R4({bus:e}){const t=te(),n=e.id,o=r=>{const s=r.trim();Pn(n,{name:s===""?void 0:s})};return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(Mt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),c.jsx(cw,{label:t("props.note"),value:e.note??"",onCommit:r=>Pn(n,{note:r.trim()===""?void 0:r.trim()})}),c.jsx(D4,{bus:e})]})}function D4({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Pn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:c.jsx(Zt,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Pn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function F4({wireId:e}){const t=te(),n=x(f=>f.diagram.wires),o=x(f=>f.diagram.elements),r=x(f=>f.diagram.buses),s=x(f=>f.internal.terminalToNode),i=x(f=>f.setSelectedNode),a=(n??[]).find(f=>f.id===e);if(!a)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const l=s.get(a.ends[0]),d=new Map(o.map(f=>[f.id,f])),u=new Map((r??[]).map(f=>[f.id,f])),m=f=>{if(!f.includes(".")){const M=u.get(f);return{id:f,label:(M==null?void 0:M.name)??f}}const h=f.indexOf("."),b=f.slice(0,h),k=f.slice(h+1),w=d.get(b);return{id:b,label:(w==null?void 0:w.name)??b,pin:k}},p=m(a.ends[0]),g=m(a.ends[1]);return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),c.jsx("div",{className:"font-mono text-[12px]",children:a.id})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[p,g].map((f,h)=>c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([f.id]),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:f.id}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:f.label}),f.pin&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:f.pin})]},h))}),l&&c.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:()=>i(l),children:t("props.selectWholeNode")})]})}function H4({nodeId:e}){const t=te(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return c.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 d=a.slice(0,l),u=a.slice(l+1),m=s.get(d)??[];m.push(u),s.set(d,m)}const i=new Map(o.map(a=>[a.id,a]));return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),c.jsx("div",{className:"font-mono text-[12px]",children:n.id}),c.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const d=i.get(a);return c.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:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(d==null?void 0:d.name)??""}),c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function at({label:e,children:t}){return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),c.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function Mt({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=I.useState(t),a=I.useRef(null);return I.useEffect(()=>i(t),[t]),c.jsx(at,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(t),(u=a.current)==null||u.blur())},className:ke("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&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function cw({label:e,value:t,onCommit:n}){const[o,r]=I.useState(t);return I.useEffect(()=>r(t),[t]),c.jsx(at,{label:e,children:c.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},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 Zt({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=I.useState(String(t)),a=I.useRef(null);return I.useEffect(()=>i(String(t)),[t]),c.jsx(at,{label:e,children:c.jsxs("div",{className:"relative",children:[c.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 d,u;l.key==="Enter"&&((d=a.current)==null||d.blur()),l.key==="Escape"&&(i(String(t)),(u=a.current)==null||u.blur())},min:n,className:ke("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&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Gn({active:e,onClick:t,children:n}){return c.jsx("button",{type:"button",onClick:t,className:ke("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 W4({id:e,element:t,field:n}){var l;const o=te(),s=Nt()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=d=>{const u={...t.state??{}};d===void 0||d===n.default?delete u[n.name]:u[n.name]=d,x.getState().updateElement(e,{state:Object.keys(u).length>0?u:void 0})};return n.type==="boolean"?c.jsx(at,{label:s,children:c.jsx(Gn,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Zt,{label:s,value:typeof i=="number"?i:0,onCommit:a}):c.jsx(Mt,{label:s,value:typeof i=="string"?i:"",onCommit:d=>a(d.trim()===""?void 0:d)})}function q4(){const e=te(),t=Nt(),n=x(m=>m.selection),o=x(m=>m.selectedNode),r=x(m=>m.selectedWire),s=x(m=>m.diagram.elements),i=x(m=>m.diagram.buses),a=Ve(),l=Ce(a,"dense");if(n.length===0&&!o&&!r)return null;let d=e("props.title"),u=null;if(r)d=e("props.wire");else if(o)d=e("props.node");else if(n.length===1){const m=n[0],p=(i??[]).find(g=>g.id===m);if(p)d=p.name??e("props.bus");else{const g=s.find(f=>f.id===m);if(g){const f=Xe[g.kind];d=f?t(`${f.id}.name`,f.name):g.kind}}}else u=n.length;return c.jsxs("aside",{className:ke("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",l?"w-48":"w-56"),style:{top:`calc(${l?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:d}),u!=null&&c.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:u})})]}),c.jsx(O4,{})]})}function G4(){I.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 K4(){G4();const e=I.useRef(null),t=mS(e);return c.jsx(Tv,{children:c.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:c.jsxs(RS,{width:t,children:[c.jsx(MS,{}),c.jsx(y4,{}),c.jsx(q4,{}),c.jsx(f4,{}),c.jsx(d4,{}),c.jsx(e4,{}),c.jsx(N4,{}),c.jsx(P4,{}),c.jsx(LS,{})]})})})}const X4="ole-theme";function V4(){try{const e=window.localStorage.getItem(X4);return e==="light"||e==="dark"?e:null}catch{return null}}function Y4(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function U4(){return typeof window>"u"?"light":V4()??(Y4()?"dark":"light")}function dw(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function Z4({className:e,diagram:t,locale:n,theme:o}){return I.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),I.useEffect(()=>{n&&Et.getState().setLocale(n)},[n]),I.useEffect(()=>{o&&dw(o)},[o]),I.useEffect(()=>{Hn()},[]),Z$(),c.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:c.jsx(K4,{})})}const uw={"application/json":[".json"]},mw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",fw=e=>e instanceof DOMException&&e.name==="AbortError";function sr(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 Q4(e){return JSON.stringify(e,null,2)+`
|
|
194
|
-
|
|
195
|
-
|
|
191
|
+
*/const kt=ee("WandSparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);/**
|
|
192
|
+
* @license lucide-react v0.469.0 - ISC
|
|
193
|
+
*
|
|
194
|
+
* This source code is licensed under the ISC license.
|
|
195
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
+
*/const Wn=ee("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function zr(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=zr(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function Rr(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=zr(e))&&(o&&(o+=" "),o+=t);return o}const qn="-",lv=e=>{const t=dv(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:i=>{const a=i.split(qn);return a[0]===""&&a.length!==1&&a.shift(),Dr(a,t)||cv(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&o[i]?[...l,...o[i]]:l}}},Dr=(e,t)=>{var i;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Dr(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const s=e.join(qn);return(i=t.validators.find(({validator:a})=>a(s)))==null?void 0:i.classGroupId},bo=/^\[(.+)\]$/,cv=e=>{if(bo.test(e)){const t=bo.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},dv=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return mv(Object.entries(e.classGroups),n).forEach(([s,i])=>{_n(i,o,s,t)}),o},_n=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const s=r===""?t:wo(t,r);s.classGroupId=n;return}if(typeof r=="function"){if(uv(r)){_n(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([s,i])=>{_n(i,wo(t,s),n,o)})})},wo=(e,t)=>{let n=e;return t.split(qn).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},uv=e=>e.isThemeGetter,mv=(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,fv=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)}}},Fr="!",hv=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],s=t.length,i=a=>{const l=[];let u=0,d=0,m;for(let w=0;w<a.length;w++){let E=a[w];if(u===0){if(E===r&&(o||a.slice(w,w+s)===t)){l.push(a.slice(d,w)),d=w+s;continue}if(E==="/"){m=w;continue}}E==="["?u++:E==="]"&&u--}const f=l.length===0?a:a.substring(d),p=f.startsWith(Fr),h=p?f.substring(1):f,g=m&&m>d?m-d:void 0;return{modifiers:l,hasImportantModifier:p,baseClassName:h,maybePostfixModifierPosition:g}};return n?a=>n({className:a,parseClassName:i}):i},pv=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},gv=e=>({cache:fv(e.cacheSize),parseClassName:hv(e),...lv(e)}),yv=/\s+/,xv=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,s=[],i=e.trim().split(yv);let a="";for(let l=i.length-1;l>=0;l-=1){const u=i[l],{modifiers:d,hasImportantModifier:m,baseClassName:f,maybePostfixModifierPosition:p}=n(u);let h=!!p,g=o(h?f.substring(0,p):f);if(!g){if(!h){a=u+(a.length>0?" "+a:a);continue}if(g=o(f),!g){a=u+(a.length>0?" "+a:a);continue}h=!1}const w=pv(d).join(":"),E=m?w+Fr:w,k=E+g;if(s.includes(k))continue;s.push(k);const b=r(g,h);for(let $=0;$<b.length;++$){const A=b[$];s.push(E+A)}a=u+(a.length>0?" "+a:a)}return a};function bv(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Hr(t))&&(o&&(o+=" "),o+=n);return o}const Hr=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Hr(e[o]))&&(n&&(n+=" "),n+=t);return n};function wv(e,...t){let n,o,r,s=i;function i(l){const u=t.reduce((d,m)=>m(d),e());return n=gv(u),o=n.cache.get,r=n.cache.set,s=a,a(l)}function a(l){const u=o(l);if(u)return u;const d=xv(l,n);return r(l,d),d}return function(){return s(bv.apply(null,arguments))}}const le=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Wr=/^\[(?:([a-z-]+):)?(.+)\]$/i,vv=/^\d+\/\d+$/,kv=new Set(["px","full","screen"]),_v=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,$v=/\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$/,Sv=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jv=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ev=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Oe=e=>rt(e)||kv.has(e)||vv.test(e),Fe=e=>lt(e,"length",Ov),rt=e=>!!e&&!Number.isNaN(Number(e)),an=e=>lt(e,"number",rt),pt=e=>!!e&&Number.isInteger(Number(e)),Nv=e=>e.endsWith("%")&&rt(e.slice(0,-1)),U=e=>Wr.test(e),He=e=>_v.test(e),Mv=new Set(["length","size","percentage"]),Tv=e=>lt(e,Mv,qr),Av=e=>lt(e,"position",qr),Cv=new Set(["image","url"]),Iv=e=>lt(e,Cv,Lv),Pv=e=>lt(e,"",Bv),gt=()=>!0,lt=(e,t,n)=>{const o=Wr.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},Ov=e=>$v.test(e)&&!Sv.test(e),qr=()=>!1,Bv=e=>jv.test(e),Lv=e=>Ev.test(e),zv=()=>{const e=le("colors"),t=le("spacing"),n=le("blur"),o=le("brightness"),r=le("borderColor"),s=le("borderRadius"),i=le("borderSpacing"),a=le("borderWidth"),l=le("contrast"),u=le("grayscale"),d=le("hueRotate"),m=le("invert"),f=le("gap"),p=le("gradientColorStops"),h=le("gradientColorStopPositions"),g=le("inset"),w=le("margin"),E=le("opacity"),k=le("padding"),b=le("saturate"),$=le("scale"),A=le("sepia"),B=le("skew"),W=le("space"),K=le("translate"),oe=()=>["auto","contain","none"],ie=()=>["auto","hidden","clip","visible","scroll"],R=()=>["auto",U,t],F=()=>[U,t],Z=()=>["",Oe,Fe],ae=()=>["auto",rt,U],ce=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Q=()=>["solid","dashed","dotted","double","none"],he=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],pe=()=>["start","end","center","between","around","evenly","stretch"],ge=()=>["","0",U],Ie=()=>["auto","avoid","all","avoid-page","page","left","right","column"],$e=()=>[rt,U];return{cacheSize:500,separator:":",theme:{colors:[gt],spacing:[Oe,Fe],blur:["none","",He,U],brightness:$e(),borderColor:[e],borderRadius:["none","","full",He,U],borderSpacing:F(),borderWidth:Z(),contrast:$e(),grayscale:ge(),hueRotate:$e(),invert:ge(),gap:F(),gradientColorStops:[e],gradientColorStopPositions:[Nv,Fe],inset:R(),margin:R(),opacity:$e(),padding:F(),saturate:$e(),scale:$e(),sepia:ge(),skew:$e(),space:F(),translate:F()},classGroups:{aspect:[{aspect:["auto","square","video",U]}],container:["container"],columns:[{columns:[He]}],"break-after":[{"break-after":Ie()}],"break-before":[{"break-before":Ie()}],"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:[...ce(),U]}],overflow:[{overflow:ie()}],"overflow-x":[{"overflow-x":ie()}],"overflow-y":[{"overflow-y":ie()}],overscroll:[{overscroll:oe()}],"overscroll-x":[{"overscroll-x":oe()}],"overscroll-y":[{"overscroll-y":oe()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",pt,U]}],basis:[{basis:R()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",U]}],grow:[{grow:ge()}],shrink:[{shrink:ge()}],order:[{order:["first","last","none",pt,U]}],"grid-cols":[{"grid-cols":[gt]}],"col-start-end":[{col:["auto",{span:["full",pt,U]},U]}],"col-start":[{"col-start":ae()}],"col-end":[{"col-end":ae()}],"grid-rows":[{"grid-rows":[gt]}],"row-start-end":[{row:["auto",{span:[pt,U]},U]}],"row-start":[{"row-start":ae()}],"row-end":[{"row-end":ae()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",U]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",U]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...pe()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...pe(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...pe(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[k]}],px:[{px:[k]}],py:[{py:[k]}],ps:[{ps:[k]}],pe:[{pe:[k]}],pt:[{pt:[k]}],pr:[{pr:[k]}],pb:[{pb:[k]}],pl:[{pl:[k]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[W]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[W]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",U,t]}],"min-w":[{"min-w":[U,t,"min","max","fit"]}],"max-w":[{"max-w":[U,t,"none","full","min","max","fit","prose",{screen:[He]},He]}],h:[{h:[U,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[U,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[U,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[U,t,"auto","min","max","fit"]}],"font-size":[{text:["base",He,Fe]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",an]}],"font-family":[{font:[gt]}],"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",U]}],"line-clamp":[{"line-clamp":["none",rt,an]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Oe,U]}],"list-image":[{"list-image":["none",U]}],"list-style-type":[{list:["none","disc","decimal",U]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[E]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[E]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Oe,Fe]}],"underline-offset":[{"underline-offset":["auto",Oe,U]}],"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:F()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",U]}],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",U]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[E]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),Av]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Tv]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},Iv]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[h]}],"gradient-via-pos":[{via:[h]}],"gradient-to-pos":[{to:[h]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],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":[E]}],"border-style":[{border:[...Q(),"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":[E]}],"divide-style":[{divide:Q()}],"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:["",...Q()]}],"outline-offset":[{"outline-offset":[Oe,U]}],"outline-w":[{outline:[Oe,Fe]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[E]}],"ring-offset-w":[{"ring-offset":[Oe,Fe]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",He,Pv]}],"shadow-color":[{shadow:[gt]}],opacity:[{opacity:[E]}],"mix-blend":[{"mix-blend":[...he(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":he()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",He,U]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[d]}],invert:[{invert:[m]}],saturate:[{saturate:[b]}],sepia:[{sepia:[A]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[d]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[E]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[A]}],"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",U]}],duration:[{duration:$e()}],ease:[{ease:["linear","in","out","in-out",U]}],delay:[{delay:$e()}],animate:[{animate:["none","spin","ping","pulse","bounce",U]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[$]}],"scale-x":[{"scale-x":[$]}],"scale-y":[{"scale-y":[$]}],rotate:[{rotate:[pt,U]}],"translate-x":[{"translate-x":[K]}],"translate-y":[{"translate-y":[K]}],"skew-x":[{"skew-x":[B]}],"skew-y":[{"skew-y":[B]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",U]}],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",U]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":F()}],"scroll-mx":[{"scroll-mx":F()}],"scroll-my":[{"scroll-my":F()}],"scroll-ms":[{"scroll-ms":F()}],"scroll-me":[{"scroll-me":F()}],"scroll-mt":[{"scroll-mt":F()}],"scroll-mr":[{"scroll-mr":F()}],"scroll-mb":[{"scroll-mb":F()}],"scroll-ml":[{"scroll-ml":F()}],"scroll-p":[{"scroll-p":F()}],"scroll-px":[{"scroll-px":F()}],"scroll-py":[{"scroll-py":F()}],"scroll-ps":[{"scroll-ps":F()}],"scroll-pe":[{"scroll-pe":F()}],"scroll-pt":[{"scroll-pt":F()}],"scroll-pr":[{"scroll-pr":F()}],"scroll-pb":[{"scroll-pb":F()}],"scroll-pl":[{"scroll-pl":F()}],"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",U]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[Oe,Fe,an]}],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"]}}},Rv=wv(zv);function _e(...e){return Rv(Rr(e))}const Gr=O.createContext(null);function Dv(){const e=O.useContext(Gr);if(!e)throw new Error("useContextMenu must be used inside <ContextMenuHost>");return e}const At=8;function Fv({children:e}){const[t,n]=O.useState({open:!1,x:0,y:0,items:[]}),[o,r]=O.useState(null),s=O.useRef(null),i=O.useCallback(()=>{n(u=>u.open?{...u,open:!1}:u)},[]),a=O.useCallback((u,d,m)=>{r(null),n({open:!0,x:u,y:d,items:m})},[]),l=O.useMemo(()=>({open:a,close:i}),[a,i]);return O.useLayoutEffect(()=>{if(!t.open||!s.current)return;const u=s.current.getBoundingClientRect();let d=t.x,m=t.y;d+u.width>window.innerWidth-At&&(d=Math.max(At,t.x-u.width)),m+u.height>window.innerHeight-At&&(m=Math.max(At,t.y-u.height)),r({left:d,top:m})},[t]),O.useEffect(()=>{if(!t.open)return;const u=p=>{s.current&&!s.current.contains(p.target)&&i()},d=p=>{p.key==="Escape"&&(p.preventDefault(),i())},m=()=>i(),f=()=>i();return document.addEventListener("pointerdown",u,!0),document.addEventListener("keydown",d,!0),window.addEventListener("wheel",m,{passive:!0}),window.addEventListener("blur",f),()=>{document.removeEventListener("pointerdown",u,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("wheel",m),window.removeEventListener("blur",f)}},[t.open,i]),c.jsxs(Gr.Provider,{value:l,children:[e,t.open&&c.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:u=>u.preventDefault(),children:t.items.map((u,d)=>{if(u.type==="separator")return c.jsx("div",{role:"separator",className:"my-1 h-px bg-border"},`sep-${d}`);const m=u.icon;return c.jsxs("button",{type:"button",role:"menuitem",disabled:u.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",u.destructive&&"text-destructive hover:bg-destructive/10 hover:text-destructive",u.disabled&&"pointer-events-none text-muted-foreground opacity-60"),onClick:()=>{i(),u.onSelect()},children:[c.jsxs("span",{className:"flex items-center gap-2",children:[m?c.jsx(m,{className:"size-4"}):null,c.jsx("span",{children:u.label})]}),u.shortcut?c.jsx("span",{className:"text-xs text-muted-foreground",children:u.shortcut}):null]},`${u.label}-${d}`)})})]})}const vo=e=>{let t;const n=new Set,o=(u,d)=>{const m=typeof u=="function"?u(t):u;if(!Object.is(m,t)){const f=t;t=d??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(p=>p(t,f))}},r=()=>t,a={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u))},l=t=e(o,r,a);return a},Hv=(e=>e?vo(e):vo),Wv=e=>e;function qv(e,t=Wv){const n=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>t(e.getState()),[e,t]),O.useCallback(()=>t(e.getInitialState()),[e,t]));return O.useDebugValue(n),n}const ko=e=>{const t=Hv(e),n=o=>qv(t,o);return Object.assign(n,t),n},Xt=(e=>e?ko(e):ko),_o={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.nodeNotFound":"电气节点 {id} 不存在","props.wireNotFound":"连线 {id} 不存在","props.nodeStats":"{terminals} 个端子 · {elements} 个元件","props.selectElement":"选中 {label}","props.selectWholeNode":"选中整个电气节点","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":"点击画布放置一段文字注释;双击文字可重新编辑","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.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.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":"选择 母线 工具(B),在画布上按下拖动","onboard.step2.title":"从母线拖出元件","onboard.step2.body":"切到 元件(P)选一种,按住母线拖到目标位置 — 自动连接","onboard.step3.title":"继续串接","onboard.step3.body":"从任意端子拖出,落到目标即与该端子相连","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.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","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","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.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.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":"Draw a busbar","onboard.step1.body":"Pick the busbar tool (B), then press and drag on the canvas","onboard.step2.title":"Drag elements from the bus","onboard.step2.body":"Switch to Place (P), pick a kind, then drag from the bus — it auto-connects","onboard.step3.title":"Chain the next one","onboard.step3.body":"Drag from any terminal — the new element drops pre-connected","onboard.dismiss":"Got it"}},Xr="ole-locale";function Gv(){if(typeof window>"u")return"zh";try{const e=window.localStorage.getItem(Xr);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 $o(e){try{window.localStorage.setItem(Xr,e)}catch{}}const Nt=Xt((e,t)=>({locale:Gv(),setLocale:n=>{$o(n),e({locale:n})},toggle:()=>{const n=t().locale==="zh"?"en":"zh";$o(n),e({locale:n})}}));function Kr(e,t){return t?e.replace(/\{(\w+)\}/g,(n,o)=>t[o]!==void 0?String(t[o]):`{${o}}`):e}function Yr(e,t){return _o[e][t]??_o.zh[t]??t}function we(e,t){return Kr(Yr(Nt.getState().locale,e),t)}function ne(){const e=Nt(t=>t.locale);return(t,n)=>Kr(Yr(e,t),n)}function Vr(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 $n=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return $n(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return $n(o)(n)}}}},Xv=(e,t)=>(n,o,r)=>{let s={storage:Vr(()=>window.localStorage),partialize:w=>w,version:0,merge:(w,E)=>({...E,...w}),...t},i=!1,a=0;const l=new Set,u=new Set;let d=s.storage;if(!d)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${s.name}', the given storage is currently unavailable.`),n(...w)},o,r);const m=()=>{const w=s.partialize({...o()});return d.setItem(s.name,{state:w,version:s.version})},f=r.setState;r.setState=(w,E)=>(f(w,E),m());const p=e((...w)=>(n(...w),m()),o,r);r.getInitialState=()=>p;let h;const g=()=>{var w,E;if(!d)return;const k=++a;i=!1,l.forEach($=>{var A;return $((A=o())!=null?A:p)});const b=((E=s.onRehydrateStorage)==null?void 0:E.call(s,(w=o())!=null?w:p))||void 0;return $n(d.getItem.bind(d))(s.name).then($=>{if($)if(typeof $.version=="number"&&$.version!==s.version){if(s.migrate){const A=s.migrate($.state,$.version);return A instanceof Promise?A.then(B=>[!0,B]):[!0,A]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,$.state];return[!1,void 0]}).then($=>{var A;if(k!==a)return;const[B,W]=$;if(h=s.merge(W,(A=o())!=null?A:p),n(h,!0),B)return m()}).then(()=>{k===a&&(b==null||b(o(),void 0),h=o(),i=!0,u.forEach($=>$(h)))}).catch($=>{k===a&&(b==null||b(void 0,$))})};return r.persist={setOptions:w=>{s={...s,...w},w.storage&&(d=w.storage)},clearStorage:()=>{d==null||d.removeItem(s.name)},getOptions:()=>s,rehydrate:()=>g(),hasHydrated:()=>i,onHydrate:w=>(l.add(w),()=>{l.delete(w)}),onFinishHydration:w=>(u.add(w),()=>{u.delete(w)})},s.skipHydration||g(),h||p},Kv=Xv,Be=.5;function Ur(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])<Be&&Math.abs(s[1]-e[r][1])<Be||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>Be&&l>Be){const d=(n.length>=2?Math.abs(n[n.length-2][1]-s[1])<Be?"h":"v":null)==="h"?[i[0],s[1]]:[s[0],i[1]];n.push(d)}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])<Be&&Math.abs(i[0]-a[0])<Be,u=Math.abs(s[1]-i[1])<Be&&Math.abs(i[1]-a[1])<Be;l||u||o.push(i)}return o.push(n[n.length-1]),o}function Jr(){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 Zr(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 Sn(e){return e===90||e===270?"y":"x"}function Ae(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 Yv={n:"e",e:"s",s:"w",w:"n"},Vv={n:"n",s:"s",e:"w",w:"e"};function _t(e,t){let n=t.mirror?Vv[e]:e;const o=t.rot/90|0;for(let r=0;r<o;r++)n=Yv[n];return n}function jn(e){switch(e){case"n":return[0,-1];case"s":return[0,1];case"e":return[1,0];case"w":return[-1,0]}}class Qr{constructor(){ht(this,"parent",new Map);ht(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 So=["n","e","s","w"],jo={n:"s",s:"n",e:"w",w:"e"};function Eo(e,t){const n=So.indexOf(e),r=((So.indexOf(t)-n)%4+4)%4;return[0,90,180,270][r]}const No=320,ln=220,yt=260,cn=720,xt=30,Mo=30,We=80,To=10,Uv=60,Jv=520,Zv=80,Qv=80,Ao=8,Co=new Set(["source","renewable"]);function e2(e){var uo,mo,fo,ho,po,go;const{elements:t,buses:n,wires:o,library:r,userLayout:s,userBusLayout:i}=e,a=new Map(s),l=new Map(i),u=new Set(s.keys()),d=new Set(i.keys()),m=new Map;for(const y of t)m.set(y.id,y);const f=new Map;for(const y of n)f.set(y.id,y);const p=y=>{const v=m.get(y);if(v)return r.get(v.kind)},h=new Set(n.map(y=>y.id)),g=y=>h.has(y),w=new Qr;for(const y of o)w.add(y.ends[0]),w.add(y.ends[1]),w.union(y.ends[0],y.ends[1]);for(const y of t){const v=r.get(y.kind);if(v)for(const S of v.terminals)w.add(`${y.id}.${S.id}`)}for(const y of n)w.add(y.id);const E=[];for(const[,y]of w.groups())y.length>=2&&E.push(y);const k=new Map;for(const y of E)for(const v of y)k.set(v,[y]);const b=new Map;for(const y of E){const v=y.filter(g);if(v.length!==0)for(const S of v){const j=y.filter(_=>_!==S),N=b.get(S)??[];N.push(...j),b.set(S,N)}}const $=new Map;for(const y of E){const v=y.filter(g);if(v.length!==0)for(const S of y){if(g(S))continue;const j=S.indexOf(".");if(j<0)continue;const N=S.slice(0,j),_=S.slice(j+1),M=$.get(N)??[];for(const L of v)M.some(C=>C.busId===L&&C.pin===_)||M.push({busId:L,pin:_});$.set(N,M)}}const A=[],B=new Set;for(const[y,v]of $)if(new Set(v.map(j=>j.busId)).size>=2){const j=((mo=r.get(((uo=m.get(y))==null?void 0:uo.kind)??""))==null?void 0:mo.category)==="transformer"?"vertical":"horizontal";A.push({elementId:y,attachments:v,orientation:j}),j==="vertical"&&B.add(y)}const W=new Map,K=(y,v)=>{y!==v&&(W.has(y)||W.set(y,new Set),W.has(v)||W.set(v,new Set),W.get(y).add(v),W.get(v).add(y))};for(const y of o)K(y.ends[0],y.ends[1]);for(const y of t){const v=r.get(y.kind);if(!v||v.terminals.length<2)continue;const S=v.terminals.map(j=>`${y.id}.${j.id}`);for(let j=0;j<S.length;j++)for(let N=j+1;N<S.length;N++)K(S[j],S[N])}for(const y of t){if(B.has(y.id))continue;const v=r.get(y.kind);if(!v||v.category!=="transformer"||v.terminals.length<2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),j=new Map;for(const _ of S){const M=_.slice(y.id.length+1);j.set(M,new Set);const L=new Set(S.filter(P=>P!==_)),C=new Set([_]),I=[_];for(;I.length>0;){const P=I.shift();if(g(P)){j.get(M).add(P);continue}const T=W.get(P);if(T)for(const z of T)C.has(z)||L.has(z)||(C.add(z),I.push(z))}}const N=new Set;for(const _ of j.values())for(const M of _)N.add(M);if(N.size>=2){const _=[];for(const[M,L]of j)for(const C of L)_.push({busId:C,pin:M});A.push({elementId:y.id,attachments:_,orientation:"vertical"}),B.add(y.id)}}const oe=(y,v)=>{var L;const S=p(v),j=S?S.terminals.map(C=>`${v}.${C.id}`):[],N=y,_=new Set([N,...j]),M=[N];for(;M.length>0;){const C=M.shift(),I=C.indexOf(".");if(I>0){const T=C.slice(0,I),z=m.get(T);if(z){const D=(L=r.get(z.kind))==null?void 0:L.category;if(D&&Co.has(D))return!0}}const P=W.get(C);if(P)for(const T of P)_.has(T)||(_.add(T),M.push(T))}return!1};for(const y of A){if(y.orientation!=="horizontal")continue;const v=new Set(y.attachments.map(j=>j.busId));let S=0;for(const j of v)oe(j,y.elementId)&&S++;S===1&&(y.orientation="vertical",B.add(y.elementId))}for(const y of t){if(B.has(y.id)||y.kind!=="breaker")continue;const v=r.get(y.kind);if(!v||v.terminals.length!==2)continue;const S=v.terminals.map(_=>`${y.id}.${_.id}`),j=new Map;for(const _ of S){const M=_.slice(y.id.length+1),L=new Set(S.filter(P=>P!==_)),C=new Set([_]),I=[_];for(;I.length>0;){const P=I.shift();if(g(P)){j.set(M,P);break}const T=W.get(P);if(T)for(const z of T){if(C.has(z)||L.has(z))continue;const D=z.indexOf(".");if(D>0){const H=z.slice(0,D);if(H!==y.id){const G=m.get(H),Y=G?r.get(G.kind):void 0;if((Y==null?void 0:Y.category)==="transformer")continue}}C.add(z),I.push(z)}}}if(new Set(j.values()).size>=2){const _=[];for(const[M,L]of j)_.push({busId:L,pin:M});A.push({elementId:y.id,attachments:_,orientation:"horizontal"})}}const ie=new Map;for(const y of n)ie.set(y.id,new Map);for(const y of A){const v=Array.from(new Set(y.attachments.map(S=>S.busId)));for(const S of v)for(const j of v)S!==j&&((fo=ie.get(S))==null||fo.set(j,y))}const R=y=>{var S;const v=(S=r.get(y))==null?void 0:S.category;return v?Co.has(v):!1},F=[];for(const y of n){const v=b.get(y.id);if(v)for(const S of v){if(g(S))continue;const j=S.indexOf(".");if(j<0)continue;const N=S.slice(0,j),_=m.get(N);if(_&&R(_.kind)){F.push(y.id);break}}}F.length===0&&n.length>0&&F.push(n[0].id);const Z=new Map;for(const y of F)Z.set(y,0);{const y=[...F];for(;y.length>0;){const v=y.shift(),S=Z.get(v),j=ie.get(v);if(j)for(const[N,_]of j){if(Z.has(N))continue;const M=_.orientation==="horizontal"?S:S+1;Z.set(N,M),y.push(N)}}}for(const y of n){if(Z.has(y.id))continue;const v=Z.size===0?-1:Math.max(...Array.from(Z.values()));Z.set(y.id,v+1)}const ae=new Map;for(const y of n){const v=Z.get(y.id),S=ae.get(v)??[];S.push(y.id),ae.set(v,S)}const ce=[...ae.keys()].sort((y,v)=>y-v),Q=(y,v,S)=>{const j=`${y.elementId}.${S}`,N=v,_=p(y.elementId),M=new Set;if(_)for(const T of _.terminals)T.id!==S&&M.add(`${y.elementId}.${T.id}`);const L=new Set([j]),C=[{ref:j,dist:0}],I=new Map,P=(T,z,D,H)=>{L.add(T),I.set(T,z),C.push({ref:T,dist:H+D})};for(;C.length>0;){const{ref:T,dist:z}=C.shift();if(T===N){const Y=I.get(N);let de;if(Y){const J=Y.indexOf(".");if(J>0){const q=Y.slice(0,J);q!==y.elementId&&(de=q)}}return{extent:z,head:de}}const D=T.indexOf(".");if(D<0)continue;const H=T.slice(0,D),G=T.slice(D+1);if(!g(H)&&!B.has(H)){const Y=p(H),de=Y==null?void 0:Y.terminals.find(J=>J.id===G);if(Y&&de)for(const J of Y.terminals){if(J.id===G)continue;const q=`${H}.${J.id}`;L.has(q)||M.has(q)||P(q,T,Math.abs(de.y-J.y),z)}}for(const Y of k.get(T)??[])for(const de of Y){if(de===T||L.has(de)||M.has(de))continue;const J=g(T)||g(de);P(de,T,J?Mo:xt,z)}}return{extent:0}},he=(y,v)=>{var T,z,D;const S=(T=ie.get(y))==null?void 0:T.get(v);if(!S||S.orientation==="horizontal")return yt;const j=p(S.elementId);if(!j)return yt;const N=(z=S.attachments.find(H=>H.busId===y))==null?void 0:z.pin,_=(D=S.attachments.find(H=>H.busId===v))==null?void 0:D.pin;if(!N||!_)return yt;const M=j.terminals.find(H=>H.id===N),L=j.terminals.find(H=>H.id===_);if(!M||!L)return yt;const C=Math.abs(L.y-M.y),I=Q(S,y,N).extent,P=Q(S,v,_).extent;return I+C+P},pe=new Map;for(const y of A){if(y.orientation!=="vertical")continue;const v=y.attachments.slice().sort((L,C)=>(Z.get(L.busId)??0)-(Z.get(C.busId)??0));if(v.length<2)continue;const S=v[0].busId,j=v[1].busId,N=v[0].pin,M=Q(y,S,N).head??y.elementId;pe.set(M,{lowerBusId:j})}const ge=30,Ie=y=>{const v=p(y);return Math.max((v==null?void 0:v.width)??We,We)},$e=2,Qn=(y,v,S,j=0)=>{const N=p(v);let _=Ie(v);if(N&&!S.has(v)&&j<$e){S.add(v);let M=0;for(const L of N.terminals){const C=`${v}.${L.id}`;if(C!==y)for(const I of k.get(C)??[]){const P=new Set;let T=!1;for(const D of I){if(D===C)continue;if(g(D)){T=!0;continue}const H=D.indexOf(".");if(H<0)continue;const G=D.slice(0,H);G===v||S.has(G)||B.has(G)||P.add(G)}if(T||P.size===0)continue;let z=0;for(const D of P){const H=[...I].find(G=>G.indexOf(".")>0&&G.slice(0,G.indexOf("."))===D);z+=(H?Qn(H,D,S,j+1):Ie(D))+ge}M=Math.max(M,z-ge)}}S.delete(v),_=Math.max(_,M)}return _},ut=320,Qe=new Map,eo=(y,v)=>{if(!B.has(y))return!1;const S=A.find(M=>M.elementId===y),j=S==null?void 0:S.attachments.find(M=>M.busId!==v);if(!j)return!1;const N=Z.get(v)??0;return(Z.get(j.busId)??0)<N},mt=(y,v,S)=>{const j=pe.get(y);if(j){const _=Qe.get(j.lowerBusId);if(_!==void 0)return Math.max(v,_+We)}let N=0;return S&&(N=Qn(S,y,new Set)),Math.max(v,We,N)},to=(y,v)=>{if(Qe.has(y))return Qe.get(y);if(v.has(y))return ut;v.add(y);const S=b.get(y)??[];let j=0,N=0;for(const M of S){if(g(M))continue;const L=M.indexOf(".");if(L<0)continue;const C=M.slice(0,L),I=M.slice(L+1);if(eo(C,y))continue;const P=p(C);if(!P)continue;const T=P.terminals.find(H=>H.id===I);if(!T)continue;const z=pe.get(C);z&&to(z.lowerBusId,v);const D=mt(C,P.width,`${C}.${I}`);T.y>0?j+=D:N+=D}const _=Math.max(ut,Math.max(j,N)+We);return Qe.set(y,_),v.delete(y),_};for(const y of n)to(y.id,new Set);const De=new Map,Aw=(y,v,S)=>{const j=p(v);if(!j)return;const N=`${v}.${S}`,_=j.terminals.filter(C=>C.id!==S).map(C=>`${v}.${C.id}`);if(_.length===0)return;const M=new Set([N,..._]),L=_.slice();for(;L.length>0;){const C=L.shift();if(g(C)&&C!==y){const P=l.get(C);return P?P.at[0]:void 0}for(const P of k.get(C)??[])for(const T of P)T===C||M.has(T)||(M.add(T),L.push(T));const I=C.indexOf(".");if(I>0){const P=C.slice(0,I);if(!g(P)){const T=p(P);if(T)for(const z of T.terminals){const D=`${P}.${z.id}`;M.has(D)||(M.add(D),L.push(D))}}}}},Cw=y=>{const v=b.get(y);if(!v||v.length===0)return;const S=l.get(y);if(!S)return;const j=v.flatMap(T=>{if(g(T))return[];const z=T.indexOf(".");if(z<0)return[];const D=T.slice(0,z),H=T.slice(z+1);if(a.has(D))return[];if(eo(D,y))return[];const G=p(D);if(!G)return[];const Y=G.terminals.find(de=>de.id===H);return Y?[{elId:D,lib:G,localTerm:Y,isLinker:B.has(D),busFacingRef:`${D}.${H}`}]:[]});if(j.length===0)return;const N=[],_=[];for(const T of j)T.localTerm.y>0?N.push(T):_.push(T);const M=T=>T.reduce((z,D)=>z+mt(D.elId,D.lib.width,D.busFacingRef),0),L=Math.max(M(N),M(_))+We,C=Math.max(S.span,L);C!==S.span&&!d.has(y)&&l.set(y,{...S,span:C});const I=l.get(y),P=(T,z)=>{if(T.length===0)return;const D=new Map;for(const X of T){const V=Aw(y,X.elId,X.localTerm.id);V!==void 0&&D.set(X.elId,V)}T.sort((X,V)=>{const ue=D.get(X.elId)??I.at[0],ye=D.get(V.elId)??I.at[0];if(ue!==ye)return ue-ye;const xe=mt(X.elId,X.lib.width,X.busFacingRef);return mt(V.elId,V.lib.width,V.busFacingRef)-xe});const H=T.map(X=>mt(X.elId,X.lib.width,X.busFacingRef)),G=H.reduce((X,V)=>X+V,0),Y=Math.max(C,G),de=(Y-G)/(T.length+1);let J=I.at[0]-Y/2+de;const q=I.at[1]+z*Mo;for(let X=0;X<T.length;X++){const V=T[X],ue=H[X],ye=J+ue/2;V.isLinker?De.has(V.elId)||De.set(V.elId,ye):a.set(V.elId,{at:[fe(ye-V.localTerm.x),fe(q-V.localTerm.y)],rot:0,mirror:!1}),J+=ue+de}};P(N,-1),P(_,1)},Iw=y=>{if(a.has(y.elementId)||y.orientation==="horizontal")return;const v=p(y.elementId);if(!v)return;const S=y.attachments.filter(J=>l.has(J.busId));if(S.length<2)return;const j=S.slice().sort((J,q)=>(Z.get(J.busId)??0)-(Z.get(q.busId)??0)),N=j[0].busId,_=l.get(N),M=j[0].pin,L=j[j.length-1].pin,C=v.terminals.find(J=>J.id===M),I=v.terminals.find(J=>J.id===L);if(!C||!I)return;const P=C.y<=I.y?0:180,T=Z.get(N)??0,z=S.filter(J=>(Z.get(J.busId)??0)===T),D=[];let H=0;for(const J of z){const q=Q(y,J.busId,J.pin);H=Math.max(H,q.extent);const X=q.head?a.get(q.head):void 0;X?D.push(X.at[0]):De.has(y.elementId)?D.push(De.get(y.elementId)):D.push(l.get(J.busId).at[0])}let G;D.length>0?G=D.reduce((J,q)=>J+q,0)/D.length:De.has(y.elementId)?G=De.get(y.elementId):G=_.at[0];const Y=_.at[1]+H,de=P===0?[fe(G-C.x),fe(Y-C.y)]:[fe(G+C.x),fe(Y+C.y)];if(a.set(y.elementId,{at:de,rot:P,mirror:!1}),z.length>1){const J=a.get(y.elementId),q=Ae([C.x,C.y],J),X=_t(C.orientation,J);Pw(`${y.elementId}.${M}`,q,X,G)}},Pw=(y,v,S,j)=>{const N=new Set([y]);let _=y,M=v,L=S;for(;;){const C=k.get(_)??[];let I,P=!1;for(const be of C){if(be.length>=3){P=!0;break}const Ye=be.find(sn=>sn!==_);if(!(!Ye||N.has(Ye))){if(g(Ye)){P=!0;break}I=Ye;break}}if(P||!I)break;const T=I.indexOf(".");if(T<0)break;const z=I.slice(0,T),D=I.slice(T+1);if(g(z)||B.has(z)||a.has(z))break;const H=p(z);if(!H)break;const G=H.terminals.find(be=>be.id===D);if(!G)break;const Y=jn(L),de=[M[0]+Y[0]*xt,M[1]+Y[1]*xt],J=jo[L],q=Eo(G.orientation,J),X=Ae([G.x,G.y],{at:[0,0],rot:q,mirror:!1}),V=[fe(j-X[0]),fe(de[1]-X[1])];a.set(z,{at:V,rot:q,mirror:!1}),N.add(I);const ue=H.terminals.find(be=>be.id!==D);if(!ue)break;const ye=`${z}.${ue.id}`;N.add(ye);const xe={at:V,rot:q,mirror:!1};M=Ae([ue.x,ue.y],xe),L=_t(ue.orientation,xe),_=ye}},Ow=y=>{if(a.has(y.elementId)||y.orientation!=="horizontal")return;const v=p(y.elementId);if(!v)return;const S=y.attachments.filter(z=>l.has(z.busId));if(S.length<2)return;const j=S.map(z=>{const D=Q(y,z.busId,z.pin),H=D.head?a.get(D.head):void 0,G=H?H.at[0]:l.get(z.busId).at[0];return{att:z,x:G,extent:D.extent}});j.sort((z,D)=>z.x-D.x);const N=j[0],_=j[j.length-1],M=v.terminals.find(z=>z.id===N.att.pin),L=v.terminals.find(z=>z.id===_.att.pin);if(!M||!L)return;const C=M.y<=L.y?270:90,I=(N.x+_.x)/2,T=l.get(N.att.busId).at[1]+Math.max(N.extent,_.extent);a.set(y.elementId,{at:[fe(I),fe(T)],rot:C,mirror:!1})},no=100;let Tt=ln;for(let y=0;y<ce.length;y++){const v=ce[y],S=ae.get(v);let j;if(y===0)j=ln;else{const _=ae.get(ce[y-1]);let M=0;for(const L of _)for(const C of S)(ho=ie.get(L))!=null&&ho.get(C)&&(M=Math.max(M,he(L,C)));M===0&&(M=yt),j=Tt+M}Tt=j;let N=No;for(const _ of S){if(l.has(_)){Tt=Math.max(Tt,l.get(_).at[1]);continue}let M;if(y>0){const C=ae.get(ce[y-1]),I=[];for(const P of C){const T=(po=ie.get(P))==null?void 0:po.get(_);if(!T||T.orientation!=="vertical")continue;const z=(go=T.attachments.find(H=>H.busId===P))==null?void 0:go.pin;if(!z)continue;const D=Q(T,P,z);D.head&&a.has(D.head)?I.push(a.get(D.head).at[0]):De.has(T.elementId)?I.push(De.get(T.elementId)):I.push(l.get(P).at[0])}I.length>0&&(M=I.reduce((P,T)=>P+T,0)/I.length)}if(M===void 0){const C=Qe.get(_)??cn;M=N+C/2,N+=C+no}const L=Qe.get(_)??cn;l.set(_,{at:[fe(M),fe(j)],rot:0,span:L,axis:Sn(0)})}for(const _ of S)Cw(_);if(y>0)for(const _ of A)a.has(_.elementId)||!_.attachments.some(L=>S.includes(L.busId))||Iw(_);for(const _ of A)_.orientation!=="horizontal"||a.has(_.elementId)||!_.attachments.every(L=>S.includes(L.busId))||Ow(_)}if(n.length===0&&a.size<t.length){const y=N=>{const _=new Set,M=p(N);if(!M)return _;for(const L of M.terminals){const C=`${N}.${L.id}`;for(const I of k.get(C)??[])for(const P of I){if(P===C||g(P))continue;const T=P.indexOf(".");if(T<0)continue;const z=P.slice(0,T);z!==N&&_.add(z)}}return _},v=new Set,S=[];for(const N of t){if(v.has(N.id)||!p(N.id))continue;const _=[],M=[N.id];for(v.add(N.id);M.length>0;){const L=M.pop();_.push(L);for(const C of y(L))v.has(C)||(v.add(C),M.push(C))}_.length>=2&&S.push(_)}let j=No;for(const N of S){if(N.some(I=>a.has(I)))continue;N.sort((I,P)=>{var G,Y;const T=R(((G=m.get(I))==null?void 0:G.kind)??"")?0:1,z=R(((Y=m.get(P))==null?void 0:Y.kind)??"")?0:1;if(T!==z)return T-z;const D=y(I).size,H=y(P).size;return D!==H?D-H:I.localeCompare(P)});const _=N[0],M=p(_);if(!M)continue;const L=M.terminals.slice().sort((I,P)=>P.y-I.y)[0],C=L?Ae([L.x,L.y],{at:[0,0],rot:0,mirror:!1}):[0,0];a.set(_,{at:[fe(j-C[0]),fe(ln-C[1])],rot:0,mirror:!1}),j+=Math.max(cn,N.length*We)+no}}const Bw=y=>{if(g(y))return l.has(y);const v=y.indexOf(".");return v<0?!1:a.has(y.slice(0,v))};let en=!0,Lw=t.length+4;for(;en&&Lw-- >0;){en=!1;for(const y of E){if(y.length<2)continue;const v=[],S=new Map;for(const q of y){if(g(q))continue;const X=q.indexOf(".");if(X<0)continue;const V=q.slice(0,X),ue=q.slice(X+1);if(a.has(V)){v.push(q);continue}if(B.has(V)||S.has(V))continue;const ye=p(V);if(!ye)continue;const xe=ye.terminals.find(be=>be.id===ue);xe&&S.set(V,{ref:q,elId:V,lib:ye,localTerm:xe})}if(S.size===0||v.length===0)continue;const j=[...S.values()],N=new Map;for(const q of j)for(const X of k.get(q.ref)??[])for(const V of X){if(V===q.ref||g(V)||!Bw(V))continue;const ue=V;N.set(ue,(N.get(ue)??0)+1)}let _;if(N.size>0){let q=-1;for(const[X,V]of N)(V>q||V===q&&(_===void 0||X<_))&&(q=V,_=X)}if(_||(_=[...v].sort()[0]),!_)continue;const M=_.indexOf("."),L=_.slice(0,M),C=_.slice(M+1),I=p(L),P=a.get(L);if(!I||!P)continue;const T=I.terminals.find(q=>q.id===C);if(!T)continue;const z=Ae([T.x,T.y],P),D=_t(T.orientation,P),H=jn(D),G=[-H[1],H[0]];j.sort((q,X)=>q.elId.localeCompare(X.elId));const Y=j.map(q=>Math.max(q.lib.width,We));let J=-Y.reduce((q,X)=>q+X,0)/2;for(let q=0;q<j.length;q++){const X=j[q],V=Y[q],ue=J+V/2;J+=V;const ye=jo[D],xe=Eo(X.localTerm.orientation,ye),be=Ae([X.localTerm.x,X.localTerm.y],{at:[0,0],rot:xe,mirror:!1}),Ye=[z[0]+H[0]*xt+G[0]*ue,z[1]+H[1]*xt+G[1]*ue],sn=[fe(Ye[0]-be[0]),fe(Ye[1]-be[1])];a.set(X.elId,{at:sn,rot:xe,mirror:!1}),en=!0}}}const ft=y=>{const v=a.get(y),S=p(y);if(!v||!S)return null;const j=S.viewBox.split(/\s+/).map(Number);if(j.length<4||j.some(T=>Number.isNaN(T))){const T=S.width/2;return{min:v.at[0]-T,max:v.at[0]+T}}const[N,_,M,L]=j,C=[[N,_],[N+M,_],[N,_+L],[N+M,_+L]];let I=1/0,P=-1/0;for(const T of C){const z=Ae(T,v);I=Math.min(I,z[0]),P=Math.max(P,z[0])}return{min:I,max:P}},tn=y=>{const v=new Set,S=p(y);if(!S)return v;for(const j of S.terminals){const N=`${y}.${j.id}`;for(const _ of k.get(N)??[])for(const M of _){if(M===N||g(M))continue;const L=M.indexOf(".");if(L<0)continue;const C=M.slice(0,L);C!==y&&v.add(C)}}return v},oo=40,nn=y=>{const v=a.get(y),S=p(y);if(!v||!S)return null;const j=S.viewBox.split(/\s+/).map(Number);if(j.length<4||j.some(T=>Number.isNaN(T))){const T=S.height/2;return{min:v.at[1]-T,max:v.at[1]+T}}const[N,_,M,L]=j,C=[[N,_],[N+M,_],[N,_+L],[N+M,_+L]];let I=1/0,P=-1/0;for(const T of C){const z=Ae(T,v);I=Math.min(I,z[1]),P=Math.max(P,z[1])}return{min:I,max:P}},zw=(y,v)=>{const S=new Set,j=[];for(const N of b.get(y)??[]){if(g(N))continue;const _=N.indexOf(".");if(_<0)continue;const M=N.slice(0,_),L=a.get(M);!L||L.at[1]>=v-1||S.has(M)||(S.add(M),j.push(M))}for(;j.length>0;){const N=j.pop();for(const _ of tn(N)){if(S.has(_))continue;const M=a.get(_);!M||M.at[1]>=v-1||(S.add(_),j.push(_))}}return S},ro=(y,v,S)=>{const j=new Set([y]),N=[y];for(;N.length>0;){const _=N.pop();for(const M of tn(_))M===v||j.has(M)||!S.has(M)||(j.add(M),N.push(M))}return j},so=(y,v)=>{let S=y.length*y.length+8,j=!1,N=!0;for(;N&&S-- >0;){N=!1;for(let _=0;_<y.length&&!N;_++)for(let M=_+1;M<y.length;M++){const L=y[_],C=y[M],I=ft(L),P=ft(C),T=nn(L),z=nn(C);if(!I||!P||!T||!z)continue;const D=Math.min(I.max,P.max)-Math.max(I.min,P.min),H=Math.min(T.max,z.max)-Math.max(T.min,z.min);if(D<=0||H<=0)continue;const G=ro(L,C,v),Y=ro(C,L,v);if(G.has(C)||Y.has(L))continue;const de=![...G].some(xe=>u.has(xe)),J=![...Y].some(xe=>u.has(xe));if(!de&&!J)continue;const q=(I.min+I.max)/2,X=(P.min+P.max)/2;let V,ue;de&&(!J||G.size<=Y.size)?(V=G,ue=q<=X?-1:1):(V=Y,ue=X<=q?-1:1);const ye=fe(ue*(D+oo));if(ye!==0){for(const xe of V){const be=a.get(xe);be&&a.set(xe,{...be,at:[be.at[0]+ye,be.at[1]]})}j=!0,N=!0;break}}}return j};for(const y of n){const v=l.get(y.id);if(!v)continue;const S=zw(y.id,v.at[1]);if(S.size<2)continue;const j=[...S];if(so(j,S)){let _=1/0,M=-1/0;for(const L of j){const C=ft(L);C&&(_=Math.min(_,C.min),M=Math.max(M,C.max))}if(Number.isFinite(_)){const C=j.some(P=>u.has(P))?0:fe(v.at[0]-(_+M)/2);if(C!==0)for(const P of j){const T=a.get(P);T&&a.set(P,{...T,at:[T.at[0]+C,T.at[1]]})}const I=M-_+oo;if(I>v.span&&!d.has(y.id)){const P=l.get(y.id);l.set(y.id,{...P,span:I})}}}}const io=()=>{const v=t.map(j=>j.id).filter(j=>a.has(j)).map(j=>({x:ft(j),y:nn(j)})).filter(j=>j.x&&j.y);let S=0;for(let j=0;j<v.length;j++)for(let N=j+1;N<v.length;N++){const _=Math.min(v[j].x.max,v[N].x.max)-Math.max(v[j].x.min,v[N].x.min),M=Math.min(v[j].y.max,v[N].y.max)-Math.max(v[j].y.min,v[N].y.min);_>1&&M>1&&S++}return S},Rw=io(),ao=new Map;for(const[y,v]of a)ao.set(y,{...v,at:[...v.at]});const lo=new Map;for(const[y,v]of l)lo.set(y,{...v,at:[...v.at]});const on=120,co=new Map;{const y=new Map,v=new Map,S=[];for(const N of n)for(const _ of b.get(N.id)??[]){if(g(_))continue;const M=_.indexOf(".");if(M<0)continue;const L=_.slice(0,M);a.has(L)&&S.push({el:L,bus:N.id,d:1})}S.sort((N,_)=>N.d-_.d);let j=0;for(;j<S.length;){const{el:N,bus:_,d:M}=S[j++],L=y.get(N);if(L===void 0)y.set(N,M),v.set(N,_);else if(M===L&&v.get(N)!==_){v.set(N,null);continue}else continue;for(const C of tn(N))a.has(C)&&(y.has(C)||S.push({el:C,bus:_,d:M+1}))}for(const[N,_]of v)_&&co.set(N,_)}for(const y of ce){const v=(ae.get(y)??[]).filter(I=>l.has(I));if(v.length<2||v.some(I=>d.has(I)))continue;const S=[];let j=0;for(const I of v){const P=l.get(I),T=[];let z=1/0,D=-1/0;for(const[H,G]of co){if(G!==I)continue;const Y=ft(H);Y&&(T.push(H),z=Math.min(z,Y.min),D=Math.max(D,Y.max))}Number.isFinite(z)||(z=P.at[0]-ut/2,D=P.at[0]+ut/2),S.push({busId:I,min:z,max:D,members:T}),j+=D-z}if(S.some(I=>I.members.some(P=>u.has(P))))continue;let N=1/0,_=-1/0;for(const I of S)N=Math.min(N,I.min),_=Math.max(_,I.max);const M=_-N,L=j+on*(S.length-1);if(!(M>L+on))continue;S.sort((I,P)=>(I.min+I.max)/2-(P.min+P.max)/2);let C=N;for(const I of S){const P=fe(C-I.min);if(P!==0){const T=l.get(I.busId);l.set(I.busId,{...T,at:[T.at[0]+P,T.at[1]]});for(const z of I.members){const D=a.get(z);D&&a.set(z,{...D,at:[D.at[0]+P,D.at[1]]})}I.min+=P,I.max+=P}C=I.max+on}for(const I of S){const P=l.get(I.busId),T=Math.max(ut,I.max-I.min);T<P.span&&l.set(I.busId,{...P,span:T})}}{const y=t.map(S=>S.id).filter(S=>a.has(S)),v=new Set(y);so(y,v)}if(io()>Rw){a.clear();for(const[y,v]of ao)a.set(y,v);l.clear();for(const[y,v]of lo)l.set(y,v)}let rn=0;for(const y of t){if(a.has(y.id))continue;const v=rn%Ao,S=Math.floor(rn/Ao);a.set(y.id,{at:[fe(Uv+v*Zv),fe(Jv+S*Qv)],rot:0,mirror:!1}),rn++}return{devices:a,buses:l}}function fe(e){return Math.round(e/To)*To}function t2(e,t){const n=e.ends[0],o=e.ends[1],r=Io(n,t),s=Io(o,t);if(r||s){const l=r?n:o,d=dn(r?o:n,t);if(!d)return null;const m=t.buses.get(l);if(!m)return null;const{axis:f,at:p,span:h}=m.geometry,g=h/2;let w;if(f==="x")w=[Dt(d[0],p[0]-g,p[0]+g),p[1]];else{const E=Dt(d[1],p[1]-g,p[1]+g);w=[p[0],E]}return{wireId:e.id,path:Oo(d,w)}}const i=dn(n,t),a=dn(o,t);return!i||!a?null:{wireId:e.id,path:Oo(i,a)}}function Io(e,t){return!e.includes(".")&&t.buses.has(e)}function dn(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 Po(e,t,n){if(!e.includes(".")){const r=n.buses.get(e);if(!r){const d=n.junctions.get(e);return d?[d.world[0],d.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[Dt(t[0],i[0]-l,i[0]+l),i[1]];const u=Dt(t[1],i[1]-l,i[1]+l);return[i[0],u]}const o=n.terminals.get(e);return o?[o.world[0],o.world[1]]:null}function Oo(e,t){return e[0]===t[0]||e[1]===t[1]?[e,t]:[e,[e[0],t[1]],t]}function Dt(e,t,n){return e<t?t:e>n?n:e}const es="ammeter",ts="电流表 (A)",ns="measurement",os="-22 -42 44 44",rs=44,ss=44,is='<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>',as=[{id:"t_top",x:0,y:-40,orientation:"n"}],ls={kind:"inline"},n2={id:es,name:ts,category:ns,viewBox:os,width:rs,height:ss,svg:is,terminals:as,source:ls},o2=Object.freeze(Object.defineProperty({__proto__:null,category:ns,default:n2,height:ss,id:es,name:ts,source:ls,svg:is,terminals:as,viewBox:os,width:rs},Symbol.toStringTag,{value:"Module"})),cs="arc-suppression-coil",ds="消弧线圈",us="grounding",ms="中性点谐振接地:电感线圈连接到地",fs="-12 -32 24 67",hs=24,ps=67,gs='<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"/>',ys=[{id:"t_top",x:0,y:-30,orientation:"n"}],xs={kind:"inline"},r2={id:cs,name:ds,category:us,description:ms,viewBox:fs,width:hs,height:ps,svg:gs,terminals:ys,source:xs},s2=Object.freeze(Object.defineProperty({__proto__:null,category:us,default:r2,description:ms,height:ps,id:cs,name:ds,source:xs,svg:gs,terminals:ys,viewBox:fs,width:hs},Symbol.toStringTag,{value:"Module"})),bs="arrester",ws="避雷器 (FBL)",vs="protection",ks="-7 -22 14 44",_s=14,$s=44,Ss='<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"/>',js=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Es={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_22/en_60617_07_22_03.elmt",qetEnglishName:"Surge diverter; Lightning arrester"},i2={id:bs,name:ws,category:vs,viewBox:ks,width:_s,height:$s,svg:Ss,terminals:js,source:Es},a2=Object.freeze(Object.defineProperty({__proto__:null,category:vs,default:i2,height:$s,id:bs,name:ws,source:Es,svg:Ss,terminals:js,viewBox:ks,width:_s},Symbol.toStringTag,{value:"Module"})),Ns="async-motor",Ms="异步电动机",Ts="load",As="-62 -82 64 84",Cs=64,Is=84,Ps='<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"/>',Os=[{id:"t1",x:-50,y:-80,orientation:"n"},{id:"t2",x:-10,y:-80,orientation:"n"},{id:"t3",x:-30,y:-80,orientation:"n"}],Bs={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"},l2={id:Ns,name:Ms,category:Ts,viewBox:As,width:Cs,height:Is,svg:Ps,terminals:Os,source:Bs},c2=Object.freeze(Object.defineProperty({__proto__:null,category:Ts,default:l2,height:Is,id:Ns,name:Ms,source:Bs,svg:Ps,terminals:Os,viewBox:As,width:Cs},Symbol.toStringTag,{value:"Module"})),Ls="autotransformer",zs="自耦变压器",Rs="transformer",Ds="-62 -112 64 144",Fs=64,Hs=144,Ws='<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"/>',qs=[{id:"t1",x:-30,y:-110,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],Gs={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_06.elmt",qetEnglishName:"Auto-transformer, general symbol"},d2={id:Ls,name:zs,category:Rs,viewBox:Ds,width:Fs,height:Hs,svg:Ws,terminals:qs,source:Gs},u2=Object.freeze(Object.defineProperty({__proto__:null,category:Rs,default:d2,height:Hs,id:Ls,name:zs,source:Gs,svg:Ws,terminals:qs,viewBox:Ds,width:Fs},Symbol.toStringTag,{value:"Module"})),Xs="battery",Ks="电池储能",Ys="storage",Vs="-12 -12 29 24",Us=29,Js=24,Zs='<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"/>',Qs=[{id:"t_left",x:-10,y:0,orientation:"w"},{id:"t_right",x:15,y:0,orientation:"e"}],ei=[{name:"E",label:"容量",type:"number",unit:"kWh"}],ti={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_15/en_60617_06_15_01.elmt",qetEnglishName:"Battery cell"},m2={id:Xs,name:Ks,category:Ys,viewBox:Vs,width:Us,height:Js,svg:Zs,terminals:Qs,params:ei,source:ti},f2=Object.freeze(Object.defineProperty({__proto__:null,category:Ys,default:m2,height:Js,id:Xs,name:Ks,params:ei,source:ti,svg:Zs,terminals:Qs,viewBox:Vs,width:Us},Symbol.toStringTag,{value:"Module"})),ni="bell",oi="电铃 (HA)",ri="control",si="信号电铃 / 警铃。",ii="-32 -32 44 44",ai=44,li=44,ci='<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"/>',di=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ui={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_06.elmt",qetEnglishName:"Bell"},h2={id:ni,name:oi,category:ri,description:si,viewBox:ii,width:ai,height:li,svg:ci,terminals:di,source:ui},p2=Object.freeze(Object.defineProperty({__proto__:null,category:ri,default:h2,description:si,height:li,id:ni,name:oi,source:ui,svg:ci,terminals:di,viewBox:ii,width:ai},Symbol.toStringTag,{value:"Module"})),mi="break-contact",fi="常闭触点 (NC)",hi="control",pi="常闭辅助触点 (break contact)。",gi="-2 -42 14 64",yi=14,xi=64,bi='<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"/>',wi=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],vi=[{name:"open",type:"boolean",default:!1,label:"断开"}],ki={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_02/en_60617_07_02_03.elmt",qetEnglishName:"Break contact"},g2={id:mi,name:fi,category:hi,description:pi,viewBox:gi,width:yi,height:xi,svg:bi,terminals:wi,state:vi,source:ki},y2=Object.freeze(Object.defineProperty({__proto__:null,category:hi,default:g2,description:pi,height:xi,id:mi,name:fi,source:ki,state:vi,svg:bi,terminals:wi,viewBox:gi,width:yi},Symbol.toStringTag,{value:"Module"})),_i="breaker",$i="断路器 (QF)",Si="switching",ji="-7 -22 15 46",Ei=15,Ni=46,Mi='<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"/><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>',Ti=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ai=[{name:"open",type:"boolean",default:!1,label:"断开"}],Ci={x:6,y:-2,anchor:"start"},Ii={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/11_circuit_breakers/disjoncteur1.elmt",qetEnglishName:"Circuit-breaker"},x2={id:_i,name:$i,category:Si,viewBox:ji,width:Ei,height:Ni,svg:Mi,terminals:Ti,state:Ai,label:Ci,source:Ii},b2=Object.freeze(Object.defineProperty({__proto__:null,category:Si,default:x2,height:Ni,id:_i,label:Ci,name:$i,source:Ii,state:Ai,svg:Mi,terminals:Ti,viewBox:ji,width:Ei},Symbol.toStringTag,{value:"Module"})),Pi="buchholz-relay",Oi="瓦斯继电器 (63)",Bi="protection",Li="瓦斯 / 气体继电器 (Buchholz, ANSI 63)。",zi="-22 -62 44 64",Ri=44,Di=64,Fi='<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"/>',Hi=[{id:"t_top",x:0,y:-60,orientation:"n"}],Wi={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"},w2={id:Pi,name:Oi,category:Bi,description:Li,viewBox:zi,width:Ri,height:Di,svg:Fi,terminals:Hi,source:Wi},v2=Object.freeze(Object.defineProperty({__proto__:null,category:Bi,default:w2,description:Li,height:Di,id:Pi,name:Oi,source:Wi,svg:Fi,terminals:Hi,viewBox:zi,width:Ri},Symbol.toStringTag,{value:"Module"})),qi="busbar",Gi="母线段",Xi="busbar",Ki="可拉伸单母线段,多设备挂接",Yi="-42 -4 84 8",Vi=84,Ui=8,Ji='<line x1="-40" y1="0" x2="40" y2="0" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>',Zi=[{id:"tap",x:0,y:0,orientation:"n"}],Qi={axis:"x",minLength:20,naturalSpan:80},ea=[{name:"Un",label:"额定电压",type:"number",unit:"kV",showOnCanvas:!0}],ta={x:0,y:-6,anchor:"middle"},na={kind:"inline"},k2={id:qi,name:Gi,category:Xi,description:Ki,viewBox:Yi,width:Vi,height:Ui,svg:Ji,terminals:Zi,stretchable:Qi,params:ea,label:ta,source:na},_2=Object.freeze(Object.defineProperty({__proto__:null,category:Xi,default:k2,description:Ki,height:Ui,id:qi,label:ta,name:Gi,params:ea,source:na,stretchable:Qi,svg:Ji,terminals:Zi,viewBox:Yi,width:Vi},Symbol.toStringTag,{value:"Module"})),oa="buzzer",ra="蜂鸣器 (HA)",sa="control",ia="信号蜂鸣器。",aa="-32 -52 44 64",la=44,ca=64,da='<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"/>',ua=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],ma={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_10.elmt",qetEnglishName:"Buzzer"},$2={id:oa,name:ra,category:sa,description:ia,viewBox:aa,width:la,height:ca,svg:da,terminals:ua,source:ma},S2=Object.freeze(Object.defineProperty({__proto__:null,category:sa,default:$2,description:ia,height:ca,id:oa,name:ra,source:ma,svg:da,terminals:ua,viewBox:aa,width:la},Symbol.toStringTag,{value:"Module"})),fa="capacitor",ha="电容 (C)",pa="passive",ga="通用 / 滤波 / 直流母线电容。无功补偿请用并联电容器。",ya="-7 -23 14 27",xa=14,ba=27,wa='<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"/>',va=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],ka=[{name:"C",label:"容值",type:"number",unit:"μF",showOnCanvas:!0},{name:"Un",label:"额定电压",type:"number",unit:"V"}],_a={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},j2={id:fa,name:ha,category:pa,description:ga,viewBox:ya,width:xa,height:ba,svg:wa,terminals:va,params:ka,source:_a},E2=Object.freeze(Object.defineProperty({__proto__:null,category:pa,default:j2,description:ga,height:ba,id:fa,name:ha,params:ka,source:_a,svg:wa,terminals:va,viewBox:ya,width:xa},Symbol.toStringTag,{value:"Module"})),$a="contactor",Sa="接触器 (KM)",ja="motor-control",Ea="主回路接触器, 通常配热继电器和电机使用。",Na="-10 -42 15 64",Ma=15,Ta=64,Aa='<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"/>',Ca=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Ia=[{name:"open",type:"boolean",default:!0,label:"断开"}],Pa={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"},N2={id:$a,name:Sa,category:ja,description:Ea,viewBox:Na,width:Ma,height:Ta,svg:Aa,terminals:Ca,state:Ia,source:Pa},M2=Object.freeze(Object.defineProperty({__proto__:null,category:ja,default:N2,description:Ea,height:Ta,id:$a,name:Sa,source:Pa,state:Ia,svg:Aa,terminals:Ca,viewBox:Na,width:Ma},Symbol.toStringTag,{value:"Module"})),Oa="converter-bidir",Ba="双向变流器 (PCS)",La="renewable",za="储能变流器:双向 AC ↔ DC",Ra="-42 -42 44 48",Da=44,Fa=48,Ha='<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"/>',Wa=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],qa=[{name:"S",label:"容量",type:"number",unit:"MVA"}],Ga={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_06.elmt",qetEnglishName:"Rectifier/inverter"},T2={id:Oa,name:Ba,category:La,description:za,viewBox:Ra,width:Da,height:Fa,svg:Ha,terminals:Wa,params:qa,source:Ga},A2=Object.freeze(Object.defineProperty({__proto__:null,category:La,default:T2,description:za,height:Fa,id:Oa,name:Ba,params:qa,source:Ga,svg:Ha,terminals:Wa,viewBox:Ra,width:Da},Symbol.toStringTag,{value:"Module"})),Xa="ct",Ka="电流互感器 (CT)",Ya="instrument-transformer",Va="-42 -62 54 64",Ua=54,Ja=64,Za='<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"/>',Qa=[{id:"t1",x:-30,y:-60,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],el={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_10.elmt",qetEnglishName:"Current transformer, general symbol"},C2={id:Xa,name:Ka,category:Ya,viewBox:Va,width:Ua,height:Ja,svg:Za,terminals:Qa,source:el},I2=Object.freeze(Object.defineProperty({__proto__:null,category:Ya,default:C2,height:Ja,id:Xa,name:Ka,source:el,svg:Za,terminals:Qa,viewBox:Va,width:Ua},Symbol.toStringTag,{value:"Module"})),tl="dc-combiner",nl="直流汇流箱",ol="renewable",rl="光伏组串汇流箱 (4 路输入示例)。",sl="-27 -32 54 64",il=54,al=64,ll='<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>',cl=[{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"}],dl={kind:"inline"},P2={id:tl,name:nl,category:ol,description:rl,viewBox:sl,width:il,height:al,svg:ll,terminals:cl,source:dl},O2=Object.freeze(Object.defineProperty({__proto__:null,category:ol,default:P2,description:rl,height:al,id:tl,name:nl,source:dl,svg:ll,terminals:cl,viewBox:sl,width:il},Symbol.toStringTag,{value:"Module"})),ul="dc-disconnector",ml="直流隔离开关",fl="switching",hl="DC isolating switch — 光伏组串 / 储能 直流侧隔离。",pl="-12 -32 30 64",gl=30,yl=64,xl='<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"/>',bl=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],wl=[{name:"open",type:"boolean",default:!1,label:"断开"}],vl={kind:"inline"},B2={id:ul,name:ml,category:fl,description:hl,viewBox:pl,width:gl,height:yl,svg:xl,terminals:bl,state:wl,source:vl},L2=Object.freeze(Object.defineProperty({__proto__:null,category:fl,default:B2,description:hl,height:yl,id:ul,name:ml,source:vl,state:wl,svg:xl,terminals:bl,viewBox:pl,width:gl},Symbol.toStringTag,{value:"Module"})),kl="dc-motor",_l="直流电机 (M)",$l="load",Sl="直流电动机 (串励通用符号)。",jl="-72 -82 89 84",El=89,Nl=84,Ml='<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"/>',Tl=[{id:"t1",x:-70,y:-80,orientation:"n"},{id:"t2",x:10,y:-80,orientation:"n"}],Al={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_05/en_60617_06_05_01.elmt",qetEnglishName:"Series motor, DC"},z2={id:kl,name:_l,category:$l,description:Sl,viewBox:jl,width:El,height:Nl,svg:Ml,terminals:Tl,source:Al},R2=Object.freeze(Object.defineProperty({__proto__:null,category:$l,default:z2,description:Sl,height:Nl,id:kl,name:_l,source:Al,svg:Ml,terminals:Tl,viewBox:jl,width:El},Symbol.toStringTag,{value:"Module"})),Cl="diode",Il="二极管 (D)",Pl="passive",Ol="整流 / 续流 / 保护二极管。t1=阳极(上), t2=阴极(下)。",Bl="-12 -42 24 44",Ll=24,zl=44,Rl='<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"/>',Dl=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Fl={x:6,y:-20,anchor:"start"},Hl={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_03/en_60617_05_03_01.elmt",qetEnglishName:"Semiconductor diode, general symbol"},D2={id:Cl,name:Il,category:Pl,description:Ol,viewBox:Bl,width:Ll,height:zl,svg:Rl,terminals:Dl,label:Fl,source:Hl},F2=Object.freeze(Object.defineProperty({__proto__:null,category:Pl,default:D2,description:Ol,height:zl,id:Cl,label:Fl,name:Il,source:Hl,svg:Rl,terminals:Dl,viewBox:Bl,width:Ll},Symbol.toStringTag,{value:"Module"})),Wl="disconnector",ql="隔离开关 (QS)",Gl="switching",Xl="-10 -42 15 64",Kl=15,Yl=64,Vl='<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"/>',Ul=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Jl=[{name:"open",type:"boolean",default:!1,label:"断开"}],Zl={x:6,y:-10,anchor:"start"},Ql={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_13/en_60617_07_13_06.elmt",qetEnglishName:"Disconnector; Isolator"},H2={id:Wl,name:ql,category:Gl,viewBox:Xl,width:Kl,height:Yl,svg:Vl,terminals:Ul,state:Jl,label:Zl,source:Ql},W2=Object.freeze(Object.defineProperty({__proto__:null,category:Gl,default:H2,height:Yl,id:Wl,label:Zl,name:ql,source:Ql,state:Jl,svg:Vl,terminals:Ul,viewBox:Xl,width:Kl},Symbol.toStringTag,{value:"Module"})),ec="distance-relay",tc="距离继电器 (21)",nc="protection",oc="距离 / 低阻抗保护继电器 (ANSI 21)。",rc="-62 -42 64 44",sc=64,ic=44,ac='<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 <</text>',lc=[{id:"t_top",x:-30,y:-40,orientation:"n"}],cc={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_09.elmt",qetEnglishName:"Under-impedance relay"},q2={id:ec,name:tc,category:nc,description:oc,viewBox:rc,width:sc,height:ic,svg:ac,terminals:lc,source:cc},G2=Object.freeze(Object.defineProperty({__proto__:null,category:nc,default:q2,description:oc,height:ic,id:ec,name:tc,source:cc,svg:ac,terminals:lc,viewBox:rc,width:sc},Symbol.toStringTag,{value:"Module"})),dc="earth",uc="接地",mc="busbar",fc="-12 -17 24 34",hc=24,pc=34,gc='<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"/>',yc=[{id:"t1",x:0,y:-15,orientation:"n"}],xc={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"},X2={id:dc,name:uc,category:mc,viewBox:fc,width:hc,height:pc,svg:gc,terminals:yc,source:xc},K2=Object.freeze(Object.defineProperty({__proto__:null,category:mc,default:X2,height:pc,id:dc,name:uc,source:xc,svg:gc,terminals:yc,viewBox:fc,width:hc},Symbol.toStringTag,{value:"Module"})),bc="earthing-switch",wc="接地刀闸 (QE)",vc="switching",kc="隔离开关 + 接地连接,单端口",_c="-12 -32 24 64",$c=24,Sc=64,jc='<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"/>',Ec=[{id:"t_top",x:0,y:-30,orientation:"n"}],Nc=[{name:"open",type:"boolean",default:!0,label:"断开"}],Mc={x:12,y:-8,anchor:"start"},Tc={kind:"inline"},Y2={id:bc,name:wc,category:vc,description:kc,viewBox:_c,width:$c,height:Sc,svg:jc,terminals:Ec,state:Nc,label:Mc,source:Tc},V2=Object.freeze(Object.defineProperty({__proto__:null,category:vc,default:Y2,description:kc,height:Sc,id:bc,label:Mc,name:wc,source:Tc,state:Nc,svg:jc,terminals:Ec,viewBox:_c,width:$c},Symbol.toStringTag,{value:"Module"})),Ac="energy-meter",Cc="电能表 (Wh)",Ic="measurement",Pc="有功电能表 (kWh) — 服务入口 / 子表。",Oc="-22 -36 44 72",Bc=44,Lc=72,zc='<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"/>',Rc=[{id:"t1",x:0,y:-34,orientation:"n"},{id:"t2",x:0,y:34,orientation:"s"}],Dc={kind:"elmt",path:"11_singlepole/500_home_installation/40_meters/wattheuremetre_08-04-03_en60617.elmt",qetEnglishName:"Watt hour meter (en_60617)"},U2={id:Ac,name:Cc,category:Ic,description:Pc,viewBox:Oc,width:Bc,height:Lc,svg:zc,terminals:Rc,source:Dc},J2=Object.freeze(Object.defineProperty({__proto__:null,category:Ic,default:U2,description:Pc,height:Lc,id:Ac,name:Cc,source:Dc,svg:zc,terminals:Rc,viewBox:Oc,width:Bc},Symbol.toStringTag,{value:"Module"})),Fc="ev-charger",Hc="EV 充电桩",Wc="load",qc="电动汽车充电站 / 充电桩。",Gc="-17 -27 34 49",Xc=34,Kc=49,Yc='<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>',Vc=[{id:"t_top",x:0,y:-25,orientation:"n"}],Uc={kind:"inline"},Z2={id:Fc,name:Hc,category:Wc,description:qc,viewBox:Gc,width:Xc,height:Kc,svg:Yc,terminals:Vc,source:Uc},Q2=Object.freeze(Object.defineProperty({__proto__:null,category:Wc,default:Z2,description:qc,height:Kc,id:Fc,name:Hc,source:Uc,svg:Yc,terminals:Vc,viewBox:Gc,width:Xc},Symbol.toStringTag,{value:"Module"})),Jc="frequency-meter",Zc="频率表 (Hz)",Qc="measurement",ed="-22 -42 44 44",td=44,nd=44,od='<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>',rd=[{id:"t_top",x:0,y:-40,orientation:"n"}],sd={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_07.elmt",qetEnglishName:"Frequency meter"},ek={id:Jc,name:Zc,category:Qc,viewBox:ed,width:td,height:nd,svg:od,terminals:rd,source:sd},tk=Object.freeze(Object.defineProperty({__proto__:null,category:Qc,default:ek,height:nd,id:Jc,name:Zc,source:sd,svg:od,terminals:rd,viewBox:ed,width:td},Symbol.toStringTag,{value:"Module"})),id="fuse-switch-disconnector",ad="熔断器式隔离开关",ld="switching",cd="负荷型熔断器隔离开关 (on-load fuse switch-disconnector)。",dd="-8 -32 12 64",ud=12,md=64,fd='<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"/>',hd=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],pd=[{name:"open",type:"boolean",default:!1,label:"断开"}],gd={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"},nk={id,name:ad,category:ld,description:cd,viewBox:dd,width:ud,height:md,svg:fd,terminals:hd,state:pd,source:gd},ok=Object.freeze(Object.defineProperty({__proto__:null,category:ld,default:nk,description:cd,height:md,id,name:ad,source:gd,state:pd,svg:fd,terminals:hd,viewBox:dd,width:ud},Symbol.toStringTag,{value:"Module"})),yd="fuse",xd="熔断器 (FU)",bd="switching",wd="-7 -32 14 64",vd=14,kd=64,_d='<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"/>',$d=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Sd=[{name:"blown",type:"boolean",default:!1,label:"熔断"}],jd={x:7,y:-2,anchor:"start"},Ed={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_21/en_60617_07_21_01.elmt",qetEnglishName:"Fuse, general symbol"},rk={id:yd,name:xd,category:bd,viewBox:wd,width:vd,height:kd,svg:_d,terminals:$d,state:Sd,label:jd,source:Ed},sk=Object.freeze(Object.defineProperty({__proto__:null,category:bd,default:rk,height:kd,id:yd,label:jd,name:xd,source:Ed,state:Sd,svg:_d,terminals:$d,viewBox:wd,width:vd},Symbol.toStringTag,{value:"Module"})),Nd="generator",Md="发电机 (G)",Td="source",Ad="-42 -42 44 44",Cd=44,Id=44,Pd='<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>',Od=[{id:"t_bottom",x:-20,y:0,orientation:"s"}],Bd={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_16/en_60617_06_16_01.elmt",qetEnglishName:"Generator, general symbol"},ik={id:Nd,name:Md,category:Td,viewBox:Ad,width:Cd,height:Id,svg:Pd,terminals:Od,source:Bd},ak=Object.freeze(Object.defineProperty({__proto__:null,category:Td,default:ik,height:Id,id:Nd,name:Md,source:Bd,svg:Pd,terminals:Od,viewBox:Ad,width:Cd},Symbol.toStringTag,{value:"Module"})),Ld="genset",zd="发电机组 (G)",Rd="source",Dd="柴油 / 燃气发电机组。",Fd="-28 -22 56 64",Hd=56,Wd=64,qd='<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"/>',Gd=[{id:"t_out",x:0,y:40,orientation:"s"}],Xd=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Kd={kind:"inline"},lk={id:Ld,name:zd,category:Rd,description:Dd,viewBox:Fd,width:Hd,height:Wd,svg:qd,terminals:Gd,params:Xd,source:Kd},ck=Object.freeze(Object.defineProperty({__proto__:null,category:Rd,default:lk,description:Dd,height:Wd,id:Ld,name:zd,params:Xd,source:Kd,svg:qd,terminals:Gd,viewBox:Fd,width:Hd},Symbol.toStringTag,{value:"Module"})),Yd="gfci-breaker",Vd="GFCI 断路器 (RCBO)",Ud="protection",Jd="剩余电流断路器带过流保护 (UL943 / IEC 61009)。北美 GFCI / 欧洲 RCBO。",Zd="-18 -22 22 44",Qd=22,eu=44,tu='<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"/>',nu=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],ou=[{name:"open",type:"boolean",default:!1,label:"断开"}],ru=[{name:"In",label:"额定电流",type:"number",unit:"A"},{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],su={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/rcbo.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},dk={id:Yd,name:Vd,category:Ud,description:Jd,viewBox:Zd,width:Qd,height:eu,svg:tu,terminals:nu,state:ou,params:ru,source:su},uk=Object.freeze(Object.defineProperty({__proto__:null,category:Ud,default:dk,description:Jd,height:eu,id:Yd,name:Vd,params:ru,source:su,state:ou,svg:tu,terminals:nu,viewBox:Zd,width:Qd},Symbol.toStringTag,{value:"Module"})),iu="grid-source",au="系统电源",lu="source",cu="无穷大母线 / 外部电网",du="-16 -31 32 53",uu=32,mu=53,fu='<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"/>',hu=[{id:"t_bottom",x:0,y:20,orientation:"s"}],pu={kind:"inline"},mk={id:iu,name:au,category:lu,description:cu,viewBox:du,width:uu,height:mu,svg:fu,terminals:hu,source:pu},fk=Object.freeze(Object.defineProperty({__proto__:null,category:lu,default:mk,description:cu,height:mu,id:iu,name:au,source:pu,svg:fu,terminals:hu,viewBox:du,width:uu},Symbol.toStringTag,{value:"Module"})),gu="grounding-transformer",yu="接地变 (Z形)",xu="grounding",bu="星-曲折接线变压器,中性点接地用",wu="-62 -152 64 164",vu=64,ku=164,_u='<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"/>',$u=[{id:"t1",x:-30,y:-150,orientation:"n"},{id:"t2",x:-30,y:10,orientation:"s"}],Su={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"},hk={id:gu,name:yu,category:xu,description:bu,viewBox:wu,width:vu,height:ku,svg:_u,terminals:$u,source:Su},pk=Object.freeze(Object.defineProperty({__proto__:null,category:xu,default:hk,description:bu,height:ku,id:gu,name:yu,source:Su,svg:_u,terminals:$u,viewBox:wu,width:vu},Symbol.toStringTag,{value:"Module"})),ju="heater",Eu="电加热器 (EH)",Nu="load",Mu="电阻加热元件 / 电热负荷。",Tu="-22 -7 54 14",Au=54,Cu=14,Iu='<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"/>',Pu=[{id:"t1",x:-20,y:0,orientation:"w"},{id:"t2",x:30,y:0,orientation:"e"}],Ou=[{name:"P",label:"功率",type:"number",unit:"kW",showOnCanvas:!0}],Bu={kind:"elmt",path:"91_en_60617/en_60617_04/en_60617_04_01/en_60617_04_01_12.elmt",qetEnglishName:"Heating element"},gk={id:ju,name:Eu,category:Nu,description:Mu,viewBox:Tu,width:Au,height:Cu,svg:Iu,terminals:Pu,params:Ou,source:Bu},yk=Object.freeze(Object.defineProperty({__proto__:null,category:Nu,default:gk,description:Mu,height:Cu,id:ju,name:Eu,params:Ou,source:Bu,svg:Iu,terminals:Pu,viewBox:Tu,width:Au},Symbol.toStringTag,{value:"Module"})),Lu="igbt",zu="绝缘栅双极晶体管 (IGBT)",Ru="passive",Du="N 沟道增强型 IGBT。t1=集电极(上), t2=发射极(下), t_g=门极。",Fu="-32 -32 54 74",Hu=54,Wu=74,qu='<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"/>',Gu=[{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"}],Xu={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"},xk={id:Lu,name:zu,category:Ru,description:Du,viewBox:Fu,width:Hu,height:Wu,svg:qu,terminals:Gu,source:Xu},bk=Object.freeze(Object.defineProperty({__proto__:null,category:Ru,default:xk,description:Du,height:Wu,id:Lu,name:zu,source:Xu,svg:qu,terminals:Gu,viewBox:Fu,width:Hu},Symbol.toStringTag,{value:"Module"})),Ku="indicator-light",Yu="指示灯 (HL)",Vu="control",Uu="信号 / 状态指示灯。",Ju="-12 -22 24 24",Zu=24,Qu=24,em='<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"/>',tm=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],nm=[{name:"color",label:"颜色",type:"string"}],om={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_01.elmt",qetEnglishName:"Lamp, general symbol"},wk={id:Ku,name:Yu,category:Vu,description:Uu,viewBox:Ju,width:Zu,height:Qu,svg:em,terminals:tm,params:nm,source:om},vk=Object.freeze(Object.defineProperty({__proto__:null,category:Vu,default:wk,description:Uu,height:Qu,id:Ku,name:Yu,params:nm,source:om,svg:em,terminals:tm,viewBox:Ju,width:Zu},Symbol.toStringTag,{value:"Module"})),rm="inductor",sm="电感 (L)",im="passive",am="通用电感 / 线圈 / 扼流圈。",lm="-17 -32 34 64",cm=34,dm=64,um='<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"/>',mm=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],fm=[{name:"L",label:"电感量",type:"number",unit:"mH",showOnCanvas:!0},{name:"In",label:"额定电流",type:"number",unit:"A"}],hm={x:6,y:0,anchor:"start"},pm={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/30_inductors/inductance.elmt",qetEnglishName:"Inductor"},kk={id:rm,name:sm,category:im,description:am,viewBox:lm,width:cm,height:dm,svg:um,terminals:mm,params:fm,label:hm,source:pm},_k=Object.freeze(Object.defineProperty({__proto__:null,category:im,default:kk,description:am,height:dm,id:rm,label:hm,name:sm,params:fm,source:pm,svg:um,terminals:mm,viewBox:lm,width:cm},Symbol.toStringTag,{value:"Module"})),gm="inverter",ym="逆变器 (DC→AC)",xm="renewable",bm="-42 -42 44 44",wm=44,vm=44,km='<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"/>',_m=[{id:"t_dc",x:-20,y:-40,orientation:"n"},{id:"t_ac",x:-20,y:0,orientation:"s"}],$m={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_05.elmt",qetEnglishName:"Inverter"},$k={id:gm,name:ym,category:xm,viewBox:bm,width:wm,height:vm,svg:km,terminals:_m,source:$m},Sk=Object.freeze(Object.defineProperty({__proto__:null,category:xm,default:$k,height:vm,id:gm,name:ym,source:$m,svg:km,terminals:_m,viewBox:bm,width:wm},Symbol.toStringTag,{value:"Module"})),Sm="limit-switch",jm="限位开关 (SQ)",Em="control",Nm="行程 / 位置开关 (常开, 机械操作)。",Mm="-10 -42 12 64",Tm=12,Am=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"/><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"/>',Im=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Pm=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],Om={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_08/en_60617_07_08_01.elmt",qetEnglishName:"Position switch, make contact"},jk={id:Sm,name:jm,category:Em,description:Nm,viewBox:Mm,width:Tm,height:Am,svg:Cm,terminals:Im,state:Pm,source:Om},Ek=Object.freeze(Object.defineProperty({__proto__:null,category:Em,default:jk,description:Nm,height:Am,id:Sm,name:jm,source:Om,state:Pm,svg:Cm,terminals:Im,viewBox:Mm,width:Tm},Symbol.toStringTag,{value:"Module"})),Bm="load-switch",Lm="负荷开关",zm="switching",Rm="-10 -42 14 64",Dm=14,Fm=64,Hm='<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"/>',Wm=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],qm=[{name:"open",type:"boolean",default:!1,label:"断开"}],Gm={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"},Nk={id:Bm,name:Lm,category:zm,viewBox:Rm,width:Dm,height:Fm,svg:Hm,terminals:Wm,state:qm,source:Gm},Mk=Object.freeze(Object.defineProperty({__proto__:null,category:zm,default:Nk,height:Fm,id:Bm,name:Lm,source:Gm,state:qm,svg:Hm,terminals:Wm,viewBox:Rm,width:Dm},Symbol.toStringTag,{value:"Module"})),Xm="load",Km="负荷",Ym="load",Vm="抽象负荷(电流流出箭头)",Um="-8 -22 16 46",Jm=16,Zm=46,Qm='<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"/>',ef=[{id:"t_top",x:0,y:-20,orientation:"n"}],tf=[{name:"P",label:"有功功率",type:"number",unit:"MW",showOnCanvas:!0},{name:"cosphi",label:"功率因数",type:"number"}],nf={x:6,y:0,anchor:"start"},of={kind:"inline"},Tk={id:Xm,name:Km,category:Ym,description:Vm,viewBox:Um,width:Jm,height:Zm,svg:Qm,terminals:ef,params:tf,label:nf,source:of},Ak=Object.freeze(Object.defineProperty({__proto__:null,category:Ym,default:Tk,description:Vm,height:Zm,id:Xm,label:nf,name:Km,params:tf,source:of,svg:Qm,terminals:ef,viewBox:Um,width:Jm},Symbol.toStringTag,{value:"Module"})),rf="make-contact",sf="常开触点 (NO)",af="control",lf="常开辅助触点 (make contact)。",cf="-10 -42 12 64",df=12,uf=64,mf='<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"/>',ff=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],hf=[{name:"closed",type:"boolean",default:!1,label:"闭合"}],pf={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"},Ck={id:rf,name:sf,category:af,description:lf,viewBox:cf,width:df,height:uf,svg:mf,terminals:ff,state:hf,source:pf},Ik=Object.freeze(Object.defineProperty({__proto__:null,category:af,default:Ck,description:lf,height:uf,id:rf,name:sf,source:pf,state:hf,svg:mf,terminals:ff,viewBox:cf,width:df},Symbol.toStringTag,{value:"Module"})),gf="motor-starter",yf="电机启动器",xf="motor-control",bf="电机启动器 (IEC 60617 通用符号)。",wf="-22 -27 44 54",vf=44,kf=54,_f='<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"/>',$f=[{id:"t_top",x:0,y:-25,orientation:"n"},{id:"t_bottom",x:0,y:25,orientation:"s"}],Sf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_14/en_60617_07_14_01.elmt",qetEnglishName:"Motor starter, general symbol"},Pk={id:gf,name:yf,category:xf,description:bf,viewBox:wf,width:vf,height:kf,svg:_f,terminals:$f,source:Sf},Ok=Object.freeze(Object.defineProperty({__proto__:null,category:xf,default:Pk,description:bf,height:kf,id:gf,name:yf,source:Sf,svg:_f,terminals:$f,viewBox:wf,width:vf},Symbol.toStringTag,{value:"Module"})),jf="ngr",Ef="中性点电阻 (NGR)",Nf="grounding",Mf="小电阻接地:连接变压器中性点到地",Tf="-12 -32 24 62",Af=24,Cf=62,If='<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"/>',Pf=[{id:"t_top",x:0,y:-30,orientation:"n"}],Of=[{name:"R",label:"电阻",type:"number",unit:"Ω"}],Bf={kind:"inline"},Bk={id:jf,name:Ef,category:Nf,description:Mf,viewBox:Tf,width:Af,height:Cf,svg:If,terminals:Pf,params:Of,source:Bf},Lk=Object.freeze(Object.defineProperty({__proto__:null,category:Nf,default:Bk,description:Mf,height:Cf,id:jf,name:Ef,params:Of,source:Bf,svg:If,terminals:Pf,viewBox:Tf,width:Af},Symbol.toStringTag,{value:"Module"})),Lf="overcurrent-relay",zf="过流继电器 (50/51)",Rf="protection",Df="过电流保护继电器 (ANSI 50/51)。",Ff="-62 -62 64 64",Hf=64,Wf=64,qf='<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>',Gf=[{id:"t_top",x:-30,y:-60,orientation:"n"}],Xf={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_05.elmt",qetEnglishName:"Overcurrent relay"},zk={id:Lf,name:zf,category:Rf,description:Df,viewBox:Ff,width:Hf,height:Wf,svg:qf,terminals:Gf,source:Xf},Rk=Object.freeze(Object.defineProperty({__proto__:null,category:Rf,default:zk,description:Df,height:Wf,id:Lf,name:zf,source:Xf,svg:qf,terminals:Gf,viewBox:Ff,width:Hf},Symbol.toStringTag,{value:"Module"})),Kf="phase-failure-relay",Yf="断相继电器",Vf="protection",Uf="断相 / 缺相保护继电器。",Jf="-62 -42 64 44",Zf=64,Qf=44,eh='<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 < 3</text>',th=[{id:"t_top",x:-30,y:-40,orientation:"n"}],nh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_12.elmt",qetEnglishName:"Phase-failure detection relay"},Dk={id:Kf,name:Yf,category:Vf,description:Uf,viewBox:Jf,width:Zf,height:Qf,svg:eh,terminals:th,source:nh},Fk=Object.freeze(Object.defineProperty({__proto__:null,category:Vf,default:Dk,description:Uf,height:Qf,id:Kf,name:Yf,source:nh,svg:eh,terminals:th,viewBox:Jf,width:Zf},Symbol.toStringTag,{value:"Module"})),oh="plc",rh="PLC / 控制器",sh="control",ih="可编程逻辑控制器 (PLC)。",ah="-24 -42 48 84",lh=48,ch=84,dh='<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"/>',uh=[{id:"t_top",x:0,y:-40,orientation:"n"},{id:"t_bottom",x:0,y:40,orientation:"s"}],mh={kind:"inline"},Hk={id:oh,name:rh,category:sh,description:ih,viewBox:ah,width:lh,height:ch,svg:dh,terminals:uh,source:mh},Wk=Object.freeze(Object.defineProperty({__proto__:null,category:sh,default:Hk,description:ih,height:ch,id:oh,name:rh,source:mh,svg:dh,terminals:uh,viewBox:ah,width:lh},Symbol.toStringTag,{value:"Module"})),fh="power-factor-meter",hh="功率因数表 (cosφ)",ph="measurement",gh="功率因数表 (cosφ)。",yh="-22 -42 44 44",xh=44,bh=44,wh='<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>',vh=[{id:"t_top",x:0,y:-40,orientation:"n"}],kh={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_05.elmt",qetEnglishName:"Power-factor meter"},qk={id:fh,name:hh,category:ph,description:gh,viewBox:yh,width:xh,height:bh,svg:wh,terminals:vh,source:kh},Gk=Object.freeze(Object.defineProperty({__proto__:null,category:ph,default:qk,description:gh,height:bh,id:fh,name:hh,source:kh,svg:wh,terminals:vh,viewBox:yh,width:xh},Symbol.toStringTag,{value:"Module"})),_h="power-supply",$h="开关电源 (PS)",Sh="source",jh="AC→DC 开关电源 / 直流电源模块。t_ac 上(~), t_dc 下(=)。",Eh="-24 -42 48 84",Nh=48,Mh=84,Th='<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"/>',Ah=[{id:"t_ac",x:0,y:-40,orientation:"n"},{id:"t_dc",x:0,y:40,orientation:"s"}],Ch=[{name:"Vdc",label:"输出电压",type:"number",unit:"V",showOnCanvas:!0}],Ih={kind:"inline"},Xk={id:_h,name:$h,category:Sh,description:jh,viewBox:Eh,width:Nh,height:Mh,svg:Th,terminals:Ah,params:Ch,source:Ih},Kk=Object.freeze(Object.defineProperty({__proto__:null,category:Sh,default:Xk,description:jh,height:Mh,id:_h,name:$h,params:Ch,source:Ih,svg:Th,terminals:Ah,viewBox:Eh,width:Nh},Symbol.toStringTag,{value:"Module"})),Ph="protective-relay",Oh="保护继电器",Bh="protection",Lh="测量继电器 / 保护继电器通用符号 (IEC 60617)。",zh="-32 -42 64 44",Rh=64,Dh=44,Fh='<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"/>',Hh=[{id:"t_top",x:0,y:-40,orientation:"n"}],Wh={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"},Yk={id:Ph,name:Oh,category:Bh,description:Lh,viewBox:zh,width:Rh,height:Dh,svg:Fh,terminals:Hh,source:Wh},Vk=Object.freeze(Object.defineProperty({__proto__:null,category:Bh,default:Yk,description:Lh,height:Dh,id:Ph,name:Oh,source:Wh,svg:Fh,terminals:Hh,viewBox:zh,width:Rh},Symbol.toStringTag,{value:"Module"})),qh="proximity-switch",Gh="接近开关 (SQ)",Xh="control",Kh="接近传感器 / 无触点接近开关。",Yh="-12 -32 24 64",Vh=24,Uh=64,Jh='<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"/>',Zh=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Qh={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_19/en_60617_07_19_01.elmt",qetEnglishName:"Proximity sensor"},Uk={id:qh,name:Gh,category:Xh,description:Kh,viewBox:Yh,width:Vh,height:Uh,svg:Jh,terminals:Zh,source:Qh},Jk=Object.freeze(Object.defineProperty({__proto__:null,category:Xh,default:Uk,description:Kh,height:Uh,id:qh,name:Gh,source:Qh,svg:Jh,terminals:Zh,viewBox:Yh,width:Vh},Symbol.toStringTag,{value:"Module"})),e0="pt",t0="电压互感器 (PT)",n0="instrument-transformer",o0="-22 -42 44 115",r0=44,s0=115,i0='<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"/>',a0=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:71,orientation:"s"}],l0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_13/en_60617_06_13_01A.elmt",qetEnglishName:"Voltage transformer"},Zk={id:e0,name:t0,category:n0,viewBox:o0,width:r0,height:s0,svg:i0,terminals:a0,source:l0},Qk=Object.freeze(Object.defineProperty({__proto__:null,category:n0,default:Zk,height:s0,id:e0,name:t0,source:l0,svg:i0,terminals:a0,viewBox:o0,width:r0},Symbol.toStringTag,{value:"Module"})),c0="push-button",d0="按钮 (SB)",u0="control",m0="手动按钮, 自动复位 (常开 make)。",f0="-37 -42 39 64",h0=39,p0=64,g0='<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"}],x0={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"},e_={id:c0,name:d0,category:u0,description:m0,viewBox:f0,width:h0,height:p0,svg:g0,terminals:y0,source:x0},t_=Object.freeze(Object.defineProperty({__proto__:null,category:u0,default:e_,description:m0,height:p0,id:c0,name:d0,source:x0,svg:g0,terminals:y0,viewBox:f0,width:h0},Symbol.toStringTag,{value:"Module"})),b0="pv",w0="光伏组件",v0="renewable",k0="-33 -22 85 64",_0=85,$0=64,S0='<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"/>',j0=[{id:"t_dc",x:50,y:10,orientation:"e"}],E0={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_18/en_60617_06_18_06.elmt",qetEnglishName:"Photovoltaic generator"},n_={id:b0,name:w0,category:v0,viewBox:k0,width:_0,height:$0,svg:S0,terminals:j0,source:E0},o_=Object.freeze(Object.defineProperty({__proto__:null,category:v0,default:n_,height:$0,id:b0,name:w0,source:E0,svg:S0,terminals:j0,viewBox:k0,width:_0},Symbol.toStringTag,{value:"Module"})),N0="rcd",M0="剩余电流装置 (RCD)",T0="protection",A0="不带过流保护的剩余电流断路器 (IEC 61008)。",C0="-12 -22 19 44",I0=19,P0=44,O0='<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"/>',B0=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],L0=[{name:"open",type:"boolean",default:!1,label:"断开"}],z0=[{name:"IDn",label:"剩余动作电流",type:"number",unit:"mA",default:30}],R0={kind:"elmt",path:"11_singlepole/200_fuses_protective_gears/50_residual_current_circuit_breaker/ddr1.elmt",qetEnglishName:"Residual Circuit Breaker with Overload"},r_={id:N0,name:M0,category:T0,description:A0,viewBox:C0,width:I0,height:P0,svg:O0,terminals:B0,state:L0,params:z0,source:R0},s_=Object.freeze(Object.defineProperty({__proto__:null,category:T0,default:r_,description:A0,height:P0,id:N0,name:M0,params:z0,source:R0,state:L0,svg:O0,terminals:B0,viewBox:C0,width:I0},Symbol.toStringTag,{value:"Module"})),D0="recloser",F0="重合闸 (Recloser)",H0="protection",W0="中压自动重合闸开关。",q0="-12 -32 36 64",G0=36,X0=64,K0='<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>',Y0=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],V0=[{name:"open",type:"boolean",default:!1,label:"断开"}],U0={kind:"inline"},i_={id:D0,name:F0,category:H0,description:W0,viewBox:q0,width:G0,height:X0,svg:K0,terminals:Y0,state:V0,source:U0},a_=Object.freeze(Object.defineProperty({__proto__:null,category:H0,default:i_,description:W0,height:X0,id:D0,name:F0,source:U0,state:V0,svg:K0,terminals:Y0,viewBox:q0,width:G0},Symbol.toStringTag,{value:"Module"})),J0="rectifier",Z0="整流器 (AC→DC)",Q0="renewable",ep="-42 -42 44 44",tp=44,np=44,op='<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"/>',rp=[{id:"t_ac",x:-20,y:-40,orientation:"n"},{id:"t_dc",x:-20,y:0,orientation:"s"}],sp={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_14/en_60617_06_14_03.elmt",qetEnglishName:"Rectifier"},l_={id:J0,name:Z0,category:Q0,viewBox:ep,width:tp,height:np,svg:op,terminals:rp,source:sp},c_=Object.freeze(Object.defineProperty({__proto__:null,category:Q0,default:l_,height:np,id:J0,name:Z0,source:sp,svg:op,terminals:rp,viewBox:ep,width:tp},Symbol.toStringTag,{value:"Module"})),ip="relay-coil",ap="继电器线圈 (KA)",lp="control",cp="继电器 / 接触器操作线圈 (方框)。",dp="-22 -22 44 44",up=44,mp=44,fp='<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"/>',hp=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],pp={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"},d_={id:ip,name:ap,category:lp,description:cp,viewBox:dp,width:up,height:mp,svg:fp,terminals:hp,source:pp},u_=Object.freeze(Object.defineProperty({__proto__:null,category:lp,default:d_,description:cp,height:mp,id:ip,name:ap,source:pp,svg:fp,terminals:hp,viewBox:dp,width:up},Symbol.toStringTag,{value:"Module"})),gp="resistor",yp="电阻 (R)",xp="passive",bp="通用电阻 / 限流 / 制动电阻。",wp="-6 -23 12 35",vp=12,kp=35,_p='<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"/>',$p=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t2",x:0,y:10,orientation:"s"}],Sp=[{name:"R",label:"阻值",type:"number",unit:"Ω",showOnCanvas:!0},{name:"P",label:"额定功率",type:"number",unit:"W"}],jp={x:6,y:0,anchor:"start"},Ep={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/10_resistors/resistance.elmt",qetEnglishName:"Resistor"},m_={id:gp,name:yp,category:xp,description:bp,viewBox:wp,width:vp,height:kp,svg:_p,terminals:$p,params:Sp,label:jp,source:Ep},f_=Object.freeze(Object.defineProperty({__proto__:null,category:xp,default:m_,description:bp,height:kp,id:gp,label:jp,name:yp,params:Sp,source:Ep,svg:_p,terminals:$p,viewBox:wp,width:vp},Symbol.toStringTag,{value:"Module"})),Np="reverse-power-relay",Mp="逆功率继电器 (32)",Tp="protection",Ap="逆功率 / 逆流保护继电器 (ANSI 32)。",Cp="-62 -42 64 44",Ip=64,Pp=44,Op='<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"/>',Bp=[{id:"t_top",x:-30,y:-40,orientation:"n"}],Lp={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_02.elmt",qetEnglishName:"Reverse current relay"},h_={id:Np,name:Mp,category:Tp,description:Ap,viewBox:Cp,width:Ip,height:Pp,svg:Op,terminals:Bp,source:Lp},p_=Object.freeze(Object.defineProperty({__proto__:null,category:Tp,default:h_,description:Ap,height:Pp,id:Np,name:Mp,source:Lp,svg:Op,terminals:Bp,viewBox:Cp,width:Ip},Symbol.toStringTag,{value:"Module"})),zp="selector-switch",Rp="选择开关 (SA)",Dp="switching",Fp="转换 / 选择开关 (旋转操作, 保位)。",Hp="-34 -42 36 64",Wp=36,qp=64,Gp='<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"/>',Xp=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],Kp=[{name:"open",type:"boolean",default:!1,label:"断开"}],Yp={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"},g_={id:zp,name:Rp,category:Dp,description:Fp,viewBox:Hp,width:Wp,height:qp,svg:Gp,terminals:Xp,state:Kp,source:Yp},y_=Object.freeze(Object.defineProperty({__proto__:null,category:Dp,default:g_,description:Fp,height:qp,id:zp,name:Rp,source:Yp,state:Kp,svg:Gp,terminals:Xp,viewBox:Hp,width:Wp},Symbol.toStringTag,{value:"Module"})),Vp="series-reactor",Up="串联电抗器",Jp="compensation",Zp="与并联电抗器同符号;通过用法区分。",Qp="-62 -82 64 104",eg=64,tg=104,ng='<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"/>',og=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],rg={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},x_={id:Vp,name:Up,category:Jp,description:Zp,viewBox:Qp,width:eg,height:tg,svg:ng,terminals:og,source:rg},b_=Object.freeze(Object.defineProperty({__proto__:null,category:Jp,default:x_,description:Zp,height:tg,id:Vp,name:Up,source:rg,svg:ng,terminals:og,viewBox:Qp,width:eg},Symbol.toStringTag,{value:"Module"})),sg="shunt-capacitor",ig="并联电容器",ag="compensation",lg="-7 -23 14 27",cg=14,dg=27,ug='<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"/>',mg=[{id:"t1",x:0,y:-21,orientation:"n"},{id:"t_bottom",x:0,y:2,orientation:"s"}],fg=[{name:"Q",label:"无功容量",type:"number",unit:"Mvar"},{name:"stages",label:"分组数",type:"number"}],hg={kind:"elmt",path:"11_singlepole/395_electronics_semiconductors/20_capacitors/capacite.elmt",qetEnglishName:"Capacitor"},w_={id:sg,name:ig,category:ag,viewBox:lg,width:cg,height:dg,svg:ug,terminals:mg,params:fg,source:hg},v_=Object.freeze(Object.defineProperty({__proto__:null,category:ag,default:w_,height:dg,id:sg,name:ig,params:fg,source:hg,svg:ug,terminals:mg,viewBox:lg,width:cg},Symbol.toStringTag,{value:"Module"})),pg="shunt-reactor",gg="并联电抗器",yg="compensation",xg="-62 -82 64 104",bg=64,wg=104,vg='<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"/>',kg=[{id:"t1",x:-30,y:-80,orientation:"n"},{id:"t_bottom",x:-30,y:20,orientation:"s"}],_g={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_09/en_60617_06_09_08.elmt",qetEnglishName:"Choke; Reactor, general symbol"},k_={id:pg,name:gg,category:yg,viewBox:xg,width:bg,height:wg,svg:vg,terminals:kg,source:_g},__=Object.freeze(Object.defineProperty({__proto__:null,category:yg,default:k_,height:wg,id:pg,name:gg,source:_g,svg:vg,terminals:kg,viewBox:xg,width:bg},Symbol.toStringTag,{value:"Module"})),$g="siren",Sg="警笛 (HA)",jg="control",Eg="声响警笛 / 报警器。",Ng="-32 -42 44 54",Mg=44,Tg=54,Ag='<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"/>',Cg=[{id:"t1",x:-20,y:10,orientation:"s"},{id:"t2",x:0,y:10,orientation:"s"}],Ig={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_10/en_60617_08_10_09.elmt",qetEnglishName:"Siren"},$_={id:$g,name:Sg,category:jg,description:Eg,viewBox:Ng,width:Mg,height:Tg,svg:Ag,terminals:Cg,source:Ig},S_=Object.freeze(Object.defineProperty({__proto__:null,category:jg,default:$_,description:Eg,height:Tg,id:$g,name:Sg,source:Ig,svg:Ag,terminals:Cg,viewBox:Ng,width:Mg},Symbol.toStringTag,{value:"Module"})),Pg="socket-outlet",Og="插座 / 连接器",Bg="load",Lg="电源插座 / 多极连接器。",zg="-7 -2 13 34",Rg=13,Dg=34,Fg='<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"/>',Hg=[{id:"t1",x:0,y:0,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],Wg={kind:"elmt",path:"11_singlepole/140_connectors_plugs/prise_multipolaire_2.elmt",qetEnglishName:`Plug and multipolar representation
|
|
197
|
+
unifilar`},j_={id:Pg,name:Og,category:Bg,description:Lg,viewBox:zg,width:Rg,height:Dg,svg:Fg,terminals:Hg,source:Wg},E_=Object.freeze(Object.defineProperty({__proto__:null,category:Bg,default:j_,description:Lg,height:Dg,id:Pg,name:Og,source:Wg,svg:Fg,terminals:Hg,viewBox:zg,width:Rg},Symbol.toStringTag,{value:"Module"})),qg="soft-starter",Gg="软启动器",Xg="motor-control",Kg="电机软启动器 (晶闸管降压启动)。",Yg="-22 -42 44 84",Vg=44,Ug=84,Jg='<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"/>',Zg=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Qg={kind:"inline"},N_={id:qg,name:Gg,category:Xg,description:Kg,viewBox:Yg,width:Vg,height:Ug,svg:Jg,terminals:Zg,source:Qg},M_=Object.freeze(Object.defineProperty({__proto__:null,category:Xg,default:N_,description:Kg,height:Ug,id:qg,name:Gg,source:Qg,svg:Jg,terminals:Zg,viewBox:Yg,width:Vg},Symbol.toStringTag,{value:"Module"})),e1="sync-motor",t1="同步电动机",n1="load",o1="-62 -82 64 114",r1=64,s1=114,i1='<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"/>',a1=[{id:"t1",x:-10,y:-80,orientation:"n"},{id:"t2",x:-50,y:-80,orientation:"n"}],l1={kind:"elmt",path:"91_en_60617/en_60617_06/en_60617_06_07/en_60617_06_07_02.elmt",qetEnglishName:"Synchronous motor, single-phase"},T_={id:e1,name:t1,category:n1,viewBox:o1,width:r1,height:s1,svg:i1,terminals:a1,source:l1},A_=Object.freeze(Object.defineProperty({__proto__:null,category:n1,default:T_,height:s1,id:e1,name:t1,source:l1,svg:i1,terminals:a1,viewBox:o1,width:r1},Symbol.toStringTag,{value:"Module"})),c1="synchronoscope",d1="同步表",u1="measurement",m1="同步指示器 / 同步表。",f1="-22 -42 44 44",h1=44,p1=44,g1='<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"/>',y1=[{id:"t_top",x:0,y:-40,orientation:"n"}],x1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_08.elmt",qetEnglishName:"Synchronoscope"},C_={id:c1,name:d1,category:u1,description:m1,viewBox:f1,width:h1,height:p1,svg:g1,terminals:y1,source:x1},I_=Object.freeze(Object.defineProperty({__proto__:null,category:u1,default:C_,description:m1,height:p1,id:c1,name:d1,source:x1,svg:g1,terminals:y1,viewBox:f1,width:h1},Symbol.toStringTag,{value:"Module"})),b1="terminal",w1="接线端子 / 节点 (X)",v1="busbar",k1="接线端子 / 接线盒 / 汇接节点。",_1="-5 -5 10 10",$1=10,S1=10,j1='<ellipse cx="0" cy="0" rx="2.5" ry="2.5" fill="black" stroke="black" stroke-width="1"/>',E1=[{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"}],N1={kind:"elmt",path:"91_en_60617/en_60617_03/en_60617_03_02/en_60617_03_02_02.elmt",qetEnglishName:"Terminal"},P_={id:b1,name:w1,category:v1,description:k1,viewBox:_1,width:$1,height:S1,svg:j1,terminals:E1,source:N1},O_=Object.freeze(Object.defineProperty({__proto__:null,category:v1,default:P_,description:k1,height:S1,id:b1,name:w1,source:N1,svg:j1,terminals:E1,viewBox:_1,width:$1},Symbol.toStringTag,{value:"Module"})),M1="thermal-overload",T1="热过载继电器",A1="motor-control",C1="电机热过载保护继电器, 通常串接在接触器和电机之间。",I1="-9 -32 19 64",P1=19,O1=64,B1='<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"/>',L1=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],z1=[{name:"tripped",type:"boolean",default:!1,label:"动作"}],R1={kind:"inline"},B_={id:M1,name:T1,category:A1,description:C1,viewBox:I1,width:P1,height:O1,svg:B1,terminals:L1,state:z1,source:R1},L_=Object.freeze(Object.defineProperty({__proto__:null,category:A1,default:B_,description:C1,height:O1,id:M1,name:T1,source:R1,state:z1,svg:B1,terminals:L1,viewBox:I1,width:P1},Symbol.toStringTag,{value:"Module"})),D1="thermocouple",F1="热电偶 (BT)",H1="measurement",W1="热电偶温度传感器。",q1="-26 -42 52 46",G1=52,X1=46,K1='<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"/>',Y1=[{id:"t1",x:10,y:-40,orientation:"n"},{id:"t2",x:-10,y:-40,orientation:"n"}],V1={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_06/en_60617_08_06_01.elmt",qetEnglishName:"Thermocouple"},z_={id:D1,name:F1,category:H1,description:W1,viewBox:q1,width:G1,height:X1,svg:K1,terminals:Y1,source:V1},R_=Object.freeze(Object.defineProperty({__proto__:null,category:H1,default:z_,description:W1,height:X1,id:D1,name:F1,source:V1,svg:K1,terminals:Y1,viewBox:q1,width:G1},Symbol.toStringTag,{value:"Module"})),U1="thyristor",J1="晶闸管 (V)",Z1="passive",Q1="反向阻断三极晶闸管 / SCR。t1=阳极(上), t2=阴极(下)。",ey="-22 -42 34 44",ty=34,ny=44,oy='<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"/>',ry=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],sy={x:6,y:-20,anchor:"start"},iy={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)"},D_={id:U1,name:J1,category:Z1,description:Q1,viewBox:ey,width:ty,height:ny,svg:oy,terminals:ry,label:sy,source:iy},F_=Object.freeze(Object.defineProperty({__proto__:null,category:Z1,default:D_,description:Q1,height:ny,id:U1,label:sy,name:J1,source:iy,svg:oy,terminals:ry,viewBox:ey,width:ty},Symbol.toStringTag,{value:"Module"})),ay="time-relay",ly="时间继电器 (KT)",cy="control",dy="延时 (缓动) 继电器线圈。",uy="-32 -22 54 44",my=54,fy=44,hy='<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"/>',py=[{id:"t1",x:0,y:-20,orientation:"n"},{id:"t2",x:0,y:20,orientation:"s"}],gy={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"},H_={id:ay,name:ly,category:cy,description:dy,viewBox:uy,width:my,height:fy,svg:hy,terminals:py,source:gy},W_=Object.freeze(Object.defineProperty({__proto__:null,category:cy,default:H_,description:dy,height:fy,id:ay,name:ly,source:gy,svg:hy,terminals:py,viewBox:uy,width:my},Symbol.toStringTag,{value:"Module"})),yy="transfer-switch",xy="切换开关 (ATS)",by="switching",wy="双源切换开关 (Automatic / Manual Transfer Switch)。两个电源输入 + 一个负荷输出, 互锁不并联。",vy="-27 -32 51 64",ky=51,_y=64,$y='<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"/>',Sy=[{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"}],jy=[{name:"position",type:"string",default:"normal",label:"位置 (normal/emergency/off)"}],Ey={kind:"inline"},q_={id:yy,name:xy,category:by,description:wy,viewBox:vy,width:ky,height:_y,svg:$y,terminals:Sy,state:jy,source:Ey},G_=Object.freeze(Object.defineProperty({__proto__:null,category:by,default:q_,description:wy,height:_y,id:yy,name:xy,source:Ey,state:jy,svg:$y,terminals:Sy,viewBox:vy,width:ky},Symbol.toStringTag,{value:"Module"})),Ny="transformer-2w",My="双绕组变压器",Ty="transformer",Ay="-62 -142 64 144",Cy=64,Iy=144,Py='<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"/>',Oy=[{id:"t1",x:-30,y:-140,orientation:"n"},{id:"t2",x:-30,y:0,orientation:"s"}],By=[{name:"S",label:"容量",type:"number",unit:"MVA",showOnCanvas:!0},{name:"ratio",label:"变比",type:"string",showOnCanvas:!0}],Ly={x:4,y:-68,anchor:"start"},zy={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"},X_={id:Ny,name:My,category:Ty,viewBox:Ay,width:Cy,height:Iy,svg:Py,terminals:Oy,params:By,label:Ly,source:zy},K_=Object.freeze(Object.defineProperty({__proto__:null,category:Ty,default:X_,height:Iy,id:Ny,label:Ly,name:My,params:By,source:zy,svg:Py,terminals:Oy,viewBox:Ay,width:Cy},Symbol.toStringTag,{value:"Module"})),Ry="transformer-3w",Dy="三绕组变压器",Fy="transformer",Hy="-82 -131 114 133",Wy=114,qy=133,Gy='<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"/>',Xy=[{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"}],Ky={x:4,y:-64,anchor:"start"},Yy={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:Ry,name:Dy,category:Fy,viewBox:Hy,width:Wy,height:qy,svg:Gy,terminals:Xy,label:Ky,source:Yy},V_=Object.freeze(Object.defineProperty({__proto__:null,category:Fy,default:Y_,height:qy,id:Ry,label:Ky,name:Dy,source:Yy,svg:Gy,terminals:Xy,viewBox:Hy,width:Wy},Symbol.toStringTag,{value:"Module"})),Vy="triac",Uy="双向晶闸管 (V)",Jy="passive",Zy="双向三极晶闸管 (TRIAC)。",Qy="-22 -42 44 44",ex=44,tx=44,nx='<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"/>',ox=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],rx={x:6,y:-20,anchor:"start"},sx={kind:"elmt",path:"91_en_60617/en_60617_05/en_60617_05_04/en_60617_05_04_11.elmt",qetEnglishName:"Bidirectional triode thyristor; Triac"},U_={id:Vy,name:Uy,category:Jy,description:Zy,viewBox:Qy,width:ex,height:tx,svg:nx,terminals:ox,label:rx,source:sx},J_=Object.freeze(Object.defineProperty({__proto__:null,category:Jy,default:U_,description:Zy,height:tx,id:Vy,label:rx,name:Uy,source:sx,svg:nx,terminals:ox,viewBox:Qy,width:ex},Symbol.toStringTag,{value:"Module"})),ix="undervoltage-relay",ax="欠压继电器 (27)",lx="protection",cx="欠电压保护继电器 (ANSI 27)。",dx="-62 -82 64 84",ux=64,mx=84,fx='<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 <</text>',hx=[{id:"t_top",x:-30,y:-80,orientation:"n"}],px={kind:"elmt",path:"91_en_60617/en_60617_07/en_60617_07_17/en_60617_07_17_07.elmt",qetEnglishName:"Undervoltage relay"},Z_={id:ix,name:ax,category:lx,description:cx,viewBox:dx,width:ux,height:mx,svg:fx,terminals:hx,source:px},Q_=Object.freeze(Object.defineProperty({__proto__:null,category:lx,default:Z_,description:cx,height:mx,id:ix,name:ax,source:px,svg:fx,terminals:hx,viewBox:dx,width:ux},Symbol.toStringTag,{value:"Module"})),gx="ups",yx="不间断电源 (UPS)",xx="source",bx="在线 / 后备式不间断电源。",wx="-26 -42 52 84",vx=52,kx=84,_x='<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"/>',$x=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Sx=[{name:"S",label:"容量",type:"number",unit:"kVA"}],jx={kind:"inline"},e$={id:gx,name:yx,category:xx,description:bx,viewBox:wx,width:vx,height:kx,svg:_x,terminals:$x,params:Sx,source:jx},t$=Object.freeze(Object.defineProperty({__proto__:null,category:xx,default:e$,description:bx,height:kx,id:gx,name:yx,params:Sx,source:jx,svg:_x,terminals:$x,viewBox:wx,width:vx},Symbol.toStringTag,{value:"Module"})),Ex="varmeter",Nx="无功功率表 (var)",Mx="measurement",Tx="无功功率表 (var)。",Ax="-22 -42 44 44",Cx=44,Ix=44,Px='<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>',Ox=[{id:"t_top",x:0,y:-40,orientation:"n"}],Bx={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_04.elmt",qetEnglishName:"Varmeter"},n$={id:Ex,name:Nx,category:Mx,description:Tx,viewBox:Ax,width:Cx,height:Ix,svg:Px,terminals:Ox,source:Bx},o$=Object.freeze(Object.defineProperty({__proto__:null,category:Mx,default:n$,description:Tx,height:Ix,id:Ex,name:Nx,source:Bx,svg:Px,terminals:Ox,viewBox:Ax,width:Cx},Symbol.toStringTag,{value:"Module"})),Lx="vfd",zx="变频器 (VFD)",Rx="motor-control",Dx="Variable Frequency Drive — 异步电动机调速。",Fx="-24 -42 48 84",Hx=48,Wx=84,qx='<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"/>',Gx=[{id:"t_in",x:0,y:-40,orientation:"n"},{id:"t_out",x:0,y:40,orientation:"s"}],Xx={kind:"inline"},r$={id:Lx,name:zx,category:Rx,description:Dx,viewBox:Fx,width:Hx,height:Wx,svg:qx,terminals:Gx,source:Xx},s$=Object.freeze(Object.defineProperty({__proto__:null,category:Rx,default:r$,description:Dx,height:Wx,id:Lx,name:zx,source:Xx,svg:qx,terminals:Gx,viewBox:Fx,width:Hx},Symbol.toStringTag,{value:"Module"})),Kx="voltage-regulator",Yx="调压器 (T)",Vx="transformer",Ux="可调感应调压器 / 自耦调压器。",Jx="-17 -32 38 64",Zx=38,Qx=64,eb='<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"/>',tb=[{id:"t1",x:0,y:-30,orientation:"n"},{id:"t2",x:0,y:30,orientation:"s"}],nb=[{name:"ratio",label:"调压范围",type:"string",showOnCanvas:!0}],ob={kind:"elmt",path:"11_singlepole/340_converters_inverters/10_converters/regulator_ind_3f_1.elmt",qetEnglishName:"Voltage regulator"},i$={id:Kx,name:Yx,category:Vx,description:Ux,viewBox:Jx,width:Zx,height:Qx,svg:eb,terminals:tb,params:nb,source:ob},a$=Object.freeze(Object.defineProperty({__proto__:null,category:Vx,default:i$,description:Ux,height:Qx,id:Kx,name:Yx,params:nb,source:ob,svg:eb,terminals:tb,viewBox:Jx,width:Zx},Symbol.toStringTag,{value:"Module"})),rb="voltmeter",sb="电压表 (V)",ib="measurement",ab="-22 -42 44 44",lb=44,cb=44,db='<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>',ub=[{id:"t_top",x:0,y:-40,orientation:"n"}],mb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_02/en_60617_08_02_01.elmt",qetEnglishName:"Voltmeter"},l$={id:rb,name:sb,category:ib,viewBox:ab,width:lb,height:cb,svg:db,terminals:ub,source:mb},c$=Object.freeze(Object.defineProperty({__proto__:null,category:ib,default:l$,height:cb,id:rb,name:sb,source:mb,svg:db,terminals:ub,viewBox:ab,width:lb},Symbol.toStringTag,{value:"Module"})),fb="wattmeter",hb="功率表 (W)",pb="measurement",gb="-22 -42 44 44",yb=44,xb=44,bb='<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>',wb=[{id:"t_top",x:0,y:-40,orientation:"n"}],vb={kind:"elmt",path:"91_en_60617/en_60617_08/en_60617_08_03/en_60617_08_03_01.elmt",qetEnglishName:"Recording wattmeter"},d$={id:fb,name:hb,category:pb,viewBox:gb,width:yb,height:xb,svg:bb,terminals:wb,source:vb},u$=Object.freeze(Object.defineProperty({__proto__:null,category:pb,default:d$,height:xb,id:fb,name:hb,source:vb,svg:bb,terminals:wb,viewBox:gb,width:yb},Symbol.toStringTag,{value:"Module"})),kb="wind-turbine",_b="风力发电机",$b="renewable",Sb="风机:发电机 + 三叶轮标记",jb="-22 -46 44 68",Eb=44,Nb=68,Mb='<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"/>',Tb=[{id:"t_bottom",x:0,y:20,orientation:"s"}],Ab={kind:"inline"},m$={id:kb,name:_b,category:$b,description:Sb,viewBox:jb,width:Eb,height:Nb,svg:Mb,terminals:Tb,source:Ab},f$=Object.freeze(Object.defineProperty({__proto__:null,category:$b,default:m$,description:Sb,height:Nb,id:kb,name:_b,source:Ab,svg:Mb,terminals:Tb,viewBox:jb,width:Eb},Symbol.toStringTag,{value:"Module"})),Cb="zener-diode",Ib="稳压二极管 (D)",Pb="passive",Ob="齐纳 / 稳压二极管。t1=阳极(上), t2=阴极(下)。",Bb="-12 -42 24 44",Lb=24,zb=44,Rb='<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"/>',Db=[{id:"t1",x:0,y:-40,orientation:"n"},{id:"t2",x:0,y:0,orientation:"s"}],Fb={x:6,y:-20,anchor:"start"},Hb={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"},h$={id:Cb,name:Ib,category:Pb,description:Ob,viewBox:Bb,width:Lb,height:zb,svg:Rb,terminals:Db,label:Fb,source:Hb},p$=Object.freeze(Object.defineProperty({__proto__:null,category:Pb,default:h$,description:Ob,height:zb,id:Cb,label:Fb,name:Ib,source:Hb,svg:Rb,terminals:Db,viewBox:Bb,width:Lb},Symbol.toStringTag,{value:"Module"})),g$=Object.assign({"./ammeter.json":o2,"./arc-suppression-coil.json":s2,"./arrester.json":a2,"./async-motor.json":c2,"./autotransformer.json":u2,"./battery.json":f2,"./bell.json":p2,"./break-contact.json":y2,"./breaker.json":b2,"./buchholz-relay.json":v2,"./busbar.json":_2,"./buzzer.json":S2,"./capacitor.json":E2,"./contactor.json":M2,"./converter-bidir.json":A2,"./ct.json":I2,"./dc-combiner.json":O2,"./dc-disconnector.json":L2,"./dc-motor.json":R2,"./diode.json":F2,"./disconnector.json":W2,"./distance-relay.json":G2,"./earth.json":K2,"./earthing-switch.json":V2,"./energy-meter.json":J2,"./ev-charger.json":Q2,"./frequency-meter.json":tk,"./fuse-switch-disconnector.json":ok,"./fuse.json":sk,"./generator.json":ak,"./genset.json":ck,"./gfci-breaker.json":uk,"./grid-source.json":fk,"./grounding-transformer.json":pk,"./heater.json":yk,"./igbt.json":bk,"./indicator-light.json":vk,"./inductor.json":_k,"./inverter.json":Sk,"./limit-switch.json":Ek,"./load-switch.json":Mk,"./load.json":Ak,"./make-contact.json":Ik,"./motor-starter.json":Ok,"./ngr.json":Lk,"./overcurrent-relay.json":Rk,"./phase-failure-relay.json":Fk,"./plc.json":Wk,"./power-factor-meter.json":Gk,"./power-supply.json":Kk,"./protective-relay.json":Vk,"./proximity-switch.json":Jk,"./pt.json":Qk,"./push-button.json":t_,"./pv.json":o_,"./rcd.json":s_,"./recloser.json":a_,"./rectifier.json":c_,"./relay-coil.json":u_,"./resistor.json":f_,"./reverse-power-relay.json":p_,"./selector-switch.json":y_,"./series-reactor.json":b_,"./shunt-capacitor.json":v_,"./shunt-reactor.json":__,"./siren.json":S_,"./socket-outlet.json":E_,"./soft-starter.json":M_,"./sync-motor.json":A_,"./synchronoscope.json":I_,"./terminal.json":O_,"./thermal-overload.json":L_,"./thermocouple.json":R_,"./thyristor.json":F_,"./time-relay.json":W_,"./transfer-switch.json":G_,"./transformer-2w.json":K_,"./transformer-3w.json":V_,"./triac.json":J_,"./undervoltage-relay.json":Q_,"./ups.json":t$,"./varmeter.json":o$,"./vfd.json":s$,"./voltage-regulator.json":a$,"./voltmeter.json":c$,"./wattmeter.json":u$,"./wind-turbine.json":f$,"./zener-diode.json":p$}),Wb=Object.values(g$).map(e=>e.default),Xe=Object.fromEntries(Wb.map(e=>[e.id,e])),Bo=["busbar","switching","protection","motor-control","control","transformer","instrument-transformer","measurement","source","load","storage","compensation","passive","grounding","renewable"],y$=(()=>{var t;const e={};for(const n of Wb)(e[t=n.category]??(e[t]=[])).push(n);return e})(),En=new Map(Object.entries(Xe));function qb(e){return Xe[e]}function x$(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 b$=320;function qe(e){var h,g,w,E,k;const t=Jr(),n=new Map;e.elements.forEach((b,$)=>{if(n.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/elements/${$}`});return}n.set(b.id,b);const A=En.get(b.kind);A||t.diagnostics.push({code:"E003",severity:"error",message:`${we("compile.unknownKind",{kind:b.kind})} (id=${b.id})`,pointer:`/elements/${$}`}),t.elements.set(b.id,{element:b,libraryDef:A})});const o=new Map,r=new Map;(e.buses??[]).forEach((b,$)=>{if(n.has(b.id)||o.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/buses/${$}`});return}if(o.set(b.id,b),b.layout){const A=b.layout.rot??0;r.set(b.id,{at:b.layout.at,span:b.layout.span,rot:A,axis:Sn(A)})}});const s=new Map;(e.junctions??[]).forEach((b,$)=>{if(n.has(b.id)||o.has(b.id)||s.has(b.id)){t.diagnostics.push({code:"E001",severity:"error",message:we("compile.duplicateId",{id:b.id}),pointer:`/junctions/${$}`});return}s.set(b.id,b)});const i=b=>!b.includes(".")&&o.has(b),a=b=>!b.includes(".")&&s.has(b),l=(b,$)=>{if(i(b)||a(b))return!0;const A=b.indexOf(".");if(A<=0)return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.invalidTermRef",{ref:b}),pointer:$}),!1;const B=b.slice(0,A),W=b.slice(A+1),K=t.elements.get(B);if(!K)return t.diagnostics.push({code:"E002",severity:"error",message:we("compile.elementMissing",{id:B}),pointer:$}),!1;if(!K.libraryDef)return!1;if(!K.libraryDef.terminals.find(oe=>oe.id===W)){const oe=K.libraryDef.terminals.map(ie=>ie.id).join(", ");return t.diagnostics.push({code:"E003",severity:"error",message:we("compile.missingPin",{id:B,kind:K.element.kind,pin:W,available:oe}),pointer:$}),!1}return!0},u=[];(e.wires??[]).forEach((b,$)=>{const A=`/wires/${$}`,B=l(b.ends[0],A),W=l(b.ends[1],A);B&&W&&u.push(b)});const d=new Map;if(e.layout)for(const[b,$]of Object.entries(e.layout))t.elements.has(b)?d.set(b,Zr($)):t.diagnostics.push({code:"E004",severity:"error",message:we("compile.layoutMissingElement",{id:b}),pointer:`/layout/${b}`});const m=e2({elements:e.elements,buses:e.buses??[],wires:u,library:En,userLayout:d,userBusLayout:r});t.layout=m.devices;for(const[b,$]of m.buses){const A=o.get(b);A&&t.buses.set(b,{bus:A,geometry:$})}for(const[b,$]of o)t.buses.has(b)||t.buses.set(b,{bus:$,geometry:{at:((h=$.layout)==null?void 0:h.at)??[0,0],span:((g=$.layout)==null?void 0:g.span)??b$,rot:((w=$.layout)==null?void 0:w.rot)??0,axis:Sn(((E=$.layout)==null?void 0:E.rot)??0)}});for(const b of t.elements.values()){if(!b.libraryDef)continue;const $=t.layout.get(b.element.id);if(!$)continue;const A=[];for(const B of b.libraryDef.terminals){const W=`${b.element.id}.${B.id}`,K=Ae([B.x,B.y],$),oe=_t(B.orientation,$);t.terminals.set(W,{ref:W,elementId:b.element.id,pin:B.id,world:K,orientation:oe}),A.push(W)}t.elementToTerminals.set(b.element.id,A)}const f=b=>{if(!b.includes(".")){const A=t.buses.get(b);return A?A.geometry.at:null}const $=t.terminals.get(b);return $?$.world:null};for(const[b,$]of s){let A;if((k=$.layout)!=null&&k.at)A=[$.layout.at[0],$.layout.at[1]];else{const B=[];for(const W of u){const[K,oe]=W.ends,ie=K===b?oe:oe===b?K:null;if(ie===null)continue;const R=f(ie);R&&B.push(R)}A=B.length?[B.reduce((W,K)=>W+K[0],0)/B.length,B.reduce((W,K)=>W+K[1],0)/B.length]:[0,0]}t.junctions.set(b,{junction:$,world:A})}const p=new Qr;for(const b of u)p.add(b.ends[0]),p.add(b.ends[1]),p.union(b.ends[0],b.ends[1]);for(const[,b]of p.groups()){const $=x$(b);t.nodes.set($,{id:$,terminals:b});for(const A of b)t.terminalToNode.set(A,$)}for(const b of t.elements.values()){const $=t.elementToTerminals.get(b.element.id)??[];if($.length===0)continue;$.some(B=>t.terminalToNode.has(B))||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b.element.id})})}for(const b of t.buses.keys())t.terminalToNode.has(b)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b})});for(const b of t.junctions.keys())t.terminalToNode.has(b)||t.diagnostics.push({code:"W001",severity:"warning",message:we("compile.elementUnconnected",{id:b})});for(const b of u){if(b.path&&b.path.length>=2){const A=b.path,B=A.length>=2?A[1]:null,W=A.length>=2?A[A.length-2]:null,K=Po(b.ends[0],B,t),oe=Po(b.ends[1],W,t);if(K&&oe){const ie=[[K[0],K[1]],...A.slice(1,-1).map(F=>[F[0],F[1]]),[oe[0],oe[1]]],R=Ur(ie);if(R.length>=2){t.wireRenders.set(b.id,{wireId:b.id,path:R,userEdited:!0});continue}}}const $=t2(b,t);$&&t.wireRenders.set(b.id,$)}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"},Lo="B",zo="J";function Gn(e){return new Set([...e.elements.map(t=>t.id),...(e.buses??[]).map(t=>t.id),...(e.junctions??[]).map(t=>t.id)])}function jt(e,t){const n=w$[t]??t,o=Gn(e);let r=1;for(;o.has(`${n}${r}`);)r++;return`${n}${r}`}function Nn(e){const t=Gn(e);let n=1;for(;t.has(`${Lo}${n}`);)n++;return`${Lo}${n}`}function Mn(e){const t=Gn(e);let n=1;for(;t.has(`${zo}${n}`);)n++;return`${zo}${n}`}function v$(e){const t=new Set((e.annotations??[]).map(o=>o.id));let n=1;for(;t.has(`a${n}`);)n++;return`a${n}`}function Ue(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)}`}const Ro={version:"1",elements:[]},k$=100,Do=20;function _$(){if(typeof window>"u")return"select";try{return window.matchMedia("(pointer: coarse)").matches?"pan":"select"}catch{return"select"}}const x=Xt()(Kv((e,t)=>({diagram:Ro,internal:qe(Ro),fileSession:null,activeTool:_$(),placeKind:null,lastPlaceKind:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null,busbarDrawStart:null,cursorSvg:null,selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,past:[],future:[],clipboard:null,clipboardPasteIndex:0,setDiagram:n=>e({diagram:n,internal:qe(n),past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation:null,editingElement:null,wireFromTerminal:null,wireDragFrom:null,placeFromTerminal:null}),setFileSession:n=>e({fileSession:n}),loadDiagramFromFile:(n,o)=>e({diagram:n,internal:qe(n),fileSession:o,past:[],future:[],selection:[],selectedWire:null,selectedNode:null,selectedAnnotation:null,editingAnnotation: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>=k$?r.slice(1):r;e({diagram:s,internal:qe(s),past:[...i,o],future:[]})},undo:()=>{const{past:n,future:o,diagram:r}=t();if(n.length===0)return;const s=n[n.length-1];e({diagram:s,internal:qe(s),past:n.slice(0,-1),future:[...o,r],wireFromTerminal:null,wireDragFrom:null,placeFromTerminal: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:qe(s),past:[...n,r],future:o.slice(0,-1),wireFromTerminal:null,wireDragFrom:null,placeFromTerminal: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})},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:$$(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,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}),setEditingAnnotation:n=>e({editingAnnotation:n,selectedAnnotation:n??t().selectedAnnotation,editingElement:n?null:t().editingElement}),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 f;const{selection:n,diagram:o,internal:r}=t();if(n.length===0)return;const s=new Set(n),i=o.elements.filter(p=>s.has(p.id)).map(p=>structuredClone(p)),a=(o.buses??[]).filter(p=>s.has(p.id)).map(p=>structuredClone(p)),l=(o.junctions??[]).filter(p=>s.has(p.id)).map(p=>{var g;const h=structuredClone(p);if(!h.layout){const w=(g=r.junctions.get(p.id))==null?void 0:g.world;w&&(h.layout={at:[w[0],w[1]]})}return h}),u={};for(const p of n)if(s.has(p)&&!r.buses.has(p)){const h=(f=o.layout)==null?void 0:f[p];if(h){u[p]=structuredClone(h);continue}const g=r.layout.get(p);g&&(u[p]=Ct(g))}const d={};for(const p of n){const h=r.buses.get(p);h&&(d[p]=et(h.geometry))}const m=(o.wires??[]).filter(p=>p.ends.every(h=>s.has(un(h)))).map(p=>structuredClone(p));e({clipboard:{elements:i,buses:a,junctions:l,placements:u,busLayouts:d,wires:m},clipboardPasteIndex:0})},cutSelection:()=>{const{selection:n}=t();n.length!==0&&(t().copySelection(),t().deleteSelection())},pasteClipboard:()=>{const{clipboard:n,clipboardPasteIndex:o,diagram:r}=t();if(!n||n.elements.length===0&&n.buses.length===0&&n.junctions.length===0)return;const s=o+1,i=Do*s,a=Do*s,l=new Map;let u=r;for(const m of n.elements){const f=jt(u,m.kind);l.set(m.id,f),u={...u,elements:[...u.elements,{id:f,kind:m.kind}]}}for(const m of n.buses){const f=Nn(u);l.set(m.id,f),u={...u,buses:[...u.buses??[],{id:f}]}}for(const m of n.junctions){const f=Mn(u);l.set(m.id,f),u={...u,junctions:[...u.junctions??[],{id:f}]}}const d=m=>{const f=m.indexOf("."),p=f<0?m:m.slice(0,f),h=l.get(p);return h?f<0?h:`${h}${m.slice(f)}`:m};t().dispatch(m=>{const f=n.elements.map(k=>{const b=structuredClone(k);return b.id=l.get(k.id),b}),p=n.buses.map(k=>{const b=structuredClone(k);b.id=l.get(k.id);const $=n.busLayouts[k.id];return $&&(b.layout={...$,at:[$.at[0]+i,$.at[1]+a]}),b}),h=n.junctions.map(k=>{const b=structuredClone(k);return b.id=l.get(k.id),b.layout&&(b.layout={at:[b.layout.at[0]+i,b.layout.at[1]+a]}),b}),g={...m.layout??{}};for(const[k,b]of l){const $=n.placements[k];$&&(g[b]={...$,at:[$.at[0]+i,$.at[1]+a]})}const w=n.wires.map(k=>{const b=[d(k.ends[0]),d(k.ends[1])];return{id:Ue(b[0],b[1]),ends:b}}),E=Fo(m.wires??[],w);return{...m,elements:[...m.elements,...f],buses:p.length?[...m.buses??[],...p]:m.buses,junctions:h.length?[...m.junctions??[],...h]:m.junctions,wires:E.length?E:void 0,layout:Object.keys(g).length?g: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(u=>u.layout);if(!o&&!r)return n;const{layout:s,...i}=n,a=(l=n.buses)==null?void 0:l.map(u=>{const{layout:d,...m}=u;return m});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[u,d]of Object.entries(i)){if(o.has(u)){s=!0;continue}l[u]=d}s&&(i=Object.keys(l).length?l:void 0)}let a=r.buses;if(a){const l=a.map(u=>{if(o.has(u.id)&&u.layout){s=!0;const{layout:d,...m}=u;return m}return u});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 u=n.layout.get(l.id);u&&(s[l.id]=Ct(u))}const i=[];if((o.buses??[]).forEach((l,u)=>{l.layout||n.buses.has(l.id)&&i.push({idx:u,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 u=n.buses.get(l.id);return!l.layout&&u?{...l,layout:et(u.geometry)}:l})),{...o,layout:{...r,...s},buses:a}})},fillUnplacedSelection:()=>{const{selection:n,internal:o}=t();n.length!==0&&t().dispatch(r=>{var u;const s=r.layout??{},i={},a=new Map;for(const d of n)if(o.buses.has(d)){const m=o.buses.get(d);(u=r.buses)!=null&&u.find(f=>f.id===d&&f.layout)||a.set(d,et(m.geometry))}else{if(s[d])continue;const m=o.layout.get(d);m&&(i[d]=Ct(m))}if(Object.keys(i).length===0&&a.size===0)return r;let l=r.buses;return a.size>0&&l&&(l=l.map(d=>a.has(d.id)?{...d,layout:a.get(d.id)}:d)),{...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[d,m]of n){if(o.buses.has(d)){i.set(d,m);continue}if(o.junctions.has(d)){a.set(d,m);continue}const f=o.layout.get(d),p=s[d]??(f?Ct(f):{at:[0,0]});s[d]={...p,at:[p.at[0]+m[0],p.at[1]+m[1]]}}let l=r.buses;i.size>0&&(l=(r.buses??[]).map(d=>{const m=i.get(d.id);if(!m)return d;const f=d.layout??et(o.buses.get(d.id).geometry);return{...d,layout:{...f,at:[f.at[0]+m[0],f.at[1]+m[1]]}}}));let u=r.junctions;return a.size>0&&(u=(r.junctions??[]).map(d=>{var p,h;const m=a.get(d.id);if(!m)return d;const f=((p=d.layout)==null?void 0:p.at)??((h=o.junctions.get(d.id))==null?void 0:h.world)??[0,0];return{...d,layout:{at:[f[0]+m[0],f[1]+m[1]]}}})),{...r,layout:s,buses:l,junctions:u}})},deleteSelection:()=>{const{selection:n}=t();if(n.length===0)return;const o=new Set(n);t().dispatch(r=>{const s=r.elements.filter(d=>!o.has(d.id)),i=(r.buses??[]).filter(d=>!o.has(d.id)),a=(r.junctions??[]).filter(d=>!o.has(d.id)),l=(r.wires??[]).filter(d=>!o.has(un(d.ends[0]))&&!o.has(un(d.ends[1]))),u=r.layout?Object.fromEntries(Object.entries(r.layout).filter(([d])=>!o.has(d))):void 0;return{...r,elements:s,buses:i.length?i:void 0,junctions:a.length?a: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??[]).filter(u=>u.id!==n);if(a.length===(i.wires??[]).length)return i;const l={...i.layout??{}};for(const u of s){if(l[u])continue;const d=o.layout.get(u);if(!d)continue;const m={at:d.at};d.rot&&(m.rot=d.rot),d.mirror&&(m.mirror=d.mirror),l[u]=m}return{...i,wires:a.length?a:void 0,layout:Object.keys(l).length?l: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 d of i){if(l[d])continue;const m=o.layout.get(d);if(!m)continue;const f={at:m.at};m.rot&&(f.rot=m.rot),m.mirror&&(f.mirror=m.mirror),l[d]=f}const u=(a.wires??[]).filter(d=>!s.has(d.ends[0])&&!s.has(d.ends[1]));return{...a,wires:u.length?u: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 u,d,m,f;const i={...s.layout??{}},a=new Map;for(const p of o){if(r.junctions.has(p))continue;if(r.buses.has(p)){const w=r.buses.get(p),k=(((((m=(d=(u=s.buses)==null?void 0:u.find(b=>b.id===p))==null?void 0:d.layout)==null?void 0:m.rot)??w.geometry.rot??0)+n)%360+360)%360;a.set(p,k);continue}const h=i[p]??{at:((f=r.layout.get(p))==null?void 0:f.at)??[0,0]},g=(((h.rot??0)+n)%360+360)%360;i[p]={...h,rot:g}}let l=s.buses;return a.size>0&&(l=(s.buses??[]).map(p=>{if(!a.has(p.id))return p;const h=p.layout??et(r.buses.get(p.id).geometry);return{...p,layout:{...h,rot:a.get(p.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=jt(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=Nn(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=Mn(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=Ue(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(h=>h.id),...(s.buses??[]).map(h=>h.id),...(s.junctions??[]).map(h=>h.id)]),a=()=>{let h=1;for(;i.has(`J${h}`);)h++;const g=`J${h}`;return i.add(g),g},l=h=>{const g=a();return s={...s,junctions:[...s.junctions??[],{id:g,layout:{at:h}}]},g},u=h=>{if("end"in h)return h.end;if("junctionAt"in h)return l(h.junctionAt);const g=(s.wires??[]).find(b=>b.id===h.onWire),w=l(h.at);if(!g)return w;const E=(s.wires??[]).filter(b=>b.id!==h.onWire),k=(b,$)=>({id:Ue(b,$),ends:[b,$]});return s={...s,wires:Fo(E,[k(g.ends[0],w),k(w,g.ends[1])])},w},d=u(n),m=u(o);if(d===null||m===null||d===m)return s;const f=Ue(d,m),p=s.wires??[];return p.some(h=>h.id===f)?s:{...s,wires:[...p,{id:f,ends:[d,m]}]}})},updateWirePath:(n,o)=>{t().dispatch(r=>{const s=r.wires??[];if(!s.some(u=>u.id===n))return r;const i=o&&o.length>=2?Ur(o):null,a=i&&i.length>=2?i:null,l=s.map(u=>{if(u.id!==n)return u;if(a)return{...u,path:a};const{path:d,...m}=u;return m});return{...r,wires:l}})},resetWirePath:n=>{t().updateWirePath(n,null)},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)?et(a.buses.get(n).geometry):{at:[0,0],span:320}),u={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:u}});return{...r,buses:s}})},addAnnotation:(n,o="")=>{const r=v$(t().diagram);return t().dispatch(s=>{const i={id:r,at:n,text:o};return{...s,annotations:[...s.annotations??[],i]}}),r},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=>{t().dispatch(o=>{const r=o.annotations??[],s=r.filter(i=>i.id!==n);return s.length===r.length?o:{...o,annotations:s.length?s:void 0}}),t().selectedAnnotation===n&&e({selectedAnnotation:null,editingAnnotation:null})}}),{name:"ole-editor",version:2,storage:Vr(()=>localStorage),partialize:e=>({diagram:e.diagram,activeTool:e.activeTool,placeKind:e.placeKind,lastPlaceKind:e.lastPlaceKind}),onRehydrateStorage:()=>e=>{e!=null&&e.diagram&&(e.internal=qe(e.diagram))}}));function $$(e){return Array.from(new Set(e))}function un(e){const t=e.indexOf(".");return t<0?e:e.slice(0,t)}function Fo(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 Ct(e){return{at:[e.at[0],e.at[1]],...e.rot?{rot:e.rot}:{},...e.mirror?{mirror:e.mirror}:{}}}function et(e){return{at:[e.at[0],e.at[1]],span:e.span,...e.rot?{rot:e.rot}:{}}}let Gb=null;function Ho(e){Gb=e}function Je(){return Gb}const Ft=10;function Xb(){if(typeof document>"u")return!0;const e=document.querySelector(".ole-canvas-root");return!!e&&!e.classList.contains("hide-grid")}function se(e){return Xb()?Math.round(e/Ft)*Ft:e}const S$=30,j$=144;function Kb(e,t){const n=Xe[e],o=x.getState(),r=o.diagram;if(!n||e==="busbar")return{newElementId:o.addElement(e,t),attachedToBus:!1};const s=E$(r,t);if(!s){const g=Yb(n),w=g?[se(t[0])-g.x,se(t[1])-g.y]:[se(t[0]),se(t[1])];return{newElementId:o.addElement(e,w),attachedToBus:!1}}const{busId:i,busAt:a,axis:l}=s,u=N$(n,l),d=jt(r,e),m=n.terminals.find(g=>g.id===u),f=l==="x"?t[0]:a[0],p=l==="y"?t[1]:a[1],h=m?[se(f)-m.x,se(p)-m.y]:[se(t[0]),se(t[1])];return o.dispatch(g=>{const w={id:d,kind:e},E={at:h},k=`${d}.${u}`,b={id:Ue(i,k),ends:[i,k]};return{...g,elements:[...g.elements,w],wires:[...g.wires??[],b],layout:{...g.layout??{},[d]:E}}}),o.setSelection([d]),{newElementId:d,attachedToBus:!0}}function E$(e,t){const n=x.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 u;if(i==="x"){const d=a[0]-l/2,m=a[0]+l/2,f=t[0]<d?d-t[0]:t[0]>m?t[0]-m:0,p=Math.abs(t[1]-a[1]);u=Math.sqrt(f*f+p*p)}else{const d=a[1]-l/2,m=a[1]+l/2,f=t[1]<d?d-t[1]:t[1]>m?t[1]-m:0,p=Math.abs(t[0]-a[0]);u=Math.sqrt(p*p+f*f)}u<=S$&&(!o||u<o.dist)&&(o={busId:r.id,busAt:[a[0],a[1]],axis:i,dist:u})}return o?{busId:o.busId,busAt:o.busAt,axis:o.axis}:null}function N$(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 Yb(e){return!e||e.stretchable||e.terminals.length===0?null:[...e.terminals].sort((n,o)=>n.y-o.y)[0]}function Vb(e,t){const n=x.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 p=i[0]-a/2,h=i[0]+a/2,g=Math.max(p,Math.min(h,t[0])),w=i[1],E=t[1]>=w?"s":"n";return{ref:e,world:[g,w],orientation:E,isBus:!0,busId:e}}const l=i[1]-a/2,u=i[1]+a/2,d=Math.max(l,Math.min(u,t[1])),m=i[0],f=t[0]>=m?"e":"w";return{ref:e,world:[m,d],orientation:f,isBus:!0,busId:e}}const o=n.terminals.get(e);return o?{ref:e,world:o.world,orientation:o.orientation,isBus:!1}:null}const M$={n:"s",s:"n",e:"w",w:"e"};function Ub(e,t,n){if(e.terminals.length===0)return{id:"t",x:0,y:0,orientation:"n"};const o=M$[t.orientation],r=e.terminals.filter(l=>l.orientation===o),s=r.length>0?r:e.terminals;let i=s[0],a=Wo(i,n,t.world);for(let l=1;l<s.length;l++){const u=s[l],d=Wo(u,n,t.world);d<a&&(a=d,i=u)}return i}function Wo(e,t,n){const o=t[0]+e.x-n[0],r=t[1]+e.y-n[1];return o*o+r*r}function T$(e,t,n){const o=Xe[e],r=x.getState(),s=r.diagram;if(!o)return null;const i=Vb(t,n);if(!i)return null;const a=n[0]-i.world[0],l=n[1]-i.world[1],u=a*a+l*l<=j$,d=[se(n[0]),se(n[1])],m=Ub(o,i,d),f=u?i.world:d,p=[se(f[0]-m.x),se(f[1]-m.y)],h=jt(s,e);return r.dispatch(g=>{const w={id:h,kind:e},E={at:p},k=`${h}.${m.id}`,b=i.isBus&&i.busId?i.busId:t,$={id:Ue(b,k),ends:[b,k]};return{...g,elements:[...g.elements,w],wires:[...g.wires??[],$],layout:{...g.layout??{},[h]:E}}}),r.setSelection([h]),{newElementId:h,attachedToBus:i.isBus}}const Kt=9,Ht=7;function Yt(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 Vt(e){const t=A$(e.viewBox);return t?{x:t.x+t.w+2,y:t.y+4,anchor:"start"}:{x:0,y:0,anchor:"start"}}function Ut(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 A$(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 C$(){const e=x(r=>r.internal.elements),t=x(r=>r.internal.layout),n=x(r=>{var s;return((s=r.diagram.meta)==null?void 0:s.labelMode)??"all"}),o=x(r=>r.editingElement);return c.jsx("g",{className:"ole-annotation-layer",pointerEvents:"none",children:Array.from(e.values()).map(r=>{var d;const s=t.get(r.element.id);if(!s||!r.libraryDef)return null;const i=r.libraryDef.label??Vt(r.libraryDef),a=Ut(i,s),l=i.anchor??"start";if(o===r.element.id)return c.jsx(I$,{elementId:r.element.id,currentName:((d=r.element.name)==null?void 0:d.trim())||r.element.id,world:a,anchor:l},r.element.id);if(n==="off")return null;const u=Yt(r,n);return u.length===0?null:c.jsx("g",{className:"ole-annotation",transform:`translate(${a[0]} ${a[1]})`,children:u.map((m,f)=>c.jsx("text",{x:0,y:f*Kt,textAnchor:l,className:"ole-annotation-text",children:m},f))},r.element.id)})})}const mn=200,fn=9;function I$({elementId:e,currentName:t,world:n,anchor:o}){const r=O.useRef(null);O.useEffect(()=>{const l=r.current;if(!l)return;l.focus();const u=document.createRange();u.selectNodeContents(l);const d=window.getSelection();d==null||d.removeAllRanges(),d==null||d.addRange(u)},[e]);function s(){var f;const l=x.getState(),u=l.diagram.elements.find(p=>p.id===e);if(!u){l.setEditingElement(null);return}const d=(((f=r.current)==null?void 0:f.innerText)??"").replace(/\u00a0/g," ").trim(),m=d===""||d===e?void 0:d;m!==u.name&&l.updateElement(e,{name:m}),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-=mn/2:o==="end"&&(a-=mn),c.jsx("foreignObject",{x:a,y:n[1]-fn,width:mn,height:fn*2.2,className:"ole-element-name-editor",children:c.jsx("div",{ref:r,contentEditable:!0,suppressContentEditableWarning:!0,onBlur:s,onKeyDown:i,onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),style:{fontSize:`${fn}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})})}const Jb=8,Wt=1.25;function P$(){const e=x(o=>o.diagram.annotations),t=x(o=>o.selectedAnnotation),n=x(o=>o.editingAnnotation);return!e||e.length===0?null:c.jsx("g",{className:"ole-free-annotation-layer",children:e.map(o=>n===o.id?c.jsx(B$,{ann:o},o.id):c.jsx(O$,{ann:o,isSelected:t===o.id},o.id))})}function O$({ann:e,isSelected:t}){const n=e.fontSize??Jb,o=e.text===""?[""]:e.text.split(`
|
|
198
|
+
`),r=Math.max(20,...o.map(i=>i.length*n*.55)),s=o.length*n*Wt;return c.jsxs("g",{"data-annotation-id":e.id,className:"ole-free-annotation","data-selected":t?"true":void 0,children:[c.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&&c.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)=>c.jsx("text",{x:e.at[0],y:e.at[1]+n*.85+a*n*Wt,fontSize:n,className:"ole-free-annotation-text",children:i},a))]})}function B$({ann:e}){const t=O.useRef(null),n=e.fontSize??Jb;O.useEffect(()=>{const a=t.current;if(!a)return;a.focus();const l=document.createRange();l.selectNodeContents(a);const u=window.getSelection();u==null||u.removeAllRanges(),u==null||u.addRange(l)},[e.id]);function o(){var u;const a=x.getState(),l=(((u=t.current)==null?void 0:u.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(),o();return}if(a.key==="Enter"&&!a.shiftKey){a.preventDefault(),o();return}a.stopPropagation()}return c.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:c.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:Wt,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*Wt}px`,whiteSpace:"pre-wrap",wordBreak:"break-word",cursor:"text"},children:e.text})})}const L$=20;function z$(){const e=x(d=>d.selection),t=x(d=>d.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],u=r==="x"?[s[0]+a,s[1]]:[s[0],s[1]+a];return c.jsxs("g",{className:"ole-bus-handles",pointerEvents:"auto",children:[c.jsx(qo,{x:l[0],y:l[1],busId:n,side:"start",axis:r}),c.jsx(qo,{x:u[0],y:u[1],busId:n,side:"end",axis:r})]})}function qo({x:e,y:t,busId:n,side:o,axis:r}){const s=Je(),i=O.useRef(null),a=d=>{if(d.button!==0||(d.stopPropagation(),d.preventDefault(),!s))return;const m=x.getState().internal.buses.get(n);m&&(i.current={pointerId:d.pointerId,startSpan:m.geometry.span,startAt:[...m.geometry.at],startSvg:s.screenToSvg(d.clientX,d.clientY)},d.target.setPointerCapture(d.pointerId))},l=d=>{const m=i.current;if(!m||d.pointerId!==m.pointerId||!s)return;const f=s.screenToSvg(d.clientX,d.clientY),p=r==="x"?f[0]-m.startSvg[0]:f[1]-m.startSvg[1],h=Xb()?Math.round(p/Ft)*Ft:p,g=m.startSpan+(o==="end"?h:-h);if(g<L$)return;const w=r==="x"?[m.startAt[0]+h/2,m.startAt[1]]:[m.startAt[0],m.startAt[1]+h/2];x.getState().updateBus(n,{span:g,at:w})},u=d=>{const m=i.current;!m||d.pointerId!==m.pointerId||(d.target.hasPointerCapture(d.pointerId)&&d.target.releasePointerCapture(d.pointerId),i.current=null)};return c.jsx("circle",{className:"ole-bus-handle",cx:e,cy:t,r:5,"data-handle":o,onPointerDown:a,onPointerMove:l,onPointerUp:u,onPointerCancel:u})}const Tn=.5;function $t(e,t){return Math.abs(e[1]-t[1])<Tn?"h":"v"}function R$(){const e=x(a=>a.selectedWire),t=x(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=$t(o[a-1],o[a]),u=$t(o[a],o[a+1]),d=a-1===0,m=a+1===r-1,f=d&&l==="v"||m&&u==="v",p=d&&l==="h"||m&&u==="h";f&&p||s.push(c.jsx(D$,{wireId:e,index:a,xLocked:f,yLocked:p},`v-${a}`))}const i=[];for(let a=0;a<r-1;a++){const l=o[a],u=o[a+1];Math.abs(l[0]-u[0])<Tn&&Math.abs(l[1]-u[1])<Tn||i.push(c.jsx(F$,{wireId:e,segIndex:a,axis:$t(l,u)},`m-${a}`))}return c.jsxs("g",{className:"ole-wire-handles",pointerEvents:"auto",children:[i,s]})}function D$({wireId:e,index:t,xLocked:n,yLocked:o}){const r=Je(),s=O.useRef(null),i=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.path});if(!i||t<=0||t>=i.length-1)return null;const[a,l]=i[t],u=n&&!o?"ns-resize":!n&&o?"ew-resize":"move",d=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!r))return;const g=x.getState().internal.wireRenders.get(e);g&&(s.current={pointerId:h.pointerId,startPath:g.path.map(w=>[w[0],w[1]]),startSvg:r.screenToSvg(h.clientX,h.clientY),index:t,xLocked:n,yLocked:o},document.body.style.cursor=u,h.target.setPointerCapture(h.pointerId))},m=h=>{const g=s.current;if(!g||h.pointerId!==g.pointerId||!r)return;const w=r.screenToSvg(h.clientX,h.clientY),E=g.startPath,k=g.index;if(k<=0||k>=E.length-1)return;const b=E[k],$=[g.xLocked?b[0]:se(b[0]+(w[0]-g.startSvg[0])),g.yLocked?b[1]:se(b[1]+(w[1]-g.startSvg[1]))];if($[0]===b[0]&&$[1]===b[1])return;const A=E.map(K=>[K[0],K[1]]);A[k]=$;const B=$t(E[k-1],E[k]);k-1>0&&(B==="h"?A[k-1]=[E[k-1][0],$[1]]:A[k-1]=[$[0],E[k-1][1]]);const W=$t(E[k],E[k+1]);k+1<E.length-1&&(W==="h"?A[k+1]=[E[k+1][0],$[1]]:A[k+1]=[$[0],E[k+1][1]]),x.getState().updateWirePath(e,A)},f=h=>{const g=s.current;!g||h.pointerId!==g.pointerId||(h.target.hasPointerCapture(h.pointerId)&&h.target.releasePointerCapture(h.pointerId),s.current=null,document.body.style.cursor="")},p=h=>{h.stopPropagation(),h.preventDefault();const g=x.getState().internal.wireRenders.get(e);if(!g||g.path.length<=2||t<=0||t>=g.path.length-1)return;const w=g.path.filter((E,k)=>k!==t);x.getState().updateWirePath(e,w)};return c.jsx("circle",{className:"ole-wire-handle ole-wire-vertex",cx:a,cy:l,r:5,style:{cursor:u},onPointerDown:d,onPointerMove:m,onPointerUp:f,onPointerCancel:f,onDoubleClick:p})}function F$({wireId:e,segIndex:t,axis:n}){const o=Je(),r=O.useRef(null),s=x(h=>{var g;return(g=h.internal.wireRenders.get(e))==null?void 0:g.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,u=(i[1]+a[1])/2,d=n==="h"?"ns-resize":"ew-resize",m=h=>{if(h.button!==0||(h.stopPropagation(),h.preventDefault(),!o))return;const g=x.getState().internal.wireRenders.get(e);g&&(r.current={pointerId:h.pointerId,startPath:g.path.map(w=>[w[0],w[1]]),startSvg:o.screenToSvg(h.clientX,h.clientY),axis:n,segIndex:t},document.body.style.cursor=d,h.currentTarget.setPointerCapture(h.pointerId))},f=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId||!o)return;const w=o.screenToSvg(h.clientX,h.clientY),E=g.startPath,k=g.segIndex;if(k>=E.length-1)return;const b=E[k],$=E[k+1],A=[];for(let B=0;B<=k;B++)A.push(E[B]);if(g.axis==="h"){const B=se(b[1]+(w[1]-g.startSvg[1]));A.push([b[0],B]),A.push([$[0],B])}else{const B=se(b[0]+(w[0]-g.startSvg[0]));A.push([B,b[1]]),A.push([B,$[1]])}for(let B=k+1;B<E.length;B++)A.push(E[B]);x.getState().updateWirePath(e,A)},p=h=>{const g=r.current;if(!g||h.pointerId!==g.pointerId)return;const w=h.currentTarget;w.hasPointerCapture(h.pointerId)&&w.releasePointerCapture(h.pointerId),r.current=null,document.body.style.cursor=""};return c.jsxs("g",{className:"ole-wire-handle ole-wire-midpoint-group",style:{cursor:d},onPointerDown:m,onPointerMove:f,onPointerUp:p,onPointerCancel:p,children:[c.jsx("circle",{className:"ole-wire-midpoint-hit",cx:l,cy:u,r:8}),c.jsx("circle",{className:"ole-wire-handle ole-wire-midpoint",cx:l,cy:u,r:3.5})]})}const H$=3,hn=12;function W$(){const e=x(a=>a.internal.buses),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(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 c.jsx("g",{className:"ole-bus-layer",children:Array.from(e.values()).map(({bus:a,geometry:l})=>{const{axis:u,at:d,span:m}=l,f=m/2,p=u==="x"?d[0]-f:d[0],h=u==="x"?d[1]:d[1]-f,g=u==="x"?d[0]+f:d[0],w=u==="x"?d[1]:d[1]+f,E=s.has(a.id),k=i.has(a.id),b=r.get(a.id)??void 0,$=hn/2,A=u==="x"?d[0]-f:d[0]-$,B=u==="x"?d[1]-$:d[1]-f,W=u==="x"?m:hn,K=u==="x"?hn:m;return c.jsxs("g",{"data-bus-id":a.id,"data-element-id":a.id,"data-node-id":b,"data-selected":E?"true":void 0,"data-node-related":k?"true":void 0,className:"ole-bus",children:[c.jsx("rect",{x:A,y:B,width:W,height:K,fill:"transparent",className:"ole-bus-hit"}),c.jsx("line",{x1:p,y1:h,x2:g,y2:w,stroke:"currentColor",strokeWidth:H$,strokeLinecap:"round",fill:"none"})]},a.id)})})}function q$(){const e=x(a=>a.busbarDrawStart),t=x(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 c.jsxs("g",{className:"ole-busbar-preview",pointerEvents:"none",children:[c.jsx("line",{x1:e[0],y1:e[1],x2:s,y2:i,className:"ole-busbar-preview-line"}),c.jsx("circle",{cx:e[0],cy:e[1],r:3.5,className:"ole-busbar-preview-anchor"}),c.jsx("circle",{cx:s,cy:i,r:3.5,className:"ole-busbar-preview-anchor"})]})}const G$=4,X$=9;function K$(){const e=x(a=>a.internal.junctions),t=x(a=>a.selection),n=x(a=>a.selectedNode),o=x(a=>a.internal.nodes),r=x(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 c.jsx("g",{className:"ole-junction-layer",children:Array.from(e.values()).map(({junction:a,world:l})=>{const u=r.get(a.id)??void 0;return c.jsxs("g",{"data-junction-id":a.id,"data-element-id":a.id,"data-node-id":u,"data-selected":s.has(a.id)?"true":void 0,"data-node-related":i.has(a.id)?"true":void 0,className:"ole-junction",children:[c.jsx("circle",{cx:l[0],cy:l[1],r:X$,fill:"transparent",className:"ole-junction-hit"}),c.jsx("circle",{cx:l[0],cy:l[1],r:G$,className:"ole-junction-dot"})]},a.id)})})}function Ge(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 Y$(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 V$({lib:e}){const t=Y$(e.viewBox);return t?c.jsx("rect",{className:"ole-element-hit",x:t.x,y:t.y,width:t.w,height:t.h}):null}function U$(){const e=x(a=>a.internal.elements),t=x(a=>a.internal.layout),n=x(a=>a.selection),o=x(a=>a.selectedNode),r=x(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 u=l.indexOf(".");u>0&&i.add(l.slice(0,u))}}return c.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 u=s.has(a.element.id),d=i.has(a.element.id);return a.libraryDef?c.jsxs("g",{"data-element-id":a.element.id,"data-selected":u?"true":void 0,"data-node-related":d?"true":void 0,transform:Ge(l),className:"ole-element",children:[c.jsx(V$,{lib:a.libraryDef}),c.jsx("g",{dangerouslySetInnerHTML:{__html:a.libraryDef.svg}})]},a.element.id):c.jsxs("g",{"data-element-id":a.element.id,"data-selected":u?"true":void 0,"data-node-related":d?"true":void 0,transform:Ge(l),className:"ole-element ole-element--unknown",children:[c.jsx("rect",{x:-10,y:-10,width:20,height:20,fill:"none",stroke:"#EF4444",strokeWidth:1,strokeDasharray:"2 2"}),c.jsx("text",{x:0,y:4,fontSize:8,fill:"#EF4444",textAnchor:"middle",fontFamily:"system-ui, sans-serif",children:"?"})]},a.element.id)})})}let Zb=null;const An=new Set;function It(e){Zb=e;for(const t of An)t(e)}function J$(){return Zb}function Z$(e){return An.add(e),()=>{An.delete(e)}}function Q$(){const[e,t]=O.useState(J$());return O.useEffect(()=>Z$(t),[]),!e||e.w===0&&e.h===0?null:c.jsx("rect",{className:"ole-marquee",x:e.x,y:e.y,width:e.w,height:e.h,pointerEvents:"none"})}function eS(){const e=x(u=>u.activeTool),t=x(u=>u.placeKind),n=x(u=>u.cursorSvg),o=x(u=>u.placeFromTerminal);if(e!=="place"||!t||!n)return null;const r=qb(t);if(!r)return null;let s=null,i=null;if(o){const u=Vb(o,n);u&&(s=Ub(r,u,n),i={source:u.world,pin:n})}else s=Yb(r);const a=n[0]-((s==null?void 0:s.x)??0),l=n[1]-((s==null?void 0:s.y)??0);return c.jsxs("g",{className:"ole-place-ghost-group",pointerEvents:"none",children:[i&&c.jsxs(c.Fragment,{children:[c.jsx("line",{x1:i.source[0],y1:i.source[1],x2:i.pin[0],y2:i.pin[1],className:"ole-wire-preview-line"}),c.jsx("circle",{cx:i.source[0],cy:i.source[1],r:4,className:"ole-wire-preview-anchor"})]}),c.jsx("g",{className:"ole-place-ghost",transform:`translate(${a} ${l})`,opacity:.5,children:c.jsx("g",{dangerouslySetInnerHTML:{__html:r.svg}})})]})}function tS(){const e=x(r=>r.selection),t=x(r=>r.internal.elements),n=x(r=>r.internal.layout),o=x(r=>r.internal.buses);return e.length===0?null:c.jsx("g",{className:"ole-selection-overlay",pointerEvents:"none",children:e.map(r=>{const s=o.get(r);if(s){const{axis:u,at:d,span:m}=s.geometry,f=m/2,p=u==="x"?d[0]-f:d[0]-4,h=u==="x"?d[1]-4:d[1]-f,g=u==="x"?m:8,w=u==="x"?8:m;return c.jsx("rect",{x:p,y:h,width:g,height:w,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=nS(i.libraryDef.viewBox);return l?c.jsx("rect",{x:l.x,y:l.y,width:l.w,height:l.h,fill:"none",className:"ole-selection-rect",transform:Ge(a)},r):null})})}function nS(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 oS(){const e=x(s=>s.internal.terminals),t=x(s=>s.internal.terminalToNode),n=x(s=>s.wireFromTerminal),o=x(s=>s.selection),r=new Set(o);return c.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,u=r.has(s.elementId);return c.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":u?"true":void 0,className:"ole-terminal"},s.ref)})})}function rS(){const e=x(i=>i.internal.wireRenders),t=x(i=>i.internal.terminalToNode),n=x(i=>i.diagram.wires),o=x(i=>i.selectedWire),r=x(i=>i.selectedNode),s=new Map;for(const i of n??[]){const a=t.get(i.ends[0]);a&&s.set(i.id,a)}return c.jsx("g",{className:"ole-wire-layer",fill:"none",stroke:"currentColor",strokeWidth:1,children:Array.from(e.values()).flatMap(i=>{const a=i.path;if(a.length<2)return[];const l=a.map(f=>`${f[0]},${f[1]}`).join(" "),u=s.get(i.wireId),d=o===i.wireId,m=r!=null&&r===u;return[c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":u,className:"ole-wire-hit",points:l},`hit-${i.wireId}`),c.jsx("polyline",{"data-wire-id":i.wireId,"data-node-id":u,"data-manual":i.userEdited?"true":void 0,"data-selected":d||m?"true":void 0,className:"ole-wire",points:l},i.wireId)]})})}let Ve=null;const Cn=new Set;function Le(e){if(!(e===null&&Ve===null||e&&Ve&&e.ref===Ve.ref&&e.world[0]===Ve.world[0]&&e.world[1]===Ve.world[1])){Ve=e;for(const t of Cn)t(e)}}function sS(){return Ve}function iS(e){return Cn.add(e),()=>{Cn.delete(e)}}function aS(){const e=x(l=>l.wireDragFrom),t=x(l=>l.cursorSvg),[n,o]=O.useState(sS());if(O.useEffect(()=>iS(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 c.jsxs("g",{className:"ole-wire-preview",pointerEvents:"none",children:[c.jsx("line",{x1:r[0],y1:r[1],x2:s,y2:i,className:"ole-wire-preview-line"}),c.jsx("circle",{cx:r[0],cy:r[1],r:4,className:"ole-wire-preview-anchor"}),n&&c.jsxs(c.Fragment,{children:[c.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&&c.jsx("circle",{cx:n.world[0],cy:n.world[1],r:n.isBus?3:4,className:"ole-wire-preview-target-dot"})]})]})}function Ze(e,t){return e instanceof Element?e.closest(`[${t}]`):null}function at(e){var t;return((t=Ze(e,"data-element-id"))==null?void 0:t.getAttribute("data-element-id"))??null}function lS(e){var t;return((t=Ze(e,"data-bus-id"))==null?void 0:t.getAttribute("data-bus-id"))??null}function cS(e){var t;return((t=Ze(e,"data-junction-id"))==null?void 0:t.getAttribute("data-junction-id"))??null}function st(e){var r;const t=(r=Ze(e,"data-terminal-id"))==null?void 0:r.getAttribute("data-terminal-id");if(t)return t;const n=cS(e);if(n)return n;const o=lS(e);return o||null}function Jt(e){var t;return((t=Ze(e,"data-node-id"))==null?void 0:t.getAttribute("data-node-id"))??null}function In(e){var t;return((t=Ze(e,"data-wire-id"))==null?void 0:t.getAttribute("data-wire-id"))??null}function qt(e){var t;return((t=Ze(e,"data-annotation-id"))==null?void 0:t.getAttribute("data-annotation-id"))??null}function Qb(e,t){try{e.dispatchEvent(new PointerEvent("pointercancel",{pointerId:t,bubbles:!0,cancelable:!0,pointerType:"touch"}))}catch{}}function dS(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable}function ew(){const e=x.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]");n==null||n.blur()}e.setEditingAnnotation(null),e.setEditingElement(null);return}if(t==="wire"||t==="busbar"||t==="junction"||t==="text"){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 uS(){O.useEffect(()=>{const e=t=>{if(dS(t.target))return;const n=t.metaKey||t.ctrlKey,o=x.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=x.getState().diagram.elements.map(s=>s.id);o.setSelection(r);return}if(n&&!t.shiftKey&&!t.altKey){const r=t.key.toLowerCase();if(r==="c"){if(o.selection.length===0)return;t.preventDefault(),o.copySelection();return}if(r==="x"){if(o.selection.length===0)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"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":ew();return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}let Pn=null;const On=new Set;function mS(e){if(e!==Pn){Pn=e;for(const t of On)t(e)}}function fS(){return Pn}function hS(e){return On.add(e),()=>{On.delete(e)}}const Go="ole-hover-element-host",pS="ole-hover-terminal-on",gS="ole-hover-node-on";function yS(e){O.useEffect(()=>{const t=e.current;if(!t)return;let n=null,o=null;const r=new Set,s=new Set,i=(m,f,p)=>{for(const h of m)h.classList.remove(p);m.clear();for(const h of f)h.classList.add(p),m.add(h)},a=m=>{var p,h;if(m===n)return;n&&((p=t.querySelector(`[data-element-id="${Pt(n)}"]`))==null||p.classList.remove(Go)),m&&((h=t.querySelector(`[data-element-id="${Pt(m)}"]`))==null||h.classList.add(Go));const f=m?Array.from(t.querySelectorAll(`.ole-terminal[data-element-id="${Pt(m)}"]`)):[];i(r,f,pS),n=m,m?t.setAttribute("data-hover-element",""):t.removeAttribute("data-hover-element"),mS(m)},l=m=>{if(m===o)return;const f=m?Array.from(t.querySelectorAll(`[data-node-id="${Pt(m)}"]`)):[];i(s,f,gS),o=m,m?t.setAttribute("data-hover-node",""):t.removeAttribute("data-hover-node")},u=m=>{a(at(m.target));const f=st(m.target);let p=null;f?p=x.getState().internal.terminalToNode.get(f)??null:p=Jt(m.target),l(p)},d=()=>{a(null),l(null)};return t.addEventListener("pointermove",u),t.addEventListener("pointerleave",d),()=>{t.removeEventListener("pointermove",u),t.removeEventListener("pointerleave",d),a(null),l(null)}},[e])}function Pt(e){return e.replace(/(["\\])/g,"\\$1")}function tw(e,t){const n=x.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 f=a[0]-l/2,p=a[0]+l/2,h=Math.max(f,Math.min(p,t[0]));return{ref:e,world:[h,a[1]],isBus:!0}}const u=a[1]-l/2,d=a[1]+l/2,m=Math.max(u,Math.min(d,t[1]));return{ref:e,world:[a[0],m],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 Xo=3;let re=null,Se=null,je=null,me=null;const xS={id:"select",cursor:"default",onPointerDown(e,t){var p,h,g,w,E,k,b;if(e.button!==0||e.target instanceof Element&&e.target.closest(".ole-bus-handle, .ole-wire-handle"))return;const n=x.getState(),o=qt(e.target);if(o){e.preventDefault(),e.stopPropagation();const $=(p=n.diagram.annotations)==null?void 0:p.find(A=>A.id===o);if(!$)return;n.setSelectedAnnotation(o),me={pointerId:e.pointerId,id:o,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),origin:[$.at[0],$.at[1]],moved:!1};return}const s=(e.target instanceof Element?(h=e.target.closest("[data-terminal-id]"))==null?void 0:h.getAttribute("data-terminal-id"):null)?st(e.target):null;if(s){const $=s.indexOf("."),A=$>0?s.slice(0,$):"";if(A&&n.selection.includes(A)){e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((w=(g=e.target).hasPointerCapture)!=null&&w.call(g,e.pointerId))&&e.target.releasePointerCapture(e.pointerId),t.hostEl.classList.add("tool-wire"),n.setWireFromTerminal(s),n.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY)),je={pointerId:e.pointerId,fromRef:s};return}}let i=at(e.target);if(!i){const $=In(e.target);if($&&typeof document<"u"){const A=document.elementsFromPoint(e.clientX,e.clientY);for(const B of A){const W=(k=(E=B.closest)==null?void 0:E.call(B,"[data-bus-id]"))==null?void 0:k.getAttribute("data-bus-id");if(!W)continue;const K=(b=n.diagram.wires)==null?void 0:b.find(oe=>oe.id===$);K&&(K.ends[0]===W||K.ends[1]===W)&&(i=W);break}}}if(!i){const $=In(e.target);if($){if(e.preventDefault(),e.altKey){const A=Jt(e.target);if(A){n.setSelectedNode(A);return}}n.setSelectedWire($);return}e.shiftKey||n.clearSelection(),Se={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 a=n.selection;e.shiftKey?n.toggleInSelection(i):a.includes(i)||n.setSelection([i]);const l=e.shiftKey?x.getState().selection:a.includes(i)?a:[i];if(l.length===0)return;const u=x.getState().internal,d=new Map,m=new Map,f=new Map;for(const $ of l){const A=u.buses.get($);if(A){m.set($,[A.geometry.at[0],A.geometry.at[1]]);continue}const B=u.junctions.get($);if(B){f.set($,[B.world[0],B.world[1]]);continue}const W=u.layout.get($);W&&d.set($,{...W})}d.size===0&&m.size===0&&f.size===0||(re={pointerId:e.pointerId,startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:d,busOriginals:m,junctionOriginals:f,moved:!1},e.preventDefault())},onPointerMove(e,t){if(me&&e.pointerId===me.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=se(n[0]-me.startSvg[0]),r=se(n[1]-me.startSvg[1]);!me.moved&&(o!==0||r!==0)&&(me.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));const s=t.hostEl.querySelector(`[data-annotation-id="${Pe(me.id)}"]`);s&&s.setAttribute("transform",`translate(${o} ${r})`);return}if(je&&e.pointerId===je.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg(n);const o=typeof document<"u"?document.elementFromPoint(e.clientX,e.clientY):null,r=o?st(o):null;if(!r||r===je.fromRef){Le(null);return}Le(tw(r,n));return}if(re&&e.pointerId===re.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=se(n[0]-re.startSvg[0]),r=se(n[1]-re.startSvg[1]);!re.moved&&(o!==0||r!==0)&&(re.moved=!0,t.hostEl.hasPointerCapture(e.pointerId)||t.hostEl.setPointerCapture(e.pointerId));for(const[s,i]of re.originals){const a=t.hostEl.querySelector(`[data-element-id="${Pe(s)}"]`);if(!a)continue;const l={...i,at:[i.at[0]+o,i.at[1]+r]};a.setAttribute("transform",Ge(l))}for(const s of re.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Pe(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}for(const s of re.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Pe(s)}"]`);i&&i.setAttribute("transform",`translate(${o} ${r})`)}return}if(Se&&e.pointerId===Se.pointerId){const n=t.viewport.screenToSvg(e.clientX,e.clientY);It(Ko(Se.startSvg,n));return}},onPointerUp(e,t){if(me&&e.pointerId===me.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=se(n[0]-me.startSvg[0]),r=se(n[1]-me.startSvg[1]),s=t.hostEl.querySelector(`[data-annotation-id="${Pe(me.id)}"]`);s&&s.removeAttribute("transform"),me.moved&&(o!==0||r!==0)&&x.getState().updateAnnotation(me.id,{at:[me.origin[0]+o,me.origin[1]+r]}),me=null;return}if(je&&e.pointerId===je.pointerId){const n=x.getState(),o=je.fromRef;je=null,t.hostEl.classList.remove("tool-wire"),n.setWireFromTerminal(null),n.setCursorSvg(null),Le(null);const r=st(e.target);r&&r!==o&&n.addWire(o,r);return}if(re&&e.pointerId===re.pointerId){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),re.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=se(n[0]-re.startSvg[0]),r=se(n[1]-re.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of re.originals.keys())s.set(i,[o,r]);for(const i of re.busOriginals.keys())s.set(i,[o,r]);for(const i of re.junctionOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of re.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Pe(s)}"]`);i&&i.removeAttribute("transform")}for(const s of re.junctionOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${Pe(s)}"]`);i&&i.removeAttribute("transform")}}re=null;return}if(Se&&e.pointerId===Se.pointerId){t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=Ko(Se.startSvg,n);if(o.w>=Xo||o.h>=Xo){const r=bS(o);if(Se.shiftKey){const s=new Set(Se.baseSelection);for(const i of r)s.has(i)?s.delete(i):s.add(i);x.getState().setSelection([...s])}else x.getState().setSelection(r)}It(null),Se=null}},onPointerCancel(e,t){var n,o,r,s,i,a;if(me&&e.pointerId===me.pointerId){const l=t.hostEl.querySelector(`[data-annotation-id="${Pe(me.id)}"]`);if(l&&l.removeAttribute("transform"),(o=(n=t.hostEl).hasPointerCapture)!=null&&o.call(n,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}me=null}if(re&&e.pointerId===re.pointerId){for(const[l,u]of re.originals){const d=t.hostEl.querySelector(`[data-element-id="${Pe(l)}"]`);d&&d.setAttribute("transform",Ge(u))}for(const l of re.busOriginals.keys()){const u=t.hostEl.querySelector(`[data-element-id="${Pe(l)}"]`);u&&u.removeAttribute("transform")}for(const l of re.junctionOriginals.keys()){const u=t.hostEl.querySelector(`[data-element-id="${Pe(l)}"]`);u&&u.removeAttribute("transform")}if((s=(r=t.hostEl).hasPointerCapture)!=null&&s.call(r,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}re=null}if(je&&e.pointerId===je.pointerId){t.hostEl.classList.remove("tool-wire");const l=x.getState();l.setWireFromTerminal(null),l.setCursorSvg(null),Le(null),je=null}if(Se&&e.pointerId===Se.pointerId){if((a=(i=t.hostEl).hasPointerCapture)!=null&&a.call(i,e.pointerId))try{t.hostEl.releasePointerCapture(e.pointerId)}catch{}It(null),Se=null}},onDoubleClick(e){const t=x.getState(),n=qt(e.target);if(n){e.preventDefault(),e.stopPropagation(),t.setEditingAnnotation(n);return}const o=at(e.target);o&&(e.preventDefault(),e.stopPropagation(),t.setEditingElement(o))},onDeactivate(e){if(re=null,Se=null,me=null,je){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setCursorSvg(null),Le(null),je=null}It(null)}};function Ko(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 bS(e){const{internal:t}=x.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=vS(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(([m,f])=>wS([m,f],r));let a=1/0,l=-1/0,u=1/0,d=-1/0;for(const[m,f]of i)m<a&&(a=m),m>l&&(l=m),f<u&&(u=f),f>d&&(d=f);l>=e.x&&a<=e.x+e.w&&d>=e.y&&u<=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,u=s==="x"?i[0]-l:i[0],d=s==="x"?i[0]+l:i[0],m=s==="x"?i[1]:i[1]-l,f=s==="x"?i[1]:i[1]+l;d>=e.x&&u<=e.x+e.w&&f>=e.y&&m<=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 wS(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 vS(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 Pe(e){return e.replace(/(["\\])/g,"\\$1")}const kS=4;let te=null;const _S={id:"pan",cursor:"grab",onPointerDown(e,t){if(e.button!==0)return;const n=t.viewport.getViewport(),o=at(e.target);let r=null;if(o){const s=x.getState();s.selection.includes(o)||s.setSelection([o]);const i=x.getState().selection,a=x.getState().internal,l=new Map,u=new Map;for(const d of i){const m=a.buses.get(d);if(m){u.set(d,[m.geometry.at[0],m.geometry.at[1]]);continue}const f=a.layout.get(d);f&&l.set(d,{...f})}(l.size>0||u.size>0)&&(r={startSvg:t.viewport.screenToSvg(e.clientX,e.clientY),originals:l,busOriginals:u})}te={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(!te||e.pointerId!==te.pointerId)return;const n=e.clientX-te.startX,o=e.clientY-te.startY;if(!te.moved&&Math.hypot(n,o)>kS){te.moved=!0;try{t.hostEl.setPointerCapture(e.pointerId)}catch{}}if(te.moved){if(te.elementDrag){const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=se(r[0]-te.elementDrag.startSvg[0]),i=se(r[1]-te.elementDrag.startSvg[1]);for(const[a,l]of te.elementDrag.originals){const u=t.hostEl.querySelector(`[data-element-id="${bt(a)}"]`);if(!u)continue;const d={...l,at:[l.at[0]+s,l.at[1]+i]};u.setAttribute("transform",Ge(d))}for(const a of te.elementDrag.busOriginals.keys()){const l=t.hostEl.querySelector(`[data-element-id="${bt(a)}"]`);l&&l.setAttribute("transform",`translate(${s} ${i})`)}return}t.viewport.setViewport({tx:te.startTx+n,ty:te.startTy+o})}},onPointerUp(e,t){if(!(!te||e.pointerId!==te.pointerId)){if(t.hostEl.hasPointerCapture(e.pointerId)&&t.hostEl.releasePointerCapture(e.pointerId),t.hostEl.style.cursor="grab",te.elementDrag&&te.moved){const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=se(n[0]-te.elementDrag.startSvg[0]),r=se(n[1]-te.elementDrag.startSvg[1]);if(o!==0||r!==0){const s=new Map;for(const i of te.elementDrag.originals.keys())s.set(i,[o,r]);for(const i of te.elementDrag.busOriginals.keys())s.set(i,[o,r]);x.getState().moveElements(s)}for(const s of te.elementDrag.busOriginals.keys()){const i=t.hostEl.querySelector(`[data-element-id="${bt(s)}"]`);i&&i.removeAttribute("transform")}}else te.moved||$S(te.startTarget);te=null}},onPointerCancel(e,t){if(te!=null&&te.elementDrag){for(const[n,o]of te.elementDrag.originals){const r=t.hostEl.querySelector(`[data-element-id="${bt(n)}"]`);r&&r.setAttribute("transform",Ge(o))}for(const n of te.elementDrag.busOriginals.keys()){const o=t.hostEl.querySelector(`[data-element-id="${bt(n)}"]`);o&&o.removeAttribute("transform")}}te=null},onDeactivate(){te=null}};function $S(e){if(!e)return;const t=x.getState(),n=qt(e);if(n){t.setSelectedAnnotation(n);return}const o=at(e);if(o){t.setSelection([o]);return}const r=Jt(e);if(r){t.setSelectedNode(r);return}t.clearSelection()}function bt(e){return e.replace(/(["\\])/g,"\\$1")}const vt={tight:1024,compact:720,dense:520,mini:380},Yo={full:0,tight:1,compact:2,dense:3,mini:4};function Ce(e,t){return Yo[e]>=Yo[t]}function SS(e){return e>=vt.tight?"full":e>=vt.compact?"tight":e>=vt.dense?"compact":e>=vt.mini?"dense":"mini"}const nw=O.createContext("full");function Ke(){return O.useContext(nw)}function jS(e){const[t,n]=O.useState(null);return O.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 ow(){if(typeof window>"u")return!1;try{if(!window.matchMedia("(pointer: coarse)").matches)return!1}catch{return!1}return window.innerWidth<vt.dense}function Zt(){ow()&&x.getState().setActiveTool("pan")}function ES(){ow()&&x.getState().setPlaceKind(null)}const Vo=10,Ot=e=>Math.round(e/Vo)*Vo;function NS(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],u=a-s,d=l-i,m=u*u+d*d,f=m===0?0:Math.max(0,Math.min(1,((t[0]-s)*u+(t[1]-i)*d)/m)),p=s+f*u,h=i+f*d,g=(p-t[0])**2+(h-t[1])**2;g<o&&(o=g,n=[p,h])}return n}function Uo(e,t){return typeof document<"u"?document.elementFromPoint(e,t):null}function pn(e,t){const n=e?st(e):null;if(n){const s=tw(n,t);if(s)return{spec:{end:n},world:s.world,ref:n,isBus:s.isBus,create:!1}}const o=e?In(e):null;if(o){const s=x.getState().internal.wireRenders.get(o),i=s?NS(s.path,t):t,a=[Ot(i[0]),Ot(i[1])];return{spec:{onWire:o,at:a},world:a,ref:null,isBus:!1,create:!0}}const r=[Ot(t[0]),Ot(t[1])];return{spec:{junctionAt:r},world:r,ref:null,isBus:!1,create:!0}}function MS(e){return{ref:e.ref,world:e.world,isBus:e.isBus,...e.create?{create:"junction"}:{}}}function Jo(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 TS={id:"wire",cursor:"crosshair",onActivate(e){e.hostEl.classList.add("tool-wire")},onDeactivate(e){e.hostEl.classList.remove("tool-wire");const t=x.getState();t.setWireFromTerminal(null),t.setWireDragFrom(null),t.setCursorSvg(null),Le(null)},onPointerDown(e,t){var s,i;if(e.button!==0)return;e.preventDefault(),e.stopPropagation(),e.target instanceof Element&&((i=(s=e.target).hasPointerCapture)!=null&&i.call(s,e.pointerId))&&e.target.releasePointerCapture(e.pointerId);const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=pn(e.target instanceof Element?e.target:null,n),r=x.getState();r.setWireDragFrom({spec:o.spec,world:o.world,ref:o.ref}),r.setWireFromTerminal(o.ref),r.setCursorSvg(n)},onPointerMove(e,t){const n=x.getState(),o=n.wireDragFrom;if(!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY);n.setCursorSvg(r);const s=Uo(e.clientX,e.clientY),i=pn(s,r),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Le(Jo(a,i)?null:MS(i))},onPointerUp(e,t){const n=x.getState(),o=n.wireDragFrom;if(n.setWireFromTerminal(null),n.setWireDragFrom(null),n.setCursorSvg(null),Le(null),!o)return;const r=t.viewport.screenToSvg(e.clientX,e.clientY),s=Uo(e.clientX,e.clientY)??(e.target instanceof Element?e.target:null),i=pn(s,r),a={spec:o.spec,world:o.world,ref:o.ref,create:!o.ref};Jo(a,i)||(n.connectWire(o.spec,i.spec),Zt())},onPointerLeave(){const e=x.getState();e.setWireFromTerminal(null),e.setWireDragFrom(null),e.setCursorSvg(null),Le(null)}},Zo=10;let wt=!1;function Qo(){setTimeout(()=>ES(),0)}const AS={id:"place",cursor:"copy",onActivate(e){e.hostEl.classList.add("tool-place")},onDeactivate(e){e.hostEl.classList.remove("tool-place");const t=x.getState();t.setPlaceFromTerminal(null),t.setCursorSvg(null),wt=!1},onPointerDown(e,t){var s,i;if(e.button!==0)return;const{placeKind:n}=x.getState();if(!n)return;e.preventDefault();const o=st(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=x.getState();a.setPlaceFromTerminal(o),a.setCursorSvg(t.viewport.screenToSvg(e.clientX,e.clientY));return}const r=t.viewport.screenToSvg(e.clientX,e.clientY);Kb(n,r),wt=!0},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([er(n[0]),er(n[1])])},onPointerUp(e,t){const n=x.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);T$(r,o,s),Qo();return}wt&&(wt=!1,Qo())},onPointerLeave(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setPlaceFromTerminal(null),e.setCursorSvg(null),wt=!1}};function er(e){return Math.round(e/Zo)*Zo}const tr=10,nr=20;function tt(e){return Math.round(e/tr)*tr}const CS={id:"busbar",cursor:"crosshair",onPointerDown(e,t){if(e.button!==0)return;e.preventDefault();const n=t.viewport.screenToSvg(e.clientX,e.clientY),o=[tt(n[0]),tt(n[1])];x.getState().setBusbarDrawStart(o),x.getState().setCursorSvg(o)},onPointerMove(e,t){const n=t.viewport.screenToSvg(e.clientX,e.clientY);x.getState().setCursorSvg([tt(n[0]),tt(n[1])])},onPointerUp(e,t){const n=x.getState().busbarDrawStart;if(x.getState().setBusbarDrawStart(null),!n)return;const o=t.viewport.screenToSvg(e.clientX,e.clientY),r=tt(o[0]),s=tt(o[1]),i=r-n[0],a=s-n[1],l=Math.abs(i)>=Math.abs(a);let u,d,m;if(l){if(d=Math.abs(i),d<nr)return;u=0,m=[(n[0]+r)/2,n[1]]}else{if(d=Math.abs(a),d<nr)return;u=90,m=[n[0],(n[1]+s)/2]}x.getState().addBus(m,d,u),Zt()},onPointerLeave(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onPointerCancel(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)},onDeactivate(){const e=x.getState();e.setBusbarDrawStart(null),e.setCursorSvg(null)}},or=10,rr=e=>Math.round(e/or)*or,IS={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);x.getState().addJunction([rr(n[0]),rr(n[1])]),Zt()}},PS={id:"text",cursor:"text",onPointerDown(e,t){if(e.button!==0)return;const n=x.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),Zt()}},OS={select:xS,pan:_S,wire:TS,place:AS,busbar:CS,junction:IS,text:PS};function BS(e,t){const n=x(o=>o.activeTool);O.useEffect(()=>{var f;const o=e.current;if(!o)return;const r=OS[n],s={viewport:t,hostEl:o};(f=r.onActivate)==null||f.call(r,s),r.cursor&&(o.style.cursor=r.cursor);const i=p=>{var h;return(h=r.onPointerDown)==null?void 0:h.call(r,p,s)},a=p=>{var h;return(h=r.onPointerMove)==null?void 0:h.call(r,p,s)},l=p=>{var h;return(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},u=p=>{var h;return r.onPointerCancel?r.onPointerCancel(p,s):(h=r.onPointerUp)==null?void 0:h.call(r,p,s)},d=p=>{var h;return(h=r.onPointerLeave)==null?void 0:h.call(r,p,s)},m=p=>{var h;return(h=r.onDoubleClick)==null?void 0:h.call(r,p,s)};return o.addEventListener("pointerdown",i),o.addEventListener("pointermove",a),o.addEventListener("pointerup",l),o.addEventListener("pointercancel",u),o.addEventListener("pointerleave",d),o.addEventListener("dblclick",m),()=>{var p;o.removeEventListener("pointerdown",i),o.removeEventListener("pointermove",a),o.removeEventListener("pointerup",l),o.removeEventListener("pointercancel",u),o.removeEventListener("pointerleave",d),o.removeEventListener("dblclick",m),(p=r.onDeactivate)==null||p.call(r,s),o.style.cursor=""}},[n,e,t])}let Bn=1;const Ln=new Set;function LS(e){if(e!==Bn){Bn=e;for(const t of Ln)t(e)}}function zS(){return Bn}function RS(e){return Ln.add(e),()=>{Ln.delete(e)}}const gn=.1,yn=8,DS=1.0015,FS=1.02;function HS(e,t,n={tx:0,ty:0,scale:1}){const o=O.useRef({...n}),r=O.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)),LS(o.current.scale),r.current.size>0){const l={...o.current};for(const u of r.current)u(l)}};return O.useEffect(()=>{const i=e.current;if(!i)return;let a=!1,l=-1,u=0,d=0,m=0,f=0,p=!1;const h=new Map;let g=null,w=!1;const E=()=>{if(h.size<2){g=null;return}const R=[...h.values()],F=R[1].x-R[0].x,Z=R[1].y-R[0].y,ae=Math.hypot(F,Z)||1,ce=i.getBoundingClientRect();g={startDist:ae,startScale:o.current.scale,startTx:o.current.tx,startTy:o.current.ty,startMidX:(R[0].x+R[1].x)/2-ce.left,startMidY:(R[0].y+R[1].y)/2-ce.top}},k=R=>{if(R.pointerType==="touch"){if(h.set(R.pointerId,{x:R.clientX,y:R.clientY}),h.size>=2&&!w){w=!0;for(const F of h.keys())F!==R.pointerId&&Qb(i,F);E()}if(w){R.stopPropagation(),R.preventDefault();try{i.setPointerCapture(R.pointerId)}catch{}}}},b=R=>{if(R.pointerType!=="touch"||!h.has(R.pointerId)||(h.set(R.pointerId,{x:R.clientX,y:R.clientY}),!w||!g))return;R.stopPropagation();const F=[...h.values()];if(F.length<2)return;const Z=F[1].x-F[0].x,ae=F[1].y-F[0].y,ce=Math.hypot(Z,ae)||1,Q=i.getBoundingClientRect(),he=(F[0].x+F[1].x)/2-Q.left,pe=(F[0].y+F[1].y)/2-Q.top,ge=ce/g.startDist,Ie=xn(g.startScale*ge,gn,yn),$e=Ie/g.startScale;o.current.tx=g.startMidX-(g.startMidX-g.startTx)*$e+(he-g.startMidX),o.current.ty=g.startMidY-(g.startMidY-g.startTy)*$e+(pe-g.startMidY),o.current.scale=Ie,s()},$=R=>{var F;if(R.pointerType==="touch"&&h.has(R.pointerId)&&(h.delete(R.pointerId),w)){if(R.stopPropagation(),(F=i.hasPointerCapture)!=null&&F.call(i,R.pointerId))try{i.releasePointerCapture(R.pointerId)}catch{}h.size>=2?E():g=null,h.size===0&&(w=!1)}},A=R=>{R.preventDefault();const F=i.getBoundingClientRect(),Z=R.clientX-F.left,ae=R.clientY-F.top,ce=R.ctrlKey||R.metaKey;if(R.deltaX===0||ce){const pe=Math.pow(ce?FS:DS,-R.deltaY),ge=xn(o.current.scale*pe,gn,yn),Ie=ge/o.current.scale;o.current.tx=Z-(Z-o.current.tx)*Ie,o.current.ty=ae-(ae-o.current.ty)*Ie,o.current.scale=ge}else o.current.tx-=R.deltaX,o.current.ty-=R.deltaY;s()},B=R=>{const F=R.button===1,Z=p&&R.button===0;!F&&!Z||(R.preventDefault(),a=!0,l=R.pointerId,u=R.clientX,d=R.clientY,m=o.current.tx,f=o.current.ty,i.setPointerCapture(R.pointerId),i.style.cursor="grabbing")},W=R=>{!a||R.pointerId!==l||(o.current.tx=m+(R.clientX-u),o.current.ty=f+(R.clientY-d),s())},K=R=>{a&&R.pointerId===l&&(a=!1,i.releasePointerCapture(R.pointerId),i.style.cursor=p?"grab":"")},oe=R=>{if(R.code==="Space"&&!p){const F=R.target;if(F&&(F.tagName==="INPUT"||F.tagName==="TEXTAREA"||F.isContentEditable))return;p=!0,i.style.cursor="grab",R.preventDefault()}},ie=R=>{R.code==="Space"&&(p=!1,a||(i.style.cursor=""))};return i.addEventListener("wheel",A,{passive:!1}),i.addEventListener("pointerdown",B),i.addEventListener("pointermove",W),i.addEventListener("pointerup",K),i.addEventListener("pointercancel",K),i.addEventListener("pointerdown",k,{capture:!0}),i.addEventListener("pointermove",b,{capture:!0}),i.addEventListener("pointerup",$,{capture:!0}),i.addEventListener("pointercancel",$,{capture:!0}),window.addEventListener("keydown",oe),window.addEventListener("keyup",ie),s(),()=>{i.removeEventListener("wheel",A),i.removeEventListener("pointerdown",B),i.removeEventListener("pointermove",W),i.removeEventListener("pointerup",K),i.removeEventListener("pointercancel",K),i.removeEventListener("pointerdown",k,{capture:!0}),i.removeEventListener("pointermove",b,{capture:!0}),i.removeEventListener("pointerup",$,{capture:!0}),i.removeEventListener("pointercancel",$,{capture:!0}),window.removeEventListener("keydown",oe),window.removeEventListener("keyup",ie)}},[]),{screenToSvg(i,a){const l=e.current;if(!l)return[i,a];const u=l.getBoundingClientRect(),d=(i-u.left-o.current.tx)/o.current.scale,m=(a-u.top-o.current.ty)/o.current.scale;return[d,m]},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=xn(i.scale,gn,yn)),s()},subscribe(i){return r.current.add(i),()=>{r.current.delete(i)}}}}function xn(e,t,n){return e<t?t:e>n?n:e}const rw=typeof navigator<"u"&&/Mac|iP(ad|hone|od)/.test(navigator.platform),nt=rw?"⌘":"Ctrl+",WS=rw?"⇧":"Shift+",bn=[10,20,50,100,200,500,1e3,2e3,5e3,1e4],qS=18;function GS(e){for(const t of bn)if(t*e>=qS)return t;return bn[bn.length-1]}function XS(){const e=ne(),t=O.useRef(null),n=O.useRef(null),o=O.useRef(null),r=HS(t,n);BS(t,r),yS(t),O.useEffect(()=>(Ho(r),()=>Ho(null)),[r]),O.useEffect(()=>{const d=m=>{const f=o.current;if(!f)return;const h=GS(m.scale)*m.scale;f.setAttribute("width",String(h)),f.setAttribute("height",String(h)),f.setAttribute("patternTransform",`translate(${m.tx} ${m.ty})`)};return d(r.getViewport()),r.subscribe(d)},[r]);const s=Dv(),i=O.useCallback((d,m,f)=>{const p=x.getState(),h=p.activeTool;if(h==="wire"||h==="busbar"||h==="junction"||h==="place"){ew();return}const g=at(f);if(g)p.selection.includes(g)||p.setSelection([g]);else{const B=Jt(f);B&&p.selectedNode!==B&&p.setSelectedNode(B)}const w=x.getState(),E=w.selection.length>0,k=w.selectedNode!=null,b=!!w.clipboard,$=w.diagram.elements.length>0,A=[{label:e("menu.undo"),shortcut:`${nt}Z`,icon:Hn,onSelect:()=>x.getState().undo(),disabled:w.past.length===0},{label:e("menu.redo"),shortcut:`${nt}${WS}Z`,icon:Fn,onSelect:()=>x.getState().redo(),disabled:w.future.length===0},{type:"separator"},{label:e("menu.cut"),shortcut:`${nt}X`,icon:Pr,onSelect:()=>x.getState().cutSelection(),disabled:!E},{label:e("menu.copy"),shortcut:`${nt}C`,icon:Tr,onSelect:()=>x.getState().copySelection(),disabled:!E},{label:e("menu.paste"),shortcut:`${nt}V`,icon:Mr,onSelect:()=>x.getState().pasteClipboard(),disabled:!b},{type:"separator"},{label:e("menu.rotate"),shortcut:"R",icon:Ir,onSelect:()=>x.getState().rotateSelection(90),disabled:!E},{label:e("menu.mirror"),shortcut:"M",icon:Ar,onSelect:()=>x.getState().mirrorSelection(),disabled:!E},{type:"separator"},{label:e("menu.selectAll"),shortcut:`${nt}A`,icon:av,onSelect:()=>{const B=x.getState();B.setSelection(B.diagram.elements.map(W=>W.id))},disabled:!$},{type:"separator"},{label:e(k&&!E?"menu.disconnect":"menu.delete"),shortcut:"Del",icon:Br,destructive:!0,onSelect:()=>k&&!E?x.getState().deleteSelectedNode():x.getState().deleteSelection(),disabled:!E&&!k}];s.open(d,m,A)},[s,e]);O.useEffect(()=>{const d=t.current;if(!d)return;const m=700,f=4;let p,h=null;const g=()=>{p!==void 0&&window.clearTimeout(p),p=void 0,h=null},w=b=>{b.pointerType==="touch"&&(g(),h={pointerId:b.pointerId,x:b.clientX,y:b.clientY,target:b.target},p=window.setTimeout(()=>{const $=h;h=null,p=void 0,$&&(Qb(d,$.pointerId),i($.x,$.y,$.target))},m))},E=b=>{if(!h||b.pointerId!==h.pointerId)return;const $=b.clientX-h.x,A=b.clientY-h.y;Math.hypot($,A)>f&&g()},k=b=>{!h||b.pointerId!==h.pointerId||g()};return d.addEventListener("pointerdown",w),d.addEventListener("pointermove",E),d.addEventListener("pointerup",k),d.addEventListener("pointercancel",k),()=>{g(),d.removeEventListener("pointerdown",w),d.removeEventListener("pointermove",E),d.removeEventListener("pointerup",k),d.removeEventListener("pointercancel",k)}},[i]);const a=d=>{d.dataTransfer.types.includes("application/x-oneline-kind")&&(d.preventDefault(),d.dataTransfer.dropEffect="copy")},l=d=>{const m=d.dataTransfer.getData("application/x-oneline-kind");if(!m)return;d.preventDefault();const f=r.screenToSvg(d.clientX,d.clientY);Kb(m,f)},u=d=>{d.preventDefault(),i(d.clientX,d.clientY,d.target)};return c.jsx("div",{ref:t,className:"ole-canvas-root absolute inset-0 overflow-hidden",onDragOver:a,onDrop:l,onContextMenu:u,children:c.jsxs("svg",{className:"ole-canvas-svg block h-full w-full",xmlns:"http://www.w3.org/2000/svg",children:[c.jsx("defs",{children:c.jsx("pattern",{ref:o,id:"ole-grid-dots",width:20,height:20,patternUnits:"userSpaceOnUse",children:c.jsx("circle",{cx:0,cy:0,r:2,fill:"var(--canvas-grid-strong)"})})}),c.jsx("rect",{width:"100%",height:"100%",fill:"url(#ole-grid-dots)"}),c.jsxs("g",{ref:n,className:"ole-viewport",children:[c.jsx(W$,{}),c.jsx(rS,{}),c.jsx(K$,{}),c.jsx(U$,{}),c.jsx(C$,{}),c.jsx(P$,{}),c.jsx(tS,{}),c.jsx(z$,{}),c.jsx(R$,{}),c.jsx(oS,{}),c.jsx(aS,{}),c.jsx(q$,{}),c.jsx(eS,{}),c.jsx(Q$,{})]})]})})}const sr=60,KS=.1,YS=8,VS=8;function US(e,t,n){return e<t?t:e>n?n:e}function JS(){return document.querySelector(".ole-canvas-root")}function Xn(){const e=Je(),t=JS();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 E of o){const k=E.getBoundingClientRect();k.width===0&&k.height===0||(k.left<r&&(r=k.left),k.top<s&&(s=k.top),k.right>i&&(i=k.right),k.bottom>a&&(a=k.bottom))}if(r===1/0)return!1;const[l,u]=e.screenToSvg(r,s),[d,m]=e.screenToSvg(i,a),f=Math.max(d-l,1),p=Math.max(m-u,1),h=US(Math.min((n.width-sr*2)/f,(n.height-sr*2)/p),KS,YS),g=(l+d)/2,w=(u+m)/2;return e.setViewport({tx:n.width/2-h*g,ty:n.height/2-h*w,scale:h}),!0}function Kn(){let e=VS;const t=()=>{Xn()||--e>0&&requestAnimationFrame(t)};requestAnimationFrame(t)}const ir=10,ZS=100;function QS(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(hover: none), (pointer: coarse)").matches}function e4(){const[e,t]=O.useState(fS()),[n,o]=O.useState(!1),[r,s]=O.useState(null),i=O.useRef(null),a=O.useRef(void 0),[l]=O.useState(QS);O.useEffect(()=>hS(h=>t(h)),[]),O.useEffect(()=>{if(window.clearTimeout(a.current),o(!1),s(null),!!e)return a.current=window.setTimeout(()=>o(!0),ZS),()=>window.clearTimeout(a.current)},[e]);const u=x(h=>e?h.diagram.elements.find(g=>g.id===e)??null:null);if(O.useLayoutEffect(()=>{if(!n||!e)return;let h=0,g=-1,w=-1;const E=()=>{const k=document.querySelector(`[data-element-id="${t4(e)}"]`),b=i.current;if(k&&b){const $=k.getBoundingClientRect();let A=$.bottom+ir;A+b.offsetHeight>window.innerHeight-4&&(A=$.top-b.offsetHeight-ir);let B=$.left+$.width/2-b.offsetWidth/2;B=Math.max(4,Math.min(B,window.innerWidth-b.offsetWidth-4)),(A!==g||B!==w)&&(s({top:A,left:B}),g=A,w=B)}h=requestAnimationFrame(E)};return h=requestAnimationFrame(E),()=>cancelAnimationFrame(h)},[n,e]),l||!n||!e||!u)return null;const d=Xe[u.kind],m=u.name??u.id,f=(d==null?void 0:d.name)??u.kind,p=u.name&&u.name!==u.id;return typeof document>"u"?null:jr.createPortal(c.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:[c.jsx("span",{className:"font-medium text-foreground",children:m}),p&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:u.id}),c.jsx("span",{className:"text-muted-foreground/80",children:"·"}),c.jsx("span",{className:"text-muted-foreground",children:f})]}),document.body)}function t4(e){return e.replace(/(["\\])/g,"\\$1")}function n4({width:e,children:t}){const n=e==null?"full":SS(e);return c.jsx(nw.Provider,{value:n,children:t})}function ar(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function o4(...e){return t=>{let n=!1;const o=e.map(r=>{const s=ar(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():ar(e[r],null)}}}}var r4=Symbol.for("react.lazy"),Gt=ke[" use ".trim().toString()];function s4(e){return typeof e=="object"&&e!==null&&"then"in e}function sw(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===r4&&"_payload"in e&&s4(e._payload)}function i4(e){const t=l4(e),n=ke.forwardRef((o,r)=>{let{children:s,...i}=o;sw(s)&&typeof Gt=="function"&&(s=Gt(s._payload));const a=ke.Children.toArray(s),l=a.find(d4);if(l){const u=l.props.children,d=a.map(m=>m===l?ke.Children.count(u)>1?ke.Children.only(null):ke.isValidElement(u)?u.props.children:null:m);return c.jsx(t,{...i,ref:r,children:ke.isValidElement(u)?ke.cloneElement(u,void 0,d):null})}return c.jsx(t,{...i,ref:r,children:s})});return n.displayName=`${e}.Slot`,n}var a4=i4("Slot");function l4(e){const t=ke.forwardRef((n,o)=>{let{children:r,...s}=n;if(sw(r)&&typeof Gt=="function"&&(r=Gt(r._payload)),ke.isValidElement(r)){const i=m4(r),a=u4(s,r.props);return r.type!==ke.Fragment&&(a.ref=o?o4(o,i):i),ke.cloneElement(r,a)}return ke.Children.count(r)>1?ke.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var c4=Symbol("radix.slottable");function d4(e){return ke.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===c4}function u4(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 m4(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 lr=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,cr=Rr,f4=(e,t)=>n=>{var o;if((t==null?void 0:t.variants)==null)return cr(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:r,defaultVariants:s}=t,i=Object.keys(r).map(u=>{const d=n==null?void 0:n[u],m=s==null?void 0:s[u];if(d===null)return null;const f=lr(d)||lr(m);return r[u][f]}),a=n&&Object.entries(n).reduce((u,d)=>{let[m,f]=d;return f===void 0||(u[m]=f),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,d)=>{let{class:m,className:f,...p}=d;return Object.entries(p).every(h=>{let[g,w]=h;return Array.isArray(w)?w.includes({...s,...a}[g]):{...s,...a}[g]===w})?[...u,m,f]:u},[]);return cr(e,i,l,n==null?void 0:n.class,n==null?void 0:n.className)},h4=f4("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"}}),Ne=ke.forwardRef(({className:e,variant:t,size:n,asChild:o=!1,...r},s)=>{const i=o?a4:"button";return c.jsx(i,{className:_e(h4({variant:t,size:n,className:e})),ref:s,...r})});Ne.displayName="Button";const p4=350;function Me({content:e,children:t,disabled:n,delayMs:o=p4}){const r=O.useRef(null),s=O.useRef(null),[i,a]=O.useState(!1),[l,u]=O.useState(null),d=O.useId(),m=O.useRef(void 0),f=()=>{n||(window.clearTimeout(m.current),m.current=window.setTimeout(()=>a(!0),o))},p=()=>{window.clearTimeout(m.current),a(!1)};O.useLayoutEffect(()=>{if(!i||!r.current||!s.current)return;const E=r.current.getBoundingClientRect(),k=s.current.getBoundingClientRect(),b=8;let $="top",A=E.top-k.height-b;A<4&&($="bottom",A=E.bottom+b);let B=E.left+E.width/2-k.width/2;B=Math.max(4,Math.min(B,window.innerWidth-k.width-4)),u({top:A,left:B,side:$})},[i,e]),O.useEffect(()=>()=>window.clearTimeout(m.current),[]),O.useEffect(()=>{if(!i)return;const E=b=>{b.key==="Escape"&&a(!1)},k=()=>a(!1);return window.addEventListener("keydown",E),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("keydown",E),window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[i]);const h=t,g=h.props,w=O.cloneElement(h,{ref:E=>{r.current=E;const k=h.ref;typeof k=="function"?k(E):k&&typeof k=="object"&&(k.current=E)},onPointerEnter:E=>{var k;(k=g.onPointerEnter)==null||k.call(g,E),f()},onPointerLeave:E=>{var k;(k=g.onPointerLeave)==null||k.call(g,E),p()},onFocus:E=>{var k;(k=g.onFocus)==null||k.call(g,E),f()},onBlur:E=>{var k;(k=g.onBlur)==null||k.call(g,E),p()},"aria-describedby":i?d:g["aria-describedby"]});return c.jsxs(c.Fragment,{children:[w,i&&typeof document<"u"&&jr.createPortal(c.jsx("div",{ref:s,id:d,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 dr=12,g4=56;function y4(){var E;const e=ne(),t=x(k=>k.selection),n=x(k=>k.selectedNode),o=x(k=>k.selectedWire),r=x(k=>k.activeTool),s=x(k=>k.rotateSelection),i=x(k=>k.mirrorSelection),a=x(k=>k.deleteSelection),l=x(k=>k.deleteSelectedNode),u=x(k=>k.deleteSelectedWire),d=x(k=>k.resetWirePath),m=x(k=>k.internal.wireRenders),f=o!=null&&((E=m.get(o))==null?void 0:E.userEdited)===!0,p=O.useRef(null);O.useEffect(()=>{const k=p.current;if(!k)return;const b=t.length>0,$=!b&&o!=null,A=!b&&!$&&n!=null;if(!((b||$||A)&&(r==="select"||r==="pan"))){k.style.display="none";return}k.style.display="flex";let W=0,K="";const oe=()=>{let ie=1/0,R=-1/0,F=1/0,Z=-1/0,ae=!1;const ce=Q=>{Q.width===0&&Q.height===0||(Q.left<ie&&(ie=Q.left),Q.right>R&&(R=Q.right),Q.top<F&&(F=Q.top),Q.bottom>Z&&(Z=Q.bottom),ae=!0)};if(b)for(const Q of t){const he=document.querySelector(`[data-element-id="${CSS.escape(Q)}"]`);he&&ce(he.getBoundingClientRect())}else if($&&o){const Q=document.querySelector(`polyline.ole-wire[data-wire-id="${CSS.escape(o)}"]`);Q&&ce(Q.getBoundingClientRect())}else if(A&&n){const Q=document.querySelectorAll(`polyline.ole-wire[data-node-id="${CSS.escape(n)}"]`);for(const he of Q)ce(he.getBoundingClientRect())}if(ae){const Q=(ie+R)/2;let he=F-dr,pe="-100%";he<g4&&(he=Z+dr,pe="0%");const ge=`translate3d(${Q}px, ${he}px, 0) translate(-50%, ${pe})`;ge!==K&&(k.style.transform=ge,K=ge)}W=requestAnimationFrame(oe)};return W=requestAnimationFrame(oe),()=>cancelAnimationFrame(W)},[t,n,o,r]);const h=t.length===0&&o!=null,g=t.length===0&&!h&&n!=null,w=g||h;return c.jsxs("div",{ref:p,role:"toolbar","aria-label":e(h?"ctx.ariaWire":g?"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:[h&&f&&o&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{children:c.jsx("span",{className:"font-medium",children:e("ctx.resetWirePath")})}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.resetWirePathHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>d(o),"aria-label":e("ctx.resetWirePath"),children:c.jsx(iv,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),!w&&c.jsxs(c.Fragment,{children:[c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.rotate")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"R"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.rotateHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>s(90),"aria-label":e("ctx.rotate"),children:c.jsx(Ir,{})})}),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.mirror")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"M"})]}),c.jsx("div",{className:"text-muted-foreground",children:e("ctx.mirrorHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7",onClick:()=>i(),"aria-label":e("ctx.mirrorTitle"),children:c.jsx(Ar,{})})}),c.jsx("div",{"aria-hidden":!0,className:"mx-0.5 h-4 w-px bg-border"})]}),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:e("ctx.delete")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:"Del"})]}),c.jsx("div",{className:"text-muted-foreground",children:e(h?"ctx.deleteHintWire":g?"ctx.deleteHintNode":"ctx.deleteHintElement")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",className:"size-7 text-destructive hover:text-destructive",onClick:()=>h?u():g?l():a(),"aria-label":e("ctx.delete"),children:c.jsx(Br,{})})})]})}function Yn({open:e,onOpenChange:t,trigger:n,children:o}){const r=O.useRef(null);return O.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]),c.jsxs("div",{ref:r,className:"relative",children:[n,e&&c.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 iw="ole-panel-open";function x4(){if(typeof window>"u")return{outlineOpen:!1};try{const e=window.localStorage.getItem(iw);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 ur(e){try{const t={outline:e.outlineOpen};window.localStorage.setItem(iw,JSON.stringify(t))}catch{}}const Et=Xt((e,t)=>({...x4(),setOutlineOpen:n=>{e({outlineOpen:n}),ur(t())},toggleOutline:()=>{e(n=>({outlineOpen:!n.outlineOpen})),ur(t())}})),zt=[.1,.25,.5,.75,1,1.25,1.5,2,3,4,6,8],aw=.1,lw=8,cw="ole-grid";function b4(){try{const e=window.localStorage.getItem(cw);return e==null?!0:e==="1"}catch{return!0}}function w4(e){try{window.localStorage.setItem(cw,e?"1":"0")}catch{}}function v4(e,t,n){return e<t?t:e>n?n:e}function dw(){return document.querySelector(".ole-canvas-root")}function Vn(e){const t=Je(),n=dw();if(!t||!n)return;const o=n.getBoundingClientRect(),r=o.width/2,s=o.height/2,i=t.getViewport(),a=v4(e,aw,lw),l=a/i.scale;t.setViewport({tx:r-(r-i.tx)*l,ty:s-(s-i.ty)*l,scale:a})}function k4(){const e=Je();if(!e)return;const t=e.getViewport().scale,n=zt.find(o=>o>t+1e-6)??lw;Vn(n)}function _4(){const e=Je();if(!e)return;const t=e.getViewport().scale;let n=aw;for(let o=zt.length-1;o>=0;o--)if(zt[o]<t-1e-6){n=zt[o];break}Vn(n)}const $4={off:"id",id:"all",all:"off"};function S4(){var o;const e=x.getState(),t=((o=e.diagram.meta)==null?void 0:o.labelMode)??"all",n=$4[t];e.dispatch(r=>{const s={...r.meta??{},labelMode:n};return{...r,meta:s}})}function uw(){const[e,t]=O.useState(()=>b4());return O.useEffect(()=>{const n=dw();n==null||n.classList.toggle("hide-grid",!e),w4(e)},[e]),O.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 mw(){const e=ne();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomOut")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomOutHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:_4,"aria-label":e("view.zoomOut"),children:c.jsx(Dn,{})})})}function fw(){const e=ne();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.zoomIn")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.zoomInHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:k4,"aria-label":e("view.zoomIn"),children:c.jsx(rv,{})})})}function hw(){const e=ne(),[t,n]=O.useState(zS);return O.useEffect(()=>RS(n),[]),c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.reset")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.current",{z:Math.round(t*100)})})]}),children:c.jsxs("button",{type:"button",onClick:()=>Vn(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 pw(){const e=ne();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e("view.fit")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.fitHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:Xn,"aria-label":e("view.fit"),children:c.jsx(tv,{})})})}function gw({grid:e,setGrid:t}){const n=ne();return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:n(e?"view.gridHide":"view.gridShow")}),c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n("view.gridHotkey")})]}),c.jsx("div",{className:"text-muted-foreground",children:n(e?"view.gridHideHint":"view.gridShowHint")})]}),children:c.jsx(Ne,{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:c.jsx(Qw,{})})})}function yw(){const e=ne(),t=x(n=>{var o;return((o=n.diagram.meta)==null?void 0:o.labelMode)??"all"});return c.jsx(Me,{content:c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:e(t==="off"?"view.labelOff":t==="id"?"view.labelId":"view.labelAll")}),c.jsx("div",{className:"text-muted-foreground",children:e("view.labelHint")})]}),children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:S4,"aria-label":e("view.label"),"aria-pressed":t!=="off",className:_e(t==="off"&&"text-muted-foreground/60"),children:c.jsx(Lr,{})})})}function j4({stacked:e}={}){const t=ne(),[n,o]=O.useState(!1),[r,s]=uw(),i=c.jsxs("div",{className:"space-y-0.5",children:[c.jsx("div",{className:"font-medium",children:t("view.menu")}),c.jsx("div",{className:"text-muted-foreground",children:t("view.menuHint")})]}),a=e?c.jsx(Me,{content:i,children:c.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:[c.jsx(kn,{className:"size-4"}),c.jsx("span",{className:"max-w-full truncate",children:t("view.menu")})]})}):c.jsx(Me,{content:i,children:c.jsx(Ne,{variant:"ghost",size:"icon",onClick:()=>o(l=>!l),"aria-label":t("view.menu"),"aria-pressed":n,children:c.jsx(kn,{})})});return c.jsx(Yn,{open:n,onOpenChange:o,trigger:a,children:c.jsxs("div",{className:"flex flex-col gap-0.5",children:[c.jsx(hw,{}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(mw,{}),c.jsx(fw,{})]}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsxs("div",{className:"flex items-center gap-0.5",children:[c.jsx(pw,{}),c.jsx(gw,{grid:r,setGrid:s}),c.jsx(yw,{})]})]})})}function E4(){const e=Ke();return Ce(e,"dense")?null:c.jsx(N4,{tier:e})}function N4({tier:e}){const t=Ce(e,"tight"),[n,o]=uw();return c.jsx("div",{className:"absolute z-20",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",right:"calc(0.75rem + env(safe-area-inset-right, 0px))"},children:c.jsxs("div",{className:"ole-glass flex items-center gap-0.5 rounded-2xl border border-border p-1.5 shadow-sm",children:[c.jsx(mw,{}),!t&&c.jsx(hw,{}),c.jsx(fw,{}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-4 w-px bg-border"}),c.jsx(pw,{}),c.jsx(gw,{grid:n,setGrid:o}),c.jsx(yw,{})]})})}const mr=[{id:"select",labelKey:"tool.select",hotkey:"V",descriptionKey:"tool.selectHint",icon:nv,switchTo:"select",iconOnly:!0},{id:"pan",labelKey:"tool.pan",hotkey:"H",descriptionKey:"tool.panHint",icon:ev,switchTo:"pan",groupBreakAfter:!0,iconOnly:!0},{id:"busbar",labelKey:"tool.bus",hotkey:"B",descriptionKey:"tool.busHint",icon:Dn,switchTo:"busbar"},{id:"junction",labelKey:"tool.junction",hotkey:"J",descriptionKey:"tool.junctionHint",icon:Kw,switchTo:"junction",iconOnly:!0},{id:"place",labelKey:"tool.place",hotkey:"P",descriptionKey:"tool.placeHint",icon:Or,switchTo:"place"},{id:"wire",labelKey:"tool.wire",hotkey:"W",descriptionKey:"tool.wireHint",icon:Nr,switchTo:"wire"},{id:"text",labelKey:"tool.text",hotkey:"T",descriptionKey:"tool.textHint",icon:Lr,switchTo:"text",iconOnly:!0}];function M4(){const e=ne(),t=x(d=>d.activeTool),n=x(d=>d.placeKind),o=x(d=>d.placeFromTerminal),r=x(d=>d.wireDragFrom),s=x(d=>d.busbarDrawStart),i=x(d=>d.selection.length>0||d.selectedNode!=null);let a=null,l=!1;switch(t){case"select":a=e(i?"mode.selectWithSel":"mode.selectEmpty"),i&&(l=!0);break;case"pan":a=e("mode.pan");break;case"wire":a=e(r?"mode.wireDragging":"mode.wireInit"),l=!0;break;case"busbar":a=e(s?"mode.busDragging":"mode.busInit"),l=!0;break;case"junction":a=e("mode.junction"),l=!0;break;case"place":n?o?a=e("mode.placeFromTerm"):a=e("mode.placeNormal"):a=e("mode.placeNoKind"),l=!0;break;case"text":a=e("mode.text"),l=!0;break}if(!a)return null;const u=e(t==="select"?"mode.escSelect":"mode.escOther");return c.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:[c.jsx("span",{children:a}),l&&c.jsxs("span",{className:"text-muted-foreground/70",children:["· ",u]})]})}function T4(){const e=ne(),t=x(h=>h.activeTool),n=x(h=>h.placeKind),o=x(h=>h.setActiveTool),r=x(h=>h.past.length),s=x(h=>h.future.length),i=x(h=>h.undo),a=x(h=>h.redo),l=Ke(),u=Ce(l,"tight"),d=!Ce(l,"dense"),m=Ce(l,"dense"),f=m?mr.filter(h=>h.id!=="select"&&h.id!=="text"):mr,p=h=>t===h.switchTo;return c.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))"},children:[d&&c.jsx(M4,{}),c.jsxs("div",{className:_e("ole-glass flex flex-row items-center rounded-2xl border border-border shadow-sm",m?"gap-0.5 p-1":"gap-0.5 p-1.5"),children:[m&&c.jsx(A4,{stacked:!0}),f.map(h=>{const g=h.icon,w=p(h),E=h.id==="place"&&w&&n==null?e("tool.placeNoKindTooltip"):e(h.descriptionKey);return c.jsxs(O.Fragment,{children:[c.jsx(it,{icon:g,label:e(h.labelKey),hotkey:h.hotkey,active:w,iconOnly:!m&&(h.iconOnly||u),stacked:m,description:E,onClick:()=>{o(h.switchTo,{placeKind:h.presetPlaceKind!==void 0?h.presetPlaceKind:void 0})}}),h.groupBreakAfter&&!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"})]},h.id)}),!m&&c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),m?c.jsx(I4,{stacked:!0}):c.jsxs(c.Fragment,{children:[c.jsx(it,{icon:Hn,label:e("tool.undo"),hotkey:"⌘Z",description:e("tool.undoHint"),iconOnly:!0,disabled:r===0,onClick:i}),c.jsx(it,{icon:Fn,label:e("tool.redo"),hotkey:"⌘⇧Z",description:e("tool.redoHint"),iconOnly:!0,disabled:s===0,onClick:a}),c.jsx("div",{"aria-hidden":!0,className:"mx-1 h-5 w-px bg-border"}),c.jsx(C4,{iconOnly:u})]}),m&&c.jsx(j4,{stacked:!0})]})]})}function A4({stacked:e}){const t=ne(),n=Et(r=>r.outlineOpen),o=Et(r=>r.toggleOutline);return c.jsx(it,{icon:Cr,label:t("outline.title"),active:n,iconOnly:!0,stacked:e,onClick:o})}function it({icon:e,label:t,hotkey:n,active:o,disabled:r,iconOnly:s,stacked:i,onClick:a,description:l}){const u=c.jsxs("div",{className:"space-y-0.5",children:[c.jsxs("div",{children:[c.jsx("span",{className:"font-medium",children:t}),n&&c.jsx("span",{className:"ml-1.5 text-muted-foreground",children:n})]}),l&&c.jsx("div",{className:"text-muted-foreground",children:l})]});return c.jsx(Me,{content:u,disabled:r,children:c.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:[c.jsxs("span",{className:"relative inline-flex shrink-0",children:[c.jsx(e,{className:"size-4"}),n&&!i&&c.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?c.jsx("span",{className:"max-w-full truncate",children:t}):!s&&c.jsx("span",{children:t})]})})}function xw(){const e=x(r=>r.diagram.elements),t=x(r=>r.diagram.layout),n=x(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 C4({iconOnly:e}){const t=ne(),[n,o]=O.useState(!1),r=xw(),s=i=>()=>{o(!1),i()};return c.jsxs(Yn,{open:n,onOpenChange:o,trigger:c.jsx(it,{icon:kt,label:t("layout.label"),description:t("layout.hint"),active:n,iconOnly:e,onClick:()=>o(i=>!i)}),children:[c.jsx(Ee,{onClick:s(()=>x.getState().autoArrangeAll()),icon:c.jsx(kt,{}),disabled:!r.hasAnyElement||!r.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Ee,{onClick:s(()=>x.getState().autoArrangeSelection()),icon:c.jsx(kt,{}),disabled:!r.hasSelection||!r.selectionHasArranged,children:t("layout.selAuto")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:s(()=>x.getState().fillUnplacedAll()),icon:c.jsx(Rt,{}),disabled:!r.hasGapsAll,children:t("layout.allFill")}),c.jsx(Ee,{onClick:s(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(Rt,{}),disabled:!r.hasSelection||!r.selectionHasGaps,children:t("layout.selFill")})]})}function I4({stacked:e}){const t=ne(),[n,o]=O.useState(!1),r=x(f=>f.past.length),s=x(f=>f.future.length),i=x(f=>f.undo),a=x(f=>f.redo),l=x(f=>f.selection.length>0),u=x(f=>f.clipboard!=null),d=xw(),m=f=>()=>{o(!1),f()};return c.jsxs(Yn,{open:n,onOpenChange:o,trigger:c.jsx(it,{icon:kn,label:t("tool.more"),description:t("tool.moreHint"),active:n,iconOnly:!0,stacked:e,onClick:()=>o(f=>!f)}),children:[c.jsx(Ee,{onClick:m(i),icon:c.jsx(Hn,{}),disabled:r===0,children:t("tool.undo")}),c.jsx(Ee,{onClick:m(a),icon:c.jsx(Fn,{}),disabled:s===0,children:t("tool.redo")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:m(()=>x.getState().cutSelection()),icon:c.jsx(Pr,{}),disabled:!l,children:t("menu.cut")}),c.jsx(Ee,{onClick:m(()=>x.getState().copySelection()),icon:c.jsx(Tr,{}),disabled:!l,children:t("menu.copy")}),c.jsx(Ee,{onClick:m(()=>x.getState().pasteClipboard()),icon:c.jsx(Mr,{}),disabled:!u,children:t("menu.paste")}),c.jsx("div",{"aria-hidden":!0,className:"my-1 h-px bg-border"}),c.jsx(Ee,{onClick:m(()=>x.getState().autoArrangeAll()),icon:c.jsx(kt,{}),disabled:!d.hasAnyElement||!d.hasArrangedAny,children:t("layout.allAuto")}),c.jsx(Ee,{onClick:m(()=>x.getState().autoArrangeSelection()),icon:c.jsx(kt,{}),disabled:!d.hasSelection||!d.selectionHasArranged,children:t("layout.selAuto")}),c.jsx(Ee,{onClick:m(()=>x.getState().fillUnplacedAll()),icon:c.jsx(Rt,{}),disabled:!d.hasGapsAll,children:t("layout.allFill")}),c.jsx(Ee,{onClick:m(()=>x.getState().fillUnplacedSelection()),icon:c.jsx(Rt,{}),disabled:!d.hasSelection||!d.selectionHasGaps,children:t("layout.selFill")})]})}function Ee({children:e,icon:t,onClick:n,disabled:o}){return c.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,c.jsx("span",{className:"flex-1",children:e})]})}function P4(){const e=Et(r=>r.outlineOpen),t=Et(r=>r.setOutlineOpen),n=Ke();return Ce(n,"dense")?e?c.jsx("div",{className:"absolute z-10",style:{left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"},children:c.jsx(fr,{onClose:()=>t(!1),sheet:!0})}):null:c.jsx("div",{className:"absolute z-10 flex flex-col items-start",style:{bottom:"calc(0.75rem + var(--ole-bottom-inset, 0px))",left:"calc(0.75rem + var(--ole-left-inset, 0px))",maxHeight:"calc(100% - 1.5rem)"},children:e?c.jsx(fr,{onClose:()=>t(!1)}):c.jsx(O4,{onClick:()=>t(!0)})})}function O4({onClick:e}){const t=ne(),n=Ke(),o=Ce(n,"compact");return c.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:[c.jsx(Cr,{className:"size-4 shrink-0"}),!o&&c.jsx("span",{className:"text-xs font-medium",children:t("outline.title")})]})}function fr({onClose:e,sheet:t}){const n=ne(),o=x(u=>u.diagram.elements),r=x(u=>u.activeTool==="place"),s=Ke(),i=Ce(s,"compact"),a=Ce(s,"dense"),l=t?"min(50vh, calc(100vh - 9rem))":r?"min(40vh, calc(100vh - 200px))":"min(70vh, calc(100vh - 100px))";return c.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:[c.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:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:n("outline.title")}),!a&&c.jsx(L4,{children:o.length}),c.jsx(ov,{className:"size-3.5 text-muted-foreground"})]}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:o.length===0?c.jsx("p",{className:"px-2 py-2 text-xs italic text-muted-foreground",children:n("outline.empty")}):c.jsx("ul",{className:"space-y-px",children:o.map(u=>c.jsx(B4,{element:u},u.id))})})]})}function B4({element:e}){const t=Xe[e.kind],n=x(l=>l.selection.includes(e.id)),o=x(l=>l.setSelection),r=x(l=>l.toggleInSelection),s=Ke(),i=!Ce(s,"compact"),a=l=>{l.shiftKey||l.metaKey||l.ctrlKey?r(e.id):o([e.id])};return c.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:[c.jsx("div",{className:"flex h-4 w-6 shrink-0 items-center justify-center",children:t&&c.jsx("svg",{viewBox:t.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:t.svg}})}),c.jsx("span",{className:"flex-1 truncate text-xs text-foreground/90 group-hover:text-accent-foreground",children:e.name??e.id}),i&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:e.id})]})}function L4({children:e}){return c.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 z4={"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":"负荷","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":"抽象负荷(电流流出箭头)","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":"剩余动作电流"},R4={"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","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"},hr={zh:z4,en:R4};function D4(e,t){return hr[e][t]??hr.zh[t]}function Mt(){const e=Nt(t=>t.locale);return(t,n)=>D4(e,t)??n??t}const bw="ole-palette-collapsed",F4=new Set(["busbar"]),St=(()=>{const e={};for(const[t,n]of Object.entries(y$)){const o=n.filter(r=>!F4.has(r.id));o.length&&(e[t]=o)}return e})(),H4=(()=>{const e=new Set(Bo),t=Object.keys(St).filter(n=>!e.has(n));return[...Bo.filter(n=>{var o;return(o=St[n])==null?void 0:o.length}),...t]})();function W4(){try{const e=window.localStorage.getItem(bw);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 q4(e){try{window.localStorage.setItem(bw,JSON.stringify([...e]))}catch{}}function G4(){const e=ne(),t=x(m=>m.activeTool==="place"),n=x(m=>m.placeKind),o=x(m=>m.setActiveTool),r=Et(m=>m.outlineOpen),s=Ke(),i=Ce(s,"dense"),a=68,u=i?void 0:`calc(100vh - ${a}px - ${r?"calc(40vh + 20px)":"68px"})`;if(!t||i&&n!=null)return null;const d=i?{top:`calc(${a}px + var(--ole-top-inset, 0px))`,left:"calc(0.75rem + var(--ole-left-inset, 0px))",right:"calc(0.75rem + var(--ole-right-inset, 0px))",bottom:"calc(4rem + var(--ole-bottom-inset, 0px) + 0.75rem)"}:{top:a};return c.jsx("div",{className:i?"absolute z-20":"absolute left-3 z-20",style:d,role:"dialog","aria-label":e("library.title"),children:c.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:u?{maxHeight:u}:void 0,children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:e("library.title")}),c.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:c.jsx(Wn,{className:"size-3.5"})})]}),c.jsx(X4,{sheet:i})]})})}function X4({sheet:e}){const t=ne(),n=Mt(),[o,r]=O.useState(""),[s,i]=O.useState(()=>W4()),a=O.useMemo(()=>{const m=o.trim().toLowerCase();if(!m)return St;const f={};for(const[p,h]of Object.entries(St)){const g=h.filter(w=>{const E=n(`${w.id}.name`,w.name).toLowerCase(),k=n(`${w.id}.desc`,w.description??"").toLowerCase();return E.includes(m)||w.id.toLowerCase().includes(m)||k.includes(m)});g.length&&(f[p]=g)}return f},[o,n]),l=o.trim().length>0,u=l&&Object.values(a).every(m=>!(m!=null&&m.length)),d=O.useCallback((m,f)=>{i(p=>{const h=new Set(p);return f?h.delete(m):h.add(m),q4(h),h})},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"px-2 pb-1.5 pt-2",children:c.jsx(K4,{value:o,onChange:r})}),c.jsx("div",{className:"flex-1 overflow-y-auto px-2 pb-2",children:u?c.jsx("p",{className:"px-3 py-6 text-center text-xs text-muted-foreground",children:t("library.empty")}):H4.map(m=>{var w;const f=a[m];if(!(f!=null&&f.length))return null;const p=((w=St[m])==null?void 0:w.length)??f.length,h=t(`cat.${m}`),g=l||!s.has(m);return c.jsxs("details",{open:g,className:"group mb-2 last:mb-0",onToggle:E=>{l||d(m,E.currentTarget.open)},children:[c.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:[c.jsx(Xw,{className:"size-3 transition-transform [details:not([open])>summary>&]:-rotate-90"}),c.jsx("span",{className:"flex-1",children:h}),c.jsx(V4,{children:l&&f.length!==p?`${f.length}/${p}`:p})]}),c.jsx("ul",{className:"mt-0.5 space-y-px",children:f.map(E=>c.jsx(Y4,{entry:E,sheet:e},E.id))})]},m)})})]})}function K4({value:e,onChange:t}){const n=ne();return c.jsxs("div",{className:"relative",children:[c.jsx(sv,{className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),c.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&&c.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:c.jsx(Wn,{className:"size-3"})})]})}function Y4({entry:e,sheet:t}){const n=ne(),o=Mt(),r=o(`${e.id}.name`,e.name),s=o(`${e.id}.desc`,e.description??""),i=x(m=>m.setActiveTool),a=x(m=>m.activeTool==="place"&&m.placeKind===e.id),l=x(m=>t&&m.activeTool==="place"&&m.placeKind==null&&m.lastPlaceKind===e.id),u=O.useRef(null);O.useEffect(()=>{var m;l&&((m=u.current)==null||m.scrollIntoView({block:"nearest"}))},[l]);const d=m=>{m.dataTransfer.effectAllowed="copy",m.dataTransfer.setData("application/x-oneline-kind",e.id),m.dataTransfer.setData("text/plain",e.id);const f=document.createElement("div");f.className="ole-glass",f.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(";"),f.innerHTML=`<svg class="ole-symbol" viewBox="${e.viewBox}" width="48" height="48" preserveAspectRatio="xMidYMid meet">${e.svg}</svg>`,document.body.appendChild(f),m.dataTransfer.setDragImage(f,32,32),setTimeout(()=>f.remove(),0)};return c.jsxs("li",{ref:u,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:d,onClick:()=>i("place",{placeKind:e.id}),"data-kind":e.id,title:s?`${r} — ${s}`:`${r} — ${n("library.itemHint")}`,children:[c.jsx("div",{className:"flex h-7 w-12 shrink-0 items-center justify-center",children:c.jsx("svg",{viewBox:e.viewBox,className:"ole-symbol size-full",preserveAspectRatio:"xMidYMid meet",dangerouslySetInnerHTML:{__html:e.svg}})}),c.jsx("span",{className:"truncate text-xs text-foreground/80 group-hover:text-accent-foreground",children:r})]})}function V4({children:e}){return c.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 zn="ole-onboarding-dismissed";function U4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(zn)==="1"}catch{return!1}}function pr(e){try{e?window.localStorage.setItem(zn,"1"):window.localStorage.removeItem(zn)}catch{}}const gr=Xt(e=>({dismissed:U4(),dismiss:()=>{pr(!0),e({dismissed:!0})},reset:()=>{pr(!1),e({dismissed:!1})}}));function J4(){const e=ne(),t=gr(o=>o.dismissed),n=gr(o=>o.dismiss);return t?null:c.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:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm font-semibold",children:e("onboard.title")}),c.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:c.jsx(Wn,{className:"size-3.5"})})]}),c.jsxs("ol",{className:"mt-3 space-y-2.5",children:[c.jsx(wn,{n:1,icon:c.jsx(Dn,{}),title:e("onboard.step1.title"),body:e("onboard.step1.body")}),c.jsx(wn,{n:2,icon:c.jsx(Or,{}),title:e("onboard.step2.title"),body:e("onboard.step2.body")}),c.jsx(wn,{n:3,icon:c.jsx(Nr,{}),title:e("onboard.step3.title"),body:e("onboard.step3.body")})]}),c.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 wn({n:e,icon:t,title:n,body:o}){return c.jsxs("li",{className:"flex items-start gap-2.5",children:[c.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}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium",children:[c.jsx("span",{className:"text-muted-foreground [&>svg]:size-3.5",children:t}),c.jsx("span",{children:n})]}),c.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-muted-foreground",children:o})]})]})}function Z4(){const e=ne(),t=x(f=>f.selection),n=x(f=>f.diagram.elements),o=x(f=>f.diagram.buses),r=x(f=>f.diagram.junctions),s=x(f=>f.selectedNode),i=x(f=>f.selectedWire);if(i)return c.jsx(rj,{wireId:i});if(s)return c.jsx(ij,{nodeId:s});if(t.length===0)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.empty")});if(t.length>1)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:e("props.multi",{n:t.length})});const a=t[0],l=(o??[]).find(f=>f.id===a);if(l)return c.jsx(nj,{bus:l});const u=(r??[]).find(f=>f.id===a);if(u)return c.jsx(sj,{junction:u});const d=n.find(f=>f.id===a);if(!d)return null;const m=Xe[d.kind];return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(dt,{label:e("props.name"),value:d.name??"",placeholder:d.id,onCommit:f=>x.getState().updateElement(a,{name:f.trim()===""?void 0:f.trim()})}),c.jsx(Un,{label:e("props.note"),value:d.note??"",onCommit:f=>x.getState().updateElement(a,{note:f.trim()===""?void 0:f.trim()})}),(m==null?void 0:m.state)&&m.state.length>0&&c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:m.state.map(f=>c.jsx(aj,{id:a,element:d,field:f},f.name))}),c.jsx(Q4,{id:a,element:d,schema:(m==null?void 0:m.params)??[]})]})}function Q4({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:c.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:[n.map(s=>c.jsx(ej,{id:e,element:t,field:s},s.name)),r.map(([s,i])=>c.jsx(tj,{id:e,element:t,fieldKey:s,value:i},s))]})}function ej({id:e,element:t,field:n}){var l;const o=ne(),r=Mt(),s=((l=t.params)==null?void 0:l[n.name])??n.default,i=r(`${t.kind}.param.${n.name}`,n.label??n.name),a=u=>{const d={...t.params??{}};u===void 0||u===n.default?delete d[n.name]:d[n.name]=u,x.getState().updateElement(e,{params:Object.keys(d).length>0?d:void 0})};return n.type==="boolean"?c.jsx(ct,{label:i,children:c.jsx(Jn,{active:!!s,onClick:()=>a(!s),children:o(s?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Qt,{label:i,value:typeof s=="number"?s:0,unit:n.unit,onCommit:a}):c.jsx(dt,{label:i,value:typeof s=="string"?s:"",unit:n.unit,onCommit:u=>a(u.trim()===""?void 0:u)})}function tj({id:e,element:t,fieldKey:n,value:o}){const r=ne(),s=i=>{const a={...t.params??{}};i===void 0?delete a[n]:a[n]=i,x.getState().updateElement(e,{params:Object.keys(a).length>0?a:void 0})};return typeof o=="boolean"?c.jsx(ct,{label:n,children:c.jsx(Jn,{active:o,onClick:()=>s(!o),children:r(o?"common.yes":"common.no")})}):typeof o=="number"?c.jsx(Qt,{label:n,value:o,onCommit:s}):c.jsx(dt,{label:n,value:o,onCommit:i=>s(i.trim()===""?void 0:i)})}function nj({bus:e}){const t=ne(),n=e.id,o=r=>{const s=r.trim();Rn(n,{name:s===""?void 0:s})};return c.jsxs("div",{className:"flex flex-col gap-2.5 overflow-y-auto px-3 py-3 text-xs",children:[c.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:o}),c.jsx(Un,{label:t("props.note"),value:e.note??"",onCommit:r=>Rn(n,{note:r.trim()===""?void 0:r.trim()})}),c.jsx(oj,{bus:e})]})}function oj({bus:e}){const t=(o,r)=>{const s={...e.params??{}};r===void 0||r===""?delete s[o]:s[o]=r,Rn(e.id,{params:Object.keys(s).length>0?s:void 0})},n=e.params??{};return c.jsx("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border/40 pt-2.5",children:c.jsx(Qt,{label:"Un",value:typeof n.Un=="number"?n.Un:0,unit:"kV",onCommit:o=>t("Un",o)})})}function Rn(e,t){x.getState().dispatch(n=>{const o=(n.buses??[]).map(r=>r.id===e?{...r,...t}:r);return{...n,buses:o}})}function rj({wireId:e}){const t=ne(),n=x(w=>w.diagram.wires),o=x(w=>w.diagram.elements),r=x(w=>w.diagram.buses),s=x(w=>w.diagram.junctions),i=x(w=>w.internal.terminalToNode),a=x(w=>w.setSelectedNode),l=(n??[]).find(w=>w.id===e);if(!l)return c.jsx("div",{className:"px-4 py-5 text-center text-xs text-muted-foreground",children:t("props.wireNotFound",{id:e})});const u=i.get(l.ends[0]),d=new Map(o.map(w=>[w.id,w])),m=new Map((r??[]).map(w=>[w.id,w])),f=new Map((s??[]).map(w=>[w.id,w])),p=w=>{if(!w.includes(".")){const A=m.get(w);if(A)return{id:w,label:A.name??w};const B=f.get(w);return{id:w,label:(B==null?void 0:B.name)??w}}const E=w.indexOf("."),k=w.slice(0,E),b=w.slice(E+1),$=d.get(k);return{id:k,label:($==null?void 0:$.name)??k,pin:b}},h=p(l.ends[0]),g=p(l.ends[1]);return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.wire")}),c.jsx("div",{className:"font-mono text-[12px]",children:l.id})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[h,g].map((w,E)=>c.jsxs("li",{className:"flex cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 hover:bg-accent",onClick:()=>x.getState().setSelection([w.id]),children:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:w.id}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:w.label}),w.pin&&c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:w.pin})]},E))}),u&&c.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(u),children:t("props.selectWholeNode")})]})}function sj({junction:e}){var r;const t=ne(),n=x(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 c.jsxs("div",{className:"flex flex-col gap-2.5 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.junction")}),c.jsx("div",{className:"font-mono text-[12px]",children:e.id})]}),c.jsx(dt,{label:t("props.name"),value:e.name??"",placeholder:e.id,onCommit:s=>x.getState().updateJunction(e.id,{name:s.trim()===""?void 0:s.trim()})}),c.jsx(Un,{label:t("props.note"),value:e.note??"",onCommit:s=>x.getState().updateJunction(e.id,{note:s.trim()===""?void 0:s.trim()})}),o&&c.jsxs("div",{className:"flex items-center justify-between border-t border-border/40 pt-2",children:[c.jsx("span",{className:"text-muted-foreground",children:t("props.junctionPos")}),c.jsxs("span",{className:"font-mono text-[11px]",children:[Math.round(o[0]),", ",Math.round(o[1])]})]})]})}function ij({nodeId:e}){const t=ne(),n=x(a=>a.internal.nodes.get(e)),o=x(a=>a.diagram.elements),r=x(a=>a.setSelection);if(!n)return c.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 u=a.slice(0,l),d=a.slice(l+1),m=s.get(u)??[];m.push(d),s.set(u,m)}const i=new Map(o.map(a=>[a.id,a]));return c.jsxs("div",{className:"flex flex-col gap-3 px-3 py-3 text-xs",children:[c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:t("props.node")}),c.jsx("div",{className:"font-mono text-[12px]",children:n.id}),c.jsx("div",{className:"text-[11px] text-muted-foreground",children:t("props.nodeStats",{terminals:n.terminals.length,elements:s.size})})]}),c.jsx("ul",{className:"space-y-0.5 border-t border-border/40 pt-2",children:[...s.entries()].map(([a,l])=>{const u=i.get(a);return c.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:[c.jsx("span",{className:"flex-1 truncate font-mono text-[11px]",children:a}),c.jsx("span",{className:"truncate text-[10px] text-muted-foreground",children:(u==null?void 0:u.name)??""}),c.jsx("span",{className:"font-mono text-[10px] text-muted-foreground/80",children:l.join(", ")})]},a)})})]})}function ct({label:e,children:t}){return c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("label",{className:"w-16 shrink-0 truncate text-[11px] text-muted-foreground",children:e}),c.jsx("div",{className:"min-w-0 flex-1",children:t})]})}function dt({label:e,value:t,placeholder:n,unit:o,onCommit:r}){const[s,i]=O.useState(t),a=O.useRef(null);return O.useEffect(()=>i(t),[t]),c.jsx(ct,{label:e,children:c.jsxs("div",{className:"relative",children:[c.jsx("input",{ref:a,type:"text",value:s,placeholder:n,onChange:l=>i(l.target.value),onBlur:()=>{s!==t&&r(s)},onKeyDown:l=>{var u,d;l.key==="Enter"&&((u=a.current)==null||u.blur()),l.key==="Escape"&&(i(t),(d=a.current)==null||d.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&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Un({label:e,value:t,onCommit:n}){const[o,r]=O.useState(t);return O.useEffect(()=>r(t),[t]),c.jsx(ct,{label:e,children:c.jsx("textarea",{rows:2,value:o,onChange:s=>r(s.target.value),onBlur:()=>{o!==t&&n(o)},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 Qt({label:e,value:t,min:n,unit:o,onCommit:r}){const[s,i]=O.useState(String(t)),a=O.useRef(null);return O.useEffect(()=>i(String(t)),[t]),c.jsx(ct,{label:e,children:c.jsxs("div",{className:"relative",children:[c.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 u,d;l.key==="Enter"&&((u=a.current)==null||u.blur()),l.key==="Escape"&&(i(String(t)),(d=a.current)==null||d.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&&c.jsx("span",{className:"pointer-events-none absolute right-2 top-1/2 -translate-y-1/2 text-[10px] text-muted-foreground",children:o})]})})}function Jn({active:e,onClick:t,children:n}){return c.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 aj({id:e,element:t,field:n}){var l;const o=ne(),s=Mt()(`${t.kind}.state.${n.name}`,n.label??n.name),i=((l=t.state)==null?void 0:l[n.name])??n.default,a=u=>{const d={...t.state??{}};u===void 0||u===n.default?delete d[n.name]:d[n.name]=u,x.getState().updateElement(e,{state:Object.keys(d).length>0?d:void 0})};return n.type==="boolean"?c.jsx(ct,{label:s,children:c.jsx(Jn,{active:!!i,onClick:()=>a(!i),children:o(i?"common.yes":"common.no")})}):n.type==="number"?c.jsx(Qt,{label:s,value:typeof i=="number"?i:0,onCommit:a}):c.jsx(dt,{label:s,value:typeof i=="string"?i:"",onCommit:u=>a(u.trim()===""?void 0:u)})}function lj(){const e=ne(),t=Mt(),n=x(m=>m.selection),o=x(m=>m.selectedNode),r=x(m=>m.selectedWire),s=x(m=>m.diagram.elements),i=x(m=>m.diagram.buses),a=Ke(),l=Ce(a,"dense");if(n.length===0&&!o&&!r)return null;let u=e("props.title"),d=null;if(r)u=e("props.wire");else if(o)u=e("props.node");else if(n.length===1){const m=n[0],f=(i??[]).find(p=>p.id===m);if(f)u=f.name??e("props.bus");else{const p=s.find(h=>h.id===m);if(p){const h=Xe[p.kind];u=h?t(`${h.id}.name`,h.name):p.kind}}}else d=n.length;return c.jsxs("aside",{className:_e("ole-glass absolute z-10 flex flex-col overflow-hidden rounded-2xl border border-border shadow-sm",l?"w-48":"w-56"),style:{top:`calc(${l?"4.5rem":"0.75rem"} + var(--ole-top-inset, 0px))`,right:"calc(0.75rem + var(--ole-right-inset, 0px))",maxHeight:`calc(100% - ${l?"5.25rem":"1.5rem"} - var(--ole-top-inset, 0px) - var(--ole-bottom-inset, 0px) - 4.5rem)`},children:[c.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border/40 px-3 py-2",children:[c.jsx("span",{className:"flex-1 truncate text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:u}),d!=null&&c.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:d})})]}),c.jsx(Z4,{})]})}function cj(){O.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 dj(){cj();const e=O.useRef(null),t=jS(e);return c.jsx(Fv,{children:c.jsx("div",{ref:e,className:"relative h-full w-full overflow-hidden bg-background text-foreground",children:c.jsxs(n4,{width:t,children:[c.jsx(XS,{}),c.jsx(P4,{}),c.jsx(lj,{}),c.jsx(T4,{}),c.jsx(E4,{}),c.jsx(y4,{}),c.jsx(G4,{}),c.jsx(J4,{}),c.jsx(e4,{})]})})})}const uj="ole-theme";function mj(){try{const e=window.localStorage.getItem(uj);return e==="light"||e==="dark"?e:null}catch{return null}}function fj(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches}function hj(){return typeof window>"u"?"light":mj()??(fj()?"dark":"light")}function ww(e){typeof document>"u"||document.documentElement.classList.toggle("dark",e==="dark")}function pj({className:e,diagram:t,locale:n,theme:o}){return O.useEffect(()=>{if(!t)return;x.getState().diagram.elements.length===0&&x.getState().setDiagram(t)},[t]),O.useEffect(()=>{n&&Nt.getState().setLocale(n)},[n]),O.useEffect(()=>{o&&ww(o)},[o]),O.useEffect(()=>{Kn()},[]),uS(),c.jsx("div",{className:`ole-root ${e??"h-full w-full"}`,children:c.jsx(dj,{})})}const vw={"application/json":[".json"]},kw=()=>typeof window<"u"&&typeof window.showOpenFilePicker=="function",_w=e=>e instanceof DOMException&&e.name==="AbortError";function yr(e){let t;try{t=JSON.parse(e)}catch(o){throw new Error(we("io.parseFailed",{err:o.message}))}if(!t||typeof t!="object"||Array.isArray(t))throw new Error(we("io.notObject"));const n=t;if(n.version!=="1")throw new Error(we("io.versionMismatch",{actual:JSON.stringify(n.version)}));if(!Array.isArray(n.elements))throw new Error(we("io.elementsMissing"));return n}function gj(e){return JSON.stringify(e,null,2)+`
|
|
199
|
+
`}async function yj(){if(kw()){let e;try{[e]=await window.showOpenFilePicker({multiple:!1,types:[{description:we("topbar.file.fileDescription"),accept:vw}]})}catch(n){if(_w(n))return null;throw n}const t=await e.getFile();return{diagram:yr(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:yr(await o.text()),session:{name:o.name}})}catch(s){t(s)}}),n.addEventListener("cancel",()=>e(null)),n.click()})}async function xr(e,t,n={}){const o=gj(e);if(!n.saveAs&&(t!=null&&t.handle)){const i=await t.handle.createWritable();return await i.write(o),await i.close(),t}if(kw()){let i;try{i=await window.showSaveFilePicker({suggestedName:(t==null?void 0:t.name)??"diagram.json",types:[{description:we("topbar.file.fileDescription"),accept:vw}]})}catch(l){if(_w(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 xj(){const e=ne(),t=x(m=>m.fileSession),n=(t==null?void 0:t.name)??e("common.unnamed"),{onNew:o,onOpen:r,onSave:s,onSaveAs:i}=bj(),[a,l]=O.useState(!1),u=O.useRef(null);O.useEffect(()=>{const m=f=>{if(!(f.metaKey||f.ctrlKey))return;const p=f.key.toLowerCase();p==="o"?(f.preventDefault(),r()):p==="s"&&(f.preventDefault(),f.shiftKey?i():s())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,s,i]),O.useEffect(()=>{if(!a)return;const m=p=>{u.current&&!u.current.contains(p.target)&&l(!1)},f=p=>{p.key==="Escape"&&l(!1)};return window.addEventListener("mousedown",m),window.addEventListener("keydown",f),()=>{window.removeEventListener("mousedown",m),window.removeEventListener("keydown",f)}},[a]);const d=m=>()=>{l(!1),m()};return c.jsxs("div",{ref:u,className:"relative",children:[c.jsxs(Ne,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":a,onClick:()=>l(m=>!m),children:[c.jsx(yo,{}),e("topbar.file.label")]}),a&&c.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:[c.jsx("div",{className:"border-b border-border px-2 pb-1.5 pt-1 text-xs text-muted-foreground",children:n}),c.jsx(Bt,{onClick:d(o),icon:c.jsx(Jw,{}),children:e("topbar.file.new")}),c.jsx(Bt,{onClick:d(r),icon:c.jsx(yo,{}),hint:"⌘O",children:e("topbar.file.open")}),c.jsx(Bt,{onClick:d(s),icon:c.jsx(xo,{}),hint:"⌘S",children:e("topbar.file.save")}),c.jsx(Bt,{onClick:d(i),icon:c.jsx(xo,{}),hint:"⌘⇧S",children:e("topbar.file.saveAs")})]})]})}function Bt({children:e,icon:t,hint:n,onClick:o}){return c.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,c.jsx("span",{className:"flex-1",children:e}),n&&c.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n})]})}function bj(){const e=ne(),t=x(l=>l.loadDiagramFromFile),n=x(l=>l.setFileSession),o=x(l=>l.setDiagram);return{onNew:()=>{const{diagram:l}=x.getState();l.elements.length>0&&!confirm(e("topbar.file.newConfirm"))||(o({version:"1",elements:[]}),n(null))},onOpen:async()=>{try{const l=await yj();l&&(t(l.diagram,l.session),Kn())}catch(l){alert(e("topbar.file.openFailed",{err:l.message}))}},onSave:async()=>{try{const{diagram:l,fileSession:u}=x.getState(),d=await xr(l,u);d&&n(d)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}},onSaveAs:async()=>{try{const{diagram:l,fileSession:u}=x.getState(),d=await xr(l,u,{saveAs:!0});d&&n(d)}catch(l){alert(e("topbar.file.saveFailed",{err:l.message}))}}}}const vn="WIRES",Re="ELEMENTS",br="LABELS",wr="ANNOTATIONS",vr=32,kr=64,wj=8,vj=1.25,kj=6;function $w(e,t={}){const n=new Oj(t.precision??6);n.header(t.title),n.tables([{name:vn,color:7},{name:Re,color:7},{name:br,color:8},{name:wr,color:3}]),n.beginEntities();for(const r of e.wireRenders.values())r.path.length<2||n.lwpolyline(vn,r.path.map(Te),!1);for(const{geometry:r}of e.buses.values()){const{axis:s,at:i,span:a}=r,l=a/2,u=s==="x"?[i[0]-l,i[1]]:[i[0],i[1]-l],d=s==="x"?[i[0]+l,i[1]]:[i[0],i[1]+l];n.lwpolyline(vn,[u,d].map(Te),!1)}for(const r of e.elements.values()){const s=e.layout.get(r.element.id),i=r.libraryDef;!s||!i||_j(n,i.svg,s)}const o=t.labelMode??"all";if(o!=="off")for(const r of e.elements.values()){const s=e.layout.get(r.element.id);if(!s||!r.libraryDef)continue;const i=Yt(r,o);if(i.length===0)continue;const a=r.libraryDef.label??Vt(r.libraryDef),[l,u]=Ut(a,s);for(let d=0;d<i.length;d++){const[m,f]=Te([l,u+d*Kt]);n.text(br,[m,f],i[d],Ht,0,!1)}}for(const r of t.annotations??[]){if(!r.text)continue;const s=r.fontSize??wj,i=r.text.split(`
|
|
200
|
+
`);for(let a=0;a<i.length;a++){const[l,u]=Te([r.at[0],r.at[1]+(a+1)*s*vj]);n.text(wr,[l,u],i[a],s,0,!1)}}return n.endEntities(),n.toString()}async function Sw(e,t="diagram.dxf",n){const o=$w(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 _j(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":$j(e,i,n);break;case"polyline":_r(e,i,n,!1);break;case"polygon":_r(e,i,n,!0);break;case"rect":Sj(e,i,n);break;case"circle":jj(e,i,n);break;case"ellipse":Ej(e,i,n);break;case"path":Aj(e,i,n);break;case"text":Tj(e,i,n);break}}function $j(e,t,n){const o=ve(t,"x1"),r=ve(t,"y1"),s=ve(t,"x2"),i=ve(t,"y2"),a=Te(ze([o,r],n)),l=Te(ze([s,i],n));e.line(Re,a,l)}function _r(e,t,n,o){const r=Pj(t.getAttribute("points")??"");if(r.length<2)return;const s=r.map(i=>Te(ze(i,n)));e.lwpolyline(Re,s,o)}function Sj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=ve(t,"width"),i=ve(t,"height"),l=[[o,r],[o+s,r],[o+s,r+i],[o,r+i]].map(u=>Te(ze(u,n)));e.lwpolyline(Re,l,!0)}function jj(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"r"),i=Te(ze([o,r],n));e.circle(Re,i,s)}function Ej(e,t,n){const o=ve(t,"cx"),r=ve(t,"cy"),s=ve(t,"rx"),i=ve(t,"ry");if(Math.abs(s-i)<1e-6){Nj(e,o,r,s,n);return}Mj(e,o,r,s,i,n)}function Nj(e,t,n,o,r){const s=Te(ze([t,n],r));e.circle(Re,s,o)}function Mj(e,t,n,o,r,s){const i=[];for(let a=0;a<kr;a++){const l=a/kr*Math.PI*2;i.push(Te(ze([t+o*Math.cos(l),n+r*Math.sin(l)],s)))}e.lwpolyline(Re,i,!0)}function Tj(e,t,n){const o=ve(t,"x"),r=ve(t,"y"),s=parseFloat(t.getAttribute("font-size")??"")||kj,i=(t.textContent??"").trim();if(!i)return;const a=Te(ze([o,r],n));e.text(Re,a,i,s,n.rot,n.mirror)}function Aj(e,t,n){const o=t.getAttribute("d")??"",r=Cj(o);if(r.length===0)return;let s=null,i=[];const a=()=>{i.length>=2&&e.lwpolyline(Re,i.map(l=>Te(ze(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[u,d,,m,f,p,h]=l.args,g=Ij(s,[p,h],u,d,m!==0,f!==0);if(g)for(let w=1;w<=vr;w++){const E=g.theta1+g.delta*w/vr;i.push([g.cx+u*Math.cos(E),g.cy+d*Math.sin(E)])}else i.push([p,h]);s=[p,h]}a()}function Cj(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 Ij(e,t,n,o,r,s){if(n<=0||o<=0)return null;const[i,a]=e,[l,u]=t;if(i===l&&a===u)return null;const d=(i-l)/2,m=(a-u)/2;let f=Math.abs(n),p=Math.abs(o);const h=f*f,g=p*p,w=d*d/h+m*m/g;if(w>1){const F=Math.sqrt(w);f*=F,p*=F}const E=r===s?-1:1,k=f*f*p*p-f*f*m*m-p*p*d*d,b=f*f*m*m+p*p*d*d,$=E*Math.sqrt(Math.max(0,k/b)),A=$*(f*m)/p,B=$*-(p*d)/f,W=A+(i+l)/2,K=B+(a+u)/2,oe=(F,Z,ae,ce)=>{const Q=F*ae+Z*ce,he=Math.hypot(F,Z)*Math.hypot(ae,ce);let pe=Math.acos(Math.max(-1,Math.min(1,Q/he)));return F*ce-Z*ae<0&&(pe=-pe),pe},ie=oe(1,0,(d-A)/f,(m-B)/p);let R=oe((d-A)/f,(m-B)/p,(-d-A)/f,(-m-B)/p);return!s&&R>0?R-=2*Math.PI:s&&R<0&&(R+=2*Math.PI),{cx:W,cy:K,theta1:ie,delta:R}}function ze(e,t){return Ae(e,t)}function Te(e){return[e[0],-e[1]]}function ve(e,t){const n=parseFloat(e.getAttribute(t)??"");return Number.isFinite(n)?n:0}function Pj(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 Oj{constructor(t){ht(this,"out",[]);ht(this,"precision");this.precision=t}toString(){return this.out.join("")}g(t,n){this.out.push(`${t}
|
|
196
201
|
${this.fmt(n)}
|
|
197
|
-
`)}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
|
|
198
|
-
`);for(let
|
|
199
|
-
`)}function
|
|
200
|
-
`),m=
|
|
202
|
+
`)}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,$r(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){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,$r(o)),s!==0&&this.g(50,s),i&&this.g(71,2)}}function $r(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}const Bj="http://www.w3.org/2000/svg",Lt=24,jw=8,Ew=1.25;function Zn(e,t={}){const n=Lj(e,t),o=Math.floor(n.minX-Lt),r=Math.floor(n.minY-Lt),s=Math.ceil(n.maxX+Lt)-o,i=Math.ceil(n.maxY+Lt)-r,a=t.background??"#FFFFFF",l=[];l.push('<?xml version="1.0" encoding="UTF-8"?>'),l.push(`<svg xmlns="${Bj}" viewBox="${o} ${r} ${s} ${i}" width="${s}" height="${i}">`),t.title&&l.push(` <title>${ot(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 f=m.path.map(([p,h])=>`${p},${h}`).join(" ");l.push(` <polyline points="${f}"/>`)}l.push(" </g>");for(const{bus:m,geometry:f}of e.buses.values()){const{axis:p,at:h,span:g}=f,w=g/2,E=p==="x"?h[0]-w:h[0],k=p==="x"?h[1]:h[1]-w,b=p==="x"?h[0]+w:h[0],$=p==="x"?h[1]:h[1]+w;l.push(` <line id="${ot(m.id)}" x1="${E}" y1="${k}" x2="${b}" y2="${$}" stroke="black" stroke-width="3" stroke-linecap="round" fill="none"/>`)}for(const{junction:m,world:f}of e.junctions.values())l.push(` <circle id="${ot(m.id)}" cx="${f[0]}" cy="${f[1]}" r="3.5" fill="black"/>`);for(const m of e.elements.values()){if(!m.libraryDef)continue;const f=e.layout.get(m.element.id);f&&(l.push(` <g id="${ot(m.element.id)}" transform="${Ge(f)}">`),l.push(` ${m.libraryDef.svg}`),l.push(" </g>"))}const u=t.labelMode??"all";if(u!=="off"){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" font-size="${Ht}" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const f of e.elements.values()){const p=e.layout.get(f.element.id);if(!p||!f.libraryDef)continue;const h=Yt(f,u);if(h.length===0)continue;const g=f.libraryDef.label??Vt(f.libraryDef),[w,E]=Ut(g,p),k=g.anchor??"start";for(let b=0;b<h.length;b++)l.push(` <text x="${w}" y="${E+b*Kt}" text-anchor="${k}">${ot(h[b])}</text>`)}l.push(" </g>")}const d=t.annotations??[];if(d.length>0){const m=a==="transparent"?"#FFFFFF":a;l.push(` <g fill="black" font-family="ui-sans-serif, system-ui, sans-serif" paint-order="stroke" stroke="${m}" stroke-width="2" stroke-linejoin="round">`);for(const f of d){if(!f.text)continue;const p=f.fontSize??jw,h=f.text.split(`
|
|
203
|
+
`);for(let g=0;g<h.length;g++){const w=f.at[1]+p*.85+g*p*Ew;l.push(` <text x="${f.at[0]}" y="${w}" font-size="${p}">${ot(h[g])}</text>`)}}l.push(" </g>")}return l.push("</svg>"),l.join(`
|
|
204
|
+
`)}function Lj(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0;const i=(l,u)=>{l<n&&(n=l),l>r&&(r=l),u<o&&(o=u),u>s&&(s=u)};for(const l of e.terminals.values())i(l.world[0],l.world[1]);for(const l of e.junctions.values())i(l.world[0],l.world[1]);for(const l of e.elements.values()){const u=e.layout.get(l.element.id),d=l.libraryDef;if(!u||!d)continue;const m=zj(d.viewBox);if(!m){i(u.at[0],u.at[1]);continue}const f=[[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 f){const[h,g]=Ae(p,u);i(h,g)}}for(const{geometry:l}of e.buses.values()){const{axis:u,at:d,span:m}=l,f=m/2;u==="x"?(i(d[0]-f,d[1]),i(d[0]+f,d[1])):(i(d[0],d[1]-f),i(d[0],d[1]+f))}for(const l of e.wireRenders.values())for(const[u,d]of l.path)i(u,d);const a=t.labelMode??"all";if(a!=="off")for(const l of e.elements.values()){const u=e.layout.get(l.element.id);if(!u||!l.libraryDef)continue;const d=Yt(l,a);if(d.length===0)continue;const m=l.libraryDef.label??Vt(l.libraryDef),[f,p]=Ut(m,u),h=Sr(d,Ht),g=d.length*Kt,w=m.anchor??"start",E=w==="middle"?f-h/2:w==="end"?f-h:f;i(E,p-Ht),i(E+h,p+g)}for(const l of t.annotations??[]){if(!l.text)continue;const u=l.fontSize??jw,d=l.text.split(`
|
|
205
|
+
`),m=Sr(d,u),f=d.length*u*Ew;i(l.at[0],l.at[1]),i(l.at[0]+m,l.at[1]+f)}return n===1/0&&(n=0,o=0,r=0,s=0),{minX:n,minY:o,maxX:r,maxY:s}}function Sr(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 zj(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 ot(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}async function Nw(e,t="diagram.svg",n){const o=Zn(e,n);Tw(new Blob([o],{type:"image/svg+xml;charset=utf-8"}),t)}async function Mw(e,t="diagram.png",n){const o=Zn(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 Rj(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 u=await new Promise((d,m)=>{a.toBlob(f=>f?d(f):m(new Error("toBlob failed")),"image/png")});Tw(u,t)}finally{URL.revokeObjectURL(s)}}function Rj(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 Tw(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,o.click(),URL.revokeObjectURL(n)}function Dj(){const e=ne(),[t,n]=O.useState(!1),o=O.useRef(null);O.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 m,f,p,h;n(!1);const{internal:i,diagram:a,fileSession:l}=x.getState(),u=((m=l==null?void 0:l.name)==null?void 0:m.replace(/\.json$/i,""))??((f=a.meta)==null?void 0:f.title)??"diagram",d={title:(p=a.meta)==null?void 0:p.title,labelMode:(h=a.meta)==null?void 0:h.labelMode,annotations:a.annotations};s==="svg"?Nw(i,`${u}.svg`,d):s==="png"?Mw(i,`${u}.png`,{...d,scale:2}).catch(g=>{console.error(g),alert(e("topbar.export.pngFailed",{err:g.message}))}):Sw(i,`${u}.dxf`,d).catch(g=>{console.error(g),alert(e("topbar.export.dxfFailed",{err:g.message}))})};return c.jsxs("div",{ref:o,className:"relative",children:[c.jsxs(Ne,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(s=>!s),children:[c.jsx(Yw,{}),e("topbar.export.label")]}),t&&c.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:[c.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:[c.jsx(Zw,{}),c.jsx("span",{className:"flex-1",children:"SVG"})]}),c.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:[c.jsx(Uw,{}),c.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),c.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:[c.jsx(Vw,{}),c.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ExportMenu=Dj;exports.FileMenu=xj;exports.LIBRARY=En;exports.OneLineEditor=pj;exports.applyTheme=ww;exports.buildExportDxf=$w;exports.buildExportSvg=Zn;exports.compile=qe;exports.downloadDxf=Sw;exports.downloadPng=Mw;exports.downloadSvg=Nw;exports.emptyInternalModel=Jr;exports.fitToContent=Xn;exports.fitToContentSoon=Kn;exports.getInitialTheme=hj;exports.getLibraryEntry=qb;exports.newBusId=Nn;exports.newElementId=jt;exports.newJunctionId=Mn;exports.orientationVec=jn;exports.resolvePlacement=Zr;exports.transformOrientation=_t;exports.transformPoint=Ae;exports.useEditorStore=x;exports.useLocale=Nt;exports.wireIdFromEnds=Ue;
|
|
201
206
|
//# sourceMappingURL=sldeditor.cjs.map
|