jch-config-editor 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
(function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("zustand"),require("immer"),require("nanoid"),require("react-zoom-pan-pinch")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","antd","@ant-design/icons","zustand","immer","nanoid","react-zoom-pan-pinch"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.ConfigEditor={},R.jsxRuntime,R.React,R.antd,R.icons,R.zustand,R.immer,R.nanoid,R.ReactZoomPanPinch))})(this,(function(R,e,g,t,L,St,Ct,U,Je){"use strict";var Ke=document.createElement("style");Ke.textContent=`.ConfigEditor-module__configEditor__dinNG{width:100%;height:100%;display:flex;flex-direction:column}.ConfigEditor-module__configEditor__dinNG .ant-layout{background:#f5f5f5}.ConfigEditor-module__configEditor__dinNG .ant-layout-sider{background:#fff}.ConfigEditor-module__configEditor__dinNG .ant-collapse-ghost>.ant-collapse-item>.ant-collapse-content>.ant-collapse-content-box{padding:8px 0}.ConfigEditor-module__configEditor__dinNG .ant-list-item{padding:8px 12px}.ConfigEditor-module__canvasGrid__yL2Pn{background-image:linear-gradient(#e8e8e8 1px,transparent 1px),linear-gradient(90deg,#e8e8e8 1px,transparent 1px);background-size:20px 20px}.ConfigEditor-module__nodeSelected__CePHY{box-shadow:0 0 0 2px #1890ff,0 0 10px #1890ff4d}.ConfigEditor-module__dragging__w3tvz{cursor:grabbing!important;opacity:.8}.ConfigEditor-module__toolbarBtn__vRYDU{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:all .2s}.ConfigEditor-module__toolbarBtn__vRYDU:hover{background-color:#f3f4f6}.ConfigEditor-module__toolbarBtn__vRYDU.ConfigEditor-module__active__nREu2{background-color:#dbeafe;color:#2563eb}.ConfigEditor-module__propertyForm__f-Egu .ant-form-item{margin-bottom:12px}.ConfigEditor-module__propertyForm__f-Egu .ant-form-item-label{padding-bottom:4px}.ConfigEditor-module__materialItem__rDby0{transition:all .2s}.ConfigEditor-module__materialItem__rDby0:hover{background-color:#f9fafb}.ConfigEditor-module__materialItem__rDby0.ConfigEditor-module__selected__rIJzf{background-color:#eff6ff;box-shadow:0 0 0 2px #60a5fa}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar{width:6px;height:6px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-thumb:hover{background:#a8a8a8}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.\\!visible{visibility:visible!important}.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.-top-6{top:-1.5rem}.bottom-0{bottom:0}.bottom-4{bottom:1rem}.left-0{left:0}.left-1\\/2{left:50%}.right-0{right:0}.right-4{right:1rem}.top-0{top:0}.z-10{z-index:10}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-0\\.5{height:.125rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-4{height:1rem}.h-48{height:12rem}.h-full{height:100%}.max-h-\\[400px\\]{max-height:400px}.w-0\\.5{width:.125rem}.w-10{width:2.5rem}.w-12{width:3rem}.w-3{width:.75rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-8{width:2rem}.w-full{width:100%}.min-w-0{min-width:0px}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-crosshair{cursor:crosshair}.cursor-grab{cursor:grab}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\\/10{background-color:#3b82f61a}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.object-contain{-o-object-fit:contain;object-fit:contain}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pr-4{padding-right:1rem}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-blue-400{--tw-ring-opacity: 1;--tw-ring-color: rgb(96 165 250 / var(--tw-ring-opacity, 1)) }.ring-opacity-50{--tw-ring-opacity: .5 }.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.file\\:mr-4::file-selector-button{margin-right:1rem}.file\\:rounded-full::file-selector-button{border-radius:9999px}.file\\:border-0::file-selector-button{border-width:0px}.file\\:bg-blue-50::file-selector-button{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.file\\:px-4::file-selector-button{padding-left:1rem;padding-right:1rem}.file\\:py-2::file-selector-button{padding-top:.5rem;padding-bottom:.5rem}.file\\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:font-semibold::file-selector-button{font-weight:600}.file\\:text-blue-700::file-selector-button{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.hover\\:border-blue-500:hover{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.hover\\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\\:file\\:bg-blue-100::file-selector-button:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1)) }
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild(Ke);function Nt(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var ke={},Be={exports:{}},Qe;function Ue(){return Qe||(Qe=1,(function(l){function p(r){return r&&r.__esModule?r:{default:r}}l.exports=p,l.exports.__esModule=!0,l.exports.default=l.exports})(Be)),Be.exports}var Ie={},Re;function kt(){if(Re)return Ie;Re=1,Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.default=void 0;const l={items_per_page:"条/页",jump_to:"跳至",jump_to_confirm:"确定",page:"页",prev_page:"上一页",next_page:"下一页",prev_5:"向前 5 页",next_5:"向后 5 页",prev_3:"向前 3 页",next_3:"向后 3 页",page_size:"页码"};return Ie.default=l,Ie}var Ee={},_e={},Me={},De={},et;function It(){return et||(et=1,Object.defineProperty(De,"__esModule",{value:!0}),De.commonLocale=void 0,De.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0}),De}var tt;function Et(){if(tt)return Me;tt=1,Object.defineProperty(Me,"__esModule",{value:!0}),Me.default=void 0;var l=It();function p(m){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},p(m)}function r(m,h){var f=Object.keys(m);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(m);h&&(S=S.filter(function(u){return Object.getOwnPropertyDescriptor(m,u).enumerable})),f.push.apply(f,S)}return f}function n(m){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?r(Object(f),!0).forEach(function(S){d(m,S,f[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(S){Object.defineProperty(m,S,Object.getOwnPropertyDescriptor(f,S))})}return m}function d(m,h,f){return h=o(h),h in m?Object.defineProperty(m,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):m[h]=f,m}function o(m){var h=a(m,"string");return p(h)=="symbol"?h:String(h)}function a(m,h){if(p(m)!="object"||!m)return m;var f=m[Symbol.toPrimitive];if(f!==void 0){var S=f.call(m,h);if(p(S)!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(m)}var i=n(n({},l.commonLocale),{},{locale:"zh_CN",today:"今天",now:"此刻",backToToday:"返回今天",ok:"确定",timeSelect:"选择时间",dateSelect:"选择日期",weekSelect:"选择周",clear:"清除",week:"周",month:"月",year:"年",previousMonth:"上个月 (翻页上键)",nextMonth:"下个月 (翻页下键)",monthSelect:"选择月份",yearSelect:"选择年份",decadeSelect:"选择年代",previousYear:"上一年 (Control键加左方向键)",nextYear:"下一年 (Control键加右方向键)",previousDecade:"上一年代",nextDecade:"下一年代",previousCentury:"上一世纪",nextCentury:"下一世纪",yearFormat:"YYYY年",cellDateFormat:"D",monthBeforeYear:!1});return Me.default=i,Me}var Le={},rt;function ot(){if(rt)return Le;rt=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.default=void 0;const l={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]};return Le.default=l,Le}var lt;function nt(){if(lt)return _e;lt=1;var l=Ue().default;Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var p=l(Et()),r=l(ot());const n={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...p.default},timePickerLocale:{...r.default}};return n.lang.ok="确定",_e.default=n,_e}var at;function _t(){if(at)return Ee;at=1;var l=Ue().default;Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.default=void 0;var p=l(nt());return Ee.default=p.default,Ee}var it;function Mt(){if(it)return ke;it=1;var l=Ue().default;Object.defineProperty(ke,"__esModule",{value:!0}),ke.default=void 0;var p=l(kt()),r=l(_t()),n=l(nt()),d=l(ot());const o="${label}不是一个有效的${type}",a={locale:"zh-cn",Pagination:p.default,DatePicker:n.default,TimePicker:d.default,Calendar:r.default,global:{placeholder:"请选择",close:"关闭",sortable:"可排序"},Table:{filterTitle:"筛选",filterConfirm:"确定",filterReset:"重置",filterEmptyText:"无筛选项",filterCheckAll:"全选",filterSearchPlaceholder:"在筛选项中搜索",emptyText:"暂无数据",selectAll:"全选当页",selectInvert:"反选当页",selectNone:"清空所有",selectionAll:"全选所有",sortTitle:"排序",expand:"展开行",collapse:"关闭行",triggerDesc:"点击降序",triggerAsc:"点击升序",cancelSort:"取消排序"},Modal:{okText:"确定",cancelText:"取消",justOkText:"知道了"},Tour:{Next:"下一步",Previous:"上一步",Finish:"结束导览"},Popconfirm:{cancelText:"取消",okText:"确定"},Transfer:{titles:["",""],searchPlaceholder:"请输入搜索内容",itemUnit:"项",itemsUnit:"项",remove:"删除",selectCurrent:"全选当页",removeCurrent:"删除当页",selectAll:"全选所有",deselectAll:"取消全选",removeAll:"删除全部",selectInvert:"反选当页"},Upload:{uploading:"文件上传中",removeFile:"删除文件",uploadError:"上传错误",previewFile:"预览文件",downloadFile:"下载文件"},Empty:{description:"暂无数据"},Icon:{icon:"图标"},Text:{edit:"编辑",copy:"复制",copied:"复制成功",expand:"展开",collapse:"收起"},Form:{optional:"(可选)",defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label}须为${len}个字符",min:"${label}最少${min}个字符",max:"${label}最多${max}个字符",range:"${label}须在${min}-${max}字符之间"},number:{len:"${label}必须等于${len}",min:"${label}最小值为${min}",max:"${label}最大值为${max}",range:"${label}须在${min}-${max}之间"},array:{len:"须为${len}个${label}",min:"最少${min}个${label}",max:"最多${max}个${label}",range:"${label}数量须在${min}-${max}之间"},pattern:{mismatch:"${label}与模式不匹配${pattern}"}}},QRCode:{expired:"二维码过期",refresh:"点击刷新",scanned:"已扫描"},ColorPicker:{presetEmpty:"暂无",transparent:"无色",singleColor:"单色",gradientColor:"渐变色"}};return ke.default=a,ke}var Ge,st;function Dt(){return st||(st=1,Ge=Mt()),Ge}var Lt=Dt();const Tt=Nt(Lt),Yt=l=>(p,r,n)=>(n.setState=(d,o,...a)=>{const i=typeof d=="function"?Ct.produce(d):d;return p(i,o,...a)},l(n.setState,r,n)),ct={nodes:[],materials:[],selectedNodeId:null,selectedStatusId:null,canvas:{width:1920,height:1080,background:"#ffffff",showGrid:!0},viewport:{scale:1,positionX:0,positionY:0},history:{past:[],future:[]},mode:"select",lineDrawing:{isDrawing:!1,material:null,startPoint:null,endPoint:null}},fe=(l,p,r)=>({id:U.nanoid(),type:l,targetId:p,payload:r,timestamp:Date.now()}),me=St.create()(Yt((l,p)=>({...ct,addNode:(r,n=!0)=>{l(d=>{const o={...r,id:r.id||U.nanoid()};d.nodes.push(o),n&&(d.selectedNodeId=o.id,d.history.past.push(fe("NODE_SELECT",o.id)))})},updateNode:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o,n),d.history.past.push(fe("PROPERTY_CHANGE",r,n)))})},updateNodeStyle:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o.normalStyle,n),d.history.past.push(fe("PROPERTY_CHANGE",r,{normalStyle:n})))})},updateNodeContent:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(o.contentInfo={...o.contentInfo,...n},d.history.past.push(fe("PROPERTY_CHANGE",r,{contentInfo:n})))})},updateNodeControl:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o.controlInfo,n),d.history.past.push(fe("PROPERTY_CHANGE",r,{controlInfo:n})))})},removeNode:r=>{l(n=>{const d=n.nodes.findIndex(o=>o.id===r);d!==-1&&(n.nodes.splice(d,1),n.selectedNodeId===r&&(n.selectedNodeId=null,n.selectedStatusId=null),n.history.past.push(fe("NODE_DELETE",r)))})},selectNode:r=>{l(n=>{n.selectedNodeId=r,n.selectedStatusId=null,r&&n.history.past.push(fe("NODE_SELECT",r))})},addStatus:(r,n)=>{l(d=>{const o=d.nodes.find(i=>i.id===r);if(!o)return;const a={...n,id:U.nanoid()};o.contentInfo.statusList.push(a),d.history.past.push(fe("MATERIAL_STATUS_CHANGE",r,{statusId:a.id}))})},removeStatus:(r,n)=>{l(d=>{const o=d.nodes.find(i=>i.id===r);if(!o)return;const a=o.contentInfo.statusList.findIndex(i=>i.id===n);a!==-1&&(o.contentInfo.statusList.splice(a,1),o.contentInfo.currentStatusId===n&&(o.contentInfo.currentStatusId=void 0),d.selectedStatusId===n&&(d.selectedStatusId=null))})},updateStatus:(r,n,d)=>{l(o=>{const a=o.nodes.find(m=>m.id===r);if(!a)return;const i=a.contentInfo.statusList.find(m=>m.id===n);i&&Object.assign(i,d)})},selectStatus:r=>{l(n=>{n.selectedStatusId=r})},evaluateCurrentStatus:(r,n)=>{const o=p().nodes.find(a=>a.id===r);if(o)for(const a of o.contentInfo.statusList)try{if(new Function("data","bindCodes","status",a.expression)(n,a.bindCodes,a)===!0)return a.id}catch(i){console.warn("状态表达式执行失败:",a.name,i)}},addMaterial:r=>{l(n=>{const d={...r,id:U.nanoid()};n.materials.push(d),n.history.past.push(fe("MATERIAL_ADD",d.id))})},updateMaterial:(r,n)=>{l(d=>{const o=d.materials.find(a=>a.id===r);o&&Object.assign(o,n)})},removeMaterial:r=>{l(n=>{const d=n.materials.findIndex(o=>o.id===r);d!==-1&&n.materials.splice(d,1)})},setViewport:r=>{l(n=>{Object.assign(n.viewport,r)})},setCanvasConfig:r=>{l(n=>{n.canvas={...n.canvas,...r}})},setMode:r=>{l(n=>{n.mode=r})},startLineDrawing:r=>{l(n=>{n.mode="line-draw",n.lineDrawing={isDrawing:!0,material:r,startPoint:null,endPoint:null}})},updateLineDrawing:r=>{l(n=>{n.lineDrawing.isDrawing&&(n.lineDrawing.endPoint=r)})},endLineDrawing:()=>{l(r=>{r.mode="select",r.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},cancelLineDrawing:()=>{l(r=>{r.mode="select",r.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},undo:()=>{l(r=>{const n=r.history.past.pop();n&&r.history.future.push(n)})},redo:()=>{l(r=>{const n=r.history.future.pop();n&&r.history.past.push(n)})},recordEvent:r=>{l(n=>{n.history.past.push(r),n.history.future=[]})},exportScheme:()=>{const r=p();return{version:"1.1.0",nodes:r.nodes,materials:r.materials,viewport:r.viewport,metadata:{name:"未命名组态",description:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}},importScheme:r=>{l(n=>{n.nodes=r.nodes||[],n.materials=r.materials||[],n.viewport=r.viewport||ct.viewport,n.selectedNodeId=null,n.selectedStatusId=null,n.history={past:[],future:[]}})}}))),dt=[{id:U.nanoid(),name:"矩形",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"圆形",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"圆角矩形",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"阀门",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"泵",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"罐体",type:"IMAGE",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>')}`},{id:U.nanoid(),name:"文本标签",type:"TEXT",content:{label:"标签",value:"值",labelStyle:{fontSize:14,fontWeight:"bold",color:"#262626",textAlign:"left"},valueStyle:{fontSize:14,fontWeight:"normal",color:"#1890ff",textAlign:"left"}}},{id:U.nanoid(),name:"线条",type:"LINE",config:{thickness:2,lineWeight:2,color:"#262626",lineType:"solid"}}],qe=l=>({id:U.nanoid(),name:"默认状态",expression:"return true;",material:{...l,id:U.nanoid()},bindCodes:[]}),ht=(l,p,r)=>{if(r?.type==="CUSTOM"&&r.config?.nodes){const n=r.config.nodes.map(h=>({...h,id:U.nanoid()}));let d=1/0,o=1/0,a=-1/0,i=-1/0;n.forEach(h=>{const f=h.normalStyle.x||0,S=h.normalStyle.y||0,u=h.normalStyle.width||0,E=h.normalStyle.height||0;d=Math.min(d,f),o=Math.min(o,S),a=Math.max(a,f+u),i=Math.max(i,S+E)});const m=n.map(h=>({...h,normalStyle:{...h.normalStyle,x:(h.normalStyle.x||0)-d,y:(h.normalStyle.y||0)-o,scale:void 0}}));return{id:U.nanoid(),name:r.name||"群组节点",type:"group",normalStyle:{width:a-d,height:i-o,x:l,y:p},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:m}}return{id:U.nanoid(),name:"新节点",type:"normal",normalStyle:{width:120,height:100,x:l,y:p,background:"transparent",padding:8},contentInfo:{statusList:r?[qe(r)]:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}}},{Panel:we}=t.Collapse,{Text:ze}=t.Typography,ut=()=>{const{materials:l,addMaterial:p,removeMaterial:r,selectedStatusId:n,selectStatus:d,mode:o,lineDrawing:a,startLineDrawing:i,cancelLineDrawing:m}=me(),[h,f]=g.useState(["basic","device","text","line"]),S=b=>{const G=new FileReader;return G.onload=A=>{const $=A.target?.result;p({name:b.name.replace(".svg",""),type:"IMAGE",src:$})},G.readAsDataURL(b),!1},u={basic:l.filter(b=>["矩形","圆形","圆角矩形"].includes(b.name)),device:l.filter(b=>["阀门","泵","罐体"].includes(b.name)||b.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(b.name)&&b.name!=="自定义"),text:l.filter(b=>b.type==="TEXT"),line:l.filter(b=>b.type==="LINE"),group:l.filter(b=>b.type==="CUSTOM"&&b.config?.nodes),custom:l.filter(b=>b.type==="CUSTOM"&&!b.config?.nodes||b.type==="IMAGE"&&!["矩形","圆形","圆角矩形","阀门","泵","罐体"].includes(b.name))},E=(b,G)=>{b.dataTransfer.effectAllowed="copy",b.dataTransfer.setData("application/json",JSON.stringify(G));const A=b.currentTarget.querySelector(".material-preview");A&&b.dataTransfer.setDragImage(A,20,20)},w=b=>{b.type==="LINE"&&i(b)},k=(b,G=!1)=>{const A=G===!0,$=o==="line-draw"&&A&&a.material?.id===b.id;return e.jsx(t.List.Item,{draggable:!A,onDragStart:D=>E(D,b),onClick:()=>A&&w(b),className:`
|
|
1
|
+
(function(R,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("zustand"),require("immer"),require("nanoid"),require("react-zoom-pan-pinch")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","antd","@ant-design/icons","zustand","immer","nanoid","react-zoom-pan-pinch"],e):(R=typeof globalThis<"u"?globalThis:R||self,e(R.ConfigEditor={},R.jsxRuntime,R.React,R.antd,R.icons,R.zustand,R.immer,R.nanoid,R.ReactZoomPanPinch))})(this,(function(R,e,g,t,Y,Ct,Nt,G,Qe){"use strict";var Re=document.createElement("style");Re.textContent=`.ConfigEditor-module__configEditor__dinNG{width:100%;height:100%;display:flex;flex-direction:column}.ConfigEditor-module__configEditor__dinNG .ant-layout{background:#f5f5f5}.ConfigEditor-module__configEditor__dinNG .ant-layout-sider{background:#fff}.ConfigEditor-module__configEditor__dinNG .ant-collapse-ghost>.ant-collapse-item>.ant-collapse-content>.ant-collapse-content-box{padding:8px 0}.ConfigEditor-module__configEditor__dinNG .ant-list-item{padding:8px 12px}.ConfigEditor-module__canvasGrid__yL2Pn{background-image:linear-gradient(#e8e8e8 1px,transparent 1px),linear-gradient(90deg,#e8e8e8 1px,transparent 1px);background-size:20px 20px}.ConfigEditor-module__nodeSelected__CePHY{box-shadow:0 0 0 2px #1890ff,0 0 10px #1890ff4d}.ConfigEditor-module__dragging__w3tvz{cursor:grabbing!important;opacity:.8}.ConfigEditor-module__toolbarBtn__vRYDU{width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:all .2s}.ConfigEditor-module__toolbarBtn__vRYDU:hover{background-color:#f3f4f6}.ConfigEditor-module__toolbarBtn__vRYDU.ConfigEditor-module__active__nREu2{background-color:#dbeafe;color:#2563eb}.ConfigEditor-module__propertyForm__f-Egu .ant-form-item{margin-bottom:12px}.ConfigEditor-module__propertyForm__f-Egu .ant-form-item-label{padding-bottom:4px}.ConfigEditor-module__materialItem__rDby0{transition:all .2s}.ConfigEditor-module__materialItem__rDby0:hover{background-color:#f9fafb}.ConfigEditor-module__materialItem__rDby0.ConfigEditor-module__selected__rIJzf{background-color:#eff6ff;box-shadow:0 0 0 2px #60a5fa}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar{width:6px;height:6px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-track{background:#f1f1f1;border-radius:3px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-thumb{background:#c1c1c1;border-radius:3px}.ConfigEditor-module__configEditor__dinNG ::-webkit-scrollbar-thumb:hover{background:#a8a8a8}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.\\!visible{visibility:visible!important}.visible{visibility:visible}.absolute{position:absolute}.relative{position:relative}.inset-0{inset:0}.-top-6{top:-1.5rem}.bottom-0{bottom:0}.bottom-4{bottom:1rem}.left-0{left:0}.left-1\\/2{left:50%}.right-0{right:0}.right-4{right:1rem}.top-0{top:0}.z-10{z-index:10}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.ml-2{margin-left:.5rem}.mt-2{margin-top:.5rem}.mt-4{margin-top:1rem}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-0\\.5{height:.125rem}.h-10{height:2.5rem}.h-12{height:3rem}.h-3{height:.75rem}.h-4{height:1rem}.h-48{height:12rem}.h-full{height:100%}.max-h-\\[400px\\]{max-height:400px}.w-0\\.5{width:.125rem}.w-10{width:2.5rem}.w-12{width:3rem}.w-3{width:.75rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-8{width:2rem}.w-full{width:100%}.min-w-0{min-width:0px}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-crosshair{cursor:crosshair}.cursor-grab{cursor:grab}.cursor-move{cursor:move}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-l{border-left-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.border-gray-200{--tw-border-opacity: 1;border-color:rgb(229 231 235 / var(--tw-border-opacity, 1))}.border-gray-300{--tw-border-opacity: 1;border-color:rgb(209 213 219 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\\/10{background-color:#3b82f61a}.bg-gray-100{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.bg-gray-400{--tw-bg-opacity: 1;background-color:rgb(156 163 175 / var(--tw-bg-opacity, 1))}.bg-gray-50{--tw-bg-opacity: 1;background-color:rgb(249 250 251 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.object-contain{-o-object-fit:contain;object-fit:contain}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pr-4{padding-right:1rem}.text-center{text-align:center}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.text-blue-500{--tw-text-opacity: 1;color:rgb(59 130 246 / var(--tw-text-opacity, 1))}.text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.text-gray-800{--tw-text-opacity: 1;color:rgb(31 41 55 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-4{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-blue-400{--tw-ring-opacity: 1;--tw-ring-color: rgb(96 165 250 / var(--tw-ring-opacity, 1)) }.ring-opacity-50{--tw-ring-opacity: .5 }.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.file\\:mr-4::file-selector-button{margin-right:1rem}.file\\:rounded-full::file-selector-button{border-radius:9999px}.file\\:border-0::file-selector-button{border-width:0px}.file\\:bg-blue-50::file-selector-button{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.file\\:px-4::file-selector-button{padding-left:1rem;padding-right:1rem}.file\\:py-2::file-selector-button{padding-top:.5rem;padding-bottom:.5rem}.file\\:text-sm::file-selector-button{font-size:.875rem;line-height:1.25rem}.file\\:font-semibold::file-selector-button{font-weight:600}.file\\:text-blue-700::file-selector-button{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.hover\\:border-blue-500:hover{--tw-border-opacity: 1;border-color:rgb(59 130 246 / var(--tw-border-opacity, 1))}.hover\\:bg-blue-50:hover{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.hover\\:bg-gray-100:hover{--tw-bg-opacity: 1;background-color:rgb(243 244 246 / var(--tw-bg-opacity, 1))}.hover\\:file\\:bg-blue-100::file-selector-button:hover{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\\:ring-blue-500:focus{--tw-ring-opacity: 1;--tw-ring-color: rgb(59 130 246 / var(--tw-ring-opacity, 1)) }
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild(Re);function kt(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Ie={},Ge={exports:{}},et;function qe(){return et||(et=1,(function(l){function p(r){return r&&r.__esModule?r:{default:r}}l.exports=p,l.exports.__esModule=!0,l.exports.default=l.exports})(Ge)),Ge.exports}var Ee={},tt;function It(){if(tt)return Ee;tt=1,Object.defineProperty(Ee,"__esModule",{value:!0}),Ee.default=void 0;const l={items_per_page:"条/页",jump_to:"跳至",jump_to_confirm:"确定",page:"页",prev_page:"上一页",next_page:"下一页",prev_5:"向前 5 页",next_5:"向后 5 页",prev_3:"向前 3 页",next_3:"向后 3 页",page_size:"页码"};return Ee.default=l,Ee}var _e={},Me={},De={},Le={},rt;function Et(){return rt||(rt=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.commonLocale=void 0,Le.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0}),Le}var ot;function _t(){if(ot)return De;ot=1,Object.defineProperty(De,"__esModule",{value:!0}),De.default=void 0;var l=Et();function p(m){"@babel/helpers - typeof";return p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(h){return typeof h}:function(h){return h&&typeof Symbol=="function"&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h},p(m)}function r(m,h){var f=Object.keys(m);if(Object.getOwnPropertySymbols){var S=Object.getOwnPropertySymbols(m);h&&(S=S.filter(function(u){return Object.getOwnPropertyDescriptor(m,u).enumerable})),f.push.apply(f,S)}return f}function n(m){for(var h=1;h<arguments.length;h++){var f=arguments[h]!=null?arguments[h]:{};h%2?r(Object(f),!0).forEach(function(S){d(m,S,f[S])}):Object.getOwnPropertyDescriptors?Object.defineProperties(m,Object.getOwnPropertyDescriptors(f)):r(Object(f)).forEach(function(S){Object.defineProperty(m,S,Object.getOwnPropertyDescriptor(f,S))})}return m}function d(m,h,f){return h=o(h),h in m?Object.defineProperty(m,h,{value:f,enumerable:!0,configurable:!0,writable:!0}):m[h]=f,m}function o(m){var h=a(m,"string");return p(h)=="symbol"?h:String(h)}function a(m,h){if(p(m)!="object"||!m)return m;var f=m[Symbol.toPrimitive];if(f!==void 0){var S=f.call(m,h);if(p(S)!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(m)}var i=n(n({},l.commonLocale),{},{locale:"zh_CN",today:"今天",now:"此刻",backToToday:"返回今天",ok:"确定",timeSelect:"选择时间",dateSelect:"选择日期",weekSelect:"选择周",clear:"清除",week:"周",month:"月",year:"年",previousMonth:"上个月 (翻页上键)",nextMonth:"下个月 (翻页下键)",monthSelect:"选择月份",yearSelect:"选择年份",decadeSelect:"选择年代",previousYear:"上一年 (Control键加左方向键)",nextYear:"下一年 (Control键加右方向键)",previousDecade:"上一年代",nextDecade:"下一年代",previousCentury:"上一世纪",nextCentury:"下一世纪",yearFormat:"YYYY年",cellDateFormat:"D",monthBeforeYear:!1});return De.default=i,De}var Ye={},lt;function nt(){if(lt)return Ye;lt=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.default=void 0;const l={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]};return Ye.default=l,Ye}var at;function it(){if(at)return Me;at=1;var l=qe().default;Object.defineProperty(Me,"__esModule",{value:!0}),Me.default=void 0;var p=l(_t()),r=l(nt());const n={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...p.default},timePickerLocale:{...r.default}};return n.lang.ok="确定",Me.default=n,Me}var st;function Mt(){if(st)return _e;st=1;var l=qe().default;Object.defineProperty(_e,"__esModule",{value:!0}),_e.default=void 0;var p=l(it());return _e.default=p.default,_e}var ct;function Dt(){if(ct)return Ie;ct=1;var l=qe().default;Object.defineProperty(Ie,"__esModule",{value:!0}),Ie.default=void 0;var p=l(It()),r=l(Mt()),n=l(it()),d=l(nt());const o="${label}不是一个有效的${type}",a={locale:"zh-cn",Pagination:p.default,DatePicker:n.default,TimePicker:d.default,Calendar:r.default,global:{placeholder:"请选择",close:"关闭",sortable:"可排序"},Table:{filterTitle:"筛选",filterConfirm:"确定",filterReset:"重置",filterEmptyText:"无筛选项",filterCheckAll:"全选",filterSearchPlaceholder:"在筛选项中搜索",emptyText:"暂无数据",selectAll:"全选当页",selectInvert:"反选当页",selectNone:"清空所有",selectionAll:"全选所有",sortTitle:"排序",expand:"展开行",collapse:"关闭行",triggerDesc:"点击降序",triggerAsc:"点击升序",cancelSort:"取消排序"},Modal:{okText:"确定",cancelText:"取消",justOkText:"知道了"},Tour:{Next:"下一步",Previous:"上一步",Finish:"结束导览"},Popconfirm:{cancelText:"取消",okText:"确定"},Transfer:{titles:["",""],searchPlaceholder:"请输入搜索内容",itemUnit:"项",itemsUnit:"项",remove:"删除",selectCurrent:"全选当页",removeCurrent:"删除当页",selectAll:"全选所有",deselectAll:"取消全选",removeAll:"删除全部",selectInvert:"反选当页"},Upload:{uploading:"文件上传中",removeFile:"删除文件",uploadError:"上传错误",previewFile:"预览文件",downloadFile:"下载文件"},Empty:{description:"暂无数据"},Icon:{icon:"图标"},Text:{edit:"编辑",copy:"复制",copied:"复制成功",expand:"展开",collapse:"收起"},Form:{optional:"(可选)",defaultValidateMessages:{default:"字段验证错误${label}",required:"请输入${label}",enum:"${label}必须是其中一个[${enum}]",whitespace:"${label}不能为空字符",date:{format:"${label}日期格式无效",parse:"${label}不能转换为日期",invalid:"${label}是一个无效日期"},types:{string:o,method:o,array:o,object:o,number:o,date:o,boolean:o,integer:o,float:o,regexp:o,email:o,url:o,hex:o},string:{len:"${label}须为${len}个字符",min:"${label}最少${min}个字符",max:"${label}最多${max}个字符",range:"${label}须在${min}-${max}字符之间"},number:{len:"${label}必须等于${len}",min:"${label}最小值为${min}",max:"${label}最大值为${max}",range:"${label}须在${min}-${max}之间"},array:{len:"须为${len}个${label}",min:"最少${min}个${label}",max:"最多${max}个${label}",range:"${label}数量须在${min}-${max}之间"},pattern:{mismatch:"${label}与模式不匹配${pattern}"}}},QRCode:{expired:"二维码过期",refresh:"点击刷新",scanned:"已扫描"},ColorPicker:{presetEmpty:"暂无",transparent:"无色",singleColor:"单色",gradientColor:"渐变色"}};return Ie.default=a,Ie}var He,dt;function Lt(){return dt||(dt=1,He=Dt()),He}var Yt=Lt();const Tt=kt(Yt),$t=l=>(p,r,n)=>(n.setState=(d,o,...a)=>{const i=typeof d=="function"?Nt.produce(d):d;return p(i,o,...a)},l(n.setState,r,n)),ht={nodes:[],materials:[],selectedNodeId:null,selectedStatusId:null,canvas:{width:1920,height:1080,background:"#ffffff",showGrid:!0},viewport:{scale:1,positionX:0,positionY:0},history:{past:[],future:[]},mode:"select",lineDrawing:{isDrawing:!1,material:null,startPoint:null,endPoint:null}},fe=(l,p,r)=>({id:G.nanoid(),type:l,targetId:p,payload:r,timestamp:Date.now()}),ye=Ct.create()($t((l,p)=>({...ht,addNode:(r,n=!0)=>{l(d=>{const o={...r,id:r.id||G.nanoid()};d.nodes.push(o),n&&(d.selectedNodeId=o.id,d.history.past.push(fe("NODE_SELECT",o.id)))})},updateNode:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o,n),d.history.past.push(fe("PROPERTY_CHANGE",r,n)))})},updateNodeStyle:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o.normalStyle,n),d.history.past.push(fe("PROPERTY_CHANGE",r,{normalStyle:n})))})},updateNodeContent:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(o.contentInfo={...o.contentInfo,...n},d.history.past.push(fe("PROPERTY_CHANGE",r,{contentInfo:n})))})},updateNodeControl:(r,n)=>{l(d=>{const o=d.nodes.find(a=>a.id===r);o&&(Object.assign(o.controlInfo,n),d.history.past.push(fe("PROPERTY_CHANGE",r,{controlInfo:n})))})},removeNode:r=>{l(n=>{const d=n.nodes.findIndex(o=>o.id===r);d!==-1&&(n.nodes.splice(d,1),n.selectedNodeId===r&&(n.selectedNodeId=null,n.selectedStatusId=null),n.history.past.push(fe("NODE_DELETE",r)))})},selectNode:r=>{l(n=>{n.selectedNodeId=r,n.selectedStatusId=null,r&&n.history.past.push(fe("NODE_SELECT",r))})},addStatus:(r,n)=>{l(d=>{const o=d.nodes.find(i=>i.id===r);if(!o)return;const a={...n,id:G.nanoid()};o.contentInfo.statusList.push(a),d.history.past.push(fe("MATERIAL_STATUS_CHANGE",r,{statusId:a.id}))})},removeStatus:(r,n)=>{l(d=>{const o=d.nodes.find(i=>i.id===r);if(!o)return;const a=o.contentInfo.statusList.findIndex(i=>i.id===n);a!==-1&&(o.contentInfo.statusList.splice(a,1),o.contentInfo.currentStatusId===n&&(o.contentInfo.currentStatusId=void 0),d.selectedStatusId===n&&(d.selectedStatusId=null))})},updateStatus:(r,n,d)=>{l(o=>{const a=o.nodes.find(m=>m.id===r);if(!a)return;const i=a.contentInfo.statusList.find(m=>m.id===n);i&&Object.assign(i,d)})},selectStatus:r=>{l(n=>{n.selectedStatusId=r})},evaluateCurrentStatus:(r,n)=>{const o=p().nodes.find(a=>a.id===r);if(o)for(const a of o.contentInfo.statusList)try{if(new Function("data","bindCodes","status",a.expression)(n,a.bindCodes,a)===!0)return a.id}catch(i){console.warn("状态表达式执行失败:",a.name,i)}},addMaterial:r=>{l(n=>{const d={...r,id:G.nanoid()};n.materials.push(d),n.history.past.push(fe("MATERIAL_ADD",d.id))})},updateMaterial:(r,n)=>{l(d=>{const o=d.materials.find(a=>a.id===r);o&&Object.assign(o,n)})},removeMaterial:r=>{l(n=>{const d=n.materials.findIndex(o=>o.id===r);d!==-1&&n.materials.splice(d,1)})},setViewport:r=>{l(n=>{Object.assign(n.viewport,r)})},setCanvasConfig:r=>{l(n=>{n.canvas={...n.canvas,...r}})},setMode:r=>{l(n=>{n.mode=r})},startLineDrawing:r=>{l(n=>{n.mode="line-draw",n.lineDrawing={isDrawing:!0,material:r,startPoint:null,endPoint:null}})},updateLineDrawing:r=>{l(n=>{n.lineDrawing.isDrawing&&(n.lineDrawing.endPoint=r)})},endLineDrawing:()=>{l(r=>{r.mode="select",r.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},cancelLineDrawing:()=>{l(r=>{r.mode="select",r.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},undo:()=>{l(r=>{const n=r.history.past.pop();n&&r.history.future.push(n)})},redo:()=>{l(r=>{const n=r.history.future.pop();n&&r.history.past.push(n)})},recordEvent:r=>{l(n=>{n.history.past.push(r),n.history.future=[]})},exportScheme:()=>{const r=p();return{version:"1.1.0",nodes:r.nodes,materials:r.materials,viewport:r.viewport,metadata:{name:"未命名组态",description:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}},importScheme:r=>{l(n=>{n.nodes=r.nodes||[],n.materials=r.materials||[],n.viewport=r.viewport||ht.viewport,n.selectedNodeId=null,n.selectedStatusId=null,n.history={past:[],future:[]}})}}))),ut=[{id:G.nanoid(),name:"矩形",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"圆形",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"圆角矩形",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"阀门",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"泵",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"罐体",type:"IMAGE",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>')}`},{id:G.nanoid(),name:"文本标签",type:"TEXT",content:{label:"标签",value:"值",labelStyle:{fontSize:14,fontWeight:"bold",color:"#262626",textAlign:"left"},valueStyle:{fontSize:14,fontWeight:"normal",color:"#1890ff",textAlign:"left"}}},{id:G.nanoid(),name:"线条",type:"LINE",config:{thickness:2,lineWeight:2,color:"#262626",lineType:"solid"}}],Ve=l=>({id:G.nanoid(),name:"默认状态",expression:"return true;",material:{...l,id:G.nanoid()},bindCodes:[]}),gt=(l,p,r)=>{if(r?.type==="CUSTOM"&&r.config?.nodes){const n=r.config.nodes.map(h=>({...h,id:G.nanoid()}));let d=1/0,o=1/0,a=-1/0,i=-1/0;n.forEach(h=>{const f=h.normalStyle.x||0,S=h.normalStyle.y||0,u=h.normalStyle.width||0,E=h.normalStyle.height||0;d=Math.min(d,f),o=Math.min(o,S),a=Math.max(a,f+u),i=Math.max(i,S+E)});const m=n.map(h=>({...h,normalStyle:{...h.normalStyle,x:(h.normalStyle.x||0)-d,y:(h.normalStyle.y||0)-o,scale:void 0}}));return{id:G.nanoid(),name:r.name||"群组节点",type:"group",normalStyle:{width:a-d,height:i-o,x:l,y:p},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:m}}return{id:G.nanoid(),name:"新节点",type:"normal",normalStyle:{width:120,height:100,x:l,y:p,background:"transparent",padding:8},contentInfo:{statusList:r?[Ve(r)]:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}}},{Panel:we}=t.Collapse,{Text:Pe}=t.Typography,ft=()=>{const{materials:l,addMaterial:p,removeMaterial:r,selectedStatusId:n,selectStatus:d,mode:o,lineDrawing:a,startLineDrawing:i,cancelLineDrawing:m}=ye(),[h,f]=g.useState(["basic","device","text","line"]),S=b=>{const q=new FileReader;return q.onload=W=>{const F=W.target?.result;p({name:b.name.replace(".svg",""),type:"IMAGE",src:F})},q.readAsDataURL(b),!1},u={basic:l.filter(b=>["矩形","圆形","圆角矩形"].includes(b.name)),device:l.filter(b=>["阀门","泵","罐体"].includes(b.name)||b.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(b.name)&&b.name!=="自定义"),text:l.filter(b=>b.type==="TEXT"),line:l.filter(b=>b.type==="LINE"),group:l.filter(b=>b.type==="CUSTOM"&&b.config?.nodes),custom:l.filter(b=>b.type==="CUSTOM"&&!b.config?.nodes||b.type==="IMAGE"&&!["矩形","圆形","圆角矩形","阀门","泵","罐体"].includes(b.name))},E=(b,q)=>{b.dataTransfer.effectAllowed="copy",b.dataTransfer.setData("application/json",JSON.stringify(q));const W=b.currentTarget.querySelector(".material-preview");W&&b.dataTransfer.setDragImage(W,20,20)},v=b=>{b.type==="LINE"&&i(b)},I=(b,q=!1)=>{const W=q===!0,F=o==="line-draw"&&W&&a.material?.id===b.id;return e.jsx(t.List.Item,{draggable:!W,onDragStart:L=>E(L,b),onClick:()=>W&&v(b),className:`
|
|
3
3
|
rounded-lg transition-all duration-200 select-none
|
|
4
|
-
${
|
|
4
|
+
${W?"cursor-pointer":"cursor-move"}
|
|
5
5
|
hover:bg-gray-100
|
|
6
|
-
${
|
|
7
|
-
`,actions:[A?e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.EditOutlined,{}),onClick:D=>{D.stopPropagation(),w(b)},children:"绘制"},"draw"):null,e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(L.DeleteOutlined,{}),onClick:D=>{D.stopPropagation(),r(b.id)}},"delete")].filter(Boolean),children:e.jsxs("div",{className:`flex items-center gap-3 w-full py-2 ${A?"":"pointer-events-none"}`,children:[e.jsx("div",{className:"material-preview w-12 h-12 flex items-center justify-center bg-white rounded border border-gray-200",children:b.type==="IMAGE"&&b.src?e.jsx(t.Image,{src:b.src,alt:b.name,width:40,height:40,preview:!1}):b.type==="TEXT"?e.jsx("span",{className:"text-xs text-gray-500",children:"T"}):b.type==="LINE"?e.jsx("div",{className:"w-8 h-0.5 bg-gray-400"}):b.type==="CUSTOM"&&b.config?.nodes?e.jsx("span",{className:"text-xs text-blue-500 font-bold",children:"G"}):e.jsx("span",{className:"text-xs text-gray-500",children:"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(ze,{strong:!0,className:"block truncate",children:b.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ze,{type:"secondary",className:"text-xs",children:b.type}),$&&e.jsx(t.Tag,{color:"blue",className:"text-xs",children:"绘制中"})]})]})]})},b.id)};return e.jsxs("div",{className:"h-full flex flex-col bg-white border-r border-gray-200",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"物料库"}),e.jsx(ze,{type:"secondary",className:"text-sm",children:"拖拽物料到画布创建节点"})]}),e.jsx("div",{className:"p-3 border-b border-gray-200",children:e.jsx(t.Upload,{accept:".svg",beforeUpload:S,showUploadList:!1,children:e.jsx(t.Button,{icon:e.jsx(L.UploadOutlined,{}),block:!0,type:"dashed",children:"上传 SVG"})})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:e.jsxs(t.Collapse,{activeKey:h,onChange:b=>f(b),ghost:!0,expandIconPosition:"end",children:[e.jsx(we,{header:"基础形状",children:e.jsx(t.List,{dataSource:u.basic,renderItem:b=>k(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"basic"),e.jsx(we,{header:"设备图标",children:e.jsx(t.List,{dataSource:u.device,renderItem:b=>k(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"device"),e.jsx(we,{header:"文本",children:e.jsx(t.List,{dataSource:u.text,renderItem:b=>k(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"text"),e.jsxs(we,{header:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"线条"}),o==="line-draw"&&e.jsx(t.Tag,{color:"blue",className:"text-xs",children:"绘制模式"})]}),children:[e.jsx(t.List,{dataSource:u.line,renderItem:b=>k(b,!0),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}}),o==="line-draw"&&e.jsxs("div",{className:"mt-2 p-2 bg-blue-50 rounded text-xs text-blue-600",children:[e.jsx("div",{children:"点击线条物料开始绘制"}),e.jsx("div",{children:"点击画布确定起点和终点"})]})]},"line"),u.group.length>0&&e.jsx(we,{header:"群组",children:e.jsx(t.List,{dataSource:u.group,renderItem:b=>k(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"group"),u.custom.length>0&&e.jsx(we,{header:"自定义",children:e.jsx(t.List,{dataSource:u.custom,renderItem:b=>k(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"custom")]})}),e.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:e.jsx(ze,{type:"secondary",className:"text-xs",children:o==="line-draw"?e.jsx(e.Fragment,{children:"💡 提示:点击绘制线段,可连续绘制多段线,双击结束绘制,ESC 取消"}):e.jsx(e.Fragment,{children:"💡 提示:拖拽物料到画布创建节点,点击线条物料进入绘制模式"})})})]})},{Text:gt}=t.Typography,$t=(l,p)=>{try{const r=p&&Array.isArray(p)?p.map((o,a)=>o.paramsName):["A"],d=new Function(...r,l.expression)(...p.map(o=>o.value));return console.log(`Evaluating status [${l.name}] with data:`,p,"Result:",d),d===!0}catch(r){return console.warn(`状态表达式执行失败 [${l.name}]:`,r),!1}},zt=(l,p)=>{for(const r of l){console.log(r,"status");let n=[];if(Array.isArray(p)?(console.log(r.bindCodes,"bindCodes"),n=p.filter(d=>r.bindCodes?.includes(d.paramsCode))):n=p,$t(r,n))return r}},Ft=(l,p)=>{if(!p||!l)return{value:void 0};if(Array.isArray(l)){const r=l.find(n=>n.paramsCode===p);if(r)return{value:r.value,unit:r.unit}}else if(typeof l=="object"&&p in l)return{value:l[p],unit:l.unit};return{value:void 0}},Pt=(l,p)=>{if(l==null||l==="")return"";if(p===-1)return String(l);const r=Number(l);return isNaN(r)?String(l):r.toFixed(p??2)},Xt=(l,p,r,n)=>{switch(l.type){case"IMAGE":const d=l,o=d.backgroundColor,a=d.fillColor;let i=d.src;return a&&i&&i.includes("data:image/svg+xml")&&(l.name==="矩形"?i=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${a}" rx="4"/></svg>`)}`:l.name==="圆形"?i=`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="${a}"/></svg>`)}`:l.name==="圆角矩形"&&(i=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${a}" rx="20"/></svg>`)}`)),e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",style:{backgroundColor:o},children:i?e.jsx("img",{src:i,alt:l.name,style:{width:"100%",height:"100%",objectFit:"contain"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"无图片"})})});case"TEXT":const m=l,{label:h,value:f,valueSourceCode:S,unit:u,decimals:E,labelStyle:w,valueStyle:k,customStyle:b}=m.content||{},{value:G,unit:A}=S?Ft(p,S):{value:void 0,unit:void 0},D=Pt(G!==void 0?G:f,E),T=u||A||"";return e.jsxs("div",{className:"w-full h-full flex flex-col justify-center gap-1",style:{...b},children:[h&&e.jsx(gt,{style:{fontSize:14,fontWeight:"bold",color:"#262626",textAlign:"left",...w},children:h}),D&&e.jsxs(gt,{style:{fontSize:14,color:"#1890ff",textAlign:"left",...k},children:[D,T?` ${T}`:""]})]});case"LINE":const ue=l,{thickness:ee=2,color:ge="#d9d9d9",dashed:oe=!1,lineType:j=oe?"dashed":"solid",lineWeight:K=ee,startX:H=0,startY:F=0,endX:c=100,endY:V=0}=ue.config||{},Y=(Te=>{const W=Math.max(K,1);switch(Te){case"solid":return"";case"dashed":return`${W*8},${W*4}`;case"center":return`${W*12},${W*3},${W*2},${W*3}`;case"phantom":return`${W*12},${W*3},${W*2},${W*3},${W*2},${W*3}`;case"dot":return`${W},${W*3}`;case"dash-dot":return`${W*8},${W*3},${W},${W*3}`;default:return""}})(j),_=r?"#1890ff":ge;return e.jsx("div",{className:"w-full h-full relative",style:{overflow:"visible"},children:e.jsxs("svg",{className:"absolute top-0 left-0",width:"100%",height:"100%",style:{overflow:"visible",pointerEvents:"none"},children:[e.jsx("line",{x1:H,y1:F,x2:c,y2:V,stroke:"transparent",strokeWidth:Math.max(K,10),strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"stroke",cursor:"pointer"}}),e.jsx("line",{x1:H,y1:F,x2:c,y2:V,stroke:_,strokeWidth:K,strokeDasharray:Y,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none"}})]})});case"CUSTOM":const J=l;return J.render?J.render({}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"自定义组件"})});default:return e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"未知类型"})})}},Ot=({node:l,isSelected:p=!1,onClick:r,onMouseDown:n,data:d,onUpdateNode:o,scale:a=1})=>{const{normalStyle:i,contentInfo:m,controlInfo:h}=l,{statusList:f}=m,{isClickable:S,isDraggable:u,isResizable:E}=h,w=g.useRef(r);g.useEffect(()=>{w.current=r},[r]);const[k,b]=g.useState(null),G=g.useRef(null),A=g.useRef(null),$=g.useRef(null),D=g.useRef(null),[T,ue]=g.useState(null),[ee,ge]=g.useState(null),oe=g.useRef(null),j=g.useMemo(()=>{if(f.length===0)return;const C=zt(f,d);return C||f[0]},[f,d]),K=j?.material,H=K?.type==="LINE",F=H?K.config:null,c=i.scale??1,V=(i.width||100)*c,x=(i.height||100)*c,Y=g.useCallback(()=>{const C=D.current?.closest('[data-canvas="true"]');if(!C)return a;const O=C.getBoundingClientRect(),P=parseFloat(C.style.width);return P?O.width/P:a},[a]),_=g.useCallback((C,O)=>{C.stopPropagation(),C.preventDefault(),G.current={mouseX:C.clientX,mouseY:C.clientY,startX:F?.startX||0,startY:F?.startY||0,endX:F?.endX||0,endY:F?.endY||0,nodeX:i.x||0,nodeY:i.y||0},b(O)},[F,i.x,i.y]);g.useEffect(()=>{if(!k||!H||!F||!o)return;const C=P=>{const M=G.current;if(!M||!D.current)return;const se=Y(),ce=(P.clientX-M.mouseX)/se,re=(P.clientY-M.mouseY)/se;let Q=M.startX,le=M.startY,ne=M.endX,ae=M.endY,xe=M.nodeX,Se=M.nodeY;k==="start"?(Q=M.startX+ce,le=M.startY+re,Q<0&&(xe=M.nodeX+Q,ne=M.endX-Q,Q=0),le<0&&(Se=M.nodeY+le,ae=M.endY-le,le=0)):(ne=M.endX+ce,ae=M.endY+re,ne<0&&(xe=M.nodeX+ne,Q=M.startX-ne,ne=0),ae<0&&(Se=M.nodeY+ae,le=M.startY-ae,ae=0));const Oe=Math.max((F.lineWeight||2)*2,4),Ae=Math.max(Q,ne),je=Math.max(le,ae),Ye=Math.max(Ae,Oe),Ce=Math.max(je,Oe);A.current={nodeX:xe,nodeY:Se,width:Ye,height:Ce,startX:Q,startY:le,endX:ne,endY:ae};const de=D.current;de.style.left=`${xe}px`,de.style.top=`${Se}px`,de.style.width=`${Ye}px`,de.style.height=`${Ce}px`,de.querySelectorAll("svg line").forEach(s=>{s.setAttribute("x1",String(Q)),s.setAttribute("y1",String(le)),s.setAttribute("x2",String(ne)),s.setAttribute("y2",String(ae))});const $e=de.querySelector('[data-handle="start"]'),ye=de.querySelector('[data-handle="end"]');$e&&($e.style.left=`${Q-6}px`,$e.style.top=`${le-6}px`),ye&&(ye.style.left=`${ne-6}px`,ye.style.top=`${ae-6}px`)},O=()=>{const P=A.current;P&&o(l.id,{normalStyle:{...i,x:P.nodeX,y:P.nodeY,width:P.width,height:P.height},contentInfo:{...m,statusList:f.map(M=>({...M,material:M.material.type==="LINE"?{...M.material,config:{...F,startX:P.startX,startY:P.startY,endX:P.endX,endY:P.endY}}:M.material}))}}),b(null),G.current=null,A.current=null};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",O),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",O)}},[k,H,F,l.id,i,m,f,o,Y]),g.useEffect(()=>{if(!T||!o)return;const C=P=>{if(!D.current)return;const M=Y(),se=(P.clientX-T.startX)/M,ce=(P.clientY-T.startY)/M;let re=T.startWidth,Q=T.startHeight,le=T.startNodeX,ne=T.startNodeY;switch(T.corner){case"se":re=Math.max(20,T.startWidth+se),Q=Math.max(20,T.startHeight+ce);break;case"sw":re=Math.max(20,T.startWidth-se),Q=Math.max(20,T.startHeight+ce),le=T.startNodeX+(T.startWidth-re);break;case"ne":re=Math.max(20,T.startWidth+se),Q=Math.max(20,T.startHeight-ce),ne=T.startNodeY+(T.startHeight-Q);break;case"nw":re=Math.max(20,T.startWidth-se),Q=Math.max(20,T.startHeight-ce),le=T.startNodeX+(T.startWidth-re),ne=T.startNodeY+(T.startHeight-Q);break}$.current={x:le,y:ne,width:re,height:Q};const ae=D.current;ae.style.left=`${le}px`,ae.style.top=`${ne}px`,ae.style.width=`${re}px`,ae.style.height=`${Q}px`},O=()=>{const P=$.current;P&&o(l.id,{normalStyle:{...i,x:P.x,y:P.y,width:P.width,height:P.height}}),ue(null),$.current=null};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",O),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",O)}},[T,o,l.id,i,Y]);const J=g.useCallback((C,O)=>{C.stopPropagation(),C.preventDefault(),ue({corner:O,startX:C.clientX,startY:C.clientY,startWidth:i.width||100,startHeight:i.height||100,startNodeX:i.x||0,startNodeY:i.y||0})},[i.width,i.height,i.x,i.y]),Te=g.useCallback(C=>{C.stopPropagation(),C.preventDefault();const O=D.current?.getBoundingClientRect();O&&ge({startX:C.clientX,startY:C.clientY,startAngle:i.rotate||0,centerX:O.left+O.width/2,centerY:O.top+O.height/2})},[i.rotate]);g.useEffect(()=>{if(!ee)return;const C=P=>{const M=P.clientX-ee.centerX,se=P.clientY-ee.centerY;let re=(Math.atan2(se,M)*(180/Math.PI)+90)%360;if(re<0&&(re+=360),oe.current=re,D.current){const Q=i.transform||"";D.current.style.transform=`rotate(${re}deg) ${Q}`.trim()}},O=()=>{const P=oe.current??ee.startAngle;oe.current=null,o&&o(l.id,{normalStyle:{...i,rotate:Math.round(P)}}),ge(null)};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",O),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",O)}},[ee,o,l.id,i]);const W=l.type==="group",Ze={position:"absolute",left:i.x||0,top:i.y||0,width:V,height:x,background:W?"transparent":i.background||"transparent",backgroundImage:W?void 0:i.backgroundImage?`url(${i.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center",padding:Array.isArray(i.padding)?i.padding.join("px ")+"px":i.padding,margin:Array.isArray(i.margin)?i.margin.join("px ")+"px":i.margin,borderRadius:W?void 0:i.borderRadius,border:p&&!H?"2px solid #1890ff":H||W?"none":i.border||"1px dashed transparent",pointerEvents:"auto",opacity:i.opacity??1,transform:`rotate(${oe.current??(i.rotate||0)}deg) ${i.transform||""}`.trim(),transformOrigin:"center center",zIndex:p?1e3:i.zIndex??1,cursor:u&&!k?"move":S?"pointer":"default",boxSizing:"border-box",overflow:p||H||W?"visible":"hidden"},Pe=F?{x:F.startX||0,y:F.startY||0}:{x:0,y:0},Xe=F?{x:F.endX||0,y:F.endY||0}:{x:0,y:0};return e.jsxs("div",{ref:D,"data-node-id":l.id,style:Ze,onClick:C=>{console.log("NodeRenderer onClick",l.id,"isClickable:",S);const O=w.current;S&&O&&!k&&!T&&!ee&&(C.stopPropagation(),O(C))},onMouseDown:C=>{u&&n&&!k&&n(C)},children:[p&&!H&&!W&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"nw-resize",marginTop:"-6px",marginLeft:"-6px"},onMouseDown:C=>J(C,"nw"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"ne-resize",marginTop:"-6px",marginRight:"-6px"},onMouseDown:C=>J(C,"ne"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"sw-resize",marginBottom:"-6px",marginLeft:"-6px"},onMouseDown:C=>J(C,"sw"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"se-resize",marginBottom:"-6px",marginRight:"-6px"},onMouseDown:C=>J(C,"se"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 bg-green-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"grab",marginTop:"-20px",transform:"translateX(-50%)",boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:C=>Te(C),title:"拖拽旋转"}),e.jsx("div",{className:"absolute top-0 left-1/2 w-0.5 h-3 bg-green-500",style:{zIndex:9998,pointerEvents:"none",marginTop:"-14px",transform:"translateX(-50%)"}}),e.jsxs("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:[l.name," ",j?`(${j.name})`:""]})]}),p&&H&&F&&o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-handle":"start",className:"absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",style:{left:Pe.x-6,top:Pe.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:C=>_(C,"start"),title:"拖拽调整起点"}),e.jsx("div",{"data-handle":"end",className:"absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",style:{left:Xe.x-6,top:Xe.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:C=>_(C,"end"),title:"拖拽调整终点"}),e.jsx("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:l.name})]}),e.jsx("div",{className:"w-full h-full relative",children:K?e.jsx("div",{className:"w-full h-full",children:Xt(K,d,p)}):W?null:e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300 text-xs",children:"无状态"})}),l.type==="group"&&l.children&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:l.children.map(C=>e.jsx("div",{className:"pointer-events-auto",children:e.jsx(He,{node:C,isSelected:!1,data:d,onUpdateNode:o,scale:a})},C.id))})]})},He=g.memo(Ot,(l,p)=>{const r=l.node,n=p.node,d=r.id===n.id&&r.normalStyle.x===n.normalStyle.x&&r.normalStyle.y===n.normalStyle.y&&r.normalStyle.width===n.normalStyle.width&&r.normalStyle.height===n.normalStyle.height,o=r.contentInfo===n.contentInfo,a=l.isSelected===p.isSelected&&l.scale===p.scale;return d&&o&&a}),At=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#eb2f96","#13c2c2","#fa8c16","#595959","#262626","#8c8c8c","#d9d9d9","#ffffff","#000000","#ff4d4f","#73d13d"],ve=({value:l="#1890ff",onChange:p,onChangeComplete:r})=>{const[n,d]=g.useState(!1),[o,a]=g.useState(l),i=g.useRef(null);g.useEffect(()=>{a(l)},[l]),g.useEffect(()=>{const h=f=>{i.current&&!i.current.contains(f.target)&&(d(!1),r?.({toHexString:()=>o}))};return n&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,r,o]);const m=h=>{a(h),p?.({toHexString:()=>h})};return e.jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[e.jsx("div",{onClick:()=>d(!n),style:{width:28,height:28,backgroundColor:o,border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer"}}),n&&e.jsxs("div",{style:{position:"absolute",top:32,left:0,zIndex:1e3,background:"#fff",padding:8,borderRadius:4,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",border:"1px solid #f0f0f0"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:4},children:At.map(h=>e.jsx("div",{onClick:()=>{m(h),d(!1),r?.({toHexString:()=>h})},style:{width:20,height:20,backgroundColor:h,border:o===h?"2px solid #1890ff":"1px solid #d9d9d9",borderRadius:2,cursor:"pointer"}},h))}),e.jsx("input",{type:"color",value:o,onChange:h=>m(h.target.value),onBlur:()=>r?.({toHexString:()=>o}),style:{width:"100%",marginTop:8,height:28,border:"1px solid #d9d9d9",borderRadius:4}})]})]})},{TextArea:jt}=t.Input,ft=({defaultTestData:l})=>{const p=g.useRef(null),r=g.useRef(null),n=g.useRef(null),{nodes:d,selectedNodeId:o,mode:a,lineDrawing:i,viewport:m,canvas:h,setViewport:f,setCanvasConfig:S,addNode:u,selectNode:E,updateNode:w,removeNode:k,undo:b,redo:G,setMode:A,startLineDrawing:$,endLineDrawing:D,cancelLineDrawing:T}=me();console.log("selectedNodeId",o);const[ue,ee]=g.useState(!1),[,ge]=g.useState({}),oe=g.useRef(a);g.useEffect(()=>{oe.current=a},[a]);const j=g.useRef(!1),K=g.useRef({x:0,y:0}),H=g.useRef({x:0,y:0,newX:0,newY:0}),F=g.useRef(null),[c,V]=g.useState({start:null,end:null,isDrawing:!1}),[x,Y]=g.useState({start:null,end:null}),[_,J]=g.useState([]);g.useRef(!1);const[Te,W]=g.useState(!1),[Ze,Pe]=g.useState(JSON.stringify(l,null,2)),[Xe,C]=g.useState(!1),[O,P]=g.useState(!1),M=g.useCallback((s,y)=>{if(!r.current)return{x:0,y:0};const N=r.current.getBoundingClientRect(),I=s-N.left,v=y-N.top,z=N.width/h.width,B=N.height/h.height,q=I/z,Z=v/B;return{x:Math.round(q),y:Math.round(Z)}},[h.width,h.height]),se=g.useCallback((s,y)=>M(s,y),[M]),ce=g.useCallback((s,y,N=!0)=>{if(!i.material)return;const I=i.material,v=I.config||{},z=v.lineWeight||v.thickness||2,B=Math.min(s.x,y.x),q=Math.min(s.y,y.y),Z=Math.round(s.x-B),X=Math.round(s.y-q),te=Math.round(y.x-B),ie=Math.round(y.y-q),he=Math.max(z*2,4),Ne=Math.max(Math.abs(s.x-y.x),he),be=Math.max(Math.abs(s.y-y.y),he),We={...I,id:U.nanoid(),config:{color:v.color,lineWeight:z,thickness:z,lineType:v.lineType,startX:Z,startY:X,endX:te,endY:ie}},Rt={id:U.nanoid(),name:`${I.name}_${Date.now()}`,type:"normal",normalStyle:{width:Ne,height:be,x:B,y:q,background:"transparent"},contentInfo:{statusList:[qe(We)],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}};if(u(Rt,!1),N){const xt={x:y.x,y:y.y};V({start:xt,end:{...xt},isDrawing:!0})}else V({start:null,end:null,isDrawing:!1}),D()},[i.material,u,D]),re=g.useCallback(()=>{const s=p.current?.state;s&&f({scale:s.scale,positionX:s.positionX,positionY:s.positionY})},[f]),Q=g.useCallback(s=>{j.current||a!=="box-select"&&(s.target===r.current||s.target.dataset?.canvas==="true")&&(E(null),J([]))},[E,a]),le=g.useCallback(s=>{if(s.button===0){if(a==="line-draw"&&i.material){s.stopPropagation();const y=M(s.clientX,s.clientY);c.isDrawing?c.start&&ce(c.start,y,!0):V({start:y,end:y,isDrawing:!0});return}if(a==="box-select"&&!O){const y=se(s.clientX,s.clientY);Y({start:y,end:y}),J([]),s.preventDefault(),s.stopPropagation()}}},[a,i.material,c.isDrawing,c.start,O,ce,M,se]),ne=g.useCallback(s=>{if(!(a!=="line-draw"||!i.material)&&c.isDrawing&&c.start){const y=M(s.clientX,s.clientY);ce(c.start,y,!1)}},[a,i.material,c.isDrawing,c.start,ce,M]),ae=g.useCallback(s=>{s.preventDefault(),s.dataTransfer.dropEffect="copy",ee(!0)},[]),xe=g.useCallback(s=>{s.preventDefault(),ee(!1)},[]),Se=g.useCallback(s=>{if(s.preventDefault(),ee(!1),!(!r.current||a!=="select"))try{const y=s.dataTransfer.getData("application/json");if(!y)return;const N=JSON.parse(y),I=M(s.clientX,s.clientY),v=I.x-50,z=I.y-50,B=ht(v,z,N);u(B),J([B.id])}catch(y){console.error("Failed to parse dropped material:",y)}},[a,u,M]),Oe=g.useCallback((s,y)=>{a!=="select"&&a!=="box-select"||!y.controlInfo.isDraggable||(s.stopPropagation(),E(y.id),j.current=!0,K.current={x:s.clientX,y:s.clientY},H.current={x:y.normalStyle.x||0,y:y.normalStyle.y||0,newX:y.normalStyle.x||0,newY:y.normalStyle.y||0},F.current=y,s.preventDefault())},[a,E]);g.useEffect(()=>{const s=v=>{if(j.current&&o&&F.current){if(!r.current)return;const z=r.current.getBoundingClientRect(),B=z.width/h.width,q=z.height/h.height,Z=v.clientX-K.current.x,X=v.clientY-K.current.y,te=Z/B,ie=X/q,he=H.current.x+te,Ne=H.current.y+ie,be=document.querySelector(`[data-node-id="${o}"]`);be&&(be.style.left=`${he}px`,be.style.top=`${Ne}px`),H.current.newX=he,H.current.newY=Ne}if(a==="box-select"&&x.start){const z=se(v.clientX,v.clientY);Y(B=>({...B,end:z}))}if(a==="line-draw"&&c.isDrawing){const z=M(v.clientX,v.clientY);V(B=>({...B,end:z}))}},y=()=>{if(j.current&&o&&F.current){const v=me.getState(),z=H.current.newX??H.current.x,B=H.current.newY??H.current.y;v.updateNode(o,{normalStyle:{...F.current.normalStyle,x:z,y:B}})}if(j.current=!1,F.current=null,ge({}),a==="box-select"&&x.start&&x.end){const v=Math.min(x.start.x,x.end.x),z=Math.max(x.start.x,x.end.x),B=Math.min(x.start.y,x.end.y),q=Math.max(x.start.y,x.end.y),Z=d.filter(X=>{const te=X.normalStyle.x||0,ie=X.normalStyle.y||0,he=X.normalStyle.width||0,Ne=X.normalStyle.height||0,be=te+he/2,We=ie+Ne/2;return be>=v&&be<=z&&We>=B&&We<=q}).map(X=>X.id);J(Z),Y({start:null,end:null})}},N=v=>{v.key==="Escape"&&a==="line-draw"&&(V({start:null,end:null,isDrawing:!1}),T()),v.key==="Delete"&&(o?k(o):_.length>0&&(_.forEach(z=>k(z)),J([]))),v.ctrlKey&&v.key==="z"&&(v.preventDefault(),b()),v.ctrlKey&&v.key==="y"&&(v.preventDefault(),G()),v.key===" "&&!O&&(v.preventDefault(),P(!0))},I=v=>{v.key===" "&&O&&P(!1)};return window.addEventListener("mousemove",s),window.addEventListener("mouseup",y),window.addEventListener("keydown",N),window.addEventListener("keyup",I),()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",y),window.removeEventListener("keydown",N),window.removeEventListener("keyup",I)}},[o,x,a,c.isDrawing,_,d,h.width,h.height,k,b,O,G,T,M,se,J]);const Ae=g.useCallback(()=>{const s=_.length>0?_.map(N=>d.find(I=>I.id===N)).filter(Boolean):o?[d.find(N=>N.id===o)].filter(Boolean):[];if(s.length===0)return;const y=[];s.forEach(N=>{const I={...N,id:U.nanoid(),name:`${N.name}_副本`,normalStyle:{...N.normalStyle,x:(N.normalStyle.x||0)+20,y:(N.normalStyle.y||0)+20}};u(I),y.push(I.id)}),y.length===1?E(y[0]):J(y)},[o,_,d,u,E,J]),je=g.useCallback(()=>{if(_.length<2)return;const s=[];for(let q=0;q<_.length;q++){const Z=_[q],X=d.find(te=>te.id===Z);if(X){if(X?.type==="group"){X.children.forEach(ie=>s.push({...ie,normalStyle:{...ie.normalStyle,x:(X.normalStyle.x||0)+(ie.normalStyle.x||0),y:(X.normalStyle.y||0)+(ie.normalStyle.y||0)}})),k(Z);continue}s.push(X)}}if(s.length<2)return;let y=1/0,N=1/0,I=-1/0,v=-1/0;s.forEach(q=>{const Z=q.normalStyle.x||0,X=q.normalStyle.y||0,te=q.normalStyle.width||0,ie=q.normalStyle.height||0;y=Math.min(y,Z),N=Math.min(N,X),I=Math.max(I,Z+te),v=Math.max(v,X+ie)});const z=s.map(q=>({...q,normalStyle:{...q.normalStyle,x:(q.normalStyle.x||0)-y,y:(q.normalStyle.y||0)-N}})),B={id:U.nanoid(),name:`群组_${Date.now()}`,type:"group",normalStyle:{x:y,y:N,width:I-y,height:v-N,background:"transparent"},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:z};_.forEach(q=>k(q)),u(B),J([]),E(B.id)},[_,d,k,u,E]),Ye=g.useCallback(()=>{const s=_.length>0?_.map(y=>d.find(N=>N.id===y)).filter(y=>!!y&&y.type==="group"):o?[d.find(y=>y.id===o)].filter(y=>!!y&&y.type==="group"):[];s.length!==0&&(s.forEach(y=>{if(!y.children||y.children.length===0)return;const N=y.children.map(I=>({...I,normalStyle:{...I.normalStyle,x:(y.normalStyle.x||0)+(I.normalStyle.x||0),y:(y.normalStyle.y||0)+(I.normalStyle.y||0)}}));k(y.id),N.forEach(I=>u(I))}),J([]),E(null))},[o,_,d,k,u,E,J]),Ce=g.useCallback(s=>{if(_.length<2)return;const y=_.map(Z=>d.find(X=>X.id===Z)).filter(Z=>!!Z&&Z.type!=="group");if(y.length<2)return;let N=1/0,I=-1/0,v=1/0,z=-1/0;y.forEach(Z=>{const X=Z.normalStyle.x||0,te=Z.normalStyle.y||0;N=Math.min(N,X),I=Math.max(I,X),v=Math.min(v,te),z=Math.max(z,te)});const B=[...y].sort((Z,X)=>s==="horizontal"?(Z.normalStyle.x||0)-(X.normalStyle.x||0):(Z.normalStyle.y||0)-(X.normalStyle.y||0)),q=B.length;if(s==="horizontal"){const X=(I-N)/(q-1);B.forEach((te,ie)=>{const he=N+X*ie;w(te.id,{normalStyle:{...te.normalStyle,x:he}})})}else{const X=(z-v)/(q-1);B.forEach((te,ie)=>{const he=v+X*ie;w(te.id,{normalStyle:{...te.normalStyle,y:he}})})}},[_,d,w]),de=g.useCallback(s=>{if(_.length<2)return;const y=me.getState(),N=_.map(v=>d.find(z=>z.id===v)).filter(v=>!!v);if(N.length<2)return;let I=0;switch(s){case"left":I=Math.min(...N.map(v=>v.normalStyle.x||0));break;case"right":I=Math.max(...N.map(v=>(v.normalStyle.x||0)+(v.normalStyle.width||0)));break;case"top":I=Math.min(...N.map(v=>v.normalStyle.y||0));break;case"bottom":I=Math.max(...N.map(v=>(v.normalStyle.y||0)+(v.normalStyle.height||0)));break}N.forEach(v=>{let z=v.normalStyle.x||0,B=v.normalStyle.y||0;switch(s){case"left":z=I;break;case"right":z=I-(v.normalStyle.width||0);break;case"top":B=I;break;case"bottom":B=I-(v.normalStyle.height||0);break}y.updateNode(v.id,{normalStyle:{...v.normalStyle,x:z,y:B}})})},[_,d]),vt=[{icon:e.jsx(L.SelectOutlined,{}),title:"选择模式",active:a==="select",onClick:()=>{A("select")}},{icon:e.jsx(L.GroupOutlined,{}),title:"框选模式",active:a==="box-select",onClick:()=>{A("box-select"),J([])}},{icon:e.jsx(L.DragOutlined,{}),title:"拖拽模式",active:a==="drag",onClick:()=>{A("drag")}},{icon:e.jsx(L.EditOutlined,{}),title:"线条绘制",active:a==="line-draw",onClick:()=>{A("line-draw")}},{icon:e.jsx(L.EyeOutlined,{}),title:"预览模式",active:a==="preview",onClick:()=>{A("preview")}}],$e=g.useMemo(()=>[{icon:e.jsx(L.UndoOutlined,{}),title:"撤销 (Ctrl+Z)",onClick:b},{icon:e.jsx(L.RedoOutlined,{}),title:"重做 (Ctrl+Y)",onClick:G},{icon:e.jsx(L.CopyOutlined,{}),title:"复制节点",disabled:!o&&_.length===0,onClick:Ae},{icon:e.jsx(L.GroupOutlined,{}),title:"组合选中节点",disabled:_.length<2,onClick:je},{icon:e.jsx(L.UngroupOutlined,{}),title:"解除组合",disabled:!o&&_.length===0,onClick:Ye},{icon:e.jsx(L.AlignLeftOutlined,{}),title:"左对齐",disabled:_.length<2,onClick:()=>de("left")},{icon:e.jsx(L.AlignRightOutlined,{}),title:"右对齐",disabled:_.length<2,onClick:()=>de("right")},{icon:e.jsx(L.VerticalAlignTopOutlined,{}),title:"上对齐",disabled:_.length<2,onClick:()=>de("top")},{icon:e.jsx(L.VerticalAlignBottomOutlined,{}),title:"下对齐",disabled:_.length<2,onClick:()=>de("bottom")},{icon:e.jsx(L.ColumnWidthOutlined,{}),title:"水平分布",disabled:_.length<2,onClick:()=>Ce("horizontal")},{icon:e.jsx(L.ColumnHeightOutlined,{}),title:"垂直分布",disabled:_.length<2,onClick:()=>Ce("vertical")},{icon:e.jsx(L.SettingOutlined,{}),title:"画布配置",onClick:()=>C(!0)},{icon:e.jsx(L.ExperimentOutlined,{}),title:"数据模拟",type:"primary",onClick:()=>W(!0)},{icon:e.jsx(L.DeleteOutlined,{}),title:"删除选中 (Delete)",disabled:!o&&_.length===0,onClick:()=>{o?k(o):_.length>0&&(_.forEach(s=>k(s)),J([]))}}],[b,G,a,A,J,_,je,Ye,Ae,de,Ce,C,W,o,k]),ye=g.useCallback(s=>{s.preventDefault(),(s.key==="ArrowLeft"||s.key==="ArrowRight"||s.key==="ArrowUp"||s.key==="ArrowDown")&&_.map(N=>d.find(I=>I.id===N)).forEach(N=>{N&&w(N.id,{normalStyle:{...N.normalStyle,x:(N.normalStyle.x||0)-2*(s.key==="ArrowLeft"?1:s.key==="ArrowRight"?-1:0),y:(N.normalStyle.y||0)-2*(s.key==="ArrowUp"?1:s.key==="ArrowDown"?-1:0)}})})},[_,d,w]);return g.useEffect(()=>(document.addEventListener("keydown",ye),()=>{document.removeEventListener("keydown",ye)}),[ye]),e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-gray-100",children:[e.jsxs("div",{className:"h-12 bg-white border-b border-gray-200 flex items-center justify-between px-4",children:[e.jsx(t.Space,{children:vt.map(s=>e.jsx(t.Tooltip,{title:s.title,children:e.jsx(t.Button,{type:s.active?"primary":"default",icon:s.icon,onClick:s.onClick})},s.title))}),e.jsx(t.Space,{children:$e.map(s=>e.jsx(t.Tooltip,{title:s.title,children:e.jsx(t.Button,{type:s.active?"primary":s.type||"default",icon:s.icon,onClick:s.onClick,disabled:s.disabled})},s.title))})]}),e.jsx("div",{ref:n,className:"flex-1 relative",children:e.jsx(Je.TransformWrapper,{ref:p,initialScale:1,initialPositionX:0,initialPositionY:0,minScale:.5,maxScale:5,onTransformed:re,limitToBounds:!1,centerZoomedOut:!1,panning:{disabled:!O&&(a==="select"||a==="line-draw"||a==="box-select"),velocityDisabled:!0},wheel:{disabled:!1,step:.1},pinch:{disabled:!1},doubleClick:{disabled:!0},children:({zoomIn:s,zoomOut:y,resetTransform:N})=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute bottom-4 right-4 z-10 bg-white rounded-lg shadow-lg p-2",children:e.jsxs(t.Space,{direction:"vertical",children:[e.jsx(t.Tooltip,{title:"放大",children:e.jsx(t.Button,{icon:e.jsx(L.ZoomInOutlined,{}),onClick:()=>s()})}),e.jsx(t.Tooltip,{title:"缩小",children:e.jsx(t.Button,{icon:e.jsx(L.ZoomOutOutlined,{}),onClick:()=>y()})}),e.jsx(t.Tooltip,{title:"重置视图",children:e.jsx(t.Button,{onClick:()=>N(),children:"100%"})}),e.jsxs("div",{className:"text-center text-xs text-gray-500",children:[Math.round(m.scale*100),"%"]})]})}),e.jsx(Je.TransformComponent,{wrapperStyle:{width:"100%",height:"100%",position:"relative"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{ref:r,"data-canvas":"true",className:`relative ${ue?"ring-4 ring-blue-400 ring-opacity-50":""} ${a==="line-draw"?"cursor-crosshair":""} ${O?"cursor-grab":""}`,style:{width:h.width,height:h.height,flexShrink:0,backgroundColor:h.background,backgroundImage:h.backgroundImage?`url(${h.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},onClick:Q,onMouseDown:le,onDoubleClick:ne,onDragOver:ae,onDragLeave:xe,onDrop:Se,children:[h.showGrid!==!1&&e.jsxs("svg",{className:"absolute top-0 left-0 pointer-events-none",width:h.width,height:h.height,children:[e.jsx("defs",{children:e.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M 20 0 L 0 0 0 20",fill:"none",stroke:"#f0f0f0",strokeWidth:"1"})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#grid)"})]}),d.map(I=>e.jsx(He,{node:I,isSelected:o===I.id||_.includes(I.id),data:l,onClick:v=>{console.log("Node onClick:",I.id,"mode:",oe.current),oe.current!=="line-draw"&&(v.shiftKey?(E(I.id),J([..._,I.id])):(E(I.id),J([I.id])))},onMouseDown:v=>Oe(v,I),onUpdateNode:(v,z)=>w(v,z),scale:m.scale},`${I.id}`)),a==="line-draw"&&c.isDrawing&&c.start&&c.end&&e.jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",width:h.width,height:h.height,children:e.jsx("line",{x1:c.start.x,y1:c.start.y,x2:c.end.x,y2:c.end.y,stroke:"#1890ff",strokeWidth:"2",strokeDasharray:"5,5",strokeLinecap:"round",strokeLinejoin:"round"})}),a==="box-select"&&x.start&&x.end&&e.jsx("div",{className:"absolute border-2 border-blue-500 bg-blue-500/10 pointer-events-none",style:{left:Math.min(x.start.x,x.end.x),top:Math.min(x.start.y,x.end.y),width:Math.abs(x.end.x-x.start.x),height:Math.abs(x.end.y-x.start.y),zIndex:9999}})]})})]})})}),e.jsx(t.Modal,{title:"数据模拟",open:Te,onCancel:()=>W(!1),footer:null,children:e.jsx(t.Form,{layout:"vertical",children:e.jsx(t.Form.Item,{label:"测试数据 (JSON)",children:e.jsx(jt,{value:Ze,onChange:s=>Pe(s.target.value),rows:10,placeholder:"输入 JSON 格式的测试数据"})})})}),e.jsx(t.Modal,{title:"画布配置",open:Xe,onCancel:()=>C(!1),footer:null,children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"宽度",children:e.jsx(t.InputNumber,{value:h.width,onChange:s=>S({width:s||1920}),min:100,max:5e3,style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"高度",children:e.jsx(t.InputNumber,{value:h.height,onChange:s=>S({height:s||1080}),min:100,max:5e3,style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"显示网格",children:e.jsx(t.Switch,{checked:h.showGrid!==!1,onChange:s=>S({showGrid:s})})}),e.jsx(t.Form.Item,{label:"背景色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:h.background||"#ffffff",onChange:s=>S({background:s.toHexString()})}),e.jsx(t.Input,{value:h.background,onChange:s=>S({background:s.target.value}),placeholder:"#ffffff"})]})}),e.jsxs(t.Form.Item,{label:"背景图片",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Upload,{accept:"image/*",showUploadList:!1,beforeUpload:s=>{if(!s.type.startsWith("image/"))return t.message.error("只能上传图片文件!"),!1;const N=new FileReader;return N.onload=I=>{const v=I.target?.result;S({backgroundImage:v}),t.message.success("背景图片上传成功")},N.readAsDataURL(s),!1},children:e.jsx(t.Button,{icon:e.jsx(L.UploadOutlined,{}),children:"上传图片"})}),e.jsx(t.Input,{value:h.backgroundImage,onChange:s=>S({backgroundImage:s.target.value}),placeholder:"输入图片 URL 或上传图片",style:{flex:1}}),h.backgroundImage&&e.jsx(t.Button,{icon:e.jsx(L.CloseOutlined,{}),onClick:()=>S({backgroundImage:void 0}),danger:!0,size:"small"})]}),h.backgroundImage&&e.jsx("div",{className:"mt-2 p-2 border rounded",style:{maxWidth:"100%"},children:e.jsx("img",{src:h.backgroundImage,alt:"背景预览",style:{maxWidth:"100%",maxHeight:120,objectFit:"contain"}})})]})]})})]})},{Option:Fe}=t.Select,Wt=({material:l,onSave:p,bindCodes:r=[],dataOptions:n=[]})=>{const o=l.content||{},[a,i]=g.useState({label:o.label||"",value:o.value||"",valueSourceCode:o.valueSourceCode||"",unit:o.unit||"",decimals:o.decimals??2,labelFontSize:o.labelStyle?.fontSize||14,labelFontWeight:o.labelStyle?.fontWeight||"bold",labelColor:o.labelStyle?.color||"#262626",valueFontSize:o.valueStyle?.fontSize||14,valueFontWeight:o.valueStyle?.fontWeight||"normal",valueColor:o.valueStyle?.color||"#1890ff"});g.useEffect(()=>{i({label:o.label||"",value:o.value||"",valueSourceCode:o.valueSourceCode||"",unit:o.unit||"",decimals:o.decimals??2,labelFontSize:o.labelStyle?.fontSize||14,labelFontWeight:o.labelStyle?.fontWeight||"bold",labelColor:o.labelStyle?.color||"#262626",valueFontSize:o.valueStyle?.fontSize||14,valueFontWeight:o.valueStyle?.fontWeight||"normal",valueColor:o.valueStyle?.color||"#1890ff"})},[l.id]);const m=(u,E)=>{i(w=>({...w,[u]:E}))},h=u=>{const E=n.find(k=>k.paramsCode===u),w=E?.unit||"";i(k=>({...k,valueSourceCode:u,unit:w,value:String(E?.value||"")})),setTimeout(()=>{p({content:{...o,valueSourceCode:u,value:String(E?.value||""),unit:w}})},0)},f=()=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:a.labelColor},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:a.valueColor}}})},S=n.filter(u=>r.includes(u.paramsCode));return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"文本内容"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"标签文本 (label)",children:e.jsx(t.Input,{value:a.label,onChange:u=>m("label",u.target.value),onBlur:f,placeholder:"输入标签文本"})}),e.jsx(t.Form.Item,{label:"值来源",help:"从绑定的数据中选择字段,优先级高于手动输入的值",children:e.jsx(t.Select,{value:a.valueSourceCode||void 0,onChange:h,placeholder:"选择数据字段(可选)",allowClear:!0,style:{width:"100%"},fieldNames:{value:"paramsCode",label:"paramsName"},options:S})}),e.jsx(t.Form.Item,{label:a.valueSourceCode?"默认值(备用)":"值文本",help:a.valueSourceCode?"已绑定数据源,实际值将来自数据字段,此处仅设置无数据时的备用显示":"手动输入显示的值",children:e.jsx(t.Input,{value:a.value,onChange:u=>m("value",u.target.value),onBlur:f,placeholder:a.valueSourceCode?"数据字段无值时显示此备用值":"输入值文本",disabled:!!a.valueSourceCode,variant:a.valueSourceCode?"filled":void 0})}),e.jsx(t.Form.Item,{label:"单位",help:"优先从绑定数据自动获取,也可手动输入",children:e.jsx(t.Input,{value:a.unit,onChange:u=>m("unit",u.target.value),onBlur:f,placeholder:"单位(如°C、%、MPa等)",suffix:a.valueSourceCode&&S.length>0?e.jsx(t.Tag,{color:"blue",style:{marginRight:-8},children:"自动"}):null})}),e.jsx(t.Form.Item,{label:"保留小数位",help:"数值格式化时保留的小数位数,-1表示不格式化",children:e.jsx(t.InputNumber,{value:a.decimals,onChange:u=>m("decimals",u??2),onBlur:f,min:-1,max:10,style:{width:"100%"}})})]}),e.jsx(t.Divider,{children:"标签样式"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"字体大小",children:e.jsx(t.InputNumber,{value:a.labelFontSize,onChange:u=>m("labelFontSize",u||14),onBlur:f,min:8,max:72})}),e.jsx(t.Form.Item,{label:"字体粗细",children:e.jsxs(t.Select,{value:a.labelFontWeight,onChange:u=>{m("labelFontWeight",u),setTimeout(f,0)},style:{width:100},children:[e.jsx(Fe,{value:"normal",children:"正常"}),e.jsx(Fe,{value:"bold",children:"粗体"})]})})]}),e.jsx(t.Form.Item,{label:"文字颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:a.labelColor||"#262626",onChange:u=>{m("labelColor",u.toHexString())},onChangeComplete:u=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:u.toHexString()},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:a.valueColor}}})}}),e.jsx(t.Input,{value:a.labelColor,onChange:u=>m("labelColor",u.target.value),onBlur:f,placeholder:"#262626",style:{width:100}})]})})]}),e.jsx(t.Divider,{children:"值样式"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"字体大小",children:e.jsx(t.InputNumber,{value:a.valueFontSize,onChange:u=>m("valueFontSize",u||14),onBlur:f,min:8,max:72})}),e.jsx(t.Form.Item,{label:"字体粗细",children:e.jsxs(t.Select,{value:a.valueFontWeight,onChange:u=>{m("valueFontWeight",u),setTimeout(f,0)},style:{width:100},children:[e.jsx(Fe,{value:"normal",children:"正常"}),e.jsx(Fe,{value:"bold",children:"粗体"})]})})]}),e.jsx(t.Form.Item,{label:"文字颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:a.valueColor||"#1890ff",onChange:u=>{m("valueColor",u.toHexString())},onChangeComplete:u=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:a.labelColor},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:u.toHexString()}}})}}),e.jsx(t.Input,{value:a.valueColor,onChange:u=>m("valueColor",u.target.value),onBlur:f,placeholder:"#1890ff",style:{width:100}})]})})]})]})},Bt=({material:l,onSave:p})=>{const r=l,[n,d]=g.useState({name:l.name,src:r.src||"",backgroundColor:r.backgroundColor||"",fillColor:r.fillColor||""});g.useEffect(()=>{d({name:l.name,src:r.src||"",backgroundColor:r.backgroundColor||"",fillColor:r.fillColor||""})},[l.id]);const o=(i,m)=>{d(h=>({...h,[i]:m}))},a=()=>{p({name:n.name,src:n.src,backgroundColor:n.backgroundColor})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"图片属性"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"图片名称",children:e.jsx(t.Input,{value:n.name,onChange:i=>o("name",i.target.value),onBlur:a})}),e.jsx(t.Form.Item,{label:"图片地址 (src)",children:e.jsx(t.Input.TextArea,{value:n.src,onChange:i=>o("src",i.target.value),onBlur:a,rows:4,placeholder:"输入图片 URL 或 Data URI"})}),e.jsx(t.Form.Item,{label:"填充颜色(基本形状)",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.fillColor||"#1890ff",onChange:i=>{const m=i.toHexString();o("fillColor",m),p({name:n.name,src:n.src,backgroundColor:n.backgroundColor,fillColor:m})}}),e.jsx(t.Input,{value:n.fillColor,onChange:i=>o("fillColor",i.target.value),onBlur:a,placeholder:"#1890ff"})]})}),e.jsx(t.Form.Item,{label:"背景颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.backgroundColor||"#1890ff",onChange:i=>{const m=i.toHexString();o("backgroundColor",m),p({name:n.name,src:n.src,backgroundColor:m,fillColor:n.fillColor})}}),e.jsx(t.Input,{value:n.backgroundColor,onChange:i=>o("backgroundColor",i.target.value),onBlur:a,placeholder:"#1890ff"})]})})]})]})},{Option:Ut}=t.Select,Gt=({material:l,onSave:p})=>{const r=l.config||{},[n,d]=g.useState({lineWeight:r.lineWeight||r.thickness||2,color:r.color||"#262626",lineType:r.lineType||"solid",startX:r.startX??0,startY:r.startY??0,endX:r.endX??100,endY:r.endY??0});g.useEffect(()=>{d({lineWeight:r.lineWeight||r.thickness||2,color:r.color||"#262626",lineType:r.lineType||"solid",startX:r.startX??0,startY:r.startY??0,endX:r.endX??100,endY:r.endY??0})},[l.id]);const o=i=>{const m={...n,...i};d(m),p({config:{...r,thickness:m.lineWeight,lineWeight:m.lineWeight,color:m.color,lineType:m.lineType,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY}})},a=[{value:"solid",label:"实线",desc:"连续实线"},{value:"dashed",label:"虚线",desc:"长划间隔"},{value:"center",label:"点画线(中心线)",desc:"长点-短点交替"},{value:"phantom",label:"假想线",desc:"长划-双点交替"},{value:"dot",label:"点线",desc:"密集点状"},{value:"dash-dot",label:"画点线",desc:"长划-点交替"}];return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"起止位置(相对节点)"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(t.Form.Item,{label:"起点 X",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.startX,onChange:i=>o({startX:i??0}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"起点 Y",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.startY,onChange:i=>o({startY:i??0}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"终点 X",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.endX,onChange:i=>o({endX:i??100}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"终点 Y",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.endY,onChange:i=>o({endY:i??0}),style:{width:"100%"}})})]}),e.jsx(t.Form.Item,{label:"快速对齐",className:"mt-4",children:e.jsxs(t.Space,{children:[e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startY??n.startY;o({endY:i})},title:"将线条变为水平线",children:"水平"}),e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startX??n.startX;o({endX:i})},title:"将线条变为垂直线",children:"垂直"}),e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startX??n.startX,m=r.startY??n.startY,h=r.endX??n.endX,f=r.endY??n.endY;o({startX:h,startY:f,endX:i,endY:m})},title:"交换起点和终点",children:"反向"})]})})]}),e.jsx(t.Divider,{children:"线条属性"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"线型",help:"选择线条样式",children:e.jsx(t.Select,{value:n.lineType,onChange:i=>o({lineType:i}),children:a.map(i=>e.jsx(Ut,{value:i.value,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"text-xs text-gray-400",children:i.desc})]})},i.value))})}),e.jsx(t.Form.Item,{label:"线宽(像素)",children:e.jsx(t.InputNumber,{value:n.lineWeight,onChange:i=>o({lineWeight:i||2}),min:1,max:20,style:{width:120}})}),e.jsx(t.Form.Item,{label:"颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.color||"#d9d9d9",onChange:i=>o({color:i.toHexString()})}),e.jsx(t.Input,{value:n.color,onChange:i=>o({color:i.target.value}),placeholder:"#d9d9d9",style:{width:100}})]})})]})]})},pt=({material:l,onSave:p,bindCodes:r,dataOptions:n})=>{switch(l.type){case"TEXT":return e.jsx(Wt,{material:l,onSave:p,bindCodes:r,dataOptions:n});case"IMAGE":return e.jsx(Bt,{material:l,onSave:p});case"LINE":return e.jsx(Gt,{material:l,onSave:p});default:return e.jsx("div",{className:"text-center text-gray-400 py-8",children:"暂不支持编辑此类型的物料"})}},{Panel:bt}=t.Collapse,{TextArea:qt}=t.Input,Ht=({node:l,updateNode:p,materials:r})=>{const n=r.filter(f=>f.type!=="CUSTOM"||!f.config?.nodes),d=(f,S)=>{const u=l.children?.map(E=>E.id===f?{...E,contentInfo:{...E.contentInfo,statusList:S}}:E);p(l.id,{children:u})},o=f=>{const S=l.children?.find(E=>E.id===f);if(!S)return;const u={id:U.nanoid(),name:`状态${S.contentInfo.statusList.length+1}`,expression:S.contentInfo.statusList.length===0?"return true;":"return false;",material:{...n[0],id:U.nanoid()},bindCodes:[]};d(f,[...S.contentInfo.statusList,u])},a=(f,S)=>{const u=l.children?.find(w=>w.id===f);if(!u)return;const E=u.contentInfo.statusList.filter(w=>w.id!==S);d(f,E)},i=(f,S,u)=>{const E=l.children?.find(k=>k.id===f);if(!E)return;const w=E.contentInfo.statusList.map(k=>k.id===S?{...k,...u}:k);d(f,w)},m=(f,S,u)=>{const E=l.children?.find(b=>b.id===f);if(!E)return;const w=E.contentInfo.statusList.findIndex(b=>b.id===S);if(w===-1)return;const k=[...E.contentInfo.statusList];u==="up"&&w>0?[k[w],k[w-1]]=[k[w-1],k[w]]:u==="down"&&w<k.length-1&&([k[w],k[w+1]]=[k[w+1],k[w]]),d(f,k)},h=(f,S,u)=>{const E=r.find(w=>w.id===u);E&&i(f,S,{material:{...E,id:U.nanoid()}})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg mb-4",children:e.jsxs("div",{className:"text-sm text-blue-700",children:[e.jsx("strong",{children:"群组节点"}),":为每个子节点配置多个状态和绑定"]})}),e.jsx(t.Collapse,{ghost:!0,children:l.children?.map((f,S)=>e.jsx(bt,{header:e.jsxs("div",{className:"flex items-center justify-between w-full pr-4",children:[e.jsxs("span",{className:"font-medium text-sm",children:["子节点 ",S+1]}),e.jsxs(t.Tag,{color:"blue",style:{fontSize:"12px",padding:"0 4px"},children:[f.contentInfo.statusList.length," 个状态"]})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"状态列表"}),e.jsx(t.Button,{type:"primary",size:"small",icon:e.jsx(L.PlusOutlined,{}),onClick:()=>o(f.id),children:"添加状态"})]}),f.contentInfo.statusList.length===0?e.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):e.jsx(t.Collapse,{ghost:!0,children:f.contentInfo.statusList.map((u,E)=>e.jsx(bt,{header:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400 w-5",children:E+1}),e.jsx("span",{className:"font-medium",children:u.name}),e.jsx(t.Tag,{color:"default",className:"text-xs",children:u.material.type})]}),extra:e.jsxs(t.Space,{size:"small",onClick:w=>w.stopPropagation(),children:[e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.ArrowUpOutlined,{}),disabled:E===0,onClick:w=>{w.stopPropagation(),m(f.id,u.id,"up")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.ArrowDownOutlined,{}),disabled:E===f.contentInfo.statusList.length-1,onClick:w=>{w.stopPropagation(),m(f.id,u.id,"down")}}),e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(L.DeleteOutlined,{}),onClick:w=>{w.stopPropagation(),a(f.id,u.id)}})]}),children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"状态名称",children:e.jsx(t.Input,{value:u.name,onChange:w=>i(f.id,u.id,{name:w.target.value}),placeholder:"输入状态名称"})}),e.jsx(t.Form.Item,{label:"执行表达式",help:"返回 true 时激活此状态,可使用 data 变量访问绑定数据",children:e.jsx(qt,{value:u.expression,onChange:w=>i(f.id,u.id,{expression:w.target.value}),rows:3,placeholder:"return true;"})}),e.jsx(t.Form.Item,{label:"绑定数据源 (bindCodes)",children:e.jsx(t.Select,{mode:"tags",value:u.bindCodes||[],onChange:w=>i(f.id,u.id,{bindCodes:w}),placeholder:"输入数据源 code",tokenSeparators:[","," "]})}),e.jsx(t.Form.Item,{label:"更换物料",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Tag,{color:"blue",children:u.material.name}),e.jsx(t.Tag,{color:"default",children:u.material.type}),e.jsx(t.Select,{placeholder:"选择新物料",style:{width:150},value:void 0,onChange:w=>w&&h(f.id,u.id,w),options:n.map(w=>({value:w.id,label:`${w.name} (${w.type})`}))})]})}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),e.jsx(t.Tag,{children:u.material.name})]}),e.jsx(pt,{material:u.material,onSave:w=>{const k={...u.material,...w};i(f.id,u.id,{material:k})}})]})]})},u.id))})]})},f.id))})]})},{Panel:pe}=t.Collapse,{TabPane:Ve}=t.Tabs,{TextArea:Vt}=t.Input,mt=({defaultTestData:l})=>{const{nodes:p,selectedNodeId:r,updateNode:n,updateNodeStyle:d,updateNodeControl:o,updateNodeContent:a,materials:i,selectedStatusId:m,selectStatus:h}=me(),[f]=t.Form.useForm(),[S,u]=g.useState("basic"),[E,w]=g.useState(!1),[k,b]=g.useState(null),[G,A]=g.useState({}),$=g.useMemo(()=>p.find(c=>c.id===r),[p,r]),D=$?.contentInfo.statusList||[],T=c=>{r&&(c.normalStyle&&d(r,c.normalStyle),c.name!==void 0&&n(r,{name:c.name}),c.controlInfo&&o(r,c.controlInfo))};console.log(r,"selectedNodeId",$),g.useEffect(()=>{$&&$&&(f.setFieldsValue({name:$.name,normalStyle:{width:100,height:100,x:0,y:0,padding:8,background:"transparent",borderRadius:0,opacity:1,...$.normalStyle},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0,...$.controlInfo}}),h(null))},[$,h,f]);const ue=()=>{!r||!$||(b("new"),w(!0))},ee=c=>{if(!r||!$)return;const V={id:U.nanoid(),name:`${c.name}_状态${D.length+1}`,expression:D.length===0?"return true;":"return false;",material:{...c,id:U.nanoid()},bindCodes:[]};if(k==="new"){const x=[...D,V];a(r,{statusList:x})}else if(k){const x=D.map(Y=>Y.id===k?{...Y,material:{...c,id:U.nanoid()}}:Y);a(r,{statusList:x})}w(!1),b(null)},ge=c=>{if(!r||!$)return;const V=$.contentInfo.statusList?.filter(x=>x.id!==c)||[];a(r,{statusList:V}),m===c&&h(null)},oe=(c,V)=>{if(!r||!$)return;const x=$.contentInfo.statusList?.map(Y=>Y.id===c?{...Y,...V}:Y)||[];a(r,{statusList:x})},j=c=>{if(!r||!$)return;const V={...c,id:U.nanoid(),name:`${c.name}_复制`,expression:"return false;"},x=[...D,V];a(r,{statusList:x})},K=(c,V)=>{if(!r||!$)return;const x=D.findIndex(_=>_.id===c);if(x===-1)return;const Y=[...D];V==="up"&&x>0?[Y[x],Y[x-1]]=[Y[x-1],Y[x]]:V==="down"&&x<Y.length-1&&([Y[x],Y[x+1]]=[Y[x+1],Y[x]]),a(r,{statusList:Y})},H=c=>{b(c),w(!0)},F=(c,V)=>{if(!r||!$)return;const x=D.map(Y=>Y.id===c?{...Y,material:{...Y.material,...V}}:Y);a(r,{statusList:x})};return $?e.jsxs("div",{className:"h-full flex flex-col bg-white border-l border-gray-200",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"属性面板"}),e.jsx("p",{className:"text-sm text-gray-500",children:"编辑选中节点的属性"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsxs(t.Tabs,{activeKey:S,onChange:u,children:[e.jsx(Ve,{tab:"基础",children:e.jsxs(t.Form,{form:f,layout:"vertical",onValuesChange:T,initialValues:{name:$.name},children:[e.jsx(t.Form.Item,{label:"节点名称",name:"name",children:e.jsx(t.Input,{placeholder:"输入节点名称"})}),e.jsxs(t.Collapse,{ghost:!0,defaultActiveKey:["position","size","style"],children:[e.jsx(pe,{header:"位置",children:e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"X",name:["normalStyle","x"],children:e.jsx(t.InputNumber,{})}),e.jsx(t.Form.Item,{label:"Y",name:["normalStyle","y"],children:e.jsx(t.InputNumber,{})})]})},"position"),e.jsx(pe,{header:"尺寸",children:e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"宽度",name:["normalStyle","width"],children:e.jsx(t.InputNumber,{min:10})}),e.jsx(t.Form.Item,{label:"高度",name:["normalStyle","height"],children:e.jsx(t.InputNumber,{min:10})})]})},"size"),e.jsxs(pe,{header:"样式",children:[e.jsx(t.Form.Item,{label:"背景色",name:["normalStyle","background"],children:e.jsx(t.Input,{placeholder:"transparent, #fff, url(...)"})}),e.jsx(t.Form.Item,{label:"内边距",name:["normalStyle","padding"],children:e.jsx(t.InputNumber,{min:0})}),e.jsx(t.Form.Item,{label:"圆角",name:["normalStyle","borderRadius"],children:e.jsx(t.InputNumber,{min:0})}),e.jsx(t.Form.Item,{label:"缩放比例",name:["normalStyle","scale"],help:"等比缩放节点的宽高",children:e.jsx(t.InputNumber,{min:.1,max:5,step:.1})}),e.jsx(t.Form.Item,{label:"旋转角度",name:["normalStyle","rotate"],help:"顺时针旋转角度(度)",children:e.jsx(t.InputNumber,{min:0,max:360,step:1})}),e.jsx(t.Form.Item,{label:"透明度",name:["normalStyle","opacity"],children:e.jsx(t.InputNumber,{min:0,max:1,step:.1})}),e.jsx(t.Form.Item,{label:"层级",name:["normalStyle","zIndex"],children:e.jsx(t.InputNumber,{})})]},"style")]})]})},"basic"),e.jsx(Ve,{tab:"状态",children:$.type==="group"&&$.children?e.jsx(Ht,{node:$,updateNode:n,materials:i}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"font-medium",children:["状态列表",e.jsx(t.Tag,{color:"blue",className:"ml-2",children:D.length})]}),e.jsx(t.Button,{type:"primary",size:"small",icon:e.jsx(L.PlusOutlined,{}),onClick:ue,children:"添加状态"})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"节点根据状态表达式计算结果显示对应物料,第一个返回 true 的状态为当前状态"}),D.length>0&&e.jsx("div",{className:"mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600",children:"当前状态:"}),e.jsx("span",{className:"ml-2 text-sm font-medium text-blue-600",children:"由表达式自动计算"})]})})}),D.length===0?e.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):e.jsx(t.Collapse,{ghost:!0,defaultActiveKey:D[0]?.id+r,children:D.map((c,V)=>e.jsx(pe,{header:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400 w-5",children:V+1}),e.jsx("span",{className:"font-medium",children:c.name}),e.jsx(t.Tag,{color:"default",className:"text-xs",children:c.material.type})]}),extra:e.jsxs(t.Space,{size:"small",onClick:x=>x.stopPropagation(),children:[e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.ArrowUpOutlined,{}),disabled:V===0,onClick:x=>{x.stopPropagation(),K(c.id,"up")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.ArrowDownOutlined,{}),disabled:V===D.length-1,onClick:x=>{x.stopPropagation(),K(c.id,"down")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(L.CopyOutlined,{}),onClick:x=>{x.stopPropagation(),j(c)}}),e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(L.DeleteOutlined,{}),onClick:x=>{x.stopPropagation(),ge(c.id)}})]}),children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"状态名称",children:e.jsx(t.Input,{value:c.name,onChange:x=>oe(c.id,{name:x.target.value}),placeholder:"输入状态名称"})}),e.jsx(t.Form.Item,{label:"执行表达式",help:"返回 true 时激活此状态,可使用 data 变量访问绑定数据",children:e.jsx(Vt,{value:G[c.id]??c.expression,onChange:x=>A(Y=>({...Y,[c.id]:x.target.value})),onBlur:x=>{oe(c.id,{expression:x.target.value}),A(Y=>{const _={...Y};return delete _[c.id],_})},rows:3,placeholder:"return true;"})}),e.jsx(t.Form.Item,{label:"绑定数据源 (bindCodes)",children:e.jsx(t.Select,{mode:"tags",value:c.bindCodes||[],onChange:x=>oe(c.id,{bindCodes:x}),placeholder:"输入数据源 code",tokenSeparators:[","," "]})}),e.jsx(t.Form.Item,{label:"绑定物料",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Tag,{color:"blue",children:c.material.name}),e.jsx(t.Tag,{color:"default",children:c.material.type}),e.jsx(t.Button,{type:"link",size:"small",icon:e.jsx(L.EditOutlined,{}),onClick:()=>H(c.id),children:"更换物料"})]})}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),e.jsx(t.Tag,{children:c.material.name})]}),e.jsx(pt,{material:c.material,onSave:x=>F(c.id,x),bindCodes:c.bindCodes||[],dataOptions:l||[]})]})]})},c.id+r))})]})},"status"),e.jsx(Ve,{tab:"控制",children:e.jsxs(t.Form,{form:f,layout:"vertical",onValuesChange:T,children:[e.jsx(t.Form.Item,{label:"可拖拽",name:["controlInfo","isDraggable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可点击",name:["controlInfo","isClickable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可调整大小",name:["controlInfo","isResizable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可选中",name:["controlInfo","isSelectable"],valuePropName:"checked",children:e.jsx(t.Switch,{})})]})},"control")]})}),e.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsxs("div",{children:["节点 ID: ",$.id.slice(0,8),"..."]}),e.jsxs("div",{children:["状态数: ",D.length]})]})}),e.jsx(t.Modal,{title:"选择物料",open:E,onCancel:()=>{w(!1),b(null)},footer:null,width:600,children:e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs(t.Collapse,{ghost:!0,defaultActiveKey:["basic","device","text","line"],children:[e.jsx(pe,{header:"基础形状",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>["矩形","圆形","圆角矩形"].includes(c.name)).map(c=>e.jsx(yt,{material:c,onClick:()=>ee(c)},c.id))})},"basic"),e.jsx(pe,{header:"设备图标",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>["阀门","泵","罐体"].includes(c.name)||c.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(c.name)).map(c=>e.jsx(yt,{material:c,onClick:()=>ee(c)},c.id))})},"device"),e.jsx(pe,{header:"文本",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>c.type==="TEXT").map(c=>e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>ee(c),children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:e.jsx("span",{className:"text-lg font-bold text-gray-500",children:"T"})}),e.jsx("span",{className:"text-xs",children:c.name})]},c.id))})},"text"),e.jsx(pe,{header:"线条",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>c.type==="LINE").map(c=>e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>ee(c),children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:e.jsx("div",{className:"w-8 h-0.5 bg-gray-400"})}),e.jsx("span",{className:"text-xs",children:c.name})]},c.id))})},"line")]})})})]}):e.jsx("div",{className:"h-full flex items-center justify-center bg-white border-l border-gray-200",children:e.jsx(t.Empty,{description:"请选择一个节点"})})},yt=({material:l,onClick:p})=>{const r=l.type==="IMAGE"?l.src:void 0;return e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:p,children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center",children:r?e.jsx("img",{src:r,alt:l.name,className:"w-10 h-10 object-contain"}):e.jsx("span",{className:"text-xs",children:l.name[0]})}),e.jsx("span",{className:"text-xs",children:l.name})]})},Zt={configEditor:"ConfigEditor-module__configEditor__dinNG"},{Header:Jt,Sider:wt,Content:Kt}=t.Layout,Qt=({initialScheme:l,onChange:p,readonly:r=!1,headerExtra:n,className:d="",style:o,showHeader:a=!0,showMaterialPanel:i=!0,showPropertyPanel:m=!0,customMaterials:h})=>{const[f,S]=g.useState(!1),[u,E]=g.useState(""),[w,k]=g.useState([{paramsCode:"001",paramsName:"通频速度有效值",value:25,paramsUnit:"mm/s"},{paramsCode:"002",paramsName:"通频加速度有效值",value:1.5,paramsUnit:"m/s²"}]),{exportScheme:b,importScheme:G,nodes:A,materials:$,addMaterial:D}=me();g.useRef(null);const T=g.useRef(!1);g.useEffect(()=>{T.current||(T.current=!0,$.length===0&&dt.forEach(j=>D(j)),h&&h.length>0&&h.forEach(j=>D(j)),l&&G(l))},[]),g.useEffect(()=>{if(p){const j=b();p(j)}},[A,p]);const ue=g.useCallback(()=>{const j=b(),K=JSON.stringify(j,null,2),H="data:application/json;charset=utf-8,"+encodeURIComponent(K),F=`scheme_${Date.now()}.json`,c=document.createElement("a");c.setAttribute("href",H),c.setAttribute("download",F),c.click(),t.message.success("导出成功!")},[b]),ee=g.useCallback(()=>{try{const j=JSON.parse(u);G(j),S(!1),E(""),t.message.success("导入成功!")}catch{t.message.error("JSON 格式错误,请检查输入")}},[u,G]),ge=g.useCallback(j=>{const K=new FileReader;return K.onload=H=>{try{const F=H.target?.result,c=JSON.parse(F);G(c),t.message.success("导入成功!"),S(!1)}catch{t.message.error("文件格式错误")}},K.readAsText(j),!1},[G]),oe=g.useCallback(()=>b(),[b]);return g.useImperativeHandle(g.useRef?.(),()=>({getScheme:oe,exportScheme:b,importScheme:G}),[oe,b,G]),e.jsx(t.ConfigProvider,{locale:Tt,children:e.jsx("div",{className:Zt.configEditor,style:o,children:e.jsxs(t.Layout,{className:`h-full w-full overflow-hidden ${d}`,children:[a&&e.jsxs(Jt,{className:"bg-white border-b border-gray-200 px-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-xl font-bold text-blue-600",children:"组态编辑器"}),e.jsxs("div",{className:"text-sm text-gray-500",children:[A.length," 个节点"]})]}),e.jsxs(t.Space,{children:[n,!r&&e.jsxs(e.Fragment,{children:[e.jsx(t.Tooltip,{title:"导出 JSON",children:e.jsx(t.Button,{icon:e.jsx(L.DownloadOutlined,{}),onClick:ue,children:"导出"})}),e.jsx(t.Tooltip,{title:"导入 JSON",children:e.jsx(t.Button,{icon:e.jsx(L.UploadOutlined,{}),onClick:()=>S(!0),children:"导入"})})]})]})]}),e.jsxs(t.Layout,{children:[i&&!r&&e.jsx(wt,{width:280,className:"bg-white",theme:"light",children:e.jsx(ut,{})}),e.jsx(Kt,{className:"bg-gray-100 relative",children:e.jsx(ft,{defaultTestData:w})}),m&&!r&&e.jsx(wt,{width:360,className:"bg-white",theme:"light",children:e.jsx(mt,{defaultTestData:w})})]}),e.jsx(t.Modal,{title:"导入组态方案",open:f,onOk:ee,onCancel:()=>{S(!1),E("")},width:600,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2",children:"选择 JSON 文件导入:"}),e.jsx("input",{type:"file",accept:".json",onChange:j=>{const K=j.target.files?.[0];K&&ge(K)},className:`block w-full text-sm text-gray-500
|
|
6
|
+
${F?"bg-blue-50 ring-2 ring-blue-400":""}
|
|
7
|
+
`,actions:[W?e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.EditOutlined,{}),onClick:L=>{L.stopPropagation(),v(b)},children:"绘制"},"draw"):null,e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(Y.DeleteOutlined,{}),onClick:L=>{L.stopPropagation(),r(b.id)}},"delete")].filter(Boolean),children:e.jsxs("div",{className:`flex items-center gap-3 w-full py-2 ${W?"":"pointer-events-none"}`,children:[e.jsx("div",{className:"material-preview w-12 h-12 flex items-center justify-center bg-white rounded border border-gray-200",children:b.type==="IMAGE"&&b.src?e.jsx(t.Image,{src:b.src,alt:b.name,width:40,height:40,preview:!1}):b.type==="TEXT"?e.jsx("span",{className:"text-xs text-gray-500",children:"T"}):b.type==="LINE"?e.jsx("div",{className:"w-8 h-0.5 bg-gray-400"}):b.type==="CUSTOM"&&b.config?.nodes?e.jsx("span",{className:"text-xs text-blue-500 font-bold",children:"G"}):e.jsx("span",{className:"text-xs text-gray-500",children:"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(Pe,{strong:!0,className:"block truncate",children:b.name}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Pe,{type:"secondary",className:"text-xs",children:b.type}),F&&e.jsx(t.Tag,{color:"blue",className:"text-xs",children:"绘制中"})]})]})]})},b.id)};return e.jsxs("div",{className:"h-full flex flex-col bg-white border-r border-gray-200",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"物料库"}),e.jsx(Pe,{type:"secondary",className:"text-sm",children:"拖拽物料到画布创建节点"})]}),e.jsx("div",{className:"p-3 border-b border-gray-200",children:e.jsx(t.Upload,{accept:".svg",beforeUpload:S,showUploadList:!1,children:e.jsx(t.Button,{icon:e.jsx(Y.UploadOutlined,{}),block:!0,type:"dashed",children:"上传 SVG"})})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:e.jsxs(t.Collapse,{activeKey:h,onChange:b=>f(b),ghost:!0,expandIconPosition:"end",children:[e.jsx(we,{header:"基础形状",children:e.jsx(t.List,{dataSource:u.basic,renderItem:b=>I(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"basic"),e.jsx(we,{header:"设备图标",children:e.jsx(t.List,{dataSource:u.device,renderItem:b=>I(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"device"),e.jsx(we,{header:"文本",children:e.jsx(t.List,{dataSource:u.text,renderItem:b=>I(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"text"),e.jsxs(we,{header:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:"线条"}),o==="line-draw"&&e.jsx(t.Tag,{color:"blue",className:"text-xs",children:"绘制模式"})]}),children:[e.jsx(t.List,{dataSource:u.line,renderItem:b=>I(b,!0),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}}),o==="line-draw"&&e.jsxs("div",{className:"mt-2 p-2 bg-blue-50 rounded text-xs text-blue-600",children:[e.jsx("div",{children:"点击线条物料开始绘制"}),e.jsx("div",{children:"点击画布确定起点和终点"})]})]},"line"),u.group.length>0&&e.jsx(we,{header:"群组",children:e.jsx(t.List,{dataSource:u.group,renderItem:b=>I(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"group"),u.custom.length>0&&e.jsx(we,{header:"自定义",children:e.jsx(t.List,{dataSource:u.custom,renderItem:b=>I(b,!1),locale:{emptyText:e.jsx(t.Empty,{description:"暂无物料",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}})},"custom")]})}),e.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:e.jsx(Pe,{type:"secondary",className:"text-xs",children:o==="line-draw"?e.jsx(e.Fragment,{children:"💡 提示:点击绘制线段,可连续绘制多段线,双击结束绘制,ESC 取消"}):e.jsx(e.Fragment,{children:"💡 提示:拖拽物料到画布创建节点,点击线条物料进入绘制模式"})})})]})},{Text:pt}=t.Typography,zt=(l,p)=>{try{const r=p&&Array.isArray(p)?p.map((o,a)=>o.paramsName):["A"],d=new Function(...r,l.expression)(...p.map(o=>o.value));return console.log(`Evaluating status [${l.name}] with data:`,p,"Result:",d),d===!0}catch(r){return console.warn(`状态表达式执行失败 [${l.name}]:`,r),!1}},Ft=(l,p)=>{for(const r of l){console.log(r,"status");let n=[];if(Array.isArray(p)?(console.log(r.bindCodes,"bindCodes"),n=p.filter(d=>r.bindCodes?.includes(d.paramsCode))):n=p,zt(r,n))return r}},Pt=(l,p)=>{if(!p||!l)return{value:void 0};if(Array.isArray(l)){const r=l.find(n=>n.paramsCode===p);if(r)return{value:r.value,unit:r.unit}}else if(typeof l=="object"&&p in l)return{value:l[p],unit:l.unit};return{value:void 0}},Xt=(l,p)=>{if(l==null||l==="")return"";if(p===-1)return String(l);const r=Number(l);return isNaN(r)?String(l):r.toFixed(p??2)},Ot=(l,p,r,n)=>{switch(l.type){case"IMAGE":const d=l,o=d.backgroundColor,a=d.fillColor;let i=d.src;return a&&i&&i.includes("data:image/svg+xml")&&(l.name==="矩形"?i=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${a}" rx="4"/></svg>`)}`:l.name==="圆形"?i=`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="${a}"/></svg>`)}`:l.name==="圆角矩形"&&(i=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${a}" rx="20"/></svg>`)}`)),e.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",style:{backgroundColor:o},children:i?e.jsx("img",{src:i,alt:l.name,style:{width:"100%",height:"100%",objectFit:"contain"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"无图片"})})});case"TEXT":const m=l,{label:h,value:f,valueSourceCode:S,unit:u,decimals:E,labelStyle:v,valueStyle:I,customStyle:b}=m.content||{},{value:q,unit:W}=S?Pt(p,S):{value:void 0,unit:void 0},L=Xt(q!==void 0?q:f,E),T=u||W||"";return e.jsxs("div",{className:"w-full h-full flex flex-col justify-center gap-1",style:{...b},children:[h&&e.jsx(pt,{style:{fontSize:14,fontWeight:"bold",color:"#262626",textAlign:"left",...v},children:h}),L&&e.jsxs(pt,{style:{fontSize:14,color:"#1890ff",textAlign:"left",...I},children:[L,T?` ${T}`:""]})]});case"LINE":const ue=l,{thickness:ee=2,color:ge="#d9d9d9",dashed:oe=!1,lineType:B=oe?"dashed":"solid",lineWeight:K=ee,startX:H=0,startY:P=0,endX:c=100,endY:V=0}=ue.config||{},$=(Te=>{const U=Math.max(K,1);switch(Te){case"solid":return"";case"dashed":return`${U*8},${U*4}`;case"center":return`${U*12},${U*3},${U*2},${U*3}`;case"phantom":return`${U*12},${U*3},${U*2},${U*3},${U*2},${U*3}`;case"dot":return`${U},${U*3}`;case"dash-dot":return`${U*8},${U*3},${U},${U*3}`;default:return""}})(B),M=r?"#1890ff":ge;return e.jsx("div",{className:"w-full h-full relative",style:{overflow:"visible"},children:e.jsxs("svg",{className:"absolute top-0 left-0",width:"100%",height:"100%",style:{overflow:"visible",pointerEvents:"none"},children:[e.jsx("line",{x1:H,y1:P,x2:c,y2:V,stroke:"transparent",strokeWidth:Math.max(K,10),strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"stroke",cursor:"pointer"}}),e.jsx("line",{x1:H,y1:P,x2:c,y2:V,stroke:M,strokeWidth:K,strokeDasharray:$,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none"}})]})});case"CUSTOM":const J=l;return J.render?J.render({}):e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"自定义组件"})});default:return e.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:e.jsx("span",{className:"text-gray-400 text-xs",children:"未知类型"})})}},At=({node:l,isSelected:p=!1,onClick:r,onMouseDown:n,data:d,onUpdateNode:o,scale:a=1})=>{const{normalStyle:i,contentInfo:m,controlInfo:h}=l,{statusList:f}=m,{isClickable:S,isDraggable:u,isResizable:E}=h,v=g.useRef(r);g.useEffect(()=>{v.current=r},[r]);const[I,b]=g.useState(null),q=g.useRef(null),W=g.useRef(null),F=g.useRef(null),L=g.useRef(null),[T,ue]=g.useState(null),[ee,ge]=g.useState(null),oe=g.useRef(null),B=g.useMemo(()=>{if(f.length===0)return;const k=Ft(f,d);return k||f[0]},[f,d]),K=B?.material,H=K?.type==="LINE",P=H?K.config:null,c=i.scale??1,V=(i.width||100)*c,x=(i.height||100)*c,$=g.useCallback(()=>{const k=L.current?.closest('[data-canvas="true"]');if(!k)return a;const A=k.getBoundingClientRect(),X=parseFloat(k.style.width);return X?A.width/X:a},[a]),M=g.useCallback((k,A)=>{k.stopPropagation(),k.preventDefault(),q.current={mouseX:k.clientX,mouseY:k.clientY,startX:P?.startX||0,startY:P?.startY||0,endX:P?.endX||0,endY:P?.endY||0,nodeX:i.x||0,nodeY:i.y||0},b(A)},[P,i.x,i.y]);g.useEffect(()=>{if(!I||!H||!P||!o)return;const k=X=>{const D=q.current;if(!D||!L.current)return;const se=$(),ce=(X.clientX-D.mouseX)/se,re=(X.clientY-D.mouseY)/se;let Q=D.startX,le=D.startY,ne=D.endX,ae=D.endY,xe=D.nodeX,Se=D.nodeY;I==="start"?(Q=D.startX+ce,le=D.startY+re,Q<0&&(xe=D.nodeX+Q,ne=D.endX-Q,Q=0),le<0&&(Se=D.nodeY+le,ae=D.endY-le,le=0)):(ne=D.endX+ce,ae=D.endY+re,ne<0&&(xe=D.nodeX+ne,Q=D.startX-ne,ne=0),ae<0&&(Se=D.nodeY+ae,le=D.startY-ae,ae=0));const je=Math.max((P.lineWeight||2)*2,4),We=Math.max(Q,ne),Be=Math.max(le,ae),$e=Math.max(We,je),Ce=Math.max(Be,je);W.current={nodeX:xe,nodeY:Se,width:$e,height:Ce,startX:Q,startY:le,endX:ne,endY:ae};const de=L.current;de.style.left=`${xe}px`,de.style.top=`${Se}px`,de.style.width=`${$e}px`,de.style.height=`${Ce}px`,de.querySelectorAll("svg line").forEach(be=>{be.setAttribute("x1",String(Q)),be.setAttribute("y1",String(le)),be.setAttribute("x2",String(ne)),be.setAttribute("y2",String(ae))});const ze=de.querySelector('[data-handle="start"]'),Fe=de.querySelector('[data-handle="end"]');ze&&(ze.style.left=`${Q-6}px`,ze.style.top=`${le-6}px`),Fe&&(Fe.style.left=`${ne-6}px`,Fe.style.top=`${ae-6}px`)},A=()=>{const X=W.current;X&&o(l.id,{normalStyle:{...i,x:X.nodeX,y:X.nodeY,width:X.width,height:X.height},contentInfo:{...m,statusList:f.map(D=>({...D,material:D.material.type==="LINE"?{...D.material,config:{...P,startX:X.startX,startY:X.startY,endX:X.endX,endY:X.endY}}:D.material}))}}),b(null),q.current=null,W.current=null};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",A),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",A)}},[I,H,P,l.id,i,m,f,o,$]),g.useEffect(()=>{if(!T||!o)return;const k=X=>{if(!L.current)return;const D=$(),se=(X.clientX-T.startX)/D,ce=(X.clientY-T.startY)/D;let re=T.startWidth,Q=T.startHeight,le=T.startNodeX,ne=T.startNodeY;switch(T.corner){case"se":re=Math.max(20,T.startWidth+se),Q=Math.max(20,T.startHeight+ce);break;case"sw":re=Math.max(20,T.startWidth-se),Q=Math.max(20,T.startHeight+ce),le=T.startNodeX+(T.startWidth-re);break;case"ne":re=Math.max(20,T.startWidth+se),Q=Math.max(20,T.startHeight-ce),ne=T.startNodeY+(T.startHeight-Q);break;case"nw":re=Math.max(20,T.startWidth-se),Q=Math.max(20,T.startHeight-ce),le=T.startNodeX+(T.startWidth-re),ne=T.startNodeY+(T.startHeight-Q);break}F.current={x:le,y:ne,width:re,height:Q};const ae=L.current;ae.style.left=`${le}px`,ae.style.top=`${ne}px`,ae.style.width=`${re}px`,ae.style.height=`${Q}px`},A=()=>{const X=F.current;X&&o(l.id,{normalStyle:{...i,x:X.x,y:X.y,width:X.width,height:X.height}}),ue(null),F.current=null};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",A),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",A)}},[T,o,l.id,i,$]);const J=g.useCallback((k,A)=>{k.stopPropagation(),k.preventDefault(),ue({corner:A,startX:k.clientX,startY:k.clientY,startWidth:i.width||100,startHeight:i.height||100,startNodeX:i.x||0,startNodeY:i.y||0})},[i.width,i.height,i.x,i.y]),Te=g.useCallback(k=>{k.stopPropagation(),k.preventDefault();const A=L.current?.getBoundingClientRect();A&&ge({startX:k.clientX,startY:k.clientY,startAngle:i.rotate||0,centerX:A.left+A.width/2,centerY:A.top+A.height/2})},[i.rotate]);g.useEffect(()=>{if(!ee)return;const k=X=>{const D=X.clientX-ee.centerX,se=X.clientY-ee.centerY;let re=(Math.atan2(se,D)*(180/Math.PI)+90)%360;if(re<0&&(re+=360),oe.current=re,L.current){const Q=i.transform||"";L.current.style.transform=`rotate(${re}deg) ${Q}`.trim()}},A=()=>{const X=oe.current??ee.startAngle;oe.current=null,o&&o(l.id,{normalStyle:{...i,rotate:Math.round(X)}}),ge(null)};return window.addEventListener("mousemove",k),window.addEventListener("mouseup",A),()=>{window.removeEventListener("mousemove",k),window.removeEventListener("mouseup",A)}},[ee,o,l.id,i]);const U=l.type==="group",Ke={position:"absolute",left:i.x||0,top:i.y||0,width:V,height:x,background:U?"transparent":i.background||"transparent",backgroundImage:U?void 0:i.backgroundImage?`url(${i.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center",padding:Array.isArray(i.padding)?i.padding.join("px ")+"px":i.padding,margin:Array.isArray(i.margin)?i.margin.join("px ")+"px":i.margin,borderRadius:U?void 0:i.borderRadius,border:p&&!H?"2px solid #1890ff":H||U?"none":i.border||"1px dashed transparent",pointerEvents:"auto",opacity:i.opacity??1,transform:`rotate(${oe.current??(i.rotate||0)}deg) ${i.transform||""}`.trim(),transformOrigin:"center center",zIndex:p?1e3:i.zIndex??1,cursor:u&&!I?"move":S?"pointer":"default",boxSizing:"border-box",overflow:p||H||U?"visible":"hidden"},Oe=P?{x:P.startX||0,y:P.startY||0}:{x:0,y:0},Ae=P?{x:P.endX||0,y:P.endY||0}:{x:0,y:0};return e.jsxs("div",{ref:L,"data-node-id":l.id,style:Ke,onClick:k=>{console.log("NodeRenderer onClick",l.id,"isClickable:",S);const A=v.current;S&&A&&!I&&!T&&!ee&&(k.stopPropagation(),A(k))},onMouseDown:k=>{u&&n&&!I&&n(k)},children:[p&&!H&&!U&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"nw-resize",marginTop:"-6px",marginLeft:"-6px"},onMouseDown:k=>J(k,"nw"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"ne-resize",marginTop:"-6px",marginRight:"-6px"},onMouseDown:k=>J(k,"ne"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"sw-resize",marginBottom:"-6px",marginLeft:"-6px"},onMouseDown:k=>J(k,"sw"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 bg-blue-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"se-resize",marginBottom:"-6px",marginRight:"-6px"},onMouseDown:k=>J(k,"se"),title:"拖拽调整大小"}),e.jsx("div",{className:"absolute top-0 left-1/2 w-4 h-4 bg-green-500 border-2 border-white rounded-full",style:{zIndex:9999,pointerEvents:"auto",cursor:"grab",marginTop:"-20px",transform:"translateX(-50%)",boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:k=>Te(k),title:"拖拽旋转"}),e.jsx("div",{className:"absolute top-0 left-1/2 w-0.5 h-3 bg-green-500",style:{zIndex:9998,pointerEvents:"none",marginTop:"-14px",transform:"translateX(-50%)"}}),e.jsxs("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:[l.name," ",B?`(${B.name})`:""]})]}),p&&H&&P&&o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{"data-handle":"start",className:"absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",style:{left:Oe.x-6,top:Oe.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:k=>M(k,"start"),title:"拖拽调整起点"}),e.jsx("div",{"data-handle":"end",className:"absolute w-3 h-3 bg-blue-500 border-2 border-white rounded-full cursor-move z-50",style:{left:Ae.x-6,top:Ae.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:k=>M(k,"end"),title:"拖拽调整终点"}),e.jsx("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:l.name})]}),e.jsx("div",{className:"w-full h-full relative",children:K?e.jsx("div",{className:"w-full h-full",children:Ot(K,d,p)}):U?null:e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300 text-xs",children:"无状态"})}),l.type==="group"&&l.children&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:l.children.map(k=>e.jsx("div",{className:"pointer-events-auto",children:e.jsx(Ze,{node:k,isSelected:!1,data:d,onUpdateNode:o,scale:a})},k.id))})]})},Ze=g.memo(At,(l,p)=>{const r=l.node,n=p.node,d=r.id===n.id&&r.normalStyle.x===n.normalStyle.x&&r.normalStyle.y===n.normalStyle.y&&r.normalStyle.width===n.normalStyle.width&&r.normalStyle.height===n.normalStyle.height,o=r.contentInfo===n.contentInfo,a=l.isSelected===p.isSelected&&l.scale===p.scale;return d&&o&&a}),jt=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#eb2f96","#13c2c2","#fa8c16","#595959","#262626","#8c8c8c","#d9d9d9","#ffffff","#000000","#ff4d4f","#73d13d"],ve=({value:l="#1890ff",onChange:p,onChangeComplete:r})=>{const[n,d]=g.useState(!1),[o,a]=g.useState(l),i=g.useRef(null);g.useEffect(()=>{a(l)},[l]),g.useEffect(()=>{const h=f=>{i.current&&!i.current.contains(f.target)&&(d(!1),r?.({toHexString:()=>o}))};return n&&document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n,r,o]);const m=h=>{a(h),p?.({toHexString:()=>h})};return e.jsxs("div",{ref:i,style:{position:"relative",display:"inline-block"},children:[e.jsx("div",{onClick:()=>d(!n),style:{width:28,height:28,backgroundColor:o,border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer"}}),n&&e.jsxs("div",{style:{position:"absolute",top:32,left:0,zIndex:1e3,background:"#fff",padding:8,borderRadius:4,boxShadow:"0 2px 8px rgba(0,0,0,0.15)",border:"1px solid #f0f0f0"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:4},children:jt.map(h=>e.jsx("div",{onClick:()=>{m(h),d(!1),r?.({toHexString:()=>h})},style:{width:20,height:20,backgroundColor:h,border:o===h?"2px solid #1890ff":"1px solid #d9d9d9",borderRadius:2,cursor:"pointer"}},h))}),e.jsx("input",{type:"color",value:o,onChange:h=>m(h.target.value),onBlur:()=>r?.({toHexString:()=>o}),style:{width:"100%",marginTop:8,height:28,border:"1px solid #d9d9d9",borderRadius:4}})]})]})},{TextArea:Wt}=t.Input,bt=({defaultTestData:l})=>{const p=g.useRef(null),r=g.useRef(null),n=g.useRef(null),{nodes:d,selectedNodeId:o,mode:a,lineDrawing:i,viewport:m,canvas:h,setViewport:f,setCanvasConfig:S,addNode:u,selectNode:E,updateNode:v,removeNode:I,undo:b,redo:q,setMode:W,startLineDrawing:F,endLineDrawing:L,cancelLineDrawing:T}=ye();console.log("selectedNodeId",o);const[ue,ee]=g.useState(!1),[,ge]=g.useState({}),oe=g.useRef(a);g.useEffect(()=>{oe.current=a},[a]);const B=g.useRef(!1),K=g.useRef({x:0,y:0}),H=g.useRef({x:0,y:0,newX:0,newY:0}),P=g.useRef(null),[c,V]=g.useState({start:null,end:null,isDrawing:!1}),[x,$]=g.useState({start:null,end:null}),[M,J]=g.useState([]);g.useRef(!1);const[Te,U]=g.useState(!1),[Ke,Oe]=g.useState(JSON.stringify(l,null,2)),[Ae,k]=g.useState(!1),[A,X]=g.useState(!1),D=g.useCallback((s,w)=>{if(!r.current)return{x:0,y:0};const N=r.current.getBoundingClientRect(),C=s-N.left,y=w-N.top,_=N.width/h.width,j=N.height/h.height,z=C/_,Z=y/j;return{x:Math.round(z),y:Math.round(Z)}},[h.width,h.height]),se=g.useCallback((s,w)=>D(s,w),[D]),ce=g.useCallback((s,w,N=!0)=>{if(!i.material)return;const C=i.material,y=C.config||{},_=y.lineWeight||y.thickness||2,j=Math.min(s.x,w.x),z=Math.min(s.y,w.y),Z=Math.round(s.x-j),O=Math.round(s.y-z),te=Math.round(w.x-j),ie=Math.round(w.y-z),he=Math.max(_*2,4),ke=Math.max(Math.abs(s.x-w.x),he),me=Math.max(Math.abs(s.y-w.y),he),Ue={...C,id:G.nanoid(),config:{color:y.color,lineWeight:_,thickness:_,lineType:y.lineType,startX:Z,startY:O,endX:te,endY:ie}},er={id:G.nanoid(),name:`${C.name}_${Date.now()}`,type:"normal",normalStyle:{width:ke,height:me,x:j,y:z,background:"transparent"},contentInfo:{statusList:[Ve(Ue)],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}};if(u(er,!1),N){const St={x:w.x,y:w.y};V({start:St,end:{...St},isDrawing:!0})}else V({start:null,end:null,isDrawing:!1}),L()},[i.material,u,L]),re=g.useCallback(()=>{const s=p.current?.state;s&&f({scale:s.scale,positionX:s.positionX,positionY:s.positionY})},[f]),Q=g.useCallback(s=>{B.current||a!=="box-select"&&(s.target===r.current||s.target.dataset?.canvas==="true")&&(E(null),J([]))},[E,a]),le=g.useCallback(s=>{if(s.button===0){if(a==="line-draw"&&i.material){s.stopPropagation();const w=D(s.clientX,s.clientY);c.isDrawing?c.start&&ce(c.start,w,!0):V({start:w,end:w,isDrawing:!0});return}if(a==="box-select"&&!A){const w=se(s.clientX,s.clientY);$({start:w,end:w}),J([]),s.preventDefault(),s.stopPropagation()}}},[a,i.material,c.isDrawing,c.start,A,ce,D,se]),ne=g.useCallback(s=>{if(!(a!=="line-draw"||!i.material)&&c.isDrawing&&c.start){const w=D(s.clientX,s.clientY);ce(c.start,w,!1)}},[a,i.material,c.isDrawing,c.start,ce,D]),ae=g.useCallback(s=>{s.preventDefault(),s.dataTransfer.dropEffect="copy",ee(!0)},[]),xe=g.useCallback(s=>{s.preventDefault(),ee(!1)},[]),Se=g.useCallback(s=>{if(s.preventDefault(),ee(!1),!(!r.current||a!=="select"))try{const w=s.dataTransfer.getData("application/json");if(!w)return;const N=JSON.parse(w),C=D(s.clientX,s.clientY),y=C.x-50,_=C.y-50,j=gt(y,_,N);u(j),J([j.id])}catch(w){console.error("Failed to parse dropped material:",w)}},[a,u,D]),je=g.useCallback((s,w)=>{a!=="select"&&a!=="box-select"||!w.controlInfo.isDraggable||(s.stopPropagation(),E(w.id),B.current=!0,K.current={x:s.clientX,y:s.clientY},H.current={x:w.normalStyle.x||0,y:w.normalStyle.y||0,newX:w.normalStyle.x||0,newY:w.normalStyle.y||0},P.current=w,s.preventDefault())},[a,E]);g.useEffect(()=>{const s=y=>{if(B.current&&o&&P.current){if(!r.current)return;const _=r.current.getBoundingClientRect(),j=_.width/h.width,z=_.height/h.height,Z=y.clientX-K.current.x,O=y.clientY-K.current.y,te=Z/j,ie=O/z,he=H.current.x+te,ke=H.current.y+ie,me=document.querySelector(`[data-node-id="${o}"]`);me&&(me.style.left=`${he}px`,me.style.top=`${ke}px`),H.current.newX=he,H.current.newY=ke}if(a==="box-select"&&x.start){const _=se(y.clientX,y.clientY);$(j=>({...j,end:_}))}if(a==="line-draw"&&c.isDrawing){const _=D(y.clientX,y.clientY);V(j=>({...j,end:_}))}},w=()=>{if(B.current&&o&&P.current){const y=ye.getState(),_=H.current.newX??H.current.x,j=H.current.newY??H.current.y;y.updateNode(o,{normalStyle:{...P.current.normalStyle,x:_,y:j}})}if(B.current=!1,P.current=null,ge({}),a==="box-select"&&x.start&&x.end){const y=Math.min(x.start.x,x.end.x),_=Math.max(x.start.x,x.end.x),j=Math.min(x.start.y,x.end.y),z=Math.max(x.start.y,x.end.y),Z=d.filter(O=>{const te=O.normalStyle.x||0,ie=O.normalStyle.y||0,he=O.normalStyle.width||0,ke=O.normalStyle.height||0,me=te+he/2,Ue=ie+ke/2;return me>=y&&me<=_&&Ue>=j&&Ue<=z}).map(O=>O.id);J(Z),$({start:null,end:null})}},N=y=>{y.key==="Escape"&&a==="line-draw"&&(V({start:null,end:null,isDrawing:!1}),T()),y.key==="Delete"&&(o?I(o):M.length>0&&(M.forEach(_=>I(_)),J([]))),y.ctrlKey&&y.key==="z"&&(y.preventDefault(),b()),y.ctrlKey&&y.key==="y"&&(y.preventDefault(),q()),y.key===" "&&!A&&(y.preventDefault(),X(!0))},C=y=>{y.key===" "&&A&&X(!1)};return window.addEventListener("mousemove",s),window.addEventListener("mouseup",w),window.addEventListener("keydown",N),window.addEventListener("keyup",C),()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",w),window.removeEventListener("keydown",N),window.removeEventListener("keyup",C)}},[o,x,a,c.isDrawing,M,d,h.width,h.height,I,b,A,q,T,D,se,J]);const We=g.useCallback(()=>{const s=M.length>0?M.map(N=>d.find(C=>C.id===N)).filter(Boolean):o?[d.find(N=>N.id===o)].filter(Boolean):[];if(s.length===0)return;const w=[];s.forEach(N=>{const C={...N,id:G.nanoid(),name:`${N.name}_副本`,normalStyle:{...N.normalStyle,x:(N.normalStyle.x||0)+20,y:(N.normalStyle.y||0)+20}};u(C),w.push(C.id)}),w.length===1?E(w[0]):J(w)},[o,M,d,u,E,J]),Be=g.useCallback(()=>{if(M.length<2)return;const s=[];for(let z=0;z<M.length;z++){const Z=M[z],O=d.find(te=>te.id===Z);if(O){if(O?.type==="group"){O.children.forEach(ie=>s.push({...ie,normalStyle:{...ie.normalStyle,x:(O.normalStyle.x||0)+(ie.normalStyle.x||0),y:(O.normalStyle.y||0)+(ie.normalStyle.y||0)}})),I(Z);continue}s.push(O)}}if(s.length<2)return;let w=1/0,N=1/0,C=-1/0,y=-1/0;s.forEach(z=>{const Z=z.normalStyle.x||0,O=z.normalStyle.y||0,te=z.normalStyle.width||0,ie=z.normalStyle.height||0;w=Math.min(w,Z),N=Math.min(N,O),C=Math.max(C,Z+te),y=Math.max(y,O+ie)});const _=s.map(z=>({...z,normalStyle:{...z.normalStyle,x:(z.normalStyle.x||0)-w,y:(z.normalStyle.y||0)-N}})),j={id:G.nanoid(),name:`群组_${Date.now()}`,type:"group",normalStyle:{x:w,y:N,width:C-w,height:y-N,background:"transparent"},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:_};M.forEach(z=>I(z)),u(j),J([]),E(j.id)},[M,d,I,u,E]),$e=g.useCallback(()=>{const s=M.length>0?M.map(w=>d.find(N=>N.id===w)).filter(w=>!!w&&w.type==="group"):o?[d.find(w=>w.id===o)].filter(w=>!!w&&w.type==="group"):[];s.length!==0&&(s.forEach(w=>{if(!w.children||w.children.length===0)return;const N=w.children.map(C=>({...C,normalStyle:{...C.normalStyle,x:(w.normalStyle.x||0)+(C.normalStyle.x||0),y:(w.normalStyle.y||0)+(C.normalStyle.y||0)}}));I(w.id),N.forEach(C=>u(C))}),J([]),E(null))},[o,M,d,I,u,E,J]),Ce=g.useCallback(s=>{if(M.length<2)return;const w=M.map(Z=>d.find(O=>O.id===Z)).filter(Z=>!!Z&&Z.type!=="group");if(w.length<2)return;let N=1/0,C=-1/0,y=1/0,_=-1/0;w.forEach(Z=>{const O=Z.normalStyle.x||0,te=Z.normalStyle.y||0;N=Math.min(N,O),C=Math.max(C,O),y=Math.min(y,te),_=Math.max(_,te)});const j=[...w].sort((Z,O)=>s==="horizontal"?(Z.normalStyle.x||0)-(O.normalStyle.x||0):(Z.normalStyle.y||0)-(O.normalStyle.y||0)),z=j.length;if(s==="horizontal"){const O=(C-N)/(z-1);j.forEach((te,ie)=>{const he=N+O*ie;v(te.id,{normalStyle:{...te.normalStyle,x:he}})})}else{const O=(_-y)/(z-1);j.forEach((te,ie)=>{const he=y+O*ie;v(te.id,{normalStyle:{...te.normalStyle,y:he}})})}},[M,d,v]),de=s=>{const w=s.contentInfo.statusList.find(N=>N.material.type==="LINE");return w?w.material.config:null},Ne=g.useCallback(s=>{if(M.length<2)return;const w=ye.getState(),N=M.map(y=>d.find(_=>_.id===y)).filter(y=>!!y);if(N.length<2)return;let C=0;switch(s){case"left":C=Math.min(...N.map(y=>{const _=de(y);return _?(y.normalStyle.x||0)+(_.startX||0):y.normalStyle.x||0}));break;case"right":C=Math.max(...N.map(y=>{const _=de(y);return _?(y.normalStyle.x||0)+(_.endX||0):(y.normalStyle.x||0)+(y.normalStyle.width||0)}));break;case"top":C=Math.min(...N.map(y=>{const _=de(y);return _?(y.normalStyle.y||0)+(_.startY||0):y.normalStyle.y||0}));break;case"bottom":C=Math.max(...N.map(y=>{const _=de(y);return _?(y.normalStyle.y||0)+(_.endY||0):(y.normalStyle.y||0)+(y.normalStyle.height||0)}));break}N.forEach(y=>{let _=y.normalStyle.x||0,j=y.normalStyle.y||0;const z=de(y);switch(s){case"left":z?_=C-(z.startX||0):_=C;break;case"right":z?_=C-(z.endX||0):_=C-(y.normalStyle.width||0);break;case"top":z?j=C-(z.startY||0):j=C;break;case"bottom":z?j=C-(z.endY||0):j=C-(y.normalStyle.height||0);break}w.updateNode(y.id,{normalStyle:{...y.normalStyle,x:_,y:j}})})},[M,d]),ze=[{icon:e.jsx(Y.SelectOutlined,{}),title:"选择模式",active:a==="select",onClick:()=>{W("select")}},{icon:e.jsx(Y.GroupOutlined,{}),title:"框选模式",active:a==="box-select",onClick:()=>{W("box-select"),J([])}},{icon:e.jsx(Y.DragOutlined,{}),title:"拖拽模式",active:a==="drag",onClick:()=>{W("drag")}},{icon:e.jsx(Y.EditOutlined,{}),title:"线条绘制",active:a==="line-draw",onClick:()=>{W("line-draw")}},{icon:e.jsx(Y.EyeOutlined,{}),title:"预览模式",active:a==="preview",onClick:()=>{W("preview")}}],Fe=g.useMemo(()=>[{icon:e.jsx(Y.UndoOutlined,{}),title:"撤销 (Ctrl+Z)",onClick:b},{icon:e.jsx(Y.RedoOutlined,{}),title:"重做 (Ctrl+Y)",onClick:q},{icon:e.jsx(Y.CopyOutlined,{}),title:"复制节点",disabled:!o&&M.length===0,onClick:We},{icon:e.jsx(Y.GroupOutlined,{}),title:"组合选中节点",disabled:M.length<2,onClick:Be},{icon:e.jsx(Y.UngroupOutlined,{}),title:"解除组合",disabled:!o&&M.length===0,onClick:$e},{icon:e.jsx(Y.AlignLeftOutlined,{}),title:"左对齐",disabled:M.length<2,onClick:()=>Ne("left")},{icon:e.jsx(Y.AlignRightOutlined,{}),title:"右对齐",disabled:M.length<2,onClick:()=>Ne("right")},{icon:e.jsx(Y.VerticalAlignTopOutlined,{}),title:"上对齐",disabled:M.length<2,onClick:()=>Ne("top")},{icon:e.jsx(Y.VerticalAlignBottomOutlined,{}),title:"下对齐",disabled:M.length<2,onClick:()=>Ne("bottom")},{icon:e.jsx(Y.ColumnWidthOutlined,{}),title:"水平分布",disabled:M.length<2,onClick:()=>Ce("horizontal")},{icon:e.jsx(Y.ColumnHeightOutlined,{}),title:"垂直分布",disabled:M.length<2,onClick:()=>Ce("vertical")},{icon:e.jsx(Y.SettingOutlined,{}),title:"画布配置",onClick:()=>k(!0)},{icon:e.jsx(Y.ExperimentOutlined,{}),title:"数据模拟",type:"primary",onClick:()=>U(!0)},{icon:e.jsx(Y.DeleteOutlined,{}),title:"删除选中 (Delete)",disabled:!o&&M.length===0,onClick:()=>{o?I(o):M.length>0&&(M.forEach(s=>I(s)),J([]))}}],[b,q,a,W,J,M,Be,$e,We,Ne,Ce,k,U,o,I]),be=g.useCallback(s=>{s.preventDefault(),(s.key==="ArrowLeft"||s.key==="ArrowRight"||s.key==="ArrowUp"||s.key==="ArrowDown")&&M.map(N=>d.find(C=>C.id===N)).forEach(N=>{N&&v(N.id,{normalStyle:{...N.normalStyle,x:(N.normalStyle.x||0)-2*(s.key==="ArrowLeft"?1:s.key==="ArrowRight"?-1:0),y:(N.normalStyle.y||0)-2*(s.key==="ArrowUp"?1:s.key==="ArrowDown"?-1:0)}})})},[M,d,v]);return g.useEffect(()=>(document.addEventListener("keydown",be),()=>{document.removeEventListener("keydown",be)}),[be]),e.jsxs("div",{className:"flex-1 flex flex-col h-full bg-gray-100",children:[e.jsxs("div",{className:"h-12 bg-white border-b border-gray-200 flex items-center justify-between px-4",children:[e.jsx(t.Space,{children:ze.map(s=>e.jsx(t.Tooltip,{title:s.title,children:e.jsx(t.Button,{type:s.active?"primary":"default",icon:s.icon,onClick:s.onClick})},s.title))}),e.jsx(t.Space,{children:Fe.map(s=>e.jsx(t.Tooltip,{title:s.title,children:e.jsx(t.Button,{type:s.active?"primary":s.type||"default",icon:s.icon,onClick:s.onClick,disabled:s.disabled})},s.title))})]}),e.jsx("div",{ref:n,className:"flex-1 relative",children:e.jsx(Qe.TransformWrapper,{ref:p,initialScale:1,initialPositionX:0,initialPositionY:0,minScale:.5,maxScale:5,onTransformed:re,limitToBounds:!1,centerZoomedOut:!1,panning:{disabled:!A&&(a==="select"||a==="line-draw"||a==="box-select"),velocityDisabled:!0},wheel:{disabled:!1,step:.1},pinch:{disabled:!1},doubleClick:{disabled:!0},children:({zoomIn:s,zoomOut:w,resetTransform:N})=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute bottom-4 right-4 z-10 bg-white rounded-lg shadow-lg p-2",children:e.jsxs(t.Space,{direction:"vertical",children:[e.jsx(t.Tooltip,{title:"放大",children:e.jsx(t.Button,{icon:e.jsx(Y.ZoomInOutlined,{}),onClick:()=>s()})}),e.jsx(t.Tooltip,{title:"缩小",children:e.jsx(t.Button,{icon:e.jsx(Y.ZoomOutOutlined,{}),onClick:()=>w()})}),e.jsx(t.Tooltip,{title:"重置视图",children:e.jsx(t.Button,{onClick:()=>N(),children:"100%"})}),e.jsxs("div",{className:"text-center text-xs text-gray-500",children:[Math.round(m.scale*100),"%"]})]})}),e.jsx(Qe.TransformComponent,{wrapperStyle:{width:"100%",height:"100%",position:"relative"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{ref:r,"data-canvas":"true",className:`relative ${ue?"ring-4 ring-blue-400 ring-opacity-50":""} ${a==="line-draw"?"cursor-crosshair":""} ${A?"cursor-grab":""}`,style:{width:h.width,height:h.height,flexShrink:0,backgroundColor:h.background,backgroundImage:h.backgroundImage?`url(${h.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},onClick:Q,onMouseDown:le,onDoubleClick:ne,onDragOver:ae,onDragLeave:xe,onDrop:Se,children:[h.showGrid!==!1&&e.jsxs("svg",{className:"absolute top-0 left-0 pointer-events-none",width:h.width,height:h.height,children:[e.jsx("defs",{children:e.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:"M 20 0 L 0 0 0 20",fill:"none",stroke:"#f0f0f0",strokeWidth:"1"})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#grid)"})]}),d.map(C=>e.jsx(Ze,{node:C,isSelected:o===C.id||M.includes(C.id),data:l,onClick:y=>{console.log("Node onClick:",C.id,"mode:",oe.current),oe.current!=="line-draw"&&(y.shiftKey?(E(C.id),J([...M,C.id])):(E(C.id),J([C.id])))},onMouseDown:y=>je(y,C),onUpdateNode:(y,_)=>v(y,_),scale:m.scale},`${C.id}`)),a==="line-draw"&&c.isDrawing&&c.start&&c.end&&e.jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",width:h.width,height:h.height,children:e.jsx("line",{x1:c.start.x,y1:c.start.y,x2:c.end.x,y2:c.end.y,stroke:"#1890ff",strokeWidth:"2",strokeDasharray:"5,5",strokeLinecap:"round",strokeLinejoin:"round"})}),a==="box-select"&&x.start&&x.end&&e.jsx("div",{className:"absolute border-2 border-blue-500 bg-blue-500/10 pointer-events-none",style:{left:Math.min(x.start.x,x.end.x),top:Math.min(x.start.y,x.end.y),width:Math.abs(x.end.x-x.start.x),height:Math.abs(x.end.y-x.start.y),zIndex:9999}})]})})]})})}),e.jsx(t.Modal,{title:"数据模拟",open:Te,onCancel:()=>U(!1),footer:null,children:e.jsx(t.Form,{layout:"vertical",children:e.jsx(t.Form.Item,{label:"测试数据 (JSON)",children:e.jsx(Wt,{value:Ke,onChange:s=>Oe(s.target.value),rows:10,placeholder:"输入 JSON 格式的测试数据"})})})}),e.jsx(t.Modal,{title:"画布配置",open:Ae,onCancel:()=>k(!1),footer:null,children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"宽度",children:e.jsx(t.InputNumber,{value:h.width,onChange:s=>S({width:s||1920}),min:100,max:5e3,style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"高度",children:e.jsx(t.InputNumber,{value:h.height,onChange:s=>S({height:s||1080}),min:100,max:5e3,style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"显示网格",children:e.jsx(t.Switch,{checked:h.showGrid!==!1,onChange:s=>S({showGrid:s})})}),e.jsx(t.Form.Item,{label:"背景色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:h.background||"#ffffff",onChange:s=>S({background:s.toHexString()})}),e.jsx(t.Input,{value:h.background,onChange:s=>S({background:s.target.value}),placeholder:"#ffffff"})]})}),e.jsxs(t.Form.Item,{label:"背景图片",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Upload,{accept:"image/*",showUploadList:!1,beforeUpload:s=>{if(!s.type.startsWith("image/"))return t.message.error("只能上传图片文件!"),!1;const N=new FileReader;return N.onload=C=>{const y=C.target?.result;S({backgroundImage:y}),t.message.success("背景图片上传成功")},N.readAsDataURL(s),!1},children:e.jsx(t.Button,{icon:e.jsx(Y.UploadOutlined,{}),children:"上传图片"})}),e.jsx(t.Input,{value:h.backgroundImage,onChange:s=>S({backgroundImage:s.target.value}),placeholder:"输入图片 URL 或上传图片",style:{flex:1}}),h.backgroundImage&&e.jsx(t.Button,{icon:e.jsx(Y.CloseOutlined,{}),onClick:()=>S({backgroundImage:void 0}),danger:!0,size:"small"})]}),h.backgroundImage&&e.jsx("div",{className:"mt-2 p-2 border rounded",style:{maxWidth:"100%"},children:e.jsx("img",{src:h.backgroundImage,alt:"背景预览",style:{maxWidth:"100%",maxHeight:120,objectFit:"contain"}})})]})]})})]})},{Option:Xe}=t.Select,Bt=({material:l,onSave:p,bindCodes:r=[],dataOptions:n=[]})=>{const o=l.content||{},[a,i]=g.useState({label:o.label||"",value:o.value||"",valueSourceCode:o.valueSourceCode||"",unit:o.unit||"",decimals:o.decimals??2,labelFontSize:o.labelStyle?.fontSize||14,labelFontWeight:o.labelStyle?.fontWeight||"bold",labelColor:o.labelStyle?.color||"#262626",valueFontSize:o.valueStyle?.fontSize||14,valueFontWeight:o.valueStyle?.fontWeight||"normal",valueColor:o.valueStyle?.color||"#1890ff"});g.useEffect(()=>{i({label:o.label||"",value:o.value||"",valueSourceCode:o.valueSourceCode||"",unit:o.unit||"",decimals:o.decimals??2,labelFontSize:o.labelStyle?.fontSize||14,labelFontWeight:o.labelStyle?.fontWeight||"bold",labelColor:o.labelStyle?.color||"#262626",valueFontSize:o.valueStyle?.fontSize||14,valueFontWeight:o.valueStyle?.fontWeight||"normal",valueColor:o.valueStyle?.color||"#1890ff"})},[l.id]);const m=(u,E)=>{i(v=>({...v,[u]:E}))},h=u=>{const E=n.find(I=>I.paramsCode===u),v=E?.unit||"";i(I=>({...I,valueSourceCode:u,unit:v,value:String(E?.value||"")})),setTimeout(()=>{p({content:{...o,valueSourceCode:u,value:String(E?.value||""),unit:v}})},0)},f=()=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:a.labelColor},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:a.valueColor}}})},S=n.filter(u=>r.includes(u.paramsCode));return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"文本内容"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"标签文本 (label)",children:e.jsx(t.Input,{value:a.label,onChange:u=>m("label",u.target.value),onBlur:f,placeholder:"输入标签文本"})}),e.jsx(t.Form.Item,{label:"值来源",help:"从绑定的数据中选择字段,优先级高于手动输入的值",children:e.jsx(t.Select,{value:a.valueSourceCode||void 0,onChange:h,placeholder:"选择数据字段(可选)",allowClear:!0,style:{width:"100%"},fieldNames:{value:"paramsCode",label:"paramsName"},options:S})}),e.jsx(t.Form.Item,{label:a.valueSourceCode?"默认值(备用)":"值文本",help:a.valueSourceCode?"已绑定数据源,实际值将来自数据字段,此处仅设置无数据时的备用显示":"手动输入显示的值",children:e.jsx(t.Input,{value:a.value,onChange:u=>m("value",u.target.value),onBlur:f,placeholder:a.valueSourceCode?"数据字段无值时显示此备用值":"输入值文本",disabled:!!a.valueSourceCode,variant:a.valueSourceCode?"filled":void 0})}),e.jsx(t.Form.Item,{label:"单位",help:"优先从绑定数据自动获取,也可手动输入",children:e.jsx(t.Input,{value:a.unit,onChange:u=>m("unit",u.target.value),onBlur:f,placeholder:"单位(如°C、%、MPa等)",suffix:a.valueSourceCode&&S.length>0?e.jsx(t.Tag,{color:"blue",style:{marginRight:-8},children:"自动"}):null})}),e.jsx(t.Form.Item,{label:"保留小数位",help:"数值格式化时保留的小数位数,-1表示不格式化",children:e.jsx(t.InputNumber,{value:a.decimals,onChange:u=>m("decimals",u??2),onBlur:f,min:-1,max:10,style:{width:"100%"}})})]}),e.jsx(t.Divider,{children:"标签样式"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"字体大小",children:e.jsx(t.InputNumber,{value:a.labelFontSize,onChange:u=>m("labelFontSize",u||14),onBlur:f,min:8,max:72})}),e.jsx(t.Form.Item,{label:"字体粗细",children:e.jsxs(t.Select,{value:a.labelFontWeight,onChange:u=>{m("labelFontWeight",u),setTimeout(f,0)},style:{width:100},children:[e.jsx(Xe,{value:"normal",children:"正常"}),e.jsx(Xe,{value:"bold",children:"粗体"})]})})]}),e.jsx(t.Form.Item,{label:"文字颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:a.labelColor||"#262626",onChange:u=>{m("labelColor",u.toHexString())},onChangeComplete:u=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:u.toHexString()},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:a.valueColor}}})}}),e.jsx(t.Input,{value:a.labelColor,onChange:u=>m("labelColor",u.target.value),onBlur:f,placeholder:"#262626",style:{width:100}})]})})]}),e.jsx(t.Divider,{children:"值样式"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"字体大小",children:e.jsx(t.InputNumber,{value:a.valueFontSize,onChange:u=>m("valueFontSize",u||14),onBlur:f,min:8,max:72})}),e.jsx(t.Form.Item,{label:"字体粗细",children:e.jsxs(t.Select,{value:a.valueFontWeight,onChange:u=>{m("valueFontWeight",u),setTimeout(f,0)},style:{width:100},children:[e.jsx(Xe,{value:"normal",children:"正常"}),e.jsx(Xe,{value:"bold",children:"粗体"})]})})]}),e.jsx(t.Form.Item,{label:"文字颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:a.valueColor||"#1890ff",onChange:u=>{m("valueColor",u.toHexString())},onChangeComplete:u=>{p({content:{...o,label:a.label,value:a.value,valueSourceCode:a.valueSourceCode,unit:a.unit,decimals:a.decimals,labelStyle:{fontSize:a.labelFontSize,fontWeight:a.labelFontWeight,color:a.labelColor},valueStyle:{fontSize:a.valueFontSize,fontWeight:a.valueFontWeight,color:u.toHexString()}}})}}),e.jsx(t.Input,{value:a.valueColor,onChange:u=>m("valueColor",u.target.value),onBlur:f,placeholder:"#1890ff",style:{width:100}})]})})]})]})},Ut=({material:l,onSave:p})=>{const r=l,[n,d]=g.useState({name:l.name,src:r.src||"",backgroundColor:r.backgroundColor||"",fillColor:r.fillColor||""});g.useEffect(()=>{d({name:l.name,src:r.src||"",backgroundColor:r.backgroundColor||"",fillColor:r.fillColor||""})},[l.id]);const o=(i,m)=>{d(h=>({...h,[i]:m}))},a=()=>{p({name:n.name,src:n.src,backgroundColor:n.backgroundColor})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"图片属性"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"图片名称",children:e.jsx(t.Input,{value:n.name,onChange:i=>o("name",i.target.value),onBlur:a})}),e.jsx(t.Form.Item,{label:"图片地址 (src)",children:e.jsx(t.Input.TextArea,{value:n.src,onChange:i=>o("src",i.target.value),onBlur:a,rows:4,placeholder:"输入图片 URL 或 Data URI"})}),e.jsx(t.Form.Item,{label:"填充颜色(基本形状)",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.fillColor||"#1890ff",onChange:i=>{const m=i.toHexString();o("fillColor",m),p({name:n.name,src:n.src,backgroundColor:n.backgroundColor,fillColor:m})}}),e.jsx(t.Input,{value:n.fillColor,onChange:i=>o("fillColor",i.target.value),onBlur:a,placeholder:"#1890ff"})]})}),e.jsx(t.Form.Item,{label:"背景颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.backgroundColor||"#1890ff",onChange:i=>{const m=i.toHexString();o("backgroundColor",m),p({name:n.name,src:n.src,backgroundColor:m,fillColor:n.fillColor})}}),e.jsx(t.Input,{value:n.backgroundColor,onChange:i=>o("backgroundColor",i.target.value),onBlur:a,placeholder:"#1890ff"})]})})]})]})},{Option:Gt}=t.Select,qt=({material:l,onSave:p})=>{const r=l.config||{},[n,d]=g.useState({lineWeight:r.lineWeight||r.thickness||2,color:r.color||"#262626",lineType:r.lineType||"solid",startX:r.startX??0,startY:r.startY??0,endX:r.endX??100,endY:r.endY??0});g.useEffect(()=>{d({lineWeight:r.lineWeight||r.thickness||2,color:r.color||"#262626",lineType:r.lineType||"solid",startX:r.startX??0,startY:r.startY??0,endX:r.endX??100,endY:r.endY??0})},[l.id]);const o=i=>{const m={...n,...i};d(m),p({config:{...r,thickness:m.lineWeight,lineWeight:m.lineWeight,color:m.color,lineType:m.lineType,startX:m.startX,startY:m.startY,endX:m.endX,endY:m.endY}})},a=[{value:"solid",label:"实线",desc:"连续实线"},{value:"dashed",label:"虚线",desc:"长划间隔"},{value:"center",label:"点画线(中心线)",desc:"长点-短点交替"},{value:"phantom",label:"假想线",desc:"长划-双点交替"},{value:"dot",label:"点线",desc:"密集点状"},{value:"dash-dot",label:"画点线",desc:"长划-点交替"}];return e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Divider,{style:{marginTop:0},children:"起止位置(相对节点)"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(t.Form.Item,{label:"起点 X",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.startX,onChange:i=>o({startX:i??0}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"起点 Y",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.startY,onChange:i=>o({startY:i??0}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"终点 X",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.endX,onChange:i=>o({endX:i??100}),style:{width:"100%"}})}),e.jsx(t.Form.Item,{label:"终点 Y",className:"mb-2",children:e.jsx(t.InputNumber,{value:n.endY,onChange:i=>o({endY:i??0}),style:{width:"100%"}})})]}),e.jsx(t.Form.Item,{label:"快速对齐",className:"mt-4",children:e.jsxs(t.Space,{children:[e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startY??n.startY;o({endY:i})},title:"将线条变为水平线",children:"水平"}),e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startX??n.startX;o({endX:i})},title:"将线条变为垂直线",children:"垂直"}),e.jsx(t.Button,{size:"small",onClick:()=>{const i=r.startX??n.startX,m=r.startY??n.startY,h=r.endX??n.endX,f=r.endY??n.endY;o({startX:h,startY:f,endX:i,endY:m})},title:"交换起点和终点",children:"反向"})]})})]}),e.jsx(t.Divider,{children:"线条属性"}),e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"线型",help:"选择线条样式",children:e.jsx(t.Select,{value:n.lineType,onChange:i=>o({lineType:i}),children:a.map(i=>e.jsx(Gt,{value:i.value,children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{children:i.label}),e.jsx("span",{className:"text-xs text-gray-400",children:i.desc})]})},i.value))})}),e.jsx(t.Form.Item,{label:"线宽(像素)",children:e.jsx(t.InputNumber,{value:n.lineWeight,onChange:i=>o({lineWeight:i||2}),min:1,max:20,style:{width:120}})}),e.jsx(t.Form.Item,{label:"颜色",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{value:n.color||"#d9d9d9",onChange:i=>o({color:i.toHexString()})}),e.jsx(t.Input,{value:n.color,onChange:i=>o({color:i.target.value}),placeholder:"#d9d9d9",style:{width:100}})]})})]})]})},mt=({material:l,onSave:p,bindCodes:r,dataOptions:n})=>{switch(l.type){case"TEXT":return e.jsx(Bt,{material:l,onSave:p,bindCodes:r,dataOptions:n});case"IMAGE":return e.jsx(Ut,{material:l,onSave:p});case"LINE":return e.jsx(qt,{material:l,onSave:p});default:return e.jsx("div",{className:"text-center text-gray-400 py-8",children:"暂不支持编辑此类型的物料"})}},{Panel:yt}=t.Collapse,{TextArea:Ht}=t.Input,Vt=({node:l,updateNode:p,materials:r})=>{const n=r.filter(f=>f.type!=="CUSTOM"||!f.config?.nodes),d=(f,S)=>{const u=l.children?.map(E=>E.id===f?{...E,contentInfo:{...E.contentInfo,statusList:S}}:E);p(l.id,{children:u})},o=f=>{const S=l.children?.find(E=>E.id===f);if(!S)return;const u={id:G.nanoid(),name:`状态${S.contentInfo.statusList.length+1}`,expression:S.contentInfo.statusList.length===0?"return true;":"return false;",material:{...n[0],id:G.nanoid()},bindCodes:[]};d(f,[...S.contentInfo.statusList,u])},a=(f,S)=>{const u=l.children?.find(v=>v.id===f);if(!u)return;const E=u.contentInfo.statusList.filter(v=>v.id!==S);d(f,E)},i=(f,S,u)=>{const E=l.children?.find(I=>I.id===f);if(!E)return;const v=E.contentInfo.statusList.map(I=>I.id===S?{...I,...u}:I);d(f,v)},m=(f,S,u)=>{const E=l.children?.find(b=>b.id===f);if(!E)return;const v=E.contentInfo.statusList.findIndex(b=>b.id===S);if(v===-1)return;const I=[...E.contentInfo.statusList];u==="up"&&v>0?[I[v],I[v-1]]=[I[v-1],I[v]]:u==="down"&&v<I.length-1&&([I[v],I[v+1]]=[I[v+1],I[v]]),d(f,I)},h=(f,S,u)=>{const E=r.find(v=>v.id===u);E&&i(f,S,{material:{...E,id:G.nanoid()}})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg mb-4",children:e.jsxs("div",{className:"text-sm text-blue-700",children:[e.jsx("strong",{children:"群组节点"}),":为每个子节点配置多个状态和绑定"]})}),e.jsx(t.Collapse,{ghost:!0,children:l.children?.map((f,S)=>e.jsx(yt,{header:e.jsxs("div",{className:"flex items-center justify-between w-full pr-4",children:[e.jsxs("span",{className:"font-medium text-sm",children:["子节点 ",S+1]}),e.jsxs(t.Tag,{color:"blue",style:{fontSize:"12px",padding:"0 4px"},children:[f.contentInfo.statusList.length," 个状态"]})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("span",{className:"text-sm text-gray-600",children:"状态列表"}),e.jsx(t.Button,{type:"primary",size:"small",icon:e.jsx(Y.PlusOutlined,{}),onClick:()=>o(f.id),children:"添加状态"})]}),f.contentInfo.statusList.length===0?e.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):e.jsx(t.Collapse,{ghost:!0,children:f.contentInfo.statusList.map((u,E)=>e.jsx(yt,{header:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400 w-5",children:E+1}),e.jsx("span",{className:"font-medium",children:u.name}),e.jsx(t.Tag,{color:"default",className:"text-xs",children:u.material.type})]}),extra:e.jsxs(t.Space,{size:"small",onClick:v=>v.stopPropagation(),children:[e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.ArrowUpOutlined,{}),disabled:E===0,onClick:v=>{v.stopPropagation(),m(f.id,u.id,"up")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.ArrowDownOutlined,{}),disabled:E===f.contentInfo.statusList.length-1,onClick:v=>{v.stopPropagation(),m(f.id,u.id,"down")}}),e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(Y.DeleteOutlined,{}),onClick:v=>{v.stopPropagation(),a(f.id,u.id)}})]}),children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"状态名称",children:e.jsx(t.Input,{value:u.name,onChange:v=>i(f.id,u.id,{name:v.target.value}),placeholder:"输入状态名称"})}),e.jsx(t.Form.Item,{label:"执行表达式",help:"返回 true 时激活此状态,可使用 data 变量访问绑定数据",children:e.jsx(Ht,{value:u.expression,onChange:v=>i(f.id,u.id,{expression:v.target.value}),rows:3,placeholder:"return true;"})}),e.jsx(t.Form.Item,{label:"绑定数据源 (bindCodes)",children:e.jsx(t.Select,{mode:"tags",value:u.bindCodes||[],onChange:v=>i(f.id,u.id,{bindCodes:v}),placeholder:"输入数据源 code",tokenSeparators:[","," "]})}),e.jsx(t.Form.Item,{label:"更换物料",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Tag,{color:"blue",children:u.material.name}),e.jsx(t.Tag,{color:"default",children:u.material.type}),e.jsx(t.Select,{placeholder:"选择新物料",style:{width:150},value:void 0,onChange:v=>v&&h(f.id,u.id,v),options:n.map(v=>({value:v.id,label:`${v.name} (${v.type})`}))})]})}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),e.jsx(t.Tag,{children:u.material.name})]}),e.jsx(mt,{material:u.material,onSave:v=>{const I={...u.material,...v};i(f.id,u.id,{material:I})}})]})]})},u.id))})]})},f.id))})]})},{Panel:pe}=t.Collapse,{TabPane:Je}=t.Tabs,{TextArea:Zt}=t.Input,wt=({defaultTestData:l})=>{const{nodes:p,selectedNodeId:r,updateNode:n,updateNodeStyle:d,updateNodeControl:o,updateNodeContent:a,materials:i,selectedStatusId:m,selectStatus:h}=ye(),[f]=t.Form.useForm(),[S,u]=g.useState("basic"),[E,v]=g.useState(!1),[I,b]=g.useState(null),[q,W]=g.useState({}),F=g.useMemo(()=>p.find(c=>c.id===r),[p,r]),L=F?.contentInfo.statusList||[],T=c=>{r&&(c.normalStyle&&d(r,c.normalStyle),c.name!==void 0&&n(r,{name:c.name}),c.controlInfo&&o(r,c.controlInfo))};console.log(r,"selectedNodeId",F),g.useEffect(()=>{F&&F&&(f.setFieldsValue({name:F.name,normalStyle:{width:100,height:100,x:0,y:0,padding:8,background:"transparent",borderRadius:0,opacity:1,...F.normalStyle},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0,...F.controlInfo}}),h(null))},[F,h,f]);const ue=()=>{!r||!F||(b("new"),v(!0))},ee=c=>{if(!r||!F)return;const V={id:G.nanoid(),name:`${c.name}_状态${L.length+1}`,expression:L.length===0?"return true;":"return false;",material:{...c,id:G.nanoid()},bindCodes:[]};if(I==="new"){const x=[...L,V];a(r,{statusList:x})}else if(I){const x=L.map($=>$.id===I?{...$,material:{...c,id:G.nanoid()}}:$);a(r,{statusList:x})}v(!1),b(null)},ge=c=>{if(!r||!F)return;const V=F.contentInfo.statusList?.filter(x=>x.id!==c)||[];a(r,{statusList:V}),m===c&&h(null)},oe=(c,V)=>{if(!r||!F)return;const x=F.contentInfo.statusList?.map($=>$.id===c?{...$,...V}:$)||[];a(r,{statusList:x})},B=c=>{if(!r||!F)return;const V={...c,id:G.nanoid(),name:`${c.name}_复制`,expression:"return false;"},x=[...L,V];a(r,{statusList:x})},K=(c,V)=>{if(!r||!F)return;const x=L.findIndex(M=>M.id===c);if(x===-1)return;const $=[...L];V==="up"&&x>0?[$[x],$[x-1]]=[$[x-1],$[x]]:V==="down"&&x<$.length-1&&([$[x],$[x+1]]=[$[x+1],$[x]]),a(r,{statusList:$})},H=c=>{b(c),v(!0)},P=(c,V)=>{if(!r||!F)return;const x=L.map($=>$.id===c?{...$,material:{...$.material,...V}}:$);a(r,{statusList:x})};return F?e.jsxs("div",{className:"h-full flex flex-col bg-white border-l border-gray-200",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"属性面板"}),e.jsx("p",{className:"text-sm text-gray-500",children:"编辑选中节点的属性"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:e.jsxs(t.Tabs,{activeKey:S,onChange:u,children:[e.jsx(Je,{tab:"基础",children:e.jsxs(t.Form,{form:f,layout:"vertical",onValuesChange:T,initialValues:{name:F.name},children:[e.jsx(t.Form.Item,{label:"节点名称",name:"name",children:e.jsx(t.Input,{placeholder:"输入节点名称"})}),e.jsxs(t.Collapse,{ghost:!0,defaultActiveKey:["position","size","style"],children:[e.jsx(pe,{header:"位置",children:e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"X",name:["normalStyle","x"],children:e.jsx(t.InputNumber,{})}),e.jsx(t.Form.Item,{label:"Y",name:["normalStyle","y"],children:e.jsx(t.InputNumber,{})})]})},"position"),e.jsx(pe,{header:"尺寸",children:e.jsxs(t.Space,{children:[e.jsx(t.Form.Item,{label:"宽度",name:["normalStyle","width"],children:e.jsx(t.InputNumber,{min:10})}),e.jsx(t.Form.Item,{label:"高度",name:["normalStyle","height"],children:e.jsx(t.InputNumber,{min:10})})]})},"size"),e.jsxs(pe,{header:"样式",children:[e.jsx(t.Form.Item,{label:"背景色",name:["normalStyle","background"],children:e.jsx(t.Input,{placeholder:"transparent, #fff, url(...)"})}),e.jsx(t.Form.Item,{label:"内边距",name:["normalStyle","padding"],children:e.jsx(t.InputNumber,{min:0})}),e.jsx(t.Form.Item,{label:"圆角",name:["normalStyle","borderRadius"],children:e.jsx(t.InputNumber,{min:0})}),e.jsx(t.Form.Item,{label:"缩放比例",name:["normalStyle","scale"],help:"等比缩放节点的宽高",children:e.jsx(t.InputNumber,{min:.1,max:5,step:.1})}),e.jsx(t.Form.Item,{label:"旋转角度",name:["normalStyle","rotate"],help:"顺时针旋转角度(度)",children:e.jsx(t.InputNumber,{min:0,max:360,step:1})}),e.jsx(t.Form.Item,{label:"透明度",name:["normalStyle","opacity"],children:e.jsx(t.InputNumber,{min:0,max:1,step:.1})}),e.jsx(t.Form.Item,{label:"层级",name:["normalStyle","zIndex"],children:e.jsx(t.InputNumber,{})})]},"style")]})]})},"basic"),e.jsx(Je,{tab:"状态",children:F.type==="group"&&F.children?e.jsx(Vt,{node:F,updateNode:n,materials:i}):e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("span",{className:"font-medium",children:["状态列表",e.jsx(t.Tag,{color:"blue",className:"ml-2",children:L.length})]}),e.jsx(t.Button,{type:"primary",size:"small",icon:e.jsx(Y.PlusOutlined,{}),onClick:ue,children:"添加状态"})]}),e.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"节点根据状态表达式计算结果显示对应物料,第一个返回 true 的状态为当前状态"}),L.length>0&&e.jsx("div",{className:"mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx("span",{className:"text-sm text-gray-600",children:"当前状态:"}),e.jsx("span",{className:"ml-2 text-sm font-medium text-blue-600",children:"由表达式自动计算"})]})})}),L.length===0?e.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):e.jsx(t.Collapse,{ghost:!0,defaultActiveKey:L[0]?.id+r,children:L.map((c,V)=>e.jsx(pe,{header:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-gray-400 w-5",children:V+1}),e.jsx("span",{className:"font-medium",children:c.name}),e.jsx(t.Tag,{color:"default",className:"text-xs",children:c.material.type})]}),extra:e.jsxs(t.Space,{size:"small",onClick:x=>x.stopPropagation(),children:[e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.ArrowUpOutlined,{}),disabled:V===0,onClick:x=>{x.stopPropagation(),K(c.id,"up")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.ArrowDownOutlined,{}),disabled:V===L.length-1,onClick:x=>{x.stopPropagation(),K(c.id,"down")}}),e.jsx(t.Button,{type:"text",size:"small",icon:e.jsx(Y.CopyOutlined,{}),onClick:x=>{x.stopPropagation(),B(c)}}),e.jsx(t.Button,{type:"text",size:"small",danger:!0,icon:e.jsx(Y.DeleteOutlined,{}),onClick:x=>{x.stopPropagation(),ge(c.id)}})]}),children:e.jsxs(t.Form,{layout:"vertical",children:[e.jsx(t.Form.Item,{label:"状态名称",children:e.jsx(t.Input,{value:c.name,onChange:x=>oe(c.id,{name:x.target.value}),placeholder:"输入状态名称"})}),e.jsx(t.Form.Item,{label:"执行表达式",help:"返回 true 时激活此状态,可使用 data 变量访问绑定数据",children:e.jsx(Zt,{value:q[c.id]??c.expression,onChange:x=>W($=>({...$,[c.id]:x.target.value})),onBlur:x=>{oe(c.id,{expression:x.target.value}),W($=>{const M={...$};return delete M[c.id],M})},rows:3,placeholder:"return true;"})}),e.jsx(t.Form.Item,{label:"绑定数据源 (bindCodes)",children:e.jsx(t.Select,{mode:"tags",value:c.bindCodes||[],onChange:x=>oe(c.id,{bindCodes:x}),placeholder:"输入数据源 code",tokenSeparators:[","," "]})}),e.jsx(t.Form.Item,{label:"绑定物料",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t.Tag,{color:"blue",children:c.material.name}),e.jsx(t.Tag,{color:"default",children:c.material.type}),e.jsx(t.Button,{type:"link",size:"small",icon:e.jsx(Y.EditOutlined,{}),onClick:()=>H(c.id),children:"更换物料"})]})}),e.jsx(t.Divider,{style:{margin:"12px 0"}}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),e.jsx(t.Tag,{children:c.material.name})]}),e.jsx(mt,{material:c.material,onSave:x=>P(c.id,x),bindCodes:c.bindCodes||[],dataOptions:l||[]})]})]})},c.id+r))})]})},"status"),e.jsx(Je,{tab:"控制",children:e.jsxs(t.Form,{form:f,layout:"vertical",onValuesChange:T,children:[e.jsx(t.Form.Item,{label:"可拖拽",name:["controlInfo","isDraggable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可点击",name:["controlInfo","isClickable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可调整大小",name:["controlInfo","isResizable"],valuePropName:"checked",children:e.jsx(t.Switch,{})}),e.jsx(t.Form.Item,{label:"可选中",name:["controlInfo","isSelectable"],valuePropName:"checked",children:e.jsx(t.Switch,{})})]})},"control")]})}),e.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:e.jsxs("div",{className:"text-xs text-gray-500",children:[e.jsxs("div",{children:["节点 ID: ",F.id.slice(0,8),"..."]}),e.jsxs("div",{children:["状态数: ",L.length]})]})}),e.jsx(t.Modal,{title:"选择物料",open:E,onCancel:()=>{v(!1),b(null)},footer:null,width:600,children:e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs(t.Collapse,{ghost:!0,defaultActiveKey:["basic","device","text","line"],children:[e.jsx(pe,{header:"基础形状",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>["矩形","圆形","圆角矩形"].includes(c.name)).map(c=>e.jsx(vt,{material:c,onClick:()=>ee(c)},c.id))})},"basic"),e.jsx(pe,{header:"设备图标",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>["阀门","泵","罐体"].includes(c.name)||c.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(c.name)).map(c=>e.jsx(vt,{material:c,onClick:()=>ee(c)},c.id))})},"device"),e.jsx(pe,{header:"文本",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>c.type==="TEXT").map(c=>e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>ee(c),children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:e.jsx("span",{className:"text-lg font-bold text-gray-500",children:"T"})}),e.jsx("span",{className:"text-xs",children:c.name})]},c.id))})},"text"),e.jsx(pe,{header:"线条",children:e.jsx("div",{className:"grid grid-cols-4 gap-2",children:i.filter(c=>c.type==="LINE").map(c=>e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>ee(c),children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:e.jsx("div",{className:"w-8 h-0.5 bg-gray-400"})}),e.jsx("span",{className:"text-xs",children:c.name})]},c.id))})},"line")]})})})]}):e.jsx("div",{className:"h-full flex items-center justify-center bg-white border-l border-gray-200",children:e.jsx(t.Empty,{description:"请选择一个节点"})})},vt=({material:l,onClick:p})=>{const r=l.type==="IMAGE"?l.src:void 0;return e.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:p,children:[e.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center",children:r?e.jsx("img",{src:r,alt:l.name,className:"w-10 h-10 object-contain"}):e.jsx("span",{className:"text-xs",children:l.name[0]})}),e.jsx("span",{className:"text-xs",children:l.name})]})},Jt={configEditor:"ConfigEditor-module__configEditor__dinNG"},{Header:Kt,Sider:xt,Content:Qt}=t.Layout,Rt=({initialScheme:l,onChange:p,readonly:r=!1,headerExtra:n,className:d="",style:o,showHeader:a=!0,showMaterialPanel:i=!0,showPropertyPanel:m=!0,customMaterials:h})=>{const[f,S]=g.useState(!1),[u,E]=g.useState(""),[v,I]=g.useState([{paramsCode:"001",paramsName:"通频速度有效值",value:25,paramsUnit:"mm/s"},{paramsCode:"002",paramsName:"通频加速度有效值",value:1.5,paramsUnit:"m/s²"}]),{exportScheme:b,importScheme:q,nodes:W,materials:F,addMaterial:L}=ye();g.useRef(null);const T=g.useRef(!1);g.useEffect(()=>{T.current||(T.current=!0,F.length===0&&ut.forEach(B=>L(B)),h&&h.length>0&&h.forEach(B=>L(B)),l&&q(l))},[]),g.useEffect(()=>{if(p){const B=b();p(B)}},[W,p]);const ue=g.useCallback(()=>{const B=b(),K=JSON.stringify(B,null,2),H="data:application/json;charset=utf-8,"+encodeURIComponent(K),P=`scheme_${Date.now()}.json`,c=document.createElement("a");c.setAttribute("href",H),c.setAttribute("download",P),c.click(),t.message.success("导出成功!")},[b]),ee=g.useCallback(()=>{try{const B=JSON.parse(u);q(B),S(!1),E(""),t.message.success("导入成功!")}catch{t.message.error("JSON 格式错误,请检查输入")}},[u,q]),ge=g.useCallback(B=>{const K=new FileReader;return K.onload=H=>{try{const P=H.target?.result,c=JSON.parse(P);q(c),t.message.success("导入成功!"),S(!1)}catch{t.message.error("文件格式错误")}},K.readAsText(B),!1},[q]),oe=g.useCallback(()=>b(),[b]);return g.useImperativeHandle(g.useRef?.(),()=>({getScheme:oe,exportScheme:b,importScheme:q}),[oe,b,q]),e.jsx(t.ConfigProvider,{locale:Tt,children:e.jsx("div",{className:Jt.configEditor,style:o,children:e.jsxs(t.Layout,{className:`h-full w-full overflow-hidden ${d}`,children:[a&&e.jsxs(Kt,{className:"bg-white border-b border-gray-200 px-4 flex items-center justify-between flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-xl font-bold text-blue-600",children:"组态编辑器"}),e.jsxs("div",{className:"text-sm text-gray-500",children:[W.length," 个节点"]})]}),e.jsxs(t.Space,{children:[n,!r&&e.jsxs(e.Fragment,{children:[e.jsx(t.Tooltip,{title:"导出 JSON",children:e.jsx(t.Button,{icon:e.jsx(Y.DownloadOutlined,{}),onClick:ue,children:"导出"})}),e.jsx(t.Tooltip,{title:"导入 JSON",children:e.jsx(t.Button,{icon:e.jsx(Y.UploadOutlined,{}),onClick:()=>S(!0),children:"导入"})})]})]})]}),e.jsxs(t.Layout,{children:[i&&!r&&e.jsx(xt,{width:280,className:"bg-white",theme:"light",children:e.jsx(ft,{})}),e.jsx(Qt,{className:"bg-gray-100 relative",children:e.jsx(bt,{defaultTestData:v})}),m&&!r&&e.jsx(xt,{width:360,className:"bg-white",theme:"light",children:e.jsx(wt,{defaultTestData:v})})]}),e.jsx(t.Modal,{title:"导入组态方案",open:f,onOk:ee,onCancel:()=>{S(!1),E("")},width:600,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"mb-2",children:"选择 JSON 文件导入:"}),e.jsx("input",{type:"file",accept:".json",onChange:B=>{const K=B.target.files?.[0];K&&ge(K)},className:`block w-full text-sm text-gray-500
|
|
8
8
|
file:mr-4 file:py-2 file:px-4
|
|
9
9
|
file:rounded-full file:border-0
|
|
10
10
|
file:text-sm file:font-semibold
|
|
11
11
|
file:bg-blue-50 file:text-blue-700
|
|
12
|
-
hover:file:bg-blue-100`})]}),e.jsx("div",{className:"text-center text-gray-400",children:"或"}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2",children:"粘贴 JSON 内容:"}),e.jsx("textarea",{value:u,onChange:
|
|
12
|
+
hover:file:bg-blue-100`})]}),e.jsx("div",{className:"text-center text-gray-400",children:"或"}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2",children:"粘贴 JSON 内容:"}),e.jsx("textarea",{value:u,onChange:B=>E(B.target.value),placeholder:"粘贴 JSON 内容...",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"})]})]})})]})})})};R.Canvas=bt,R.ConfigEditor=Rt,R.MaterialPanel=ft,R.NodeRenderer=Ze,R.PropertyPanel=wt,R.createDefaultNode=gt,R.createDefaultStatus=Ve,R.initMaterials=ut,R.useEditorStore=ye,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
13
13
|
//# sourceMappingURL=config-editor.umd.js.map
|