jch-config-editor 0.1.13 → 0.1.15

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,30 @@
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(be,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react"),require("antd"),require("@ant-design/icons"),require("zustand"),require("immer"),require("nanoid"),require("react-zoom-pan-pinch"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","antd","@ant-design/icons","zustand","immer","nanoid","react-zoom-pan-pinch","react-dom"],a):(be=typeof globalThis<"u"?globalThis:be||self,a(be.ConfigEditor={},be.jsxRuntime,be.React,be.antd,be.icons,be.zustand,be.immer,be.nanoid,be.ReactZoomPanPinch))})(this,(function(be,a,E,m,se,sc,ac,he,Yr){"use strict";var Xr=document.createElement("style");Xr.textContent=`.react-flow{direction:ltr;--xy-edge-stroke-default: #b1b1b7;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #555;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(255, 255, 255, .5);--xy-minimap-background-color-default: #fff;--xy-minimap-mask-background-color-default: rgba(240, 240, 240, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #e2e2e2;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: transparent;--xy-background-pattern-dots-color-default: #91919a;--xy-background-pattern-lines-color-default: #eee;--xy-background-pattern-cross-color-default: #e2e2e2;background-color:var(--xy-background-color, var(--xy-background-color-default));--xy-node-color-default: inherit;--xy-node-border-default: 1px solid #1a192b;--xy-node-background-color-default: #fff;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(0, 0, 0, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #1a192b;--xy-node-border-radius-default: 3px;--xy-handle-background-color-default: #1a192b;--xy-handle-border-color-default: #fff;--xy-selection-background-color-default: rgba(0, 89, 220, .08);--xy-selection-border-default: 1px dotted rgba(0, 89, 220, .8);--xy-controls-button-background-color-default: #fefefe;--xy-controls-button-background-color-hover-default: #f4f4f4;--xy-controls-button-color-default: inherit;--xy-controls-button-color-hover-default: inherit;--xy-controls-button-border-color-default: #eee;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #ffffff;--xy-edge-label-color-default: inherit;--xy-resize-background-color-default: #3367d9}.react-flow.dark{--xy-edge-stroke-default: #3e3e3e;--xy-edge-stroke-width-default: 1;--xy-edge-stroke-selected-default: #727272;--xy-connectionline-stroke-default: #b1b1b7;--xy-connectionline-stroke-width-default: 1;--xy-attribution-background-color-default: rgba(150, 150, 150, .25);--xy-minimap-background-color-default: #141414;--xy-minimap-mask-background-color-default: rgba(60, 60, 60, .6);--xy-minimap-mask-stroke-color-default: transparent;--xy-minimap-mask-stroke-width-default: 1;--xy-minimap-node-background-color-default: #2b2b2b;--xy-minimap-node-stroke-color-default: transparent;--xy-minimap-node-stroke-width-default: 2;--xy-background-color-default: #141414;--xy-background-pattern-dots-color-default: #777;--xy-background-pattern-lines-color-default: #777;--xy-background-pattern-cross-color-default: #777;--xy-node-color-default: #f8f8f8;--xy-node-border-default: 1px solid #3c3c3c;--xy-node-background-color-default: #1e1e1e;--xy-node-group-background-color-default: rgba(240, 240, 240, .25);--xy-node-boxshadow-hover-default: 0 1px 4px 1px rgba(255, 255, 255, .08);--xy-node-boxshadow-selected-default: 0 0 0 .5px #999;--xy-handle-background-color-default: #bebebe;--xy-handle-border-color-default: #1e1e1e;--xy-selection-background-color-default: rgba(200, 200, 220, .08);--xy-selection-border-default: 1px dotted rgba(200, 200, 220, .8);--xy-controls-button-background-color-default: #2b2b2b;--xy-controls-button-background-color-hover-default: #3e3e3e;--xy-controls-button-color-default: #f8f8f8;--xy-controls-button-color-hover-default: #fff;--xy-controls-button-border-color-default: #5b5b5b;--xy-controls-box-shadow-default: 0 0 2px 1px rgba(0, 0, 0, .08);--xy-edge-label-background-color-default: #141414;--xy-edge-label-color-default: #f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props, var(--xy-background-color, var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width, var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke, var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width, var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{overflow:visible;position:absolute;pointer-events:none}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected, var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke, var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:dashdraw .5s linear infinite}svg.react-flow__connectionline{z-index:1001;overflow:visible;position:absolute}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background-color:var(--xy-handle-background-color, var(--xy-handle-background-color-default));border:1px solid var(--xy-handle-border-color, var(--xy-handle-border-color-default));border-radius:100%}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:0;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px) translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px) translateY(-50%)}.react-flow__attribution{font-size:10px;background:var(--xy-attribution-background-color, var(--xy-attribution-background-color-default));padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;left:0;top:0}.react-flow__viewport-portal{position:absolute;width:100%;height:100%;left:0;top:0;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__minimap{background:var( --xy-minimap-background-color-props, var(--xy-minimap-background-color, var(--xy-minimap-background-color-default)) )}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var( --xy-minimap-mask-background-color-props, var(--xy-minimap-mask-background-color, var(--xy-minimap-mask-background-color-default)) );stroke:var( --xy-minimap-mask-stroke-color-props, var(--xy-minimap-mask-stroke-color, var(--xy-minimap-mask-stroke-color-default)) );stroke-width:var( --xy-minimap-mask-stroke-width-props, var(--xy-minimap-mask-stroke-width, var(--xy-minimap-mask-stroke-width-default)) )}.react-flow__minimap-node{fill:var( --xy-minimap-node-background-color-props, var(--xy-minimap-node-background-color, var(--xy-minimap-node-background-color-default)) );stroke:var( --xy-minimap-node-stroke-color-props, var(--xy-minimap-node-stroke-color, var(--xy-minimap-node-stroke-color-default)) );stroke-width:var( --xy-minimap-node-stroke-width-props, var(--xy-minimap-node-stroke-width, var(--xy-minimap-node-stroke-width-default)) )}.react-flow__background-pattern.dots{fill:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-dots-color-default)) )}.react-flow__background-pattern.lines{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-lines-color-default)) )}.react-flow__background-pattern.cross{stroke:var( --xy-background-pattern-color-props, var(--xy-background-pattern-color, var(--xy-background-pattern-cross-color-default)) )}.react-flow__controls{display:flex;flex-direction:column;box-shadow:var(--xy-controls-box-shadow, var(--xy-controls-box-shadow-default))}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{display:flex;justify-content:center;align-items:center;height:26px;width:26px;padding:4px;border:none;background:var(--xy-controls-button-background-color, var(--xy-controls-button-background-color-default));border-bottom:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) );color:var( --xy-controls-button-color-props, var(--xy-controls-button-color, var(--xy-controls-button-color-default)) );cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px;fill:currentColor}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:var(--xy-node-border-radius, var(--xy-node-border-radius-default));width:150px;font-size:12px;color:var(--xy-node-color, var(--xy-node-color-default));text-align:center;border:var(--xy-node-border, var(--xy-node-border-default));background-color:var(--xy-node-background-color, var(--xy-node-background-color-default))}.react-flow__node-input.selectable:hover,.react-flow__node-default.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:var(--xy-node-boxshadow-hover, var(--xy-node-boxshadow-hover-default))}.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:var(--xy-node-boxshadow-selected, var(--xy-node-boxshadow-selected-default))}.react-flow__node-group{background-color:var(--xy-node-group-background-color, var(--xy-node-group-background-color-default))}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color, var(--xy-selection-background-color-default));border:var(--xy-selection-border, var(--xy-selection-border-default))}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls-button:hover{background:var( --xy-controls-button-background-color-hover-props, var(--xy-controls-button-background-color-hover, var(--xy-controls-button-background-color-hover-default)) );color:var( --xy-controls-button-color-hover-props, var(--xy-controls-button-color-hover, var(--xy-controls-button-color-hover-default)) )}.react-flow__controls-button:disabled{pointer-events:none}.react-flow__controls-button:disabled svg{fill-opacity:.4}.react-flow__controls-button:last-child{border-bottom:none}.react-flow__controls.horizontal .react-flow__controls-button{border-bottom:none;border-right:1px solid var( --xy-controls-button-border-color-props, var(--xy-controls-button-border-color, var(--xy-controls-button-border-color-default)) )}.react-flow__controls.horizontal .react-flow__controls-button:last-child{border-right:none}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{width:5px;height:5px;border:1px solid #fff;border-radius:1px;background-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));translate:-50% -50%}.react-flow__resize-control.handle.left{left:0;top:50%}.react-flow__resize-control.handle.right{left:100%;top:50%}.react-flow__resize-control.handle.top{left:50%;top:0}.react-flow__resize-control.handle.bottom{left:50%;top:100%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color, var(--xy-resize-background-color-default));border-width:0;border-style:solid}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;transform:translate(-50%);top:0;height:100%}.react-flow__resize-control.line.left{left:0;border-left-width:1px}.react-flow__resize-control.line.right{left:100%;border-right-width:1px}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{height:1px;transform:translateY(-50%);left:0;width:100%}.react-flow__resize-control.line.top{top:0;border-top-width:1px}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}.react-flow__edge-textbg{fill:var(--xy-edge-label-background-color, var(--xy-edge-label-background-color-default))}.react-flow__edge-text{fill:var(--xy-edge-label-color, var(--xy-edge-label-color-default))}.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}.static{position:static}.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}.m-0{margin:0}.mx-2{margin-left:.5rem;margin-right:.5rem}.mx-auto{margin-left:auto;margin-right:auto}.\\!mr-0{margin-right:0!important}.mb-0{margin-bottom:0}.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-0\\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.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-6{height:1.5rem}.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%}.w-px{width:1px}.min-w-0{min-width:0px}.min-w-\\[180px\\]{min-width:180px}.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}.list-none{list-style-type: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-end{justify-content:flex-end}.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-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-amber-100{--tw-border-opacity: 1;border-color:rgb(254 243 199 / var(--tw-border-opacity, 1))}.border-amber-200{--tw-border-opacity: 1;border-color:rgb(253 230 138 / var(--tw-border-opacity, 1))}.border-amber-300{--tw-border-opacity: 1;border-color:rgb(252 211 77 / var(--tw-border-opacity, 1))}.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-500{--tw-bg-opacity: 1 !important;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))!important}.bg-amber-50{--tw-bg-opacity: 1;background-color:rgb(255 251 235 / var(--tw-bg-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-50\\/50{background-color:#eff6ff80}.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-300{--tw-bg-opacity: 1;background-color:rgb(209 213 219 / 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-0{padding:0}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.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}.pl-1{padding-left:.25rem}.pl-2{padding-left:.5rem}.pr-4{padding-right:1rem}.pt-1{padding-top:.25rem}.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-amber-800{--tw-text-opacity: 1;color:rgb(146 64 14 / var(--tw-text-opacity, 1))}.text-amber-950{--tw-text-opacity: 1;color:rgb(69 26 3 / var(--tw-text-opacity, 1))}.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-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / 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)}.shadow-md{--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);--tw-shadow-colored: 0 4px 6px -1px var(--tw-shadow-color), 0 2px 4px -2px 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\\:text-red-500:hover{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-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(Xr);function Vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rt={},To={exports:{}},Wr;function Oo(){return Wr||(Wr=1,(function(e){function t(n){return n&&n.__esModule?n:{default:n}}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports})(To)),To.exports}var en={},qr;function lc(){if(qr)return en;qr=1,Object.defineProperty(en,"__esModule",{value:!0}),en.default=void 0;const e={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 en.default=e,en}var tn={},nn={},on={},rn={},jr;function cc(){return jr||(jr=1,Object.defineProperty(rn,"__esModule",{value:!0}),rn.commonLocale=void 0,rn.commonLocale={yearFormat:"YYYY",dayFormat:"D",cellMeridiemFormat:"A",monthBeforeYear:!0}),rn}var Ur;function dc(){if(Ur)return on;Ur=1,Object.defineProperty(on,"__esModule",{value:!0}),on.default=void 0;var e=cc();function t(d){"@babel/helpers - typeof";return t=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},t(d)}function n(d,c){var u=Object.keys(d);if(Object.getOwnPropertySymbols){var f=Object.getOwnPropertySymbols(d);c&&(f=f.filter(function(h){return Object.getOwnPropertyDescriptor(d,h).enumerable})),u.push.apply(u,f)}return u}function o(d){for(var c=1;c<arguments.length;c++){var u=arguments[c]!=null?arguments[c]:{};c%2?n(Object(u),!0).forEach(function(f){r(d,f,u[f])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(u)):n(Object(u)).forEach(function(f){Object.defineProperty(d,f,Object.getOwnPropertyDescriptor(u,f))})}return d}function r(d,c,u){return c=i(c),c in d?Object.defineProperty(d,c,{value:u,enumerable:!0,configurable:!0,writable:!0}):d[c]=u,d}function i(d){var c=s(d,"string");return t(c)=="symbol"?c:String(c)}function s(d,c){if(t(d)!="object"||!d)return d;var u=d[Symbol.toPrimitive];if(u!==void 0){var f=u.call(d,c);if(t(f)!="object")return f;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(d)}var l=o(o({},e.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 on.default=l,on}var sn={},Gr;function Kr(){if(Gr)return sn;Gr=1,Object.defineProperty(sn,"__esModule",{value:!0}),sn.default=void 0;const e={placeholder:"请选择时间",rangePlaceholder:["开始时间","结束时间"]};return sn.default=e,sn}var Zr;function Jr(){if(Zr)return nn;Zr=1;var e=Oo().default;Object.defineProperty(nn,"__esModule",{value:!0}),nn.default=void 0;var t=e(dc()),n=e(Kr());const o={lang:{placeholder:"请选择日期",yearPlaceholder:"请选择年份",quarterPlaceholder:"请选择季度",monthPlaceholder:"请选择月份",weekPlaceholder:"请选择周",rangePlaceholder:["开始日期","结束日期"],rangeYearPlaceholder:["开始年份","结束年份"],rangeMonthPlaceholder:["开始月份","结束月份"],rangeQuarterPlaceholder:["开始季度","结束季度"],rangeWeekPlaceholder:["开始周","结束周"],...t.default},timePickerLocale:{...n.default}};return o.lang.ok="确定",nn.default=o,nn}var Qr;function uc(){if(Qr)return tn;Qr=1;var e=Oo().default;Object.defineProperty(tn,"__esModule",{value:!0}),tn.default=void 0;var t=e(Jr());return tn.default=t.default,tn}var Rr;function fc(){if(Rr)return Rt;Rr=1;var e=Oo().default;Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.default=void 0;var t=e(lc()),n=e(uc()),o=e(Jr()),r=e(Kr());const i="${label}不是一个有效的${type}",s={locale:"zh-cn",Pagination:t.default,DatePicker:o.default,TimePicker:r.default,Calendar:n.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:i,method:i,array:i,object:i,number:i,date:i,boolean:i,integer:i,float:i,regexp:i,email:i,url:i,hex:i},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 Rt.default=s,Rt}var Ao,ei;function hc(){return ei||(ei=1,Ao=fc()),Ao}var pc=hc();const gc=Vr(pc),mc=e=>(t,n,o)=>(o.setState=(r,i,...s)=>{const l=typeof r=="function"?ac.produce(r):r;return t(l,i,...s)},e(o.setState,n,o));function ti(e){const t=[];for(const n of Object.keys(e)){t.push(n);const o=e[n];if(o!==null&&typeof o=="object"&&!Array.isArray(o))for(const r of Object.keys(o))t.push(`${n}.${r}`)}return t}function ni(e,t){const n=e.sample&&typeof e.sample=="object"&&!Array.isArray(e.sample)?{...e.sample}:{};if(t&&typeof t=="object"&&!Array.isArray(t))return{...n,...t};if(Array.isArray(t)){const o={...n};for(const r of t){if(!r||typeof r!="object")continue;const i=r;i.paramsCode!=null&&(o[String(i.paramsCode)]=i.value)}return o}return n}const yc={id:"_",name:"_",sample:{}};function $o(e,t,n){const o=e.boundDatasetId!=null?String(e.boundDatasetId).trim():"",i=(o?n.find(s=>s.id===o):void 0)??yc;try{const s=ni(i,t);return new Function("data",e.expression)(s)===!0}catch(s){return console.warn(`状态表达式执行失败 [${e.name}]:`,s),!1}}function oi(e,t,n){for(const o of e)if($o(o,t,n))return o}function ri(e,t){for(const n of e){for(const o of n.contentInfo.statusList)o.boundDatasetId===t&&(o.boundDatasetId=null);n.type==="group"&&n.children?.length&&ri(n.children,t)}}function ii(e){for(const t of e){for(const n of t.contentInfo.statusList)delete n.bindCodes;t.type==="group"&&t.children?.length&&ii(t.children)}}const Lo=(e,t)=>({id:e||he.nanoid(),name:t||"画布 1",nodes:[],canvasConfig:{width:1920,height:1080,background:"#00193C",showGrid:!0},viewport:{scale:1,positionX:0,positionY:0},selectedNodeId:null,selectedNodeIds:[],selectedStatusId:null,history:{past:[],future:[]}}),si=(()=>{const e=Lo();return{id:he.nanoid(),name:"默认项目",canvases:[e],currentCanvasId:e.id}})(),wt=si.canvases[0],bc={root:si,materials:[],mode:"select",lineDrawing:{isDrawing:!1,material:null,startPoint:null,endPoint:null},eventFlow:{eventBlocks:[],eventRoots:[],editingEventRootId:null,isEditingEventFlow:!1},dataPool:[],nodes:wt.nodes,canvas:wt.canvasConfig,viewport:wt.viewport,selectedNodeId:wt.selectedNodeId,selectedNodeIds:wt.selectedNodeIds,selectedStatusId:wt.selectedStatusId,history:wt.history},at=(e,t,n)=>({id:he.nanoid(),type:e,targetId:t,payload:n,timestamp:Date.now()}),Ie=sc.create()(mc((e,t)=>({...bc,addCanvas:n=>{const o=Lo(he.nanoid(),n||`画布 ${t().root.canvases.length+1}`);return e(r=>{r.root.canvases.push(o),r.root.currentCanvasId=o.id;const i=o;r.nodes=i.nodes,r.canvas=i.canvasConfig,r.viewport=i.viewport,r.selectedNodeId=i.selectedNodeId,r.selectedNodeIds=i.selectedNodeIds,r.selectedStatusId=i.selectedStatusId,r.history=i.history}),o.id},removeCanvas:n=>{e(o=>{const r=o.root.canvases.findIndex(i=>i.id===n);if(r!==-1&&!(o.root.canvases.length<=1)&&(o.root.canvases.splice(r,1),o.root.currentCanvasId===n)){const i=o.root.canvases[0];o.root.currentCanvasId=i.id,o.nodes=i.nodes,o.canvas=i.canvasConfig,o.viewport=i.viewport,o.selectedNodeId=i.selectedNodeId,o.selectedNodeIds=i.selectedNodeIds,o.selectedStatusId=i.selectedStatusId,o.history=i.history}})},switchCanvas:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===n);r&&(o.root.currentCanvasId=n,o.nodes=r.nodes,o.canvas=r.canvasConfig,o.viewport=r.viewport,o.selectedNodeId=r.selectedNodeId,o.selectedNodeIds=r.selectedNodeIds,o.selectedStatusId=r.selectedStatusId,o.history=r.history)})},updateCanvasName:(n,o)=>{e(r=>{const i=r.root.canvases.find(s=>s.id===n);i&&(i.name=o)})},getCurrentCanvas:()=>{const n=t();return n.root.canvases.find(o=>o.id===n.root.currentCanvasId)},setSelectedNodeIds:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.selectedNodeIds=n,o.selectedNodeIds=n)})},addSelectedNodeId:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&!r.selectedNodeIds.includes(n)&&(r.selectedNodeIds.push(n),o.selectedNodeIds=r.selectedNodeIds)})},removeSelectedNodeId:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.selectedNodeIds=r.selectedNodeIds.filter(i=>i!==n),o.selectedNodeIds=r.selectedNodeIds)})},clearSelectedNodeIds:()=>{e(n=>{const o=n.root.canvases.find(r=>r.id===n.root.currentCanvasId);o&&(o.selectedNodeIds=[],n.selectedNodeIds=[])})},addNode:(n,o=!0)=>{e(r=>{const i=r.root.canvases.find(l=>l.id===r.root.currentCanvasId);if(!i)return;const s={...n,id:n.id||he.nanoid()};i.nodes.push(s),r.nodes=i.nodes,o&&(i.selectedNodeId=s.id,r.selectedNodeId=s.id,i.history.past.push(at("NODE_SELECT",s.id)),r.history=i.history)})},updateNode:(n,o)=>{e(r=>{const i=r.root.canvases.find(l=>l.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(l=>l.id===n);s&&(o.normalStyle&&Object.assign(s.normalStyle,o.normalStyle),o.contentInfo&&(s.contentInfo={...s.contentInfo,...o.contentInfo}),o.name&&(s.name=o.name),o.controlInfo&&Object.assign(s.controlInfo,o.controlInfo),i.history.past.push(at("PROPERTY_CHANGE",n,o)),r.history=i.history,r.nodes=i.nodes)})},updateNodeStyle:(n,o)=>{e(r=>{const i=r.root.canvases.find(l=>l.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(l=>l.id===n);s&&(Object.assign(s.normalStyle,o),i.history.past.push(at("PROPERTY_CHANGE",n,{normalStyle:o})),r.history=i.history)})},updateNodeContent:(n,o)=>{e(r=>{const i=r.root.canvases.find(l=>l.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(l=>l.id===n);s&&(s.contentInfo={...s.contentInfo,...o},i.history.past.push(at("PROPERTY_CHANGE",n,{contentInfo:o})),r.history=i.history,r.nodes=i.nodes)})},updateNodeControl:(n,o)=>{e(r=>{const i=r.root.canvases.find(l=>l.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(l=>l.id===n);s&&(Object.assign(s.controlInfo,o),i.history.past.push(at("PROPERTY_CHANGE",n,{controlInfo:o})),r.history=i.history)})},removeNode:n=>{e(o=>{const r=o.root.canvases.find(s=>s.id===o.root.currentCanvasId);if(!r)return;const i=r.nodes.findIndex(s=>s.id===n);i!==-1&&(r.nodes.splice(i,1),o.nodes=r.nodes,r.selectedNodeId===n&&(r.selectedNodeId=null,o.selectedNodeId=null,r.selectedStatusId=null,o.selectedStatusId=null),r.selectedNodeIds=r.selectedNodeIds.filter(s=>s!==n),o.selectedNodeIds=r.selectedNodeIds,r.history.past.push(at("NODE_DELETE",n)),o.history=r.history)})},selectNode:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.selectedNodeId=n,o.selectedNodeId=n,r.selectedStatusId=null,o.selectedStatusId=null,n&&(r.history.past.push(at("NODE_SELECT",n)),o.history=r.history))})},addStatus:(n,o)=>{e(r=>{const i=r.root.canvases.find(d=>d.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(d=>d.id===n);if(!s)return;const l={...o,id:he.nanoid()};s.contentInfo.statusList.push(l),i.history.past.push(at("MATERIAL_STATUS_CHANGE",n,{statusId:l.id})),r.history=i.history})},removeStatus:(n,o)=>{e(r=>{const i=r.root.canvases.find(d=>d.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(d=>d.id===n);if(!s)return;const l=s.contentInfo.statusList.findIndex(d=>d.id===o);l!==-1&&(s.contentInfo.statusList.splice(l,1),s.contentInfo.currentStatusId===o&&(s.contentInfo.currentStatusId=void 0),i.selectedStatusId===o&&(i.selectedStatusId=null,r.selectedStatusId=null))})},updateStatus:(n,o,r)=>{e(i=>{const s=i.root.canvases.find(c=>c.id===i.root.currentCanvasId);if(!s)return;const l=s.nodes.find(c=>c.id===n);if(!l)return;const d=l.contentInfo.statusList.find(c=>c.id===o);d&&Object.assign(d,r)})},selectStatus:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.selectedStatusId=n,o.selectedStatusId=n)})},evaluateCurrentStatus:(n,o)=>{const r=t(),i=r.root.canvases.find(d=>d.id===r.root.currentCanvasId);if(!i)return;const s=i.nodes.find(d=>d.id===n);if(!s)return;const{dataPool:l}=t();for(const d of s.contentInfo.statusList)if($o(d,o,l))return d.id},addDataPoolItem:n=>{const o=he.nanoid();return e(r=>{r.dataPool.push({...n,id:o,sample:n.sample&&typeof n.sample=="object"&&!Array.isArray(n.sample)?n.sample:{}})}),o},updateDataPoolItem:(n,o)=>{e(r=>{const i=r.dataPool.find(s=>s.id===n);i&&(o.name!==void 0&&(i.name=o.name),o.sample!==void 0&&(i.sample=o.sample&&typeof o.sample=="object"&&!Array.isArray(o.sample)?o.sample:{}))})},removeDataPoolItem:n=>{e(o=>{const r=o.dataPool.findIndex(i=>i.id===n);if(r!==-1){o.dataPool.splice(r,1);for(const i of o.root.canvases)ri(i.nodes,n)}})},setDataPool:n=>{e(o=>{o.dataPool=n.map(r=>({...r,sample:r.sample&&typeof r.sample=="object"&&!Array.isArray(r.sample)?r.sample:{}}))})},addMaterial:n=>{e(o=>{const r={...n,id:he.nanoid()};o.materials.push(r)})},updateMaterial:(n,o)=>{e(r=>{const i=r.materials.find(s=>s.id===n);i&&Object.assign(i,o)})},removeMaterial:n=>{e(o=>{const r=o.materials.findIndex(i=>i.id===n);r!==-1&&o.materials.splice(r,1)})},setViewport:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(Object.assign(r.viewport,n),o.viewport=r.viewport)})},setCanvasConfig:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.canvasConfig={...r.canvasConfig,...n},o.canvas=r.canvasConfig)})},setMode:n=>{e(o=>{o.mode=n})},startLineDrawing:n=>{e(o=>{o.mode="line-draw",o.lineDrawing={isDrawing:!0,material:n,startPoint:null,endPoint:null}})},updateLineDrawing:n=>{e(o=>{o.lineDrawing.isDrawing&&(o.lineDrawing.endPoint=n)})},endLineDrawing:()=>{e(n=>{n.mode="select",n.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},cancelLineDrawing:()=>{e(n=>{n.mode="select",n.lineDrawing={isDrawing:!1,material:null,startPoint:null,endPoint:null}})},undo:()=>{e(n=>{const o=n.root.canvases.find(i=>i.id===n.root.currentCanvasId);if(!o)return;const r=o.history.past.pop();r&&(o.history.future.push(r),n.history=o.history)})},redo:()=>{e(n=>{const o=n.root.canvases.find(i=>i.id===n.root.currentCanvasId);if(!o)return;const r=o.history.future.pop();r&&(o.history.past.push(r),n.history=o.history)})},recordEvent:n=>{e(o=>{const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId);r&&(r.history.past.push(n),r.history.future=[],o.history=r.history)})},exportScheme:()=>{const n=t();return{version:"2.0.0",root:n.root,materials:n.materials,dataPool:n.dataPool,eventFlow:n.eventFlow,metadata:{name:n.root.name,description:"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()}}},importScheme:n=>{e(o=>{if(n.root){o.root=n.root,o.materials=n.materials||[],o.dataPool=n.dataPool??[],n.eventFlow&&(o.eventFlow=n.eventFlow);const r=o.root.canvases.find(i=>i.id===o.root.currentCanvasId)||o.root.canvases[0];r&&(o.root.currentCanvasId=r.id,o.nodes=r.nodes,o.canvas=r.canvasConfig,o.viewport=r.viewport,o.selectedNodeId=r.selectedNodeId,o.selectedNodeIds=r.selectedNodeIds,o.selectedStatusId=r.selectedStatusId,o.history=r.history)}else{const r=Lo();r.nodes=n.nodes||[],o.root.canvases=[r],o.root.currentCanvasId=r.id,o.materials=n.materials||[],o.dataPool=n.dataPool??[],o.nodes=r.nodes,o.canvas=r.canvasConfig,o.viewport=n.viewport||r.viewport,o.selectedNodeId=null,o.selectedStatusId=null,o.history={past:[],future:[]}}for(const r of o.root.canvases)ii(r.nodes)})},addEventBlock:n=>{const o=he.nanoid();return e(r=>{r.eventFlow.eventBlocks.push({...n,id:o})}),o},upsertEventBlock:n=>{e(o=>{const r=o.eventFlow.eventBlocks.findIndex(i=>i.id===n.id);r!==-1?o.eventFlow.eventBlocks[r]={...n}:o.eventFlow.eventBlocks.push({...n})})},updateEventBlock:(n,o)=>{e(r=>{const i=r.eventFlow.eventBlocks.find(s=>s.id===n);i&&Object.assign(i,o)})},removeEventBlock:n=>{e(o=>{const r=o.eventFlow.eventBlocks.findIndex(i=>i.id===n);r!==-1&&o.eventFlow.eventBlocks.splice(r,1)})},addEventRoot:n=>{const o=he.nanoid();return e(r=>{r.eventFlow.eventRoots.push({...n,id:o})}),o},updateEventRoot:(n,o)=>{e(r=>{const i=r.eventFlow.eventRoots.find(s=>s.id===n);i&&Object.assign(i,o)})},removeEventRoot:n=>{e(o=>{const r=o.eventFlow.eventRoots.findIndex(i=>i.id===n);r!==-1&&o.eventFlow.eventRoots.splice(r,1)})},setEditingEventRoot:n=>{e(o=>{o.eventFlow.editingEventRootId=n})},setIsEditingEventFlow:n=>{e(o=>{o.eventFlow.isEditingEventFlow=n})},bindNodeEvent:(n,o,r)=>{const i=he.nanoid();return e(s=>{s.eventFlow.eventRoots.push({id:i,bindNodeId:n,eventType:o,flowData:r,enabled:!0})}),i},unbindNodeEvent:(n,o,r)=>{e(i=>{const s=i.eventFlow.eventRoots.findIndex(l=>l.bindNodeId!==n||l.eventType!==o?!1:o==="external"?(l.externalEventKey||"").trim()===(r||"").trim():!0);s!==-1&&i.eventFlow.eventRoots.splice(s,1)})},getNodeEventRoots:n=>t().eventFlow.eventRoots.filter(o=>o.bindNodeId===n)}))),ai=[{id:he.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:he.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:he.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:he.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:he.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:he.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:he.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:he.nanoid(),name:"线条",type:"LINE",config:{thickness:2,lineWeight:2,color:"#262626",lineType:"solid"}}],zo=e=>({id:he.nanoid(),name:"默认状态",expression:"return true;",material:{...e,id:he.nanoid()},boundDatasetId:null}),li=(e,t,n)=>{if(n?.type==="CUSTOM"&&n.config?.nodes){const o=n.config.nodes.map(c=>({...c,id:he.nanoid()}));let r=1/0,i=1/0,s=-1/0,l=-1/0;o.forEach(c=>{const u=c.normalStyle.x||0,f=c.normalStyle.y||0,h=c.normalStyle.width||0,g=c.normalStyle.height||0;r=Math.min(r,u),i=Math.min(i,f),s=Math.max(s,u+h),l=Math.max(l,f+g)});const d=o.map(c=>({...c,normalStyle:{...c.normalStyle,x:(c.normalStyle.x||0)-r,y:(c.normalStyle.y||0)-i,scale:void 0}}));return{id:he.nanoid(),name:n.name||"群组节点",type:"group",normalStyle:{width:s-r,height:l-i,x:e,y:t},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:d}}return{id:he.nanoid(),name:"新节点",type:"normal",normalStyle:{width:120,height:100,x:e,y:t,background:"transparent",padding:8},contentInfo:{statusList:n?[zo(n)]:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}}},{Panel:Tt}=m.Collapse,{Text:Dn}=m.Typography,ci=()=>{const{materials:e,addMaterial:t,removeMaterial:n,selectedStatusId:o,selectStatus:r,mode:i,lineDrawing:s,startLineDrawing:l,cancelLineDrawing:d}=Ie(),[c,u]=E.useState(["basic","device","text","line"]),f=v=>{const w=new FileReader;return w.onload=_=>{const y=_.target?.result;t({name:v.name.replace(".svg",""),type:"IMAGE",src:y})},w.readAsDataURL(v),!1},h={basic:e.filter(v=>["矩形","圆形","圆角矩形"].includes(v.name)),device:e.filter(v=>["阀门","泵","罐体"].includes(v.name)||v.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(v.name)&&v.name!=="自定义"),text:e.filter(v=>v.type==="TEXT"),line:e.filter(v=>v.type==="LINE"),group:e.filter(v=>v.type==="CUSTOM"&&v.config?.nodes),custom:e.filter(v=>v.type==="CUSTOM"&&!v.config?.nodes||v.type==="IMAGE"&&!["矩形","圆形","圆角矩形","阀门","泵","罐体"].includes(v.name))},g=(v,w)=>{v.dataTransfer.effectAllowed="copy",v.dataTransfer.setData("application/json",JSON.stringify(w));const _=v.currentTarget.querySelector(".material-preview");_&&v.dataTransfer.setDragImage(_,20,20)},p=v=>{v.type==="LINE"&&l(v)},b=(v,w=!1)=>{const _=w===!0,y=i==="line-draw"&&_&&s.material?.id===v.id;return a.jsx(m.List.Item,{draggable:!_,onDragStart:x=>g(x,v),onClick:()=>_&&p(v),className:`
3
3
  rounded-lg transition-all duration-200 select-none
4
- ${A?"cursor-pointer":"cursor-move"}
4
+ ${_?"cursor-pointer":"cursor-move"}
5
5
  hover:bg-gray-100
6
- ${$?"bg-blue-50 ring-2 ring-blue-400":""}
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
+ ${y?"bg-blue-50 ring-2 ring-blue-400":""}
7
+ `,actions:[_?a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.EditOutlined,{}),onClick:x=>{x.stopPropagation(),p(v)},children:"绘制"},"draw"):null,a.jsx(m.Button,{type:"text",size:"small",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),onClick:x=>{x.stopPropagation(),n(v.id)}},"delete")].filter(Boolean),children:a.jsxs("div",{className:`flex items-center gap-3 w-full py-2 ${_?"":"pointer-events-none"}`,children:[a.jsx("div",{className:"material-preview w-12 h-12 flex items-center justify-center bg-white rounded border border-gray-200",children:v.type==="IMAGE"&&v.src?a.jsx(m.Image,{src:v.src,alt:v.name,width:40,height:40,preview:!1}):v.type==="TEXT"?a.jsx("span",{className:"text-xs text-gray-500",children:"T"}):v.type==="LINE"?a.jsx("div",{className:"w-8 h-0.5 bg-gray-400"}):v.type==="CUSTOM"&&v.config?.nodes?a.jsx("span",{className:"text-xs text-blue-500 font-bold",children:"G"}):a.jsx("span",{className:"text-xs text-gray-500",children:"?"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx(Dn,{strong:!0,className:"block truncate",children:v.name}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(Dn,{type:"secondary",className:"text-xs",children:v.type}),y&&a.jsx(m.Tag,{color:"blue",className:"text-xs",children:"绘制中"})]})]})]})},v.id)};return a.jsxs("div",{className:"h-full flex flex-col bg-white border-r border-gray-200",children:[a.jsxs("div",{className:"p-4 border-b border-gray-200",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"物料库"}),a.jsx(Dn,{type:"secondary",className:"text-sm",children:"拖拽物料到画布创建节点"})]}),a.jsx("div",{className:"p-3 border-b border-gray-200",children:a.jsx(m.Upload,{accept:".svg",beforeUpload:f,showUploadList:!1,children:a.jsx(m.Button,{icon:a.jsx(se.UploadOutlined,{}),block:!0,type:"dashed",children:"上传 SVG"})})}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:a.jsxs(m.Collapse,{activeKey:c,onChange:v=>u(v),ghost:!0,expandIconPosition:"end",children:[a.jsx(Tt,{header:"基础形状",children:a.jsx(m.List,{dataSource:h.basic,renderItem:v=>b(v,!1),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}})},"basic"),a.jsx(Tt,{header:"设备图标",children:a.jsx(m.List,{dataSource:h.device,renderItem:v=>b(v,!1),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}})},"device"),a.jsx(Tt,{header:"文本",children:a.jsx(m.List,{dataSource:h.text,renderItem:v=>b(v,!1),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}})},"text"),a.jsxs(Tt,{header:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{children:"线条"}),i==="line-draw"&&a.jsx(m.Tag,{color:"blue",className:"text-xs",children:"绘制模式"})]}),children:[a.jsx(m.List,{dataSource:h.line,renderItem:v=>b(v,!0),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}}),i==="line-draw"&&a.jsxs("div",{className:"mt-2 p-2 bg-blue-50 rounded text-xs text-blue-600",children:[a.jsx("div",{children:"点击线条物料开始绘制"}),a.jsx("div",{children:"点击画布确定起点和终点"})]})]},"line"),h.group.length>0&&a.jsx(Tt,{header:"群组",children:a.jsx(m.List,{dataSource:h.group,renderItem:v=>b(v,!1),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}})},"group"),h.custom.length>0&&a.jsx(Tt,{header:"自定义",children:a.jsx(m.List,{dataSource:h.custom,renderItem:v=>b(v,!1),locale:{emptyText:a.jsx(m.Empty,{description:"暂无物料",image:m.Empty.PRESENTED_IMAGE_SIMPLE})}})},"custom")]})}),a.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:a.jsx(Dn,{type:"secondary",className:"text-xs",children:i==="line-draw"?a.jsx(a.Fragment,{children:"💡 提示:点击绘制线段,可连续绘制多段线,双击结束绘制,ESC 取消"}):a.jsx(a.Fragment,{children:"💡 提示:拖拽物料到画布创建节点,点击线条物料进入绘制模式"})})})]})};var Fo=function(e,t){return Fo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])},Fo(e,t)};function lt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Fo(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function vc(e,t,n,o){function r(i){return i instanceof n?i:new n(function(s){s(i)})}return new(n||(n=Promise))(function(i,s){function l(u){try{c(o.next(u))}catch(f){s(f)}}function d(u){try{c(o.throw(u))}catch(f){s(f)}}function c(u){u.done?i(u.value):r(u.value).then(l,d)}c((o=o.apply(e,t||[])).next())})}function di(e,t){var n={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,r,i,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=l(0),s.throw=l(1),s.return=l(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function l(c){return function(u){return d([c,u])}}function d(c){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(o=1,r&&(i=c[0]&2?r.return:c[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,c[1])).done)return i;switch(r=0,i&&(c=[c[0]&2,i.value]),c[0]){case 0:case 1:i=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,r=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(i=n.trys,!(i=i.length>0&&i[i.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!i||c[1]>i[0]&&c[1]<i[3])){n.label=c[1];break}if(c[0]===6&&n.label<i[1]){n.label=i[1],i=c;break}if(i&&n.label<i[2]){n.label=i[2],n.ops.push(c);break}i[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(u){c=[6,u],r=0}finally{o=i=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function Ot(e){var t=typeof Symbol=="function"&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Tn(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var o=n.call(e),r,i=[],s;try{for(;(t===void 0||t-- >0)&&!(r=o.next()).done;)i.push(r.value)}catch(l){s={error:l}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(s)throw s.error}}return i}function On(e,t,n){if(n||arguments.length===2)for(var o=0,r=t.length,i;o<r;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}function At(e){return this instanceof At?(this.v=e,this):new At(e)}function wc(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=n.apply(e,t||[]),r,i=[];return r=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",s),r[Symbol.asyncIterator]=function(){return this},r;function s(g){return function(p){return Promise.resolve(p).then(g,f)}}function l(g,p){o[g]&&(r[g]=function(b){return new Promise(function(v,w){i.push([g,b,v,w])>1||d(g,b)})},p&&(r[g]=p(r[g])))}function d(g,p){try{c(o[g](p))}catch(b){h(i[0][3],b)}}function c(g){g.value instanceof At?Promise.resolve(g.value.v).then(u,f):h(i[0][2],g)}function u(g){d("next",g)}function f(g){d("throw",g)}function h(g,p){g(p),i.shift(),i.length&&d(i[0][0],i[0][1])}}function xc(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ot=="function"?Ot(e):e[Symbol.iterator](),n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n);function o(i){n[i]=e[i]&&function(s){return new Promise(function(l,d){s=e[i](s),r(l,d,s.done,s.value)})}}function r(i,s,l,d){Promise.resolve(d).then(function(c){i({value:c,done:l})},s)}}typeof SuppressedError=="function"&&SuppressedError;function Se(e){return typeof e=="function"}function Bo(e){var t=function(o){Error.call(o),o.stack=new Error().stack},n=e(t);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var Ho=Bo(function(e){return function(n){e(this),this.message=n?n.length+` errors occurred during unsubscription:
8
+ `+n.map(function(o,r){return r+1+") "+o.toString()}).join(`
9
+ `):"",this.name="UnsubscriptionError",this.errors=n}});function An(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var an=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,n,o,r,i;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var l=Ot(s),d=l.next();!d.done;d=l.next()){var c=d.value;c.remove(this)}}catch(b){t={error:b}}finally{try{d&&!d.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}else s.remove(this);var u=this.initialTeardown;if(Se(u))try{u()}catch(b){i=b instanceof Ho?b.errors:[b]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var h=Ot(f),g=h.next();!g.done;g=h.next()){var p=g.value;try{hi(p)}catch(b){i=i??[],b instanceof Ho?i=On(On([],Tn(i)),Tn(b.errors)):i.push(b)}}}catch(b){o={error:b}}finally{try{g&&!g.done&&(r=h.return)&&r.call(h)}finally{if(o)throw o.error}}}if(i)throw new Ho(i)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)hi(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(t)}},e.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},e.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},e.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&An(n,t)},e.prototype.remove=function(t){var n=this._finalizers;n&&An(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),ui=an.EMPTY;function fi(e){return e instanceof an||e&&"closed"in e&&Se(e.remove)&&Se(e.add)&&Se(e.unsubscribe)}function hi(e){Se(e)?e():e.unsubscribe()}var Sc={Promise:void 0},_c={setTimeout:function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return setTimeout.apply(void 0,On([e,t],Tn(n)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function pi(e){_c.setTimeout(function(){throw e})}function gi(){}function $n(e){e()}var Yo=(function(e){lt(t,e);function t(n){var o=e.call(this)||this;return o.isStopped=!1,n?(o.destination=n,fi(n)&&n.add(o)):o.destination=Nc,o}return t.create=function(n,o,r){return new Xo(n,o,r)},t.prototype.next=function(n){this.isStopped||this._next(n)},t.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(n){this.destination.next(n)},t.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(an),Ec=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(o){Ln(o)}},e.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(o){Ln(o)}else Ln(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(n){Ln(n)}},e})(),Xo=(function(e){lt(t,e);function t(n,o,r){var i=e.call(this)||this,s;return Se(n)||!n?s={next:n??void 0,error:o??void 0,complete:r??void 0}:s=n,i.destination=new Ec(s),i}return t})(Yo);function Ln(e){pi(e)}function Cc(e){throw e}var Nc={closed:!0,next:gi,error:Cc,complete:gi},Vo=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function mi(e){return e}function kc(e){return e.length===0?mi:e.length===1?e[0]:function(n){return e.reduce(function(o,r){return r(o)},n)}}var Fe=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(t,n,o){var r=this,i=Mc(t)?t:new Xo(t,n,o);return $n(function(){var s=r,l=s.operator,d=s.source;i.add(l?l.call(i,d):d?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},e.prototype.forEach=function(t,n){var o=this;return n=yi(n),new n(function(r,i){var s=new Xo({next:function(l){try{t(l)}catch(d){i(d),s.unsubscribe()}},error:i,complete:r});o.subscribe(s)})},e.prototype._subscribe=function(t){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(t)},e.prototype[Vo]=function(){return this},e.prototype.pipe=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return kc(t)(this)},e.prototype.toPromise=function(t){var n=this;return t=yi(t),new t(function(o,r){var i;n.subscribe(function(s){return i=s},function(s){return r(s)},function(){return o(i)})})},e.create=function(t){return new e(t)},e})();function yi(e){var t;return(t=e??Sc.Promise)!==null&&t!==void 0?t:Promise}function Ic(e){return e&&Se(e.next)&&Se(e.error)&&Se(e.complete)}function Mc(e){return e&&e instanceof Yo||Ic(e)&&fi(e)}function Pc(e){return Se(e?.lift)}function xt(e){return function(t){if(Pc(t))return t.lift(function(n){try{return e(n,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function St(e,t,n,o,r){return new Dc(e,t,n,o,r)}var Dc=(function(e){lt(t,e);function t(n,o,r,i,s,l){var d=e.call(this,n)||this;return d.onFinalize=s,d.shouldUnsubscribe=l,d._next=o?function(c){try{o(c)}catch(u){n.error(u)}}:e.prototype._next,d._error=i?function(c){try{i(c)}catch(u){n.error(u)}finally{this.unsubscribe()}}:e.prototype._error,d._complete=r?function(){try{r()}catch(c){n.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,d}return t.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;e.prototype.unsubscribe.call(this),!o&&((n=this.onFinalize)===null||n===void 0||n.call(this))}},t})(Yo),Tc=Bo(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),bi=(function(e){lt(t,e);function t(){var n=e.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return t.prototype.lift=function(n){var o=new vi(this,this);return o.operator=n,o},t.prototype._throwIfClosed=function(){if(this.closed)throw new Tc},t.prototype.next=function(n){var o=this;$n(function(){var r,i;if(o._throwIfClosed(),!o.isStopped){o.currentObservers||(o.currentObservers=Array.from(o.observers));try{for(var s=Ot(o.currentObservers),l=s.next();!l.done;l=s.next()){var d=l.value;d.next(n)}}catch(c){r={error:c}}finally{try{l&&!l.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}}})},t.prototype.error=function(n){var o=this;$n(function(){if(o._throwIfClosed(),!o.isStopped){o.hasError=o.isStopped=!0,o.thrownError=n;for(var r=o.observers;r.length;)r.shift().error(n)}})},t.prototype.complete=function(){var n=this;$n(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var o=n.observers;o.length;)o.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(n){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,n)},t.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},t.prototype._innerSubscribe=function(n){var o=this,r=this,i=r.hasError,s=r.isStopped,l=r.observers;return i||s?ui:(this.currentObservers=null,l.push(n),new an(function(){o.currentObservers=null,An(l,n)}))},t.prototype._checkFinalizedStatuses=function(n){var o=this,r=o.hasError,i=o.thrownError,s=o.isStopped;r?n.error(i):s&&n.complete()},t.prototype.asObservable=function(){var n=new Fe;return n.source=this,n},t.create=function(n,o){return new vi(n,o)},t})(Fe),vi=(function(e){lt(t,e);function t(n,o){var r=e.call(this)||this;return r.destination=n,r.source=o,r}return t.prototype.next=function(n){var o,r;(r=(o=this.destination)===null||o===void 0?void 0:o.next)===null||r===void 0||r.call(o,n)},t.prototype.error=function(n){var o,r;(r=(o=this.destination)===null||o===void 0?void 0:o.error)===null||r===void 0||r.call(o,n)},t.prototype.complete=function(){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||o===void 0||o.call(n)},t.prototype._subscribe=function(n){var o,r;return(r=(o=this.source)===null||o===void 0?void 0:o.subscribe(n))!==null&&r!==void 0?r:ui},t})(bi),Oc={now:function(){return Date.now()}},Ac=(function(e){lt(t,e);function t(n,o){return e.call(this)||this}return t.prototype.schedule=function(n,o){return this},t})(an),wi={setInterval:function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return setInterval.apply(void 0,On([e,t],Tn(n)))},clearInterval:function(e){return clearInterval(e)},delegate:void 0},$c=(function(e){lt(t,e);function t(n,o){var r=e.call(this,n,o)||this;return r.scheduler=n,r.work=o,r.pending=!1,r}return t.prototype.schedule=function(n,o){var r;if(o===void 0&&(o=0),this.closed)return this;this.state=n;var i=this.id,s=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(s,i,o)),this.pending=!0,this.delay=o,this.id=(r=this.id)!==null&&r!==void 0?r:this.requestAsyncId(s,this.id,o),this},t.prototype.requestAsyncId=function(n,o,r){return r===void 0&&(r=0),wi.setInterval(n.flush.bind(n,this),r)},t.prototype.recycleAsyncId=function(n,o,r){if(r===void 0&&(r=0),r!=null&&this.delay===r&&this.pending===!1)return o;o!=null&&wi.clearInterval(o)},t.prototype.execute=function(n,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(n,o);if(r)return r;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(n,o){var r=!1,i;try{this.work(n)}catch(s){r=!0,i=s||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),i},t.prototype.unsubscribe=function(){if(!this.closed){var n=this,o=n.id,r=n.scheduler,i=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,An(i,this),o!=null&&(this.id=this.recycleAsyncId(r,o,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t})(Ac),xi=(function(){function e(t,n){n===void 0&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(t,n,o){return n===void 0&&(n=0),new this.schedulerActionCtor(this,t).schedule(o,n)},e.now=Oc.now,e})(),Lc=(function(e){lt(t,e);function t(n,o){o===void 0&&(o=xi.now);var r=e.call(this,n,o)||this;return r.actions=[],r._active=!1,r}return t.prototype.flush=function(n){var o=this.actions;if(this._active){o.push(n);return}var r;this._active=!0;do if(r=n.execute(n.state,n.delay))break;while(n=o.shift());if(this._active=!1,r){for(;n=o.shift();)n.unsubscribe();throw r}},t})(xi),zc=new Lc($c);function Fc(e){return e&&Se(e.schedule)}function Bc(e){return e[e.length-1]}function Hc(e){return Fc(Bc(e))?e.pop():void 0}var Si=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function _i(e){return Se(e?.then)}function Ei(e){return Se(e[Vo])}function Ci(e){return Symbol.asyncIterator&&Se(e?.[Symbol.asyncIterator])}function Ni(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Yc(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var ki=Yc();function Ii(e){return Se(e?.[ki])}function Mi(e){return wc(this,arguments,function(){var n,o,r,i;return di(this,function(s){switch(s.label){case 0:n=e.getReader(),s.label=1;case 1:s.trys.push([1,,9,10]),s.label=2;case 2:return[4,At(n.read())];case 3:return o=s.sent(),r=o.value,i=o.done,i?[4,At(void 0)]:[3,5];case 4:return[2,s.sent()];case 5:return[4,At(r)];case 6:return[4,s.sent()];case 7:return s.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function Pi(e){return Se(e?.getReader)}function _t(e){if(e instanceof Fe)return e;if(e!=null){if(Ei(e))return Xc(e);if(Si(e))return Vc(e);if(_i(e))return Wc(e);if(Ci(e))return Di(e);if(Ii(e))return qc(e);if(Pi(e))return jc(e)}throw Ni(e)}function Xc(e){return new Fe(function(t){var n=e[Vo]();if(Se(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Vc(e){return new Fe(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Wc(e){return new Fe(function(t){e.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,pi)})}function qc(e){return new Fe(function(t){var n,o;try{for(var r=Ot(e),i=r.next();!i.done;i=r.next()){var s=i.value;if(t.next(s),t.closed)return}}catch(l){n={error:l}}finally{try{i&&!i.done&&(o=r.return)&&o.call(r)}finally{if(n)throw n.error}}t.complete()})}function Di(e){return new Fe(function(t){Uc(e,t).catch(function(n){return t.error(n)})})}function jc(e){return Di(Mi(e))}function Uc(e,t){var n,o,r,i;return vc(this,void 0,void 0,function(){var s,l;return di(this,function(d){switch(d.label){case 0:d.trys.push([0,5,6,11]),n=xc(e),d.label=1;case 1:return[4,n.next()];case 2:if(o=d.sent(),!!o.done)return[3,4];if(s=o.value,t.next(s),t.closed)return[2];d.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return l=d.sent(),r={error:l},[3,11];case 6:return d.trys.push([6,,9,10]),o&&!o.done&&(i=n.return)?[4,i.call(n)]:[3,8];case 7:d.sent(),d.label=8;case 8:return[3,10];case 9:if(r)throw r.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ct(e,t,n,o,r){o===void 0&&(o=0),r===void 0&&(r=!1);var i=t.schedule(function(){n(),r?e.add(this.schedule(null,o)):this.unsubscribe()},o);if(e.add(i),!r)return i}function Ti(e,t){return t===void 0&&(t=0),xt(function(n,o){n.subscribe(St(o,function(r){return ct(o,e,function(){return o.next(r)},t)},function(){return ct(o,e,function(){return o.complete()},t)},function(r){return ct(o,e,function(){return o.error(r)},t)}))})}function Oi(e,t){return t===void 0&&(t=0),xt(function(n,o){o.add(e.schedule(function(){return n.subscribe(o)},t))})}function Gc(e,t){return _t(e).pipe(Oi(t),Ti(t))}function Kc(e,t){return _t(e).pipe(Oi(t),Ti(t))}function Zc(e,t){return new Fe(function(n){var o=0;return t.schedule(function(){o===e.length?n.complete():(n.next(e[o++]),n.closed||this.schedule())})})}function Jc(e,t){return new Fe(function(n){var o;return ct(n,t,function(){o=e[ki](),ct(n,t,function(){var r,i,s;try{r=o.next(),i=r.value,s=r.done}catch(l){n.error(l);return}s?n.complete():n.next(i)},0,!0)}),function(){return Se(o?.return)&&o.return()}})}function Ai(e,t){if(!e)throw new Error("Iterable cannot be null");return new Fe(function(n){ct(n,t,function(){var o=e[Symbol.asyncIterator]();ct(n,t,function(){o.next().then(function(r){r.done?n.complete():n.next(r.value)})},0,!0)})})}function Qc(e,t){return Ai(Mi(e),t)}function Rc(e,t){if(e!=null){if(Ei(e))return Gc(e,t);if(Si(e))return Zc(e,t);if(_i(e))return Kc(e,t);if(Ci(e))return Ai(e,t);if(Ii(e))return Jc(e,t);if(Pi(e))return Qc(e,t)}throw Ni(e)}function zn(e,t){return t?Rc(e,t):_t(e)}function Ze(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=Hc(e);return zn(e,n)}function Ne(e,t){var n=Se(e)?e:function(){return e},o=function(r){return r.error(n())};return new Fe(o)}function ed(e){return e instanceof Date&&!isNaN(e)}var td=Bo(function(e){return function(n){n===void 0&&(n=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=n}});function nd(e,t){var n=ed(e)?{first:e}:{each:e},o=n.first,r=n.each,i=n.with,s=i===void 0?od:i,l=n.scheduler,d=l===void 0?zc:l,c=n.meta,u=c===void 0?null:c;if(o==null&&r==null)throw new TypeError("No timeout provided.");return xt(function(f,h){var g,p,b=null,v=0,w=function(_){p=ct(h,d,function(){try{g.unsubscribe(),_t(s({meta:u,lastValue:b,seen:v})).subscribe(h)}catch(y){h.error(y)}},_)};g=f.subscribe(St(h,function(_){p?.unsubscribe(),v++,h.next(b=_),r>0&&w(r)},void 0,void 0,function(){p?.closed||p?.unsubscribe(),b=null})),!v&&w(o!=null?typeof o=="number"?o:+o-d.now():r)})}function od(e){throw new td(e)}function Fn(e,t){return xt(function(n,o){var r=0;n.subscribe(St(o,function(i){o.next(e.call(t,i,r++))}))})}function rd(e,t,n,o,r,i,s,l){var d=[],c=0,u=0,f=!1,h=function(){f&&!d.length&&!c&&t.complete()},g=function(b){return c<o?p(b):d.push(b)},p=function(b){c++;var v=!1;_t(n(b,u++)).subscribe(St(t,function(w){t.next(w)},function(){v=!0},void 0,function(){if(v)try{c--;for(var w=function(){var _=d.shift();s||p(_)};d.length&&c<o;)w();h()}catch(_){t.error(_)}}))};return e.subscribe(St(t,g,function(){f=!0,h()})),function(){}}function Wo(e,t,n){return n===void 0&&(n=1/0),Se(t)?Wo(function(o,r){return Fn(function(i,s){return t(o,i,r,s)})(_t(e(o,r)))},n):(typeof t=="number"&&(n=t),xt(function(o,r){return rd(o,r,e,n)}))}function Bn(e){return xt(function(t,n){var o=null,r=!1,i;o=t.subscribe(St(n,void 0,void 0,function(s){i=_t(e(s,Bn(e)(t))),o?(o.unsubscribe(),o=null,i.subscribe(n)):r=!0})),r&&(o.unsubscribe(),o=null,i.subscribe(n))})}function id(e,t,n){var o=Se(e)||t||n?{next:e,error:t,complete:n}:e;return o?xt(function(r,i){var s;(s=o.subscribe)===null||s===void 0||s.call(o);var l=!0;r.subscribe(St(i,function(d){var c;(c=o.next)===null||c===void 0||c.call(o,d),i.next(d)},function(){var d;l=!1,(d=o.complete)===null||d===void 0||d.call(o),i.complete()},function(d){var c;l=!1,(c=o.error)===null||c===void 0||c.call(o,d),i.error(d)},function(){var d,c;l&&((d=o.unsubscribe)===null||d===void 0||d.call(o)),(c=o.finalize)===null||c===void 0||c.call(o)}))}):mi}function qo(e){return encodeURIComponent((e||"").trim()||"__default__")}function sd(e){return e.eventType==="external"?`${e.bindNodeId}::ext::${qo(e.externalEventKey??"")}`:`${e.bindNodeId}::${e.eventType}`}function $i(e,t){return`${e}:${t}`}class $t{static instance;eventSubjects=new Map;subscriptions=new Map;eventBlocks=new Map;nodeEventBindings=new Map;defaultRuntimeHandlers;constructor(){}static getInstance(){return $t.instance||($t.instance=new $t),$t.instance}registerEventBlock(t){this.eventBlocks.set(t.id,t)}unregisterEventBlock(t){this.eventBlocks.delete(t)}getEventBlock(t){return this.eventBlocks.get(t)}setDefaultRuntimeHandlers(t){this.defaultRuntimeHandlers=t}mergeRuntimeHandlers(t){const n=this.defaultRuntimeHandlers;if(!(!n&&!t))return{dataRequest:{...n?.dataRequest,...t?.dataRequest},external:{...n?.external,...t?.external}}}disposeEventRootPipeline(t){const n=this.subscriptions.get(t.id);n&&(n.unsubscribe(),this.subscriptions.delete(t.id)),this.eventSubjects.delete(t.id)}bindNodeEvent(t){const n=sd(t),o=this.nodeEventBindings.get(n);o&&o.id!==t.id&&this.disposeEventRootPipeline(o),this.nodeEventBindings.set(n,t),this.eventSubjects.has(t.id)||this.createEventFlowPipeline(t)}unbindNodeEvent(t,n,o){if(n==="external"){const l=`${t}::ext::${qo(o??"")}`,d=this.nodeEventBindings.get(l);d&&(this.disposeEventRootPipeline(d),this.nodeEventBindings.delete(l));return}const r=`${t}::${n}`,i=$i(t,n),s=this.nodeEventBindings.get(r)??this.nodeEventBindings.get(i);s&&(this.disposeEventRootPipeline(s),this.nodeEventBindings.delete(r),this.nodeEventBindings.delete(i))}unbindAllForNode(t){const n=[];this.nodeEventBindings.forEach((o,r)=>{o.bindNodeId===t&&n.push({key:r,root:o})}),n.forEach(({key:o,root:r})=>{this.disposeEventRootPipeline(r),this.nodeEventBindings.delete(o)})}getNodeEventBindings(t){const n=[];return this.nodeEventBindings.forEach(o=>{o.bindNodeId===t&&n.push(o)}),n}emit(t,n,o){const r=`${t}::${n}`,i=this.nodeEventBindings.get(r)??this.nodeEventBindings.get($i(t,n));if(!i||!i.enabled)return Ze({success:!0,result:null,path:[],duration:0});if(!this.eventSubjects.get(i.id))return Ne(()=>new Error(`Event flow not initialized for ${r}`));const l=Date.now(),d={...o,executionPath:o.executionPath||[],runtimeHandlers:this.mergeRuntimeHandlers(o.runtimeHandlers)};return this.executeEventFlow(i,d).pipe(Fn(c=>({success:!0,result:c,path:d.executionPath,duration:Date.now()-l})),Bn(c=>Ze({success:!1,error:c.message||"Event flow execution failed",path:d.executionPath,duration:Date.now()-l})))}emitExternal(t,n,o){const r=`${t}::ext::${qo(n)}`,i=this.nodeEventBindings.get(r);if(!i||!i.enabled)return Ze({success:!0,result:null,path:[],duration:0});if(!this.eventSubjects.get(i.id))return Ne(()=>new Error(`Event flow not initialized for ${r}`));const l=Date.now(),d={...o,executionPath:o.executionPath||[],runtimeHandlers:this.mergeRuntimeHandlers(o.runtimeHandlers)};return this.executeEventFlow(i,d).pipe(Fn(c=>({success:!0,result:c,path:d.executionPath,duration:Date.now()-l})),Bn(c=>Ze({success:!1,error:c.message||"Event flow execution failed",path:d.executionPath,duration:Date.now()-l})))}createEventFlowPipeline(t){const n=new bi;this.eventSubjects.set(t.id,n)}executeEventFlow(t,n){const{nodes:o,edges:r}=t.flowData;if(o.length===0)return Ze(null);const i=o.filter(s=>s.inputs.length===0);return i.length===0?Ne(()=>new Error("No start node found in event flow")):this.executeFlowNodes(i,o,r,n,{})}executeFlowNodes(t,n,o,r,i){if(t.length===0)return Ze(i);const s=t.map(l=>this.executeSingleFlowNode(l,r,i).pipe(id(d=>{i[l.id]=d,r.executionPath.push(l.id)})));return zn(s).pipe(Wo(l=>l,1),Fn(()=>{const l=new Set;return t.forEach(c=>{c.outputs.forEach(u=>{const f=n.find(h=>h.id===u);f&&f.inputs.every(g=>i[g]!==void 0)&&l.add(u)})}),n.filter(c=>l.has(c.id))}),Wo(l=>l.length>0?this.executeFlowNodes(l,n,o,r,i):Ze(i)),nd(3e4),Bn(l=>(console.error("Event flow execution error:",l),Ne(()=>l))))}resolveFlowEventBlock(t){return this.eventBlocks.get(t.eventBlockId)??t.data.eventBlock}interpolateBuiltinString(t,n,o){return t.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(r,i)=>{const s=String(i).trim();if(s.startsWith("$")){const d=this.getValueFromPath(o,s.slice(1));return d==null?"":String(d)}const l=n[s];return l==null?"":String(l)})}executeBuiltin(t,n,o){const r=t.builtinId;if(!r)return Ne(()=>new Error("内置动作未选择类型"));if(r==="antdMessage"){const i=t.builtinConfig??{},s=String(i.content??""),l=i.level??"info",d=i.duration,c=this.interpolateBuiltinString(s,o,n);if(!c.trim())return Ne(()=>new Error("Message 提示内容为空"));try{const u={type:l,content:c};if(d!=null&&d!==""){const f=Number(d);Number.isNaN(f)||(u.duration=f)}return m.message.open(u),Ze({ok:!0,builtinId:r,content:c,level:l})}catch(u){return Ne(()=>u)}}return Ne(()=>new Error(`未知内置动作: ${String(r)}`))}invokeRuntimeHandler(t,n,o){try{const r=t(n,o);return r instanceof Promise?zn(r):Ze(r)}catch(r){return Ne(()=>r)}}executeSingleFlowNode(t,n,o){const r=this.resolveFlowEventBlock(t);if(!r)return Ne(()=>new Error(`Event block not found: ${t.eventBlockId}`));const i=this.prepareEventArgs(t,n,o),s=r.executorType??"inlineScript";if(s==="dataRequest"){const l=(r.dataRequestKey||"").trim();if(!l)return Ne(()=>new Error("事件块未配置 dataRequestKey"));const d=n.runtimeHandlers?.dataRequest?.[l];return d?this.invokeRuntimeHandler(d,n,i):Ne(()=>new Error(`未注册 dataRequest 处理器: ${l}`))}if(s==="external"){const l=(r.externalHandlerKey||"").trim();if(!l)return Ne(()=>new Error("事件块未配置 externalHandlerKey"));const d=n.runtimeHandlers?.external?.[l];return d?this.invokeRuntimeHandler(d,n,i):Ne(()=>new Error(`未注册 external 处理器: ${l}`))}if(s==="builtin")return this.executeBuiltin(r,n,i);try{const d=new Function("node","context","args",r.callback)(n.triggerNode,n,i);return d instanceof Promise?zn(d):Ze(d)}catch(l){return Ne(()=>l)}}prepareEventArgs(t,n,o){const r={$event:n.originalEvent,$data:n.data,$node:n.triggerNode},{inputMapping:i}=t.data;return i&&Object.entries(i).forEach(([s,l])=>{if(l.startsWith("$prev.")){const d=l.replace("$prev.","");r[s]=o[d]}else if(l.startsWith("$")){const d=l.slice(1);r[s]=this.getValueFromPath(n,d)}else r[s]=l}),r}getValueFromPath(t,n){return n.split(".").reduce((o,r)=>{if(o!==null&&typeof o=="object"&&r in o)return o[r]},t)}clearAll(){this.subscriptions.forEach(t=>t.unsubscribe()),this.subscriptions.clear(),this.eventSubjects.clear(),this.nodeEventBindings.clear()}}const ln=$t.getInstance(),Li=({node:e,children:t,runtimeHandlers:n,flowContextData:o})=>{const{eventFlow:r}=Ie(),i=E.useRef(null),s=E.useCallback(()=>r.eventRoots.filter(d=>d.bindNodeId===e.id&&d.enabled),[r.eventRoots,e.id]),l=E.useCallback(d=>c=>{const u=s().filter(h=>h.eventType===d);if(u.length===0)return;d!=="mouseOver"&&d!=="mouseLeave"&&c.preventDefault(),c.stopPropagation();const f=o&&typeof o=="object"?{...o}:{};u.forEach(h=>{ln.emit(e.id,d,{triggerNode:e,originalEvent:c,data:f,runtimeHandlers:n}).subscribe({next:g=>{g.success||console.error("Event flow execution failed:",g.error)},error:g=>{console.error("Event flow error:",g)}})})},[s,e,n,o]);return E.useEffect(()=>(s().forEach(c=>{ln.bindNodeEvent(c)}),()=>{ln.unbindAllForNode(e.id)}),[s,e.id]),E.useEffect(()=>{const d=i.current;if(!d)return;const c={click:l("click"),mousedown:l("mouseDown"),mouseup:l("mouseUp"),dblclick:l("doubleClick"),mouseover:l("mouseOver"),mouseleave:l("mouseLeave"),mouseenter:l("mouseEnter"),contextmenu:l("contextMenu")};return Object.entries(c).forEach(([u,f])=>{d.addEventListener(u,f,!0)}),()=>{Object.entries(c).forEach(([u,f])=>{d.removeEventListener(u,f,!0)})}},[l]),E.cloneElement(t,{ref:d=>{i.current=d;const c=t.ref;typeof c=="function"?c(d):c&&"current"in c&&(c.current=d)}})},{Text:zi}=m.Typography,ad=(e,t)=>{if(!t||!e)return{value:void 0};if(Array.isArray(e)){const n=e.find(o=>o.paramsCode===t);if(n)return{value:n.value,unit:n.unit}}else if(typeof e=="object"&&t in e)return{value:e[t],unit:e.unit};return{value:void 0}},ld=(e,t)=>{if(e==null||e==="")return"";if(t===-1)return String(e);const n=Number(e);return isNaN(n)?String(e):n.toFixed(t??2)},cd=(e,t,n,o)=>{switch(e.type){case"IMAGE":const r=e,i=r.backgroundColor,s=r.fillColor;let l=r.src;return s&&l&&l.includes("data:image/svg+xml")&&(e.name==="矩形"?l=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${s}" rx="4"/></svg>`)}`:e.name==="圆形"?l=`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="${s}"/></svg>`)}`:e.name==="圆角矩形"&&(l=`data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="100" height="60"><rect width="100" height="60" fill="${s}" rx="20"/></svg>`)}`)),a.jsx("div",{className:"w-full h-full flex items-center justify-center overflow-hidden",style:{backgroundColor:i},children:l?a.jsx("img",{src:l,alt:e.name,style:{width:"100%",height:"100%",objectFit:"contain"}}):a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx("span",{className:"text-gray-400 text-xs",children:"无图片"})})});case"TEXT":const d=e,{label:c,value:u,valueSourceCode:f,unit:h,decimals:g,labelStyle:p,valueStyle:b,customStyle:v}=d.content||{},{value:w,unit:_}=f?ad(t,f):{value:void 0,unit:void 0},x=ld(w!==void 0?w:u,g),D=h||_||"";return a.jsxs("div",{className:"w-full h-full flex flex-col justify-center gap-1",style:{...v},children:[c&&a.jsx(zi,{style:{fontSize:14,fontWeight:"bold",color:"#262626",textAlign:"left",...p},children:c}),x&&a.jsxs(zi,{style:{fontSize:14,color:"#1890ff",textAlign:"left",...b},children:[x,D?` ${D}`:""]})]});case"LINE":const M=e,{thickness:P=2,color:T="#d9d9d9",dashed:z=!1,lineType:q=z?"dashed":"solid",lineWeight:A=P,startX:H=0,startY:j=0,endX:C=100,endY:S=0}=M.config||{},k=(Y=>{const F=Math.max(A,1);switch(Y){case"solid":return"";case"dashed":return`${F*8},${F*4}`;case"center":return`${F*12},${F*3},${F*2},${F*3}`;case"phantom":return`${F*12},${F*3},${F*2},${F*3},${F*2},${F*3}`;case"dot":return`${F},${F*3}`;case"dash-dot":return`${F*8},${F*3},${F},${F*3}`;default:return""}})(q),I=n?"#1890ff":T;return a.jsx("div",{className:"w-full h-full relative",style:{overflow:"visible"},children:a.jsxs("svg",{className:"absolute top-0 left-0",width:"100%",height:"100%",style:{overflow:"visible",pointerEvents:"none"},children:[a.jsx("line",{x1:H,y1:j,x2:C,y2:S,stroke:"transparent",strokeWidth:Math.max(A,10),strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"stroke",cursor:"pointer"}}),a.jsx("line",{x1:H,y1:j,x2:C,y2:S,stroke:I,strokeWidth:A,strokeDasharray:k,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none"}})]})});case"CUSTOM":const O=e;return O.render?O.render({}):a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:a.jsx("span",{className:"text-gray-400 text-xs",children:"自定义组件"})});default:return a.jsx("div",{className:"w-full h-full flex items-center justify-center bg-gray-100",children:a.jsx("span",{className:"text-gray-400 text-xs",children:"未知类型"})})}},dd=({node:e,isSelected:t=!1,onClick:n,onMouseDown:o,data:r,onUpdateNode:i,scale:s=1,enableEventFlow:l=!1,eventFlowData:d})=>{const{normalStyle:c,controlInfo:u}=e,{isClickable:f,isDraggable:h,isResizable:g}=u,p=e.contentInfo,b=Ie(L=>L.dataPool),v=E.useRef(n);E.useEffect(()=>{v.current=n},[n]);const[w,_]=E.useState(null),y=E.useRef(null),x=E.useRef(null),D=E.useRef(null),M=E.useRef(null),P=E.useRef(null),[T,z]=E.useState(null),[q,A]=E.useState(null),H=E.useRef(null),j=E.useMemo(()=>{const L=e.contentInfo.statusList;if(L.length===0)return;const V=oi(L,r,b);return V||L[0]},[e.contentInfo.statusList,r,b]),C=j?.material,S=C?.type==="LINE",N=S?C.config:null,k=c.scale??1,I=(c.width||100)*k,O=(c.height||100)*k,Y=E.useCallback(()=>{const L=P.current?.closest('[data-canvas="true"]');if(!L)return s;const V=L.getBoundingClientRect(),K=parseFloat(L.style.width);return K?V.width/K:s},[s]),F=E.useCallback((L,V)=>{L.stopPropagation(),L.preventDefault();const K=N?.startX||0,W=N?.startY||0,R=N?.endX||0,ee=N?.endY||0,le=c.x||0,ne=c.y||0,de=Math.max((N?.lineWeight||N?.thickness||2)*2,4),ue=Math.min(K,R),ye=Math.min(W,ee),ke=Math.max(K,R),$e=Math.max(W,ee),Be=Math.max(ke-ue,de),Pe=Math.max($e-ye,de);y.current={mouseX:L.clientX,mouseY:L.clientY,startX:K,startY:W,endX:R,endY:ee,nodeX:le,nodeY:ne};const De=Math.min(K,R),He=Math.min(W,ee);D.current={nodeX:le+De,nodeY:ne+He,width:Be,height:Pe,startX:K-De,startY:W-He,endX:R-De,endY:ee-He},x.current=j||null,_(V)},[N,c.x,c.y,j]);E.useEffect(()=>{if(!w||!S||!N||!i)return;const L=K=>{const W=y.current;if(!W||!P.current)return;const R=Y(),ee=(K.clientX-W.mouseX)/R,le=(K.clientY-W.mouseY)/R;let ne=W.startX,de=W.startY,ue=W.endX,ye=W.endY,ke=W.nodeX,$e=W.nodeY;w==="start"?(ne=W.startX+ee,de=W.startY+le,ne<0&&(ke=W.nodeX+ne,ue=W.endX-ne,ne=0),de<0&&($e=W.nodeY+de,ye=W.endY-de,de=0)):(ue=W.endX+ee,ye=W.endY+le,ue<0&&(ke=W.nodeX+ue,ne=W.startX-ue,ue=0),ye<0&&($e=W.nodeY+ye,de=W.startY-ye,ye=0));const Be=Math.max((N.lineWeight||2)*2,4),Pe=Math.min(ne,ue),De=Math.min(de,ye),He=Math.max(ne,ue),et=Math.max(de,ye),je=ke+Pe,gt=$e+De,mt=ne-Pe,Ue=de-De,Ge=ue-Pe,Ke=ye-De,Zt=Math.max(He-Pe,Be),Jt=Math.max(et-De,Be);D.current={nodeX:je,nodeY:gt,width:Zt,height:Jt,startX:mt,startY:Ue,endX:Ge,endY:Ke};const Le=P.current;Le.style.left=`${je}px`,Le.style.top=`${gt}px`,Le.style.width=`${Zt}px`,Le.style.height=`${Jt}px`,Le.querySelectorAll("svg line").forEach(tt=>{tt.setAttribute("x1",String(mt)),tt.setAttribute("y1",String(Ue)),tt.setAttribute("x2",String(Ge)),tt.setAttribute("y2",String(Ke))});const yt=Le.querySelector('[data-handle="start"]'),bt=Le.querySelector('[data-handle="end"]');yt&&(yt.style.left=`${mt-6}px`,yt.style.top=`${Ue-6}px`),bt&&(bt.style.left=`${Ge-6}px`,bt.style.top=`${Ke-6}px`)},V=()=>{const K=D.current;if(!K||!i){_(null),y.current=null,D.current=null,x.current=null;return}const W=Ie.getState().nodes.find(ue=>ue.id===e.id),R=W?.contentInfo.statusList??e.contentInfo.statusList,le=x.current?.id??R.find(ue=>ue.material.type==="LINE")?.id,ne=R.map(ue=>{if(ue.material.type!=="LINE"||ue.id!==le)return ue;const ye=ue.material;return{...ue,material:{...ye,config:{...ye.config,startX:K.startX,startY:K.startY,endX:K.endX,endY:K.endY}}}}),de=W?.contentInfo??p;i(e.id,{normalStyle:{x:K.nodeX,y:K.nodeY,width:K.width,height:K.height},contentInfo:{...de,statusList:ne}}),_(null),y.current=null,D.current=null,x.current=null};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",V),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",V)}},[w,S,N,e.id,c,p,e.contentInfo.statusList,i,Y]),E.useEffect(()=>{if(!T||!i)return;const L=K=>{if(!P.current)return;const W=Y(),R=(K.clientX-T.startX)/W,ee=(K.clientY-T.startY)/W;let le=T.startWidth,ne=T.startHeight,de=T.startNodeX,ue=T.startNodeY;switch(T.corner){case"se":le=Math.max(20,T.startWidth+R),ne=Math.max(20,T.startHeight+ee);break;case"sw":le=Math.max(20,T.startWidth-R),ne=Math.max(20,T.startHeight+ee),de=T.startNodeX+(T.startWidth-le);break;case"ne":le=Math.max(20,T.startWidth+R),ne=Math.max(20,T.startHeight-ee),ue=T.startNodeY+(T.startHeight-ne);break;case"nw":le=Math.max(20,T.startWidth-R),ne=Math.max(20,T.startHeight-ee),de=T.startNodeX+(T.startWidth-le),ue=T.startNodeY+(T.startHeight-ne);break}M.current={x:de,y:ue,width:le,height:ne};const ye=P.current;ye.style.left=`${de}px`,ye.style.top=`${ue}px`,ye.style.width=`${le}px`,ye.style.height=`${ne}px`},V=()=>{const K=M.current;K&&i(e.id,{normalStyle:{...c,x:K.x,y:K.y,width:K.width,height:K.height}}),z(null),M.current=null};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",V),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",V)}},[T,i,e.id,c,Y]);const X=E.useCallback((L,V)=>{L.stopPropagation(),L.preventDefault(),z({corner:V,startX:L.clientX,startY:L.clientY,startWidth:c.width||100,startHeight:c.height||100,startNodeX:c.x||0,startNodeY:c.y||0})},[c.width,c.height,c.x,c.y]),G=E.useCallback(L=>{L.stopPropagation(),L.preventDefault();const V=P.current?.getBoundingClientRect();V&&A({startX:L.clientX,startY:L.clientY,startAngle:c.rotate||0,centerX:V.left+V.width/2,centerY:V.top+V.height/2})},[c.rotate]);E.useEffect(()=>{if(!q)return;const L=K=>{const W=K.clientX-q.centerX,R=K.clientY-q.centerY;let le=(Math.atan2(R,W)*(180/Math.PI)+90)%360;if(le<0&&(le+=360),H.current=le,P.current){const ne=c.transform||"";P.current.style.transform=`rotate(${le}deg) ${ne}`.trim()}},V=()=>{const K=H.current??q.startAngle;H.current=null,i&&i(e.id,{normalStyle:{...c,rotate:Math.round(K)}}),A(null)};return window.addEventListener("mousemove",L),window.addEventListener("mouseup",V),()=>{window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",V)}},[q,i,e.id,c]);const Z=e.type==="group",U={position:"absolute",left:c.x||0,top:c.y||0,width:I,height:O,background:Z?"transparent":c.background||"transparent",backgroundImage:Z?void 0:c.backgroundImage?`url(${c.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center",padding:Array.isArray(c.padding)?c.padding.join("px ")+"px":c.padding,margin:Array.isArray(c.margin)?c.margin.join("px ")+"px":c.margin,borderRadius:Z?void 0:c.borderRadius,border:t&&!S?"2px solid #1890ff":S||Z?"none":c.border||"1px dashed transparent",pointerEvents:"auto",opacity:c.opacity??1,transform:`rotate(${H.current??(c.rotate||0)}deg) ${c.transform||""}`.trim(),transformOrigin:"center center",zIndex:t?1e3:c.zIndex??1,cursor:h&&!w?"move":f?"pointer":"default",boxSizing:"border-box",overflow:t||S||Z?"visible":"hidden"},te=N?{x:N.startX||0,y:N.startY||0}:{x:0,y:0},re=N?{x:N.endX||0,y:N.endY||0}:{x:0,y:0},$=a.jsxs("div",{ref:P,"data-node-id":e.id,style:U,onClick:L=>{console.log("NodeRenderer onClick",e.id,"isClickable:",f);const V=v.current;f&&V&&!w&&!T&&!q&&(L.stopPropagation(),V(L))},onMouseDown:L=>{h&&o&&!w&&o(L)},children:[t&&!S&&!Z&&a.jsxs(a.Fragment,{children:[a.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:L=>X(L,"nw"),title:"拖拽调整大小"}),a.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:L=>X(L,"ne"),title:"拖拽调整大小"}),a.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:L=>X(L,"sw"),title:"拖拽调整大小"}),a.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:L=>X(L,"se"),title:"拖拽调整大小"}),a.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:L=>G(L),title:"拖拽旋转"}),a.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%)"}}),a.jsxs("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:[e.name," ",j?`(${j.name})`:""]})]}),t&&S&&N&&i&&a.jsxs(a.Fragment,{children:[a.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:te.x-6,top:te.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:L=>F(L,"start"),title:"拖拽调整起点"}),a.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:re.x-6,top:re.y-6,boxShadow:"0 0 4px rgba(0,0,0,0.3)"},onMouseDown:L=>F(L,"end"),title:"拖拽调整终点"}),a.jsx("div",{className:"absolute -top-6 left-0 bg-blue-500 text-white text-xs px-2 py-0.5 rounded whitespace-nowrap",children:e.name})]}),a.jsx("div",{className:"w-full h-full relative",children:C?a.jsx("div",{className:"w-full h-full",children:cd(C,r,t)}):Z?null:a.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-300 text-xs",children:"无状态"})}),e.type==="group"&&e.children&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:e.children.map(L=>a.jsx("div",{className:"pointer-events-auto",children:a.jsx(jo,{node:L,isSelected:!1,data:r,onUpdateNode:i,scale:s,enableEventFlow:l,eventFlowData:d})},L.id))})]});return l?a.jsx(Li,{node:e,flowContextData:d,children:$}):$},jo=E.memo(dd,(e,t)=>{const n=e.node,o=t.node,r=n.id===o.id&&n.normalStyle.x===o.normalStyle.x&&n.normalStyle.y===o.normalStyle.y&&n.normalStyle.width===o.normalStyle.width&&n.normalStyle.height===o.normalStyle.height,i=n.contentInfo===o.contentInfo,s=JSON.stringify(e.eventFlowData??null)===JSON.stringify(t.eventFlowData??null),l=e.isSelected===t.isSelected&&e.scale===t.scale&&e.enableEventFlow===t.enableEventFlow&&s,d=h=>{const g=[];return h.contentInfo?.statusList?.forEach(p=>{if(p.material?.type==="LINE"){const b=p.material.config;g.push({statusId:p.id,startX:b?.startX??0,startY:b?.startY??0,endX:b?.endX??100,endY:b?.endY??0})}}),g},c=d(n),u=d(o);let f=!0;if(c.length!==u.length)f=!1;else for(let h=0;h<c.length;h++){const g=c[h],p=u.find(b=>b.statusId===g.statusId);if(!p||g.startX!==p.startX||g.startY!==p.startY||g.endX!==p.endX||g.endY!==p.endY){f=!1;break}}return r&&i&&l&&f}),ud=["#1890ff","#52c41a","#faad14","#f5222d","#722ed1","#eb2f96","#13c2c2","#fa8c16","#595959","#262626","#8c8c8c","#d9d9d9","#ffffff","#000000","#ff4d4f","#73d13d"],Lt=({value:e="#1890ff",onChange:t,onChangeComplete:n})=>{const[o,r]=E.useState(!1),[i,s]=E.useState(e),l=E.useRef(null);E.useEffect(()=>{s(e)},[e]),E.useEffect(()=>{const c=u=>{l.current&&!l.current.contains(u.target)&&(r(!1),n?.({toHexString:()=>i}))};return o&&document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o,n,i]);const d=c=>{s(c),t?.({toHexString:()=>c})};return a.jsxs("div",{ref:l,style:{position:"relative",display:"inline-block"},children:[a.jsx("div",{onClick:()=>r(!o),style:{width:28,height:28,backgroundColor:i,border:"1px solid #d9d9d9",borderRadius:4,cursor:"pointer"}}),o&&a.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:[a.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(8, 1fr)",gap:4},children:ud.map(c=>a.jsx("div",{onClick:()=>{d(c),r(!1),n?.({toHexString:()=>c})},style:{width:20,height:20,backgroundColor:c,border:i===c?"2px solid #1890ff":"1px solid #d9d9d9",borderRadius:2,cursor:"pointer"}},c))}),a.jsx("input",{type:"color",value:i,onChange:c=>d(c.target.value),onBlur:()=>n?.({toHexString:()=>i}),style:{width:"100%",marginTop:8,height:28,border:"1px solid #d9d9d9",borderRadius:4}})]})]})},{TextArea:fd}=m.Input;function Fi(e){if(!e||!(e instanceof HTMLElement))return!1;const t=e.tagName;return!!(t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||t==="OPTION"||e.isContentEditable||e.closest('[contenteditable="true"]')||e.closest('[role="combobox"]')||e.closest('[role="listbox"]'))}const Bi=({defaultTestData:e})=>{const t=E.useRef(null),n=E.useRef(null),o=E.useRef(null),{nodes:r,selectedNodeId:i,selectedNodeIds:s,mode:l,lineDrawing:d,viewport:c,canvas:u,root:f,setViewport:h,setCanvasConfig:g,addNode:p,selectNode:b,updateNode:v,removeNode:w,undo:_,redo:y,setMode:x,startLineDrawing:D,endLineDrawing:M,cancelLineDrawing:P,addCanvas:T,removeCanvas:z,switchCanvas:q,updateCanvasName:A,setSelectedNodeIds:H}=Ie();console.log("selectedNodeId",i);const[j,C]=E.useState(!1),[,S]=E.useState({}),N=E.useRef(l);E.useEffect(()=>{N.current=l},[l]);const k=E.useRef(!1),I=E.useRef({x:0,y:0}),O=E.useRef({x:0,y:0,newX:0,newY:0}),Y=E.useRef(null),[F,X]=E.useState({start:null,end:null,isDrawing:!1}),[G,Z]=E.useState({start:null,end:null}),U=s,te=H;E.useRef(!1);const[re,$]=E.useState(!1),[L,V]=E.useState(JSON.stringify(e,null,2)),K=E.useMemo(()=>{try{const B=JSON.parse(L);return B!==null&&typeof B=="object"&&!Array.isArray(B)?B:{_payload:B}}catch{const B=e;return B!==null&&typeof B=="object"&&!Array.isArray(B)?B:{}}},[L,e]),[W,R]=E.useState(!1),[ee,le]=E.useState(!1),ne=E.useCallback((B,J)=>{if(!n.current)return{x:0,y:0};const ie=n.current.getBoundingClientRect(),oe=B-ie.left,Q=J-ie.top,ce=ie.width/u.width,me=ie.height/u.height,fe=oe/ce,ve=Q/me;return{x:Math.round(fe),y:Math.round(ve)}},[u.width,u.height]),de=E.useCallback((B,J)=>ne(B,J),[ne]),ue=E.useCallback((B,J,ie=!0)=>{if(!d.material)return;const oe=d.material,Q=oe.config||{},ce=Q.lineWeight||Q.thickness||2,me=Math.min(B.x,J.x),fe=Math.min(B.y,J.y),ve=Math.round(B.x-me),ge=Math.round(B.y-fe),_e=Math.round(J.x-me),Ce=Math.round(J.y-fe),ze=Math.max(ce*2,4),vt=Math.max(Math.abs(B.x-J.x),ze),nt=Math.max(Math.abs(B.y-J.y),ze),Qt={...oe,id:he.nanoid(),config:{color:Q.color,lineWeight:ce,thickness:ce,lineType:Q.lineType,startX:ve,startY:ge,endX:_e,endY:Ce}},Br={id:he.nanoid(),name:`${oe.name}_${Date.now()}`,type:"normal",normalStyle:{width:vt,height:nt,x:me,y:fe,background:"transparent"},contentInfo:{statusList:[zo(Qt)],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0}};if(p(Br,!1),ie){const Do={x:J.x,y:J.y};X({start:Do,end:{...Do},isDrawing:!0})}else X({start:null,end:null,isDrawing:!1}),M()},[d.material,p,M]),ye=E.useCallback(()=>{const B=t.current?.state;B&&h({scale:B.scale,positionX:B.positionX,positionY:B.positionY})},[h]),ke=E.useCallback(B=>{k.current||l!=="box-select"&&(B.target===n.current||B.target.dataset?.canvas==="true")&&(b(null),te([]))},[b,l]),$e=E.useCallback(B=>{if(B.button===0){if(l==="line-draw"&&d.material){B.stopPropagation();const J=ne(B.clientX,B.clientY);F.isDrawing?F.start&&ue(F.start,J,!0):X({start:J,end:J,isDrawing:!0});return}if(l==="box-select"&&!ee){const J=de(B.clientX,B.clientY);Z({start:J,end:J}),te([]),B.preventDefault(),B.stopPropagation()}}},[l,d.material,F.isDrawing,F.start,ee,ue,ne,de]),Be=E.useCallback(B=>{if(!(l!=="line-draw"||!d.material)&&F.isDrawing&&F.start){const J=ne(B.clientX,B.clientY);ue(F.start,J,!1)}},[l,d.material,F.isDrawing,F.start,ue,ne]),Pe=E.useCallback(B=>{B.preventDefault(),B.dataTransfer.dropEffect="copy",C(!0)},[]),De=E.useCallback(B=>{B.preventDefault(),C(!1)},[]),He=E.useCallback(B=>{if(B.preventDefault(),C(!1),!(!n.current||l!=="select"))try{const J=B.dataTransfer.getData("application/json");if(!J)return;const ie=JSON.parse(J),oe=ne(B.clientX,B.clientY),Q=oe.x-50,ce=oe.y-50,me=li(Q,ce,ie);p(me),te([me.id])}catch(J){console.error("Failed to parse dropped material:",J)}},[l,p,ne]),et=E.useCallback((B,J)=>{l!=="select"&&l!=="box-select"||!J.controlInfo.isDraggable||(B.stopPropagation(),b(J.id),k.current=!0,I.current={x:B.clientX,y:B.clientY},O.current={x:J.normalStyle.x||0,y:J.normalStyle.y||0,newX:J.normalStyle.x||0,newY:J.normalStyle.y||0},Y.current=J,B.preventDefault())},[l,b]);E.useEffect(()=>{const B=Q=>{if(k.current&&i&&Y.current){if(!n.current)return;const ce=n.current.getBoundingClientRect(),me=ce.width/u.width,fe=ce.height/u.height,ve=Q.clientX-I.current.x,ge=Q.clientY-I.current.y,_e=ve/me,Ce=ge/fe,ze=O.current.x+_e,vt=O.current.y+Ce,nt=document.querySelector(`[data-node-id="${i}"]`);nt&&(nt.style.left=`${ze}px`,nt.style.top=`${vt}px`),O.current.newX=ze,O.current.newY=vt}if(l==="box-select"&&G.start){const ce=de(Q.clientX,Q.clientY);Z(me=>({...me,end:ce}))}if(l==="line-draw"&&F.isDrawing){const ce=ne(Q.clientX,Q.clientY);X(me=>({...me,end:ce}))}},J=()=>{if(k.current&&i&&Y.current){const Q=Ie.getState(),ce=O.current.newX??O.current.x,me=O.current.newY??O.current.y;Q.updateNode(i,{normalStyle:{...Y.current.normalStyle,x:ce,y:me}})}if(k.current=!1,Y.current=null,S({}),l==="box-select"&&G.start&&G.end){const Q=Math.min(G.start.x,G.end.x),ce=Math.max(G.start.x,G.end.x),me=Math.min(G.start.y,G.end.y),fe=Math.max(G.start.y,G.end.y),ve=r.filter(ge=>{const _e=ge.normalStyle.x||0,Ce=ge.normalStyle.y||0,ze=ge.normalStyle.width||0,vt=ge.normalStyle.height||0,nt=_e+ze/2,Qt=Ce+vt/2;return nt>=Q&&nt<=ce&&Qt>=me&&Qt<=fe}).map(ge=>ge.id);te(ve),Z({start:null,end:null})}},ie=Q=>{Fi(Q.target)||(Q.key==="Escape"&&l==="line-draw"&&(X({start:null,end:null,isDrawing:!1}),P()),Q.key==="Delete"&&(i?w(i):U.length>0&&(U.forEach(ce=>w(ce)),te([]))),Q.ctrlKey&&Q.key==="z"&&(Q.preventDefault(),_()),Q.ctrlKey&&Q.key==="y"&&(Q.preventDefault(),y()),Q.key===" "&&!ee&&(Q.preventDefault(),le(!0)))},oe=Q=>{Q.key===" "&&ee&&le(!1)};return window.addEventListener("mousemove",B),window.addEventListener("mouseup",J),window.addEventListener("keydown",ie),window.addEventListener("keyup",oe),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",J),window.removeEventListener("keydown",ie),window.removeEventListener("keyup",oe)}},[i,G,l,F.isDrawing,U,r,u.width,u.height,w,_,ee,y,P,ne,de,te]);const je=E.useCallback(()=>{const B=U.length>0?U.map(ie=>r.find(oe=>oe.id===ie)).filter(Boolean):i?[r.find(ie=>ie.id===i)].filter(Boolean):[];if(B.length===0)return;const J=[];B.forEach(ie=>{const oe={...ie,id:he.nanoid(),name:`${ie.name}_副本`,normalStyle:{...ie.normalStyle,x:(ie.normalStyle.x||0)+20,y:(ie.normalStyle.y||0)+20}};p(oe),J.push(oe.id)}),J.length===1?b(J[0]):te(J)},[i,U,r,p,b,te]),gt=E.useCallback(()=>{if(U.length<2)return;const B=[];for(let fe=0;fe<U.length;fe++){const ve=U[fe],ge=r.find(_e=>_e.id===ve);if(ge){if(ge?.type==="group"){ge.children.forEach(Ce=>B.push({...Ce,normalStyle:{...Ce.normalStyle,x:(ge.normalStyle.x||0)+(Ce.normalStyle.x||0),y:(ge.normalStyle.y||0)+(Ce.normalStyle.y||0)}})),w(ve);continue}B.push(ge)}}if(B.length<2)return;let J=1/0,ie=1/0,oe=-1/0,Q=-1/0;B.forEach(fe=>{const ve=fe.normalStyle.x||0,ge=fe.normalStyle.y||0,_e=fe.normalStyle.width||0,Ce=fe.normalStyle.height||0;J=Math.min(J,ve),ie=Math.min(ie,ge),oe=Math.max(oe,ve+_e),Q=Math.max(Q,ge+Ce)});const ce=B.map(fe=>({...fe,normalStyle:{...fe.normalStyle,x:(fe.normalStyle.x||0)-J,y:(fe.normalStyle.y||0)-ie}})),me={id:he.nanoid(),name:`群组_${Date.now()}`,type:"group",normalStyle:{x:J,y:ie,width:oe-J,height:Q-ie,background:"transparent"},contentInfo:{statusList:[],currentStatusId:void 0},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0},children:ce};U.forEach(fe=>w(fe)),p(me),te([]),b(me.id)},[U,r,w,p,b]),mt=E.useCallback(()=>{const B=U.length>0?U.map(J=>r.find(ie=>ie.id===J)).filter(J=>!!J&&J.type==="group"):i?[r.find(J=>J.id===i)].filter(J=>!!J&&J.type==="group"):[];B.length!==0&&(B.forEach(J=>{if(!J.children||J.children.length===0)return;const ie=J.children.map(oe=>({...oe,normalStyle:{...oe.normalStyle,x:(J.normalStyle.x||0)+(oe.normalStyle.x||0),y:(J.normalStyle.y||0)+(oe.normalStyle.y||0)}}));w(J.id),ie.forEach(oe=>p(oe))}),te([]),b(null))},[i,U,r,w,p,b,te]),Ue=E.useCallback(B=>{if(U.length<2)return;const J=U.map(ve=>r.find(ge=>ge.id===ve)).filter(ve=>!!ve&&ve.type!=="group");if(J.length<2)return;let ie=1/0,oe=-1/0,Q=1/0,ce=-1/0;J.forEach(ve=>{const ge=ve.normalStyle.x||0,_e=ve.normalStyle.y||0;ie=Math.min(ie,ge),oe=Math.max(oe,ge),Q=Math.min(Q,_e),ce=Math.max(ce,_e)});const me=[...J].sort((ve,ge)=>B==="horizontal"?(ve.normalStyle.x||0)-(ge.normalStyle.x||0):(ve.normalStyle.y||0)-(ge.normalStyle.y||0)),fe=me.length;if(B==="horizontal"){const ge=(oe-ie)/(fe-1);me.forEach((_e,Ce)=>{const ze=ie+ge*Ce;v(_e.id,{normalStyle:{..._e.normalStyle,x:ze}})})}else{const ge=(ce-Q)/(fe-1);me.forEach((_e,Ce)=>{const ze=Q+ge*Ce;v(_e.id,{normalStyle:{..._e.normalStyle,y:ze}})})}},[U,r,v]),Ge=B=>{const J=B.contentInfo.statusList.find(ie=>ie.material.type==="LINE");return J?J.material.config:null},Ke=E.useCallback(B=>{if(U.length<2)return;const J=Ie.getState(),ie=U.map(Q=>r.find(ce=>ce.id===Q)).filter(Q=>!!Q);if(ie.length<2)return;let oe=0;switch(B){case"left":oe=Math.min(...ie.map(Q=>{const ce=Ge(Q);return ce?(Q.normalStyle.x||0)+(ce.startX||0):Q.normalStyle.x||0}));break;case"right":oe=Math.max(...ie.map(Q=>{const ce=Ge(Q);return ce?(Q.normalStyle.x||0)+(ce.endX||0):(Q.normalStyle.x||0)+(Q.normalStyle.width||0)}));break;case"top":oe=Math.min(...ie.map(Q=>{const ce=Ge(Q);return ce?(Q.normalStyle.y||0)+(ce.startY||0):Q.normalStyle.y||0}));break;case"bottom":oe=Math.max(...ie.map(Q=>{const ce=Ge(Q);return ce?(Q.normalStyle.y||0)+(ce.endY||0):(Q.normalStyle.y||0)+(Q.normalStyle.height||0)}));break}ie.forEach(Q=>{let ce=Q.normalStyle.x||0,me=Q.normalStyle.y||0;const fe=Ge(Q);switch(B){case"left":fe?ce=oe-(fe.startX||0):ce=oe;break;case"right":fe?ce=oe-(fe.endX||0):ce=oe-(Q.normalStyle.width||0);break;case"top":fe?me=oe-(fe.startY||0):me=oe;break;case"bottom":fe?me=oe-(fe.endY||0):me=oe-(Q.normalStyle.height||0);break}J.updateNode(Q.id,{normalStyle:{...Q.normalStyle,x:ce,y:me}})})},[U,r]),Zt=[{icon:a.jsx(se.SelectOutlined,{}),title:"选择模式",active:l==="select",onClick:()=>{x("select")}},{icon:a.jsx(se.GroupOutlined,{}),title:"框选模式",active:l==="box-select",onClick:()=>{x("box-select"),te([])}},{icon:a.jsx(se.DragOutlined,{}),title:"拖拽模式",active:l==="drag",onClick:()=>{x("drag")}},{icon:a.jsx(se.EditOutlined,{}),title:"线条绘制",active:l==="line-draw",onClick:()=>{x("line-draw")}},{icon:a.jsx(se.EyeOutlined,{}),title:"预览模式",active:l==="preview",onClick:()=>{x("preview")}}],Jt=E.useMemo(()=>[{icon:a.jsx(se.UndoOutlined,{}),title:"撤销 (Ctrl+Z)",onClick:_},{icon:a.jsx(se.RedoOutlined,{}),title:"重做 (Ctrl+Y)",onClick:y},{icon:a.jsx(se.CopyOutlined,{}),title:"复制节点",disabled:!i&&U.length===0,onClick:je},{icon:a.jsx(se.GroupOutlined,{}),title:"组合选中节点",disabled:U.length<2,onClick:gt},{icon:a.jsx(se.UngroupOutlined,{}),title:"解除组合",disabled:!i&&U.length===0,onClick:mt},{icon:a.jsx(se.AlignLeftOutlined,{}),title:"左对齐",disabled:U.length<2,onClick:()=>Ke("left")},{icon:a.jsx(se.AlignRightOutlined,{}),title:"右对齐",disabled:U.length<2,onClick:()=>Ke("right")},{icon:a.jsx(se.VerticalAlignTopOutlined,{}),title:"上对齐",disabled:U.length<2,onClick:()=>Ke("top")},{icon:a.jsx(se.VerticalAlignBottomOutlined,{}),title:"下对齐",disabled:U.length<2,onClick:()=>Ke("bottom")},{icon:a.jsx(se.ColumnWidthOutlined,{}),title:"水平分布",disabled:U.length<2,onClick:()=>Ue("horizontal")},{icon:a.jsx(se.ColumnHeightOutlined,{}),title:"垂直分布",disabled:U.length<2,onClick:()=>Ue("vertical")},{icon:a.jsx(se.SettingOutlined,{}),title:"画布配置",onClick:()=>R(!0)},{icon:a.jsx(se.ExperimentOutlined,{}),title:"数据模拟",type:"primary",onClick:()=>$(!0)},{icon:a.jsx(se.DeleteOutlined,{}),title:"删除选中 (Delete)",disabled:!i&&U.length===0,onClick:()=>{i?w(i):U.length>0&&(U.forEach(B=>w(B)),te([]))}}],[_,y,l,x,te,U,gt,mt,je,Ke,Ue,R,$,i,w,f.currentCanvasId]),Le=E.useCallback(B=>{if(Fi(B.target)||B.key!=="ArrowLeft"&&B.key!=="ArrowRight"&&B.key!=="ArrowUp"&&B.key!=="ArrowDown"||U.length===0)return;B.preventDefault(),U.map(ie=>r.find(oe=>oe.id===ie)).forEach(ie=>{ie&&v(ie.id,{normalStyle:{...ie.normalStyle,x:(ie.normalStyle.x||0)-2*(B.key==="ArrowLeft"?1:B.key==="ArrowRight"?-1:0),y:(ie.normalStyle.y||0)-2*(B.key==="ArrowUp"?1:B.key==="ArrowDown"?-1:0)}})})},[U,r,v]);E.useEffect(()=>{if(l==="box-select")return document.addEventListener("keydown",Le),()=>{document.removeEventListener("keydown",Le)}},[l,Le]);const[Mo,yt]=E.useState(!1),[bt,tt]=E.useState(""),[Po,Pn]=E.useState(null);return a.jsxs("div",{className:"flex-1 flex flex-col h-full bg-gray-100",children:[a.jsxs("div",{className:"h-12 bg-white border-b border-gray-200 flex items-center justify-between px-4",children:[a.jsxs(m.Space,{children:[Zt.map(B=>a.jsx(m.Tooltip,{title:B.title,children:a.jsx(m.Button,{type:B.active?"primary":"default",icon:B.icon,onClick:B.onClick})},B.title)),a.jsx("div",{className:"w-px h-6 bg-gray-300 mx-2"}),a.jsx(m.Select,{value:f.currentCanvasId,onChange:q,style:{width:140},dropdownRender:B=>a.jsxs(a.Fragment,{children:[B,a.jsx("div",{className:"border-t border-gray-200 mt-1 pt-1",children:a.jsx(m.Button,{type:"link",size:"small",block:!0,onClick:()=>yt(!0),children:"管理画布..."})})]}),children:f.canvases.map(B=>a.jsx(m.Select.Option,{value:B.id,children:B.name},B.id))}),a.jsx(m.Button,{icon:a.jsx(se.PlusOutlined,{}),size:"small",onClick:()=>T(),title:"新建画布"})]}),a.jsx(m.Space,{children:Jt.map(B=>a.jsx(m.Tooltip,{title:B.title,children:a.jsx(m.Button,{type:B.active?"primary":B.type||"default",icon:B.icon,onClick:B.onClick,disabled:B.disabled})},B.title))})]}),a.jsx("div",{ref:o,className:"flex-1 relative",children:a.jsx(Yr.TransformWrapper,{ref:t,initialScale:1,initialPositionX:0,initialPositionY:0,minScale:.5,maxScale:5,onTransformed:ye,limitToBounds:!1,centerZoomedOut:!1,panning:{disabled:!ee&&(l==="select"||l==="line-draw"||l==="box-select"),velocityDisabled:!0},wheel:{disabled:!1,step:.1},pinch:{disabled:!1},doubleClick:{disabled:!0},children:({zoomIn:B,zoomOut:J,resetTransform:ie})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"absolute bottom-4 right-4 z-10 bg-white rounded-lg shadow-lg p-2",children:a.jsxs(m.Space,{direction:"vertical",children:[a.jsx(m.Tooltip,{title:"放大",children:a.jsx(m.Button,{icon:a.jsx(se.ZoomInOutlined,{}),onClick:()=>B()})}),a.jsx(m.Tooltip,{title:"缩小",children:a.jsx(m.Button,{icon:a.jsx(se.ZoomOutOutlined,{}),onClick:()=>J()})}),a.jsx(m.Tooltip,{title:"重置视图",children:a.jsx(m.Button,{onClick:()=>ie(),children:"100%"})}),a.jsxs("div",{className:"text-center text-xs text-gray-500",children:[Math.round(c.scale*100),"%"]})]})}),a.jsx(Yr.TransformComponent,{wrapperStyle:{width:"100%",height:"100%",position:"relative"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:a.jsxs("div",{ref:n,"data-canvas":"true",className:`relative ${j?"ring-4 ring-blue-400 ring-opacity-50":""} ${l==="line-draw"?"cursor-crosshair":""} ${ee?"cursor-grab":""}`,style:{width:u.width,height:u.height,flexShrink:0,backgroundColor:u.background,backgroundImage:u.backgroundImage?`url(${u.backgroundImage})`:void 0,backgroundSize:"cover",backgroundPosition:"center"},onClick:ke,onMouseDown:$e,onDoubleClick:Be,onDragOver:Pe,onDragLeave:De,onDrop:He,children:[u.showGrid!==!1&&a.jsxs("svg",{className:"absolute top-0 left-0 pointer-events-none",width:u.width,height:u.height,children:[a.jsx("defs",{children:a.jsx("pattern",{id:"grid",width:"20",height:"20",patternUnits:"userSpaceOnUse",children:a.jsx("path",{d:"M 20 0 L 0 0 0 20",fill:"none",stroke:"#f0f0f0",strokeWidth:"1"})})}),a.jsx("rect",{width:"100%",height:"100%",fill:"url(#grid)"})]}),r.map(oe=>a.jsx(jo,{node:oe,isSelected:l==="preview"?!1:i===oe.id||U.includes(oe.id),data:e,onClick:l==="preview"?void 0:Q=>{console.log("Node onClick:",oe.id,"mode:",N.current),N.current!=="line-draw"&&(Q.shiftKey?(b(oe.id),te([...U,oe.id])):(b(oe.id),te([oe.id])))},onMouseDown:l==="preview"?void 0:Q=>et(Q,oe),onUpdateNode:l==="preview"?void 0:(Q,ce)=>v(Q,ce),scale:c.scale,enableEventFlow:l==="preview",eventFlowData:K},`${oe.id}`)),l==="line-draw"&&F.isDrawing&&F.start&&F.end&&a.jsx("svg",{className:"absolute top-0 left-0 pointer-events-none",width:u.width,height:u.height,children:a.jsx("line",{x1:F.start.x,y1:F.start.y,x2:F.end.x,y2:F.end.y,stroke:"#1890ff",strokeWidth:"2",strokeDasharray:"5,5",strokeLinecap:"round",strokeLinejoin:"round"})}),l==="box-select"&&G.start&&G.end&&a.jsx("div",{className:"absolute border-2 border-blue-500 bg-blue-500/10 pointer-events-none",style:{left:Math.min(G.start.x,G.end.x),top:Math.min(G.start.y,G.end.y),width:Math.abs(G.end.x-G.start.x),height:Math.abs(G.end.y-G.start.y),zIndex:9999}})]})})]})})}),a.jsx(m.Modal,{title:"数据模拟",open:re,onCancel:()=>$(!1),footer:null,children:a.jsx(m.Form,{layout:"vertical",children:a.jsx(m.Form.Item,{label:"测试数据 (JSON)",children:a.jsx(fd,{value:L,onChange:B=>V(B.target.value),rows:10,placeholder:"输入 JSON 格式的测试数据"})})})}),a.jsx(m.Modal,{title:"画布配置",open:W,onCancel:()=>R(!1),footer:null,children:a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"宽度",children:a.jsx(m.InputNumber,{value:u.width,onChange:B=>g({width:B||1920}),min:100,max:5e3,style:{width:"100%"}})}),a.jsx(m.Form.Item,{label:"高度",children:a.jsx(m.InputNumber,{value:u.height,onChange:B=>g({height:B||1080}),min:100,max:5e3,style:{width:"100%"}})}),a.jsx(m.Form.Item,{label:"显示网格",children:a.jsx(m.Switch,{checked:u.showGrid!==!1,onChange:B=>g({showGrid:B})})}),a.jsx(m.Form.Item,{label:"背景色",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:u.background||"#00193C",onChange:B=>g({background:B.toHexString()})}),a.jsx(m.Input,{value:u.background,onChange:B=>g({background:B.target.value}),placeholder:"#ffffff"})]})}),a.jsxs(m.Form.Item,{label:"背景图片",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(m.Upload,{accept:"image/*",showUploadList:!1,beforeUpload:B=>{if(!B.type.startsWith("image/"))return m.message.error("只能上传图片文件!"),!1;const ie=new FileReader;return ie.onload=oe=>{const Q=oe.target?.result;g({backgroundImage:Q}),m.message.success("背景图片上传成功")},ie.readAsDataURL(B),!1},children:a.jsx(m.Button,{icon:a.jsx(se.UploadOutlined,{}),children:"上传图片"})}),a.jsx(m.Input,{value:u.backgroundImage,onChange:B=>g({backgroundImage:B.target.value}),placeholder:"输入图片 URL 或上传图片",style:{flex:1}}),u.backgroundImage&&a.jsx(m.Button,{icon:a.jsx(se.CloseOutlined,{}),onClick:()=>g({backgroundImage:void 0}),danger:!0,size:"small"})]}),u.backgroundImage&&a.jsx("div",{className:"mt-2 p-2 border rounded",style:{maxWidth:"100%"},children:a.jsx("img",{src:u.backgroundImage,alt:"背景预览",style:{maxWidth:"100%",maxHeight:120,objectFit:"contain"}})})]})]})}),a.jsxs(m.Modal,{title:"画布管理",open:Mo,onCancel:()=>{yt(!1),Pn(null),tt("")},footer:null,children:[a.jsx(m.List,{dataSource:f.canvases,renderItem:B=>a.jsx(m.List.Item,{actions:[Po===B.id?a.jsx(m.Button,{type:"primary",size:"small",onClick:()=>{A(B.id,bt),Pn(null)},children:"保存"}):a.jsx(m.Button,{type:"text",icon:a.jsx(se.EditOutlined,{}),size:"small",onClick:()=>{Pn(B.id),tt(B.name)}}),f.canvases.length>1&&a.jsx(m.Button,{type:"text",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),size:"small",onClick:()=>z(B.id)})].filter(Boolean),children:Po===B.id?a.jsx(m.Input,{value:bt,onChange:J=>tt(J.target.value),size:"small",style:{width:200}}):a.jsxs("span",{style:{fontWeight:f.currentCanvasId===B.id?"bold":"normal"},children:[B.name," ",f.currentCanvasId===B.id&&"(当前)"]})})}),a.jsx("div",{className:"mt-4 flex justify-end",children:a.jsx(m.Button,{type:"primary",icon:a.jsx(se.PlusOutlined,{}),onClick:()=>T(),children:"新建画布"})})]})]})},{Option:Hn}=m.Select,hd=({material:e,onSave:t,dataOptions:n=[]})=>{const r=e.content||{},[i,s]=E.useState({label:r.label||"",value:r.value||"",valueSourceCode:r.valueSourceCode||"",unit:r.unit||"",decimals:r.decimals??2,labelFontSize:r.labelStyle?.fontSize||14,labelFontWeight:r.labelStyle?.fontWeight||"bold",labelColor:r.labelStyle?.color||"#262626",valueFontSize:r.valueStyle?.fontSize||14,valueFontWeight:r.valueStyle?.fontWeight||"normal",valueColor:r.valueStyle?.color||"#1890ff"});E.useEffect(()=>{s({label:r.label||"",value:r.value||"",valueSourceCode:r.valueSourceCode||"",unit:r.unit||"",decimals:r.decimals??2,labelFontSize:r.labelStyle?.fontSize||14,labelFontWeight:r.labelStyle?.fontWeight||"bold",labelColor:r.labelStyle?.color||"#262626",valueFontSize:r.valueStyle?.fontSize||14,valueFontWeight:r.valueStyle?.fontWeight||"normal",valueColor:r.valueStyle?.color||"#1890ff"})},[e.id]);const l=(u,f)=>{s(h=>({...h,[u]:f}))},d=u=>{const f=n.find(g=>g.paramsCode===u),h=f?.unit||"";s(g=>({...g,valueSourceCode:u,unit:h,value:String(f?.value||"")})),setTimeout(()=>{t({content:{...r,valueSourceCode:u,value:String(f?.value||""),unit:h}})},0)},c=()=>{t({content:{...r,label:i.label,value:i.value,valueSourceCode:i.valueSourceCode,unit:i.unit,decimals:i.decimals,labelStyle:{fontSize:i.labelFontSize,fontWeight:i.labelFontWeight,color:i.labelColor},valueStyle:{fontSize:i.valueFontSize,fontWeight:i.valueFontWeight,color:i.valueColor}}})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(m.Divider,{style:{marginTop:0},children:"文本内容"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"标签文本 (label)",children:a.jsx(m.Input,{value:i.label,onChange:u=>l("label",u.target.value),onBlur:c,placeholder:"输入标签文本"})}),a.jsx(m.Form.Item,{label:"值来源",help:"从绑定的数据中选择字段,优先级高于手动输入的值",children:a.jsx(m.Select,{value:i.valueSourceCode||void 0,onChange:d,placeholder:"选择数据字段(可选)",allowClear:!0,style:{width:"100%"},fieldNames:{value:"paramsCode",label:"paramsName"},options:n})}),a.jsx(m.Form.Item,{label:i.valueSourceCode?"默认值(备用)":"值文本",help:i.valueSourceCode?"已绑定数据源,实际值将来自数据字段,此处仅设置无数据时的备用显示":"手动输入显示的值",children:a.jsx(m.Input,{value:i.value,onChange:u=>l("value",u.target.value),onBlur:c,placeholder:i.valueSourceCode?"数据字段无值时显示此备用值":"输入值文本",disabled:!!i.valueSourceCode,variant:i.valueSourceCode?"filled":void 0})}),a.jsx(m.Form.Item,{label:"单位",help:"优先从绑定数据自动获取,也可手动输入",children:a.jsx(m.Input,{value:i.unit,onChange:u=>l("unit",u.target.value),onBlur:c,placeholder:"单位(如°C、%、MPa等)",suffix:i.valueSourceCode&&n.length>0?a.jsx(m.Tag,{color:"blue",style:{marginRight:-8},children:"自动"}):null})}),a.jsx(m.Form.Item,{label:"保留小数位",help:"数值格式化时保留的小数位数,-1表示不格式化",children:a.jsx(m.InputNumber,{value:i.decimals,onChange:u=>l("decimals",u??2),onBlur:c,min:-1,max:10,style:{width:"100%"}})})]}),a.jsx(m.Divider,{children:"标签样式"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsxs(m.Space,{children:[a.jsx(m.Form.Item,{label:"字体大小",children:a.jsx(m.InputNumber,{value:i.labelFontSize,onChange:u=>l("labelFontSize",u||14),onBlur:c,min:8,max:72})}),a.jsx(m.Form.Item,{label:"字体粗细",children:a.jsxs(m.Select,{value:i.labelFontWeight,onChange:u=>{l("labelFontWeight",u),setTimeout(c,0)},style:{width:100},children:[a.jsx(Hn,{value:"normal",children:"正常"}),a.jsx(Hn,{value:"bold",children:"粗体"})]})})]}),a.jsx(m.Form.Item,{label:"文字颜色",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:i.labelColor||"#262626",onChange:u=>{l("labelColor",u.toHexString())},onChangeComplete:u=>{t({content:{...r,label:i.label,value:i.value,valueSourceCode:i.valueSourceCode,unit:i.unit,decimals:i.decimals,labelStyle:{fontSize:i.labelFontSize,fontWeight:i.labelFontWeight,color:u.toHexString()},valueStyle:{fontSize:i.valueFontSize,fontWeight:i.valueFontWeight,color:i.valueColor}}})}}),a.jsx(m.Input,{value:i.labelColor,onChange:u=>l("labelColor",u.target.value),onBlur:c,placeholder:"#262626",style:{width:100}})]})})]}),a.jsx(m.Divider,{children:"值样式"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsxs(m.Space,{children:[a.jsx(m.Form.Item,{label:"字体大小",children:a.jsx(m.InputNumber,{value:i.valueFontSize,onChange:u=>l("valueFontSize",u||14),onBlur:c,min:8,max:72})}),a.jsx(m.Form.Item,{label:"字体粗细",children:a.jsxs(m.Select,{value:i.valueFontWeight,onChange:u=>{l("valueFontWeight",u),setTimeout(c,0)},style:{width:100},children:[a.jsx(Hn,{value:"normal",children:"正常"}),a.jsx(Hn,{value:"bold",children:"粗体"})]})})]}),a.jsx(m.Form.Item,{label:"文字颜色",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:i.valueColor||"#1890ff",onChange:u=>{l("valueColor",u.toHexString())},onChangeComplete:u=>{t({content:{...r,label:i.label,value:i.value,valueSourceCode:i.valueSourceCode,unit:i.unit,decimals:i.decimals,labelStyle:{fontSize:i.labelFontSize,fontWeight:i.labelFontWeight,color:i.labelColor},valueStyle:{fontSize:i.valueFontSize,fontWeight:i.valueFontWeight,color:u.toHexString()}}})}}),a.jsx(m.Input,{value:i.valueColor,onChange:u=>l("valueColor",u.target.value),onBlur:c,placeholder:"#1890ff",style:{width:100}})]})})]})]})},pd=({material:e,onSave:t})=>{const n=e,[o,r]=E.useState({name:e.name,src:n.src||"",backgroundColor:n.backgroundColor||"",fillColor:n.fillColor||""});E.useEffect(()=>{r({name:e.name,src:n.src||"",backgroundColor:n.backgroundColor||"",fillColor:n.fillColor||""})},[e.id]);const i=(l,d)=>{r(c=>({...c,[l]:d}))},s=()=>{t({name:o.name,src:o.src,backgroundColor:o.backgroundColor})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(m.Divider,{style:{marginTop:0},children:"图片属性"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"图片名称",children:a.jsx(m.Input,{value:o.name,onChange:l=>i("name",l.target.value),onBlur:s})}),a.jsx(m.Form.Item,{label:"图片地址 (src)",children:a.jsx(m.Input.TextArea,{value:o.src,onChange:l=>i("src",l.target.value),onBlur:s,rows:4,placeholder:"输入图片 URL 或 Data URI"})}),a.jsx(m.Form.Item,{label:"填充颜色(基本形状)",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:o.fillColor||"#1890ff",onChange:l=>{const d=l.toHexString();i("fillColor",d),t({name:o.name,src:o.src,backgroundColor:o.backgroundColor,fillColor:d})}}),a.jsx(m.Input,{value:o.fillColor,onChange:l=>i("fillColor",l.target.value),onBlur:s,placeholder:"#1890ff"})]})}),a.jsx(m.Form.Item,{label:"背景颜色",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:o.backgroundColor||"#1890ff",onChange:l=>{const d=l.toHexString();i("backgroundColor",d),t({name:o.name,src:o.src,backgroundColor:d,fillColor:o.fillColor})}}),a.jsx(m.Input,{value:o.backgroundColor,onChange:l=>i("backgroundColor",l.target.value),onBlur:s,placeholder:"#1890ff"})]})})]})]})},{Option:gd}=m.Select,md=({material:e,onSave:t})=>{const n=e.config||{},[o,r]=E.useState({lineWeight:n.lineWeight||n.thickness||2,color:n.color||"#262626",lineType:n.lineType||"solid",startX:n.startX??0,startY:n.startY??0,endX:n.endX??100,endY:n.endY??0}),i=JSON.stringify({sw:n.lineWeight??n.thickness,c:n.color,t:n.lineType,sx:n.startX,sy:n.startY,ex:n.endX,ey:n.endY});E.useEffect(()=>{r({lineWeight:n.lineWeight||n.thickness||2,color:n.color||"#262626",lineType:n.lineType||"solid",startX:n.startX??0,startY:n.startY??0,endX:n.endX??100,endY:n.endY??0})},[e.id,i]);const s=d=>{const c={...o,...d};r(c),t({config:{...n,thickness:c.lineWeight,lineWeight:c.lineWeight,color:c.color,lineType:c.lineType,startX:c.startX,startY:c.startY,endX:c.endX,endY:c.endY}})},l=[{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 a.jsxs("div",{className:"space-y-4",children:[a.jsx(m.Divider,{style:{marginTop:0},children:"起止位置(相对节点)"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(m.Form.Item,{label:"起点 X",className:"mb-2",children:a.jsx(m.InputNumber,{value:o.startX,onChange:d=>s({startX:d??0}),style:{width:"100%"}})}),a.jsx(m.Form.Item,{label:"起点 Y",className:"mb-2",children:a.jsx(m.InputNumber,{value:o.startY,onChange:d=>s({startY:d??0}),style:{width:"100%"}})}),a.jsx(m.Form.Item,{label:"终点 X",className:"mb-2",children:a.jsx(m.InputNumber,{value:o.endX,onChange:d=>s({endX:d??100}),style:{width:"100%"}})}),a.jsx(m.Form.Item,{label:"终点 Y",className:"mb-2",children:a.jsx(m.InputNumber,{value:o.endY,onChange:d=>s({endY:d??0}),style:{width:"100%"}})})]}),a.jsx(m.Form.Item,{label:"快速对齐",className:"mt-4",children:a.jsxs(m.Space,{children:[a.jsx(m.Button,{size:"small",onClick:()=>{const d=n.startY??o.startY;s({endY:d})},title:"将线条变为水平线",children:"水平"}),a.jsx(m.Button,{size:"small",onClick:()=>{const d=n.startX??o.startX;s({endX:d})},title:"将线条变为垂直线",children:"垂直"}),a.jsx(m.Button,{size:"small",onClick:()=>{const d=n.startX??o.startX,c=n.startY??o.startY,u=n.endX??o.endX,f=n.endY??o.endY;s({startX:u,startY:f,endX:d,endY:c})},title:"交换起点和终点",children:"反向"})]})})]}),a.jsx(m.Divider,{children:"线条属性"}),a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"线型",help:"选择线条样式",children:a.jsx(m.Select,{value:o.lineType,onChange:d=>s({lineType:d}),children:l.map(d=>a.jsx(gd,{value:d.value,children:a.jsxs("div",{className:"flex flex-col",children:[a.jsx("span",{children:d.label}),a.jsx("span",{className:"text-xs text-gray-400",children:d.desc})]})},d.value))})}),a.jsx(m.Form.Item,{label:"线宽(像素)",children:a.jsx(m.InputNumber,{value:o.lineWeight,onChange:d=>s({lineWeight:d||2}),min:1,max:20,style:{width:120}})}),a.jsx(m.Form.Item,{label:"颜色",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Lt,{value:o.color||"#d9d9d9",onChange:d=>s({color:d.toHexString()})}),a.jsx(m.Input,{value:o.color,onChange:d=>s({color:d.target.value}),placeholder:"#d9d9d9",style:{width:100}})]})})]})]})},Hi=({status:e,onUpdate:t,onAppendToExpression:n})=>{const o=Ie(l=>l.dataPool),r=o.find(l=>l.id===e.boundDatasetId),i=r?ti(r.sample||{}):[],s=l=>{const d=`data.${l}`;n?n(d):t({expression:`${e.expression||""}${d}`})};return a.jsxs(a.Fragment,{children:[a.jsx(m.Form.Item,{label:"绑定数据集",extra:o.length===0?"请先在顶部工具栏点击「数据池」添加至少一个数据集(JSON 对象模板);宿主项目也可通过 initialScheme.dataPool 或 useEditorStore.getState().setDataPool() 注入。":"可选:绑定后表达式中的 data 会先合并该数据集的 sample,再合并画布传入的运行时数据。不绑定时 data 仅来自运行时。",children:a.jsx(m.Select,{allowClear:!0,placeholder:o.length===0?"暂无数据集,请打开「数据池」添加":"选择数据池中的数据集",value:e.boundDatasetId??void 0,options:o.map(l=>({label:l.name,value:l.id})),onChange:l=>t({boundDatasetId:l??null})})}),i.length>0&&a.jsx(m.Form.Item,{label:"字段路径(点击插入表达式)",children:a.jsx(m.Space,{size:[4,4],wrap:!0,children:i.map(l=>a.jsx(m.Tag,{className:"cursor-pointer mb-0",onClick:()=>s(l),children:`data.${l}`},l))})})]})},Yi=({material:e,onSave:t,dataOptions:n})=>{switch(e.type){case"TEXT":return a.jsx(hd,{material:e,onSave:t,dataOptions:n});case"IMAGE":return a.jsx(pd,{material:e,onSave:t});case"LINE":return a.jsx(md,{material:e,onSave:t});default:return a.jsx("div",{className:"text-center text-gray-400 py-8",children:"暂不支持编辑此类型的物料"})}},{Panel:Xi}=m.Collapse,{TextArea:yd}=m.Input,bd=({node:e,updateNode:t,materials:n})=>{const o=n.filter(u=>u.type!=="CUSTOM"||!u.config?.nodes),r=(u,f)=>{const h=e.children?.map(g=>g.id===u?{...g,contentInfo:{...g.contentInfo,statusList:f}}:g);t(e.id,{children:h})},i=u=>{const f=e.children?.find(g=>g.id===u);if(!f)return;const h={id:he.nanoid(),name:`状态${f.contentInfo.statusList.length+1}`,expression:f.contentInfo.statusList.length===0?"return true;":"return false;",material:{...o[0],id:he.nanoid()},boundDatasetId:null};r(u,[...f.contentInfo.statusList,h])},s=(u,f)=>{const h=e.children?.find(p=>p.id===u);if(!h)return;const g=h.contentInfo.statusList.filter(p=>p.id!==f);r(u,g)},l=(u,f,h)=>{const g=e.children?.find(b=>b.id===u);if(!g)return;const p=g.contentInfo.statusList.map(b=>b.id===f?{...b,...h}:b);r(u,p)},d=(u,f,h)=>{const g=e.children?.find(v=>v.id===u);if(!g)return;const p=g.contentInfo.statusList.findIndex(v=>v.id===f);if(p===-1)return;const b=[...g.contentInfo.statusList];h==="up"&&p>0?[b[p],b[p-1]]=[b[p-1],b[p]]:h==="down"&&p<b.length-1&&([b[p],b[p+1]]=[b[p+1],b[p]]),r(u,b)},c=(u,f,h)=>{const g=n.find(p=>p.id===h);g&&l(u,f,{material:{...g,id:he.nanoid()}})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("div",{className:"p-3 bg-blue-50 border border-blue-200 rounded-lg mb-4",children:a.jsxs("div",{className:"text-sm text-blue-700",children:[a.jsx("strong",{children:"群组节点"}),":为每个子节点配置多个状态和绑定"]})}),a.jsx(m.Collapse,{ghost:!0,children:e.children?.map((u,f)=>a.jsx(Xi,{header:a.jsxs("div",{className:"flex items-center justify-between w-full pr-4",children:[a.jsxs("span",{className:"font-medium text-sm",children:["子节点 ",f+1]}),a.jsxs(m.Tag,{color:"blue",style:{fontSize:"12px",padding:"0 4px"},children:[u.contentInfo.statusList.length," 个状态"]})]}),children:a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex justify-between items-center mb-3",children:[a.jsx("span",{className:"text-sm text-gray-600",children:"状态列表"}),a.jsx(m.Button,{type:"primary",size:"small",icon:a.jsx(se.PlusOutlined,{}),onClick:()=>i(u.id),children:"添加状态"})]}),u.contentInfo.statusList.length===0?a.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):a.jsx(m.Collapse,{ghost:!0,children:u.contentInfo.statusList.map((h,g)=>a.jsx(Xi,{header:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-gray-400 w-5",children:g+1}),a.jsx("span",{className:"font-medium",children:h.name}),a.jsx(m.Tag,{color:"default",className:"text-xs",children:h.material.type})]}),extra:a.jsxs(m.Space,{size:"small",onClick:p=>p.stopPropagation(),children:[a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.ArrowUpOutlined,{}),disabled:g===0,onClick:p=>{p.stopPropagation(),d(u.id,h.id,"up")}}),a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.ArrowDownOutlined,{}),disabled:g===u.contentInfo.statusList.length-1,onClick:p=>{p.stopPropagation(),d(u.id,h.id,"down")}}),a.jsx(m.Button,{type:"text",size:"small",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),onClick:p=>{p.stopPropagation(),s(u.id,h.id)}})]}),children:a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"状态名称",children:a.jsx(m.Input,{value:h.name,onChange:p=>l(u.id,h.id,{name:p.target.value}),placeholder:"输入状态名称"})}),a.jsx(Hi,{status:h,onUpdate:p=>l(u.id,h.id,p)}),a.jsx(m.Form.Item,{label:"执行表达式",help:"单参数 data(对象),须 return true/false;测点数组按 paramsCode 合并进 data。",children:a.jsx(yd,{value:h.expression,onChange:p=>l(u.id,h.id,{expression:p.target.value}),rows:3,placeholder:"return true;"})}),a.jsx(m.Form.Item,{label:"更换物料",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(m.Tag,{color:"blue",children:h.material.name}),a.jsx(m.Tag,{color:"default",children:h.material.type}),a.jsx(m.Select,{placeholder:"选择新物料",style:{width:150},value:void 0,onChange:p=>p&&c(u.id,h.id,p),options:o.map(p=>({value:p.id,label:`${p.name} (${p.type})`}))})]})}),a.jsx(m.Divider,{style:{margin:"12px 0"}}),a.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),a.jsx(m.Tag,{children:h.material.name})]}),a.jsx(Yi,{material:h.material,onSave:p=>{const b={...h.material,...p};l(u.id,h.id,{material:b})}})]})]})},h.id))})]})},u.id))})]})};function Ee(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=Ee(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var vd={value:()=>{}};function Yn(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Xn(n)}function Xn(e){this._=e}function wd(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Xn.prototype=Yn.prototype={constructor:Xn,on:function(e,t){var n=this._,o=wd(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=xd(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Vi(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Vi(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Xn(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function xd(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Vi(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=vd,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Uo="http://www.w3.org/1999/xhtml";const Wi={svg:"http://www.w3.org/2000/svg",xhtml:Uo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Vn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Wi.hasOwnProperty(t)?{space:Wi[t],local:e}:e}function Sd(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Uo&&t.documentElement.namespaceURI===Uo?t.createElement(e):t.createElementNS(n,e)}}function _d(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qi(e){var t=Vn(e);return(t.local?_d:Sd)(t)}function Ed(){}function Go(e){return e==null?Ed:function(){return this.querySelector(e)}}function Cd(e){typeof e!="function"&&(e=Go(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,l=o[r]=new Array(s),d,c,u=0;u<s;++u)(d=i[u])&&(c=e.call(d,d.__data__,u,i))&&("__data__"in d&&(c.__data__=d.__data__),l[u]=c);return new Te(o,this._parents)}function Nd(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function kd(){return[]}function ji(e){return e==null?kd:function(){return this.querySelectorAll(e)}}function Id(e){return function(){return Nd(e.apply(this,arguments))}}function Md(e){typeof e=="function"?e=Id(e):e=ji(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],l=s.length,d,c=0;c<l;++c)(d=s[c])&&(o.push(e.call(d,d.__data__,c,s)),r.push(d));return new Te(o,r)}function Ui(e){return function(){return this.matches(e)}}function Gi(e){return function(t){return t.matches(e)}}var Pd=Array.prototype.find;function Dd(e){return function(){return Pd.call(this.children,e)}}function Td(){return this.firstElementChild}function Od(e){return this.select(e==null?Td:Dd(typeof e=="function"?e:Gi(e)))}var Ad=Array.prototype.filter;function $d(){return Array.from(this.children)}function Ld(e){return function(){return Ad.call(this.children,e)}}function zd(e){return this.selectAll(e==null?$d:Ld(typeof e=="function"?e:Gi(e)))}function Fd(e){typeof e!="function"&&(e=Ui(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,l=o[r]=[],d,c=0;c<s;++c)(d=i[c])&&e.call(d,d.__data__,c,i)&&l.push(d);return new Te(o,this._parents)}function Ki(e){return new Array(e.length)}function Bd(){return new Te(this._enter||this._groups.map(Ki),this._parents)}function Wn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Wn.prototype={constructor:Wn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Hd(e){return function(){return e}}function Yd(e,t,n,o,r,i){for(var s=0,l,d=t.length,c=i.length;s<c;++s)(l=t[s])?(l.__data__=i[s],o[s]=l):n[s]=new Wn(e,i[s]);for(;s<d;++s)(l=t[s])&&(r[s]=l)}function Xd(e,t,n,o,r,i,s){var l,d,c=new Map,u=t.length,f=i.length,h=new Array(u),g;for(l=0;l<u;++l)(d=t[l])&&(h[l]=g=s.call(d,d.__data__,l,t)+"",c.has(g)?r[l]=d:c.set(g,d));for(l=0;l<f;++l)g=s.call(e,i[l],l,i)+"",(d=c.get(g))?(o[l]=d,d.__data__=i[l],c.delete(g)):n[l]=new Wn(e,i[l]);for(l=0;l<u;++l)(d=t[l])&&c.get(h[l])===d&&(r[l]=d)}function Vd(e){return e.__data__}function Wd(e,t){if(!arguments.length)return Array.from(this,Vd);var n=t?Xd:Yd,o=this._parents,r=this._groups;typeof e!="function"&&(e=Hd(e));for(var i=r.length,s=new Array(i),l=new Array(i),d=new Array(i),c=0;c<i;++c){var u=o[c],f=r[c],h=f.length,g=qd(e.call(u,u&&u.__data__,c,o)),p=g.length,b=l[c]=new Array(p),v=s[c]=new Array(p),w=d[c]=new Array(h);n(u,f,b,v,w,g,t);for(var _=0,y=0,x,D;_<p;++_)if(x=b[_]){for(_>=y&&(y=_+1);!(D=v[y])&&++y<p;);x._next=D||null}}return s=new Te(s,o),s._enter=l,s._exit=d,s}function qd(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function jd(){return new Te(this._exit||this._groups.map(Ki),this._parents)}function Ud(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Gd(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),l=new Array(r),d=0;d<s;++d)for(var c=n[d],u=o[d],f=c.length,h=l[d]=new Array(f),g,p=0;p<f;++p)(g=c[p]||u[p])&&(h[p]=g);for(;d<r;++d)l[d]=n[d];return new Te(l,this._parents)}function Kd(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Zd(e){e||(e=Jd);function t(f,h){return f&&h?e(f.__data__,h.__data__):!f-!h}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],l=s.length,d=r[i]=new Array(l),c,u=0;u<l;++u)(c=s[u])&&(d[u]=c);d.sort(t)}return new Te(r,this._parents).order()}function Jd(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Qd(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Rd(){return Array.from(this)}function eu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function tu(){let e=0;for(const t of this)++e;return e}function nu(){return!this.node()}function ou(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,l;i<s;++i)(l=r[i])&&e.call(l,l.__data__,i,r);return this}function ru(e){return function(){this.removeAttribute(e)}}function iu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function su(e,t){return function(){this.setAttribute(e,t)}}function au(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function lu(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cu(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function du(e,t){var n=Vn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?iu:ru:typeof t=="function"?n.local?cu:lu:n.local?au:su)(n,t))}function Zi(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function uu(e){return function(){this.style.removeProperty(e)}}function fu(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hu(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function pu(e,t,n){return arguments.length>1?this.each((t==null?uu:typeof t=="function"?hu:fu)(e,t,n??"")):zt(this.node(),e)}function zt(e,t){return e.style.getPropertyValue(t)||Zi(e).getComputedStyle(e,null).getPropertyValue(t)}function gu(e){return function(){delete this[e]}}function mu(e,t){return function(){this[e]=t}}function yu(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bu(e,t){return arguments.length>1?this.each((t==null?gu:typeof t=="function"?yu:mu)(e,t)):this.node()[e]}function Ji(e){return e.trim().split(/^|\s+/)}function Ko(e){return e.classList||new Qi(e)}function Qi(e){this._node=e,this._names=Ji(e.getAttribute("class")||"")}Qi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Ri(e,t){for(var n=Ko(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function es(e,t){for(var n=Ko(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function vu(e){return function(){Ri(this,e)}}function wu(e){return function(){es(this,e)}}function xu(e,t){return function(){(t.apply(this,arguments)?Ri:es)(this,e)}}function Su(e,t){var n=Ji(e+"");if(arguments.length<2){for(var o=Ko(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?xu:t?vu:wu)(n,t))}function _u(){this.textContent=""}function Eu(e){return function(){this.textContent=e}}function Cu(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nu(e){return arguments.length?this.each(e==null?_u:(typeof e=="function"?Cu:Eu)(e)):this.node().textContent}function ku(){this.innerHTML=""}function Iu(e){return function(){this.innerHTML=e}}function Mu(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Pu(e){return arguments.length?this.each(e==null?ku:(typeof e=="function"?Mu:Iu)(e)):this.node().innerHTML}function Du(){this.nextSibling&&this.parentNode.appendChild(this)}function Tu(){return this.each(Du)}function Ou(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Au(){return this.each(Ou)}function $u(e){var t=typeof e=="function"?e:qi(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Lu(){return null}function zu(e,t){var n=typeof e=="function"?e:qi(e),o=t==null?Lu:typeof t=="function"?t:Go(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Fu(){var e=this.parentNode;e&&e.removeChild(this)}function Bu(){return this.each(Fu)}function Hu(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yu(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xu(e){return this.select(e?Yu:Hu)}function Vu(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Wu(e){return function(t){e.call(this,t,this.__data__)}}function qu(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function ju(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Uu(e,t,n){return function(){var o=this.__on,r,i=Wu(t);if(o){for(var s=0,l=o.length;s<l;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Gu(e,t,n){var o=qu(e+""),r,i=o.length,s;if(arguments.length<2){var l=this.node().__on;if(l){for(var d=0,c=l.length,u;d<c;++d)for(r=0,u=l[d];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(l=t?Uu:ju,r=0;r<i;++r)this.each(l(o[r],t,n));return this}function ts(e,t,n){var o=Zi(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ku(e,t){return function(){return ts(this,e,t)}}function Zu(e,t){return function(){return ts(this,e,t.apply(this,arguments))}}function Ju(e,t){return this.each((typeof t=="function"?Zu:Ku)(e,t))}function*Qu(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ns=[null];function Te(e,t){this._groups=e,this._parents=t}function cn(){return new Te([[document.documentElement]],ns)}function Ru(){return this}Te.prototype=cn.prototype={constructor:Te,select:Cd,selectAll:Md,selectChild:Od,selectChildren:zd,filter:Fd,data:Wd,enter:Bd,exit:jd,join:Ud,merge:Gd,selection:Ru,order:Kd,sort:Zd,call:Qd,nodes:Rd,node:eu,size:tu,empty:nu,each:ou,attr:du,style:pu,property:bu,classed:Su,text:Nu,html:Pu,raise:Tu,lower:Au,append:$u,insert:zu,remove:Bu,clone:Xu,datum:Vu,on:Gu,dispatch:Ju,[Symbol.iterator]:Qu};function Oe(e){return typeof e=="string"?new Te([[document.querySelector(e)]],[document.documentElement]):new Te([[e]],ns)}function ef(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ye(e,t){if(e=ef(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const tf={passive:!1},dn={capture:!0,passive:!1};function Zo(e){e.stopImmediatePropagation()}function Ft(e){e.preventDefault(),e.stopImmediatePropagation()}function os(e){var t=e.document.documentElement,n=Oe(e).on("dragstart.drag",Ft,dn);"onselectstart"in t?n.on("selectstart.drag",Ft,dn):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function rs(e,t){var n=e.document.documentElement,o=Oe(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ft,dn),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const qn=e=>()=>e;function Jo(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:l,dx:d,dy:c,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:u}})}Jo.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function nf(e){return!e.ctrlKey&&!e.button}function of(){return this.parentNode}function rf(e,t){return t??{x:e.x,y:e.y}}function sf(){return navigator.maxTouchPoints||"ontouchstart"in this}function is(){var e=nf,t=of,n=rf,o=sf,r={},i=Yn("start","drag","end"),s=0,l,d,c,u,f=0;function h(x){x.on("mousedown.drag",g).filter(o).on("touchstart.drag",v).on("touchmove.drag",w,tf).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(x,D){if(!(u||!e.call(this,x,D))){var M=y(this,t.call(this,x,D),x,D,"mouse");M&&(Oe(x.view).on("mousemove.drag",p,dn).on("mouseup.drag",b,dn),os(x.view),Zo(x),c=!1,l=x.clientX,d=x.clientY,M("start",x))}}function p(x){if(Ft(x),!c){var D=x.clientX-l,M=x.clientY-d;c=D*D+M*M>f}r.mouse("drag",x)}function b(x){Oe(x.view).on("mousemove.drag mouseup.drag",null),rs(x.view,c),Ft(x),r.mouse("end",x)}function v(x,D){if(e.call(this,x,D)){var M=x.changedTouches,P=t.call(this,x,D),T=M.length,z,q;for(z=0;z<T;++z)(q=y(this,P,x,D,M[z].identifier,M[z]))&&(Zo(x),q("start",x,M[z]))}}function w(x){var D=x.changedTouches,M=D.length,P,T;for(P=0;P<M;++P)(T=r[D[P].identifier])&&(Ft(x),T("drag",x,D[P]))}function _(x){var D=x.changedTouches,M=D.length,P,T;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),P=0;P<M;++P)(T=r[D[P].identifier])&&(Zo(x),T("end",x,D[P]))}function y(x,D,M,P,T,z){var q=i.copy(),A=Ye(z||M,D),H,j,C;if((C=n.call(x,new Jo("beforestart",{sourceEvent:M,target:h,identifier:T,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:q}),P))!=null)return H=C.x-A[0]||0,j=C.y-A[1]||0,function S(N,k,I){var O=A,Y;switch(N){case"start":r[T]=S,Y=s++;break;case"end":delete r[T],--s;case"drag":A=Ye(I||k,D),Y=s;break}q.call(N,x,new Jo(N,{sourceEvent:k,subject:C,target:h,identifier:T,active:Y,x:A[0]+H,y:A[1]+j,dx:A[0]-O[0],dy:A[1]-O[1],dispatch:q}),P)}}return h.filter=function(x){return arguments.length?(e=typeof x=="function"?x:qn(!!x),h):e},h.container=function(x){return arguments.length?(t=typeof x=="function"?x:qn(x),h):t},h.subject=function(x){return arguments.length?(n=typeof x=="function"?x:qn(x),h):n},h.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:qn(!!x),h):o},h.on=function(){var x=i.on.apply(i,arguments);return x===i?h:x},h.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,h):Math.sqrt(f)},h}function Qo(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ss(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function un(){}var fn=.7,jn=1/fn,Bt="\\s*([+-]?\\d+)\\s*",hn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Je="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",af=/^#([0-9a-f]{3,8})$/,lf=new RegExp(`^rgb\\(${Bt},${Bt},${Bt}\\)$`),cf=new RegExp(`^rgb\\(${Je},${Je},${Je}\\)$`),df=new RegExp(`^rgba\\(${Bt},${Bt},${Bt},${hn}\\)$`),uf=new RegExp(`^rgba\\(${Je},${Je},${Je},${hn}\\)$`),ff=new RegExp(`^hsl\\(${hn},${Je},${Je}\\)$`),hf=new RegExp(`^hsla\\(${hn},${Je},${Je},${hn}\\)$`),as={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Qo(un,Et,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ls,formatHex:ls,formatHex8:pf,formatHsl:gf,formatRgb:cs,toString:cs});function ls(){return this.rgb().formatHex()}function pf(){return this.rgb().formatHex8()}function gf(){return ps(this).formatHsl()}function cs(){return this.rgb().formatRgb()}function Et(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=af.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ds(t):n===3?new Me(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Un(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Un(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=lf.exec(e))?new Me(t[1],t[2],t[3],1):(t=cf.exec(e))?new Me(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=df.exec(e))?Un(t[1],t[2],t[3],t[4]):(t=uf.exec(e))?Un(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ff.exec(e))?hs(t[1],t[2]/100,t[3]/100,1):(t=hf.exec(e))?hs(t[1],t[2]/100,t[3]/100,t[4]):as.hasOwnProperty(e)?ds(as[e]):e==="transparent"?new Me(NaN,NaN,NaN,0):null}function ds(e){return new Me(e>>16&255,e>>8&255,e&255,1)}function Un(e,t,n,o){return o<=0&&(e=t=n=NaN),new Me(e,t,n,o)}function mf(e){return e instanceof un||(e=Et(e)),e?(e=e.rgb(),new Me(e.r,e.g,e.b,e.opacity)):new Me}function Ro(e,t,n,o){return arguments.length===1?mf(e):new Me(e,t,n,o??1)}function Me(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Qo(Me,Ro,ss(un,{brighter(e){return e=e==null?jn:Math.pow(jn,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fn:Math.pow(fn,e),new Me(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Me(Ct(this.r),Ct(this.g),Ct(this.b),Gn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:us,formatHex:us,formatHex8:yf,formatRgb:fs,toString:fs}));function us(){return`#${Nt(this.r)}${Nt(this.g)}${Nt(this.b)}`}function yf(){return`#${Nt(this.r)}${Nt(this.g)}${Nt(this.b)}${Nt((isNaN(this.opacity)?1:this.opacity)*255)}`}function fs(){const e=Gn(this.opacity);return`${e===1?"rgb(":"rgba("}${Ct(this.r)}, ${Ct(this.g)}, ${Ct(this.b)}${e===1?")":`, ${e})`}`}function Gn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ct(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Nt(e){return e=Ct(e),(e<16?"0":"")+e.toString(16)}function hs(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Xe(e,t,n,o)}function ps(e){if(e instanceof Xe)return new Xe(e.h,e.s,e.l,e.opacity);if(e instanceof un||(e=Et(e)),!e)return new Xe;if(e instanceof Xe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,l=i-r,d=(i+r)/2;return l?(t===i?s=(n-o)/l+(n<o)*6:n===i?s=(o-t)/l+2:s=(t-n)/l+4,l/=d<.5?i+r:2-i-r,s*=60):l=d>0&&d<1?0:s,new Xe(s,l,d,e.opacity)}function bf(e,t,n,o){return arguments.length===1?ps(e):new Xe(e,t,n,o??1)}function Xe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Qo(Xe,bf,ss(un,{brighter(e){return e=e==null?jn:Math.pow(jn,e),new Xe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fn:Math.pow(fn,e),new Xe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new Me(er(e>=240?e-240:e+120,r,o),er(e,r,o),er(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new Xe(gs(this.h),Kn(this.s),Kn(this.l),Gn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Gn(this.opacity);return`${e===1?"hsl(":"hsla("}${gs(this.h)}, ${Kn(this.s)*100}%, ${Kn(this.l)*100}%${e===1?")":`, ${e})`}`}}));function gs(e){return e=(e||0)%360,e<0?e+360:e}function Kn(e){return Math.max(0,Math.min(1,e||0))}function er(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const tr=e=>()=>e;function vf(e,t){return function(n){return e+n*t}}function wf(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function xf(e){return(e=+e)==1?ms:function(t,n){return n-t?wf(t,n,e):tr(isNaN(t)?n:t)}}function ms(e,t){var n=t-e;return n?vf(e,n):tr(isNaN(e)?t:e)}const Zn=(function e(t){var n=xf(t);function o(r,i){var s=n((r=Ro(r)).r,(i=Ro(i)).r),l=n(r.g,i.g),d=n(r.b,i.b),c=ms(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=l(u),r.b=d(u),r.opacity=c(u),r+""}}return o.gamma=e,o})(1);function Sf(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function _f(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ef(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=pn(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(l){for(s=0;s<o;++s)i[s]=r[s](l);return i}}function Cf(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function Qe(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Nf(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=pn(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var nr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,or=new RegExp(nr.source,"g");function kf(e){return function(){return e}}function If(e){return function(t){return e(t)+""}}function ys(e,t){var n=nr.lastIndex=or.lastIndex=0,o,r,i,s=-1,l=[],d=[];for(e=e+"",t=t+"";(o=nr.exec(e))&&(r=or.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),l[s]?l[s]+=i:l[++s]=i),(o=o[0])===(r=r[0])?l[s]?l[s]+=r:l[++s]=r:(l[++s]=null,d.push({i:s,x:Qe(o,r)})),n=or.lastIndex;return n<t.length&&(i=t.slice(n),l[s]?l[s]+=i:l[++s]=i),l.length<2?d[0]?If(d[0].x):kf(t):(t=d.length,function(c){for(var u=0,f;u<t;++u)l[(f=d[u]).i]=f.x(c);return l.join("")})}function pn(e,t){var n=typeof t,o;return t==null||n==="boolean"?tr(t):(n==="number"?Qe:n==="string"?(o=Et(t))?(t=o,Zn):ys:t instanceof Et?Zn:t instanceof Date?Cf:_f(t)?Sf:Array.isArray(t)?Ef:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Nf:Qe)(e,t)}var bs=180/Math.PI,rr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function vs(e,t,n,o,r,i){var s,l,d;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(d=e*n+t*o)&&(n-=e*d,o-=t*d),(l=Math.sqrt(n*n+o*o))&&(n/=l,o/=l,d/=l),e*o<t*n&&(e=-e,t=-t,d=-d,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*bs,skewX:Math.atan(d)*bs,scaleX:s,scaleY:l}}var Jn;function Mf(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?rr:vs(t.a,t.b,t.c,t.d,t.e,t.f)}function Pf(e){return e==null||(Jn||(Jn=document.createElementNS("http://www.w3.org/2000/svg","g")),Jn.setAttribute("transform",e),!(e=Jn.transform.baseVal.consolidate()))?rr:(e=e.matrix,vs(e.a,e.b,e.c,e.d,e.e,e.f))}function ws(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,u,f,h,g,p){if(c!==f||u!==h){var b=g.push("translate(",null,t,null,n);p.push({i:b-4,x:Qe(c,f)},{i:b-2,x:Qe(u,h)})}else(f||h)&&g.push("translate("+f+t+h+n)}function s(c,u,f,h){c!==u?(c-u>180?u+=360:u-c>180&&(c+=360),h.push({i:f.push(r(f)+"rotate(",null,o)-2,x:Qe(c,u)})):u&&f.push(r(f)+"rotate("+u+o)}function l(c,u,f,h){c!==u?h.push({i:f.push(r(f)+"skewX(",null,o)-2,x:Qe(c,u)}):u&&f.push(r(f)+"skewX("+u+o)}function d(c,u,f,h,g,p){if(c!==f||u!==h){var b=g.push(r(g)+"scale(",null,",",null,")");p.push({i:b-4,x:Qe(c,f)},{i:b-2,x:Qe(u,h)})}else(f!==1||h!==1)&&g.push(r(g)+"scale("+f+","+h+")")}return function(c,u){var f=[],h=[];return c=e(c),u=e(u),i(c.translateX,c.translateY,u.translateX,u.translateY,f,h),s(c.rotate,u.rotate,f,h),l(c.skewX,u.skewX,f,h),d(c.scaleX,c.scaleY,u.scaleX,u.scaleY,f,h),c=u=null,function(g){for(var p=-1,b=h.length,v;++p<b;)f[(v=h[p]).i]=v.x(g);return f.join("")}}}var Df=ws(Mf,"px, ","px)","deg)"),Tf=ws(Pf,", ",")",")"),Of=1e-12;function xs(e){return((e=Math.exp(e))+1/e)/2}function Af(e){return((e=Math.exp(e))-1/e)/2}function $f(e){return((e=Math.exp(2*e))-1)/(e+1)}const Qn=(function e(t,n,o){function r(i,s){var l=i[0],d=i[1],c=i[2],u=s[0],f=s[1],h=s[2],g=u-l,p=f-d,b=g*g+p*p,v,w;if(b<Of)w=Math.log(h/c)/t,v=function(P){return[l+P*g,d+P*p,c*Math.exp(t*P*w)]};else{var _=Math.sqrt(b),y=(h*h-c*c+o*b)/(2*c*n*_),x=(h*h-c*c-o*b)/(2*h*n*_),D=Math.log(Math.sqrt(y*y+1)-y),M=Math.log(Math.sqrt(x*x+1)-x);w=(M-D)/t,v=function(P){var T=P*w,z=xs(D),q=c/(n*_)*(z*$f(t*T+D)-Af(D));return[l+q*g,d+q*p,c*z/xs(t*T+D)]}}return v.duration=w*1e3*t/Math.SQRT2,v}return r.rho=function(i){var s=Math.max(.001,+i),l=s*s,d=l*l;return e(s,l,d)},r})(Math.SQRT2,2,4);var Ht=0,gn=0,mn=0,Ss=1e3,Rn,yn,eo=0,kt=0,to=0,bn=typeof performance=="object"&&performance.now?performance:Date,_s=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ir(){return kt||(_s(Lf),kt=bn.now()+to)}function Lf(){kt=0}function no(){this._call=this._time=this._next=null}no.prototype=Es.prototype={constructor:no,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ir():+n)+(t==null?0:+t),!this._next&&yn!==this&&(yn?yn._next=this:Rn=this,yn=this),this._call=e,this._time=n,sr()},stop:function(){this._call&&(this._call=null,this._time=1/0,sr())}};function Es(e,t,n){var o=new no;return o.restart(e,t,n),o}function zf(){ir(),++Ht;for(var e=Rn,t;e;)(t=kt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ht}function Cs(){kt=(eo=bn.now())+to,Ht=gn=0;try{zf()}finally{Ht=0,Bf(),kt=0}}function Ff(){var e=bn.now(),t=e-eo;t>Ss&&(to-=t,eo=e)}function Bf(){for(var e,t=Rn,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Rn=n);yn=e,sr(o)}function sr(e){if(!Ht){gn&&(gn=clearTimeout(gn));var t=e-kt;t>24?(e<1/0&&(gn=setTimeout(Cs,e-bn.now()-to)),mn&&(mn=clearInterval(mn))):(mn||(eo=bn.now(),mn=setInterval(Ff,Ss)),Ht=1,_s(Cs))}}function Ns(e,t,n){var o=new no;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Hf=Yn("start","end","cancel","interrupt"),Yf=[],ks=0,Is=1,ar=2,oo=3,Ms=4,lr=5,ro=6;function io(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Xf(e,n,{name:t,index:o,group:r,on:Hf,tween:Yf,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:ks})}function cr(e,t){var n=Ve(e,t);if(n.state>ks)throw new Error("too late; already scheduled");return n}function Re(e,t){var n=Ve(e,t);if(n.state>oo)throw new Error("too late; already running");return n}function Ve(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Xf(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Es(i,0,n.time);function i(c){n.state=Is,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var u,f,h,g;if(n.state!==Is)return d();for(u in o)if(g=o[u],g.name===n.name){if(g.state===oo)return Ns(s);g.state===Ms?(g.state=ro,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete o[u]):+u<t&&(g.state=ro,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete o[u])}if(Ns(function(){n.state===oo&&(n.state=Ms,n.timer.restart(l,n.delay,n.time),l(c))}),n.state=ar,n.on.call("start",e,e.__data__,n.index,n.group),n.state===ar){for(n.state=oo,r=new Array(h=n.tween.length),u=0,f=-1;u<h;++u)(g=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=g);r.length=f+1}}function l(c){for(var u=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(d),n.state=lr,1),f=-1,h=r.length;++f<h;)r[f].call(e,u);n.state===lr&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=ro,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function so(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>ar&&o.state<lr,o.state=ro,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Vf(e){return this.each(function(){so(this,e)})}function Wf(e,t){var n,o;return function(){var r=Re(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,l=o.length;s<l;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function qf(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Re(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var l={name:t,value:n},d=0,c=r.length;d<c;++d)if(r[d].name===t){r[d]=l;break}d===c&&r.push(l)}i.tween=r}}function jf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=Ve(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Wf:qf)(n,e,t))}function dr(e,t,n){var o=e._id;return e.each(function(){var r=Re(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return Ve(r,o).value[t]}}function Ps(e,t){var n;return(typeof t=="number"?Qe:t instanceof Et?Zn:(n=Et(t))?(t=n,Zn):ys)(e,t)}function Uf(e){return function(){this.removeAttribute(e)}}function Gf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kf(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Zf(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Jf(e,t,n){var o,r,i;return function(){var s,l=n(this),d;return l==null?void this.removeAttribute(e):(s=this.getAttribute(e),d=l+"",s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,l)))}}function Qf(e,t,n){var o,r,i;return function(){var s,l=n(this),d;return l==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),d=l+"",s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,l)))}}function Rf(e,t){var n=Vn(e),o=n==="transform"?Tf:Ps;return this.attrTween(e,typeof t=="function"?(n.local?Qf:Jf)(n,o,dr(this,"attr."+e,t)):t==null?(n.local?Gf:Uf)(n):(n.local?Zf:Kf)(n,o,t))}function eh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function th(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function nh(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&th(e,i)),n}return r._value=t,r}function oh(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&eh(e,i)),n}return r._value=t,r}function rh(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=Vn(e);return this.tween(n,(o.local?nh:oh)(o,t))}function ih(e,t){return function(){cr(this,e).delay=+t.apply(this,arguments)}}function sh(e,t){return t=+t,function(){cr(this,e).delay=t}}function ah(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ih:sh)(t,e)):Ve(this.node(),t).delay}function lh(e,t){return function(){Re(this,e).duration=+t.apply(this,arguments)}}function ch(e,t){return t=+t,function(){Re(this,e).duration=t}}function dh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?lh:ch)(t,e)):Ve(this.node(),t).duration}function uh(e,t){if(typeof t!="function")throw new Error;return function(){Re(this,e).ease=t}}function fh(e){var t=this._id;return arguments.length?this.each(uh(t,e)):Ve(this.node(),t).ease}function hh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Re(this,e).ease=n}}function ph(e){if(typeof e!="function")throw new Error;return this.each(hh(this._id,e))}function gh(e){typeof e!="function"&&(e=Ui(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,l=o[r]=[],d,c=0;c<s;++c)(d=i[c])&&e.call(d,d.__data__,c,i)&&l.push(d);return new ot(o,this._parents,this._name,this._id)}function mh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),l=0;l<i;++l)for(var d=t[l],c=n[l],u=d.length,f=s[l]=new Array(u),h,g=0;g<u;++g)(h=d[g]||c[g])&&(f[g]=h);for(;l<o;++l)s[l]=t[l];return new ot(s,this._parents,this._name,this._id)}function yh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function bh(e,t,n){var o,r,i=yh(t)?cr:Re;return function(){var s=i(this,e),l=s.on;l!==o&&(r=(o=l).copy()).on(t,n),s.on=r}}function vh(e,t){var n=this._id;return arguments.length<2?Ve(this.node(),n).on.on(e):this.each(bh(n,e,t))}function wh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function xh(){return this.on("end.remove",wh(this._id))}function Sh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Go(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var l=o[s],d=l.length,c=i[s]=new Array(d),u,f,h=0;h<d;++h)(u=l[h])&&(f=e.call(u,u.__data__,h,l))&&("__data__"in u&&(f.__data__=u.__data__),c[h]=f,io(c[h],t,n,h,c,Ve(u,n)));return new ot(i,this._parents,t,n)}function _h(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ji(e));for(var o=this._groups,r=o.length,i=[],s=[],l=0;l<r;++l)for(var d=o[l],c=d.length,u,f=0;f<c;++f)if(u=d[f]){for(var h=e.call(u,u.__data__,f,d),g,p=Ve(u,n),b=0,v=h.length;b<v;++b)(g=h[b])&&io(g,t,n,b,h,p);i.push(h),s.push(u)}return new ot(i,s,t,n)}var Eh=cn.prototype.constructor;function Ch(){return new Eh(this._groups,this._parents)}function Nh(e,t){var n,o,r;return function(){var i=zt(this,e),s=(this.style.removeProperty(e),zt(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ds(e){return function(){this.style.removeProperty(e)}}function kh(e,t,n){var o,r=n+"",i;return function(){var s=zt(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Ih(e,t,n){var o,r,i;return function(){var s=zt(this,e),l=n(this),d=l+"";return l==null&&(d=l=(this.style.removeProperty(e),zt(this,e))),s===d?null:s===o&&d===r?i:(r=d,i=t(o=s,l))}}function Mh(e,t){var n,o,r,i="style."+t,s="end."+i,l;return function(){var d=Re(this,e),c=d.on,u=d.value[i]==null?l||(l=Ds(t)):void 0;(c!==n||r!==u)&&(o=(n=c).copy()).on(s,r=u),d.on=o}}function Ph(e,t,n){var o=(e+="")=="transform"?Df:Ps;return t==null?this.styleTween(e,Nh(e,o)).on("end.style."+e,Ds(e)):typeof t=="function"?this.styleTween(e,Ih(e,o,dr(this,"style."+e,t))).each(Mh(this._id,e)):this.styleTween(e,kh(e,o,t),n).on("end.style."+e,null)}function Dh(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Th(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Dh(e,s,n)),o}return i._value=t,i}function Oh(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Th(e,t,n??""))}function Ah(e){return function(){this.textContent=e}}function $h(e){return function(){var t=e(this);this.textContent=t??""}}function Lh(e){return this.tween("text",typeof e=="function"?$h(dr(this,"text",e)):Ah(e==null?"":e+""))}function zh(e){return function(t){this.textContent=e.call(this,t)}}function Fh(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&zh(r)),t}return o._value=e,o}function Bh(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Fh(e))}function Hh(){for(var e=this._name,t=this._id,n=Ts(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],l=s.length,d,c=0;c<l;++c)if(d=s[c]){var u=Ve(d,t);io(d,e,n,c,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new ot(o,this._parents,e,n)}function Yh(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var l={value:s},d={value:function(){--r===0&&i()}};n.each(function(){var c=Re(this,o),u=c.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(d)),c.on=t}),r===0&&i()})}var Xh=0;function ot(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Ts(){return++Xh}var rt=cn.prototype;ot.prototype={constructor:ot,select:Sh,selectAll:_h,selectChild:rt.selectChild,selectChildren:rt.selectChildren,filter:gh,merge:mh,selection:Ch,transition:Hh,call:rt.call,nodes:rt.nodes,node:rt.node,size:rt.size,empty:rt.empty,each:rt.each,on:vh,attr:Rf,attrTween:rh,style:Ph,styleTween:Oh,text:Lh,textTween:Bh,remove:xh,tween:jf,delay:ah,duration:dh,ease:fh,easeVarying:ph,end:Yh,[Symbol.iterator]:rt[Symbol.iterator]};function Vh(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Wh={time:null,delay:0,duration:250,ease:Vh};function qh(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function jh(e){var t,n;e instanceof ot?(t=e._id,e=e._name):(t=Ts(),(n=Wh).time=ir(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],l=s.length,d,c=0;c<l;++c)(d=s[c])&&io(d,e,t,c,s,n||qh(d,t));return new ot(o,this._parents,e,t)}cn.prototype.interrupt=Vf,cn.prototype.transition=jh;const ao=e=>()=>e;function Uh(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function it(e,t,n){this.k=e,this.x=t,this.y=n}it.prototype={constructor:it,scale:function(e){return e===1?this:new it(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new it(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var lo=new it(1,0,0);Os.prototype=it.prototype;function Os(e){for(;!e.__zoom;)if(!(e=e.parentNode))return lo;return e.__zoom}function ur(e){e.stopImmediatePropagation()}function vn(e){e.preventDefault(),e.stopImmediatePropagation()}function Gh(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Kh(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function As(){return this.__zoom||lo}function Zh(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Jh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qh(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function $s(){var e=Gh,t=Kh,n=Qh,o=Zh,r=Jh,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],l=250,d=Qn,c=Yn("start","zoom","end"),u,f,h,g=500,p=150,b=0,v=10;function w(C){C.property("__zoom",As).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",q).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(C,S,N,k){var I=C.selection?C.selection():C;I.property("__zoom",As),C!==I?D(C,S,N,k):I.interrupt().each(function(){M(this,arguments).event(k).start().zoom(null,typeof S=="function"?S.apply(this,arguments):S).end()})},w.scaleBy=function(C,S,N,k){w.scaleTo(C,function(){var I=this.__zoom.k,O=typeof S=="function"?S.apply(this,arguments):S;return I*O},N,k)},w.scaleTo=function(C,S,N,k){w.transform(C,function(){var I=t.apply(this,arguments),O=this.__zoom,Y=N==null?x(I):typeof N=="function"?N.apply(this,arguments):N,F=O.invert(Y),X=typeof S=="function"?S.apply(this,arguments):S;return n(y(_(O,X),Y,F),I,s)},N,k)},w.translateBy=function(C,S,N,k){w.transform(C,function(){return n(this.__zoom.translate(typeof S=="function"?S.apply(this,arguments):S,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),s)},null,k)},w.translateTo=function(C,S,N,k,I){w.transform(C,function(){var O=t.apply(this,arguments),Y=this.__zoom,F=k==null?x(O):typeof k=="function"?k.apply(this,arguments):k;return n(lo.translate(F[0],F[1]).scale(Y.k).translate(typeof S=="function"?-S.apply(this,arguments):-S,typeof N=="function"?-N.apply(this,arguments):-N),O,s)},k,I)};function _(C,S){return S=Math.max(i[0],Math.min(i[1],S)),S===C.k?C:new it(S,C.x,C.y)}function y(C,S,N){var k=S[0]-N[0]*C.k,I=S[1]-N[1]*C.k;return k===C.x&&I===C.y?C:new it(C.k,k,I)}function x(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function D(C,S,N,k){C.on("start.zoom",function(){M(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(k).end()}).tween("zoom",function(){var I=this,O=arguments,Y=M(I,O).event(k),F=t.apply(I,O),X=N==null?x(F):typeof N=="function"?N.apply(I,O):N,G=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),Z=I.__zoom,U=typeof S=="function"?S.apply(I,O):S,te=d(Z.invert(X).concat(G/Z.k),U.invert(X).concat(G/U.k));return function(re){if(re===1)re=U;else{var $=te(re),L=G/$[2];re=new it(L,X[0]-$[0]*L,X[1]-$[1]*L)}Y.zoom(null,re)}})}function M(C,S,N){return!N&&C.__zooming||new P(C,S)}function P(C,S){this.that=C,this.args=S,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,S),this.taps=0}P.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,S){return this.mouse&&C!=="mouse"&&(this.mouse[1]=S.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=S.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=S.invert(this.touch1[0])),this.that.__zoom=S,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var S=Oe(this.that).datum();c.call(C,this.that,new Uh(C,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:c}),S)}};function T(C,...S){if(!e.apply(this,arguments))return;var N=M(this,S).event(C),k=this.__zoom,I=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,o.apply(this,arguments)))),O=Ye(C);if(N.wheel)(N.mouse[0][0]!==O[0]||N.mouse[0][1]!==O[1])&&(N.mouse[1]=k.invert(N.mouse[0]=O)),clearTimeout(N.wheel);else{if(k.k===I)return;N.mouse=[O,k.invert(O)],so(this),N.start()}vn(C),N.wheel=setTimeout(Y,p),N.zoom("mouse",n(y(_(k,I),N.mouse[0],N.mouse[1]),N.extent,s));function Y(){N.wheel=null,N.end()}}function z(C,...S){if(h||!e.apply(this,arguments))return;var N=C.currentTarget,k=M(this,S,!0).event(C),I=Oe(C.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",G,!0),O=Ye(C,N),Y=C.clientX,F=C.clientY;os(C.view),ur(C),k.mouse=[O,this.__zoom.invert(O)],so(this),k.start();function X(Z){if(vn(Z),!k.moved){var U=Z.clientX-Y,te=Z.clientY-F;k.moved=U*U+te*te>b}k.event(Z).zoom("mouse",n(y(k.that.__zoom,k.mouse[0]=Ye(Z,N),k.mouse[1]),k.extent,s))}function G(Z){I.on("mousemove.zoom mouseup.zoom",null),rs(Z.view,k.moved),vn(Z),k.event(Z).end()}}function q(C,...S){if(e.apply(this,arguments)){var N=this.__zoom,k=Ye(C.changedTouches?C.changedTouches[0]:C,this),I=N.invert(k),O=N.k*(C.shiftKey?.5:2),Y=n(y(_(N,O),k,I),t.apply(this,S),s);vn(C),l>0?Oe(this).transition().duration(l).call(D,Y,k,C):Oe(this).call(w.transform,Y,k,C)}}function A(C,...S){if(e.apply(this,arguments)){var N=C.touches,k=N.length,I=M(this,S,C.changedTouches.length===k).event(C),O,Y,F,X;for(ur(C),Y=0;Y<k;++Y)F=N[Y],X=Ye(F,this),X=[X,this.__zoom.invert(X),F.identifier],I.touch0?!I.touch1&&I.touch0[2]!==X[2]&&(I.touch1=X,I.taps=0):(I.touch0=X,O=!0,I.taps=1+!!u);u&&(u=clearTimeout(u)),O&&(I.taps<2&&(f=X[0],u=setTimeout(function(){u=null},g)),so(this),I.start())}}function H(C,...S){if(this.__zooming){var N=M(this,S).event(C),k=C.changedTouches,I=k.length,O,Y,F,X;for(vn(C),O=0;O<I;++O)Y=k[O],F=Ye(Y,this),N.touch0&&N.touch0[2]===Y.identifier?N.touch0[0]=F:N.touch1&&N.touch1[2]===Y.identifier&&(N.touch1[0]=F);if(Y=N.that.__zoom,N.touch1){var G=N.touch0[0],Z=N.touch0[1],U=N.touch1[0],te=N.touch1[1],re=(re=U[0]-G[0])*re+(re=U[1]-G[1])*re,$=($=te[0]-Z[0])*$+($=te[1]-Z[1])*$;Y=_(Y,Math.sqrt(re/$)),F=[(G[0]+U[0])/2,(G[1]+U[1])/2],X=[(Z[0]+te[0])/2,(Z[1]+te[1])/2]}else if(N.touch0)F=N.touch0[0],X=N.touch0[1];else return;N.zoom("touch",n(y(Y,F,X),N.extent,s))}}function j(C,...S){if(this.__zooming){var N=M(this,S).event(C),k=C.changedTouches,I=k.length,O,Y;for(ur(C),h&&clearTimeout(h),h=setTimeout(function(){h=null},g),O=0;O<I;++O)Y=k[O],N.touch0&&N.touch0[2]===Y.identifier?delete N.touch0:N.touch1&&N.touch1[2]===Y.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(Y=Ye(Y,this),Math.hypot(f[0]-Y[0],f[1]-Y[1])<v)){var F=Oe(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return w.wheelDelta=function(C){return arguments.length?(o=typeof C=="function"?C:ao(+C),w):o},w.filter=function(C){return arguments.length?(e=typeof C=="function"?C:ao(!!C),w):e},w.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:ao(!!C),w):r},w.extent=function(C){return arguments.length?(t=typeof C=="function"?C:ao([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),w):t},w.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],w):[i[0],i[1]]},w.translateExtent=function(C){return arguments.length?(s[0][0]=+C[0][0],s[1][0]=+C[1][0],s[0][1]=+C[0][1],s[1][1]=+C[1][1],w):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},w.constrain=function(C){return arguments.length?(n=C,w):n},w.duration=function(C){return arguments.length?(l=+C,w):l},w.interpolate=function(C){return arguments.length?(d=C,w):d},w.on=function(){var C=c.on.apply(c,arguments);return C===c?w:C},w.clickDistance=function(C){return arguments.length?(b=(C=+C)*C,w):Math.sqrt(b)},w.tapDistance=function(C){return arguments.length?(v=+C,w):v},w}const Ae={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wn=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ls=["Enter"," ","Escape"],zs={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Yt;(function(e){e.Strict="strict",e.Loose="loose"})(Yt||(Yt={}));var It;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(It||(It={}));var xn;(function(e){e.Partial="partial",e.Full="full"})(xn||(xn={}));const Fs={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var dt;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(dt||(dt={}));var co;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(co||(co={}));var ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ae||(ae={}));const Bs={[ae.Left]:ae.Right,[ae.Right]:ae.Left,[ae.Top]:ae.Bottom,[ae.Bottom]:ae.Top};function Hs(e){return e===null?null:e?"valid":"invalid"}const Ys=e=>"id"in e&&"source"in e&&"target"in e,Rh=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),fr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Sn=(e,t=[0,0])=>{const{width:n,height:o}=st(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},ep=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):fr(r)?r:t.nodeLookup.get(r.id));const l=s?ho(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return uo(o,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fo(n)},_n=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=uo(n,ho(r)),o=!0)}),o?fo(n):{x:0,y:0,width:0,height:0}},hr=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const l={...Nn(t,[n,o,r]),width:t.width/r,height:t.height/r},d=[];for(const c of e.values()){const{measured:u,selectable:f=!0,hidden:h=!1}=c;if(s&&!f||h)continue;const g=u.width??c.width??c.initialWidth??null,p=u.height??c.height??c.initialHeight??null,b=En(l,Vt(c)),v=(g??0)*(p??0),w=i&&b>0;(!c.internals.handleBounds||w||b>=v||c.dragging)&&d.push(c)}return d},tp=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function np(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function op({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const l=np(e,s),d=_n(l),c=gr(d,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function Xs({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),l=s.parentId?n.get(s.parentId):void 0,{x:d,y:c}=l?l.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!l)i?.("005",Ae.error005());else{const g=l.measured.width,p=l.measured.height;g&&p&&(f=[[d,c],[d+g,c+p]])}else l&&qt(s.extent)&&(f=[[s.extent[0][0]+d,s.extent[0][1]+c],[s.extent[1][0]+d,s.extent[1][1]+c]]);const h=qt(f)?Mt(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",Ae.error015()),{position:{x:h.x-d+(s.measured.width??0)*u[0],y:h.y-c+(s.measured.height??0)*u[1]},positionAbsolute:h}}async function rp({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(h=>h.id)),s=[];for(const h of n){if(h.deletable===!1)continue;const g=i.has(h.id),p=!g&&h.parentId&&s.find(b=>b.id===h.parentId);(g||p)&&s.push(h)}const l=new Set(t.map(h=>h.id)),d=o.filter(h=>h.deletable!==!1),u=tp(s,d);for(const h of d)l.has(h.id)&&!u.find(p=>p.id===h.id)&&u.push(h);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const Xt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Mt=(e={x:0,y:0},t,n)=>({x:Xt(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Xt(e.y,t[0][1],t[1][1]-(n?.height??0))});function Vs(e,t,n){const{width:o,height:r}=st(n),{x:i,y:s}=n.internals.positionAbsolute;return Mt(e,[[i,s],[i+o,s+r]],t)}const Ws=(e,t,n)=>e<t?Xt(Math.abs(e-t),1,t)/t:e>n?-Xt(Math.abs(e-n),1,t)/t:0,qs=(e,t,n=15,o=40)=>{const r=Ws(e.x,o,t.width-o)*n,i=Ws(e.y,o,t.height-o)*n;return[r,i]},uo=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),pr=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),fo=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Vt=(e,t=[0,0])=>{const{x:n,y:o}=fr(e)?e.internals.positionAbsolute:Sn(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ho=(e,t=[0,0])=>{const{x:n,y:o}=fr(e)?e.internals.positionAbsolute:Sn(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},js=(e,t)=>fo(uo(pr(e),pr(t))),En=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Us=e=>We(e.width)&&We(e.height)&&We(e.x)&&We(e.y),We=e=>!isNaN(e)&&isFinite(e),Gs=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Cn=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Nn=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const l={x:(e-n)/r,y:(t-o)/r};return i?Cn(l,s):l},po=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Wt(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function ip(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Wt(e,n),r=Wt(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Wt(e.top??e.y??0,n),r=Wt(e.bottom??e.y??0,n),i=Wt(e.left??e.x??0,t),s=Wt(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function sp(e,t,n,o,r,i){const{x:s,y:l}=po(e,[t,n,o]),{x:d,y:c}=po({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-d,f=i-c;return{left:Math.floor(s),top:Math.floor(l),right:Math.floor(u),bottom:Math.floor(f)}}const gr=(e,t,n,o,r,i)=>{const s=ip(i,t,n),l=(t-s.x)/e.width,d=(n-s.y)/e.height,c=Math.min(l,d),u=Xt(c,o,r),f=e.x+e.width/2,h=e.y+e.height/2,g=t/2-f*u,p=n/2-h*u,b=sp(e,g,p,u,t,n),v={left:Math.min(b.left-s.left,0),top:Math.min(b.top-s.top,0),right:Math.min(b.right-s.right,0),bottom:Math.min(b.bottom-s.bottom,0)};return{x:g-v.left+v.right,y:p-v.top+v.bottom,zoom:u}},kn=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function qt(e){return e!=null&&e!=="parent"}function st(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ks(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Zs(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const l=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function Js(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ap(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function lp(e){return{...zs,...e||{}}}function In(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=qe(e),l=Nn({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:d,y:c}=n?Cn(l,t):l;return{xSnapped:d,ySnapped:c,...l}}const mr=e=>({width:e.offsetWidth,height:e.offsetHeight}),Qs=e=>e?.getRootNode?.()||window?.document,cp=["INPUT","SELECT","TEXTAREA"];function Rs(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:cp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ea=e=>"clientX"in e,qe=(e,t)=>{const n=ea(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},ta=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const l=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(l.left-n.left)/o,y:(l.top-n.top)/o,...mr(s)}})};function na({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:l}){const d=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+l*.375+o*.125,u=Math.abs(d-e),f=Math.abs(c-t);return[d,c,u,f]}function go(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function oa({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case ae.Left:return[t-go(t-o,i),n];case ae.Right:return[t+go(o-t,i),n];case ae.Top:return[t,n-go(n-r,i)];case ae.Bottom:return[t,n+go(r-n,i)]}}function ra({sourceX:e,sourceY:t,sourcePosition:n=ae.Bottom,targetX:o,targetY:r,targetPosition:i=ae.Top,curvature:s=.25}){const[l,d]=oa({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,u]=oa({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,h,g,p]=na({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:l,sourceControlY:d,targetControlX:c,targetControlY:u});return[`M${e},${t} C${l},${d} ${c},${u} ${o},${r}`,f,h,g,p]}function ia({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,l=o<t?o+s:o-s;return[i,l,r,s]}function dp({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,l=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+l}function up({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=uo(ho(e),ho(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return En(s,fo(i))>0}const fp=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,hp=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),sa=(e,t,n={})=>{if(!e.source||!e.target)return Gs("006",Ae.error006()),t;const o=n.getEdgeId||fp;let r;return Ys(e)?r={...e}:r={...e,id:o(e)},hp(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function aa({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,l]=ia({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,l]}const la={[ae.Left]:{x:-1,y:0},[ae.Right]:{x:1,y:0},[ae.Top]:{x:0,y:-1},[ae.Bottom]:{x:0,y:1}},pp=({source:e,sourcePosition:t=ae.Bottom,target:n})=>t===ae.Left||t===ae.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},ca=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function gp({source:e,sourcePosition:t=ae.Bottom,target:n,targetPosition:o=ae.Top,center:r,offset:i,stepPosition:s}){const l=la[t],d=la[o],c={x:e.x+l.x*i,y:e.y+l.y*i},u={x:n.x+d.x*i,y:n.y+d.y*i},f=pp({source:c,sourcePosition:t,target:u}),h=f.x!==0?"x":"y",g=f[h];let p=[],b,v;const w={x:0,y:0},_={x:0,y:0},[,,y,x]=ia({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[h]*d[h]===-1){h==="x"?(b=r.x??c.x+(u.x-c.x)*s,v=r.y??(c.y+u.y)/2):(b=r.x??(c.x+u.x)/2,v=r.y??c.y+(u.y-c.y)*s);const T=[{x:b,y:c.y},{x:b,y:u.y}],z=[{x:c.x,y:v},{x:u.x,y:v}];l[h]===g?p=h==="x"?T:z:p=h==="x"?z:T}else{const T=[{x:c.x,y:u.y}],z=[{x:u.x,y:c.y}];if(h==="x"?p=l.x===g?z:T:p=l.y===g?T:z,t===o){const C=Math.abs(e[h]-n[h]);if(C<=i){const S=Math.min(i-1,i-C);l[h]===g?w[h]=(c[h]>e[h]?-1:1)*S:_[h]=(u[h]>n[h]?-1:1)*S}}if(t!==o){const C=h==="x"?"y":"x",S=l[h]===d[C],N=c[C]>u[C],k=c[C]<u[C];(l[h]===1&&(!S&&N||S&&k)||l[h]!==1&&(!S&&k||S&&N))&&(p=h==="x"?T:z)}const q={x:c.x+w.x,y:c.y+w.y},A={x:u.x+_.x,y:u.y+_.y},H=Math.max(Math.abs(q.x-p[0].x),Math.abs(A.x-p[0].x)),j=Math.max(Math.abs(q.y-p[0].y),Math.abs(A.y-p[0].y));H>=j?(b=(q.x+A.x)/2,v=p[0].y):(b=p[0].x,v=(q.y+A.y)/2)}const D={x:c.x+w.x,y:c.y+w.y},M={x:u.x+_.x,y:u.y+_.y};return[[e,...D.x!==p[0].x||D.y!==p[0].y?[D]:[],...p,...M.x!==p[p.length-1].x||M.y!==p[p.length-1].y?[M]:[],n],b,v,y,x]}function mp(e,t,n,o){const r=Math.min(ca(e,t)/2,ca(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const c=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*u}`}const l=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${i},${s+r*d}Q ${i},${s} ${i+r*l},${s}`}function yr({sourceX:e,sourceY:t,sourcePosition:n=ae.Bottom,targetX:o,targetY:r,targetPosition:i=ae.Top,borderRadius:s=5,centerX:l,centerY:d,offset:c=20,stepPosition:u=.5}){const[f,h,g,p,b]=gp({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:l,y:d},offset:c,stepPosition:u});let v=`M${f[0].x} ${f[0].y}`;for(let w=1;w<f.length-1;w++)v+=mp(f[w-1],f[w],f[w+1],s);return v+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[v,h,g,p,b]}function da(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function yp(e){const{sourceNode:t,targetNode:n}=e;if(!da(t)||!da(n))return null;const o=t.internals.handleBounds||ua(t.handles),r=n.internals.handleBounds||ua(n.handles),i=fa(o?.source??[],e.sourceHandle),s=fa(e.connectionMode===Yt.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",Ae.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=i?.position||ae.Bottom,d=s?.position||ae.Top,c=Pt(t,i,l),u=Pt(n,s,d);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y,sourcePosition:l,targetPosition:d}}function ua(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function Pt(e,t,n=ae.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:l}=t??st(e);if(o)return{x:r+s/2,y:i+l/2};switch(t?.position??n){case ae.Top:return{x:r+s/2,y:i};case ae.Right:return{x:r+s,y:i+l/2};case ae.Bottom:return{x:r+s/2,y:i+l};case ae.Left:return{x:r,y:i+l/2}}}function fa(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function br(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function bp(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,l)=>([l.markerStart||o,l.markerEnd||r].forEach(d=>{if(d&&typeof d=="object"){const c=br(d,t);i.has(c)||(s.push({id:c,color:d.color||n,...d}),i.add(c))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))}const ha=1e3,vp=10,vr={nodeOrigin:[0,0],nodeExtent:wn,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},wp={...vr,checkEquality:!0};function wr(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function xp(e,t,n){const o=wr(vr,n);for(const r of e.values())if(r.parentId)_r(r,e,t,o);else{const i=Sn(r,o.nodeOrigin),s=qt(r.extent)?r.extent:o.nodeExtent,l=Mt(i,s,st(r));r.internals.positionAbsolute=l}}function Sp(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xr(e){return e==="manual"}function Sr(e,t,n,o={}){const r=wr(wp,o),i={i:0},s=new Map(t),l=r?.elevateNodesOnSelect&&!xr(r.zIndexMode)?ha:0;let d=e.length>0,c=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const h=Sn(u,r.nodeOrigin),g=qt(u.extent)?u.extent:r.nodeExtent,p=Mt(h,g,st(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:p,handleBounds:Sp(u,f),z:pa(u,l,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(d=!1),u.parentId&&_r(f,t,n,o,i),c||=u.selected??!1}return{nodesInitialized:d,hasSelectedNodes:c}}function _p(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function _r(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:l,zIndexMode:d}=wr(vr,o),c=e.parentId,u=t.get(c);if(!u){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}_p(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&d==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*vp),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xr(d)?ha:0,{x:h,y:g,z:p}=Ep(e,u,s,l,f,d),{positionAbsolute:b}=e.internals,v=h!==b.x||g!==b.y;(v||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:h,y:g}:b,z:p}})}function pa(e,t,n){const o=We(e.zIndex)?e.zIndex:0;return xr(n)?o:o+(e.selected?t:0)}function Ep(e,t,n,o,r,i){const{x:s,y:l}=t.internals.positionAbsolute,d=st(e),c=Sn(e,n),u=qt(e.extent)?Mt(c,e.extent,d):c;let f=Mt({x:s+u.x,y:l+u.y},o,d);e.extent==="parent"&&(f=Vs(f,d,t));const h=pa(e,r,i),g=t.internals.z??0;return{x:f.x,y:f.y,z:g>=h?g+1:h}}function Er(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const l=t.get(s.parentId);if(!l)continue;const d=i.get(s.parentId)?.expandedRect??Vt(l),c=js(d,s.rect);i.set(s.parentId,{expandedRect:c,parent:l})}return i.size>0&&i.forEach(({expandedRect:s,parent:l},d)=>{const c=l.internals.positionAbsolute,u=st(l),f=l.origin??o,h=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,g=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,p=Math.max(u.width,Math.round(s.width)),b=Math.max(u.height,Math.round(s.height)),v=(p-u.width)*f[0],w=(b-u.height)*f[1];(h>0||g>0||v||w)&&(r.push({id:d,type:"position",position:{x:l.position.x-h+v,y:l.position.y-g+w}}),n.get(d)?.forEach(_=>{e.some(y=>y.id===_.id)||r.push({id:_.id,type:"position",position:{x:_.position.x+h,y:_.position.y+g}})})),(u.width<s.width||u.height<s.height||h||g)&&r.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:p+(h?f[0]*h-v:0),height:b+(g?f[1]*g-w:0)}})}),r}function Cp(e,t,n,o,r,i,s){const l=o?.querySelector(".xyflow__viewport");let d=!1;if(!l)return{changes:[],updatedInternals:d};const c=[],u=window.getComputedStyle(l),{m22:f}=new window.DOMMatrixReadOnly(u.transform),h=[];for(const g of e.values()){const p=t.get(g.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),d=!0;continue}const b=mr(g.nodeElement),v=p.measured.width!==b.width||p.measured.height!==b.height;if(!!(b.width&&b.height&&(v||!p.internals.handleBounds||g.force))){const _=g.nodeElement.getBoundingClientRect(),y=qt(p.extent)?p.extent:i;let{positionAbsolute:x}=p.internals;p.parentId&&p.extent==="parent"?x=Vs(x,b,t.get(p.parentId)):y&&(x=Mt(x,y,b));const D={...p,measured:b,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:ta("source",g.nodeElement,_,f,p.id),target:ta("target",g.nodeElement,_,f,p.id)}}};t.set(p.id,D),p.parentId&&_r(D,t,n,{nodeOrigin:r,zIndexMode:s}),d=!0,v&&(c.push({id:p.id,type:"dimensions",dimensions:b}),p.expandParent&&p.parentId&&h.push({id:p.id,parentId:p.parentId,rect:Vt(D,r)}))}}if(h.length>0){const g=Er(h,t,n,r);c.push(...g)}return{changes:c,updatedInternals:d}}async function Np({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),l=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(l)}function ga(e,t,n,o,r,i){let s=r;const l=o.get(s)||new Map;o.set(s,l.set(n,t)),s=`${r}-${e}`;const d=o.get(s)||new Map;if(o.set(s,d.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function ma(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:l=null}=o,d={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:l},c=`${r}-${s}--${i}-${l}`,u=`${i}-${l}--${r}-${s}`;ga("source",d,u,e,r,s),ga("target",d,c,e,i,l),t.set(o.id,o)}}function ya(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:ya(n,t):!1}function ba(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function kp(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!ya(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const l=e.get(i);l&&r.set(i,{id:i,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return r}function Cr({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,l]of t){const d=n.get(s)?.internals.userNode;d&&r.push({...d,position:l.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function Ip({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=Cn(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Mp({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,l=new Map,d=!1,c={x:0,y:0},u=null,f=!1,h=null,g=!1,p=!1,b=null;function v({noDragClassName:_,handleSelector:y,domNode:x,isSelectable:D,nodeId:M,nodeClickDistance:P=0}){h=Oe(x);function T({x:H,y:j}){const{nodeLookup:C,nodeExtent:S,snapGrid:N,snapToGrid:k,nodeOrigin:I,onNodeDrag:O,onSelectionDrag:Y,onError:F,updateNodePositions:X}=t();i={x:H,y:j};let G=!1;const Z=l.size>1,U=Z&&S?pr(_n(l)):null,te=Z&&k?Ip({dragItems:l,snapGrid:N,x:H,y:j}):null;for(const[re,$]of l){if(!C.has(re))continue;let L={x:H-$.distance.x,y:j-$.distance.y};k&&(L=te?{x:Math.round(L.x+te.x),y:Math.round(L.y+te.y)}:Cn(L,N));let V=null;if(Z&&S&&!$.extent&&U){const{positionAbsolute:R}=$.internals,ee=R.x-U.x+S[0][0],le=R.x+$.measured.width-U.x2+S[1][0],ne=R.y-U.y+S[0][1],de=R.y+$.measured.height-U.y2+S[1][1];V=[[ee,ne],[le,de]]}const{position:K,positionAbsolute:W}=Xs({nodeId:re,nextPosition:L,nodeLookup:C,nodeExtent:V||S,nodeOrigin:I,onError:F});G=G||$.position.x!==K.x||$.position.y!==K.y,$.position=K,$.internals.positionAbsolute=W}if(p=p||G,!!G&&(X(l,!0),b&&(o||O||!M&&Y))){const[re,$]=Cr({nodeId:M,dragItems:l,nodeLookup:C});o?.(b,l,re,$),O?.(b,re,$),M||Y?.(b,$)}}async function z(){if(!u)return;const{transform:H,panBy:j,autoPanSpeed:C,autoPanOnNodeDrag:S}=t();if(!S){d=!1,cancelAnimationFrame(s);return}const[N,k]=qs(c,u,C);(N!==0||k!==0)&&(i.x=(i.x??0)-N/H[2],i.y=(i.y??0)-k/H[2],await j({x:N,y:k})&&T(i)),s=requestAnimationFrame(z)}function q(H){const{nodeLookup:j,multiSelectionActive:C,nodesDraggable:S,transform:N,snapGrid:k,snapToGrid:I,selectNodesOnDrag:O,onNodeDragStart:Y,onSelectionDragStart:F,unselectNodesAndEdges:X}=t();f=!0,(!O||!D)&&!C&&M&&(j.get(M)?.selected||X()),D&&O&&M&&e?.(M);const G=In(H.sourceEvent,{transform:N,snapGrid:k,snapToGrid:I,containerBounds:u});if(i=G,l=kp(j,S,G,M),l.size>0&&(n||Y||!M&&F)){const[Z,U]=Cr({nodeId:M,dragItems:l,nodeLookup:j});n?.(H.sourceEvent,l,Z,U),Y?.(H.sourceEvent,Z,U),M||F?.(H.sourceEvent,U)}}const A=is().clickDistance(P).on("start",H=>{const{domNode:j,nodeDragThreshold:C,transform:S,snapGrid:N,snapToGrid:k}=t();u=j?.getBoundingClientRect()||null,g=!1,p=!1,b=H.sourceEvent,C===0&&q(H),i=In(H.sourceEvent,{transform:S,snapGrid:N,snapToGrid:k,containerBounds:u}),c=qe(H.sourceEvent,u)}).on("drag",H=>{const{autoPanOnNodeDrag:j,transform:C,snapGrid:S,snapToGrid:N,nodeDragThreshold:k,nodeLookup:I}=t(),O=In(H.sourceEvent,{transform:C,snapGrid:S,snapToGrid:N,containerBounds:u});if(b=H.sourceEvent,(H.sourceEvent.type==="touchmove"&&H.sourceEvent.touches.length>1||M&&!I.has(M))&&(g=!0),!g){if(!d&&j&&f&&(d=!0,z()),!f){const Y=qe(H.sourceEvent,u),F=Y.x-c.x,X=Y.y-c.y;Math.sqrt(F*F+X*X)>k&&q(H)}(i.x!==O.xSnapped||i.y!==O.ySnapped)&&l&&f&&(c=qe(H.sourceEvent,u),T(O))}}).on("end",H=>{if(!(!f||g)&&(d=!1,f=!1,cancelAnimationFrame(s),l.size>0)){const{nodeLookup:j,updateNodePositions:C,onNodeDragStop:S,onSelectionDragStop:N}=t();if(p&&(C(l,!1),p=!1),r||S||!M&&N){const[k,I]=Cr({nodeId:M,dragItems:l,nodeLookup:j,dragging:!1});r?.(H.sourceEvent,l,k,I),S?.(H.sourceEvent,k,I),M||N?.(H.sourceEvent,I)}}}).filter(H=>{const j=H.target;return!H.button&&(!_||!ba(j,`.${_}`,x))&&(!y||ba(j,y,x))});h.call(A)}function w(){h?.on(".drag",null)}return{update:v,destroy:w}}function Pp(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())En(r,Vt(i))>0&&o.push(i);return o}const Dp=250;function Tp(e,t,n,o){let r=[],i=1/0;const s=Pp(e,n,t+Dp);for(const l of s){const d=[...l.internals.handleBounds?.source??[],...l.internals.handleBounds?.target??[]];for(const c of d){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:u,y:f}=Pt(l,c,c.position,!0),h=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));h>t||(h<i?(r=[{...c,x:u,y:f}],i=h):h===i&&r.push({...c,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const l=o.type==="source"?"target":"source";return r.find(d=>d.type===l)??r[0]}return r[0]}function va(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const l=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],d=(n?l?.find(c=>c.id===n):l?.[0])??null;return d&&i?{...d,...Pt(s,d,d.position,!0)}:d}function wa(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Op(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const xa=()=>!0;function Ap(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:l,nodeLookup:d,lib:c,autoPanOnConnect:u,flowId:f,panBy:h,cancelConnection:g,onConnectStart:p,onConnect:b,onConnectEnd:v,isValidConnection:w=xa,onReconnectEnd:_,updateConnection:y,getTransform:x,getFromHandle:D,autoPanSpeed:M,dragThreshold:P=1,handleDomNode:T}){const z=Qs(e.target);let q=0,A;const{x:H,y:j}=qe(e),C=wa(i,T),S=l?.getBoundingClientRect();let N=!1;if(!S||!C)return;const k=va(r,C,o,d,t);if(!k)return;let I=qe(e,S),O=!1,Y=null,F=!1,X=null;function G(){if(!u||!S)return;const[K,W]=qs(I,S,M);h({x:K,y:W}),q=requestAnimationFrame(G)}const Z={...k,nodeId:r,type:C,position:k.position},U=d.get(r);let re={inProgress:!0,isValid:null,from:Pt(U,Z,ae.Left,!0),fromHandle:Z,fromPosition:Z.position,fromNode:U,to:I,toHandle:null,toPosition:Bs[Z.position],toNode:null,pointer:I};function $(){N=!0,y(re),p?.(e,{nodeId:r,handleId:o,handleType:C})}P===0&&$();function L(K){if(!N){const{x:de,y:ue}=qe(K),ye=de-H,ke=ue-j;if(!(ye*ye+ke*ke>P*P))return;$()}if(!D()||!Z){V(K);return}const W=x();I=qe(K,S),A=Tp(Nn(I,W,!1,[1,1]),n,d,Z),O||(G(),O=!0);const R=Sa(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:w,doc:z,lib:c,flowId:f,nodeLookup:d});X=R.handleDomNode,Y=R.connection,F=Op(!!A,R.isValid);const ee=d.get(r),le=ee?Pt(ee,Z,ae.Left,!0):re.from,ne={...re,from:le,isValid:F,to:R.toHandle&&F?po({x:R.toHandle.x,y:R.toHandle.y},W):I,toHandle:R.toHandle,toPosition:F&&R.toHandle?R.toHandle.position:Bs[Z.position],toNode:R.toHandle?d.get(R.toHandle.nodeId):null,pointer:I};y(ne),re=ne}function V(K){if(!("touches"in K&&K.touches.length>0)){if(N){(A||X)&&Y&&F&&b?.(Y);const{inProgress:W,...R}=re,ee={...R,toPosition:re.toHandle?re.toPosition:null};v?.(K,ee),i&&_?.(K,ee)}g(),cancelAnimationFrame(q),O=!1,F=!1,Y=null,X=null,z.removeEventListener("mousemove",L),z.removeEventListener("mouseup",V),z.removeEventListener("touchmove",L),z.removeEventListener("touchend",V)}}z.addEventListener("mousemove",L),z.addEventListener("mouseup",V),z.addEventListener("touchmove",L),z.addEventListener("touchend",V)}function Sa(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:l,flowId:d,isValidConnection:c=xa,nodeLookup:u}){const f=i==="target",h=t?s.querySelector(`.${l}-flow__handle[data-id="${d}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:p}=qe(e),b=s.elementFromPoint(g,p),v=b?.classList.contains(`${l}-flow__handle`)?b:h,w={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const _=wa(void 0,v),y=v.getAttribute("data-nodeid"),x=v.getAttribute("data-handleid"),D=v.classList.contains("connectable"),M=v.classList.contains("connectableend");if(!y||!_)return w;const P={source:f?y:o,sourceHandle:f?x:r,target:f?o:y,targetHandle:f?r:x};w.connection=P;const z=D&&M&&(n===Yt.Strict?f&&_==="source"||!f&&_==="target":y!==o||x!==r);w.isValid=z&&c(P),w.toHandle=va(y,_,x,u,n,!0)}return w}const Nr={onPointerDown:Ap,isValid:Sa};function $p({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=Oe(e);function i({translateExtent:l,width:d,height:c,zoomStep:u=1,pannable:f=!0,zoomable:h=!0,inversePan:g=!1}){const p=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const x=n(),D=y.sourceEvent.ctrlKey&&kn()?10:1,M=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*u,P=x[2]*Math.pow(2,M*D);t.scaleTo(P)};let b=[0,0];const v=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(b=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},w=y=>{const x=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const D=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],M=[D[0]-b[0],D[1]-b[1]];b=D;const P=o()*Math.max(x[2],Math.log(x[2]))*(g?-1:1),T={x:x[0]-M[0]*P,y:x[1]-M[1]*P},z=[[0,0],[d,c]];t.setViewportConstrained({x:T.x,y:T.y,zoom:x[2]},z,l)},_=$s().on("start",v).on("zoom",f?w:null).on("zoom.wheel",h?p:null);r.call(_,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:Ye}}const mo=e=>({x:e.x,y:e.y,zoom:e.k}),kr=({x:e,y:t,zoom:n})=>lo.translate(e,t).scale(n),jt=(e,t)=>e.target.closest(`.${t}`),_a=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Lp=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ir=(e,t=0,n=Lp,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Ea=e=>{const t=e.ctrlKey&&kn()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function zp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:l,onPanZoom:d,onPanZoomEnd:c}){return u=>{if(jt(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const v=Ye(u),w=Ea(u),_=f*Math.pow(2,w);o.scaleTo(n,_,v,u);return}const h=u.deltaMode===1?20:1;let g=r===It.Vertical?0:u.deltaX*h,p=r===It.Horizontal?0:u.deltaY*h;!kn()&&u.shiftKey&&r!==It.Vertical&&(g=u.deltaY*h,p=0),o.translateBy(n,-(g/f)*i,-(p/f)*i,{internal:!0});const b=mo(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d?.(u,b),e.panScrollTimeout=setTimeout(()=>{c?.(u,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l?.(u,b))}}function Fp({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,l=jt(o,e);if(o.ctrlKey&&i&&l&&o.preventDefault(),s||l)return null;o.preventDefault(),n.call(this,o,r)}}function Bp({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=mo(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Hp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&_a(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,mo(i.transform))}}function Yp({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&_a(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const l=mo(s.transform);e.prevViewport=l,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,l)},n?150:0)}}}function Xp({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:l,noPanClassName:d,lib:c,connectionInProgress:u}){return f=>{const h=e||t,g=n&&f.ctrlKey,p=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(jt(f,`${c}-flow__node`)||jt(f,`${c}-flow__edge`)))return!0;if(!o&&!h&&!r&&!i&&!n||s||u&&!p||jt(f,l)&&p||jt(f,d)&&(!p||r&&p&&!e)||!n&&f.ctrlKey&&p)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!h&&!r&&!g&&p||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||p)&&b}}function Vp({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:l,onDraggingChange:d}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),f=$s().scaleExtent([t,n]).translateExtent(o),h=Oe(e).call(f);_({x:r.x,y:r.y,zoom:Xt(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const g=h.on("wheel.zoom"),p=h.on("dblclick.zoom");f.wheelDelta(Ea);function b(A,H){return h?new Promise(j=>{f?.interpolate(H?.interpolate==="linear"?pn:Qn).transform(Ir(h,H?.duration,H?.ease,()=>j(!0)),A)}):Promise.resolve(!1)}function v({noWheelClassName:A,noPanClassName:H,onPaneContextMenu:j,userSelectionActive:C,panOnScroll:S,panOnDrag:N,panOnScrollMode:k,panOnScrollSpeed:I,preventScrolling:O,zoomOnPinch:Y,zoomOnScroll:F,zoomOnDoubleClick:X,zoomActivationKeyPressed:G,lib:Z,onTransformChange:U,connectionInProgress:te,paneClickDistance:re,selectionOnDrag:$}){C&&!c.isZoomingOrPanning&&w();const L=S&&!G&&!C;f.clickDistance($?1/0:!We(re)||re<0?0:re);const V=L?zp({zoomPanValues:c,noWheelClassName:A,d3Selection:h,d3Zoom:f,panOnScrollMode:k,panOnScrollSpeed:I,zoomOnPinch:Y,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:l}):Fp({noWheelClassName:A,preventScrolling:O,d3ZoomHandler:g});if(h.on("wheel.zoom",V,{passive:!1}),!C){const W=Bp({zoomPanValues:c,onDraggingChange:d,onPanZoomStart:s});f.on("start",W);const R=Hp({zoomPanValues:c,panOnDrag:N,onPaneContextMenu:!!j,onPanZoom:i,onTransformChange:U});f.on("zoom",R);const ee=Yp({zoomPanValues:c,panOnDrag:N,panOnScroll:S,onPaneContextMenu:j,onPanZoomEnd:l,onDraggingChange:d});f.on("end",ee)}const K=Xp({zoomActivationKeyPressed:G,panOnDrag:N,zoomOnScroll:F,panOnScroll:S,zoomOnDoubleClick:X,zoomOnPinch:Y,userSelectionActive:C,noPanClassName:H,noWheelClassName:A,lib:Z,connectionInProgress:te});f.filter(K),X?h.on("dblclick.zoom",p):h.on("dblclick.zoom",null)}function w(){f.on("zoom",null)}async function _(A,H,j){const C=kr(A),S=f?.constrain()(C,H,j);return S&&await b(S),new Promise(N=>N(S))}async function y(A,H){const j=kr(A);return await b(j,H),new Promise(C=>C(j))}function x(A){if(h){const H=kr(A),j=h.property("__zoom");(j.k!==A.zoom||j.x!==A.x||j.y!==A.y)&&f?.transform(h,H,null,{sync:!0})}}function D(){const A=h?Os(h.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function M(A,H){return h?new Promise(j=>{f?.interpolate(H?.interpolate==="linear"?pn:Qn).scaleTo(Ir(h,H?.duration,H?.ease,()=>j(!0)),A)}):Promise.resolve(!1)}function P(A,H){return h?new Promise(j=>{f?.interpolate(H?.interpolate==="linear"?pn:Qn).scaleBy(Ir(h,H?.duration,H?.ease,()=>j(!0)),A)}):Promise.resolve(!1)}function T(A){f?.scaleExtent(A)}function z(A){f?.translateExtent(A)}function q(A){const H=!We(A)||A<0?0:A;f?.clickDistance(H)}return{update:v,destroy:w,setViewport:y,setViewportConstrained:_,getViewport:D,scaleTo:M,scaleBy:P,setScaleExtent:T,setTranslateExtent:z,syncViewport:x,setClickDistance:q}}var Ut;(function(e){e.Line="line",e.Handle="handle"})(Ut||(Ut={}));function Wp({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,l=n-o,d=[s>0?1:s<0?-1:0,l>0?1:l<0?-1:0];return s&&r&&(d[0]=d[0]*-1),l&&i&&(d[1]=d[1]*-1),d}function Ca(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function ut(e,t){return Math.max(0,t-e)}function ft(e,t){return Math.max(0,e-t)}function yo(e,t,n){return Math.max(0,t-e,e-n)}function Na(e,t){return e?!t:t}function qp(e,t,n,o,r,i,s,l){let{affectsX:d,affectsY:c}=t;const{isHorizontal:u,isVertical:f}=t,h=u&&f,{xSnapped:g,ySnapped:p}=n,{minWidth:b,maxWidth:v,minHeight:w,maxHeight:_}=o,{x:y,y:x,width:D,height:M,aspectRatio:P}=e;let T=Math.floor(u?g-e.pointerX:0),z=Math.floor(f?p-e.pointerY:0);const q=D+(d?-T:T),A=M+(c?-z:z),H=-i[0]*D,j=-i[1]*M;let C=yo(q,b,v),S=yo(A,w,_);if(s){let I=0,O=0;d&&T<0?I=ut(y+T+H,s[0][0]):!d&&T>0&&(I=ft(y+q+H,s[1][0])),c&&z<0?O=ut(x+z+j,s[0][1]):!c&&z>0&&(O=ft(x+A+j,s[1][1])),C=Math.max(C,I),S=Math.max(S,O)}if(l){let I=0,O=0;d&&T>0?I=ft(y+T,l[0][0]):!d&&T<0&&(I=ut(y+q,l[1][0])),c&&z>0?O=ft(x+z,l[0][1]):!c&&z<0&&(O=ut(x+A,l[1][1])),C=Math.max(C,I),S=Math.max(S,O)}if(r){if(u){const I=yo(q/P,w,_)*P;if(C=Math.max(C,I),s){let O=0;!d&&!c||d&&!c&&h?O=ft(x+j+q/P,s[1][1])*P:O=ut(x+j+(d?T:-T)/P,s[0][1])*P,C=Math.max(C,O)}if(l){let O=0;!d&&!c||d&&!c&&h?O=ut(x+q/P,l[1][1])*P:O=ft(x+(d?T:-T)/P,l[0][1])*P,C=Math.max(C,O)}}if(f){const I=yo(A*P,b,v)/P;if(S=Math.max(S,I),s){let O=0;!d&&!c||c&&!d&&h?O=ft(y+A*P+H,s[1][0])/P:O=ut(y+(c?z:-z)*P+H,s[0][0])/P,S=Math.max(S,O)}if(l){let O=0;!d&&!c||c&&!d&&h?O=ut(y+A*P,l[1][0])/P:O=ft(y+(c?z:-z)*P,l[0][0])/P,S=Math.max(S,O)}}}z=z+(z<0?S:-S),T=T+(T<0?C:-C),r&&(h?q>A*P?z=(Na(d,c)?-T:T)/P:T=(Na(d,c)?-z:z)*P:u?(z=T/P,c=d):(T=z*P,d=c));const N=d?y+T:y,k=c?x+z:x;return{width:D+(d?-T:T),height:M+(c?-z:z),x:i[0]*T*(d?-1:1)+N,y:i[1]*z*(c?-1:1)+k}}const ka={width:0,height:0,x:0,y:0},jp={...ka,pointerX:0,pointerY:0,aspectRatio:1};function Up(e){return[[0,0],[e.measured.width,e.measured.height]]}function Gp(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,l=n[0]*i,d=n[1]*s;return[[o-l,r-d],[o+i-l,r+s-d]]}function Kp({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=Oe(e);let s={controlDirection:Ca("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:c,boundaries:u,keepAspectRatio:f,resizeDirection:h,onResizeStart:g,onResize:p,onResizeEnd:b,shouldResize:v}){let w={...ka},_={...jp};s={boundaries:u,resizeDirection:h,keepAspectRatio:f,controlDirection:Ca(c)};let y,x=null,D=[],M,P,T,z=!1;const q=is().on("start",A=>{const{nodeLookup:H,transform:j,snapGrid:C,snapToGrid:S,nodeOrigin:N,paneDomNode:k}=n();if(y=H.get(t),!y)return;x=k?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:O}=In(A.sourceEvent,{transform:j,snapGrid:C,snapToGrid:S,containerBounds:x});w={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},_={...w,pointerX:I,pointerY:O,aspectRatio:w.width/w.height},M=void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(M=H.get(y.parentId),P=M&&y.extent==="parent"?Up(M):void 0),D=[],T=void 0;for(const[Y,F]of H)if(F.parentId===t&&(D.push({id:Y,position:{...F.position},extent:F.extent}),F.extent==="parent"||F.expandParent)){const X=Gp(F,y,F.origin??N);T?T=[[Math.min(X[0][0],T[0][0]),Math.min(X[0][1],T[0][1])],[Math.max(X[1][0],T[1][0]),Math.max(X[1][1],T[1][1])]]:T=X}g?.(A,{...w})}).on("drag",A=>{const{transform:H,snapGrid:j,snapToGrid:C,nodeOrigin:S}=n(),N=In(A.sourceEvent,{transform:H,snapGrid:j,snapToGrid:C,containerBounds:x}),k=[];if(!y)return;const{x:I,y:O,width:Y,height:F}=w,X={},G=y.origin??S,{width:Z,height:U,x:te,y:re}=qp(_,s.controlDirection,N,s.boundaries,s.keepAspectRatio,G,P,T),$=Z!==Y,L=U!==F,V=te!==I&&$,K=re!==O&&L;if(!V&&!K&&!$&&!L)return;if((V||K||G[0]===1||G[1]===1)&&(X.x=V?te:w.x,X.y=K?re:w.y,w.x=X.x,w.y=X.y,D.length>0)){const le=te-I,ne=re-O;for(const de of D)de.position={x:de.position.x-le+G[0]*(Z-Y),y:de.position.y-ne+G[1]*(U-F)},k.push(de)}if(($||L)&&(X.width=$&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Z:w.width,X.height=L&&(!s.resizeDirection||s.resizeDirection==="vertical")?U:w.height,w.width=X.width,w.height=X.height),M&&y.expandParent){const le=G[0]*(X.width??0);X.x&&X.x<le&&(w.x=le,_.x=_.x-(X.x-le));const ne=G[1]*(X.height??0);X.y&&X.y<ne&&(w.y=ne,_.y=_.y-(X.y-ne))}const W=Wp({width:w.width,prevWidth:Y,height:w.height,prevHeight:F,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),R={...w,direction:W};v?.(A,R)!==!1&&(z=!0,p?.(A,R),o(X,k))}).on("end",A=>{z&&(b?.(A,{...w}),r?.({...w}),z=!1)});i.call(q)}function d(){i.on(".drag",null)}return{update:l,destroy:d}}var bo={exports:{}},Mr={},vo={exports:{}},Pr={};var Ia;function Zp(){if(Ia)return Pr;Ia=1;var e=E;function t(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function l(f,h){var g=h(),p=o({inst:{value:g,getSnapshot:h}}),b=p[0].inst,v=p[1];return i(function(){b.value=g,b.getSnapshot=h,d(b)&&v({inst:b})},[f,g,h]),r(function(){return d(b)&&v({inst:b}),f(function(){d(b)&&v({inst:b})})},[f]),s(g),g}function d(f){var h=f.getSnapshot;f=f.value;try{var g=h();return!n(f,g)}catch{return!0}}function c(f,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return Pr.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Pr}var Dr={};var Ma;function Jp(){return Ma||(Ma=1,process.env.NODE_ENV!=="production"&&(function(){function e(g,p){return g===p&&(g!==0||1/g===1/p)||g!==g&&p!==p}function t(g,p){u||r.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var b=p();if(!f){var v=p();i(b,v)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}v=s({inst:{value:b,getSnapshot:p}});var w=v[0].inst,_=v[1];return d(function(){w.value=b,w.getSnapshot=p,n(w)&&_({inst:w})},[g,b,p]),l(function(){return n(w)&&_({inst:w}),g(function(){n(w)&&_({inst:w})})},[g]),c(b),b}function n(g){var p=g.getSnapshot;g=g.value;try{var b=p();return!i(g,b)}catch{return!0}}function o(g,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var r=E,i=typeof Object.is=="function"?Object.is:e,s=r.useState,l=r.useEffect,d=r.useLayoutEffect,c=r.useDebugValue,u=!1,f=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;Dr.useSyncExternalStore=r.useSyncExternalStore!==void 0?r.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Dr}var Pa;function Da(){return Pa||(Pa=1,process.env.NODE_ENV==="production"?vo.exports=Zp():vo.exports=Jp()),vo.exports}var Ta;function Qp(){if(Ta)return Mr;Ta=1;var e=E,t=Da();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,l=e.useMemo,d=e.useDebugValue;return Mr.useSyncExternalStoreWithSelector=function(c,u,f,h,g){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=l(function(){function w(M){if(!_){if(_=!0,y=M,M=h(M),g!==void 0&&b.hasValue){var P=b.value;if(g(P,M))return x=P}return x=M}if(P=x,o(y,M))return P;var T=h(M);return g!==void 0&&g(P,T)?(y=M,P):(y=M,x=T)}var _=!1,y,x,D=f===void 0?null:f;return[function(){return w(u())},D===null?void 0:function(){return w(D())}]},[u,f,h,g]);var v=r(c,p[0],p[1]);return s(function(){b.hasValue=!0,b.value=v},[v]),d(v),v},Mr}var Tr={};var Oa;function Rp(){return Oa||(Oa=1,process.env.NODE_ENV!=="production"&&(function(){function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=E,n=Da(),o=typeof Object.is=="function"?Object.is:e,r=n.useSyncExternalStore,i=t.useRef,s=t.useEffect,l=t.useMemo,d=t.useDebugValue;Tr.useSyncExternalStoreWithSelector=function(c,u,f,h,g){var p=i(null);if(p.current===null){var b={hasValue:!1,value:null};p.current=b}else b=p.current;p=l(function(){function w(M){if(!_){if(_=!0,y=M,M=h(M),g!==void 0&&b.hasValue){var P=b.value;if(g(P,M))return x=P}return x=M}if(P=x,o(y,M))return P;var T=h(M);return g!==void 0&&g(P,T)?(y=M,P):(y=M,x=T)}var _=!1,y,x,D=f===void 0?null:f;return[function(){return w(u())},D===null?void 0:function(){return w(D())}]},[u,f,h,g]);var v=r(c,p[0],p[1]);return s(function(){b.hasValue=!0,b.value=v},[v]),d(v),v},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Tr}var Aa;function eg(){return Aa||(Aa=1,process.env.NODE_ENV==="production"?bo.exports=Qp():bo.exports=Rp()),bo.exports}var tg=eg();const ng=Vr(tg),og={},$a=e=>{let t;const n=new Set,o=(u,f)=>{const h=typeof u=="function"?u(t):u;if(!Object.is(h,t)){const g=t;t=f??(typeof h!="object"||h===null)?h:Object.assign({},t,h),n.forEach(p=>p(t,g))}},r=()=>t,d={setState:o,getState:r,getInitialState:()=>c,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(og?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(o,r,d);return d},rg=e=>e?$a(e):$a,{useDebugValue:ig}=E,{useSyncExternalStoreWithSelector:sg}=ng,ag=e=>e;function La(e,t=ag,n){const o=sg(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ig(o),o}const za=(e,t)=>{const n=rg(e),o=(r,i=t)=>La(n,r,i);return Object.assign(o,n),o},lg=(e,t)=>e?za(e,t):za;function we(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const wo=E.createContext(null),cg=wo.Provider,Fa=Ae.error001();function pe(e,t){const n=E.useContext(wo);if(n===null)throw new Error(Fa);return La(n,e,t)}function xe(){const e=E.useContext(wo);if(e===null)throw new Error(Fa);return E.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Ba={display:"none"},dg={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ha="react-flow__node-desc",Ya="react-flow__edge-desc",ug="react-flow__aria-live",fg=e=>e.ariaLiveMessage,hg=e=>e.ariaLabelConfig;function pg({rfId:e}){const t=pe(fg);return a.jsx("div",{id:`${ug}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:dg,children:t})}function gg({rfId:e,disableKeyboardA11y:t}){const n=pe(hg);return a.jsxs(a.Fragment,{children:[a.jsx("div",{id:`${Ha}-${e}`,style:Ba,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),a.jsx("div",{id:`${Ya}-${e}`,style:Ba,children:n["edge.a11yDescription.default"]}),!t&&a.jsx(pg,{rfId:e})]})}const xo=E.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return a.jsx("div",{className:Ee(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});xo.displayName="Panel";function mg({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:a.jsx(xo,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:a.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const yg=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},So=e=>e.id;function bg(e,t){return we(e.selectedNodes.map(So),t.selectedNodes.map(So))&&we(e.selectedEdges.map(So),t.selectedEdges.map(So))}function vg({onSelectionChange:e}){const t=xe(),{selectedNodes:n,selectedEdges:o}=pe(yg,bg);return E.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const wg=e=>!!e.onSelectionChangeHandlers;function xg({onSelectionChange:e}){const t=pe(wg);return e||t?a.jsx(vg,{onSelectionChange:e}):null}const Or=typeof window<"u"?E.useLayoutEffect:E.useEffect,Xa=[0,0],Sg={x:0,y:0,zoom:1},Va=[...["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],"rfId"],_g=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),Wa={translateExtent:wn,nodeOrigin:Xa,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Eg(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:l,setDefaultNodesAndEdges:d}=pe(_g,we),c=xe();Or(()=>(d(e.defaultNodes,e.defaultEdges),()=>{u.current=Wa,l()}),[]);const u=E.useRef(Wa);return Or(()=>{for(const f of Va){const h=e[f],g=u.current[f];h!==g&&(typeof e[f]>"u"||(f==="nodes"?t(h):f==="edges"?n(h):f==="minZoom"?o(h):f==="maxZoom"?r(h):f==="translateExtent"?i(h):f==="nodeExtent"?s(h):f==="ariaLabelConfig"?c.setState({ariaLabelConfig:lp(h)}):f==="fitView"?c.setState({fitViewQueued:h}):f==="fitViewOptions"?c.setState({fitViewOptions:h}):c.setState({[f]:h})))}u.current=e},Va.map(f=>e[f])),null}function qa(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Cg(e){const[t,n]=E.useState(e==="system"?null:e);return E.useEffect(()=>{if(e!=="system"){n(e);return}const o=qa(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:qa()?.matches?"dark":"light"}const ja=typeof document<"u"?document:null;function Mn(e=null,t={target:ja,actInsideInputWithModifier:!0}){const[n,o]=E.useState(!1),r=E.useRef(!1),i=E.useRef(new Set([])),[s,l]=E.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
10
+ `).replace(`
11
+
12
+ `,`
13
+ +`).split(`
14
+ `)),u=c.reduce((f,h)=>f.concat(...h),[]);return[c,u]}return[[],[]]},[e]);return E.useEffect(()=>{const d=t?.target??ja,c=t?.actInsideInputWithModifier??!0;if(e!==null){const u=g=>{if(r.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!r.current||r.current&&!c)&&Rs(g))return!1;const b=Ga(g.code,l);if(i.current.add(g[b]),Ua(s,i.current,!1)){const v=g.composedPath?.()?.[0]||g.target,w=v?.nodeName==="BUTTON"||v?.nodeName==="A";t.preventDefault!==!1&&(r.current||!w)&&g.preventDefault(),o(!0)}},f=g=>{const p=Ga(g.code,l);Ua(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(g[p]),g.key==="Meta"&&i.current.clear(),r.current=!1},h=()=>{i.current.clear(),o(!1)};return d?.addEventListener("keydown",u),d?.addEventListener("keyup",f),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{d?.removeEventListener("keydown",u),d?.removeEventListener("keyup",f),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,o]),n}function Ua(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function Ga(e,t){return t.includes(e)?"code":"key"}const Ng=()=>{const e=xe();return E.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:l}=e.getState(),d=gr(t,o,r,i,s,n?.padding??.1);return l?(await l.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:l,y:d}=s.getBoundingClientRect(),c={x:t.x-l,y:t.y-d},u=n.snapGrid??r,f=n.snapToGrid??i;return Nn(c,o,f,u)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=po(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function Ka(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const l={...i};for(const d of s)kg(d,l);n.push(l)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function kg(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Za(e,t){return Ka(e,t)}function Ja(e,t){return Ka(e,t)}function Dt(e,t){return{id:e,type:"select",selected:t}}function Gt(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(Dt(i.id,s)))}return o}function Qa({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),l=s?.internals?.userNode??s;l!==void 0&&l!==i&&n.push({id:i.id,item:i,type:"replace"}),l===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function Ra(e){return{id:e.id,type:"remove"}}const el=e=>Rh(e),Ig=e=>Ys(e);function tl(e){return E.forwardRef(e)}function nl(e){const[t,n]=E.useState(BigInt(0)),[o]=E.useState(()=>Mg(()=>n(r=>r+BigInt(1))));return Or(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Mg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const ol=E.createContext(null);function Pg({children:e}){const t=xe(),n=E.useCallback(l=>{const{nodes:d=[],setNodes:c,hasDefaultNodes:u,onNodesChange:f,nodeLookup:h,fitViewQueued:g,onNodesChangeMiddlewareMap:p}=t.getState();let b=d;for(const w of l)b=typeof w=="function"?w(b):w;let v=Qa({items:b,lookup:h});for(const w of p.values())v=w(v);u&&c(b),v.length>0?f?.(v):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:w,nodes:_,setNodes:y}=t.getState();w&&y(_)})},[]),o=nl(n),r=E.useCallback(l=>{const{edges:d=[],setEdges:c,hasDefaultEdges:u,onEdgesChange:f,edgeLookup:h}=t.getState();let g=d;for(const p of l)g=typeof p=="function"?p(g):p;u?c(g):f&&f(Qa({items:g,lookup:h}))},[]),i=nl(r),s=E.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return a.jsx(ol.Provider,{value:s,children:e})}function Dg(){const e=E.useContext(ol);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Tg=e=>!!e.panZoom;function Ar(){const e=Ng(),t=xe(),n=Dg(),o=pe(Tg),r=E.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),s=f=>{n.nodeQueue.push(f)},l=f=>{n.edgeQueue.push(f)},d=f=>{const{nodeLookup:h,nodeOrigin:g}=t.getState(),p=el(f)?f:h.get(f.id),b=p.parentId?Zs(p.position,p.measured,p.parentId,h,g):p.position,v={...p,position:b,width:p.measured?.width??p.width,height:p.measured?.height??p.height};return Vt(v)},c=(f,h,g={replace:!1})=>{s(p=>p.map(b=>{if(b.id===f){const v=typeof h=="function"?h(b):h;return g.replace&&el(v)?v:{...b,...v}}return b}))},u=(f,h,g={replace:!1})=>{l(p=>p.map(b=>{if(b.id===f){const v=typeof h=="function"?h(b):h;return g.replace&&Ig(v)?v:{...b,...v}}return b}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>i(f)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(h=>({...h}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:s,setEdges:l,addNodes:f=>{const h=Array.isArray(f)?f:[f];n.nodeQueue.push(g=>[...g,...h])},addEdges:f=>{const h=Array.isArray(f)?f:[f];n.edgeQueue.push(g=>[...g,...h])},toObject:()=>{const{nodes:f=[],edges:h=[],transform:g}=t.getState(),[p,b,v]=g;return{nodes:f.map(w=>({...w})),edges:h.map(w=>({...w})),viewport:{x:p,y:b,zoom:v}}},deleteElements:async({nodes:f=[],edges:h=[]})=>{const{nodes:g,edges:p,onNodesDelete:b,onEdgesDelete:v,triggerNodeChanges:w,triggerEdgeChanges:_,onDelete:y,onBeforeDelete:x}=t.getState(),{nodes:D,edges:M}=await rp({nodesToRemove:f,edgesToRemove:h,nodes:g,edges:p,onBeforeDelete:x}),P=M.length>0,T=D.length>0;if(P){const z=M.map(Ra);v?.(M),_(z)}if(T){const z=D.map(Ra);b?.(D),w(z)}return(T||P)&&y?.({nodes:D,edges:M}),{deletedNodes:D,deletedEdges:M}},getIntersectingNodes:(f,h=!0,g)=>{const p=Us(f),b=p?f:d(f),v=g!==void 0;return b?(g||t.getState().nodes).filter(w=>{const _=t.getState().nodeLookup.get(w.id);if(_&&!p&&(w.id===f.id||!_.internals.positionAbsolute))return!1;const y=Vt(v?w:_),x=En(y,b);return h&&x>0||x>=y.width*y.height||x>=b.width*b.height}):[]},isNodeIntersecting:(f,h,g=!0)=>{const b=Us(f)?f:d(f);if(!b)return!1;const v=En(b,h);return g&&v>0||v>=h.width*h.height||v>=b.width*b.height},updateNode:c,updateNodeData:(f,h,g={replace:!1})=>{c(f,p=>{const b=typeof h=="function"?h(p):h;return g.replace?{...p,data:b}:{...p,data:{...p.data,...b}}},g)},updateEdge:u,updateEdgeData:(f,h,g={replace:!1})=>{u(f,p=>{const b=typeof h=="function"?h(p):h;return g.replace?{...p,data:b}:{...p,data:{...p.data,...b}}},g)},getNodesBounds:f=>{const{nodeLookup:h,nodeOrigin:g}=t.getState();return ep(f,{nodeLookup:h,nodeOrigin:g})},getHandleConnections:({type:f,id:h,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}-${f}${h?`-${h}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:h,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}${f?h?`-${f}-${h}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const h=t.getState().fitViewResolver??ap();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:h}),n.nodeQueue.push(g=>[...g]),h.promise}}},[]);return E.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const rl=e=>e.selected,Og=typeof window<"u"?window:void 0;function Ag({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=xe(),{deleteElements:o}=Ar(),r=Mn(e,{actInsideInputWithModifier:!1}),i=Mn(t,{target:Og});E.useEffect(()=>{if(r){const{edges:s,nodes:l}=n.getState();o({nodes:l.filter(rl),edges:s.filter(rl)}),n.setState({nodesSelectionActive:!1})}},[r]),E.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function $g(e){const t=xe();E.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=mr(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",Ae.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const _o={position:"absolute",width:"100%",height:"100%",top:0,left:0},Lg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function zg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=It.Free,zoomOnDoubleClick:s=!0,panOnDrag:l=!0,defaultViewport:d,translateExtent:c,minZoom:u,maxZoom:f,zoomActivationKeyCode:h,preventScrolling:g=!0,children:p,noWheelClassName:b,noPanClassName:v,onViewportChange:w,isControlledViewport:_,paneClickDistance:y,selectionOnDrag:x}){const D=xe(),M=E.useRef(null),{userSelectionActive:P,lib:T,connectionInProgress:z}=pe(Lg,we),q=Mn(h),A=E.useRef();$g(M);const H=E.useCallback(j=>{w?.({x:j[0],y:j[1],zoom:j[2]}),_||D.setState({transform:j})},[w,_]);return E.useEffect(()=>{if(M.current){A.current=Vp({domNode:M.current,minZoom:u,maxZoom:f,translateExtent:c,viewport:d,onDraggingChange:N=>D.setState(k=>k.paneDragging===N?k:{paneDragging:N}),onPanZoomStart:(N,k)=>{const{onViewportChangeStart:I,onMoveStart:O}=D.getState();O?.(N,k),I?.(k)},onPanZoom:(N,k)=>{const{onViewportChange:I,onMove:O}=D.getState();O?.(N,k),I?.(k)},onPanZoomEnd:(N,k)=>{const{onViewportChangeEnd:I,onMoveEnd:O}=D.getState();O?.(N,k),I?.(k)}});const{x:j,y:C,zoom:S}=A.current.getViewport();return D.setState({panZoom:A.current,transform:[j,C,S],domNode:M.current.closest(".react-flow")}),()=>{A.current?.destroy()}}},[]),E.useEffect(()=>{A.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:l,zoomActivationKeyPressed:q,preventScrolling:g,noPanClassName:v,userSelectionActive:P,noWheelClassName:b,lib:T,onTransformChange:H,connectionInProgress:z,selectionOnDrag:x,paneClickDistance:y})},[e,t,n,o,r,i,s,l,q,g,v,P,b,T,H,z,x,y]),a.jsx("div",{className:"react-flow__renderer",ref:M,style:_o,children:p})}const Fg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Bg(){const{userSelectionActive:e,userSelectionRect:t}=pe(Fg,we);return e&&t?a.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const $r=(e,t)=>n=>{n.target===t.current&&e?.(n)},Hg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Yg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=xn.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:l,onPaneClick:d,onPaneContextMenu:c,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:g,children:p}){const b=xe(),{userSelectionActive:v,elementsSelectable:w,dragging:_,connectionInProgress:y}=pe(Hg,we),x=w&&(e||v),D=E.useRef(null),M=E.useRef(),P=E.useRef(new Set),T=E.useRef(new Set),z=E.useRef(!1),q=I=>{if(z.current||y){z.current=!1;return}d?.(I),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},A=I=>{if(Array.isArray(o)&&o?.includes(2)){I.preventDefault();return}c?.(I)},H=u?I=>u(I):void 0,j=I=>{z.current&&(I.stopPropagation(),z.current=!1)},C=I=>{const{domNode:O}=b.getState();if(M.current=O?.getBoundingClientRect(),!M.current)return;const Y=I.target===D.current;if(!Y&&!!I.target.closest(".nokey")||!e||!(i&&Y||t)||I.button!==0||!I.isPrimary)return;I.target?.setPointerCapture?.(I.pointerId),z.current=!1;const{x:G,y:Z}=qe(I.nativeEvent,M.current);b.setState({userSelectionRect:{width:0,height:0,startX:G,startY:Z,x:G,y:Z}}),Y||(I.stopPropagation(),I.preventDefault())},S=I=>{const{userSelectionRect:O,transform:Y,nodeLookup:F,edgeLookup:X,connectionLookup:G,triggerNodeChanges:Z,triggerEdgeChanges:U,defaultEdgeOptions:te,resetSelectedElements:re}=b.getState();if(!M.current||!O)return;const{x:$,y:L}=qe(I.nativeEvent,M.current),{startX:V,startY:K}=O;if(!z.current){const ne=t?0:r;if(Math.hypot($-V,L-K)<=ne)return;re(),s?.(I)}z.current=!0;const W={startX:V,startY:K,x:$<V?$:V,y:L<K?L:K,width:Math.abs($-V),height:Math.abs(L-K)},R=P.current,ee=T.current;P.current=new Set(hr(F,W,Y,n===xn.Partial,!0).map(ne=>ne.id)),T.current=new Set;const le=te?.selectable??!0;for(const ne of P.current){const de=G.get(ne);if(de)for(const{edgeId:ue}of de.values()){const ye=X.get(ue);ye&&(ye.selectable??le)&&T.current.add(ue)}}if(!Js(R,P.current)){const ne=Gt(F,P.current,!0);Z(ne)}if(!Js(ee,T.current)){const ne=Gt(X,T.current);U(ne)}b.setState({userSelectionRect:W,userSelectionActive:!0,nodesSelectionActive:!1})},N=I=>{I.button===0&&(I.target?.releasePointerCapture?.(I.pointerId),!v&&I.target===D.current&&b.getState().userSelectionRect&&q?.(I),b.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l?.(I),b.setState({nodesSelectionActive:P.current.size>0})))},k=o===!0||Array.isArray(o)&&o.includes(0);return a.jsxs("div",{className:Ee(["react-flow__pane",{draggable:k,dragging:_,selection:e}]),onClick:x?void 0:$r(q,D),onContextMenu:$r(A,D),onWheel:$r(H,D),onPointerEnter:x?void 0:f,onPointerMove:x?S:h,onPointerUp:x?N:void 0,onPointerDownCapture:x?C:void 0,onClickCapture:x?j:void 0,onPointerLeave:g,ref:D,style:_o,children:[p,a.jsx(Bg,{})]})}function Lr({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:l,onError:d}=t.getState(),c=l.get(e);if(!c){d?.("012",Ae.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&s)&&(i({nodes:[c],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function il({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const l=xe(),[d,c]=E.useState(!1),u=E.useRef();return E.useEffect(()=>{u.current=Mp({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Lr({id:f,store:l,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}})},[]),E.useEffect(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{u.current?.destroy()}},[n,o,t,i,e,r,s]),d}const Xg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function sl(){const e=xe();return E.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:l,updateNodePositions:d,nodeLookup:c,nodeOrigin:u}=e.getState(),f=new Map,h=Xg(s),g=r?i[0]:5,p=r?i[1]:5,b=n.direction.x*g*n.factor,v=n.direction.y*p*n.factor;for(const[,w]of c){if(!h(w))continue;let _={x:w.internals.positionAbsolute.x+b,y:w.internals.positionAbsolute.y+v};r&&(_=Cn(_,i));const{position:y,positionAbsolute:x}=Xs({nodeId:w.id,nextPosition:_,nodeLookup:c,nodeExtent:o,nodeOrigin:u,onError:l});w.position=y,w.internals.positionAbsolute=x,f.set(w.id,w)}d(f)},[])}const zr=E.createContext(null),Vg=zr.Provider;zr.Consumer;const al=()=>E.useContext(zr),Wg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),qg=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:l,toHandle:d,isValid:c}=s,u=d?.nodeId===e&&d?.id===t&&d?.type===n;return{connectingFrom:l?.nodeId===e&&l?.id===t&&l?.type===n,connectingTo:u,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===Yt.Strict?l?.type!==n:e!==l?.nodeId||t!==l?.id,connectionInProcess:!!l,clickConnectionInProcess:!!r,valid:u&&c}};function jg({type:e="source",position:t=ae.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:d,className:c,onMouseDown:u,onTouchStart:f,...h},g){const p=s||null,b=e==="target",v=xe(),w=al(),{connectOnClick:_,noPanClassName:y,rfId:x}=pe(Wg,we),{connectingFrom:D,connectingTo:M,clickConnecting:P,isPossibleEndHandle:T,connectionInProcess:z,clickConnectionInProcess:q,valid:A}=pe(qg(w,p,e),we);w||v.getState().onError?.("010",Ae.error010());const H=S=>{const{defaultEdgeOptions:N,onConnect:k,hasDefaultEdges:I}=v.getState(),O={...N,...S};if(I){const{edges:Y,setEdges:F}=v.getState();F(sa(O,Y))}k?.(O),l?.(O)},j=S=>{if(!w)return;const N=ea(S.nativeEvent);if(r&&(N&&S.button===0||!N)){const k=v.getState();Nr.onPointerDown(S.nativeEvent,{handleDomNode:S.currentTarget,autoPanOnConnect:k.autoPanOnConnect,connectionMode:k.connectionMode,connectionRadius:k.connectionRadius,domNode:k.domNode,nodeLookup:k.nodeLookup,lib:k.lib,isTarget:b,handleId:p,nodeId:w,flowId:k.rfId,panBy:k.panBy,cancelConnection:k.cancelConnection,onConnectStart:k.onConnectStart,onConnectEnd:(...I)=>v.getState().onConnectEnd?.(...I),updateConnection:k.updateConnection,onConnect:H,isValidConnection:n||((...I)=>v.getState().isValidConnection?.(...I)??!0),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:k.autoPanSpeed,dragThreshold:k.connectionDragThreshold})}N?u?.(S):f?.(S)},C=S=>{const{onClickConnectStart:N,onClickConnectEnd:k,connectionClickStartHandle:I,connectionMode:O,isValidConnection:Y,lib:F,rfId:X,nodeLookup:G,connection:Z}=v.getState();if(!w||!I&&!r)return;if(!I){N?.(S.nativeEvent,{nodeId:w,handleId:p,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:w,type:e,id:p}});return}const U=Qs(S.target),te=n||Y,{connection:re,isValid:$}=Nr.isValid(S.nativeEvent,{handle:{nodeId:w,id:p,type:e},connectionMode:O,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:te,flowId:X,doc:U,lib:F,nodeLookup:G});$&&re&&H(re);const L=structuredClone(Z);delete L.inProgress,L.toPosition=L.toHandle?L.toHandle.position:null,k?.(S,L),v.setState({connectionClickStartHandle:null})};return a.jsx("div",{"data-handleid":p,"data-nodeid":w,"data-handlepos":t,"data-id":`${x}-${w}-${p}-${e}`,className:Ee(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,c,{source:!b,target:b,connectable:o,connectablestart:r,connectableend:i,clickconnecting:P,connectingfrom:D,connectingto:M,valid:A,connectionindicator:o&&(!z||T)&&(z||q?i:r)}]),onMouseDown:j,onTouchStart:j,onClick:_?C:void 0,ref:g,...h,children:d})}const Kt=E.memo(tl(jg));function Ug({data:e,isConnectable:t,sourcePosition:n=ae.Bottom}){return a.jsxs(a.Fragment,{children:[e?.label,a.jsx(Kt,{type:"source",position:n,isConnectable:t})]})}function Gg({data:e,isConnectable:t,targetPosition:n=ae.Top,sourcePosition:o=ae.Bottom}){return a.jsxs(a.Fragment,{children:[a.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label,a.jsx(Kt,{type:"source",position:o,isConnectable:t})]})}function Kg(){return null}function Zg({data:e,isConnectable:t,targetPosition:n=ae.Top}){return a.jsxs(a.Fragment,{children:[a.jsx(Kt,{type:"target",position:n,isConnectable:t}),e?.label]})}const Eo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ll={input:Ug,default:Gg,output:Zg,group:Kg};function Jg(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const Qg=e=>{const{width:t,height:n,x:o,y:r}=_n(e.nodeLookup,{filter:i=>!!i.selected});return{width:We(t)?t:null,height:We(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function Rg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=xe(),{width:r,height:i,transformString:s,userSelectionActive:l}=pe(Qg,we),d=sl(),c=E.useRef(null);E.useEffect(()=>{n||c.current?.focus({preventScroll:!0})},[n]);const u=!l&&r!==null&&i!==null;if(il({nodeRef:c,disabled:!u}),!u)return null;const f=e?g=>{const p=o.getState().nodes.filter(b=>b.selected);e(g,p)}:void 0,h=g=>{Object.prototype.hasOwnProperty.call(Eo,g.key)&&(g.preventDefault(),d({direction:Eo[g.key],factor:g.shiftKey?4:1}))};return a.jsx("div",{className:Ee(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:a.jsx("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:r,height:i}})})}const cl=typeof window<"u"?window:void 0,e0=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function dl({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:l,deleteKeyCode:d,selectionKeyCode:c,selectionOnDrag:u,selectionMode:f,onSelectionStart:h,onSelectionEnd:g,multiSelectionKeyCode:p,panActivationKeyCode:b,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:_,zoomOnPinch:y,panOnScroll:x,panOnScrollSpeed:D,panOnScrollMode:M,zoomOnDoubleClick:P,panOnDrag:T,defaultViewport:z,translateExtent:q,minZoom:A,maxZoom:H,preventScrolling:j,onSelectionContextMenu:C,noWheelClassName:S,noPanClassName:N,disableKeyboardA11y:k,onViewportChange:I,isControlledViewport:O}){const{nodesSelectionActive:Y,userSelectionActive:F}=pe(e0,we),X=Mn(c,{target:cl}),G=Mn(b,{target:cl}),Z=G||T,U=G||x,te=u&&Z!==!0,re=X||F||te;return Ag({deleteKeyCode:d,multiSelectionKeyCode:p}),a.jsx(zg,{onPaneContextMenu:i,elementsSelectable:w,zoomOnScroll:_,zoomOnPinch:y,panOnScroll:U,panOnScrollSpeed:D,panOnScrollMode:M,zoomOnDoubleClick:P,panOnDrag:!X&&Z,defaultViewport:z,translateExtent:q,minZoom:A,maxZoom:H,zoomActivationKeyCode:v,preventScrolling:j,noWheelClassName:S,noPanClassName:N,onViewportChange:I,isControlledViewport:O,paneClickDistance:l,selectionOnDrag:te,children:a.jsxs(Yg,{onSelectionStart:h,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:Z,isSelecting:!!re,selectionMode:f,selectionKeyPressed:X,paneClickDistance:l,selectionOnDrag:te,children:[e,Y&&a.jsx(Rg,{onSelectionContextMenu:C,noPanClassName:N,disableKeyboardA11y:k})]})})}dl.displayName="FlowRenderer";const t0=E.memo(dl),n0=e=>t=>e?hr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function o0(e){return pe(E.useCallback(n0(e),[e]),we)}const r0=e=>e.updateNodeInternals;function i0(){const e=pe(r0),[t]=E.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return E.useEffect(()=>()=>{t?.disconnect()},[t]),t}function s0({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=xe(),i=E.useRef(null),s=E.useRef(null),l=E.useRef(e.sourcePosition),d=E.useRef(e.targetPosition),c=E.useRef(t),u=n&&!!e.internals.handleBounds;return E.useEffect(()=>{i.current&&!e.hidden&&(!u||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[u,e.hidden]),E.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),E.useEffect(()=>{if(i.current){const f=c.current!==t,h=l.current!==e.sourcePosition,g=d.current!==e.targetPosition;(f||h||g)&&(c.current=t,l.current=e.sourcePosition,d.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function a0({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:l,elementsSelectable:d,nodesConnectable:c,nodesFocusable:u,resizeObserver:f,noDragClassName:h,noPanClassName:g,disableKeyboardA11y:p,rfId:b,nodeTypes:v,nodeClickDistance:w,onError:_}){const{node:y,internals:x,isParent:D}=pe($=>{const L=$.nodeLookup.get(e),V=$.parentLookup.has(e);return{node:L,internals:L.internals,isParent:V}},we);let M=y.type||"default",P=v?.[M]||ll[M];P===void 0&&(_?.("003",Ae.error003(M)),M="default",P=v?.default||ll.default);const T=!!(y.draggable||l&&typeof y.draggable>"u"),z=!!(y.selectable||d&&typeof y.selectable>"u"),q=!!(y.connectable||c&&typeof y.connectable>"u"),A=!!(y.focusable||u&&typeof y.focusable>"u"),H=xe(),j=Ks(y),C=s0({node:y,nodeType:M,hasDimensions:j,resizeObserver:f}),S=il({nodeRef:C,disabled:y.hidden||!T,noDragClassName:h,handleSelector:y.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:w}),N=sl();if(y.hidden)return null;const k=st(y),I=Jg(y),O=z||T||t||n||o||r,Y=n?$=>n($,{...x.userNode}):void 0,F=o?$=>o($,{...x.userNode}):void 0,X=r?$=>r($,{...x.userNode}):void 0,G=i?$=>i($,{...x.userNode}):void 0,Z=s?$=>s($,{...x.userNode}):void 0,U=$=>{const{selectNodesOnDrag:L,nodeDragThreshold:V}=H.getState();z&&(!L||!T||V>0)&&Lr({id:e,store:H,nodeRef:C}),t&&t($,{...x.userNode})},te=$=>{if(!(Rs($.nativeEvent)||p)){if(Ls.includes($.key)&&z){const L=$.key==="Escape";Lr({id:e,store:H,unselect:L,nodeRef:C})}else if(T&&y.selected&&Object.prototype.hasOwnProperty.call(Eo,$.key)){$.preventDefault();const{ariaLabelConfig:L}=H.getState();H.setState({ariaLiveMessage:L["node.a11yDescription.ariaLiveMessage"]({direction:$.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),N({direction:Eo[$.key],factor:$.shiftKey?4:1})}}},re=()=>{if(p||!C.current?.matches(":focus-visible"))return;const{transform:$,width:L,height:V,autoPanOnNodeFocus:K,setCenter:W}=H.getState();if(!K)return;hr(new Map([[e,y]]),{x:0,y:0,width:L,height:V},$,!0).length>0||W(y.position.x+k.width/2,y.position.y+k.height/2,{zoom:$[2]})};return a.jsx("div",{className:Ee(["react-flow__node",`react-flow__node-${M}`,{[g]:T},y.className,{selected:y.selected,selectable:z,parent:D,draggable:T,dragging:S}]),ref:C,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:O?"all":"none",visibility:j?"visible":"hidden",...y.style,...I},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:Y,onMouseMove:F,onMouseLeave:X,onContextMenu:G,onClick:U,onDoubleClick:Z,onKeyDown:A?te:void 0,tabIndex:A?0:void 0,onFocus:A?re:void 0,role:y.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${Ha}-${b}`,"aria-label":y.ariaLabel,...y.domAttributes,children:a.jsx(Vg,{value:e,children:a.jsx(P,{id:e,data:y.data,type:M,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:y.selected??!1,selectable:z,draggable:T,deletable:y.deletable??!0,isConnectable:q,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:S,dragHandle:y.dragHandle,zIndex:x.z,parentId:y.parentId,...k})})})}var l0=E.memo(a0);const c0=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function ul(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=pe(c0,we),s=o0(e.onlyRenderVisibleElements),l=i0();return a.jsx("div",{className:"react-flow__nodes",style:_o,children:s.map(d=>a.jsx(l0,{id:d,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},d))})}ul.displayName="NodeRenderer";const d0=E.memo(ul);function u0(e){return pe(E.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&up({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),we)}const f0=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return a.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},h0=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return a.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},fl={[co.Arrow]:f0,[co.ArrowClosed]:h0};function p0(e){const t=xe();return E.useMemo(()=>Object.prototype.hasOwnProperty.call(fl,e)?fl[e]:(t.getState().onError?.("009",Ae.error009(e)),null),[e])}const g0=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const d=p0(t);return d?a.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:a.jsx(d,{color:n,strokeWidth:s})}):null},hl=({defaultColor:e,rfId:t})=>{const n=pe(i=>i.edges),o=pe(i=>i.defaultEdgeOptions),r=E.useMemo(()=>bp(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?a.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:a.jsx("defs",{children:r.map(i=>a.jsx(g0,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};hl.displayName="MarkerDefinitions";var m0=E.memo(hl);function pl({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:d,className:c,...u}){const[f,h]=E.useState({x:1,y:0,width:0,height:0}),g=Ee(["react-flow__edge-textwrapper",c]),p=E.useRef(null);return E.useEffect(()=>{if(p.current){const b=p.current.getBBox();h({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?a.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...u,children:[r&&a.jsx("rect",{width:f.width+2*s[0],x:-s[0],y:-s[1],height:f.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),a.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:p,style:o,children:n}),d]}):null}pl.displayName="EdgeText";const y0=E.memo(pl);function Co({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:d,interactionWidth:c=20,...u}){return a.jsxs(a.Fragment,{children:[a.jsx("path",{...u,d:e,fill:"none",className:Ee(["react-flow__edge-path",u.className])}),c?a.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,o&&We(t)&&We(n)?a.jsx(y0,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:d}):null]})}function gl({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===ae.Left||e===ae.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function ml({sourceX:e,sourceY:t,sourcePosition:n=ae.Bottom,targetX:o,targetY:r,targetPosition:i=ae.Top}){const[s,l]=gl({pos:n,x1:e,y1:t,x2:o,y2:r}),[d,c]=gl({pos:i,x1:o,y1:r,x2:e,y2:t}),[u,f,h,g]=na({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:l,targetControlX:d,targetControlY:c});return[`M${e},${t} C${s},${l} ${d},${c} ${o},${r}`,u,f,h,g]}function yl(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:l,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:g,style:p,markerEnd:b,markerStart:v,interactionWidth:w})=>{const[_,y,x]=ml({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:l}),D=e.isInternal?void 0:t;return a.jsx(Co,{id:D,path:_,labelX:y,labelY:x,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:g,style:p,markerEnd:b,markerStart:v,interactionWidth:w})})}const b0=yl({isInternal:!1}),bl=yl({isInternal:!0});b0.displayName="SimpleBezierEdge",bl.displayName="SimpleBezierEdgeInternal";function vl(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:h,sourcePosition:g=ae.Bottom,targetPosition:p=ae.Top,markerEnd:b,markerStart:v,pathOptions:w,interactionWidth:_})=>{const[y,x,D]=yr({sourceX:n,sourceY:o,sourcePosition:g,targetX:r,targetY:i,targetPosition:p,borderRadius:w?.borderRadius,offset:w?.offset,stepPosition:w?.stepPosition}),M=e.isInternal?void 0:t;return a.jsx(Co,{id:M,path:y,labelX:x,labelY:D,label:s,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:b,markerStart:v,interactionWidth:_})})}const wl=vl({isInternal:!1}),xl=vl({isInternal:!0});wl.displayName="SmoothStepEdge",xl.displayName="SmoothStepEdgeInternal";function Sl(e){return E.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return a.jsx(wl,{...n,id:o,pathOptions:E.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const v0=Sl({isInternal:!1}),_l=Sl({isInternal:!0});v0.displayName="StepEdge",_l.displayName="StepEdgeInternal";function El(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:g,markerStart:p,interactionWidth:b})=>{const[v,w,_]=aa({sourceX:n,sourceY:o,targetX:r,targetY:i}),y=e.isInternal?void 0:t;return a.jsx(Co,{id:y,path:v,labelX:w,labelY:_,label:s,labelStyle:l,labelShowBg:d,labelBgStyle:c,labelBgPadding:u,labelBgBorderRadius:f,style:h,markerEnd:g,markerStart:p,interactionWidth:b})})}const w0=El({isInternal:!1}),Cl=El({isInternal:!0});w0.displayName="StraightEdge",Cl.displayName="StraightEdgeInternal";function Nl(e){return E.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=ae.Bottom,targetPosition:l=ae.Top,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:g,style:p,markerEnd:b,markerStart:v,pathOptions:w,interactionWidth:_})=>{const[y,x,D]=ra({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:l,curvature:w?.curvature}),M=e.isInternal?void 0:t;return a.jsx(Co,{id:M,path:y,labelX:x,labelY:D,label:d,labelStyle:c,labelShowBg:u,labelBgStyle:f,labelBgPadding:h,labelBgBorderRadius:g,style:p,markerEnd:b,markerStart:v,interactionWidth:_})})}const x0=Nl({isInternal:!1}),kl=Nl({isInternal:!0});x0.displayName="BezierEdge",kl.displayName="BezierEdgeInternal";const Il={default:kl,straight:Cl,step:_l,smoothstep:xl,simplebezier:bl},Ml={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},S0=(e,t,n)=>n===ae.Left?e-t:n===ae.Right?e+t:e,_0=(e,t,n)=>n===ae.Top?e-t:n===ae.Bottom?e+t:e,Pl="react-flow__edgeupdater";function Dl({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:l}){return a.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:Ee([Pl,`${Pl}-${l}`]),cx:S0(t,o,e),cy:_0(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function E0({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:l,targetPosition:d,onReconnect:c,onReconnectStart:u,onReconnectEnd:f,setReconnecting:h,setUpdateHover:g}){const p=xe(),b=(x,D)=>{if(x.button!==0)return;const{autoPanOnConnect:M,domNode:P,connectionMode:T,connectionRadius:z,lib:q,onConnectStart:A,cancelConnection:H,nodeLookup:j,rfId:C,panBy:S,updateConnection:N}=p.getState(),k=D.type==="target",I=(F,X)=>{h(!1),f?.(F,n,D.type,X)},O=F=>c?.(n,F),Y=(F,X)=>{h(!0),u?.(x,n,D.type),A?.(F,X)};Nr.onPointerDown(x.nativeEvent,{autoPanOnConnect:M,connectionMode:T,connectionRadius:z,domNode:P,handleId:D.id,nodeId:D.nodeId,nodeLookup:j,isTarget:k,edgeUpdaterType:D.type,lib:q,flowId:C,cancelConnection:H,panBy:S,isValidConnection:(...F)=>p.getState().isValidConnection?.(...F)??!0,onConnect:O,onConnectStart:Y,onConnectEnd:(...F)=>p.getState().onConnectEnd?.(...F),onReconnectEnd:I,updateConnection:N,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},v=x=>b(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=x=>b(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),_=()=>g(!0),y=()=>g(!1);return a.jsxs(a.Fragment,{children:[(e===!0||e==="source")&&a.jsx(Dl,{position:l,centerX:o,centerY:r,radius:t,onMouseDown:v,onMouseEnter:_,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&a.jsx(Dl,{position:d,centerX:i,centerY:s,radius:t,onMouseDown:w,onMouseEnter:_,onMouseOut:y,type:"target"})]})}function C0({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:l,onMouseMove:d,onMouseLeave:c,reconnectRadius:u,onReconnect:f,onReconnectStart:h,onReconnectEnd:g,rfId:p,edgeTypes:b,noPanClassName:v,onError:w,disableKeyboardA11y:_}){let y=pe(W=>W.edgeLookup.get(e));const x=pe(W=>W.defaultEdgeOptions);y=x?{...x,...y}:y;let D=y.type||"default",M=b?.[D]||Il[D];M===void 0&&(w?.("011",Ae.error011(D)),D="default",M=b?.default||Il.default);const P=!!(y.focusable||t&&typeof y.focusable>"u"),T=typeof f<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),z=!!(y.selectable||o&&typeof y.selectable>"u"),q=E.useRef(null),[A,H]=E.useState(!1),[j,C]=E.useState(!1),S=xe(),{zIndex:N,sourceX:k,sourceY:I,targetX:O,targetY:Y,sourcePosition:F,targetPosition:X}=pe(E.useCallback(W=>{const R=W.nodeLookup.get(y.source),ee=W.nodeLookup.get(y.target);if(!R||!ee)return{zIndex:y.zIndex,...Ml};const le=yp({id:e,sourceNode:R,targetNode:ee,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:W.connectionMode,onError:w});return{zIndex:dp({selected:y.selected,zIndex:y.zIndex,sourceNode:R,targetNode:ee,elevateOnSelect:W.elevateEdgesOnSelect,zIndexMode:W.zIndexMode}),...le||Ml}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),we),G=E.useMemo(()=>y.markerStart?`url('#${br(y.markerStart,p)}')`:void 0,[y.markerStart,p]),Z=E.useMemo(()=>y.markerEnd?`url('#${br(y.markerEnd,p)}')`:void 0,[y.markerEnd,p]);if(y.hidden||k===null||I===null||O===null||Y===null)return null;const U=W=>{const{addSelectedEdges:R,unselectNodesAndEdges:ee,multiSelectionActive:le}=S.getState();z&&(S.setState({nodesSelectionActive:!1}),y.selected&&le?(ee({nodes:[],edges:[y]}),q.current?.blur()):R([e])),r&&r(W,y)},te=i?W=>{i(W,{...y})}:void 0,re=s?W=>{s(W,{...y})}:void 0,$=l?W=>{l(W,{...y})}:void 0,L=d?W=>{d(W,{...y})}:void 0,V=c?W=>{c(W,{...y})}:void 0,K=W=>{if(!_&&Ls.includes(W.key)&&z){const{unselectNodesAndEdges:R,addSelectedEdges:ee}=S.getState();W.key==="Escape"?(q.current?.blur(),R({edges:[y]})):ee([e])}};return a.jsx("svg",{style:{zIndex:N},children:a.jsxs("g",{className:Ee(["react-flow__edge",`react-flow__edge-${D}`,y.className,v,{selected:y.selected,animated:y.animated,inactive:!z&&!r,updating:A,selectable:z}]),onClick:U,onDoubleClick:te,onContextMenu:re,onMouseEnter:$,onMouseMove:L,onMouseLeave:V,onKeyDown:P?K:void 0,tabIndex:P?0:void 0,role:y.ariaRole??(P?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":P?`${Ya}-${p}`:void 0,ref:q,...y.domAttributes,children:[!j&&a.jsx(M,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:z,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:k,sourceY:I,targetX:O,targetY:Y,sourcePosition:F,targetPosition:X,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:G,markerEnd:Z,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),T&&a.jsx(E0,{edge:y,isReconnectable:T,reconnectRadius:u,onReconnect:f,onReconnectStart:h,onReconnectEnd:g,sourceX:k,sourceY:I,targetX:O,targetY:Y,sourcePosition:F,targetPosition:X,setUpdateHover:H,setReconnecting:C})]})})}var N0=E.memo(C0);const k0=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Tl({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:l,onEdgeMouseMove:d,onEdgeMouseLeave:c,onEdgeClick:u,reconnectRadius:f,onEdgeDoubleClick:h,onReconnectStart:g,onReconnectEnd:p,disableKeyboardA11y:b}){const{edgesFocusable:v,edgesReconnectable:w,elementsSelectable:_,onError:y}=pe(k0,we),x=u0(t);return a.jsxs("div",{className:"react-flow__edges",children:[a.jsx(m0,{defaultColor:e,rfId:n}),x.map(D=>a.jsx(N0,{id:D,edgesFocusable:v,edgesReconnectable:w,elementsSelectable:_,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:l,onMouseMove:d,onMouseLeave:c,onClick:u,reconnectRadius:f,onDoubleClick:h,onReconnectStart:g,onReconnectEnd:p,rfId:n,onError:y,edgeTypes:o,disableKeyboardA11y:b},D))]})}Tl.displayName="EdgeRenderer";const I0=E.memo(Tl),M0=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function P0({children:e}){const t=pe(M0);return a.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function D0(e){const t=Ar(),n=E.useRef(!1);E.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const T0=e=>e.panZoom?.syncViewport;function O0(e){const t=pe(T0),n=xe();return E.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function A0(e){return e.connection.inProgress?{...e.connection,to:Nn(e.connection.to,e.transform)}:{...e.connection}}function $0(e){return A0}function L0(e){const t=$0();return pe(t,we)}const z0=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function F0({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:l,inProgress:d}=pe(z0,we);return!(i&&r&&d)?null:a.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:a.jsx("g",{className:Ee(["react-flow__connection",Hs(l)]),children:a.jsx(Ol,{style:t,type:n,CustomComponent:o,isValid:l})})})}const Ol=({style:e,type:t=dt.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:l,fromPosition:d,to:c,toNode:u,toHandle:f,toPosition:h,pointer:g}=L0();if(!r)return;if(n)return a.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:l,fromX:i.x,fromY:i.y,toX:c.x,toY:c.y,fromPosition:d,toPosition:h,connectionStatus:Hs(o),toNode:u,toHandle:f,pointer:g});let p="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:d,targetX:c.x,targetY:c.y,targetPosition:h};switch(t){case dt.Bezier:[p]=ra(b);break;case dt.SimpleBezier:[p]=ml(b);break;case dt.Step:[p]=yr({...b,borderRadius:0});break;case dt.SmoothStep:[p]=yr(b);break;default:[p]=aa(b)}return a.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};Ol.displayName="ConnectionLine";const B0={};function Al(e=B0){const t=E.useRef(e),n=xe();E.useEffect(()=>{if(process.env.NODE_ENV==="development"){const o=new Set([...Object.keys(t.current),...Object.keys(e)]);for(const r of o)if(t.current[r]!==e[r]){n.getState().onError?.("002",Ae.error002());break}t.current=e}},[e])}function H0(){const e=xe(),t=E.useRef(!1);E.useEffect(()=>{if(process.env.NODE_ENV==="development"&&!t.current){const n=document.querySelector(".react-flow__pane");n&&window.getComputedStyle(n).zIndex!=="1"&&e.getState().onError?.("013",Ae.error013("react")),t.current=!0}},[])}function $l({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:l,onNodeMouseMove:d,onNodeMouseLeave:c,onNodeContextMenu:u,onSelectionContextMenu:f,onSelectionStart:h,onSelectionEnd:g,connectionLineType:p,connectionLineStyle:b,connectionLineComponent:v,connectionLineContainerStyle:w,selectionKeyCode:_,selectionOnDrag:y,selectionMode:x,multiSelectionKeyCode:D,panActivationKeyCode:M,zoomActivationKeyCode:P,deleteKeyCode:T,onlyRenderVisibleElements:z,elementsSelectable:q,defaultViewport:A,translateExtent:H,minZoom:j,maxZoom:C,preventScrolling:S,defaultMarkerColor:N,zoomOnScroll:k,zoomOnPinch:I,panOnScroll:O,panOnScrollSpeed:Y,panOnScrollMode:F,zoomOnDoubleClick:X,panOnDrag:G,onPaneClick:Z,onPaneMouseEnter:U,onPaneMouseMove:te,onPaneMouseLeave:re,onPaneScroll:$,onPaneContextMenu:L,paneClickDistance:V,nodeClickDistance:K,onEdgeContextMenu:W,onEdgeMouseEnter:R,onEdgeMouseMove:ee,onEdgeMouseLeave:le,reconnectRadius:ne,onReconnect:de,onReconnectStart:ue,onReconnectEnd:ye,noDragClassName:ke,noWheelClassName:$e,noPanClassName:Be,disableKeyboardA11y:Pe,nodeExtent:De,rfId:He,viewport:et,onViewportChange:je}){return Al(e),Al(t),H0(),D0(n),O0(et),a.jsx(t0,{onPaneClick:Z,onPaneMouseEnter:U,onPaneMouseMove:te,onPaneMouseLeave:re,onPaneContextMenu:L,onPaneScroll:$,paneClickDistance:V,deleteKeyCode:T,selectionKeyCode:_,selectionOnDrag:y,selectionMode:x,onSelectionStart:h,onSelectionEnd:g,multiSelectionKeyCode:D,panActivationKeyCode:M,zoomActivationKeyCode:P,elementsSelectable:q,zoomOnScroll:k,zoomOnPinch:I,zoomOnDoubleClick:X,panOnScroll:O,panOnScrollSpeed:Y,panOnScrollMode:F,panOnDrag:G,defaultViewport:A,translateExtent:H,minZoom:j,maxZoom:C,onSelectionContextMenu:f,preventScrolling:S,noDragClassName:ke,noWheelClassName:$e,noPanClassName:Be,disableKeyboardA11y:Pe,onViewportChange:je,isControlledViewport:!!et,children:a.jsxs(P0,{children:[a.jsx(I0,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:de,onReconnectStart:ue,onReconnectEnd:ye,onlyRenderVisibleElements:z,onEdgeContextMenu:W,onEdgeMouseEnter:R,onEdgeMouseMove:ee,onEdgeMouseLeave:le,reconnectRadius:ne,defaultMarkerColor:N,noPanClassName:Be,disableKeyboardA11y:Pe,rfId:He}),a.jsx(F0,{style:b,type:p,component:v,containerStyle:w}),a.jsx("div",{className:"react-flow__edgelabel-renderer"}),a.jsx(d0,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:d,onNodeMouseLeave:c,onNodeContextMenu:u,nodeClickDistance:K,onlyRenderVisibleElements:z,noPanClassName:Be,noDragClassName:ke,disableKeyboardA11y:Pe,nodeExtent:De,rfId:He}),a.jsx("div",{className:"react-flow__viewport-portal"})]})})}$l.displayName="GraphView";const Y0=E.memo($l),Ll=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:l,minZoom:d=.5,maxZoom:c=2,nodeOrigin:u,nodeExtent:f,zIndexMode:h="basic"}={})=>{const g=new Map,p=new Map,b=new Map,v=new Map,w=o??t??[],_=n??e??[],y=u??[0,0],x=f??wn;ma(b,v,w);const{nodesInitialized:D}=Sr(_,g,p,{nodeOrigin:y,nodeExtent:x,zIndexMode:h});let M=[0,0,1];if(s&&r&&i){const P=_n(g,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:T,y:z,zoom:q}=gr(P,r,i,d,c,l?.padding??.1);M=[T,z,q]}return{rfId:"1",width:r??0,height:i??0,transform:M,nodes:_,nodesInitialized:D,nodeLookup:g,parentLookup:p,edges:w,edgeLookup:v,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:d,maxZoom:c,translateExtent:wn,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Yt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Fs},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Gs,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:zs,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},X0=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:l,minZoom:d,maxZoom:c,nodeOrigin:u,nodeExtent:f,zIndexMode:h})=>lg((g,p)=>{async function b(){const{nodeLookup:v,panZoom:w,fitViewOptions:_,fitViewResolver:y,width:x,height:D,minZoom:M,maxZoom:P}=p();w&&(await op({nodes:v,width:x,height:D,panZoom:w,minZoom:M,maxZoom:P},_),y?.resolve(!0),g({fitViewResolver:null}))}return{...Ll({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:l,minZoom:d,maxZoom:c,nodeOrigin:u,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:h}),setNodes:v=>{const{nodeLookup:w,parentLookup:_,nodeOrigin:y,elevateNodesOnSelect:x,fitViewQueued:D,zIndexMode:M,nodesSelectionActive:P}=p(),{nodesInitialized:T,hasSelectedNodes:z}=Sr(v,w,_,{nodeOrigin:y,nodeExtent:f,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:M}),q=P&&z;D&&T?(b(),g({nodes:v,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:q})):g({nodes:v,nodesInitialized:T,nodesSelectionActive:q})},setEdges:v=>{const{connectionLookup:w,edgeLookup:_}=p();ma(w,_,v),g({edges:v})},setDefaultNodesAndEdges:(v,w)=>{if(v){const{setNodes:_}=p();_(v),g({hasDefaultNodes:!0})}if(w){const{setEdges:_}=p();_(w),g({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:w,nodeLookup:_,parentLookup:y,domNode:x,nodeOrigin:D,nodeExtent:M,debug:P,fitViewQueued:T,zIndexMode:z}=p(),{changes:q,updatedInternals:A}=Cp(v,_,y,x,D,M,z);A&&(xp(_,y,{nodeOrigin:D,nodeExtent:M,zIndexMode:z}),T?(b(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),q?.length>0&&(P&&console.log("React Flow: trigger node changes",q),w?.(q)))},updateNodePositions:(v,w=!1)=>{const _=[];let y=[];const{nodeLookup:x,triggerNodeChanges:D,connection:M,updateConnection:P,onNodesChangeMiddlewareMap:T}=p();for(const[z,q]of v){const A=x.get(z),H=!!(A?.expandParent&&A?.parentId&&q?.position),j={id:z,type:"position",position:H?{x:Math.max(0,q.position.x),y:Math.max(0,q.position.y)}:q.position,dragging:w};if(A&&M.inProgress&&M.fromNode.id===A.id){const C=Pt(A,M.fromHandle,ae.Left,!0);P({...M,from:C})}H&&A.parentId&&_.push({id:z,parentId:A.parentId,rect:{...q.internals.positionAbsolute,width:q.measured.width??0,height:q.measured.height??0}}),y.push(j)}if(_.length>0){const{parentLookup:z,nodeOrigin:q}=p(),A=Er(_,x,z,q);y.push(...A)}for(const z of T.values())y=z(y);D(y)},triggerNodeChanges:v=>{const{onNodesChange:w,setNodes:_,nodes:y,hasDefaultNodes:x,debug:D}=p();if(v?.length){if(x){const M=Za(v,y);_(M)}D&&console.log("React Flow: trigger node changes",v),w?.(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:w,setEdges:_,edges:y,hasDefaultEdges:x,debug:D}=p();if(v?.length){if(x){const M=Ja(v,y);_(M)}D&&console.log("React Flow: trigger edge changes",v),w?.(v)}},addSelectedNodes:v=>{const{multiSelectionActive:w,edgeLookup:_,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:D}=p();if(w){const M=v.map(P=>Dt(P,!0));x(M);return}x(Gt(y,new Set([...v]),!0)),D(Gt(_))},addSelectedEdges:v=>{const{multiSelectionActive:w,edgeLookup:_,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:D}=p();if(w){const M=v.map(P=>Dt(P,!0));D(M);return}D(Gt(_,new Set([...v]))),x(Gt(y,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:w}={})=>{const{edges:_,nodes:y,nodeLookup:x,triggerNodeChanges:D,triggerEdgeChanges:M}=p(),P=v||y,T=w||_,z=[];for(const A of P){if(!A.selected)continue;const H=x.get(A.id);H&&(H.selected=!1),z.push(Dt(A.id,!1))}const q=[];for(const A of T)A.selected&&q.push(Dt(A.id,!1));D(z),M(q)},setMinZoom:v=>{const{panZoom:w,maxZoom:_}=p();w?.setScaleExtent([v,_]),g({minZoom:v})},setMaxZoom:v=>{const{panZoom:w,minZoom:_}=p();w?.setScaleExtent([_,v]),g({maxZoom:v})},setTranslateExtent:v=>{p().panZoom?.setTranslateExtent(v),g({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:w,triggerNodeChanges:_,triggerEdgeChanges:y,elementsSelectable:x}=p();if(!x)return;const D=w.reduce((P,T)=>T.selected?[...P,Dt(T.id,!1)]:P,[]),M=v.reduce((P,T)=>T.selected?[...P,Dt(T.id,!1)]:P,[]);_(D),y(M)},setNodeExtent:v=>{const{nodes:w,nodeLookup:_,parentLookup:y,nodeOrigin:x,elevateNodesOnSelect:D,nodeExtent:M,zIndexMode:P}=p();v[0][0]===M[0][0]&&v[0][1]===M[0][1]&&v[1][0]===M[1][0]&&v[1][1]===M[1][1]||(Sr(w,_,y,{nodeOrigin:x,nodeExtent:v,elevateNodesOnSelect:D,checkEquality:!1,zIndexMode:P}),g({nodeExtent:v}))},panBy:v=>{const{transform:w,width:_,height:y,panZoom:x,translateExtent:D}=p();return Np({delta:v,panZoom:x,transform:w,translateExtent:D,width:_,height:y})},setCenter:async(v,w,_)=>{const{width:y,height:x,maxZoom:D,panZoom:M}=p();if(!M)return Promise.resolve(!1);const P=typeof _?.zoom<"u"?_.zoom:D;return await M.setViewport({x:y/2-v*P,y:x/2-w*P,zoom:P},{duration:_?.duration,ease:_?.ease,interpolate:_?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...Fs}})},updateConnection:v=>{g({connection:v})},reset:()=>g({...Ll()})}},Object.is);function V0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:l,initialFitViewOptions:d,fitView:c,nodeOrigin:u,nodeExtent:f,zIndexMode:h,children:g}){const[p]=E.useState(()=>X0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:c,minZoom:s,maxZoom:l,fitViewOptions:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h}));return a.jsx(cg,{value:p,children:a.jsx(Pg,{children:g})})}function W0({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:l,fitViewOptions:d,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:h,zIndexMode:g}){return E.useContext(wo)?a.jsx(a.Fragment,{children:e}):a.jsx(V0,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:l,initialFitViewOptions:d,initialMinZoom:c,initialMaxZoom:u,nodeOrigin:f,nodeExtent:h,zIndexMode:g,children:e})}const q0={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function j0({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:l,onEdgeClick:d,onInit:c,onMove:u,onMoveStart:f,onMoveEnd:h,onConnect:g,onConnectStart:p,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:w,onNodeMouseEnter:_,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:D,onNodeDoubleClick:M,onNodeDragStart:P,onNodeDrag:T,onNodeDragStop:z,onNodesDelete:q,onEdgesDelete:A,onDelete:H,onSelectionChange:j,onSelectionDragStart:C,onSelectionDrag:S,onSelectionDragStop:N,onSelectionContextMenu:k,onSelectionStart:I,onSelectionEnd:O,onBeforeDelete:Y,connectionMode:F,connectionLineType:X=dt.Bezier,connectionLineStyle:G,connectionLineComponent:Z,connectionLineContainerStyle:U,deleteKeyCode:te="Backspace",selectionKeyCode:re="Shift",selectionOnDrag:$=!1,selectionMode:L=xn.Full,panActivationKeyCode:V="Space",multiSelectionKeyCode:K=kn()?"Meta":"Control",zoomActivationKeyCode:W=kn()?"Meta":"Control",snapToGrid:R,snapGrid:ee,onlyRenderVisibleElements:le=!1,selectNodesOnDrag:ne,nodesDraggable:de,autoPanOnNodeFocus:ue,nodesConnectable:ye,nodesFocusable:ke,nodeOrigin:$e=Xa,edgesFocusable:Be,edgesReconnectable:Pe,elementsSelectable:De=!0,defaultViewport:He=Sg,minZoom:et=.5,maxZoom:je=2,translateExtent:gt=wn,preventScrolling:mt=!0,nodeExtent:Ue,defaultMarkerColor:Ge="#b1b1b7",zoomOnScroll:Ke=!0,zoomOnPinch:Zt=!0,panOnScroll:Jt=!1,panOnScrollSpeed:Le=.5,panOnScrollMode:Mo=It.Free,zoomOnDoubleClick:yt=!0,panOnDrag:bt=!0,onPaneClick:tt,onPaneMouseEnter:Po,onPaneMouseMove:Pn,onPaneMouseLeave:B,onPaneScroll:J,onPaneContextMenu:ie,paneClickDistance:oe=1,nodeClickDistance:Q=0,children:ce,onReconnect:me,onReconnectStart:fe,onReconnectEnd:ve,onEdgeContextMenu:ge,onEdgeDoubleClick:_e,onEdgeMouseEnter:Ce,onEdgeMouseMove:ze,onEdgeMouseLeave:vt,reconnectRadius:nt=10,onNodesChange:Qt,onEdgesChange:Br,noDragClassName:Do="nodrag",noWheelClassName:Xm="nowheel",noPanClassName:Ql="nopan",fitView:Rl,fitViewOptions:ec,connectOnClick:Vm,attributionPosition:Wm,proOptions:qm,defaultEdgeOptions:jm,elevateNodesOnSelect:Um=!0,elevateEdgesOnSelect:Gm=!1,disableKeyboardA11y:tc=!1,autoPanOnConnect:Km,autoPanOnNodeDrag:Zm,autoPanSpeed:Jm,connectionRadius:Qm,isValidConnection:Rm,onError:ey,style:ty,id:nc,nodeDragThreshold:ny,connectionDragThreshold:oy,viewport:ry,onViewportChange:iy,width:sy,height:ay,colorMode:ly="light",debug:cy,onScroll:oc,ariaLabelConfig:dy,zIndexMode:rc="basic",...uy},fy){const Hr=nc||"1",hy=Cg(ly),py=E.useCallback(ic=>{ic.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),oc?.(ic)},[oc]);return a.jsx("div",{"data-testid":"rf__wrapper",...uy,onScroll:py,style:{...ty,...q0},ref:fy,className:Ee(["react-flow",r,hy]),id:nc,role:"application",children:a.jsxs(W0,{nodes:e,edges:t,width:sy,height:ay,fitView:Rl,fitViewOptions:ec,minZoom:et,maxZoom:je,nodeOrigin:$e,nodeExtent:Ue,zIndexMode:rc,children:[a.jsx(Eg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:g,onConnectStart:p,onConnectEnd:b,onClickConnectStart:v,onClickConnectEnd:w,nodesDraggable:de,autoPanOnNodeFocus:ue,nodesConnectable:ye,nodesFocusable:ke,edgesFocusable:Be,edgesReconnectable:Pe,elementsSelectable:De,elevateNodesOnSelect:Um,elevateEdgesOnSelect:Gm,minZoom:et,maxZoom:je,nodeExtent:Ue,onNodesChange:Qt,onEdgesChange:Br,snapToGrid:R,snapGrid:ee,connectionMode:F,translateExtent:gt,connectOnClick:Vm,defaultEdgeOptions:jm,fitView:Rl,fitViewOptions:ec,onNodesDelete:q,onEdgesDelete:A,onDelete:H,onNodeDragStart:P,onNodeDrag:T,onNodeDragStop:z,onSelectionDrag:S,onSelectionDragStart:C,onSelectionDragStop:N,onMove:u,onMoveStart:f,onMoveEnd:h,noPanClassName:Ql,nodeOrigin:$e,rfId:Hr,autoPanOnConnect:Km,autoPanOnNodeDrag:Zm,autoPanSpeed:Jm,onError:ey,connectionRadius:Qm,isValidConnection:Rm,selectNodesOnDrag:ne,nodeDragThreshold:ny,connectionDragThreshold:oy,onBeforeDelete:Y,debug:cy,ariaLabelConfig:dy,zIndexMode:rc}),a.jsx(Y0,{onInit:c,onNodeClick:l,onEdgeClick:d,onNodeMouseEnter:_,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:D,onNodeDoubleClick:M,nodeTypes:i,edgeTypes:s,connectionLineType:X,connectionLineStyle:G,connectionLineComponent:Z,connectionLineContainerStyle:U,selectionKeyCode:re,selectionOnDrag:$,selectionMode:L,deleteKeyCode:te,multiSelectionKeyCode:K,panActivationKeyCode:V,zoomActivationKeyCode:W,onlyRenderVisibleElements:le,defaultViewport:He,translateExtent:gt,minZoom:et,maxZoom:je,preventScrolling:mt,zoomOnScroll:Ke,zoomOnPinch:Zt,zoomOnDoubleClick:yt,panOnScroll:Jt,panOnScrollSpeed:Le,panOnScrollMode:Mo,panOnDrag:bt,onPaneClick:tt,onPaneMouseEnter:Po,onPaneMouseMove:Pn,onPaneMouseLeave:B,onPaneScroll:J,onPaneContextMenu:ie,paneClickDistance:oe,nodeClickDistance:Q,onSelectionContextMenu:k,onSelectionStart:I,onSelectionEnd:O,onReconnect:me,onReconnectStart:fe,onReconnectEnd:ve,onEdgeContextMenu:ge,onEdgeDoubleClick:_e,onEdgeMouseEnter:Ce,onEdgeMouseMove:ze,onEdgeMouseLeave:vt,reconnectRadius:nt,defaultMarkerColor:Ge,noDragClassName:Do,noWheelClassName:Xm,noPanClassName:Ql,rfId:Hr,disableKeyboardA11y:tc,nodeExtent:Ue,viewport:ry,onViewportChange:iy}),a.jsx(xg,{onSelectionChange:j}),ce,a.jsx(mg,{proOptions:qm,position:Wm}),a.jsx(gg,{rfId:Hr,disableKeyboardA11y:tc})]})})}var U0=tl(j0);function G0(e){const[t,n]=E.useState(e),o=E.useCallback(r=>n(i=>Za(r,i)),[]);return[t,n,o]}function K0(e){const[t,n]=E.useState(e),o=E.useCallback(r=>n(i=>Ja(r,i)),[]);return[t,n,o]}function Z0({dimensions:e,lineWidth:t,variant:n,className:o}){return a.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Ee(["react-flow__background-pattern",n,o])})}function J0({radius:e,className:t}){return a.jsx("circle",{cx:e,cy:e,r:e,className:Ee(["react-flow__background-pattern","dots",t])})}var ht;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ht||(ht={}));const Q0={[ht.Dots]:1,[ht.Lines]:1,[ht.Cross]:6},R0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function zl({id:e,variant:t=ht.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:l,style:d,className:c,patternClassName:u}){const f=E.useRef(null),{transform:h,patternId:g}=pe(R0,we),p=o||Q0[t],b=t===ht.Dots,v=t===ht.Cross,w=Array.isArray(n)?n:[n,n],_=[w[0]*h[2]||1,w[1]*h[2]||1],y=p*h[2],x=Array.isArray(i)?i:[i,i],D=v?[y,y]:_,M=[x[0]*h[2]||1+D[0]/2,x[1]*h[2]||1+D[1]/2],P=`${g}${e||""}`;return a.jsxs("svg",{className:Ee(["react-flow__background",c]),style:{...d,..._o,"--xy-background-color-props":l,"--xy-background-pattern-color-props":s},ref:f,"data-testid":"rf__background",children:[a.jsx("pattern",{id:P,x:h[0]%_[0],y:h[1]%_[1],width:_[0],height:_[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${M[0]},-${M[1]})`,children:b?a.jsx(J0,{radius:y/2,className:u}):a.jsx(Z0,{dimensions:D,lineWidth:r,variant:t,className:u})}),a.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}zl.displayName="Background";const em=E.memo(zl);function tm(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:a.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function nm(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:a.jsx("path",{d:"M0 0h32v4.2H0z"})})}function om(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:a.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function rm(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function im(){return a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:a.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function No({children:e,className:t,...n}){return a.jsx("button",{type:"button",className:Ee(["react-flow__controls-button",t]),...n,children:e})}const sm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Fl({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:d,className:c,children:u,position:f="bottom-left",orientation:h="vertical","aria-label":g}){const p=xe(),{isInteractive:b,minZoomReached:v,maxZoomReached:w,ariaLabelConfig:_}=pe(sm,we),{zoomIn:y,zoomOut:x,fitView:D}=Ar(),M=()=>{y(),i?.()},P=()=>{x(),s?.()},T=()=>{D(r),l?.()},z=()=>{p.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d?.(!b)},q=h==="horizontal"?"horizontal":"vertical";return a.jsxs(xo,{className:Ee(["react-flow__controls",q,c]),position:f,style:e,"data-testid":"rf__controls","aria-label":g??_["controls.ariaLabel"],children:[t&&a.jsxs(a.Fragment,{children:[a.jsx(No,{onClick:M,className:"react-flow__controls-zoomin",title:_["controls.zoomIn.ariaLabel"],"aria-label":_["controls.zoomIn.ariaLabel"],disabled:w,children:a.jsx(tm,{})}),a.jsx(No,{onClick:P,className:"react-flow__controls-zoomout",title:_["controls.zoomOut.ariaLabel"],"aria-label":_["controls.zoomOut.ariaLabel"],disabled:v,children:a.jsx(nm,{})})]}),n&&a.jsx(No,{className:"react-flow__controls-fitview",onClick:T,title:_["controls.fitView.ariaLabel"],"aria-label":_["controls.fitView.ariaLabel"],children:a.jsx(om,{})}),o&&a.jsx(No,{className:"react-flow__controls-interactive",onClick:z,title:_["controls.interactive.ariaLabel"],"aria-label":_["controls.interactive.ariaLabel"],children:b?a.jsx(im,{}):a.jsx(rm,{})}),u]})}Fl.displayName="Controls";const am=E.memo(Fl);function lm({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:l,strokeWidth:d,className:c,borderRadius:u,shapeRendering:f,selected:h,onClick:g}){const{background:p,backgroundColor:b}=i||{},v=s||p||b;return a.jsx("rect",{className:Ee(["react-flow__minimap-node",{selected:h},c]),x:t,y:n,rx:u,ry:u,width:o,height:r,style:{fill:v,stroke:l,strokeWidth:d},shapeRendering:f,onClick:g?w=>g(w,e):void 0})}const cm=E.memo(lm),dm=e=>e.nodes.map(t=>t.id),Fr=e=>e instanceof Function?e:()=>e;function um({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=cm,onClick:s}){const l=pe(dm,we),d=Fr(t),c=Fr(e),u=Fr(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return a.jsx(a.Fragment,{children:l.map(h=>a.jsx(hm,{id:h,nodeColorFunc:d,nodeStrokeColorFunc:c,nodeClassNameFunc:u,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:f},h))})}function fm({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:l,onClick:d}){const{node:c,x:u,y:f,width:h,height:g}=pe(p=>{const b=p.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const v=b.internals.userNode,{x:w,y:_}=b.internals.positionAbsolute,{width:y,height:x}=st(v);return{node:v,x:w,y:_,width:y,height:x}},we);return!c||c.hidden||!Ks(c)?null:a.jsx(l,{x:u,y:f,width:h,height:g,style:c.style,selected:!!c.selected,className:o(c),color:t(c),borderRadius:r,strokeColor:n(c),strokeWidth:i,shapeRendering:s,onClick:d,id:c.id})}const hm=E.memo(fm);var pm=E.memo(um);const gm=200,mm=150,ym=e=>!e.hidden,bm=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?js(_n(e.nodeLookup,{filter:ym}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},vm="react-flow__minimap-desc";function Bl({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:l,bgColor:d,maskColor:c,maskStrokeColor:u,maskStrokeWidth:f,position:h="bottom-right",onClick:g,onNodeClick:p,pannable:b=!1,zoomable:v=!1,ariaLabel:w,inversePan:_,zoomStep:y=1,offsetScale:x=5}){const D=xe(),M=E.useRef(null),{boundingRect:P,viewBB:T,rfId:z,panZoom:q,translateExtent:A,flowWidth:H,flowHeight:j,ariaLabelConfig:C}=pe(bm,we),S=e?.width??gm,N=e?.height??mm,k=P.width/S,I=P.height/N,O=Math.max(k,I),Y=O*S,F=O*N,X=x*O,G=P.x-(Y-P.width)/2-X,Z=P.y-(F-P.height)/2-X,U=Y+X*2,te=F+X*2,re=`${vm}-${z}`,$=E.useRef(0),L=E.useRef();$.current=O,E.useEffect(()=>{if(M.current&&q)return L.current=$p({domNode:M.current,panZoom:q,getTransform:()=>D.getState().transform,getViewScale:()=>$.current}),()=>{L.current?.destroy()}},[q]),E.useEffect(()=>{L.current?.update({translateExtent:A,width:H,height:j,inversePan:_,pannable:b,zoomStep:y,zoomable:v})},[b,v,_,y,A,H,j]);const V=g?R=>{const[ee,le]=L.current?.pointer(R)||[0,0];g(R,{x:ee,y:le})}:void 0,K=p?E.useCallback((R,ee)=>{const le=D.getState().nodeLookup.get(ee).internals.userNode;p(R,le)},[]):void 0,W=w??C["minimap.ariaLabel"];return a.jsx(xo,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*O:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:Ee(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:a.jsxs("svg",{width:S,height:N,viewBox:`${G} ${Z} ${U} ${te}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":re,ref:M,onClick:V,children:[W&&a.jsx("title",{id:re,children:W}),a.jsx(pm,{onClick:K,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:l}),a.jsx("path",{className:"react-flow__minimap-mask",d:`M${G-X},${Z-X}h${U+X*2}v${te+X*2}h${-U-X*2}z
15
+ M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Bl.displayName="MiniMap";const wm=E.memo(Bl),xm=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Sm={[Ut.Line]:"right",[Ut.Handle]:"bottom-right"};function _m({nodeId:e,position:t,variant:n=Ut.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:l=10,minHeight:d=10,maxWidth:c=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:h,autoScale:g=!0,shouldResize:p,onResizeStart:b,onResize:v,onResizeEnd:w}){const _=al(),y=typeof e=="string"?e:_,x=xe(),D=E.useRef(null),M=n===Ut.Handle,P=pe(E.useCallback(xm(M&&g),[M,g]),we),T=E.useRef(null),z=t??Sm[n];E.useEffect(()=>{if(!(!D.current||!y))return T.current||(T.current=Kp({domNode:D.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:A,transform:H,snapGrid:j,snapToGrid:C,nodeOrigin:S,domNode:N}=x.getState();return{nodeLookup:A,transform:H,snapGrid:j,snapToGrid:C,nodeOrigin:S,paneDomNode:N}},onChange:(A,H)=>{const{triggerNodeChanges:j,nodeLookup:C,parentLookup:S,nodeOrigin:N}=x.getState(),k=[],I={x:A.x,y:A.y},O=C.get(y);if(O&&O.expandParent&&O.parentId){const Y=O.origin??N,F=A.width??O.measured.width??0,X=A.height??O.measured.height??0,G={id:O.id,parentId:O.parentId,rect:{width:F,height:X,...Zs({x:A.x??O.position.x,y:A.y??O.position.y},{width:F,height:X},O.parentId,C,Y)}},Z=Er([G],C,S,N);k.push(...Z),I.x=A.x?Math.max(Y[0]*F,A.x):void 0,I.y=A.y?Math.max(Y[1]*X,A.y):void 0}if(I.x!==void 0&&I.y!==void 0){const Y={id:y,type:"position",position:{...I}};k.push(Y)}if(A.width!==void 0&&A.height!==void 0){const F={id:y,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};k.push(F)}for(const Y of H){const F={...Y,type:"position"};k.push(F)}j(k)},onEnd:({width:A,height:H})=>{const j={id:y,type:"dimensions",resizing:!1,dimensions:{width:A,height:H}};x.getState().triggerNodeChanges([j])}})),T.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:d,maxWidth:c,maxHeight:u},keepAspectRatio:f,resizeDirection:h,onResizeStart:b,onResize:v,onResizeEnd:w,shouldResize:p}),()=>{T.current?.destroy()}},[z,l,d,c,u,f,b,v,w,p]);const q=z.split("-");return a.jsx("div",{className:Ee(["react-flow__resize-control","nodrag",...q,n,o]),ref:D,style:{...r,scale:P,...s&&{[M?"backgroundColor":"borderColor"]:s}},children:i})}E.memo(_m);const Hl=e=>Symbol.iterator in e,Yl=e=>"entries"in e,Xl=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),o=t instanceof Map?t:new Map(t.entries());if(n.size!==o.size)return!1;for(const[r,i]of n)if(!o.has(r)||!Object.is(i,o.get(r)))return!1;return!0},Em=(e,t)=>{const n=e[Symbol.iterator](),o=t[Symbol.iterator]();let r=n.next(),i=o.next();for(;!r.done&&!i.done;){if(!Object.is(r.value,i.value))return!1;r=n.next(),i=o.next()}return!!r.done&&!!i.done};function Cm(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Hl(e)&&Hl(t)?Yl(e)&&Yl(t)?Xl(e,t):Em(e,t):Xl({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}const Vl={inlineScript:"内联脚本",dataRequest:"请求数据",external:"外部方法",builtin:"内置动作"},Nm=[{label:"Message 全局提示 (antd)",value:"antdMessage"}],km=[{label:"info",value:"info"},{label:"success",value:"success"},{label:"warning",value:"warning"},{label:"error",value:"error"},{label:"loading",value:"loading"}];function Wl(e,t,n){const o=n.filter(i=>i.target===e),r=o.length;return o.map((i,s)=>{const d=t.find(c=>c.id===i.source)?.data;return{sourceId:i.source,sourceLabel:d?.label??i.source,edgeIndex:s,totalIncoming:r}})}const Im={eventBlock:({data:e,id:t})=>{const n=pe(E.useCallback(i=>Wl(t,i.nodes,i.edges).map(({sourceId:s,sourceLabel:l})=>({sourceId:s,label:l})),[t]),Cm),o=e.eventBlock.executorType??"inlineScript",r=o==="dataRequest"?e.eventBlock.dataRequestKey:o==="external"?e.eventBlock.externalHandlerKey:o==="builtin"?e.eventBlock.builtinId==="antdMessage"?`${e.eventBlock.builtinId}: ${String(e.eventBlock.builtinConfig?.content??"").slice(0,24)}`:e.eventBlock.builtinId:null;return a.jsxs("div",{className:"bg-white border-2 border-blue-500 rounded-lg p-3 min-w-[180px] shadow-md",children:[a.jsx(Kt,{type:"target",position:ae.Top,className:"!bg-blue-500"}),a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium text-sm truncate",children:e.label}),a.jsxs(m.Space,{size:"small",children:[a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.EditOutlined,{}),onClick:()=>e.onEdit(t)}),a.jsx(m.Button,{type:"text",size:"small",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),onClick:()=>e.onDelete(t)})]})]}),a.jsx("div",{className:"text-xs mb-1",children:a.jsxs(m.Tag,{color:o==="inlineScript"?"default":o==="builtin"?"cyan":"purple",className:"!mr-0",children:[Vl[o],r?` · ${r}`:""]})}),a.jsxs("div",{className:"text-xs text-gray-500",children:[e.eventBlock.inputs?.length>0&&a.jsxs("div",{children:["入参名(按连线顺序): ",e.eventBlock.inputs.map(i=>i.name).join(", ")]}),n.length>0&&a.jsxs("div",{className:"mt-1 text-amber-800",children:["上游连线:",n.map(i=>a.jsxs("div",{className:"pl-1 border-l-2 border-amber-200",children:["←「",i.label,"」(整块返回值)"]},i.sourceId))]})]}),a.jsx(Kt,{type:"source",position:ae.Bottom,className:"!bg-blue-500"})]})}},Mm=Object.entries(Vl).map(([e,t])=>({label:t,value:e})),ql=[{label:"点击",value:"click"},{label:"鼠标按下",value:"mouseDown"},{label:"鼠标释放",value:"mouseUp"},{label:"双击",value:"doubleClick"},{label:"鼠标移入",value:"mouseOver"},{label:"鼠标移出",value:"mouseLeave"},{label:"鼠标进入",value:"mouseEnter"},{label:"右键菜单",value:"contextMenu"},{label:"数据请求",value:"dataRequest"},{label:"外部事件",value:"external"}];function Pm(e,t){const n={},o=[...e];return o.forEach((r,i)=>{const s=t.inputs[i]?.name??(o.length===1?"prev":`prev${i}`);n[s]=`$prev.${r.source}`}),n}function Dm(e,t,n){return n[e]?.name??(t===1?"prev":`prev${e}`)}const Tm=[{label:"string",value:"string"},{label:"number",value:"number"},{label:"boolean",value:"boolean"},{label:"object",value:"object"},{label:"any",value:"any"}];function jl(e){const n=ql.find(o=>o.value===e.eventType)?.label??e.eventType;if(e.eventType==="external"){const o=(e.externalEventKey||"").trim();return o?`${n} · ${o}`:n}return n}const Om=({open:e,onClose:t,bindNodeId:n})=>{const{nodes:o,eventFlow:r,addEventBlock:i,upsertEventBlock:s,removeEventBlock:l,addEventRoot:d,updateEventRoot:c}=Ie(),[u,f,h]=G0([]),[g,p,b]=K0([]),v=E.useRef(u);v.current=u;const[w,_]=E.useState(null),[y,x]=E.useState(!1),[D]=m.Form.useForm(),M=m.Form.useWatch("eventType",D),[P,T]=E.useState(null),[z,q]=E.useState(!1),[A]=m.Form.useForm(),H=m.Form.useWatch("executorType",A),j=m.Form.useWatch("builtinId",A),C=m.Form.useWatch("inputs",A),S=E.useMemo(()=>!z||!P?[]:Wl(P.id,u,g),[z,P,u,g]),N=E.useRef(()=>{}),k=E.useRef(()=>{});E.useEffect(()=>{if(z&&P){const $=P.builtinConfig??{},{outputs:L,...V}=P;A.setFieldsValue({...V,executorType:P.executorType??"inlineScript",builtinId:P.builtinId,inputs:P.inputs??[],builtinConfig:{content:String($.content??""),level:String($.level??"info"),duration:$.duration===void 0||$.duration===null?void 0:Number($.duration)}})}},[z,P,A]);const I=E.useCallback($=>{p(L=>sa($,L))},[p]),O=$=>{const L={bindNodeId:$.bindNodeId,eventType:$.eventType,externalEventKey:$.eventType==="external"?($.externalEventKey||"").trim():void 0,flowData:{nodes:[],edges:[]},enabled:!0},V=d(L);_({...L,id:V}),D.resetFields(),x(!1),m.message.success("事件流创建成功")},Y=E.useCallback($=>{l($),f(L=>L.filter(V=>V.id!==$)),p(L=>L.filter(V=>V.source!==$&&V.target!==$))},[l,f,p]),F=E.useCallback($=>{const L=v.current.find(W=>W.id===$)?.data?.eventBlock,V=r.eventBlocks.find(W=>W.id===$),K=L??V;K?(T({...K,id:$}),q(!0)):m.message.warning("找不到事件块")},[r.eventBlocks]);N.current=F,k.current=Y,E.useEffect(()=>{if(e&&w){const $=w.flowData.nodes.map(V=>({id:V.id,type:"eventBlock",position:V.position,data:{label:V.data.label,eventBlock:V.data.eventBlock,onEdit:K=>N.current(K),onDelete:K=>k.current(K)}})),L=w.flowData.edges.map(V=>({id:V.id,source:V.source,target:V.target}));f($),p(L)}},[e,w,f,p]);const X=()=>{const $={name:"新事件块",executorType:"inlineScript",callback:"return args;",inputs:[],outputs:[]},L=i($),V={...$,id:L},K={id:L,type:"eventBlock",position:{x:100+u.length*50,y:100+u.length*30},data:{label:V.name,eventBlock:V,onEdit:W=>N.current(W),onDelete:W=>k.current(W)}};f(W=>[...W,K])},G=()=>{const $={name:"Message 提示",executorType:"builtin",builtinId:"antdMessage",builtinConfig:{content:"操作成功",level:"info"},callback:"return null;",inputs:[],outputs:[]},L=i($),V={...$,id:L},K={id:L,type:"eventBlock",position:{x:120+u.length*50,y:140+u.length*30},data:{label:V.name,eventBlock:V,onEdit:W=>N.current(W),onDelete:W=>k.current(W)}};f(W=>[...W,K])},Z=$=>{if(!P)return;const L=$.executorType??P.executorType??"inlineScript",V={name:$.name,callback:$.callback??P.callback,executorType:L,dataRequestKey:L==="dataRequest"?($.dataRequestKey||"").trim():void 0,externalHandlerKey:L==="external"?($.externalHandlerKey||"").trim():void 0,builtinId:L==="builtin"?$.builtinId:void 0,builtinConfig:L==="builtin"&&$.builtinId==="antdMessage"?{content:String($.builtinConfig?.content??"").trim(),level:$.builtinConfig?.level||"info",duration:$.builtinConfig?.duration===null||$.builtinConfig?.duration===void 0?void 0:Number($.builtinConfig.duration)}:void 0},W=($.inputs??[]).filter(ee=>ee?.name&&String(ee.name).trim()),R={...P,...V,inputs:W,outputs:[]};s(R),f(ee=>ee.map(le=>le.id===P.id?{...le,data:{...le.data,label:R.name||le.data.label,eventBlock:R}}:le)),q(!1),T(null),m.message.success("事件块已更新")},U=()=>{if(!w)return;const $=u.map(V=>{const K=g.filter(ee=>ee.target===V.id),R={...V.data.eventBlock,outputs:[]};return{id:V.id,eventBlockId:V.id,position:V.position,inputs:K.map(ee=>ee.source),outputs:g.filter(ee=>ee.source===V.id).map(ee=>ee.target),data:{label:V.data.label,eventBlock:R,inputMapping:Pm(K,R)}}}),L=g.map(V=>({id:V.id,source:V.source,target:V.target}));c(w.id,{flowData:{nodes:$,edges:L}}),ln.bindNodeEvent({...w,flowData:{nodes:$,edges:L}}),m.message.success("事件流保存成功"),t()},te=E.useMemo(()=>o.map($=>({label:$.name,value:$.id})),[o]),re=E.useMemo(()=>n?r.eventRoots.filter($=>$.bindNodeId===n):r.eventRoots,[r.eventRoots,n]);return e?a.jsxs(m.Modal,{title:"事件流编辑器",open:e,onCancel:t,width:1200,footer:null,styles:{body:{height:700,padding:0}},children:[w?a.jsxs("div",{className:"h-full flex flex-col",style:{height:700},children:[a.jsxs("div",{className:"h-12 border-b border-gray-200 flex items-center justify-between px-4 bg-gray-50",children:[a.jsx(m.Space,{children:a.jsxs("span",{className:"font-medium",children:["编辑: ",jl(w)," →"," ",o.find($=>$.id===w.bindNodeId)?.name]})}),a.jsxs(m.Space,{children:[a.jsx(m.Button,{icon:a.jsx(se.PlusOutlined,{}),onClick:X,children:"添加事件块"}),a.jsx(m.Button,{icon:a.jsx(se.PlusOutlined,{}),onClick:G,children:"Message 提示"}),a.jsx(m.Button,{type:"primary",icon:a.jsx(se.SaveOutlined,{}),onClick:U,children:"保存"}),a.jsx(m.Button,{icon:a.jsx(se.CloseOutlined,{}),onClick:()=>_(null),children:"返回列表"})]})]}),a.jsx("div",{className:"flex-1",children:a.jsxs(U0,{nodes:u,edges:g,onNodesChange:h,onEdgesChange:b,onConnect:I,nodeTypes:Im,fitView:!0,children:[a.jsx(em,{}),a.jsx(am,{}),a.jsx(wm,{})]})})]}):a.jsxs("div",{className:"p-6",children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsx("h3",{className:"text-lg font-medium",children:"选择或创建事件流"}),a.jsx(m.Button,{type:"primary",icon:a.jsx(se.PlusOutlined,{}),onClick:()=>x(!0),children:"新建事件流"})]}),a.jsx(m.List,{dataSource:re,renderItem:$=>a.jsx(m.List.Item,{actions:[a.jsx(m.Button,{type:"primary",icon:a.jsx(se.EditOutlined,{}),onClick:()=>_($),children:"编辑"},"edit")],children:a.jsx(m.List.Item.Meta,{title:a.jsxs(m.Space,{children:[a.jsxs("span",{children:["触发: ",jl($)]}),a.jsx(m.Tag,{color:"blue",children:o.find(L=>L.id===$.bindNodeId)?.name||$.bindNodeId})]}),description:`节点数: ${$.flowData.nodes.length}, 连接数: ${$.flowData.edges.length}`})}),locale:{emptyText:a.jsx(m.Empty,{description:"暂无事件流"})}}),a.jsx(m.Modal,{title:"新建事件流",open:y,onCancel:()=>{D.resetFields(),x(!1)},footer:null,afterOpenChange:$=>{$&&(D.resetFields(),n&&D.setFieldsValue({bindNodeId:n}))},children:a.jsxs(m.Form,{form:D,onFinish:O,layout:"vertical",children:[a.jsx(m.Form.Item,{name:"bindNodeId",label:"绑定节点",rules:[{required:!0,message:"请选择节点"}],initialValue:n,children:a.jsx(m.Select,{options:te,placeholder:"选择要绑定的节点",disabled:!!n})}),a.jsx(m.Form.Item,{name:"eventType",label:"触发方式",rules:[{required:!0,message:"请选择触发方式"}],children:a.jsx(m.Select,{options:ql,placeholder:"DOM / 数据请求 / 外部"})}),M==="external"&&a.jsx(m.Form.Item,{name:"externalEventKey",label:"外部事件标识",rules:[{required:!0,message:"请填写外部事件标识"},{validator:($,L)=>(L||"").trim()?Promise.resolve():Promise.reject(new Error("标识不能为空"))}],extra:"与 eventBus.emitExternal(节点id, 该标识) 一致",children:a.jsx(m.Input,{placeholder:"例如:refresh"})}),a.jsx(m.Form.Item,{className:"mb-0",children:a.jsxs(m.Space,{className:"w-full justify-end",children:[a.jsx(m.Button,{onClick:()=>{D.resetFields(),x(!1)},children:"取消"}),a.jsx(m.Button,{type:"primary",htmlType:"submit",children:"创建"})]})})]})})]}),a.jsx(m.Modal,{title:"编辑事件块",open:z,onCancel:()=>{q(!1),T(null)},footer:null,destroyOnClose:!0,children:a.jsxs(m.Form,{form:A,onFinish:Z,layout:"vertical",children:[a.jsx(m.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"请填写名称"}],children:a.jsx(m.Input,{})}),a.jsx(m.Form.Item,{name:"executorType",label:"执行方式",rules:[{required:!0,message:"请选择执行方式"}],children:a.jsx(m.Select,{options:Mm,placeholder:"不同方式对应下方不同配置项"})}),H==="builtin"&&a.jsx(m.Form.Item,{name:"builtinId",label:"内置动作",rules:[{required:!0,message:"请选择内置动作"}],children:a.jsx(m.Select,{options:Nm,placeholder:"选择具体内置能力"})}),H==="builtin"&&j==="antdMessage"&&a.jsxs(a.Fragment,{children:[a.jsx(m.Form.Item,{name:["builtinConfig","content"],label:"提示内容",rules:[{required:!0,message:"请填写提示内容"}],extra:"占位符:{{prev}}、{{入参名}} 引用上游连线入参;{{$data.xxx}} 取事件上下文 data",children:a.jsx(m.Input.TextArea,{rows:3,placeholder:"例如:保存成功 或 结果:{{prev}}"})}),a.jsx(m.Form.Item,{name:["builtinConfig","level"],label:"状态 (type)",children:a.jsx(m.Select,{options:km})}),a.jsx(m.Form.Item,{name:["builtinConfig","duration"],label:"持续时间(秒)",extra:"留空使用 antd 默认;填 0 表示不自动关闭",children:a.jsx(m.InputNumber,{min:0,step:.5,style:{width:"100%"},placeholder:"默认"})})]}),H==="dataRequest"&&a.jsx(m.Form.Item,{name:"dataRequestKey",label:"请求标识",rules:[{required:!0,message:"请填写请求标识"},{validator:($,L)=>(L||"").trim()?Promise.resolve():Promise.reject(new Error("标识不能为空"))}],extra:"运行时 eventBus.setDefaultRuntimeHandlers({ dataRequest: { [标识]: (ctx, args) => ... } })",children:a.jsx(m.Input,{placeholder:"例如:loadTrend、fetchDeviceList"})}),H==="external"&&a.jsx(m.Form.Item,{name:"externalHandlerKey",label:"外部方法标识",rules:[{required:!0,message:"请填写外部方法标识"},{validator:($,L)=>(L||"").trim()?Promise.resolve():Promise.reject(new Error("标识不能为空"))}],extra:"运行时 eventBus.setDefaultRuntimeHandlers({ external: { [标识]: (ctx, args) => ... } })",children:a.jsx(m.Input,{placeholder:"例如:openDialog、navigateTo"})}),H==="inlineScript"&&a.jsx(m.Form.Item,{name:"callback",label:"执行代码",rules:[{validator:($,L)=>typeof L=="string"&&L.trim()?Promise.resolve():Promise.reject(new Error("请填写执行代码"))}],children:a.jsx(m.Input.TextArea,{rows:6,placeholder:`// 可用参数:
16
+ // node - 触发事件的节点
17
+ // context - 事件上下文
18
+ // args - 传入的参数
19
+
20
+ return args;`})}),S.length>0&&a.jsxs("div",{className:"mb-4 p-3 bg-amber-50 rounded border border-amber-100 text-sm",children:[a.jsx("div",{className:"font-medium text-amber-950 mb-2",children:"上游连线 → 本块 args 键名"}),a.jsx("ul",{className:"list-none space-y-2 m-0 p-0",children:S.map($=>{const L=C??P?.inputs??[],V=Dm($.edgeIndex,$.totalIncoming,L);return a.jsxs("li",{className:"pl-2 border-l-2 border-amber-300",children:[a.jsxs("div",{className:"text-gray-800",children:["第 ",$.edgeIndex+1," 条入边 ←「",$.sourceLabel,"」:上游",a.jsx("strong",{children:"整块返回值"})," →"," ",a.jsxs("code",{className:"bg-white px-1 rounded",children:["args.",V]})]}),a.jsxs("div",{className:"text-gray-600 mt-0.5",children:["在下方第 ",$.edgeIndex+1," 行填写参数名即可自定义键名(须与入边顺序一致)。"]})]},$.sourceId)})})]}),a.jsx("div",{className:"font-medium text-gray-800 mb-2",children:"入参名称(按连线顺序)"}),a.jsxs("div",{className:"text-xs text-gray-500 mb-2",children:["第 1 行对应第 1 条指向本块的连线,第 2 行对应第 2 条……(顺序与画布连线添加顺序一致,先连在前)。不添加行时:单入边用"," ",a.jsx("code",{children:"args.prev"}),",多入边用 ",a.jsx("code",{children:"args.prev0"}),"、",a.jsx("code",{children:"args.prev1"}),"…"]}),a.jsx(m.Form.List,{name:"inputs",children:($,{add:L,remove:V})=>a.jsxs(a.Fragment,{children:[$.map(({key:K,name:W,...R})=>a.jsxs(m.Space,{align:"baseline",wrap:!0,className:"mb-2",children:[a.jsx(m.Form.Item,{...R,name:[W,"name"],rules:[{required:!0,message:"名称"}],children:a.jsx(m.Input,{placeholder:"参数名,如 A",style:{width:140}})}),a.jsx(m.Form.Item,{...R,name:[W,"type"],initialValue:"any",children:a.jsx(m.Select,{options:Tm,style:{width:100}})}),a.jsx(se.MinusCircleOutlined,{className:"text-gray-400 hover:text-red-500 cursor-pointer",onClick:()=>V(W)})]},K)),a.jsx(m.Button,{type:"dashed",onClick:()=>L({type:"any"}),block:!0,icon:a.jsx(se.PlusOutlined,{}),children:"添加入参行(第几个参数)"})]})}),a.jsx(m.Form.Item,{className:"mb-0 mt-4",children:a.jsxs(m.Space,{className:"w-full justify-end",children:[a.jsx(m.Button,{onClick:()=>{q(!1),T(null)},children:"取消"}),a.jsx(m.Button,{type:"primary",htmlType:"submit",children:"保存"})]})})]})})]}):null},ko={click:"点击",mouseDown:"鼠标按下",mouseUp:"鼠标释放",doubleClick:"双击",mouseOver:"鼠标移入",mouseLeave:"鼠标移出",mouseEnter:"鼠标进入",contextMenu:"右键菜单",dataRequest:"数据请求",external:"外部事件"};function Am(e){if(e.eventType==="external"){const t=(e.externalEventKey||"").trim();return t?`${ko.external} · ${t}`:ko.external}return ko[e.eventType]}const $m=Object.entries(ko).map(([e,t])=>({label:t,value:e})),Lm=({nodeId:e})=>{const{eventFlow:t,addEventRoot:n,updateEventRoot:o,removeEventRoot:r}=Ie(),[i,s]=E.useState(!1),[l,d]=E.useState(null),[c,u]=E.useState(!1),[f]=m.Form.useForm(),h=m.Form.useWatch("eventType",f),g=E.useMemo(()=>t.eventRoots.filter(_=>_.bindNodeId===e),[t.eventRoots,e]),p=_=>{const y={bindNodeId:e,eventType:_.eventType,externalEventKey:_.eventType==="external"?(_.externalEventKey||"").trim():void 0,flowData:{nodes:[],edges:[]},enabled:!0};n(y),f.resetFields(),u(!1)},b=_=>{d(_),s(!0)},v=(_,y)=>{o(_.id,{enabled:y})},w=_=>{r(_)};return a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between items-center mb-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"事件流绑定"}),a.jsx(m.Button,{type:"primary",size:"small",icon:a.jsx(se.PlusOutlined,{}),onClick:()=>u(!0),children:"添加事件流"})]}),a.jsx(m.List,{dataSource:g,renderItem:_=>a.jsx(m.List.Item,{actions:[a.jsx(m.Switch,{checked:_.enabled,size:"small",onChange:y=>v(_,y)},"enable"),a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.EditOutlined,{}),onClick:()=>b(_)},"edit"),a.jsx(m.Popconfirm,{title:"确认删除",description:"删除后无法恢复,是否继续?",onConfirm:()=>w(_.id),children:a.jsx(m.Button,{type:"text",danger:!0,size:"small",icon:a.jsx(se.DeleteOutlined,{})})},"delete")],children:a.jsx(m.List.Item.Meta,{title:a.jsxs(m.Space,{children:[a.jsx(m.Tag,{color:_.enabled?"blue":"default",children:Am(_)}),a.jsxs("span",{className:"text-xs text-gray-400",children:[_.flowData.nodes.length," 个节点"]})]}),description:_.enabled?a.jsx("span",{className:"text-xs text-green-600",children:"已启用"}):a.jsx("span",{className:"text-xs text-gray-400",children:"已禁用"})})}),locale:{emptyText:a.jsx(m.Empty,{image:m.Empty.PRESENTED_IMAGE_SIMPLE,description:"暂无事件流绑定"})}}),a.jsx(m.Modal,{title:"添加事件流",open:c,onCancel:()=>{f.resetFields(),u(!1)},footer:null,afterOpenChange:_=>{_&&f.resetFields()},children:a.jsxs(m.Form,{form:f,onFinish:p,layout:"vertical",children:[a.jsx(m.Form.Item,{name:"eventType",label:"触发方式",rules:[{required:!0,message:"请选择触发方式"}],children:a.jsx(m.Select,{options:$m,placeholder:"选择触发方式(DOM / 数据请求 / 外部)"})}),h==="external"&&a.jsx(m.Form.Item,{name:"externalEventKey",label:"外部事件标识",rules:[{required:!0,message:"请填写外部事件标识"},{validator:(_,y)=>(y||"").trim()?Promise.resolve():Promise.reject(new Error("标识不能为空"))}],extra:"与运行时 eventBus.emitExternal(节点id, 该标识) 一致,例如:refresh、dialog:opened",children:a.jsx(m.Input,{placeholder:"例如:refresh 或 parent:reload"})}),a.jsx(m.Form.Item,{className:"mb-0",children:a.jsxs(m.Space,{className:"w-full justify-end",children:[a.jsx(m.Button,{onClick:()=>u(!1),children:"取消"}),a.jsx(m.Button,{type:"primary",htmlType:"submit",children:"创建"})]})})]})}),a.jsx(Om,{open:i,onClose:()=>{s(!1),d(null)},bindNodeId:e})]})},{Panel:pt}=m.Collapse,{TabPane:Io}=m.Tabs,{TextArea:zm}=m.Input,Ul=({defaultTestData:e})=>{const{nodes:t,selectedNodeId:n,updateNode:o,updateNodeStyle:r,updateNodeControl:i,updateNodeContent:s,materials:l,selectedStatusId:d,selectStatus:c}=Ie(),[u]=m.Form.useForm(),[f,h]=E.useState("basic"),[g,p]=E.useState(!1),[b,v]=E.useState(null),[w,_]=E.useState({}),y=E.useMemo(()=>t.find(S=>S.id===n),[t,n]),x=y?.contentInfo.statusList||[],D=S=>{n&&(S.normalStyle&&r(n,S.normalStyle),S.name!==void 0&&o(n,{name:S.name}),S.controlInfo&&i(n,S.controlInfo))};console.log(n,"selectedNodeId",y),E.useEffect(()=>{y&&y&&(u.setFieldsValue({name:y.name,normalStyle:{width:100,height:100,x:0,y:0,padding:8,background:"transparent",borderRadius:0,opacity:1,...y.normalStyle},controlInfo:{isDraggable:!0,isClickable:!0,isResizable:!0,isSelectable:!0,...y.controlInfo}}),c(null))},[y,c,u]);const M=()=>{!n||!y||(v("new"),p(!0))},P=S=>{if(!n||!y)return;const N={id:he.nanoid(),name:`${S.name}_状态${x.length+1}`,expression:x.length===0?"return true;":"return false;",material:{...S,id:he.nanoid()},boundDatasetId:null};if(b==="new"){const k=[...x,N];s(n,{statusList:k})}else if(b){const k=x.map(I=>I.id===b?{...I,material:{...S,id:he.nanoid()}}:I);s(n,{statusList:k})}p(!1),v(null)},T=S=>{if(!n||!y)return;const N=y.contentInfo.statusList?.filter(k=>k.id!==S)||[];s(n,{statusList:N}),d===S&&c(null)},z=(S,N)=>{if(!n||!y)return;const k=y.contentInfo.statusList?.map(I=>I.id===S?{...I,...N}:I)||[];s(n,{statusList:k})},q=S=>{if(!n||!y)return;const N={...S,id:he.nanoid(),name:`${S.name}_复制`,expression:"return false;"},k=[...x,N];s(n,{statusList:k})},A=(S,N)=>{if(!n||!y)return;const k=x.findIndex(O=>O.id===S);if(k===-1)return;const I=[...x];N==="up"&&k>0?[I[k],I[k-1]]=[I[k-1],I[k]]:N==="down"&&k<I.length-1&&([I[k],I[k+1]]=[I[k+1],I[k]]),s(n,{statusList:I})},H=S=>{v(S),p(!0)},j=(S,N)=>{const k=N.config||{},I=k.startX??0,O=k.startY??0,Y=k.endX??100,F=k.endY??0,X=Math.max((k.lineWeight||k.thickness||2)*2,4),G=Math.min(I,Y),Z=Math.min(O,F),U=Math.max(I,Y),te=Math.max(O,F),re=Math.max(U-G,X),$=Math.max(te-Z,X),L=S.normalStyle.x||0,V=S.normalStyle.y||0;return{material:{...N,config:{...k,startX:I-G,startY:O-Z,endX:Y-G,endY:F-Z}},box:{x:L+G,y:V+Z,width:re,height:$}}},C=(S,N)=>{if(!n||!y)return;const{list:k,lineBox:I}=x.reduce((O,Y)=>{if(Y.id!==S)return O.list.push(Y),O;let F;if(Y.material.type==="LINE"&&"config"in N&&N.config!==void 0){const X=Y.material,G=N.config;F={...X,...N,config:{...X.config||{},...G}}}else F={...Y.material,...N};if(F.type==="LINE"){const{material:X,box:G}=j(y,F);return O.list.push({...Y,material:X}),O.lineBox=G,O}return O.list.push({...Y,material:F}),O},{list:[],lineBox:null});I!==null?o(n,{normalStyle:{...y.normalStyle,x:I.x,y:I.y,width:I.width,height:I.height},contentInfo:{...y.contentInfo,statusList:k}}):s(n,{statusList:k})};return y?a.jsxs("div",{className:"h-full flex flex-col bg-white border-l border-gray-200",children:[a.jsxs("div",{className:"p-4 border-b border-gray-200",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-800",children:"属性面板"}),a.jsx("p",{className:"text-sm text-gray-500",children:"编辑选中节点的属性"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:a.jsxs(m.Tabs,{activeKey:f,onChange:h,children:[a.jsx(Io,{tab:"基础",children:a.jsxs(m.Form,{form:u,layout:"vertical",onValuesChange:D,initialValues:{name:y.name},children:[a.jsx(m.Form.Item,{label:"节点名称",name:"name",children:a.jsx(m.Input,{placeholder:"输入节点名称"})}),a.jsxs(m.Collapse,{ghost:!0,defaultActiveKey:["position","size","style"],children:[a.jsx(pt,{header:"位置",children:a.jsxs(m.Space,{children:[a.jsx(m.Form.Item,{label:"X",name:["normalStyle","x"],children:a.jsx(m.InputNumber,{})}),a.jsx(m.Form.Item,{label:"Y",name:["normalStyle","y"],children:a.jsx(m.InputNumber,{})})]})},"position"),a.jsx(pt,{header:"尺寸",children:a.jsxs(m.Space,{children:[a.jsx(m.Form.Item,{label:"宽度",name:["normalStyle","width"],children:a.jsx(m.InputNumber,{min:10})}),a.jsx(m.Form.Item,{label:"高度",name:["normalStyle","height"],children:a.jsx(m.InputNumber,{min:10})})]})},"size"),a.jsxs(pt,{header:"样式",children:[a.jsx(m.Form.Item,{label:"背景色",name:["normalStyle","background"],children:a.jsx(m.Input,{placeholder:"transparent, #fff, url(...)"})}),a.jsx(m.Form.Item,{label:"内边距",name:["normalStyle","padding"],children:a.jsx(m.InputNumber,{min:0})}),a.jsx(m.Form.Item,{label:"圆角",name:["normalStyle","borderRadius"],children:a.jsx(m.InputNumber,{min:0})}),a.jsx(m.Form.Item,{label:"缩放比例",name:["normalStyle","scale"],help:"等比缩放节点的宽高",children:a.jsx(m.InputNumber,{min:.1,max:5,step:.1})}),a.jsx(m.Form.Item,{label:"旋转角度",name:["normalStyle","rotate"],help:"顺时针旋转角度(度)",children:a.jsx(m.InputNumber,{min:0,max:360,step:1})}),a.jsx(m.Form.Item,{label:"透明度",name:["normalStyle","opacity"],children:a.jsx(m.InputNumber,{min:0,max:1,step:.1})}),a.jsx(m.Form.Item,{label:"层级",name:["normalStyle","zIndex"],children:a.jsx(m.InputNumber,{})})]},"style")]})]})},"basic"),a.jsx(Io,{tab:"状态",children:y.type==="group"&&y.children?a.jsx(bd,{node:y,updateNode:o,materials:l}):a.jsxs("div",{className:"mb-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:"font-medium",children:["状态列表",a.jsx(m.Tag,{color:"blue",className:"ml-2",children:x.length})]}),a.jsx(m.Button,{type:"primary",size:"small",icon:a.jsx(se.PlusOutlined,{}),onClick:M,children:"添加状态"})]}),a.jsx("p",{className:"text-xs text-gray-500 mb-3",children:"节点根据状态表达式计算结果显示对应物料,第一个返回 true 的状态为当前状态"}),x.length>0&&a.jsx("div",{className:"mb-4 p-3 bg-blue-50 border border-blue-200 rounded-lg",children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-gray-600",children:"当前状态:"}),a.jsx("span",{className:"ml-2 text-sm font-medium text-blue-600",children:"由表达式自动计算"})]})})}),x.length===0?a.jsx("div",{className:"text-center text-gray-400 py-4 bg-gray-50 rounded-lg",children:"暂无状态,点击上方按钮添加"}):a.jsx(m.Collapse,{ghost:!0,defaultActiveKey:x[0]?.id+n,children:x.map((S,N)=>a.jsx(pt,{header:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-gray-400 w-5",children:N+1}),a.jsx("span",{className:"font-medium",children:S.name}),a.jsx(m.Tag,{color:"default",className:"text-xs",children:S.material.type})]}),extra:a.jsxs(m.Space,{size:"small",onClick:k=>k.stopPropagation(),children:[a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.ArrowUpOutlined,{}),disabled:N===0,onClick:k=>{k.stopPropagation(),A(S.id,"up")}}),a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.ArrowDownOutlined,{}),disabled:N===x.length-1,onClick:k=>{k.stopPropagation(),A(S.id,"down")}}),a.jsx(m.Button,{type:"text",size:"small",icon:a.jsx(se.CopyOutlined,{}),onClick:k=>{k.stopPropagation(),q(S)}}),a.jsx(m.Button,{type:"text",size:"small",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),onClick:k=>{k.stopPropagation(),T(S.id)}})]}),children:a.jsxs(m.Form,{layout:"vertical",children:[a.jsx(m.Form.Item,{label:"状态名称",children:a.jsx(m.Input,{value:S.name,onChange:k=>z(S.id,{name:k.target.value}),placeholder:"输入状态名称"})}),a.jsx(Hi,{status:S,onUpdate:k=>z(S.id,k),onAppendToExpression:k=>{_(I=>({...I,[S.id]:(I[S.id]??S.expression)+k}))}}),a.jsx(m.Form.Item,{label:"执行表达式",help:"单参数 data(对象):由数据池 sample(若已绑定)与画布运行时数据合并;测点数组会按 paramsCode 写入 data。须 return true/false。",children:a.jsx(zm,{value:w[S.id]??S.expression,onChange:k=>_(I=>({...I,[S.id]:k.target.value})),onBlur:k=>{z(S.id,{expression:k.target.value}),_(I=>{const O={...I};return delete O[S.id],O})},rows:3,placeholder:"return true;"})}),a.jsx(m.Form.Item,{label:"绑定物料",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(m.Tag,{color:"blue",children:S.material.name}),a.jsx(m.Tag,{color:"default",children:S.material.type}),a.jsx(m.Button,{type:"link",size:"small",icon:a.jsx(se.EditOutlined,{}),onClick:()=>H(S.id),children:"更换物料"})]})}),a.jsx(m.Divider,{style:{margin:"12px 0"}}),a.jsxs("div",{className:"bg-gray-50 rounded-lg p-3 border border-gray-200",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"text-sm font-medium",children:"物料属性"}),a.jsx(m.Tag,{children:S.material.name})]}),a.jsx(Yi,{material:S.material,onSave:k=>C(S.id,k),dataOptions:e||[]})]})]})},S.id+n))})]})},"status"),a.jsx(Io,{tab:"控制",children:a.jsxs(m.Form,{form:u,layout:"vertical",onValuesChange:D,children:[a.jsx(m.Form.Item,{label:"可拖拽",name:["controlInfo","isDraggable"],valuePropName:"checked",children:a.jsx(m.Switch,{})}),a.jsx(m.Form.Item,{label:"可点击",name:["controlInfo","isClickable"],valuePropName:"checked",children:a.jsx(m.Switch,{})}),a.jsx(m.Form.Item,{label:"可调整大小",name:["controlInfo","isResizable"],valuePropName:"checked",children:a.jsx(m.Switch,{})}),a.jsx(m.Form.Item,{label:"可选中",name:["controlInfo","isSelectable"],valuePropName:"checked",children:a.jsx(m.Switch,{})})]})},"control"),a.jsx(Io,{tab:"事件流",children:a.jsx(Lm,{nodeId:y.id})},"eventflow")]})}),a.jsx("div",{className:"p-3 border-t border-gray-200 bg-gray-50",children:a.jsxs("div",{className:"text-xs text-gray-500",children:[a.jsxs("div",{children:["节点 ID: ",y.id.slice(0,8),"..."]}),a.jsxs("div",{children:["状态数: ",x.length]})]})}),a.jsx(m.Modal,{title:"选择物料",open:g,onCancel:()=>{p(!1),v(null)},footer:null,width:600,children:a.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:a.jsxs(m.Collapse,{ghost:!0,defaultActiveKey:["basic","device","text","line"],children:[a.jsx(pt,{header:"基础形状",children:a.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.filter(S=>["矩形","圆形","圆角矩形"].includes(S.name)).map(S=>a.jsx(Gl,{material:S,onClick:()=>P(S)},S.id))})},"basic"),a.jsx(pt,{header:"设备图标",children:a.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.filter(S=>["阀门","泵","罐体"].includes(S.name)||S.type==="IMAGE"&&!["矩形","圆形","圆角矩形"].includes(S.name)).map(S=>a.jsx(Gl,{material:S,onClick:()=>P(S)},S.id))})},"device"),a.jsx(pt,{header:"文本",children:a.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.filter(S=>S.type==="TEXT").map(S=>a.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>P(S),children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:a.jsx("span",{className:"text-lg font-bold text-gray-500",children:"T"})}),a.jsx("span",{className:"text-xs",children:S.name})]},S.id))})},"text"),a.jsx(pt,{header:"线条",children:a.jsx("div",{className:"grid grid-cols-4 gap-2",children:l.filter(S=>S.type==="LINE").map(S=>a.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:()=>P(S),children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center bg-gray-100 rounded",children:a.jsx("div",{className:"w-8 h-0.5 bg-gray-400"})}),a.jsx("span",{className:"text-xs",children:S.name})]},S.id))})},"line")]})})})]}):a.jsx("div",{className:"h-full flex items-center justify-center bg-white border-l border-gray-200",children:a.jsx(m.Empty,{description:"请选择一个节点"})})},Gl=({material:e,onClick:t})=>{const n=e.type==="IMAGE"?e.src:void 0;return a.jsxs("div",{className:"border rounded-lg p-2 cursor-pointer hover:border-blue-500 hover:bg-blue-50 transition-all text-center",onClick:t,children:[a.jsx("div",{className:"w-12 h-12 mx-auto mb-1 flex items-center justify-center",children:n?a.jsx("img",{src:n,alt:e.name,className:"w-10 h-10 object-contain"}):a.jsx("span",{className:"text-xs",children:e.name[0]})}),a.jsx("span",{className:"text-xs",children:e.name})]})},Fm={configEditor:"ConfigEditor-module__configEditor__dinNG"},Kl=`{
21
+ "speed": 0,
22
+ "temp": 25,
23
+ "nested": { "x": 1 }
24
+ }`,Zl=({open:e,onClose:t})=>{const{dataPool:n,addDataPoolItem:o,updateDataPoolItem:r,removeDataPoolItem:i}=Ie(),[s]=m.Form.useForm(),[l,d]=E.useState(null);E.useEffect(()=>{e||(d(null),s.resetFields())},[e,s]);const c=()=>{d("__new__"),s.setFieldsValue({name:`数据集 ${n.length+1}`,sampleJson:Kl.trim()})},u=p=>{d(p.id),s.setFieldsValue({name:p.name,sampleJson:JSON.stringify(p.sample??{},null,2)})},f=p=>{const b=p.trim();if(!b)return{};const v=JSON.parse(b);if(v===null||typeof v!="object"||Array.isArray(v))throw new Error("sample 必须是 JSON 对象");return v},h=()=>{s.validateFields().then(p=>{let b;try{b=f(p.sampleJson)}catch(w){m.message.error(w instanceof Error?w.message:"sample JSON 无效");return}const v=p.name.trim();if(!v){m.message.error("请填写名称");return}l==="__new__"?(o({name:v,sample:b}),m.message.success("已添加")):l&&(r(l,{name:v,sample:b}),m.message.success("已保存")),d(null),s.resetFields()}).catch(()=>{})},g=[{title:"名称",dataIndex:"name",key:"name"},{title:"字段数",key:"keys",width:90,render:(p,b)=>Object.keys(b.sample||{}).length},{title:"操作",key:"actions",width:160,render:(p,b)=>a.jsxs(m.Space,{children:[a.jsx(m.Button,{type:"link",size:"small",icon:a.jsx(se.EditOutlined,{}),onClick:()=>u(b),children:"编辑"}),a.jsx(m.Popconfirm,{title:"删除该数据集?",description:"所有绑定此数据集的状态将自动解除绑定。",onConfirm:()=>{i(b.id),m.message.success("已删除,相关状态已解除数据集绑定")},children:a.jsx(m.Button,{type:"link",size:"small",danger:!0,icon:a.jsx(se.DeleteOutlined,{}),children:"删除"})})]})}];return a.jsxs(m.Modal,{title:"数据池(节点状态用)",open:e,onCancel:t,width:760,footer:null,destroyOnClose:!0,children:[a.jsxs("p",{className:"text-sm text-gray-500 mb-3",children:["每个数据集是一个 JSON 对象模板(Record)。状态绑定后,表达式签名为"," ",a.jsx("code",{className:"bg-gray-100 px-1 rounded",children:"(data) => boolean"}),",预览时以模板为底合并画布「模拟数据」。"]}),a.jsx("div",{className:"mb-3",children:a.jsx(m.Button,{type:"primary",icon:a.jsx(se.PlusOutlined,{}),onClick:c,children:"新建数据集"})}),l&&a.jsxs("div",{className:"mb-4 p-3 border border-blue-200 rounded bg-blue-50/50",children:[a.jsxs("div",{className:"font-medium mb-2",children:[l==="__new__"?"新建":"编辑","数据集"]}),a.jsxs(m.Form,{form:s,layout:"vertical",children:[a.jsx(m.Form.Item,{name:"name",label:"名称",rules:[{required:!0,message:"必填"}],children:a.jsx(m.Input,{placeholder:"如:电机测点集"})}),a.jsx(m.Form.Item,{name:"sampleJson",label:"示例数据(JSON 对象)",rules:[{required:!0,message:"必填"}],children:a.jsx(m.Input.TextArea,{rows:10,className:"font-mono text-sm",placeholder:Kl})}),a.jsxs(m.Space,{children:[a.jsx(m.Button,{type:"primary",onClick:h,children:"保存"}),a.jsx(m.Button,{onClick:()=>{d(null),s.resetFields()},children:"取消"})]})]})]}),a.jsx(m.Table,{size:"small",rowKey:"id",dataSource:n,columns:g,pagination:!1,locale:{emptyText:"暂无数据集,请点击「新建」"}})]})},{Header:Bm,Sider:Jl,Content:Hm}=m.Layout,Ym=({initialScheme:e,onChange:t,readonly:n=!1,headerExtra:o,className:r="",style:i,showHeader:s=!0,showMaterialPanel:l=!0,showPropertyPanel:d=!0,customMaterials:c})=>{const[u,f]=E.useState(!1),[h,g]=E.useState(!1),[p,b]=E.useState(""),[v,w]=E.useState([{paramsCode:"001",paramsName:"通频速度有效值",value:25,paramsUnit:"mm/s"},{paramsCode:"002",paramsName:"通频加速度有效值",value:1.5,paramsUnit:"m/s²"}]),{exportScheme:_,importScheme:y,nodes:x,materials:D,dataPool:M,eventFlow:P,root:T,addMaterial:z}=Ie();E.useRef(null);const q=E.useRef(!1);E.useEffect(()=>{q.current||(q.current=!0,D.length===0&&ai.forEach(S=>z(S)),c&&c.length>0&&c.forEach(S=>z(S)),e&&y(e))},[]),E.useEffect(()=>{if(t){const S=_();t(S)}},[x,D,M,P,T,t,_]);const A=E.useCallback(()=>{const S=_(),N=JSON.stringify(S,null,2),k="data:application/json;charset=utf-8,"+encodeURIComponent(N),I=`scheme_${Date.now()}.json`,O=document.createElement("a");O.setAttribute("href",k),O.setAttribute("download",I),O.click(),m.message.success("导出成功!")},[_]),H=E.useCallback(()=>{try{const S=JSON.parse(p);y(S),f(!1),b(""),m.message.success("导入成功!")}catch{m.message.error("JSON 格式错误,请检查输入")}},[p,y]),j=E.useCallback(S=>{const N=new FileReader;return N.onload=k=>{try{const I=k.target?.result,O=JSON.parse(I);y(O),m.message.success("导入成功!"),f(!1)}catch{m.message.error("文件格式错误")}},N.readAsText(S),!1},[y]),C=E.useCallback(()=>_(),[_]);return E.useImperativeHandle(E.useRef?.(),()=>({getScheme:C,exportScheme:_,importScheme:y}),[C,_,y]),a.jsx(m.ConfigProvider,{locale:gc,children:a.jsx("div",{className:Fm.configEditor,style:i,children:a.jsxs(m.Layout,{className:`h-full w-full overflow-hidden ${r}`,children:[s&&a.jsxs(Bm,{className:"bg-white border-b border-gray-200 px-4 flex items-center justify-between flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx("div",{className:"text-xl font-bold text-blue-600",children:"组态编辑器"}),a.jsxs("div",{className:"text-sm text-gray-500",children:[x.length," 个节点"]})]}),a.jsxs(m.Space,{children:[o,!n&&a.jsxs(a.Fragment,{children:[a.jsx(m.Tooltip,{title:"导出 JSON",children:a.jsx(m.Button,{icon:a.jsx(se.DownloadOutlined,{}),onClick:A,children:"导出"})}),a.jsx(m.Tooltip,{title:"导入 JSON",children:a.jsx(m.Button,{icon:a.jsx(se.UploadOutlined,{}),onClick:()=>f(!0),children:"导入"})}),a.jsx(m.Tooltip,{title:"节点状态用的数据集(与事件流无关)",children:a.jsx(m.Button,{icon:a.jsx(se.DatabaseOutlined,{}),onClick:()=>g(!0),children:"数据池"})})]})]})]}),a.jsxs(m.Layout,{children:[l&&!n&&a.jsx(Jl,{width:280,className:"bg-white",theme:"light",children:a.jsx(ci,{})}),a.jsx(Hm,{className:"bg-gray-100 relative",children:a.jsx(Bi,{defaultTestData:v})}),d&&!n&&a.jsx(Jl,{width:360,className:"bg-white",theme:"light",children:a.jsx(Ul,{defaultTestData:v})})]}),a.jsx(Zl,{open:h,onClose:()=>g(!1)}),a.jsx(m.Modal,{title:"导入组态方案",open:u,onOk:H,onCancel:()=>{f(!1),b("")},width:600,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"mb-2",children:"选择 JSON 文件导入:"}),a.jsx("input",{type:"file",accept:".json",onChange:S=>{const N=S.target.files?.[0];N&&j(N)},className:`block w-full text-sm text-gray-500
8
25
  file:mr-4 file:py-2 file:px-4
9
26
  file:rounded-full file:border-0
10
27
  file:text-sm file:font-semibold
11
28
  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:j=>E(j.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=ft,R.ConfigEditor=Qt,R.MaterialPanel=ut,R.NodeRenderer=He,R.PropertyPanel=mt,R.createDefaultNode=ht,R.createDefaultStatus=qe,R.initMaterials=dt,R.useEditorStore=me,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
29
+ hover:file:bg-blue-100`})]}),a.jsx("div",{className:"text-center text-gray-400",children:"或"}),a.jsxs("div",{children:[a.jsx("p",{className:"mb-2",children:"粘贴 JSON 内容:"}),a.jsx("textarea",{value:p,onChange:S=>b(S.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"})]})]})})]})})})};be.Canvas=Bi,be.ConfigEditor=Ym,be.DataPoolModal=Zl,be.EventFlowBinding=Li,be.MaterialPanel=ci,be.NodeRenderer=jo,be.PropertyPanel=Ul,be.buildMergedDataRecord=ni,be.collectDatasetFieldPaths=ti,be.createDefaultNode=li,be.createDefaultStatus=zo,be.evaluateStatusExpression=$o,be.eventBus=ln,be.findActiveStatus=oi,be.initMaterials=ai,be.useEditorStore=Ie,Object.defineProperty(be,Symbol.toStringTag,{value:"Module"})}));
13
30
  //# sourceMappingURL=config-editor.umd.js.map