jch-config-editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3421 @@
1
+ import { jsxs as i, jsx as e, Fragment as Me } from "react/jsx-runtime";
2
+ import pe, { useState as W, useRef as he, useMemo as Gt, useCallback as G, useEffect as ae } from "react";
3
+ import { Typography as Nt, Upload as Vt, Button as A, Collapse as ge, List as Ce, Empty as te, Tag as ie, Image as Zt, Space as me, Tooltip as Ie, Modal as it, Form as N, Input as oe, Tabs as Ct, InputNumber as V, Select as be, Divider as xe, Switch as Je, ColorPicker as rt, message as Oe, ConfigProvider as Jt, Layout as at } from "antd";
4
+ import { UploadOutlined as It, EditOutlined as Mt, DeleteOutlined as Ke, UndoOutlined as Ht, RedoOutlined as Kt, GroupOutlined as Qt, AppstoreAddOutlined as en, AlignLeftOutlined as tn, AlignRightOutlined as nn, VerticalAlignTopOutlined as ln, VerticalAlignBottomOutlined as rn, SaveOutlined as an, ExperimentOutlined as on, ZoomInOutlined as sn, ZoomOutOutlined as cn, SelectOutlined as dn, DragOutlined as un, EyeOutlined as hn, PlusOutlined as Dt, ArrowUpOutlined as kt, ArrowDownOutlined as Et, CopyOutlined as mn, DownloadOutlined as fn } from "@ant-design/icons";
5
+ import { create as pn } from "zustand";
6
+ import { produce as gn } from "immer";
7
+ import { nanoid as O } from "nanoid";
8
+ import { TransformWrapper as yn, TransformComponent as vn } from "react-zoom-pan-pinch";
9
+ function bn(n) {
10
+ return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
11
+ }
12
+ var Ye = {}, tt = { exports: {} }, ut;
13
+ function ot() {
14
+ return ut || (ut = 1, (function(n) {
15
+ function f(t) {
16
+ return t && t.__esModule ? t : {
17
+ default: t
18
+ };
19
+ }
20
+ n.exports = f, n.exports.__esModule = !0, n.exports.default = n.exports;
21
+ })(tt)), tt.exports;
22
+ }
23
+ var Xe = {}, ht;
24
+ function xn() {
25
+ if (ht) return Xe;
26
+ ht = 1, Object.defineProperty(Xe, "__esModule", {
27
+ value: !0
28
+ }), Xe.default = void 0;
29
+ const n = {
30
+ // Options
31
+ items_per_page: "条/页",
32
+ jump_to: "跳至",
33
+ jump_to_confirm: "确定",
34
+ page: "页",
35
+ // Pagination
36
+ prev_page: "上一页",
37
+ next_page: "下一页",
38
+ prev_5: "向前 5 页",
39
+ next_5: "向后 5 页",
40
+ prev_3: "向前 3 页",
41
+ next_3: "向后 3 页",
42
+ page_size: "页码"
43
+ };
44
+ return Xe.default = n, Xe;
45
+ }
46
+ var Re = {}, Ae = {}, ze = {}, je = {}, mt;
47
+ function wn() {
48
+ return mt || (mt = 1, Object.defineProperty(je, "__esModule", {
49
+ value: !0
50
+ }), je.commonLocale = void 0, je.commonLocale = {
51
+ yearFormat: "YYYY",
52
+ dayFormat: "D",
53
+ cellMeridiemFormat: "A",
54
+ monthBeforeYear: !0
55
+ }), je;
56
+ }
57
+ var ft;
58
+ function Sn() {
59
+ if (ft) return ze;
60
+ ft = 1, Object.defineProperty(ze, "__esModule", {
61
+ value: !0
62
+ }), ze.default = void 0;
63
+ var n = wn();
64
+ function f(p) {
65
+ "@babel/helpers - typeof";
66
+ return f = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(b) {
67
+ return typeof b;
68
+ } : function(b) {
69
+ return b && typeof Symbol == "function" && b.constructor === Symbol && b !== Symbol.prototype ? "symbol" : typeof b;
70
+ }, f(p);
71
+ }
72
+ function t(p, b) {
73
+ var h = Object.keys(p);
74
+ if (Object.getOwnPropertySymbols) {
75
+ var w = Object.getOwnPropertySymbols(p);
76
+ b && (w = w.filter(function(c) {
77
+ return Object.getOwnPropertyDescriptor(p, c).enumerable;
78
+ })), h.push.apply(h, w);
79
+ }
80
+ return h;
81
+ }
82
+ function r(p) {
83
+ for (var b = 1; b < arguments.length; b++) {
84
+ var h = arguments[b] != null ? arguments[b] : {};
85
+ b % 2 ? t(Object(h), !0).forEach(function(w) {
86
+ o(p, w, h[w]);
87
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(p, Object.getOwnPropertyDescriptors(h)) : t(Object(h)).forEach(function(w) {
88
+ Object.defineProperty(p, w, Object.getOwnPropertyDescriptor(h, w));
89
+ });
90
+ }
91
+ return p;
92
+ }
93
+ function o(p, b, h) {
94
+ return b = l(b), b in p ? Object.defineProperty(p, b, { value: h, enumerable: !0, configurable: !0, writable: !0 }) : p[b] = h, p;
95
+ }
96
+ function l(p) {
97
+ var b = s(p, "string");
98
+ return f(b) == "symbol" ? b : String(b);
99
+ }
100
+ function s(p, b) {
101
+ if (f(p) != "object" || !p) return p;
102
+ var h = p[Symbol.toPrimitive];
103
+ if (h !== void 0) {
104
+ var w = h.call(p, b);
105
+ if (f(w) != "object") return w;
106
+ throw new TypeError("@@toPrimitive must return a primitive value.");
107
+ }
108
+ return (b === "string" ? String : Number)(p);
109
+ }
110
+ var a = r(r({}, n.commonLocale), {}, {
111
+ locale: "zh_CN",
112
+ today: "今天",
113
+ now: "此刻",
114
+ backToToday: "返回今天",
115
+ ok: "确定",
116
+ timeSelect: "选择时间",
117
+ dateSelect: "选择日期",
118
+ weekSelect: "选择周",
119
+ clear: "清除",
120
+ week: "周",
121
+ month: "月",
122
+ year: "年",
123
+ previousMonth: "上个月 (翻页上键)",
124
+ nextMonth: "下个月 (翻页下键)",
125
+ monthSelect: "选择月份",
126
+ yearSelect: "选择年份",
127
+ decadeSelect: "选择年代",
128
+ previousYear: "上一年 (Control键加左方向键)",
129
+ nextYear: "下一年 (Control键加右方向键)",
130
+ previousDecade: "上一年代",
131
+ nextDecade: "下一年代",
132
+ previousCentury: "上一世纪",
133
+ nextCentury: "下一世纪",
134
+ yearFormat: "YYYY年",
135
+ cellDateFormat: "D",
136
+ monthBeforeYear: !1
137
+ });
138
+ return ze.default = a, ze;
139
+ }
140
+ var Fe = {}, pt;
141
+ function Pt() {
142
+ if (pt) return Fe;
143
+ pt = 1, Object.defineProperty(Fe, "__esModule", {
144
+ value: !0
145
+ }), Fe.default = void 0;
146
+ const n = {
147
+ placeholder: "请选择时间",
148
+ rangePlaceholder: ["开始时间", "结束时间"]
149
+ };
150
+ return Fe.default = n, Fe;
151
+ }
152
+ var gt;
153
+ function Lt() {
154
+ if (gt) return Ae;
155
+ gt = 1;
156
+ var n = ot().default;
157
+ Object.defineProperty(Ae, "__esModule", {
158
+ value: !0
159
+ }), Ae.default = void 0;
160
+ var f = n(Sn()), t = n(/* @__PURE__ */ Pt());
161
+ const r = {
162
+ lang: {
163
+ placeholder: "请选择日期",
164
+ yearPlaceholder: "请选择年份",
165
+ quarterPlaceholder: "请选择季度",
166
+ monthPlaceholder: "请选择月份",
167
+ weekPlaceholder: "请选择周",
168
+ rangePlaceholder: ["开始日期", "结束日期"],
169
+ rangeYearPlaceholder: ["开始年份", "结束年份"],
170
+ rangeMonthPlaceholder: ["开始月份", "结束月份"],
171
+ rangeQuarterPlaceholder: ["开始季度", "结束季度"],
172
+ rangeWeekPlaceholder: ["开始周", "结束周"],
173
+ ...f.default
174
+ },
175
+ timePickerLocale: {
176
+ ...t.default
177
+ }
178
+ };
179
+ return r.lang.ok = "确定", Ae.default = r, Ae;
180
+ }
181
+ var yt;
182
+ function Nn() {
183
+ if (yt) return Re;
184
+ yt = 1;
185
+ var n = ot().default;
186
+ Object.defineProperty(Re, "__esModule", {
187
+ value: !0
188
+ }), Re.default = void 0;
189
+ var f = n(/* @__PURE__ */ Lt());
190
+ return Re.default = f.default, Re;
191
+ }
192
+ var vt;
193
+ function Cn() {
194
+ if (vt) return Ye;
195
+ vt = 1;
196
+ var n = ot().default;
197
+ Object.defineProperty(Ye, "__esModule", {
198
+ value: !0
199
+ }), Ye.default = void 0;
200
+ var f = n(xn()), t = n(/* @__PURE__ */ Nn()), r = n(/* @__PURE__ */ Lt()), o = n(/* @__PURE__ */ Pt());
201
+ const l = "${label}不是一个有效的${type}", s = {
202
+ locale: "zh-cn",
203
+ Pagination: f.default,
204
+ DatePicker: r.default,
205
+ TimePicker: o.default,
206
+ Calendar: t.default,
207
+ // locales for all components
208
+ global: {
209
+ placeholder: "请选择",
210
+ close: "关闭",
211
+ sortable: "可排序"
212
+ },
213
+ Table: {
214
+ filterTitle: "筛选",
215
+ filterConfirm: "确定",
216
+ filterReset: "重置",
217
+ filterEmptyText: "无筛选项",
218
+ filterCheckAll: "全选",
219
+ filterSearchPlaceholder: "在筛选项中搜索",
220
+ emptyText: "暂无数据",
221
+ selectAll: "全选当页",
222
+ selectInvert: "反选当页",
223
+ selectNone: "清空所有",
224
+ selectionAll: "全选所有",
225
+ sortTitle: "排序",
226
+ expand: "展开行",
227
+ collapse: "关闭行",
228
+ triggerDesc: "点击降序",
229
+ triggerAsc: "点击升序",
230
+ cancelSort: "取消排序"
231
+ },
232
+ Modal: {
233
+ okText: "确定",
234
+ cancelText: "取消",
235
+ justOkText: "知道了"
236
+ },
237
+ Tour: {
238
+ Next: "下一步",
239
+ Previous: "上一步",
240
+ Finish: "结束导览"
241
+ },
242
+ Popconfirm: {
243
+ cancelText: "取消",
244
+ okText: "确定"
245
+ },
246
+ Transfer: {
247
+ titles: ["", ""],
248
+ searchPlaceholder: "请输入搜索内容",
249
+ itemUnit: "项",
250
+ itemsUnit: "项",
251
+ remove: "删除",
252
+ selectCurrent: "全选当页",
253
+ removeCurrent: "删除当页",
254
+ selectAll: "全选所有",
255
+ deselectAll: "取消全选",
256
+ removeAll: "删除全部",
257
+ selectInvert: "反选当页"
258
+ },
259
+ Upload: {
260
+ uploading: "文件上传中",
261
+ removeFile: "删除文件",
262
+ uploadError: "上传错误",
263
+ previewFile: "预览文件",
264
+ downloadFile: "下载文件"
265
+ },
266
+ Empty: {
267
+ description: "暂无数据"
268
+ },
269
+ Icon: {
270
+ icon: "图标"
271
+ },
272
+ Text: {
273
+ edit: "编辑",
274
+ copy: "复制",
275
+ copied: "复制成功",
276
+ expand: "展开",
277
+ collapse: "收起"
278
+ },
279
+ Form: {
280
+ optional: "(可选)",
281
+ defaultValidateMessages: {
282
+ default: "字段验证错误${label}",
283
+ required: "请输入${label}",
284
+ enum: "${label}必须是其中一个[${enum}]",
285
+ whitespace: "${label}不能为空字符",
286
+ date: {
287
+ format: "${label}日期格式无效",
288
+ parse: "${label}不能转换为日期",
289
+ invalid: "${label}是一个无效日期"
290
+ },
291
+ types: {
292
+ string: l,
293
+ method: l,
294
+ array: l,
295
+ object: l,
296
+ number: l,
297
+ date: l,
298
+ boolean: l,
299
+ integer: l,
300
+ float: l,
301
+ regexp: l,
302
+ email: l,
303
+ url: l,
304
+ hex: l
305
+ },
306
+ string: {
307
+ len: "${label}须为${len}个字符",
308
+ min: "${label}最少${min}个字符",
309
+ max: "${label}最多${max}个字符",
310
+ range: "${label}须在${min}-${max}字符之间"
311
+ },
312
+ number: {
313
+ len: "${label}必须等于${len}",
314
+ min: "${label}最小值为${min}",
315
+ max: "${label}最大值为${max}",
316
+ range: "${label}须在${min}-${max}之间"
317
+ },
318
+ array: {
319
+ len: "须为${len}个${label}",
320
+ min: "最少${min}个${label}",
321
+ max: "最多${max}个${label}",
322
+ range: "${label}数量须在${min}-${max}之间"
323
+ },
324
+ pattern: {
325
+ mismatch: "${label}与模式不匹配${pattern}"
326
+ }
327
+ }
328
+ },
329
+ QRCode: {
330
+ expired: "二维码过期",
331
+ refresh: "点击刷新",
332
+ scanned: "已扫描"
333
+ },
334
+ ColorPicker: {
335
+ presetEmpty: "暂无",
336
+ transparent: "无色",
337
+ singleColor: "单色",
338
+ gradientColor: "渐变色"
339
+ }
340
+ };
341
+ return Ye.default = s, Ye;
342
+ }
343
+ var nt, bt;
344
+ function In() {
345
+ return bt || (bt = 1, nt = /* @__PURE__ */ Cn()), nt;
346
+ }
347
+ var Mn = /* @__PURE__ */ In();
348
+ const Dn = /* @__PURE__ */ bn(Mn), kn = (n) => (f, t, r) => (r.setState = (o, l, ...s) => {
349
+ const a = typeof o == "function" ? gn(o) : o;
350
+ return f(a, l, ...s);
351
+ }, n(r.setState, t, r)), En = kn, xt = {
352
+ nodes: [],
353
+ materials: [],
354
+ selectedNodeId: null,
355
+ selectedStatusId: null,
356
+ viewport: {
357
+ scale: 1,
358
+ positionX: 0,
359
+ positionY: 0
360
+ },
361
+ history: {
362
+ past: [],
363
+ future: []
364
+ },
365
+ mode: "select",
366
+ lineDrawing: {
367
+ isDrawing: !1,
368
+ material: null,
369
+ startPoint: null,
370
+ endPoint: null
371
+ }
372
+ }, ye = (n, f, t) => ({
373
+ id: O(),
374
+ type: n,
375
+ targetId: f,
376
+ payload: t,
377
+ timestamp: Date.now()
378
+ }), Qe = pn()(
379
+ En((n, f) => ({
380
+ ...xt,
381
+ // ========== 节点操作 ==========
382
+ addNode: (t, r = !0) => {
383
+ n((o) => {
384
+ const l = {
385
+ ...t,
386
+ id: O()
387
+ };
388
+ o.nodes.push(l), r && (o.selectedNodeId = l.id, o.history.past.push(ye("NODE_SELECT", l.id)));
389
+ });
390
+ },
391
+ updateNode: (t, r) => {
392
+ n((o) => {
393
+ const l = o.nodes.find((s) => s.id === t);
394
+ l && (Object.assign(l, r), o.history.past.push(ye("PROPERTY_CHANGE", t, r)));
395
+ });
396
+ },
397
+ updateNodeStyle: (t, r) => {
398
+ n((o) => {
399
+ const l = o.nodes.find((s) => s.id === t);
400
+ l && (Object.assign(l.normalStyle, r), o.history.past.push(ye("PROPERTY_CHANGE", t, { normalStyle: r })));
401
+ });
402
+ },
403
+ updateNodeContent: (t, r) => {
404
+ n((o) => {
405
+ const l = o.nodes.find((s) => s.id === t);
406
+ l && (Object.assign(l.contentInfo, r), o.history.past.push(ye("PROPERTY_CHANGE", t, { contentInfo: r })));
407
+ });
408
+ },
409
+ updateNodeControl: (t, r) => {
410
+ n((o) => {
411
+ const l = o.nodes.find((s) => s.id === t);
412
+ l && (Object.assign(l.controlInfo, r), o.history.past.push(ye("PROPERTY_CHANGE", t, { controlInfo: r })));
413
+ });
414
+ },
415
+ removeNode: (t) => {
416
+ n((r) => {
417
+ const o = r.nodes.findIndex((l) => l.id === t);
418
+ o !== -1 && (r.nodes.splice(o, 1), r.selectedNodeId === t && (r.selectedNodeId = null, r.selectedStatusId = null), r.history.past.push(ye("NODE_DELETE", t)));
419
+ });
420
+ },
421
+ selectNode: (t) => {
422
+ n((r) => {
423
+ r.selectedNodeId = t, r.selectedStatusId = null, t && r.history.past.push(ye("NODE_SELECT", t));
424
+ });
425
+ },
426
+ // ========== 状态操作 ==========
427
+ addStatus: (t, r) => {
428
+ n((o) => {
429
+ const l = o.nodes.find((a) => a.id === t);
430
+ if (!l) return;
431
+ const s = {
432
+ ...r,
433
+ id: O()
434
+ };
435
+ l.contentInfo.statusList.push(s), o.history.past.push(ye("MATERIAL_STATUS_CHANGE", t, { statusId: s.id }));
436
+ });
437
+ },
438
+ removeStatus: (t, r) => {
439
+ n((o) => {
440
+ const l = o.nodes.find((a) => a.id === t);
441
+ if (!l) return;
442
+ const s = l.contentInfo.statusList.findIndex((a) => a.id === r);
443
+ s !== -1 && (l.contentInfo.statusList.splice(s, 1), l.contentInfo.currentStatusId === r && (l.contentInfo.currentStatusId = void 0), o.selectedStatusId === r && (o.selectedStatusId = null));
444
+ });
445
+ },
446
+ updateStatus: (t, r, o) => {
447
+ n((l) => {
448
+ const s = l.nodes.find((p) => p.id === t);
449
+ if (!s) return;
450
+ const a = s.contentInfo.statusList.find((p) => p.id === r);
451
+ a && Object.assign(a, o);
452
+ });
453
+ },
454
+ selectStatus: (t) => {
455
+ n((r) => {
456
+ r.selectedStatusId = t;
457
+ });
458
+ },
459
+ evaluateCurrentStatus: (t, r) => {
460
+ const l = f().nodes.find((s) => s.id === t);
461
+ if (l)
462
+ for (const s of l.contentInfo.statusList)
463
+ try {
464
+ if (new Function("data", "bindCodes", "status", s.expression)(r, s.bindCodes, s) === !0)
465
+ return s.id;
466
+ } catch (a) {
467
+ console.warn("状态表达式执行失败:", s.name, a);
468
+ }
469
+ },
470
+ // ========== 物料库操作 ==========
471
+ addMaterial: (t) => {
472
+ n((r) => {
473
+ const o = {
474
+ ...t,
475
+ id: O()
476
+ };
477
+ r.materials.push(o), r.history.past.push(ye("MATERIAL_ADD", o.id));
478
+ });
479
+ },
480
+ updateMaterial: (t, r) => {
481
+ n((o) => {
482
+ const l = o.materials.find((s) => s.id === t);
483
+ l && Object.assign(l, r);
484
+ });
485
+ },
486
+ removeMaterial: (t) => {
487
+ n((r) => {
488
+ const o = r.materials.findIndex((l) => l.id === t);
489
+ o !== -1 && r.materials.splice(o, 1);
490
+ });
491
+ },
492
+ // ========== 视口操作 ==========
493
+ setViewport: (t) => {
494
+ n((r) => {
495
+ Object.assign(r.viewport, t);
496
+ });
497
+ },
498
+ // ========== 模式切换 ==========
499
+ setMode: (t) => {
500
+ n((r) => {
501
+ r.mode = t;
502
+ });
503
+ },
504
+ // ========== 线条绘制操作 ==========
505
+ startLineDrawing: (t) => {
506
+ n((r) => {
507
+ r.mode = "line-draw", r.lineDrawing = {
508
+ isDrawing: !0,
509
+ material: t,
510
+ startPoint: null,
511
+ endPoint: null
512
+ };
513
+ });
514
+ },
515
+ updateLineDrawing: (t) => {
516
+ n((r) => {
517
+ r.lineDrawing.isDrawing && (r.lineDrawing.endPoint = t);
518
+ });
519
+ },
520
+ endLineDrawing: () => {
521
+ n((t) => {
522
+ t.mode = "select", t.lineDrawing = {
523
+ isDrawing: !1,
524
+ material: null,
525
+ startPoint: null,
526
+ endPoint: null
527
+ };
528
+ });
529
+ },
530
+ cancelLineDrawing: () => {
531
+ n((t) => {
532
+ t.mode = "select", t.lineDrawing = {
533
+ isDrawing: !1,
534
+ material: null,
535
+ startPoint: null,
536
+ endPoint: null
537
+ };
538
+ });
539
+ },
540
+ // ========== 历史操作 ==========
541
+ undo: () => {
542
+ n((t) => {
543
+ const r = t.history.past.pop();
544
+ r && t.history.future.push(r);
545
+ });
546
+ },
547
+ redo: () => {
548
+ n((t) => {
549
+ const r = t.history.future.pop();
550
+ r && t.history.past.push(r);
551
+ });
552
+ },
553
+ recordEvent: (t) => {
554
+ n((r) => {
555
+ r.history.past.push(t), r.history.future = [];
556
+ });
557
+ },
558
+ // ========== 导入导出 ==========
559
+ exportScheme: () => {
560
+ const t = f();
561
+ return {
562
+ version: "1.1.0",
563
+ nodes: t.nodes,
564
+ materials: t.materials,
565
+ viewport: t.viewport,
566
+ metadata: {
567
+ name: "未命名组态",
568
+ description: "",
569
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
570
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
571
+ }
572
+ };
573
+ },
574
+ importScheme: (t) => {
575
+ n((r) => {
576
+ r.nodes = t.nodes || [], r.materials = t.materials || [], r.viewport = t.viewport || xt.viewport, r.selectedNodeId = null, r.selectedStatusId = null, r.history = { past: [], future: [] };
577
+ });
578
+ }
579
+ }))
580
+ ), Pn = [
581
+ // 基础形状
582
+ {
583
+ id: O(),
584
+ name: "矩形",
585
+ type: "IMAGE",
586
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="#1890ff" rx="4"/></svg>')}`
587
+ },
588
+ {
589
+ id: O(),
590
+ name: "圆形",
591
+ type: "IMAGE",
592
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><circle cx="40" cy="40" r="38" fill="#52c41a"/></svg>')}`
593
+ },
594
+ {
595
+ id: O(),
596
+ name: "圆角矩形",
597
+ type: "IMAGE",
598
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="#faad14" rx="20"/></svg>')}`
599
+ },
600
+ // 设备图标
601
+ {
602
+ id: O(),
603
+ name: "阀门",
604
+ type: "IMAGE",
605
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><path d="M10 20 L30 10 L50 20 L50 40 L30 50 L10 40 Z" fill="#bfbfbf" stroke="#595959" stroke-width="2"/><circle cx="30" cy="30" r="8" fill="#1890ff"/></svg>')}`
606
+ },
607
+ {
608
+ id: O(),
609
+ name: "泵",
610
+ type: "IMAGE",
611
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60"><circle cx="30" cy="35" r="20" fill="#bfbfbf" stroke="#595959" stroke-width="2"/><rect x="25" y="5" width="10" height="15" fill="#595959"/><path d="M30 20 L30 35 M20 30 Q30 45 40 30" stroke="#595959" stroke-width="2" fill="none"/></svg>')}`
612
+ },
613
+ {
614
+ id: O(),
615
+ name: "罐体",
616
+ type: "IMAGE",
617
+ src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="60" height="80"><ellipse cx="30" cy="10" rx="25" ry="10" fill="#d9d9d9" stroke="#595959" stroke-width="2"/><rect x="5" y="10" width="50" height="60" fill="#f0f0f0" stroke="#595959" stroke-width="2"/><ellipse cx="30" cy="70" rx="25" ry="10" fill="#d9d9d9" stroke="#595959" stroke-width="2"/></svg>')}`
618
+ },
619
+ // 文本
620
+ {
621
+ id: O(),
622
+ name: "文本标签",
623
+ type: "TEXT",
624
+ content: {
625
+ label: "标签",
626
+ value: "值",
627
+ labelStyle: {
628
+ fontSize: 14,
629
+ fontWeight: "bold",
630
+ color: "#262626",
631
+ textAlign: "left"
632
+ },
633
+ valueStyle: {
634
+ fontSize: 14,
635
+ fontWeight: "normal",
636
+ color: "#1890ff",
637
+ textAlign: "left"
638
+ }
639
+ }
640
+ },
641
+ // 线条 - 通用线条物料,通过属性配置实现不同线型
642
+ {
643
+ id: O(),
644
+ name: "线条",
645
+ type: "LINE",
646
+ config: {
647
+ thickness: 2,
648
+ lineWeight: 2,
649
+ color: "#262626",
650
+ lineType: "solid"
651
+ }
652
+ }
653
+ ], $t = (n) => ({
654
+ id: O(),
655
+ name: "默认状态",
656
+ expression: "return true;",
657
+ material: { ...n, id: O() },
658
+ bindCodes: []
659
+ }), Ln = (n, f, t) => {
660
+ if (t?.type === "CUSTOM" && t.config?.nodes) {
661
+ const r = t.config.nodes.map((b) => ({
662
+ ...b,
663
+ id: O()
664
+ // 重新生成子节点ID
665
+ }));
666
+ let o = 1 / 0, l = 1 / 0, s = -1 / 0, a = -1 / 0;
667
+ r.forEach((b) => {
668
+ const h = b.normalStyle.x || 0, w = b.normalStyle.y || 0, c = b.normalStyle.width || 0, C = b.normalStyle.height || 0;
669
+ o = Math.min(o, h), l = Math.min(l, w), s = Math.max(s, h + c), a = Math.max(a, w + C);
670
+ });
671
+ const p = r.map((b) => ({
672
+ ...b,
673
+ normalStyle: {
674
+ ...b.normalStyle,
675
+ x: (b.normalStyle.x || 0) - o,
676
+ y: (b.normalStyle.y || 0) - l,
677
+ scale: void 0
678
+ // 移除 scale,由父级容器统一控制
679
+ }
680
+ }));
681
+ return {
682
+ id: O(),
683
+ name: t.name || "群组节点",
684
+ type: "group",
685
+ normalStyle: {
686
+ width: s - o,
687
+ height: a - l,
688
+ x: n,
689
+ y: f
690
+ // 不设置背景和边框,由 NodeRenderer 控制
691
+ },
692
+ contentInfo: {
693
+ statusList: [],
694
+ currentStatusId: void 0
695
+ },
696
+ controlInfo: {
697
+ isDraggable: !0,
698
+ isClickable: !0,
699
+ isResizable: !0,
700
+ isSelectable: !0
701
+ },
702
+ children: p
703
+ };
704
+ }
705
+ return {
706
+ id: O(),
707
+ name: "新节点",
708
+ type: "normal",
709
+ normalStyle: {
710
+ width: 120,
711
+ height: 100,
712
+ x: n,
713
+ y: f,
714
+ background: "transparent",
715
+ padding: 8
716
+ },
717
+ contentInfo: {
718
+ statusList: t ? [$t(t)] : [],
719
+ currentStatusId: void 0
720
+ },
721
+ controlInfo: {
722
+ isDraggable: !0,
723
+ isClickable: !0,
724
+ isResizable: !0,
725
+ isSelectable: !0
726
+ }
727
+ };
728
+ }, { Panel: Pe } = ge, { Text: He } = Nt, $n = () => {
729
+ const {
730
+ materials: n,
731
+ addMaterial: f,
732
+ removeMaterial: t,
733
+ selectedStatusId: r,
734
+ selectStatus: o,
735
+ mode: l,
736
+ lineDrawing: s,
737
+ startLineDrawing: a,
738
+ cancelLineDrawing: p
739
+ } = Qe(), [b, h] = W([
740
+ "basic",
741
+ "device",
742
+ "text",
743
+ "line"
744
+ ]), w = (m) => {
745
+ const T = new FileReader();
746
+ return T.onload = (Y) => {
747
+ const U = Y.target?.result;
748
+ f({
749
+ name: m.name.replace(".svg", ""),
750
+ type: "IMAGE",
751
+ src: U
752
+ });
753
+ }, T.readAsDataURL(m), !1;
754
+ }, c = {
755
+ basic: n.filter(
756
+ (m) => ["矩形", "圆形", "圆角矩形"].includes(m.name)
757
+ ),
758
+ device: n.filter(
759
+ (m) => ["阀门", "泵", "罐体"].includes(m.name) || m.type === "IMAGE" && !["矩形", "圆形", "圆角矩形"].includes(m.name) && m.name !== "自定义"
760
+ ),
761
+ text: n.filter((m) => m.type === "TEXT"),
762
+ line: n.filter((m) => m.type === "LINE"),
763
+ group: n.filter((m) => m.type === "CUSTOM" && m.config?.nodes),
764
+ custom: n.filter(
765
+ (m) => m.type === "CUSTOM" && !m.config?.nodes || m.type === "IMAGE" && !["矩形", "圆形", "圆角矩形", "阀门", "泵", "罐体"].includes(m.name)
766
+ )
767
+ }, C = (m, T) => {
768
+ m.dataTransfer.effectAllowed = "copy", m.dataTransfer.setData("application/json", JSON.stringify(T));
769
+ const Y = m.currentTarget.querySelector(
770
+ ".material-preview"
771
+ );
772
+ Y && m.dataTransfer.setDragImage(Y, 20, 20);
773
+ }, g = (m) => {
774
+ m.type === "LINE" && a(m);
775
+ }, D = (m, T = !1) => {
776
+ const Y = T === !0, U = l === "line-draw" && Y && s.material?.id === m.id;
777
+ return /* @__PURE__ */ e(
778
+ Ce.Item,
779
+ {
780
+ draggable: !Y,
781
+ onDragStart: (R) => C(R, m),
782
+ onClick: () => Y && g(m),
783
+ className: `
784
+ rounded-lg transition-all duration-200 select-none
785
+ ${Y ? "cursor-pointer" : "cursor-move"}
786
+ hover:bg-gray-100
787
+ ${U ? "bg-blue-50 ring-2 ring-blue-400" : ""}
788
+ `,
789
+ actions: [
790
+ Y ? /* @__PURE__ */ e(
791
+ A,
792
+ {
793
+ type: "text",
794
+ size: "small",
795
+ icon: /* @__PURE__ */ e(Mt, {}),
796
+ onClick: (R) => {
797
+ R.stopPropagation(), g(m);
798
+ },
799
+ children: "绘制"
800
+ },
801
+ "draw"
802
+ ) : null,
803
+ /* @__PURE__ */ e(
804
+ A,
805
+ {
806
+ type: "text",
807
+ size: "small",
808
+ danger: !0,
809
+ icon: /* @__PURE__ */ e(Ke, {}),
810
+ onClick: (R) => {
811
+ R.stopPropagation(), t(m.id);
812
+ }
813
+ },
814
+ "delete"
815
+ )
816
+ ].filter(Boolean),
817
+ children: /* @__PURE__ */ i("div", { className: `flex items-center gap-3 w-full py-2 ${Y ? "" : "pointer-events-none"}`, children: [
818
+ /* @__PURE__ */ e("div", { className: "material-preview w-12 h-12 flex items-center justify-center bg-white rounded border border-gray-200", children: m.type === "IMAGE" && m.src ? /* @__PURE__ */ e(
819
+ Zt,
820
+ {
821
+ src: m.src,
822
+ alt: m.name,
823
+ width: 40,
824
+ height: 40,
825
+ preview: !1
826
+ }
827
+ ) : m.type === "TEXT" ? /* @__PURE__ */ e("span", { className: "text-xs text-gray-500", children: "T" }) : m.type === "LINE" ? /* @__PURE__ */ e("div", { className: "w-8 h-0.5 bg-gray-400" }) : m.type === "CUSTOM" && m.config?.nodes ? /* @__PURE__ */ e("span", { className: "text-xs text-blue-500 font-bold", children: "G" }) : /* @__PURE__ */ e("span", { className: "text-xs text-gray-500", children: "?" }) }),
828
+ /* @__PURE__ */ i("div", { className: "flex-1 min-w-0", children: [
829
+ /* @__PURE__ */ e(He, { strong: !0, className: "block truncate", children: m.name }),
830
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-1", children: [
831
+ /* @__PURE__ */ e(He, { type: "secondary", className: "text-xs", children: m.type }),
832
+ U && /* @__PURE__ */ e(ie, { color: "blue", className: "text-xs", children: "绘制中" })
833
+ ] })
834
+ ] })
835
+ ] })
836
+ },
837
+ m.id
838
+ );
839
+ };
840
+ return /* @__PURE__ */ i("div", { className: "h-full flex flex-col bg-white border-r border-gray-200", children: [
841
+ /* @__PURE__ */ i("div", { className: "p-4 border-b border-gray-200", children: [
842
+ /* @__PURE__ */ e("h3", { className: "text-lg font-semibold text-gray-800", children: "物料库" }),
843
+ /* @__PURE__ */ e(He, { type: "secondary", className: "text-sm", children: "拖拽物料到画布创建节点" })
844
+ ] }),
845
+ /* @__PURE__ */ e("div", { className: "p-3 border-b border-gray-200", children: /* @__PURE__ */ e(
846
+ Vt,
847
+ {
848
+ accept: ".svg",
849
+ beforeUpload: w,
850
+ showUploadList: !1,
851
+ children: /* @__PURE__ */ e(A, { icon: /* @__PURE__ */ e(It, {}), block: !0, type: "dashed", children: "上传 SVG" })
852
+ }
853
+ ) }),
854
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-2", children: /* @__PURE__ */ i(
855
+ ge,
856
+ {
857
+ activeKey: b,
858
+ onChange: (m) => h(m),
859
+ ghost: !0,
860
+ expandIconPosition: "end",
861
+ children: [
862
+ /* @__PURE__ */ e(Pe, { header: "基础形状", children: /* @__PURE__ */ e(
863
+ Ce,
864
+ {
865
+ dataSource: c.basic,
866
+ renderItem: (m) => D(m, !1),
867
+ locale: {
868
+ emptyText: /* @__PURE__ */ e(
869
+ te,
870
+ {
871
+ description: "暂无物料",
872
+ image: te.PRESENTED_IMAGE_SIMPLE
873
+ }
874
+ )
875
+ }
876
+ }
877
+ ) }, "basic"),
878
+ /* @__PURE__ */ e(Pe, { header: "设备图标", children: /* @__PURE__ */ e(
879
+ Ce,
880
+ {
881
+ dataSource: c.device,
882
+ renderItem: (m) => D(m, !1),
883
+ locale: {
884
+ emptyText: /* @__PURE__ */ e(
885
+ te,
886
+ {
887
+ description: "暂无物料",
888
+ image: te.PRESENTED_IMAGE_SIMPLE
889
+ }
890
+ )
891
+ }
892
+ }
893
+ ) }, "device"),
894
+ /* @__PURE__ */ e(Pe, { header: "文本", children: /* @__PURE__ */ e(
895
+ Ce,
896
+ {
897
+ dataSource: c.text,
898
+ renderItem: (m) => D(m, !1),
899
+ locale: {
900
+ emptyText: /* @__PURE__ */ e(
901
+ te,
902
+ {
903
+ description: "暂无物料",
904
+ image: te.PRESENTED_IMAGE_SIMPLE
905
+ }
906
+ )
907
+ }
908
+ }
909
+ ) }, "text"),
910
+ /* @__PURE__ */ i(
911
+ Pe,
912
+ {
913
+ header: /* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
914
+ /* @__PURE__ */ e("span", { children: "线条" }),
915
+ l === "line-draw" && /* @__PURE__ */ e(ie, { color: "blue", className: "text-xs", children: "绘制模式" })
916
+ ] }),
917
+ children: [
918
+ /* @__PURE__ */ e(
919
+ Ce,
920
+ {
921
+ dataSource: c.line,
922
+ renderItem: (m) => D(m, !0),
923
+ locale: {
924
+ emptyText: /* @__PURE__ */ e(
925
+ te,
926
+ {
927
+ description: "暂无物料",
928
+ image: te.PRESENTED_IMAGE_SIMPLE
929
+ }
930
+ )
931
+ }
932
+ }
933
+ ),
934
+ l === "line-draw" && /* @__PURE__ */ i("div", { className: "mt-2 p-2 bg-blue-50 rounded text-xs text-blue-600", children: [
935
+ /* @__PURE__ */ e("div", { children: "点击线条物料开始绘制" }),
936
+ /* @__PURE__ */ e("div", { children: "点击画布确定起点和终点" })
937
+ ] })
938
+ ]
939
+ },
940
+ "line"
941
+ ),
942
+ c.group.length > 0 && /* @__PURE__ */ e(Pe, { header: "群组", children: /* @__PURE__ */ e(
943
+ Ce,
944
+ {
945
+ dataSource: c.group,
946
+ renderItem: (m) => D(m, !1),
947
+ locale: {
948
+ emptyText: /* @__PURE__ */ e(
949
+ te,
950
+ {
951
+ description: "暂无物料",
952
+ image: te.PRESENTED_IMAGE_SIMPLE
953
+ }
954
+ )
955
+ }
956
+ }
957
+ ) }, "group"),
958
+ c.custom.length > 0 && /* @__PURE__ */ e(Pe, { header: "自定义", children: /* @__PURE__ */ e(
959
+ Ce,
960
+ {
961
+ dataSource: c.custom,
962
+ renderItem: (m) => D(m, !1),
963
+ locale: {
964
+ emptyText: /* @__PURE__ */ e(
965
+ te,
966
+ {
967
+ description: "暂无物料",
968
+ image: te.PRESENTED_IMAGE_SIMPLE
969
+ }
970
+ )
971
+ }
972
+ }
973
+ ) }, "custom")
974
+ ]
975
+ }
976
+ ) }),
977
+ /* @__PURE__ */ e("div", { className: "p-3 border-t border-gray-200 bg-gray-50", children: /* @__PURE__ */ e(He, { type: "secondary", className: "text-xs", children: l === "line-draw" ? /* @__PURE__ */ e(Me, { children: "💡 提示:点击绘制线段,可连续绘制多段线,双击结束绘制,ESC 取消" }) : /* @__PURE__ */ e(Me, { children: "💡 提示:拖拽物料到画布创建节点,点击线条物料进入绘制模式" }) }) })
978
+ ] });
979
+ }, { Text: wt } = Nt, Tn = (n, f) => {
980
+ try {
981
+ const t = f && Array.isArray(f) ? f.map((l, s) => l.paramsName) : ["A"], o = new Function(...t, n.expression)(...f.map((l) => l.value));
982
+ return console.log(
983
+ `Evaluating status [${n.name}] with data:`,
984
+ f,
985
+ "Result:",
986
+ o
987
+ ), o === !0;
988
+ } catch (t) {
989
+ return console.warn(`状态表达式执行失败 [${n.name}]:`, t), !1;
990
+ }
991
+ }, _n = (n, f) => {
992
+ for (const t of n) {
993
+ console.log(t, "status");
994
+ let r = [];
995
+ if (Array.isArray(f) ? (console.log(t.bindCodes, "bindCodes"), r = f.filter(
996
+ (o) => t.bindCodes?.includes(o.paramsCode)
997
+ )) : r = f, Tn(t, r))
998
+ return t;
999
+ }
1000
+ }, On = (n, f) => {
1001
+ if (!f || !n)
1002
+ return { value: void 0 };
1003
+ if (Array.isArray(n)) {
1004
+ const t = n.find((r) => r.paramsCode === f);
1005
+ if (t)
1006
+ return {
1007
+ value: t.value,
1008
+ unit: t.unit
1009
+ };
1010
+ } else if (typeof n == "object" && f in n)
1011
+ return {
1012
+ value: n[f],
1013
+ unit: n.unit
1014
+ };
1015
+ return { value: void 0 };
1016
+ }, Yn = (n, f) => {
1017
+ if (n == null) return "";
1018
+ if (f === -1) return String(n);
1019
+ const t = Number(n);
1020
+ return isNaN(t) ? String(n) : t.toFixed(f ?? 2);
1021
+ }, Xn = (n, f, t, r) => {
1022
+ switch (n.type) {
1023
+ case "IMAGE":
1024
+ const o = n;
1025
+ return /* @__PURE__ */ e("div", { className: "w-full h-full flex items-center justify-center overflow-hidden", children: o.src ? /* @__PURE__ */ e(
1026
+ "img",
1027
+ {
1028
+ src: o.src,
1029
+ alt: n.name,
1030
+ style: {
1031
+ width: "100%",
1032
+ height: "100%",
1033
+ objectFit: "contain"
1034
+ }
1035
+ }
1036
+ ) : /* @__PURE__ */ e("div", { className: "w-full h-full bg-gray-200 flex items-center justify-center", children: /* @__PURE__ */ e("span", { className: "text-gray-400 text-xs", children: "无图片" }) }) });
1037
+ case "TEXT":
1038
+ const l = n, {
1039
+ label: s,
1040
+ value: a,
1041
+ valueSourceCode: p,
1042
+ unit: b,
1043
+ decimals: h,
1044
+ labelStyle: w,
1045
+ valueStyle: c,
1046
+ customStyle: C
1047
+ } = l.content || {}, { value: g, unit: D } = p ? On(f, p) : { value: void 0, unit: void 0 }, T = Yn(g !== void 0 ? g : a, h), Y = b || D || "";
1048
+ return /* @__PURE__ */ i(
1049
+ "div",
1050
+ {
1051
+ className: "w-full h-full flex flex-col justify-center gap-1",
1052
+ style: { ...C },
1053
+ children: [
1054
+ s && /* @__PURE__ */ e(
1055
+ wt,
1056
+ {
1057
+ style: {
1058
+ fontSize: 14,
1059
+ fontWeight: "bold",
1060
+ color: "#262626",
1061
+ textAlign: "left",
1062
+ ...w
1063
+ },
1064
+ children: s
1065
+ }
1066
+ ),
1067
+ T != null && /* @__PURE__ */ i(
1068
+ wt,
1069
+ {
1070
+ style: {
1071
+ fontSize: 14,
1072
+ color: "#1890ff",
1073
+ textAlign: "left",
1074
+ ...c
1075
+ },
1076
+ children: [
1077
+ T,
1078
+ Y ? ` ${Y}` : ""
1079
+ ]
1080
+ }
1081
+ )
1082
+ ]
1083
+ }
1084
+ );
1085
+ case "LINE":
1086
+ const U = n, {
1087
+ thickness: R = 2,
1088
+ color: _ = "#d9d9d9",
1089
+ dashed: L = !1,
1090
+ lineType: X = L ? "dashed" : "solid",
1091
+ lineWeight: K = R,
1092
+ // 起点和终点的相对坐标
1093
+ startX: z = 0,
1094
+ startY: k = 0,
1095
+ endX: Z = 100,
1096
+ endY: B = 0
1097
+ } = U.config || {}, x = ((d) => {
1098
+ const v = Math.max(K, 1);
1099
+ switch (d) {
1100
+ case "solid":
1101
+ return "";
1102
+ case "dashed":
1103
+ return `${v * 8},${v * 4}`;
1104
+ case "center":
1105
+ return `${v * 12},${v * 3},${v * 2},${v * 3}`;
1106
+ case "phantom":
1107
+ return `${v * 12},${v * 3},${v * 2},${v * 3},${v * 2},${v * 3}`;
1108
+ case "dot":
1109
+ return `${v},${v * 3}`;
1110
+ case "dash-dot":
1111
+ return `${v * 8},${v * 3},${v},${v * 3}`;
1112
+ default:
1113
+ return "";
1114
+ }
1115
+ })(X), J = t ? "#1890ff" : _;
1116
+ return /* @__PURE__ */ e("div", { className: "w-full h-full relative", style: { overflow: "visible" }, children: /* @__PURE__ */ i(
1117
+ "svg",
1118
+ {
1119
+ className: "absolute top-0 left-0",
1120
+ width: "100%",
1121
+ height: "100%",
1122
+ style: { overflow: "visible", pointerEvents: "none" },
1123
+ children: [
1124
+ /* @__PURE__ */ e(
1125
+ "line",
1126
+ {
1127
+ x1: z,
1128
+ y1: k,
1129
+ x2: Z,
1130
+ y2: B,
1131
+ stroke: "transparent",
1132
+ strokeWidth: Math.max(K, 10),
1133
+ strokeLinecap: "round",
1134
+ style: { pointerEvents: "stroke", cursor: "pointer" },
1135
+ onClick: (d) => {
1136
+ d.stopPropagation();
1137
+ const v = d.target.closest("[data-node-id]");
1138
+ v && v.click();
1139
+ }
1140
+ }
1141
+ ),
1142
+ /* @__PURE__ */ e(
1143
+ "line",
1144
+ {
1145
+ x1: z,
1146
+ y1: k,
1147
+ x2: Z,
1148
+ y2: B,
1149
+ stroke: J,
1150
+ strokeWidth: K,
1151
+ strokeDasharray: x,
1152
+ strokeLinecap: "butt",
1153
+ style: { pointerEvents: "none" }
1154
+ }
1155
+ )
1156
+ ]
1157
+ }
1158
+ ) });
1159
+ case "CUSTOM":
1160
+ const j = n;
1161
+ return j.render ? j.render({}) : /* @__PURE__ */ e("div", { className: "w-full h-full flex items-center justify-center bg-gray-100", children: /* @__PURE__ */ e("span", { className: "text-gray-400 text-xs", children: "自定义组件" }) });
1162
+ default:
1163
+ return /* @__PURE__ */ e("div", { className: "w-full h-full flex items-center justify-center bg-gray-100", children: /* @__PURE__ */ e("span", { className: "text-gray-400 text-xs", children: "未知类型" }) });
1164
+ }
1165
+ }, Rn = ({
1166
+ node: n,
1167
+ isSelected: f = !1,
1168
+ onClick: t,
1169
+ onMouseDown: r,
1170
+ data: o,
1171
+ onUpdateNode: l,
1172
+ scale: s = 1
1173
+ }) => {
1174
+ const { normalStyle: a, contentInfo: p, controlInfo: b } = n, { statusList: h } = p, { isClickable: w, isDraggable: c } = b, [C, g] = W(null), [D, m] = W({ x: 0, y: 0 }), T = he(null), Y = Gt(() => {
1175
+ if (h.length === 0) return;
1176
+ const x = _n(h, o);
1177
+ return x || h[0];
1178
+ }, [h, o]), U = Y?.material, R = U?.type === "LINE", _ = R ? U.config : null, L = a.scale ?? 1, X = (a.width || 100) * L, K = (a.height || 100) * L, z = G((x, J) => {
1179
+ x.stopPropagation(), x.preventDefault(), g(J), m({ x: x.clientX, y: x.clientY });
1180
+ }, []);
1181
+ ae(() => {
1182
+ if (!C || !R || !_ || !l) return;
1183
+ const x = (j) => {
1184
+ const d = (j.clientX - D.x) / s, v = (j.clientY - D.y) / s, I = _.startX || 0, M = _.startY || 0, ne = _.endX || 0, Le = _.endY || 0;
1185
+ let se = I, ee = M, ce = ne, de = Le, we = a.x || 0, $e = a.y || 0;
1186
+ C === "start" ? (se = I + d, ee = M + v, se < 0 && (we += se, ce -= se, se = 0), ee < 0 && ($e += ee, de -= ee, ee = 0)) : (ce = ne + d, de = Le + v, ce < 0 && (we += ce, se -= ce, ce = 0), de < 0 && ($e += de, ee -= de, de = 0));
1187
+ const Te = Math.max((_.lineWeight || 2) * 2, 4), Ue = Math.max(se, ce), Be = Math.max(ee, de), qe = Math.max(Ue, Te), _e = Math.max(Be, Te);
1188
+ l(n.id, {
1189
+ normalStyle: {
1190
+ ...a,
1191
+ x: we,
1192
+ y: $e,
1193
+ width: qe,
1194
+ height: _e
1195
+ },
1196
+ contentInfo: {
1197
+ ...p,
1198
+ statusList: h.map((De) => ({
1199
+ ...De,
1200
+ material: De.material.type === "LINE" ? {
1201
+ ...De.material,
1202
+ config: {
1203
+ ..._,
1204
+ startX: se,
1205
+ startY: ee,
1206
+ endX: ce,
1207
+ endY: de
1208
+ }
1209
+ } : De.material
1210
+ }))
1211
+ }
1212
+ }), m({ x: j.clientX, y: j.clientY });
1213
+ }, J = () => {
1214
+ g(null);
1215
+ };
1216
+ return window.addEventListener("mousemove", x), window.addEventListener("mouseup", J), () => {
1217
+ window.removeEventListener("mousemove", x), window.removeEventListener("mouseup", J);
1218
+ };
1219
+ }, [C, D, R, _, n.id, a, p, h, l, s]);
1220
+ const k = n.type === "group", Z = {
1221
+ position: "absolute",
1222
+ left: a.x || 0,
1223
+ top: a.y || 0,
1224
+ width: X,
1225
+ height: K,
1226
+ // 群组节点不显示背景和边框,只作为容器
1227
+ background: k ? "transparent" : a.background || "transparent",
1228
+ backgroundImage: k ? void 0 : a.backgroundImage ? `url(${a.backgroundImage})` : void 0,
1229
+ backgroundSize: "cover",
1230
+ backgroundPosition: "center",
1231
+ padding: Array.isArray(a.padding) ? a.padding.join("px ") + "px" : a.padding,
1232
+ margin: Array.isArray(a.margin) ? a.margin.join("px ") + "px" : a.margin,
1233
+ borderRadius: k ? void 0 : a.borderRadius,
1234
+ // 线条物料选中时不显示边框,而是通过高亮线条颜色来表示
1235
+ // 群组节点选中时显示边框,平时不显示
1236
+ border: f && !R ? "2px solid #1890ff" : R || k ? "none" : a.border || "1px dashed transparent",
1237
+ // 线条节点本身不捕获点击,让内部 SVG 处理
1238
+ pointerEvents: R ? "none" : "auto",
1239
+ opacity: a.opacity ?? 1,
1240
+ transform: a.transform,
1241
+ zIndex: f ? 1e3 : a.zIndex ?? 1,
1242
+ cursor: c && !C ? "move" : w ? "pointer" : "default",
1243
+ boxSizing: "border-box",
1244
+ // 线条和群组节点使用 visible overflow,避免裁剪子节点
1245
+ overflow: R || k ? "visible" : "hidden"
1246
+ }, B = _ ? { x: _.startX || 0, y: _.startY || 0 } : { x: 0, y: 0 }, Q = _ ? { x: _.endX || 0, y: _.endY || 0 } : { x: 0, y: 0 };
1247
+ return /* @__PURE__ */ i(
1248
+ "div",
1249
+ {
1250
+ ref: T,
1251
+ "data-node-id": n.id,
1252
+ style: Z,
1253
+ onClick: (x) => {
1254
+ x.stopPropagation(), w && t && !C && t(x);
1255
+ },
1256
+ onMouseDown: (x) => {
1257
+ c && r && !C && r(x);
1258
+ },
1259
+ children: [
1260
+ f && !R && /* @__PURE__ */ i(Me, { children: [
1261
+ !k && /* @__PURE__ */ i(Me, { children: [
1262
+ /* @__PURE__ */ e("div", { className: "absolute -top-1 -left-1 w-2 h-2 bg-white border border-blue-500 rounded-full" }),
1263
+ /* @__PURE__ */ e("div", { className: "absolute -top-1 -right-1 w-2 h-2 bg-white border border-blue-500 rounded-full" }),
1264
+ /* @__PURE__ */ e("div", { className: "absolute -bottom-1 -left-1 w-2 h-2 bg-white border border-blue-500 rounded-full" }),
1265
+ /* @__PURE__ */ e("div", { className: "absolute -bottom-1 -right-1 w-2 h-2 bg-white border border-blue-500 rounded-full" })
1266
+ ] }),
1267
+ /* @__PURE__ */ i("div", { className: "absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap", children: [
1268
+ n.name,
1269
+ " ",
1270
+ Y ? `(${Y.name})` : ""
1271
+ ] })
1272
+ ] }),
1273
+ f && R && _ && l && /* @__PURE__ */ i(Me, { children: [
1274
+ /* @__PURE__ */ e(
1275
+ "div",
1276
+ {
1277
+ className: "absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",
1278
+ style: {
1279
+ left: B.x - 6,
1280
+ top: B.y - 6,
1281
+ boxShadow: "0 0 4px rgba(0,0,0,0.3)"
1282
+ },
1283
+ onMouseDown: (x) => z(x, "start"),
1284
+ title: "拖拽调整起点"
1285
+ }
1286
+ ),
1287
+ /* @__PURE__ */ e(
1288
+ "div",
1289
+ {
1290
+ className: "absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",
1291
+ style: {
1292
+ left: Q.x - 6,
1293
+ top: Q.y - 6,
1294
+ boxShadow: "0 0 4px rgba(0,0,0,0.3)"
1295
+ },
1296
+ onMouseDown: (x) => z(x, "end"),
1297
+ title: "拖拽调整终点"
1298
+ }
1299
+ ),
1300
+ /* @__PURE__ */ e("div", { className: "absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap", children: n.name })
1301
+ ] }),
1302
+ /* @__PURE__ */ e("div", { className: "w-full h-full relative", children: U ? /* @__PURE__ */ e("div", { className: "w-full h-full", children: Xn(U, o, f) }) : k ? null : (
1303
+ // 只有非群组节点才显示"无状态"
1304
+ /* @__PURE__ */ e("div", { className: "w-full h-full flex items-center justify-center text-gray-300 text-xs", children: "无状态" })
1305
+ ) }),
1306
+ n.type === "group" && n.children && /* @__PURE__ */ e("div", { className: "absolute inset-0 pointer-events-none", children: n.children.map((x) => /* @__PURE__ */ e("div", { className: "pointer-events-auto", children: /* @__PURE__ */ e(
1307
+ Tt,
1308
+ {
1309
+ node: x,
1310
+ isSelected: !1,
1311
+ data: o,
1312
+ onUpdateNode: l,
1313
+ scale: s
1314
+ }
1315
+ ) }, x.id)) })
1316
+ ]
1317
+ }
1318
+ );
1319
+ }, Tt = pe.memo(Rn, (n, f) => {
1320
+ const t = n.node, r = f.node, o = t.id === r.id && t.normalStyle.x === r.normalStyle.x && t.normalStyle.y === r.normalStyle.y && t.normalStyle.width === r.normalStyle.width && t.normalStyle.height === r.normalStyle.height, l = n.isSelected === f.isSelected && n.scale === f.scale;
1321
+ return o && l;
1322
+ }), { Panel: An } = ge, { TextArea: zn } = oe, jn = ({
1323
+ defaultTestData: n
1324
+ }) => {
1325
+ const f = he(null), t = he(null), r = he(null), {
1326
+ nodes: o,
1327
+ selectedNodeId: l,
1328
+ selectedStatusId: s,
1329
+ mode: a,
1330
+ lineDrawing: p,
1331
+ viewport: b,
1332
+ setViewport: h,
1333
+ addNode: w,
1334
+ selectNode: c,
1335
+ updateNode: C,
1336
+ removeNode: g,
1337
+ undo: D,
1338
+ redo: m,
1339
+ setMode: T,
1340
+ startLineDrawing: Y,
1341
+ updateLineDrawing: U,
1342
+ endLineDrawing: R,
1343
+ cancelLineDrawing: _,
1344
+ addMaterial: L
1345
+ } = Qe(), X = he(!1), K = he({ x: 0, y: 0 }), z = he({ x: 0, y: 0, newX: 0, newY: 0 }), k = he(null), [, Z] = W({}), [B, Q] = W(!1), [x, J] = W({ start: null, end: null, isDrawing: !1 }), [j, d] = W(!1), [v, I] = W({ start: null, end: null }), [M, ne] = W([]), Le = he(o), se = he({ start: null, end: null }), ee = he(j);
1346
+ ae(() => {
1347
+ Le.current = o;
1348
+ }, [o]), ae(() => {
1349
+ se.current = v;
1350
+ }, [v]), ae(() => {
1351
+ ee.current = j;
1352
+ }, [j]);
1353
+ const [ce, de] = W(!1), we = he(n), [$e, Te] = W(n), [Ue, Be] = W(
1354
+ JSON.stringify(n, null, 2)
1355
+ ), [qe, _e] = W(null);
1356
+ ae(() => {
1357
+ a === "preview" && Te(n), we.current = n, ce || Be(JSON.stringify(n, null, 2));
1358
+ }, [n, ce, a]);
1359
+ const De = G(() => {
1360
+ const u = f.current?.state;
1361
+ u && h({
1362
+ scale: u.scale,
1363
+ positionX: u.positionX,
1364
+ positionY: u.positionY
1365
+ });
1366
+ }, [h]), Ot = G(
1367
+ (u) => {
1368
+ X.current || j && v.start || (u.target === t.current || u.target.dataset?.canvas === "true") && c(null);
1369
+ },
1370
+ [c, j, v.start]
1371
+ ), Yt = G(
1372
+ (u) => {
1373
+ u.preventDefault(), u.dataTransfer.dropEffect = "copy", B || Q(!0);
1374
+ },
1375
+ [B]
1376
+ ), Xt = G((u) => {
1377
+ u.preventDefault(), Q(!1);
1378
+ }, []), Rt = G(
1379
+ (u) => {
1380
+ if (u.preventDefault(), u.stopPropagation(), Q(!1), !(!t.current || a !== "select"))
1381
+ try {
1382
+ const y = u.dataTransfer.getData("application/json");
1383
+ if (!y) return;
1384
+ const E = JSON.parse(y), S = t.current.getBoundingClientRect(), $ = f.current?.state, q = $?.scale ?? b.scale, F = $?.positionX ?? b.positionX, P = $?.positionY ?? b.positionY, H = (u.clientX - S.left - F) / q - 50, le = (u.clientY - S.top - P) / q - 50, ue = Ln(H, le, E);
1385
+ w(ue);
1386
+ } catch (y) {
1387
+ console.error("Failed to parse dropped material:", y);
1388
+ }
1389
+ },
1390
+ [a, b, w]
1391
+ ), At = G(
1392
+ (u, y) => {
1393
+ a !== "select" || !y.controlInfo.isDraggable || (u.stopPropagation(), c(y.id), X.current = !0, K.current = { x: u.clientX, y: u.clientY }, z.current = {
1394
+ x: y.normalStyle.x || 0,
1395
+ y: y.normalStyle.y || 0,
1396
+ newX: y.normalStyle.x || 0,
1397
+ newY: y.normalStyle.y || 0
1398
+ }, k.current = y, u.preventDefault());
1399
+ },
1400
+ [a, c]
1401
+ ), ve = G(
1402
+ (u, y) => {
1403
+ if (!t.current)
1404
+ return console.log("[getCanvasPosition] canvas ref not ready"), { x: 0, y: 0 };
1405
+ const E = t.current.getBoundingClientRect(), S = f.current?.state?.scale ?? 1, $ = u - E.left, q = y - E.top, F = $ * (1920 / E.width), P = q * (1080 / E.height), H = { x: Math.round(F), y: Math.round(P) };
1406
+ return console.log("[getCanvasPosition]", { clientX: u, clientY: y, canvasRect: E, scale: S, result: H }), H;
1407
+ },
1408
+ []
1409
+ ), Ge = G(
1410
+ (u, y, E = !0) => {
1411
+ if (!p.material) return;
1412
+ const S = p.material, $ = S.config || {}, q = $.lineWeight || $.thickness || 2, F = Math.min(u.x, y.x), P = Math.min(u.y, y.y), H = Math.round(u.x - F), le = Math.round(u.y - P), ue = Math.round(y.x - F), Se = Math.round(y.y - P), ke = Math.max(q * 2, 4), re = Math.max(Math.abs(u.x - y.x), ke), Ee = Math.max(Math.abs(u.y - y.y), ke), Ne = {
1413
+ ...S,
1414
+ id: O(),
1415
+ config: {
1416
+ // 只保留关键配置:颜色、线宽、线型
1417
+ color: $.color,
1418
+ lineWeight: q,
1419
+ thickness: q,
1420
+ lineType: $.lineType,
1421
+ // 起止位置(相对于节点)
1422
+ startX: H,
1423
+ startY: le,
1424
+ endX: ue,
1425
+ endY: Se
1426
+ }
1427
+ }, et = {
1428
+ id: O(),
1429
+ name: `${S.name}_${Date.now()}`,
1430
+ type: "normal",
1431
+ normalStyle: {
1432
+ width: re,
1433
+ height: Ee,
1434
+ x: F,
1435
+ y: P,
1436
+ background: "transparent"
1437
+ },
1438
+ contentInfo: {
1439
+ statusList: [$t(Ne)],
1440
+ currentStatusId: void 0
1441
+ },
1442
+ controlInfo: {
1443
+ isDraggable: !0,
1444
+ isClickable: !0,
1445
+ isResizable: !0,
1446
+ isSelectable: !0
1447
+ }
1448
+ };
1449
+ if (w(et, !1), E) {
1450
+ const Ze = { x: y.x, y: y.y };
1451
+ J({
1452
+ start: Ze,
1453
+ end: { ...Ze },
1454
+ isDrawing: !0
1455
+ });
1456
+ } else
1457
+ J({ start: null, end: null, isDrawing: !1 }), R();
1458
+ },
1459
+ [p.material, w, R]
1460
+ ), zt = G(
1461
+ (u) => {
1462
+ const y = ee.current;
1463
+ if (console.log("[handleCanvasMouseDown]", { button: u.button, mode: a, isBoxSelecting: y, isBoxSelectingState: j, lineDrawingMaterial: !!p.material }), console.log("[handleCanvasMouseDown] ref values:", { isBoxSelectingRef: ee.current, selectionBoxRef: se.current }), u.button !== 0) return;
1464
+ if (y) {
1465
+ const S = ve(u.clientX, u.clientY);
1466
+ I({ start: S, end: S }), ne([]);
1467
+ return;
1468
+ }
1469
+ if (a === "select" && !p.material)
1470
+ return;
1471
+ if (a !== "line-draw" || !p.material) {
1472
+ console.log("[handleCanvasMouseDown] not in line-draw mode or no material");
1473
+ return;
1474
+ }
1475
+ const E = ve(u.clientX, u.clientY);
1476
+ console.log("[handleCanvasMouseDown] drawing at", E, "isDrawing:", x.isDrawing), x.isDrawing ? x.start && Ge(x.start, E, !0) : J({
1477
+ start: E,
1478
+ end: E,
1479
+ isDrawing: !0
1480
+ });
1481
+ },
1482
+ [a, p.material, x.isDrawing, x.start, ve, Ge]
1483
+ ), jt = G(
1484
+ (u) => {
1485
+ if (!(a !== "line-draw" || !p.material) && x.isDrawing && x.start) {
1486
+ const y = ve(u.clientX, u.clientY);
1487
+ Ge(x.start, y, !1);
1488
+ }
1489
+ },
1490
+ [a, p.material, x.isDrawing, x.start, ve, Ge]
1491
+ );
1492
+ G(() => {
1493
+ if (!v.start || !v.end) return [];
1494
+ const u = Math.min(v.start.x, v.end.x), y = Math.max(v.start.x, v.end.x), E = Math.min(v.start.y, v.end.y), S = Math.max(v.start.y, v.end.y);
1495
+ return o.filter(($) => {
1496
+ const q = $.normalStyle.x || 0, F = $.normalStyle.y || 0, P = $.normalStyle.width || 0, H = $.normalStyle.height || 0, le = q + P / 2, ue = F + H / 2;
1497
+ return le >= u && le <= y && ue >= E && ue <= S;
1498
+ }).map(($) => $.id);
1499
+ }, [v, o]);
1500
+ const Ft = G(() => {
1501
+ if (M.length < 2) return;
1502
+ const u = o.filter((P) => M.includes(P.id));
1503
+ if (u.length < 2) return;
1504
+ let y = 1 / 0, E = 1 / 0, S = -1 / 0, $ = -1 / 0;
1505
+ u.forEach((P) => {
1506
+ const H = P.normalStyle.x || 0, le = P.normalStyle.y || 0, ue = P.normalStyle.width || 0, Se = P.normalStyle.height || 0;
1507
+ y = Math.min(y, H), E = Math.min(E, le), S = Math.max(S, H + ue), $ = Math.max($, le + Se);
1508
+ });
1509
+ const q = u.map((P) => ({
1510
+ ...P,
1511
+ normalStyle: {
1512
+ ...P.normalStyle,
1513
+ x: (P.normalStyle.x || 0) - y,
1514
+ y: (P.normalStyle.y || 0) - E,
1515
+ scale: void 0
1516
+ // 移除 scale,由父级容器统一控制
1517
+ }
1518
+ })), F = {
1519
+ id: O(),
1520
+ name: `群组_${Date.now()}`,
1521
+ type: "group",
1522
+ normalStyle: {
1523
+ x: y,
1524
+ y: E,
1525
+ width: S - y,
1526
+ height: $ - E
1527
+ // 不设置背景和边框,由 NodeRenderer 控制
1528
+ },
1529
+ contentInfo: {
1530
+ statusList: [],
1531
+ currentStatusId: void 0
1532
+ },
1533
+ controlInfo: {
1534
+ isDraggable: !0,
1535
+ isClickable: !0,
1536
+ isResizable: !0,
1537
+ isSelectable: !0
1538
+ },
1539
+ children: q
1540
+ };
1541
+ M.forEach((P) => g(P)), w(F), ne([]), c(F.id);
1542
+ }, [M, o, w, g, c]), Wt = G(() => {
1543
+ if (!l) return;
1544
+ const u = o.find((E) => E.id === l);
1545
+ if (!u || u.type !== "group") return;
1546
+ const y = {
1547
+ id: O(),
1548
+ name: `群组_${u.name || Date.now()}`,
1549
+ type: "CUSTOM",
1550
+ config: {
1551
+ nodes: u.children
1552
+ }
1553
+ };
1554
+ L(y), console.log("[Canvas] 群组已保存到物料库:", y.name);
1555
+ }, [l, o, L]), Ve = G((u) => {
1556
+ if (M.length < 2) return;
1557
+ const y = M.map((S) => o.find(($) => $.id === S)).filter((S) => !!S && S.type !== "group");
1558
+ if (y.length < 2) return;
1559
+ let E;
1560
+ switch (u) {
1561
+ case "left":
1562
+ E = Math.min(...y.map((S) => S.normalStyle.x || 0));
1563
+ break;
1564
+ case "right":
1565
+ E = Math.max(...y.map((S) => (S.normalStyle.x || 0) + (S.normalStyle.width || 0)));
1566
+ break;
1567
+ case "top":
1568
+ E = Math.min(...y.map((S) => S.normalStyle.y || 0));
1569
+ break;
1570
+ case "bottom":
1571
+ E = Math.max(...y.map((S) => (S.normalStyle.y || 0) + (S.normalStyle.height || 0)));
1572
+ break;
1573
+ default:
1574
+ return;
1575
+ }
1576
+ y.forEach((S) => {
1577
+ let $ = S.normalStyle.x || 0, q = S.normalStyle.y || 0;
1578
+ switch (u) {
1579
+ case "left":
1580
+ $ = E;
1581
+ break;
1582
+ case "right":
1583
+ $ = E - (S.normalStyle.width || 0);
1584
+ break;
1585
+ case "top":
1586
+ q = E;
1587
+ break;
1588
+ case "bottom":
1589
+ q = E - (S.normalStyle.height || 0);
1590
+ break;
1591
+ }
1592
+ C(S.id, {
1593
+ normalStyle: {
1594
+ ...S.normalStyle,
1595
+ x: $,
1596
+ y: q
1597
+ }
1598
+ });
1599
+ });
1600
+ }, [M, o, C]);
1601
+ ae(() => {
1602
+ const u = (S) => {
1603
+ const $ = ee.current, q = se.current;
1604
+ if ($ && q.start) {
1605
+ const F = ve(S.clientX, S.clientY);
1606
+ I((re) => ({ ...re, end: F }));
1607
+ const P = {
1608
+ start: q.start,
1609
+ end: F
1610
+ }, H = Math.min(P.start.x, P.end.x), le = Math.max(P.start.x, P.end.x), ue = Math.min(P.start.y, P.end.y), Se = Math.max(P.start.y, P.end.y), ke = Le.current.filter((re) => {
1611
+ const Ee = re.normalStyle.x || 0, Ne = re.normalStyle.y || 0, et = re.normalStyle.width || 0, Ze = re.normalStyle.height || 0, ct = Ee + et / 2, dt = Ne + Ze / 2;
1612
+ return ct >= H && ct <= le && dt >= ue && dt <= Se;
1613
+ }).map((re) => re.id);
1614
+ ne(ke);
1615
+ return;
1616
+ }
1617
+ if (X.current && l && k.current) {
1618
+ if (!t.current) return;
1619
+ const F = t.current.getBoundingClientRect(), P = 1920 / F.width, H = 1080 / F.height, le = S.clientX - K.current.x, ue = S.clientY - K.current.y, Se = le * P, ke = ue * H, re = z.current.x + Se, Ee = z.current.y + ke, Ne = document.querySelector(`[data-node-id="${l}"]`);
1620
+ Ne && (Ne.style.left = `${re}px`, Ne.style.top = `${Ee}px`), z.current.newX = re, z.current.newY = Ee;
1621
+ }
1622
+ if (a === "line-draw" && x.isDrawing) {
1623
+ const F = ve(S.clientX, S.clientY);
1624
+ J((P) => ({
1625
+ ...P,
1626
+ end: F
1627
+ }));
1628
+ }
1629
+ }, y = () => {
1630
+ if (X.current && l && k.current) {
1631
+ const S = z.current.newX ?? z.current.x, $ = z.current.newY ?? z.current.y;
1632
+ C(l, {
1633
+ normalStyle: {
1634
+ ...k.current.normalStyle,
1635
+ x: S,
1636
+ y: $
1637
+ }
1638
+ });
1639
+ }
1640
+ X.current = !1, k.current = null, Z({}), ee.current && I({ start: null, end: null });
1641
+ }, E = (S) => {
1642
+ S.key === "Escape" && a === "line-draw" && (J({ start: null, end: null, isDrawing: !1 }), _());
1643
+ };
1644
+ return window.addEventListener("mousemove", u), window.addEventListener("mouseup", y), window.addEventListener("keydown", E), () => {
1645
+ window.removeEventListener("mousemove", u), window.removeEventListener("mouseup", y), window.removeEventListener("keydown", E);
1646
+ };
1647
+ }, [
1648
+ l,
1649
+ C,
1650
+ a,
1651
+ x.isDrawing,
1652
+ ve,
1653
+ _
1654
+ ]), ae(() => {
1655
+ const u = (y) => {
1656
+ y.key === "Delete" && l && g(l), y.ctrlKey && y.key === "z" && (y.preventDefault(), D()), y.ctrlKey && y.key === "y" && (y.preventDefault(), m()), y.key === "Escape" && a === "line-draw" && (J({ start: null, end: null, isDrawing: !1 }), _());
1657
+ };
1658
+ return window.addEventListener("keydown", u), () => window.removeEventListener("keydown", u);
1659
+ }, [l, g, D, m, a, _]);
1660
+ const Ut = () => {
1661
+ try {
1662
+ const u = JSON.parse(Ue);
1663
+ we.current = u, Te(u), _e(null), de(!1);
1664
+ } catch {
1665
+ _e("JSON 格式错误,请检查输入");
1666
+ }
1667
+ }, Bt = [
1668
+ {
1669
+ icon: /* @__PURE__ */ e(dn, {}),
1670
+ title: "选择模式",
1671
+ active: a === "select",
1672
+ onClick: () => {
1673
+ T("select"), d(!1);
1674
+ }
1675
+ },
1676
+ {
1677
+ icon: /* @__PURE__ */ e(un, {}),
1678
+ title: "拖拽模式",
1679
+ active: a === "drag",
1680
+ onClick: () => {
1681
+ T("drag"), d(!1);
1682
+ }
1683
+ },
1684
+ {
1685
+ icon: /* @__PURE__ */ e(hn, {}),
1686
+ title: "预览模式",
1687
+ active: a === "preview",
1688
+ onClick: () => {
1689
+ T("preview"), d(!1);
1690
+ }
1691
+ }
1692
+ ], qt = [
1693
+ {
1694
+ icon: /* @__PURE__ */ e(Ht, {}),
1695
+ title: "撤销 (Ctrl+Z)",
1696
+ onClick: D
1697
+ },
1698
+ {
1699
+ icon: /* @__PURE__ */ e(Kt, {}),
1700
+ title: "重做 (Ctrl+Y)",
1701
+ onClick: m
1702
+ },
1703
+ {
1704
+ icon: /* @__PURE__ */ e(Qt, {}),
1705
+ title: "框选模式",
1706
+ active: j,
1707
+ onClick: () => {
1708
+ d(!j), T("select"), ne([]);
1709
+ }
1710
+ },
1711
+ {
1712
+ icon: /* @__PURE__ */ e(en, {}),
1713
+ title: "组合选中节点",
1714
+ disabled: M.length < 2,
1715
+ onClick: Ft
1716
+ },
1717
+ {
1718
+ icon: /* @__PURE__ */ e(tn, {}),
1719
+ title: "左对齐",
1720
+ disabled: M.filter((u) => o.find((y) => y.id === u)?.type !== "group").length < 2,
1721
+ onClick: () => Ve("left")
1722
+ },
1723
+ {
1724
+ icon: /* @__PURE__ */ e(nn, {}),
1725
+ title: "右对齐",
1726
+ disabled: M.filter((u) => o.find((y) => y.id === u)?.type !== "group").length < 2,
1727
+ onClick: () => Ve("right")
1728
+ },
1729
+ {
1730
+ icon: /* @__PURE__ */ e(ln, {}),
1731
+ title: "上对齐",
1732
+ disabled: M.filter((u) => o.find((y) => y.id === u)?.type !== "group").length < 2,
1733
+ onClick: () => Ve("top")
1734
+ },
1735
+ {
1736
+ icon: /* @__PURE__ */ e(rn, {}),
1737
+ title: "下对齐",
1738
+ disabled: M.filter((u) => o.find((y) => y.id === u)?.type !== "group").length < 2,
1739
+ onClick: () => Ve("bottom")
1740
+ },
1741
+ {
1742
+ icon: /* @__PURE__ */ e(an, {}),
1743
+ title: "保存群组到物料库",
1744
+ disabled: !l || o.find((u) => u.id === l)?.type !== "group",
1745
+ onClick: Wt
1746
+ },
1747
+ {
1748
+ icon: /* @__PURE__ */ e(on, {}),
1749
+ title: "数据模拟",
1750
+ type: "primary",
1751
+ onClick: () => de(!0)
1752
+ },
1753
+ {
1754
+ icon: /* @__PURE__ */ e(Ke, {}),
1755
+ title: "删除选中 (Delete)",
1756
+ disabled: !l && M.length === 0,
1757
+ onClick: () => {
1758
+ l ? g(l) : M.length > 0 && (M.forEach((u) => g(u)), ne([]));
1759
+ }
1760
+ }
1761
+ ];
1762
+ return /* @__PURE__ */ i("div", { className: "flex-1 flex flex-col h-full bg-gray-100", children: [
1763
+ /* @__PURE__ */ i("div", { className: "h-12 bg-white border-b border-gray-200 flex items-center justify-between px-4", children: [
1764
+ /* @__PURE__ */ e(me, { children: Bt.map((u) => /* @__PURE__ */ e(Ie, { title: u.title, children: /* @__PURE__ */ e(
1765
+ A,
1766
+ {
1767
+ type: u.active ? "primary" : "default",
1768
+ icon: u.icon,
1769
+ onClick: u.onClick
1770
+ }
1771
+ ) }, u.title)) }),
1772
+ /* @__PURE__ */ e(me, { children: qt.map((u) => /* @__PURE__ */ e(Ie, { title: u.title, children: /* @__PURE__ */ e(
1773
+ A,
1774
+ {
1775
+ type: u.type || "default",
1776
+ icon: u.icon,
1777
+ onClick: u.onClick,
1778
+ disabled: u.disabled
1779
+ }
1780
+ ) }, u.title)) })
1781
+ ] }),
1782
+ /* @__PURE__ */ e("div", { ref: r, className: "flex-1 relative", children: /* @__PURE__ */ e(
1783
+ yn,
1784
+ {
1785
+ ref: f,
1786
+ initialScale: 1,
1787
+ initialPositionX: 0,
1788
+ initialPositionY: 0,
1789
+ minScale: 0.5,
1790
+ maxScale: 5,
1791
+ onTransformed: De,
1792
+ limitToBounds: !1,
1793
+ centerZoomedOut: !1,
1794
+ panning: {
1795
+ disabled: !1,
1796
+ velocityDisabled: !0
1797
+ },
1798
+ wheel: {
1799
+ disabled: !1,
1800
+ step: 0.1
1801
+ },
1802
+ pinch: {
1803
+ disabled: !1
1804
+ },
1805
+ doubleClick: {
1806
+ disabled: !0
1807
+ },
1808
+ children: ({ zoomIn: u, zoomOut: y, resetTransform: E }) => /* @__PURE__ */ i(Me, { children: [
1809
+ /* @__PURE__ */ e("div", { className: "absolute bottom-4 right-4 z-10 bg-white rounded-lg shadow-lg p-2", children: /* @__PURE__ */ i(me, { direction: "vertical", children: [
1810
+ /* @__PURE__ */ e(Ie, { title: "放大", children: /* @__PURE__ */ e(
1811
+ A,
1812
+ {
1813
+ icon: /* @__PURE__ */ e(sn, {}),
1814
+ onClick: () => u()
1815
+ }
1816
+ ) }),
1817
+ /* @__PURE__ */ e(Ie, { title: "缩小", children: /* @__PURE__ */ e(
1818
+ A,
1819
+ {
1820
+ icon: /* @__PURE__ */ e(cn, {}),
1821
+ onClick: () => y()
1822
+ }
1823
+ ) }),
1824
+ /* @__PURE__ */ e(Ie, { title: "重置视图", children: /* @__PURE__ */ e(A, { onClick: () => E(), children: "100%" }) }),
1825
+ /* @__PURE__ */ i("div", { className: "text-center text-xs text-gray-500", children: [
1826
+ Math.round(b.scale * 100),
1827
+ "%"
1828
+ ] })
1829
+ ] }) }),
1830
+ /* @__PURE__ */ e(
1831
+ vn,
1832
+ {
1833
+ wrapperStyle: { width: "100%", height: "100%", position: "relative" },
1834
+ contentStyle: { width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center" },
1835
+ children: /* @__PURE__ */ i(
1836
+ "div",
1837
+ {
1838
+ ref: t,
1839
+ "data-canvas": "true",
1840
+ className: `
1841
+ relative bg-white
1842
+ ${B ? "ring-4 ring-blue-400 ring-opacity-50" : ""}
1843
+ ${a === "line-draw" ? "cursor-crosshair" : ""}
1844
+ `,
1845
+ style: {
1846
+ width: 1920,
1847
+ height: 1080,
1848
+ flexShrink: 0
1849
+ },
1850
+ onClick: Ot,
1851
+ onMouseDown: zt,
1852
+ onDoubleClick: jt,
1853
+ onDragOver: Yt,
1854
+ onDragLeave: Xt,
1855
+ onDrop: Rt,
1856
+ children: [
1857
+ /* @__PURE__ */ i(
1858
+ "svg",
1859
+ {
1860
+ className: "absolute top-0 left-0 pointer-events-none",
1861
+ width: "1920",
1862
+ height: "1080",
1863
+ children: [
1864
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ e(
1865
+ "pattern",
1866
+ {
1867
+ id: "grid",
1868
+ width: "20",
1869
+ height: "20",
1870
+ patternUnits: "userSpaceOnUse",
1871
+ children: /* @__PURE__ */ e(
1872
+ "path",
1873
+ {
1874
+ d: "M 20 0 L 0 0 0 20",
1875
+ fill: "none",
1876
+ stroke: "#e8e8e8",
1877
+ strokeWidth: "1"
1878
+ }
1879
+ )
1880
+ }
1881
+ ) }),
1882
+ /* @__PURE__ */ e("rect", { width: "1920", height: "1080", fill: "url(#grid)" })
1883
+ ]
1884
+ }
1885
+ ),
1886
+ /* @__PURE__ */ e("div", { className: "absolute left-1/2 top-1/2 w-4 h-4 -ml-2 -mt-2 border border-blue-300 rounded-full opacity-50" }),
1887
+ B && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center pointer-events-none", children: /* @__PURE__ */ e("div", { className: "bg-blue-500 text-white px-6 py-3 rounded-lg shadow-lg text-lg font-medium", children: "释放以添加节点" }) }),
1888
+ a === "line-draw" && /* @__PURE__ */ e("div", { className: "absolute top-4 left-1/2 -translate-x-1/2 z-50 pointer-events-none", children: /* @__PURE__ */ i("div", { className: "bg-blue-500 text-white px-4 py-2 rounded-lg shadow-lg text-sm font-medium flex items-center gap-2", children: [
1889
+ /* @__PURE__ */ e("span", { children: "线条绘制模式" }),
1890
+ /* @__PURE__ */ e("span", { className: "text-blue-200", children: "|" }),
1891
+ /* @__PURE__ */ e("span", { className: "text-blue-100", children: x.isDrawing ? "点击绘制下一条线段,双击结束绘制" : "点击确定起点" }),
1892
+ /* @__PURE__ */ e("span", { className: "text-blue-200", children: "|" }),
1893
+ /* @__PURE__ */ e("span", { className: "text-blue-100 text-xs", children: "ESC 取消" })
1894
+ ] }) }),
1895
+ a === "line-draw" && x.isDrawing && x.start && x.end && /* @__PURE__ */ i(
1896
+ "svg",
1897
+ {
1898
+ className: "absolute top-0 left-0 pointer-events-none",
1899
+ style: {
1900
+ zIndex: 1e3,
1901
+ width: 1920,
1902
+ height: 1080,
1903
+ overflow: "visible"
1904
+ },
1905
+ children: [
1906
+ /* @__PURE__ */ e(
1907
+ "line",
1908
+ {
1909
+ x1: x.start.x,
1910
+ y1: x.start.y,
1911
+ x2: x.end.x,
1912
+ y2: x.end.y,
1913
+ stroke: "#1890ff",
1914
+ strokeWidth: 2,
1915
+ strokeDasharray: "5,5"
1916
+ }
1917
+ ),
1918
+ /* @__PURE__ */ e(
1919
+ "circle",
1920
+ {
1921
+ cx: x.start.x,
1922
+ cy: x.start.y,
1923
+ r: 4,
1924
+ fill: "#1890ff"
1925
+ }
1926
+ ),
1927
+ /* @__PURE__ */ e(
1928
+ "circle",
1929
+ {
1930
+ cx: x.end.x,
1931
+ cy: x.end.y,
1932
+ r: 4,
1933
+ fill: "#1890ff",
1934
+ stroke: "#fff",
1935
+ strokeWidth: 2
1936
+ }
1937
+ )
1938
+ ]
1939
+ }
1940
+ ),
1941
+ j && v.start && v.end && /* @__PURE__ */ e(
1942
+ "div",
1943
+ {
1944
+ className: "absolute border-2 border-blue-500 bg-blue-500/10 pointer-events-none",
1945
+ style: {
1946
+ left: Math.min(v.start.x, v.end.x),
1947
+ top: Math.min(v.start.y, v.end.y),
1948
+ width: Math.abs(v.end.x - v.start.x),
1949
+ height: Math.abs(v.end.y - v.start.y),
1950
+ zIndex: 999
1951
+ }
1952
+ }
1953
+ ),
1954
+ o.map((S) => /* @__PURE__ */ e(
1955
+ Tt,
1956
+ {
1957
+ node: S,
1958
+ isSelected: (l === S.id || M.includes(S.id)) && a !== "preview",
1959
+ onClick: () => {
1960
+ j || c(S.id);
1961
+ },
1962
+ onMouseDown: ($) => At($, S),
1963
+ data: a === "preview" ? $e : we.current,
1964
+ onUpdateNode: C,
1965
+ scale: f.current?.state?.scale ?? 1
1966
+ },
1967
+ S.id
1968
+ )),
1969
+ o.length === 0 && !B && a !== "line-draw" && /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e(
1970
+ te,
1971
+ {
1972
+ description: /* @__PURE__ */ e("span", { children: "拖拽左侧物料库中的物料到画布以创建节点" })
1973
+ }
1974
+ ) })
1975
+ ]
1976
+ }
1977
+ )
1978
+ }
1979
+ )
1980
+ ] })
1981
+ }
1982
+ ) }),
1983
+ /* @__PURE__ */ i("div", { className: "h-8 bg-white border-t border-gray-200 flex items-center justify-between px-4 text-xs text-gray-500", children: [
1984
+ /* @__PURE__ */ i("span", { children: [
1985
+ "节点数: ",
1986
+ o.length,
1987
+ " | 选中节点: ",
1988
+ l ? "是" : "否",
1989
+ " | 选中状态: ",
1990
+ s || "无"
1991
+ ] }),
1992
+ /* @__PURE__ */ i("span", { children: [
1993
+ "位置: (",
1994
+ Math.round(b.positionX),
1995
+ ",",
1996
+ " ",
1997
+ Math.round(b.positionY),
1998
+ ") | 缩放:",
1999
+ " ",
2000
+ Math.round(b.scale * 100),
2001
+ "%"
2002
+ ] })
2003
+ ] }),
2004
+ /* @__PURE__ */ e(
2005
+ it,
2006
+ {
2007
+ title: "数据模拟",
2008
+ open: ce,
2009
+ onOk: Ut,
2010
+ onCancel: () => de(!1),
2011
+ width: 600,
2012
+ okText: "应用",
2013
+ cancelText: "取消",
2014
+ children: /* @__PURE__ */ i("div", { className: "space-y-4", children: [
2015
+ /* @__PURE__ */ i("p", { className: "text-sm text-gray-500", children: [
2016
+ "输入测试数据(JSON格式),用于状态表达式计算。状态表达式可以使用",
2017
+ " ",
2018
+ /* @__PURE__ */ e("code", { children: "data" }),
2019
+ " 变量访问这些数据。"
2020
+ ] }),
2021
+ /* @__PURE__ */ e(N, { layout: "vertical", children: /* @__PURE__ */ e(
2022
+ N.Item,
2023
+ {
2024
+ label: "测试数据",
2025
+ validateStatus: qe ? "error" : "",
2026
+ help: qe,
2027
+ children: /* @__PURE__ */ e(
2028
+ zn,
2029
+ {
2030
+ value: Ue,
2031
+ onChange: (u) => {
2032
+ Be(u.target.value), _e(null);
2033
+ },
2034
+ rows: 10,
2035
+ placeholder: `{
2036
+ "running": true,
2037
+ "temperature": 25,
2038
+ "pressure": 1.5
2039
+ }`
2040
+ }
2041
+ )
2042
+ }
2043
+ ) }),
2044
+ /* @__PURE__ */ e(ge, { ghost: !0, children: /* @__PURE__ */ e(An, { header: "使用示例", children: /* @__PURE__ */ i("div", { className: "space-y-2 text-sm", children: [
2045
+ /* @__PURE__ */ e("p", { children: /* @__PURE__ */ e("strong", { children: "状态A(运行中):" }) }),
2046
+ /* @__PURE__ */ e("code", { className: "bg-gray-100 px-2 py-1 rounded", children: "return data.running === true;" }),
2047
+ /* @__PURE__ */ e("p", { className: "mt-2", children: /* @__PURE__ */ e("strong", { children: "状态B(高温报警):" }) }),
2048
+ /* @__PURE__ */ e("code", { className: "bg-gray-100 px-2 py-1 rounded", children: "return data.temperature > 80;" }),
2049
+ /* @__PURE__ */ e("p", { className: "mt-2", children: /* @__PURE__ */ e("strong", { children: "状态C(默认):" }) }),
2050
+ /* @__PURE__ */ e("code", { className: "bg-gray-100 px-2 py-1 rounded", children: "return true;" })
2051
+ ] }) }, "examples") })
2052
+ ] })
2053
+ }
2054
+ )
2055
+ ] });
2056
+ }, { Panel: fe } = ge, { TabPane: lt } = Ct, { Option: We } = be, { TextArea: st } = oe, Fn = ({
2057
+ material: n,
2058
+ onSave: f,
2059
+ bindCodes: t = [],
2060
+ dataOptions: r = []
2061
+ }) => {
2062
+ const l = n.content || {}, [s, a] = W({
2063
+ label: l.label || "",
2064
+ value: l.value || "",
2065
+ valueSourceCode: l.valueSourceCode || "",
2066
+ unit: l.unit || "",
2067
+ decimals: l.decimals ?? 2,
2068
+ labelFontSize: l.labelStyle?.fontSize || 14,
2069
+ labelFontWeight: l.labelStyle?.fontWeight || "bold",
2070
+ labelColor: l.labelStyle?.color || "#262626",
2071
+ valueFontSize: l.valueStyle?.fontSize || 14,
2072
+ valueFontWeight: l.valueStyle?.fontWeight || "normal",
2073
+ valueColor: l.valueStyle?.color || "#1890ff"
2074
+ });
2075
+ ae(() => {
2076
+ a({
2077
+ label: l.label || "",
2078
+ value: l.value || "",
2079
+ valueSourceCode: l.valueSourceCode || "",
2080
+ unit: l.unit || "",
2081
+ decimals: l.decimals ?? 2,
2082
+ labelFontSize: l.labelStyle?.fontSize || 14,
2083
+ labelFontWeight: l.labelStyle?.fontWeight || "bold",
2084
+ labelColor: l.labelStyle?.color || "#262626",
2085
+ valueFontSize: l.valueStyle?.fontSize || 14,
2086
+ valueFontWeight: l.valueStyle?.fontWeight || "normal",
2087
+ valueColor: l.valueStyle?.color || "#1890ff"
2088
+ });
2089
+ }, [n.id]);
2090
+ const p = (c, C) => {
2091
+ a((g) => ({ ...g, [c]: C }));
2092
+ }, b = (c) => {
2093
+ const C = r.find((D) => D.paramsCode === c), g = C?.paramsUnit || "";
2094
+ a((D) => ({
2095
+ ...D,
2096
+ valueSourceCode: c,
2097
+ unit: g,
2098
+ value: C?.value || ""
2099
+ })), setTimeout(() => {
2100
+ f({
2101
+ content: {
2102
+ ...l,
2103
+ valueSourceCode: c,
2104
+ value: C?.value || "",
2105
+ unit: g
2106
+ }
2107
+ });
2108
+ }, 0);
2109
+ }, h = () => {
2110
+ f({
2111
+ content: {
2112
+ ...l,
2113
+ label: s.label,
2114
+ value: s.value,
2115
+ valueSourceCode: s.valueSourceCode,
2116
+ unit: s.unit,
2117
+ decimals: s.decimals,
2118
+ labelStyle: {
2119
+ fontSize: s.labelFontSize,
2120
+ fontWeight: s.labelFontWeight,
2121
+ color: s.labelColor
2122
+ },
2123
+ valueStyle: {
2124
+ fontSize: s.valueFontSize,
2125
+ fontWeight: s.valueFontWeight,
2126
+ color: s.valueColor
2127
+ }
2128
+ }
2129
+ });
2130
+ }, w = r.filter(
2131
+ (c) => t.includes(c.paramsCode)
2132
+ );
2133
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
2134
+ /* @__PURE__ */ e(xe, { style: { marginTop: 0 }, children: "文本内容" }),
2135
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2136
+ /* @__PURE__ */ e(N.Item, { label: "标签文本 (label)", children: /* @__PURE__ */ e(
2137
+ oe,
2138
+ {
2139
+ value: s.label,
2140
+ onChange: (c) => p("label", c.target.value),
2141
+ onBlur: h,
2142
+ placeholder: "输入标签文本"
2143
+ }
2144
+ ) }),
2145
+ /* @__PURE__ */ e(
2146
+ N.Item,
2147
+ {
2148
+ label: "值来源",
2149
+ help: "从绑定的数据中选择字段,优先级高于手动输入的值",
2150
+ children: /* @__PURE__ */ e(
2151
+ be,
2152
+ {
2153
+ value: s.valueSourceCode || void 0,
2154
+ onChange: b,
2155
+ placeholder: "选择数据字段(可选)",
2156
+ allowClear: !0,
2157
+ style: { width: "100%" },
2158
+ fieldNames: {
2159
+ value: "paramsCode",
2160
+ label: "paramsName"
2161
+ },
2162
+ options: w
2163
+ }
2164
+ )
2165
+ }
2166
+ ),
2167
+ /* @__PURE__ */ e(
2168
+ N.Item,
2169
+ {
2170
+ label: s.valueSourceCode ? "默认值(备用)" : "值文本",
2171
+ help: s.valueSourceCode ? "已绑定数据源,实际值将来自数据字段,此处仅设置无数据时的备用显示" : "手动输入显示的值",
2172
+ children: /* @__PURE__ */ e(
2173
+ oe,
2174
+ {
2175
+ value: s.value,
2176
+ onChange: (c) => p("value", c.target.value),
2177
+ onBlur: h,
2178
+ placeholder: s.valueSourceCode ? "数据字段无值时显示此备用值" : "输入值文本",
2179
+ disabled: !!s.valueSourceCode,
2180
+ variant: s.valueSourceCode ? "filled" : void 0
2181
+ }
2182
+ )
2183
+ }
2184
+ ),
2185
+ /* @__PURE__ */ e(N.Item, { label: "单位", help: "优先从绑定数据自动获取,也可手动输入", children: /* @__PURE__ */ e(
2186
+ oe,
2187
+ {
2188
+ value: s.unit,
2189
+ onChange: (c) => p("unit", c.target.value),
2190
+ onBlur: h,
2191
+ placeholder: "单位(如°C、%、MPa等)",
2192
+ suffix: s.valueSourceCode && w.length > 0 ? /* @__PURE__ */ e(ie, { color: "blue", style: { marginRight: -8 }, children: "自动" }) : null
2193
+ }
2194
+ ) }),
2195
+ /* @__PURE__ */ e(
2196
+ N.Item,
2197
+ {
2198
+ label: "保留小数位",
2199
+ help: "数值格式化时保留的小数位数,-1表示不格式化",
2200
+ children: /* @__PURE__ */ e(
2201
+ V,
2202
+ {
2203
+ value: s.decimals,
2204
+ onChange: (c) => p("decimals", c ?? 2),
2205
+ onBlur: h,
2206
+ min: -1,
2207
+ max: 10,
2208
+ style: { width: "100%" }
2209
+ }
2210
+ )
2211
+ }
2212
+ )
2213
+ ] }),
2214
+ /* @__PURE__ */ e(xe, { children: "标签样式" }),
2215
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2216
+ /* @__PURE__ */ i(me, { children: [
2217
+ /* @__PURE__ */ e(N.Item, { label: "字体大小", children: /* @__PURE__ */ e(
2218
+ V,
2219
+ {
2220
+ value: s.labelFontSize,
2221
+ onChange: (c) => p("labelFontSize", c || 14),
2222
+ onBlur: h,
2223
+ min: 8,
2224
+ max: 72
2225
+ }
2226
+ ) }),
2227
+ /* @__PURE__ */ e(N.Item, { label: "字体粗细", children: /* @__PURE__ */ i(
2228
+ be,
2229
+ {
2230
+ value: s.labelFontWeight,
2231
+ onChange: (c) => {
2232
+ p("labelFontWeight", c), setTimeout(h, 0);
2233
+ },
2234
+ style: { width: 100 },
2235
+ children: [
2236
+ /* @__PURE__ */ e(We, { value: "normal", children: "正常" }),
2237
+ /* @__PURE__ */ e(We, { value: "bold", children: "粗体" })
2238
+ ]
2239
+ }
2240
+ ) })
2241
+ ] }),
2242
+ /* @__PURE__ */ e(N.Item, { label: "文字颜色", children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2243
+ /* @__PURE__ */ e(
2244
+ rt,
2245
+ {
2246
+ value: s.labelColor,
2247
+ onChange: (c) => p("labelColor", c.toHexString()),
2248
+ onChangeComplete: () => h()
2249
+ }
2250
+ ),
2251
+ /* @__PURE__ */ e(
2252
+ oe,
2253
+ {
2254
+ value: s.labelColor,
2255
+ onChange: (c) => p("labelColor", c.target.value),
2256
+ onBlur: h,
2257
+ placeholder: "#262626",
2258
+ style: { width: 100 }
2259
+ }
2260
+ )
2261
+ ] }) })
2262
+ ] }),
2263
+ /* @__PURE__ */ e(xe, { children: "值样式" }),
2264
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2265
+ /* @__PURE__ */ i(me, { children: [
2266
+ /* @__PURE__ */ e(N.Item, { label: "字体大小", children: /* @__PURE__ */ e(
2267
+ V,
2268
+ {
2269
+ value: s.valueFontSize,
2270
+ onChange: (c) => p("valueFontSize", c || 14),
2271
+ onBlur: h,
2272
+ min: 8,
2273
+ max: 72
2274
+ }
2275
+ ) }),
2276
+ /* @__PURE__ */ e(N.Item, { label: "字体粗细", children: /* @__PURE__ */ i(
2277
+ be,
2278
+ {
2279
+ value: s.valueFontWeight,
2280
+ onChange: (c) => {
2281
+ p("valueFontWeight", c), setTimeout(h, 0);
2282
+ },
2283
+ style: { width: 100 },
2284
+ children: [
2285
+ /* @__PURE__ */ e(We, { value: "normal", children: "正常" }),
2286
+ /* @__PURE__ */ e(We, { value: "bold", children: "粗体" })
2287
+ ]
2288
+ }
2289
+ ) })
2290
+ ] }),
2291
+ /* @__PURE__ */ e(N.Item, { label: "文字颜色", children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2292
+ /* @__PURE__ */ e(
2293
+ rt,
2294
+ {
2295
+ value: s.valueColor,
2296
+ onChange: (c) => p("valueColor", c.toHexString()),
2297
+ onChangeComplete: () => h()
2298
+ }
2299
+ ),
2300
+ /* @__PURE__ */ e(
2301
+ oe,
2302
+ {
2303
+ value: s.valueColor,
2304
+ onChange: (c) => p("valueColor", c.target.value),
2305
+ onBlur: h,
2306
+ placeholder: "#1890ff",
2307
+ style: { width: 100 }
2308
+ }
2309
+ )
2310
+ ] }) })
2311
+ ] })
2312
+ ] });
2313
+ }, Wn = ({
2314
+ material: n,
2315
+ onSave: f
2316
+ }) => {
2317
+ const [t, r] = W({
2318
+ name: n.name,
2319
+ src: n.src || ""
2320
+ });
2321
+ ae(() => {
2322
+ r({
2323
+ name: n.name,
2324
+ src: n.src || ""
2325
+ });
2326
+ }, [n.id]);
2327
+ const o = (s, a) => {
2328
+ r((p) => ({ ...p, [s]: a }));
2329
+ }, l = () => {
2330
+ f({
2331
+ name: t.name,
2332
+ src: t.src
2333
+ });
2334
+ };
2335
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
2336
+ /* @__PURE__ */ e(xe, { style: { marginTop: 0 }, children: "图片属性" }),
2337
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2338
+ /* @__PURE__ */ e(N.Item, { label: "图片名称", children: /* @__PURE__ */ e(
2339
+ oe,
2340
+ {
2341
+ value: t.name,
2342
+ onChange: (s) => o("name", s.target.value),
2343
+ onBlur: l
2344
+ }
2345
+ ) }),
2346
+ /* @__PURE__ */ e(N.Item, { label: "图片地址 (src)", children: /* @__PURE__ */ e(
2347
+ st,
2348
+ {
2349
+ value: t.src,
2350
+ onChange: (s) => o("src", s.target.value),
2351
+ onBlur: l,
2352
+ rows: 4,
2353
+ placeholder: "输入图片 URL 或 Data URI"
2354
+ }
2355
+ ) })
2356
+ ] })
2357
+ ] });
2358
+ }, Un = ({
2359
+ material: n,
2360
+ onSave: f
2361
+ }) => {
2362
+ const t = n.config || {}, [r, o] = W({
2363
+ lineWeight: t.lineWeight || t.thickness || 2,
2364
+ color: t.color || "#262626",
2365
+ lineType: t.lineType || "solid",
2366
+ startX: t.startX ?? 0,
2367
+ startY: t.startY ?? 0,
2368
+ endX: t.endX ?? 100,
2369
+ endY: t.endY ?? 0
2370
+ });
2371
+ ae(() => {
2372
+ o({
2373
+ lineWeight: t.lineWeight || t.thickness || 2,
2374
+ color: t.color || "#262626",
2375
+ lineType: t.lineType || "solid",
2376
+ startX: t.startX ?? 0,
2377
+ startY: t.startY ?? 0,
2378
+ endX: t.endX ?? 100,
2379
+ endY: t.endY ?? 0
2380
+ });
2381
+ }, [n.id]);
2382
+ const l = (a) => {
2383
+ const p = { ...r, ...a };
2384
+ o(p), f({
2385
+ config: {
2386
+ ...t,
2387
+ thickness: p.lineWeight,
2388
+ lineWeight: p.lineWeight,
2389
+ color: p.color,
2390
+ lineType: p.lineType,
2391
+ startX: p.startX,
2392
+ startY: p.startY,
2393
+ endX: p.endX,
2394
+ endY: p.endY
2395
+ }
2396
+ });
2397
+ }, s = [
2398
+ { value: "solid", label: "实线", desc: "连续实线" },
2399
+ { value: "dashed", label: "虚线", desc: "长划间隔" },
2400
+ { value: "center", label: "点画线(中心线)", desc: "长点-短点交替" },
2401
+ { value: "phantom", label: "假想线", desc: "长划-双点交替" },
2402
+ { value: "dot", label: "点线", desc: "密集点状" },
2403
+ { value: "dash-dot", label: "画点线", desc: "长划-点交替" }
2404
+ ];
2405
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
2406
+ /* @__PURE__ */ e(xe, { style: { marginTop: 0 }, children: "线条属性" }),
2407
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2408
+ /* @__PURE__ */ e(N.Item, { label: "线型", help: "选择线条样式", children: /* @__PURE__ */ e(
2409
+ be,
2410
+ {
2411
+ value: r.lineType,
2412
+ onChange: (a) => l({ lineType: a }),
2413
+ children: s.map((a) => /* @__PURE__ */ e(We, { value: a.value, children: /* @__PURE__ */ i("div", { className: "flex flex-col", children: [
2414
+ /* @__PURE__ */ e("span", { children: a.label }),
2415
+ /* @__PURE__ */ e("span", { className: "text-xs text-gray-400", children: a.desc })
2416
+ ] }) }, a.value))
2417
+ }
2418
+ ) }),
2419
+ /* @__PURE__ */ e(N.Item, { label: "线宽(像素)", children: /* @__PURE__ */ e(
2420
+ V,
2421
+ {
2422
+ value: r.lineWeight,
2423
+ onChange: (a) => l({ lineWeight: a || 2 }),
2424
+ min: 1,
2425
+ max: 20,
2426
+ style: { width: 120 }
2427
+ }
2428
+ ) }),
2429
+ /* @__PURE__ */ e(N.Item, { label: "颜色", children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2430
+ /* @__PURE__ */ e(
2431
+ rt,
2432
+ {
2433
+ value: r.color,
2434
+ onChange: (a) => l({ color: a.toHexString() })
2435
+ }
2436
+ ),
2437
+ /* @__PURE__ */ e(
2438
+ oe,
2439
+ {
2440
+ value: r.color,
2441
+ onChange: (a) => l({ color: a.target.value }),
2442
+ placeholder: "#d9d9d9",
2443
+ style: { width: 100 }
2444
+ }
2445
+ )
2446
+ ] }) })
2447
+ ] }),
2448
+ /* @__PURE__ */ e(xe, { children: "起止位置(相对节点)" }),
2449
+ /* @__PURE__ */ i(N, { layout: "vertical", children: [
2450
+ /* @__PURE__ */ i("div", { className: "grid grid-cols-2 gap-2", children: [
2451
+ /* @__PURE__ */ e(N.Item, { label: "起点 X", className: "mb-2", children: /* @__PURE__ */ e(
2452
+ V,
2453
+ {
2454
+ value: r.startX,
2455
+ onChange: (a) => l({ startX: a ?? 0 }),
2456
+ style: { width: "100%" }
2457
+ }
2458
+ ) }),
2459
+ /* @__PURE__ */ e(N.Item, { label: "起点 Y", className: "mb-2", children: /* @__PURE__ */ e(
2460
+ V,
2461
+ {
2462
+ value: r.startY,
2463
+ onChange: (a) => l({ startY: a ?? 0 }),
2464
+ style: { width: "100%" }
2465
+ }
2466
+ ) }),
2467
+ /* @__PURE__ */ e(N.Item, { label: "终点 X", className: "mb-2", children: /* @__PURE__ */ e(
2468
+ V,
2469
+ {
2470
+ value: r.endX,
2471
+ onChange: (a) => l({ endX: a ?? 100 }),
2472
+ style: { width: "100%" }
2473
+ }
2474
+ ) }),
2475
+ /* @__PURE__ */ e(N.Item, { label: "终点 Y", className: "mb-2", children: /* @__PURE__ */ e(
2476
+ V,
2477
+ {
2478
+ value: r.endY,
2479
+ onChange: (a) => l({ endY: a ?? 0 }),
2480
+ style: { width: "100%" }
2481
+ }
2482
+ ) })
2483
+ ] }),
2484
+ /* @__PURE__ */ e(N.Item, { label: "快速对齐", className: "mt-4", children: /* @__PURE__ */ i(me, { children: [
2485
+ /* @__PURE__ */ e(
2486
+ A,
2487
+ {
2488
+ size: "small",
2489
+ onClick: () => {
2490
+ l({ endY: r.startY });
2491
+ },
2492
+ title: "将线条变为水平线",
2493
+ children: "水平"
2494
+ }
2495
+ ),
2496
+ /* @__PURE__ */ e(
2497
+ A,
2498
+ {
2499
+ size: "small",
2500
+ onClick: () => {
2501
+ l({ endX: r.startX });
2502
+ },
2503
+ title: "将线条变为垂直线",
2504
+ children: "垂直"
2505
+ }
2506
+ ),
2507
+ /* @__PURE__ */ e(
2508
+ A,
2509
+ {
2510
+ size: "small",
2511
+ onClick: () => {
2512
+ l({
2513
+ startX: r.endX,
2514
+ startY: r.endY,
2515
+ endX: r.startX,
2516
+ endY: r.startY
2517
+ });
2518
+ },
2519
+ title: "交换起点和终点",
2520
+ children: "反向"
2521
+ }
2522
+ )
2523
+ ] }) })
2524
+ ] })
2525
+ ] });
2526
+ }, Bn = ({
2527
+ node: n,
2528
+ updateNode: f,
2529
+ materials: t
2530
+ }) => {
2531
+ const r = t.filter((h) => h.type !== "CUSTOM" || !h.config?.nodes), o = (h, w) => {
2532
+ const c = n.children?.map((C) => C.id === h ? {
2533
+ ...C,
2534
+ contentInfo: {
2535
+ ...C.contentInfo,
2536
+ statusList: w
2537
+ }
2538
+ } : C);
2539
+ f(n.id, {
2540
+ children: c
2541
+ });
2542
+ }, l = (h) => {
2543
+ const w = n.children?.find((C) => C.id === h);
2544
+ if (!w) return;
2545
+ const c = {
2546
+ id: O(),
2547
+ name: `状态${w.contentInfo.statusList.length + 1}`,
2548
+ expression: w.contentInfo.statusList.length === 0 ? "return true;" : "return false;",
2549
+ material: { ...r[0], id: O() },
2550
+ bindCodes: []
2551
+ };
2552
+ o(h, [...w.contentInfo.statusList, c]);
2553
+ }, s = (h, w) => {
2554
+ const c = n.children?.find((g) => g.id === h);
2555
+ if (!c) return;
2556
+ const C = c.contentInfo.statusList.filter((g) => g.id !== w);
2557
+ o(h, C);
2558
+ }, a = (h, w, c) => {
2559
+ const C = n.children?.find((D) => D.id === h);
2560
+ if (!C) return;
2561
+ const g = C.contentInfo.statusList.map((D) => D.id === w ? { ...D, ...c } : D);
2562
+ o(h, g);
2563
+ }, p = (h, w, c) => {
2564
+ const C = n.children?.find((m) => m.id === h);
2565
+ if (!C) return;
2566
+ const g = C.contentInfo.statusList.findIndex((m) => m.id === w);
2567
+ if (g === -1) return;
2568
+ const D = [...C.contentInfo.statusList];
2569
+ c === "up" && g > 0 ? [D[g], D[g - 1]] = [D[g - 1], D[g]] : c === "down" && g < D.length - 1 && ([D[g], D[g + 1]] = [D[g + 1], D[g]]), o(h, D);
2570
+ }, b = (h, w, c) => {
2571
+ const C = t.find((g) => g.id === c);
2572
+ C && a(h, w, {
2573
+ material: { ...C, id: O() }
2574
+ });
2575
+ };
2576
+ return /* @__PURE__ */ i("div", { className: "space-y-4", children: [
2577
+ /* @__PURE__ */ e("div", { className: "p-3 bg-blue-50 border border-blue-200 rounded-lg mb-4", children: /* @__PURE__ */ i("div", { className: "text-sm text-blue-700", children: [
2578
+ /* @__PURE__ */ e("strong", { children: "群组节点" }),
2579
+ ":为每个子节点配置多个状态和绑定"
2580
+ ] }) }),
2581
+ /* @__PURE__ */ e(ge, { ghost: !0, children: n.children?.map((h, w) => /* @__PURE__ */ e(
2582
+ fe,
2583
+ {
2584
+ header: /* @__PURE__ */ i("div", { className: "flex items-center justify-between w-full pr-4", children: [
2585
+ /* @__PURE__ */ i("span", { className: "font-medium text-sm", children: [
2586
+ "子节点 ",
2587
+ w + 1
2588
+ ] }),
2589
+ /* @__PURE__ */ i(ie, { color: "blue", style: { fontSize: "12px", padding: "0 4px" }, children: [
2590
+ h.contentInfo.statusList.length,
2591
+ " 个状态"
2592
+ ] })
2593
+ ] }),
2594
+ children: /* @__PURE__ */ i("div", { className: "space-y-3", children: [
2595
+ /* @__PURE__ */ i("div", { className: "flex justify-between items-center mb-3", children: [
2596
+ /* @__PURE__ */ e("span", { className: "text-sm text-gray-600", children: "状态列表" }),
2597
+ /* @__PURE__ */ e(
2598
+ A,
2599
+ {
2600
+ type: "primary",
2601
+ size: "small",
2602
+ icon: /* @__PURE__ */ e(Dt, {}),
2603
+ onClick: () => l(h.id),
2604
+ children: "添加状态"
2605
+ }
2606
+ )
2607
+ ] }),
2608
+ h.contentInfo.statusList.length === 0 ? /* @__PURE__ */ e("div", { className: "text-center text-gray-400 py-4 bg-gray-50 rounded-lg", children: "暂无状态,点击上方按钮添加" }) : /* @__PURE__ */ e(ge, { ghost: !0, children: h.contentInfo.statusList.map((c, C) => /* @__PURE__ */ e(
2609
+ fe,
2610
+ {
2611
+ header: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2612
+ /* @__PURE__ */ e("span", { className: "text-xs text-gray-400 w-5", children: C + 1 }),
2613
+ /* @__PURE__ */ e("span", { className: "font-medium", children: c.name }),
2614
+ /* @__PURE__ */ e(ie, { color: "default", className: "text-xs", children: c.material.type })
2615
+ ] }),
2616
+ extra: /* @__PURE__ */ i(me, { size: "small", onClick: (g) => g.stopPropagation(), children: [
2617
+ /* @__PURE__ */ e(
2618
+ A,
2619
+ {
2620
+ type: "text",
2621
+ size: "small",
2622
+ icon: /* @__PURE__ */ e(kt, {}),
2623
+ disabled: C === 0,
2624
+ onClick: (g) => {
2625
+ g.stopPropagation(), p(h.id, c.id, "up");
2626
+ }
2627
+ }
2628
+ ),
2629
+ /* @__PURE__ */ e(
2630
+ A,
2631
+ {
2632
+ type: "text",
2633
+ size: "small",
2634
+ icon: /* @__PURE__ */ e(Et, {}),
2635
+ disabled: C === h.contentInfo.statusList.length - 1,
2636
+ onClick: (g) => {
2637
+ g.stopPropagation(), p(h.id, c.id, "down");
2638
+ }
2639
+ }
2640
+ ),
2641
+ /* @__PURE__ */ e(
2642
+ A,
2643
+ {
2644
+ type: "text",
2645
+ size: "small",
2646
+ danger: !0,
2647
+ icon: /* @__PURE__ */ e(Ke, {}),
2648
+ onClick: (g) => {
2649
+ g.stopPropagation(), s(h.id, c.id);
2650
+ }
2651
+ }
2652
+ )
2653
+ ] }),
2654
+ children: /* @__PURE__ */ i(N, { layout: "vertical", children: [
2655
+ /* @__PURE__ */ e(N.Item, { label: "状态名称", children: /* @__PURE__ */ e(
2656
+ oe,
2657
+ {
2658
+ value: c.name,
2659
+ onChange: (g) => a(h.id, c.id, { name: g.target.value }),
2660
+ placeholder: "输入状态名称"
2661
+ }
2662
+ ) }),
2663
+ /* @__PURE__ */ e(
2664
+ N.Item,
2665
+ {
2666
+ label: "执行表达式",
2667
+ help: "返回 true 时激活此状态,可使用 data 变量访问绑定数据",
2668
+ children: /* @__PURE__ */ e(
2669
+ st,
2670
+ {
2671
+ value: c.expression,
2672
+ onChange: (g) => a(h.id, c.id, { expression: g.target.value }),
2673
+ rows: 3,
2674
+ placeholder: "return true;"
2675
+ }
2676
+ )
2677
+ }
2678
+ ),
2679
+ /* @__PURE__ */ e(N.Item, { label: "绑定数据源 (bindCodes)", children: /* @__PURE__ */ e(
2680
+ be,
2681
+ {
2682
+ mode: "tags",
2683
+ value: c.bindCodes || [],
2684
+ onChange: (g) => a(h.id, c.id, { bindCodes: g }),
2685
+ placeholder: "输入数据源 code",
2686
+ tokenSeparators: [",", " "]
2687
+ }
2688
+ ) }),
2689
+ /* @__PURE__ */ e(N.Item, { label: "更换物料", children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2690
+ /* @__PURE__ */ e(ie, { color: "blue", children: c.material.name }),
2691
+ /* @__PURE__ */ e(ie, { color: "default", children: c.material.type }),
2692
+ /* @__PURE__ */ e(
2693
+ be,
2694
+ {
2695
+ placeholder: "选择新物料",
2696
+ style: { width: 150 },
2697
+ value: void 0,
2698
+ onChange: (g) => g && b(h.id, c.id, g),
2699
+ options: r.map((g) => ({
2700
+ value: g.id,
2701
+ label: `${g.name} (${g.type})`
2702
+ }))
2703
+ }
2704
+ )
2705
+ ] }) }),
2706
+ /* @__PURE__ */ e(xe, { style: { margin: "12px 0" } }),
2707
+ /* @__PURE__ */ i("div", { className: "bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
2708
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-2", children: [
2709
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: "物料属性" }),
2710
+ /* @__PURE__ */ e(ie, { children: c.material.name })
2711
+ ] }),
2712
+ /* @__PURE__ */ e(
2713
+ _t,
2714
+ {
2715
+ material: c.material,
2716
+ onSave: (g) => {
2717
+ const D = { ...c.material, ...g };
2718
+ a(h.id, c.id, { material: D });
2719
+ }
2720
+ }
2721
+ )
2722
+ ] })
2723
+ ] })
2724
+ },
2725
+ c.id
2726
+ )) })
2727
+ ] })
2728
+ },
2729
+ h.id
2730
+ )) })
2731
+ ] });
2732
+ }, _t = ({
2733
+ material: n,
2734
+ onSave: f,
2735
+ bindCodes: t,
2736
+ dataOptions: r
2737
+ }) => {
2738
+ switch (n.type) {
2739
+ case "TEXT":
2740
+ return /* @__PURE__ */ e(
2741
+ Fn,
2742
+ {
2743
+ material: n,
2744
+ onSave: f,
2745
+ bindCodes: t,
2746
+ dataOptions: r
2747
+ }
2748
+ );
2749
+ case "IMAGE":
2750
+ return /* @__PURE__ */ e(Wn, { material: n, onSave: f });
2751
+ case "LINE":
2752
+ return /* @__PURE__ */ e(Un, { material: n, onSave: f });
2753
+ default:
2754
+ return /* @__PURE__ */ e("div", { className: "text-center text-gray-400 py-8", children: "暂不支持编辑此类型的物料" });
2755
+ }
2756
+ }, qn = ({
2757
+ defaultTestData: n
2758
+ }) => {
2759
+ const {
2760
+ nodes: f,
2761
+ selectedNodeId: t,
2762
+ updateNode: r,
2763
+ updateNodeStyle: o,
2764
+ updateNodeControl: l,
2765
+ updateNodeContent: s,
2766
+ materials: a,
2767
+ // 物料库,用于创建状态时选择物料
2768
+ addStatus: p,
2769
+ removeStatus: b,
2770
+ updateStatus: h,
2771
+ selectedStatusId: w,
2772
+ selectStatus: c
2773
+ } = Qe(), [C] = N.useForm(), [g, D] = W("basic"), [m, T] = W(!1), [Y, U] = W(null), [R, _] = W({}), L = pe.useMemo(() => f.find((d) => d.id === t), [f, t]), X = L?.contentInfo.statusList || [];
2774
+ pe.useMemo(() => !L || !w ? null : L.contentInfo.statusList.find(
2775
+ (d) => d.id === w
2776
+ ) || null, [L, w]);
2777
+ const K = (d, v) => {
2778
+ t && (d.normalStyle && o(t, d.normalStyle), d.name !== void 0 && r(t, { name: d.name }), d.controlInfo && l(t, d.controlInfo));
2779
+ };
2780
+ ae(() => {
2781
+ L && (C.setFieldsValue({
2782
+ name: L.name,
2783
+ normalStyle: {
2784
+ width: 100,
2785
+ height: 100,
2786
+ x: 0,
2787
+ y: 0,
2788
+ padding: 8,
2789
+ background: "transparent",
2790
+ borderRadius: 0,
2791
+ opacity: 1,
2792
+ ...L.normalStyle
2793
+ },
2794
+ controlInfo: {
2795
+ isDraggable: !0,
2796
+ isClickable: !0,
2797
+ isResizable: !0,
2798
+ isSelectable: !0,
2799
+ ...L.controlInfo
2800
+ }
2801
+ }), c(null));
2802
+ }, [L?.id, C, c]);
2803
+ const z = () => {
2804
+ !t || !L || (U("new"), T(!0));
2805
+ }, k = (d) => {
2806
+ if (!t || !L) return;
2807
+ const v = {
2808
+ id: O(),
2809
+ name: `${d.name}_状态${X.length + 1}`,
2810
+ expression: X.length === 0 ? "return true;" : "return false;",
2811
+ material: { ...d, id: O() },
2812
+ // 复制物料并生成新ID
2813
+ bindCodes: []
2814
+ };
2815
+ if (Y === "new") {
2816
+ const I = [...X, v];
2817
+ s(t, {
2818
+ statusList: I
2819
+ });
2820
+ } else if (Y) {
2821
+ const I = X.map((M) => M.id === Y ? { ...M, material: { ...d, id: O() } } : M);
2822
+ s(t, { statusList: I });
2823
+ }
2824
+ T(!1), U(null);
2825
+ }, Z = (d) => {
2826
+ if (!t || !L) return;
2827
+ const v = L.contentInfo.statusList?.filter((I) => I.id !== d) || [];
2828
+ s(t, { statusList: v }), w === d && c(null);
2829
+ }, B = (d, v) => {
2830
+ if (!t || !L) return;
2831
+ const I = L.contentInfo.statusList?.map((M) => M.id === d ? { ...M, ...v } : M) || [];
2832
+ s(t, { statusList: I });
2833
+ }, Q = (d) => {
2834
+ if (!t || !L) return;
2835
+ const v = {
2836
+ ...d,
2837
+ id: O(),
2838
+ name: `${d.name}_复制`,
2839
+ expression: "return false;"
2840
+ }, I = [...X, v];
2841
+ s(t, { statusList: I });
2842
+ }, x = (d, v) => {
2843
+ if (!t || !L) return;
2844
+ const I = X.findIndex((ne) => ne.id === d);
2845
+ if (I === -1) return;
2846
+ const M = [...X];
2847
+ v === "up" && I > 0 ? [M[I], M[I - 1]] = [
2848
+ M[I - 1],
2849
+ M[I]
2850
+ ] : v === "down" && I < M.length - 1 && ([M[I], M[I + 1]] = [
2851
+ M[I + 1],
2852
+ M[I]
2853
+ ]), s(t, { statusList: M });
2854
+ }, J = (d) => {
2855
+ U(d), T(!0);
2856
+ }, j = (d, v) => {
2857
+ if (!t || !L) return;
2858
+ const I = X.map((M) => M.id === d ? {
2859
+ ...M,
2860
+ material: { ...M.material, ...v }
2861
+ } : M);
2862
+ s(t, {
2863
+ statusList: I
2864
+ });
2865
+ };
2866
+ return L ? /* @__PURE__ */ i("div", { className: "h-full flex flex-col bg-white border-l border-gray-200", children: [
2867
+ /* @__PURE__ */ i("div", { className: "p-4 border-b border-gray-200", children: [
2868
+ /* @__PURE__ */ e("h3", { className: "text-lg font-semibold text-gray-800", children: "属性面板" }),
2869
+ /* @__PURE__ */ e("p", { className: "text-sm text-gray-500", children: "编辑选中节点的属性" })
2870
+ ] }),
2871
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ i(Ct, { activeKey: g, onChange: D, children: [
2872
+ /* @__PURE__ */ e(lt, { tab: "基础", children: /* @__PURE__ */ i(
2873
+ N,
2874
+ {
2875
+ form: C,
2876
+ layout: "vertical",
2877
+ onValuesChange: K,
2878
+ initialValues: {
2879
+ name: L.name
2880
+ },
2881
+ children: [
2882
+ /* @__PURE__ */ e(N.Item, { label: "节点名称", name: "name", children: /* @__PURE__ */ e(oe, { placeholder: "输入节点名称" }) }),
2883
+ /* @__PURE__ */ i(ge, { ghost: !0, defaultActiveKey: ["position", "size", "style"], children: [
2884
+ /* @__PURE__ */ e(fe, { header: "位置", children: /* @__PURE__ */ i(me, { children: [
2885
+ /* @__PURE__ */ e(N.Item, { label: "X", name: ["normalStyle", "x"], children: /* @__PURE__ */ e(V, {}) }),
2886
+ /* @__PURE__ */ e(N.Item, { label: "Y", name: ["normalStyle", "y"], children: /* @__PURE__ */ e(V, {}) })
2887
+ ] }) }, "position"),
2888
+ /* @__PURE__ */ e(fe, { header: "尺寸", children: /* @__PURE__ */ i(me, { children: [
2889
+ /* @__PURE__ */ e(N.Item, { label: "宽度", name: ["normalStyle", "width"], children: /* @__PURE__ */ e(V, { min: 10 }) }),
2890
+ /* @__PURE__ */ e(N.Item, { label: "高度", name: ["normalStyle", "height"], children: /* @__PURE__ */ e(V, { min: 10 }) })
2891
+ ] }) }, "size"),
2892
+ /* @__PURE__ */ i(fe, { header: "样式", children: [
2893
+ /* @__PURE__ */ e(
2894
+ N.Item,
2895
+ {
2896
+ label: "背景色",
2897
+ name: ["normalStyle", "background"],
2898
+ children: /* @__PURE__ */ e(oe, { placeholder: "transparent, #fff, url(...)" })
2899
+ }
2900
+ ),
2901
+ /* @__PURE__ */ e(N.Item, { label: "内边距", name: ["normalStyle", "padding"], children: /* @__PURE__ */ e(V, { min: 0 }) }),
2902
+ /* @__PURE__ */ e(
2903
+ N.Item,
2904
+ {
2905
+ label: "圆角",
2906
+ name: ["normalStyle", "borderRadius"],
2907
+ children: /* @__PURE__ */ e(V, { min: 0 })
2908
+ }
2909
+ ),
2910
+ /* @__PURE__ */ e(
2911
+ N.Item,
2912
+ {
2913
+ label: "缩放比例",
2914
+ name: ["normalStyle", "scale"],
2915
+ help: "等比缩放节点的宽高",
2916
+ children: /* @__PURE__ */ e(V, { min: 0.1, max: 5, step: 0.1 })
2917
+ }
2918
+ ),
2919
+ /* @__PURE__ */ e(N.Item, { label: "透明度", name: ["normalStyle", "opacity"], children: /* @__PURE__ */ e(V, { min: 0, max: 1, step: 0.1 }) }),
2920
+ /* @__PURE__ */ e(N.Item, { label: "层级", name: ["normalStyle", "zIndex"], children: /* @__PURE__ */ e(V, {}) })
2921
+ ] }, "style")
2922
+ ] })
2923
+ ]
2924
+ }
2925
+ ) }, "basic"),
2926
+ /* @__PURE__ */ e(lt, { tab: "状态", children: L.type === "group" && L.children ? /* @__PURE__ */ e(
2927
+ Bn,
2928
+ {
2929
+ node: L,
2930
+ updateNode: r,
2931
+ materials: a
2932
+ }
2933
+ ) : /* @__PURE__ */ i("div", { className: "mb-4", children: [
2934
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-2", children: [
2935
+ /* @__PURE__ */ i("span", { className: "font-medium", children: [
2936
+ "状态列表",
2937
+ /* @__PURE__ */ e(ie, { color: "blue", className: "ml-2", children: X.length })
2938
+ ] }),
2939
+ /* @__PURE__ */ e(
2940
+ A,
2941
+ {
2942
+ type: "primary",
2943
+ size: "small",
2944
+ icon: /* @__PURE__ */ e(Dt, {}),
2945
+ onClick: z,
2946
+ children: "添加状态"
2947
+ }
2948
+ )
2949
+ ] }),
2950
+ /* @__PURE__ */ e("p", { className: "text-xs text-gray-500 mb-3", children: "节点根据状态表达式计算结果显示对应物料,第一个返回 true 的状态为当前状态" }),
2951
+ X.length > 0 && /* @__PURE__ */ i("div", { className: "mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg", children: [
2952
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ i("div", { children: [
2953
+ /* @__PURE__ */ e("span", { className: "text-sm text-gray-600", children: "当前状态:" }),
2954
+ /* @__PURE__ */ e("span", { className: "ml-2 text-sm font-medium text-blue-600", children: "由表达式自动计算" }),
2955
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-gray-400", children: "(返回 true 的第一个状态)" })
2956
+ ] }) }),
2957
+ /* @__PURE__ */ e("div", { className: "mt-2 text-xs text-gray-500", children: '提示: 使用画布工具栏的"数据模拟"按钮可以测试状态表达式' })
2958
+ ] }),
2959
+ X.length === 0 ? /* @__PURE__ */ e("div", { className: "text-center text-gray-400 py-4 bg-gray-50 rounded-lg", children: "暂无状态,点击上方按钮添加" }) : /* @__PURE__ */ e(ge, { ghost: !0, children: X.map((d, v) => /* @__PURE__ */ e(
2960
+ fe,
2961
+ {
2962
+ header: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
2963
+ /* @__PURE__ */ e("span", { className: "text-xs text-gray-400 w-5", children: v + 1 }),
2964
+ /* @__PURE__ */ e("span", { className: "font-medium", children: d.name }),
2965
+ /* @__PURE__ */ e(ie, { color: "default", className: "text-xs", children: d.material.type })
2966
+ ] }),
2967
+ extra: /* @__PURE__ */ i(
2968
+ me,
2969
+ {
2970
+ size: "small",
2971
+ onClick: (I) => I.stopPropagation(),
2972
+ children: [
2973
+ /* @__PURE__ */ e(
2974
+ A,
2975
+ {
2976
+ type: "text",
2977
+ size: "small",
2978
+ icon: /* @__PURE__ */ e(kt, {}),
2979
+ disabled: v === 0,
2980
+ onClick: (I) => {
2981
+ I.stopPropagation(), x(d.id, "up");
2982
+ }
2983
+ }
2984
+ ),
2985
+ /* @__PURE__ */ e(
2986
+ A,
2987
+ {
2988
+ type: "text",
2989
+ size: "small",
2990
+ icon: /* @__PURE__ */ e(Et, {}),
2991
+ disabled: v === X.length - 1,
2992
+ onClick: (I) => {
2993
+ I.stopPropagation(), x(d.id, "down");
2994
+ }
2995
+ }
2996
+ ),
2997
+ /* @__PURE__ */ e(
2998
+ A,
2999
+ {
3000
+ type: "text",
3001
+ size: "small",
3002
+ icon: /* @__PURE__ */ e(mn, {}),
3003
+ onClick: (I) => {
3004
+ I.stopPropagation(), Q(d);
3005
+ }
3006
+ }
3007
+ ),
3008
+ /* @__PURE__ */ e(
3009
+ A,
3010
+ {
3011
+ type: "text",
3012
+ size: "small",
3013
+ danger: !0,
3014
+ icon: /* @__PURE__ */ e(Ke, {}),
3015
+ onClick: (I) => {
3016
+ I.stopPropagation(), Z(d.id);
3017
+ }
3018
+ }
3019
+ )
3020
+ ]
3021
+ }
3022
+ ),
3023
+ children: /* @__PURE__ */ i(N, { layout: "vertical", children: [
3024
+ /* @__PURE__ */ e(N.Item, { label: "状态名称", children: /* @__PURE__ */ e(
3025
+ oe,
3026
+ {
3027
+ value: d.name,
3028
+ onChange: (I) => B(d.id, {
3029
+ name: I.target.value
3030
+ }),
3031
+ placeholder: "输入状态名称"
3032
+ }
3033
+ ) }),
3034
+ /* @__PURE__ */ e(
3035
+ N.Item,
3036
+ {
3037
+ label: "执行表达式",
3038
+ help: "返回 true 时激活此状态,可使用 data 变量访问绑定数据",
3039
+ children: /* @__PURE__ */ e(
3040
+ st,
3041
+ {
3042
+ value: R[d.id] ?? d.expression,
3043
+ onChange: (I) => _((M) => ({
3044
+ ...M,
3045
+ [d.id]: I.target.value
3046
+ })),
3047
+ onBlur: (I) => {
3048
+ B(d.id, {
3049
+ expression: I.target.value
3050
+ }), _((M) => {
3051
+ const ne = { ...M };
3052
+ return delete ne[d.id], ne;
3053
+ });
3054
+ },
3055
+ rows: 3,
3056
+ placeholder: "return true;"
3057
+ }
3058
+ )
3059
+ }
3060
+ ),
3061
+ /* @__PURE__ */ e(N.Item, { label: "绑定数据源 (bindCodes)", children: /* @__PURE__ */ e(
3062
+ be,
3063
+ {
3064
+ mode: "tags",
3065
+ value: d.bindCodes || [],
3066
+ onChange: (I) => B(d.id, {
3067
+ bindCodes: I
3068
+ }),
3069
+ placeholder: "输入数据源 code",
3070
+ tokenSeparators: [",", " "],
3071
+ fieldNames: {
3072
+ value: "paramsCode",
3073
+ label: "paramsName"
3074
+ },
3075
+ options: n
3076
+ }
3077
+ ) }),
3078
+ /* @__PURE__ */ e(N.Item, { label: "绑定物料", children: /* @__PURE__ */ i("div", { className: "flex items-center gap-2", children: [
3079
+ /* @__PURE__ */ e(ie, { color: "blue", children: d.material.name }),
3080
+ /* @__PURE__ */ e(ie, { color: "default", children: d.material.type }),
3081
+ /* @__PURE__ */ e(
3082
+ A,
3083
+ {
3084
+ type: "link",
3085
+ size: "small",
3086
+ icon: /* @__PURE__ */ e(Mt, {}),
3087
+ onClick: () => J(d.id),
3088
+ children: "更换物料"
3089
+ }
3090
+ )
3091
+ ] }) }),
3092
+ /* @__PURE__ */ e(xe, { style: { margin: "12px 0" } }),
3093
+ /* @__PURE__ */ i("div", { className: "bg-gray-50 rounded-lg p-3 border border-gray-200", children: [
3094
+ /* @__PURE__ */ i("div", { className: "flex items-center justify-between mb-2", children: [
3095
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: "物料属性" }),
3096
+ /* @__PURE__ */ e(ie, { children: d.material.name })
3097
+ ] }),
3098
+ /* @__PURE__ */ e(
3099
+ _t,
3100
+ {
3101
+ material: d.material,
3102
+ onSave: (I) => j(d.id, I),
3103
+ bindCodes: d.bindCodes || [],
3104
+ dataOptions: n || []
3105
+ }
3106
+ )
3107
+ ] })
3108
+ ] })
3109
+ },
3110
+ d.id
3111
+ )) })
3112
+ ] }) }, "status"),
3113
+ /* @__PURE__ */ e(lt, { tab: "控制", children: /* @__PURE__ */ i(
3114
+ N,
3115
+ {
3116
+ form: C,
3117
+ layout: "vertical",
3118
+ onValuesChange: K,
3119
+ children: [
3120
+ /* @__PURE__ */ e(
3121
+ N.Item,
3122
+ {
3123
+ label: "可拖拽",
3124
+ name: ["controlInfo", "isDraggable"],
3125
+ valuePropName: "checked",
3126
+ children: /* @__PURE__ */ e(Je, {})
3127
+ }
3128
+ ),
3129
+ /* @__PURE__ */ e(
3130
+ N.Item,
3131
+ {
3132
+ label: "可点击",
3133
+ name: ["controlInfo", "isClickable"],
3134
+ valuePropName: "checked",
3135
+ children: /* @__PURE__ */ e(Je, {})
3136
+ }
3137
+ ),
3138
+ /* @__PURE__ */ e(
3139
+ N.Item,
3140
+ {
3141
+ label: "可调整大小",
3142
+ name: ["controlInfo", "isResizable"],
3143
+ valuePropName: "checked",
3144
+ children: /* @__PURE__ */ e(Je, {})
3145
+ }
3146
+ ),
3147
+ /* @__PURE__ */ e(
3148
+ N.Item,
3149
+ {
3150
+ label: "可选中",
3151
+ name: ["controlInfo", "isSelectable"],
3152
+ valuePropName: "checked",
3153
+ children: /* @__PURE__ */ e(Je, {})
3154
+ }
3155
+ )
3156
+ ]
3157
+ }
3158
+ ) }, "control")
3159
+ ] }) }),
3160
+ /* @__PURE__ */ e("div", { className: "p-3 border-t border-gray-200 bg-gray-50", children: /* @__PURE__ */ i("div", { className: "text-xs text-gray-500", children: [
3161
+ /* @__PURE__ */ i("div", { children: [
3162
+ "节点 ID: ",
3163
+ L.id.slice(0, 8),
3164
+ "..."
3165
+ ] }),
3166
+ /* @__PURE__ */ i("div", { children: [
3167
+ "状态数: ",
3168
+ X.length
3169
+ ] })
3170
+ ] }) }),
3171
+ /* @__PURE__ */ e(
3172
+ it,
3173
+ {
3174
+ title: "选择物料",
3175
+ open: m,
3176
+ onCancel: () => {
3177
+ T(!1), U(null);
3178
+ },
3179
+ footer: null,
3180
+ width: 600,
3181
+ children: /* @__PURE__ */ e("div", { className: "max-h-[400px] overflow-y-auto", children: /* @__PURE__ */ i(
3182
+ ge,
3183
+ {
3184
+ ghost: !0,
3185
+ defaultActiveKey: ["basic", "device", "text", "line"],
3186
+ children: [
3187
+ /* @__PURE__ */ e(fe, { header: "基础形状", children: /* @__PURE__ */ e("div", { className: "grid grid-cols-4 gap-2", children: a.filter((d) => ["矩形", "圆形", "圆角矩形"].includes(d.name)).map((d) => /* @__PURE__ */ i(
3188
+ "div",
3189
+ {
3190
+ className: "border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",
3191
+ onClick: () => k(d),
3192
+ children: [
3193
+ /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-1 flex items-center justify-center", children: d.src ? /* @__PURE__ */ e(
3194
+ "img",
3195
+ {
3196
+ src: d.src,
3197
+ alt: d.name,
3198
+ className: "w-10 h-10 object-contain"
3199
+ }
3200
+ ) : /* @__PURE__ */ e("span", { className: "text-xs", children: d.name[0] }) }),
3201
+ /* @__PURE__ */ e("span", { className: "text-xs", children: d.name })
3202
+ ]
3203
+ },
3204
+ d.id
3205
+ )) }) }, "basic"),
3206
+ /* @__PURE__ */ e(fe, { header: "设备图标", children: /* @__PURE__ */ e("div", { className: "grid grid-cols-4 gap-2", children: a.filter(
3207
+ (d) => ["阀门", "泵", "罐体"].includes(d.name) || d.type === "IMAGE" && !["矩形", "圆形", "圆角矩形"].includes(d.name)
3208
+ ).map((d) => /* @__PURE__ */ i(
3209
+ "div",
3210
+ {
3211
+ className: "border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",
3212
+ onClick: () => k(d),
3213
+ children: [
3214
+ /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-1 flex items-center justify-center", children: d.src ? /* @__PURE__ */ e(
3215
+ "img",
3216
+ {
3217
+ src: d.src,
3218
+ alt: d.name,
3219
+ className: "w-10 h-10 object-contain"
3220
+ }
3221
+ ) : /* @__PURE__ */ e("span", { className: "text-xs", children: d.name[0] }) }),
3222
+ /* @__PURE__ */ e("span", { className: "text-xs", children: d.name })
3223
+ ]
3224
+ },
3225
+ d.id
3226
+ )) }) }, "device"),
3227
+ /* @__PURE__ */ e(fe, { header: "文本", children: /* @__PURE__ */ e("div", { className: "grid grid-cols-4 gap-2", children: a.filter((d) => d.type === "TEXT").map((d) => /* @__PURE__ */ i(
3228
+ "div",
3229
+ {
3230
+ className: "border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",
3231
+ onClick: () => k(d),
3232
+ children: [
3233
+ /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded", children: /* @__PURE__ */ e("span", { className: "text-lg font-bold text-gray-500", children: "T" }) }),
3234
+ /* @__PURE__ */ e("span", { className: "text-xs", children: d.name })
3235
+ ]
3236
+ },
3237
+ d.id
3238
+ )) }) }, "text"),
3239
+ /* @__PURE__ */ e(fe, { header: "线条", children: /* @__PURE__ */ e("div", { className: "grid grid-cols-4 gap-2", children: a.filter((d) => d.type === "LINE").map((d) => /* @__PURE__ */ i(
3240
+ "div",
3241
+ {
3242
+ className: "border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",
3243
+ onClick: () => k(d),
3244
+ children: [
3245
+ /* @__PURE__ */ e("div", { className: "w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded", children: /* @__PURE__ */ e("div", { className: "w-8 h-0.5 bg-gray-400" }) }),
3246
+ /* @__PURE__ */ e("span", { className: "text-xs", children: d.name })
3247
+ ]
3248
+ },
3249
+ d.id
3250
+ )) }) }, "line")
3251
+ ]
3252
+ }
3253
+ ) })
3254
+ }
3255
+ )
3256
+ ] }) : /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center bg-white border-l border-gray-200", children: /* @__PURE__ */ e(te, { description: "请选择一个节点" }) });
3257
+ }, { Header: Gn, Sider: St, Content: Vn } = at, ll = ({
3258
+ initialScheme: n,
3259
+ onChange: f,
3260
+ readonly: t = !1,
3261
+ headerExtra: r,
3262
+ className: o = "",
3263
+ style: l,
3264
+ showHeader: s = !0,
3265
+ showMaterialPanel: a = !0,
3266
+ showPropertyPanel: p = !0,
3267
+ customMaterials: b
3268
+ }) => {
3269
+ const [h, w] = pe.useState(!1), [c, C] = pe.useState(""), [g, D] = pe.useState([
3270
+ {
3271
+ paramsCode: "001",
3272
+ paramsName: "通频速度有效值",
3273
+ value: 25,
3274
+ paramsUnit: "mm/s"
3275
+ },
3276
+ {
3277
+ paramsCode: "002",
3278
+ paramsName: "通频加速度有效值",
3279
+ value: 1.5,
3280
+ paramsUnit: "m/s²"
3281
+ }
3282
+ ]), { exportScheme: m, importScheme: T, nodes: Y, materials: U, addMaterial: R } = Qe();
3283
+ pe.useRef(null);
3284
+ const _ = pe.useRef(!1);
3285
+ ae(() => {
3286
+ _.current || (_.current = !0, U.length === 0 && Pn.forEach((k) => R(k)), b && b.length > 0 && b.forEach((k) => R(k)), n && T(n));
3287
+ }, []), ae(() => {
3288
+ if (f) {
3289
+ const k = m();
3290
+ f(k);
3291
+ }
3292
+ }, [Y, f]);
3293
+ const L = G(() => {
3294
+ const k = m(), Z = JSON.stringify(k, null, 2), B = "data:application/json;charset=utf-8," + encodeURIComponent(Z), Q = `scheme_${Date.now()}.json`, x = document.createElement("a");
3295
+ x.setAttribute("href", B), x.setAttribute("download", Q), x.click(), Oe.success("导出成功!");
3296
+ }, [m]), X = G(() => {
3297
+ try {
3298
+ const k = JSON.parse(c);
3299
+ T(k), w(!1), C(""), Oe.success("导入成功!");
3300
+ } catch {
3301
+ Oe.error("JSON 格式错误,请检查输入");
3302
+ }
3303
+ }, [c, T]), K = G(
3304
+ (k) => {
3305
+ const Z = new FileReader();
3306
+ return Z.onload = (B) => {
3307
+ try {
3308
+ const Q = B.target?.result, x = JSON.parse(Q);
3309
+ T(x), Oe.success("导入成功!");
3310
+ } catch {
3311
+ Oe.error("文件格式错误");
3312
+ }
3313
+ }, Z.readAsText(k), !1;
3314
+ },
3315
+ [T]
3316
+ ), z = G(() => m(), [m]);
3317
+ return pe.useImperativeHandle(
3318
+ pe.useRef?.(),
3319
+ () => ({
3320
+ getScheme: z,
3321
+ exportScheme: m,
3322
+ importScheme: T
3323
+ }),
3324
+ [z, m, T]
3325
+ ), console.log("defaultTestData", g), /* @__PURE__ */ e(Jt, { locale: Dn, children: /* @__PURE__ */ i(
3326
+ at,
3327
+ {
3328
+ className: `h-full w-full overflow-hidden ${o}`,
3329
+ style: l,
3330
+ children: [
3331
+ s && /* @__PURE__ */ i(Gn, { className: "bg-white border-b border-gray-200 px-4 flex items-center justify-between flex-shrink-0", children: [
3332
+ /* @__PURE__ */ i("div", { className: "flex items-center gap-4", children: [
3333
+ /* @__PURE__ */ e("div", { className: "text-xl font-bold text-blue-600", children: "组态编辑器" }),
3334
+ /* @__PURE__ */ i("div", { className: "text-sm text-gray-500", children: [
3335
+ Y.length,
3336
+ " 个节点"
3337
+ ] })
3338
+ ] }),
3339
+ /* @__PURE__ */ i(me, { children: [
3340
+ r,
3341
+ !t && /* @__PURE__ */ i(Me, { children: [
3342
+ /* @__PURE__ */ e(Ie, { title: "导出 JSON", children: /* @__PURE__ */ e(A, { icon: /* @__PURE__ */ e(fn, {}), onClick: L, children: "导出" }) }),
3343
+ /* @__PURE__ */ e(Ie, { title: "导入 JSON", children: /* @__PURE__ */ e(
3344
+ A,
3345
+ {
3346
+ icon: /* @__PURE__ */ e(It, {}),
3347
+ onClick: () => w(!0),
3348
+ children: "导入"
3349
+ }
3350
+ ) })
3351
+ ] })
3352
+ ] })
3353
+ ] }),
3354
+ /* @__PURE__ */ i(at, { children: [
3355
+ a && !t && /* @__PURE__ */ e(St, { width: 280, className: "bg-white", theme: "light", children: /* @__PURE__ */ e($n, {}) }),
3356
+ /* @__PURE__ */ e(Vn, { className: "bg-gray-100 relative", children: /* @__PURE__ */ e(jn, { defaultTestData: g }) }),
3357
+ p && !t && /* @__PURE__ */ e(St, { width: 360, className: "bg-white", theme: "light", children: /* @__PURE__ */ e(qn, { defaultTestData: g }) })
3358
+ ] }),
3359
+ /* @__PURE__ */ e(
3360
+ it,
3361
+ {
3362
+ title: "导入组态方案",
3363
+ open: h,
3364
+ onOk: X,
3365
+ onCancel: () => {
3366
+ w(!1), C("");
3367
+ },
3368
+ width: 600,
3369
+ children: /* @__PURE__ */ i("div", { className: "space-y-4", children: [
3370
+ /* @__PURE__ */ i("div", { children: [
3371
+ /* @__PURE__ */ e("p", { className: "mb-2", children: "选择 JSON 文件导入:" }),
3372
+ /* @__PURE__ */ e(
3373
+ "input",
3374
+ {
3375
+ type: "file",
3376
+ accept: ".json",
3377
+ onChange: (k) => {
3378
+ const Z = k.target.files?.[0];
3379
+ Z && K(Z);
3380
+ },
3381
+ className: `block w-full text-sm text-gray-500
3382
+ file:mr-4 file:py-2 file:px-4
3383
+ file:rounded-full file:border-0
3384
+ file:text-sm file:font-semibold
3385
+ file:bg-blue-50 file:text-blue-700
3386
+ hover:file:bg-blue-100`
3387
+ }
3388
+ )
3389
+ ] }),
3390
+ /* @__PURE__ */ e("div", { className: "text-center text-gray-400", children: "或" }),
3391
+ /* @__PURE__ */ i("div", { children: [
3392
+ /* @__PURE__ */ e("p", { className: "mb-2", children: "粘贴 JSON 内容:" }),
3393
+ /* @__PURE__ */ e(
3394
+ "textarea",
3395
+ {
3396
+ value: c,
3397
+ onChange: (k) => C(k.target.value),
3398
+ placeholder: "粘贴 JSON 内容...",
3399
+ className: "w-full h-48 p-3 border border-gray-300 rounded-lg font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-blue-500"
3400
+ }
3401
+ )
3402
+ ] })
3403
+ ] })
3404
+ }
3405
+ )
3406
+ ]
3407
+ }
3408
+ ) });
3409
+ };
3410
+ export {
3411
+ jn as Canvas,
3412
+ ll as ConfigEditor,
3413
+ $n as MaterialPanel,
3414
+ Tt as NodeRenderer,
3415
+ qn as PropertyPanel,
3416
+ Ln as createDefaultNode,
3417
+ $t as createDefaultStatus,
3418
+ Pn as initMaterials,
3419
+ Qe as useEditorStore
3420
+ };
3421
+ //# sourceMappingURL=config-editor.es.js.map