drawui-react 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -2
- package/dist/index.d.ts +10 -2
- package/dist/index.js +1 -1
- package/dist/styles.css +91 -0
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function U(){let[o,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),o}var so=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],lo="drawui:highlighterColor";function mt(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let o=window.localStorage.getItem(lo);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function co(o){if(!(typeof window>"u"))try{window.localStorage.setItem(lo,o);}catch{}}var po="drawui:stickyNoteColor";function bt(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let o=window.localStorage.getItem(po);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function ho(o){if(!(typeof window>"u"))try{window.localStorage.setItem(po,o);}catch{}}function dn({icon:o,size:e=24,ink:n=drawuiCore.ICON_DEFAULT_INK}){return jsxRuntime.jsxs("svg",{viewBox:`0 0 ${drawuiCore.ICON_GRID} ${drawuiCore.ICON_GRID}`,width:e,height:e,fill:"none","aria-hidden":"true",children:[o.disc&&jsxRuntime.jsx("circle",{cx:drawuiCore.ICON_GRID/2,cy:drawuiCore.ICON_GRID/2,r:drawuiCore.ICON_GRID/2-1,fill:o.disc}),o.layers.map((r,h)=>{let c=r.fill??"ink",a=r.stroke??"ink";return jsxRuntime.jsx("path",{d:r.d,fill:c==="none"?"none":c==="ink"?n:c,...a==="none"?{}:{stroke:a==="ink"?n:a,strokeWidth:r.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},h)}),o.label&&jsxRuntime.jsx("text",{x:drawuiCore.ICON_GRID/2,y:drawuiCore.ICON_GRID/2+.5,textAnchor:"middle",dominantBaseline:"central",fontFamily:"sans-serif",fontSize:o.label.size??13,fill:o.label.color,children:o.label.text})]})}var go="drawui:recentIcons",wo=12;function zt(o,e){let n=/^#?([0-9a-f]{6})$/i.exec(o.trim());if(!n)return o;let r=parseInt(n[1],16);return `rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${e})`}function un(){if(typeof window>"u")return [];try{let o=JSON.parse(window.localStorage.getItem(go)||"[]");return Array.isArray(o)?o.filter(e=>typeof e=="string").slice(0,wo):[]}catch{return []}}function pn(o){if(!(typeof window>"u"))try{window.localStorage.setItem(go,JSON.stringify(o));}catch{}}var bo=o=>({"--dw-icon-cat":o,"--dw-icon-cat-soft":zt(o,.12)}),vo=react.memo(function({onPick:e,onClose:n}){U();let[r,h]=react.useState(""),[c,a]=react.useState(drawuiCore.ICON_CATEGORIES[0].id),[l,S]=react.useState(un),g=react.useRef(null),p=react.useRef(null);react.useEffect(()=>{p.current?.focus();},[]),react.useEffect(()=>{let d=C=>{let Z=g.current;Z&&(Z.contains(C.target)||C.target?.closest?.("[data-icon-toggle]")||n());},E=C=>{C.key==="Escape"&&(C.stopPropagation(),n());};return window.addEventListener("pointerdown",d),window.addEventListener("keydown",E),()=>{window.removeEventListener("pointerdown",d),window.removeEventListener("keydown",E);}},[n]);let b=react.useMemo(()=>l.map(d=>drawuiCore.getIcon(d)).filter(d=>!!d),[l]),x=react.useMemo(()=>r.trim()?drawuiCore.searchIcons(r):c==="recent"?b:drawuiCore.iconsByCategory(c),[r,c,b]),N=c==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[c]??drawuiCore.ICON_DEFAULT_INK,K=r.trim()?drawuiCore.t("icon.search"):c==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(d=>d.id===c)?.labelKey??"icon.search"),I=d=>{e(d),S(E=>{let C=[d.id,...E.filter(Z=>Z!==d.id)].slice(0,wo);return pn(C),C});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:g,style:{"--dw-icon-accent":N,"--dw-icon-soft":zt(N,.08),"--dw-icon-ring":zt(N,.22)},children:[jsxRuntime.jsxs("label",{className:"drawui-icon-search",children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),jsxRuntime.jsx("path",{d:"M15.4 15.4L20 20"})]}),jsxRuntime.jsx("input",{ref:p,value:r,onChange:d=>h(d.target.value),onKeyDown:d=>{d.key==="Enter"&&x.length>0&&I(x[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:x.length})]}),!r.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[b.length>0&&jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${c==="recent"?" active":""}`,style:bo(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>a("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(d=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${c===d.id?" active":""}`,style:bo(drawuiCore.ICON_CATEGORY_INK[d.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>a(d.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(d.labelKey)]},d.id))]}),jsxRuntime.jsxs("div",{className:"drawui-icon-card",children:[jsxRuntime.jsxs("div",{className:"drawui-icon-card-head",children:[jsxRuntime.jsx("span",{className:"drawui-icon-card-title",children:K}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:x.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[x.map(d=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${d.zh} / ${d.en}`,"aria-label":`${d.zh} ${d.en}`,onClick:()=>I(d),children:jsxRuntime.jsx(dn,{icon:d,size:30,ink:drawuiCore.iconInk(d)})},d.id)),x.length===0&&jsxRuntime.jsx("div",{className:"drawui-icon-empty",children:drawuiCore.t("icon.empty")})]})]})]})});var Le=o=>`${o.x.toFixed(1)},${o.y.toFixed(1)}`,xo=(o,e)=>{let n=e*Math.PI/180;return {x:o.x*Math.cos(n)-o.y*Math.sin(n),y:o.x*Math.sin(n)+o.y*Math.cos(n)}},it={x:Math.SQRT1_2,y:-Math.SQRT1_2},_t={x:4.6,y:19.4},dt={x:19,y:5};function Wt(o,e,n){let r={x:-n.y,y:n.x},h=a=>({x:e.x-n.x*a,y:e.y-n.y*a}),c=(a,l)=>({x:a.x+r.x*l,y:a.y+r.y*l});switch(o){case "end":{let a=h(5.6);return jsxRuntime.jsx("polygon",{points:`${Le(e)} ${Le(c(a,2.7))} ${Le(c(a,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let a=h(8.6);return jsxRuntime.jsx("polygon",{points:`${Le(e)} ${Le(c(a,3.5))} ${Le(c(a,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let a=h(4.3),l=h(8.6);return jsxRuntime.jsx("polygon",{points:`${Le(e)} ${Le(c(a,2.7))} ${Le(l)} ${Le(c(a,-2.7))}`,fill:o==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let a=xo({x:-n.x,y:-n.y},30),l=xo({x:-n.x,y:-n.y},-30);return jsxRuntime.jsx("path",{d:`M ${Le({x:e.x+a.x*5.8,y:e.y+a.y*5.8})} L ${Le(e)} L ${Le({x:e.x+l.x*5.8,y:e.y+l.y*5.8})}`,fill:"none"})}default:return null}}function Ae(o,e){let n=e||o==="dependency"||o==="realization",r=n?{x:dt.x-it.x*8.6,y:dt.y-it.y*8.6}:dt,h={x:-it.x,y:-it.y};return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:_t.x,y1:_t.y,x2:r.x,y2:r.y,strokeDasharray:n?"3 2.6":void 0}),(o==="end"||o==="both")&&Wt("end",dt,it),(o==="start"||o==="both")&&Wt("end",_t,h),o!=="none"&&o!=="start"&&o!=="end"&&o!=="both"?Wt(o,dt,it):null]})}var wt=o=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:o})}),yn=[{type:"straight",labelKey:"style.connection.straight",icon:wt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:wt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:wt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:wt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],Co=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Ae("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Ae("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Ae("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Ae("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Ae("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Ae("both",true)}],So=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Ae("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Ae("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Ae("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Ae("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Ae("realization",true)}],ko=[...Co,...So];function fn(o,e){let n=ko.find(r=>r.arrowHead===o&&r.dashed===e);return n?n.key:ko.find(r=>r.arrowHead===o)?.key}var xt=react.memo(function({connectionType:e,arrowHead:n,dashed:r,onConnectionTypeChange:h,onArrowStyleChange:c,onOptionHover:a,onOptionLeave:l}){U();let S=fn(n,r),g=p=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:p.map(b=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${S===b.key?" active":""}`,onClick:()=>c(b),"data-drawui-tip":a?void 0:drawuiCore.t(b.labelKey),onMouseEnter:a?x=>a(b.labelKey,x.currentTarget):void 0,onMouseLeave:a?l:void 0,"aria-label":drawuiCore.t(b.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:b.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(b.labelKey)})]},b.key))});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:yn.map(p=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===p.type?" active":""}`,onClick:()=>h(p.type),"data-drawui-tip":a?void 0:drawuiCore.t(p.labelKey),onMouseEnter:a?b=>a(p.labelKey,b.currentTarget):void 0,onMouseLeave:a?l:void 0,"aria-label":drawuiCore.t(p.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:p.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(p.labelKey)})]},p.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),g(Co),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),g(So)]})});var Mo=[{type:"rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsxRuntime.jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsxRuntime.jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsxRuntime.jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsxRuntime.jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsxRuntime.jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsxRuntime.jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsxRuntime.jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsxRuntime.jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})},{type:"cylinder",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsxRuntime.jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon:jsxRuntime.jsx("path",{d:"M7 18.5h9.4a3.4 3.4 0 0 0 .3-6.8 5 5 0 0 0-9.5-1.2A3.9 3.9 0 0 0 7 18.5Z"})},{type:"heart",icon:jsxRuntime.jsx("path",{d:"M12 20.3S4.6 15.7 4.6 10.5A4.1 4.1 0 0 1 12 7.6a4.1 4.1 0 0 1 7.4 2.9c0 5.2-7.4 9.8-7.4 9.8Z"})},{type:"block-arrow-right",icon:jsxRuntime.jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsxRuntime.jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsxRuntime.jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsxRuntime.jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsxRuntime.jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsxRuntime.jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsxRuntime.jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsxRuntime.jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsxRuntime.jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsxRuntime.jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsxRuntime.jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsxRuntime.jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsxRuntime.jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsxRuntime.jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsxRuntime.jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsxRuntime.jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M1 1C3.9 1 5.1 2.4 5.1 5.1c0 3.7 1.2 6.9 2.9 6.9-1.7 0-2.9 3.2-2.9 6.9 0 2.7-1.2 4.1-4.1 4.1"}),jsxRuntime.jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M23 1c-2.9 0-4.1 1.4-4.1 4.1 0 3.7-1.2 6.9-2.9 6.9 1.7 0 2.9 3.2 2.9 6.9 0 2.7 1.2 4.1 4.1 4.1"}),jsxRuntime.jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsxRuntime.jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})},{type:"uml-interface",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})},{type:"class-catalog",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsxRuntime.jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),jsxRuntime.jsx("line",{x1:"17.4",y1:"5",x2:"17.4",y2:"19"})]})}],gn=[{key:"basic",labelKey:"shapeGroup.basic",items:[{type:"rectangle"},{type:"rounded-rectangle"},{type:"stadium"},{type:"circle"},{type:"ellipse"},{type:"diamond"},{type:"triangle"},{type:"right-triangle"},{type:"hexagon"},{type:"parallelogram"},{type:"trapezoid"},{type:"pentagon"},{type:"octagon"},{type:"star"},{type:"envelope"},{type:"checkbox"}]},{key:"flowchart",labelKey:"shapeGroup.flowchart",items:[{type:"rectangle",labelKey:"flow.process"},{type:"rounded-rectangle",labelKey:"flow.step"},{type:"stadium",labelKey:"flow.startEnd"},{type:"diamond",labelKey:"flow.decision"},{type:"parallelogram",labelKey:"flow.data"},{type:"trapezoid",labelKey:"flow.manual"},{type:"hexagon",labelKey:"flow.preparation"},{type:"cylinder",labelKey:"flow.database"},{type:"delay",labelKey:"flow.delay"},{type:"predefined-process"},{type:"document"},{type:"block-arrow-right"},{type:"block-arrow-left"},{type:"block-arrow-up"},{type:"block-arrow-down"},{type:"block-arrow-double"}]},{key:"uml",labelKey:"shapeGroup.uml",items:[{type:"uml-class"},{type:"uml-interface"},{type:"rounded-rectangle",labelKey:"class.plain"},{type:"class-catalog"}]},{key:"solid",labelKey:"shapeGroup.solid",items:[{type:"cylinder"},{type:"cube"},{type:"cuboid"},{type:"triangular-pyramid"},{type:"quadrangular-pyramid"},{type:"sphere"},{type:"ellipsoid"},{type:"pie"},{type:"hollow-pie"}]},{key:"other",labelKey:"shapeGroup.other",items:[{type:"cloud"},{type:"heart"},{type:"cross"},{type:"sector"},{type:"chevron"},{type:"speech-rect"},{type:"speech-round"},{type:"brace-left"},{type:"brace-right"}]}],wn=new Map(Mo.map(o=>[o.type,o.icon])),vn=new Set(Mo.map(o=>o.type)),xn=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),kn=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Cn="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",Ut=8,Sn=6,Zt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Mn=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],Gt=react.memo(function({activeTool:e,onToolChange:n,showGrid:r,onToggleGrid:h,canUndo:c=false,canRedo:a=false,onUndo:l,onRedo:S,onExport:g,onExportData:p,onImportData:b,onHighlighterColorChange:x,onStickyNoteColorChange:N,onInsertIcon:K,onInsertTable:I,arrowStyle:d,onArrowStyleChange:E}){let[C,Z]=react.useState(false),[s,w]=react.useState(false),[m,G]=react.useState(null),[z,_]=react.useState(false),[Q,F]=react.useState(false),[H,Y]=react.useState(mt),[j,ee]=react.useState(false),[M,ue]=react.useState(bt),[xe,B]=react.useState(false),[Re,ye]=react.useState(false),[se,Te]=react.useState(null),ke=react.useRef(null),Ne=react.useRef(null),fe=react.useRef(null),O=react.useRef(null),v=react.useRef(null);U();let pe=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],oe=()=>{ke.current&&(clearTimeout(ke.current),ke.current=null),_(true);},le=()=>{ke.current=window.setTimeout(()=>_(false),200);},X=react.useRef(null),He=()=>{_(false),y(),X.current?.click();},me=u=>{let W=u.target.files?.[0];W&&b?.(W),u.target.value="";},We=()=>{Ne.current&&(clearTimeout(Ne.current),Ne.current=null),Z(true);},Ue=()=>{Ne.current=window.setTimeout(()=>{Z(false),y();},200);},Ye=()=>{fe.current&&(clearTimeout(fe.current),fe.current=null),w(true);},je=()=>{fe.current=window.setTimeout(()=>{w(false),y();},200);},Ee=(u,W)=>{let i=u.closest(".drawui-toolbar");if(!i)return;let T=u.getBoundingClientRect(),f=i.getBoundingClientRect(),k=T.bottom+46>window.innerHeight;G({label:W,x:T.left-f.left+T.width/2,y:k?T.top-f.top-8:T.bottom-f.top+8,above:k});},y=()=>G(null),$=()=>{O.current&&(clearTimeout(O.current),O.current=null),F(true);},P=()=>{O.current=window.setTimeout(()=>F(false),200);},D=u=>{Y(u),co(u),x?.(u),n("highlighter");},q=()=>{v.current&&(clearTimeout(v.current),v.current=null),ee(true);},ne=()=>{v.current=window.setTimeout(()=>ee(false),200);},Ie=u=>{ue(u),ho(u),N?.(u),n("sticky-note"),ee(false);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>n("select"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.select"),onMouseLeave:y,children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M6 3 6 19.6 10.3 15.7 13 21.1 15.8 19.8 13.1 14.5 18.6 14 Z"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>n("hand"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.hand"),onMouseLeave:y,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsxRuntime.jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsxRuntime.jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),jsxRuntime.jsx("path",{d:"M16.6 11.8V8.1a1.5 1.5 0 0 1 3 0v6.6a6.2 6.2 0 0 1-6.2 6.2h-1.5a6.2 6.2 0 0 1-5-2.5l-3.2-4.4a1.5 1.5 0 0 1 2.3-1.9l2.6 2.5"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:We,onMouseLeave:Ue,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${vn.has(e)?"active":""}`,onClick:()=>{n("rounded-rectangle"),Z(false),y();},"data-drawui-tip":C?void 0:drawuiCore.t("toolbar.shapes"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),C&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:gn.map(u=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(u.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:u.items.map(W=>{let i=W.labelKey??`tool.${W.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===W.type?"active":""}`,onClick:()=>{n(W.type),Z(false),y();},onMouseEnter:T=>Ee(T.currentTarget,i),onMouseLeave:y,"aria-label":drawuiCore.t(i),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:wn.get(W.type)})},`${u.key}-${W.type}`)})})]},u.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:q,onMouseLeave:ne,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{n("sticky-note"),ee(false),y();},"data-drawui-tip":j?void 0:drawuiCore.t("tool.sticky-note"),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:xn}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:M}})]}),j&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-sticky-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-sticky-panel-head",children:[jsxRuntime.jsx("span",{className:"drawui-sticky-panel-title",children:drawuiCore.t("tool.sticky-note")}),jsxRuntime.jsx("span",{className:"drawui-sticky-panel-key",children:"N"})]}),jsxRuntime.jsx("div",{className:"drawui-sticky-panel-grid",children:drawuiCore.STICKY_NOTE_COLORS.map(u=>jsxRuntime.jsx("button",{type:"button","aria-label":u,className:`drawui-sticky-swatch${M.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>Ie(u)},u))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${xe?"active":""}`,"data-icon-toggle":"","data-drawui-tip":xe?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{B(u=>!u),y();},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("path",{d:"M8.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M15.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M8.8 14.2c0.9 1 2 1.5 3.2 1.5s2.3 -0.5 3.2 -1.5"})]})}),xe&&jsxRuntime.jsx(vo,{onPick:u=>K?.(u.id),onClose:()=>B(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Ye,onMouseLeave:je,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{n("arrow"),w(false),y();},"data-drawui-tip":s?void 0:drawuiCore.t("toolbar.arrow"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),s&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:u=>{u.target.closest("button")||(w(false),y());},children:jsxRuntime.jsx(xt,{connectionType:d?.connectionType??"straight",arrowHead:d?.arrowHead??"end",dashed:!!d?.dashed,onConnectionTypeChange:u=>{E?.({connectionType:u}),n("arrow"),w(false),y();},onArrowStyleChange:u=>{E?.({arrowHead:u.arrowHead,dashed:u.dashed}),n("arrow"),w(false),y();},onOptionHover:(u,W)=>Ee(W,u),onOptionLeave:y})})]}),kn.filter(u=>u.type!=="arrow").map(u=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>n(u.type),"data-drawui-tip":drawuiCore.t(u.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:u.icon})})},u.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>n("pen"),"data-drawui-tip":drawuiCore.t("toolbar.pen"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:Cn})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:$,onMouseLeave:P,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>n("highlighter"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.highlighter"),onMouseLeave:y,children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsxs("g",{fill:"currentColor",stroke:"none",children:[jsxRuntime.jsx("path",{d:Zt,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:Zt,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:Zt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:H}})]}),Q&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:so.map(u=>jsxRuntime.jsx("button",{type:"button","aria-label":u,className:`drawui-highlighter-swatch${H.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>D(u)},u))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Mn.map(u=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>n(u.type),"data-drawui-tip":drawuiCore.t(u.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:u.icon})})},u.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>n("mind-map"),"data-drawui-tip":drawuiCore.t("toolbar.mind-map"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsxRuntime.jsx("path",{d:"M7.4 12h3.6"}),jsxRuntime.jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsxRuntime.jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Re?"active":""}`,onClick:()=>ye(u=>!u),"data-drawui-tip":drawuiCore.t("toolbar.table"),"data-table-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsxRuntime.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsxRuntime.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),Re&&jsxRuntime.jsxs("div",{className:"drawui-table-picker",children:[jsxRuntime.jsx("div",{className:"drawui-table-picker-hint",children:se?`${se.rows} \xD7 ${se.cols}`:drawuiCore.t("table.pickHint")}),jsxRuntime.jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:Sn*Ut},(u,W)=>{let i=Math.floor(W/Ut),T=W%Ut,f=se&&i<se.rows&&T<se.cols;return jsxRuntime.jsx("button",{type:"button","aria-label":`${i+1}x${T+1}`,className:"drawui-table-picker-cell",style:f?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Te({rows:i+1,cols:T+1}),onClick:()=>{I?.(i+1,T+1),ye(false),Te(null),y();}},W)})})]})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${r?"active":""}`,onClick:h,"data-drawui-tip":drawuiCore.t("toolbar.grid"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:l,disabled:!c,style:c?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":drawuiCore.t("toolbar.undo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 7v6h6"}),jsxRuntime.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:S,disabled:!a,style:a?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":drawuiCore.t("toolbar.redo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 7v6h-6"}),jsxRuntime.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:oe,onMouseLeave:le,children:[jsxRuntime.jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":z?void 0:drawuiCore.t("toolbar.export"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsxRuntime.jsx("polyline",{points:"7 10 12 15 17 10"}),jsxRuntime.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),z&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:[pe.map(u=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{g?.(u.format),_(false);},"data-drawui-tip":drawuiCore.t(u.labelKey),children:drawuiCore.t(u.labelKey)},u.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{p?.(),_(false);},"data-drawui-tip":drawuiCore.t("toolbar.export.data"),children:drawuiCore.t("toolbar.export.data")}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:He,"data-drawui-tip":drawuiCore.t("toolbar.import.data"),children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:X,type:"file",accept:".json,application/json",style:{display:"none"},onChange:me}),m&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${m.above?"is-above":"is-below"}`,style:{left:m.x,top:m.y},children:drawuiCore.t(m.label)})]})})});var Vt=react.memo(function({onZoomIn:e,onZoomOut:n,onReset:r,zoomLevel:h=100}){return U(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":drawuiCore.t("zoom.in"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxRuntime.jsxs("div",{className:"drawui-zoom-level",children:[h,"%"]}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:n,"data-drawui-tip":drawuiCore.t("zoom.out"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:r,"data-drawui-tip":drawuiCore.t("zoom.reset"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})})]})});var Lo=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],No=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Hn=Lo.filter(o=>o!=="#f1f5f9"),Pn=[...Hn,...No],An=[...Lo,...No],Eo=15,Io="drawui:customColors";function Kn(){if(typeof window>"u")return [];try{let o=window.localStorage.getItem(Io);if(!o)return [];let e=JSON.parse(o);return Array.isArray(e)?e.filter(n=>typeof n=="string").slice(-Eo):[]}catch{return []}}function On(o){if(!(typeof window>"u"))try{window.localStorage.setItem(Io,JSON.stringify(o));}catch{}}var Yt=[{key:"fill",labelKey:"style.fill",hasTransparent:true,hasOpacity:true},{key:"stroke",labelKey:"style.stroke",hasTransparent:false,hasOpacity:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true,hasOpacity:true}],To=(o,e)=>!!o&&!!e&&o.toLowerCase()===e.toLowerCase(),pt=10,qe=12,Ve=o=>!o||o==="transparent",Ro=react.memo(function({editor:e,selectedCount:n,hasLineSelection:r,currentConnectionType:h,currentArrowHead:c,currentDashed:a}){U();let l=!!e?.getEditingShapeId(),[S,g]=react.useState(null),[p,b]=react.useState(null),[,x]=react.useState(0),N=react.useRef(null),K=react.useRef(null),I=react.useRef(null),[d,E]=react.useState({tw:168,th:42,pw:228,ph:160}),[C,Z]=react.useState(Kn),s=react.useRef(null),w=react.useCallback(i=>{let T=i.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(T)&&Z(f=>{let k=f.filter(ce=>ce!==T);for(k.push(T);k.length>Eo;)k.shift();return On(k),k});},[]);if(react.useEffect(()=>{let i=s.current;if(!i)return;let T=()=>{i.value&&w(i.value);};return i.addEventListener("change",T),()=>i.removeEventListener("change",T)},[w,p]),react.useEffect(()=>{if(!e)return;let i=e.subscribe(()=>x(T=>(T+1)%1e6));return ()=>{i();}},[e]),react.useEffect(()=>{b(null);},[n,l]),react.useEffect(()=>{if(!p)return;let i=T=>{N.current&&!N.current.contains(T.target)&&b(null);};return document.addEventListener("pointerdown",i,true),()=>document.removeEventListener("pointerdown",i,true)},[p]),react.useLayoutEffect(()=>{let i=K.current?.offsetWidth??d.tw,T=K.current?.offsetHeight??d.th,f=I.current?.offsetWidth??d.pw,k=I.current?.offsetHeight??d.ph;E(ce=>ce.tw===i&&ce.th===T&&ce.pw===f&&ce.ph===k?ce:{tw:i,th:T,pw:f,ph:k});}),!e||n===0||l)return null;let m=e.getSelectedIds(),z=e.getShapes().filter(i=>m.includes(i.id)),_=z[0],Q=_?.id??"",F=_?.style.fillColor,H=_?.style.strokeColor??"#1f2937",Y=_?.textColor??"#1f2937",j=_?.highlightColor,ee={fill:F,stroke:H,text:Y,highlight:j},M=z.length>0&&z.every(i=>i.type==="sticky-note"),ue={fill:_?.style.fillOpacity??1,stroke:_?.style.strokeOpacity??1,highlight:_?.highlightOpacity??1},xe=i=>S&&S.key===`${Q}:${i}`?S.value:ue[i]??1,B=(i,T)=>{switch(i){case "stroke":e.updateSelectedShapesStyle({strokeColor:T});break;case "fill":e.updateSelectedShapesStyle({fillColor:T});break;case "text":e.updateSelectedShapesText({textColor:T});break;case "highlight":e.updateSelectedShapesText({highlightColor:T});break}},Re=(i,T)=>{g({key:`${Q}:${i}`,value:T}),i==="highlight"?e.updateSelectedShapesText({highlightOpacity:T}):i==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:T}):e.updateSelectedShapesStyle({fillOpacity:T});},ye=i=>e.updateConnectionType(i),se=i=>e.updateArrowStyle({arrowHead:i.arrowHead,dashed:i.dashed}),Te=!!r&&z.length>0&&z.every(i=>i.type==="line"||i.type==="arrow"),ke=z.length>0&&z.every(i=>i.type==="text"),Ne=z.length>0&&z.every(i=>i.type==="sticky-note"||i.type==="icon"),fe=Te?Yt.filter(i=>i.key==="stroke"):Ne?Yt.filter(i=>i.key!=="stroke"):Yt,O=i=>i.key==="stroke"&&Te?"style.line":i.labelKey,v=p&&p!=="more"?fe.find(i=>i.key===p):void 0,pe=!!p&&(p==="more"||p==="prefix"||!!v),oe=M&&v?.key==="fill",le=e.getCamera(),X=drawuiCore.getContentBounds(z,0),He=le.pageToScreen({x:X.x,y:X.y}),me=le.pageToScreen({x:X.x+X.width,y:X.y+X.height}),We=window.innerWidth,Ue=window.innerHeight,Ye=me.y+pt,je=He.y-pt,Ee=d.th+(pe?pt+d.ph:0),y=Ye+Ee<=Ue-qe,$=je-Ee>=qe,P=y||!$,D=(He.x+me.x)/2,q=(i,T,f)=>Math.max(T,Math.min(i,Math.max(T,f))),ne=q(D-d.tw/2,qe,We-d.tw-qe),Ie=P?Ye:je-d.th,u=q(D-d.pw/2,qe,We-d.pw-qe),W=pe?q(P?Ie+d.th+pt:Ie-pt-d.ph,qe,Ue-d.ph-qe):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:N,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:K,style:{left:ne,top:Ie},children:[fe.map(i=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${p===i.key?" active":""}`,onClick:()=>b(p===i.key?null:i.key),"data-drawui-tip":drawuiCore.t(O(i)),type:"button",children:[i.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${Ve(F)?" drawui-st-none":""}`,style:Ve(F)?void 0:{background:F}}),i.key==="stroke"&&(Te?jsxRuntime.jsx("span",{className:`drawui-st-line${Ve(H)?" drawui-st-line-none":""}`,style:Ve(H)?void 0:{background:H}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${Ve(H)?" drawui-st-frame-none":""}`,style:Ve(H)?void 0:{borderColor:H}})),i.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:Y},children:"A"}),i.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${Ve(j)?" drawui-st-none":""}`,style:Ve(j)?void 0:{background:j},children:"A"})]},i.key)),r&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${p==="more"?" active":""}`,onClick:()=>b(p==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),ke&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${p==="prefix"?" active":""}`,onClick:()=>b(p==="prefix"?null:"prefix"),"data-drawui-tip":drawuiCore.t("style.prefix"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),pe&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:I,style:{left:u,top:W},children:p==="prefix"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.prefix")}),jsxRuntime.jsx("div",{className:"drawui-muted-hint",children:drawuiCore.t("style.prefix.soon")})]}):v?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t(O(v))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[v.hasTransparent&&!oe&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${Ve(ee[v.key])?" active":""}`,onClick:()=>B(v.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(oe?drawuiCore.STICKY_NOTE_COLORS:v.hasTransparent?Pn:An).map(i=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${To(i,ee[v.key])?" active":""}`,style:{background:i},onClick:()=>B(v.key,i),"aria-label":i,type:"button"},i)),C.map(i=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${To(i,ee[v.key])?" active":""}`,style:{background:i},onClick:()=>B(v.key,i),"aria-label":i,type:"button"},`custom-${i}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:s,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),v.hasOpacity&&jsxRuntime.jsxs("div",{className:"drawui-opacity-row",children:[jsxRuntime.jsx("span",{className:"drawui-opacity-label",children:drawuiCore.t("style.opacity")}),jsxRuntime.jsx("input",{type:"range",min:0,max:100,value:Math.round(xe(v.key)*100),onChange:i=>Re(v.key,Number(i.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(xe(v.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(xt,{connectionType:h??"straight",arrowHead:c??"end",dashed:!!a,onConnectionTypeChange:ye,onArrowStyleChange:se})})})]})});var qt=14,Ao=20,Un=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],Zn=[12,14,16,18,20,24];function Ko(o,e,n){let r=o,h="",c=r.charAt(0);if(r.length>1&&(c==="+"||c==="-"||c==="#"||c==="~")&&r.charAt(1)===" "&&(h=c,r=r.slice(2)),r=r.replace(/^\s+|\s+$/g,""),e==="attribute"){let b=r.indexOf(":");return b===-1?{visibility:h,name:r,type:"",params:"",returnType:""}:{visibility:h,name:r.slice(0,b).replace(/^\s+|\s+$/g,""),type:r.slice(b+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let a=r.indexOf("(");if(a===-1){let b=r.lastIndexOf(":");return b===-1?{visibility:h,name:r,type:"",params:"",returnType:""}:{visibility:h,name:r.slice(0,b).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:r.slice(b+1).replace(/^\s+|\s+$/g,"")}}let l=r.slice(0,a).replace(/^\s+|\s+$/g,""),S=r.indexOf(")",a);if(S===-1)return {visibility:h,name:l,type:"",params:r.slice(a+1).replace(/^\s+|\s+$/g,""),returnType:""};let g=r.slice(a+1,S).replace(/^\s+|\s+$/g,""),p=r.slice(S+1).replace(/^\s+|\s+$/g,"");return p.startsWith(":")&&(p=p.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:h,name:l,type:"",params:g,returnType:p}}function Gn(o,e){let n=e.visibility?`${e.visibility} `:"";return o==="attribute"?`${n}${e.name}${e.type?`: ${e.type}`:""}`:`${n}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var $o=react.memo(function({editor:e,umlClass:n,editing:r}){let[,h]=react.useState(0);U(),react.useEffect(()=>{if(!e)return;let y=e.subscribe(()=>h($=>$+1));return ()=>{y();}},[e]);let[c,a]=react.useState(null),[l,S]=react.useState(false),[g,p]=react.useState(null),b=react.useRef(null),x=react.useRef(null),N=react.useCallback((y,$)=>{b.current&&(clearTimeout(b.current),b.current=null),a({section:y,rowId:$}),S(false);},[]),K=react.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=window.setTimeout(()=>{a(null),S(false);},150);},[]);if(!e||!n||r!==n.id)return null;let I=e.getCamera(),{id:d,x:E,y:C,width:Z,height:s,className:w,methods:m}=n,G=n.type==="uml-interface",z=G?[]:n.attributes,_=Z/2,Q=s/2,F=drawuiCore.UML_HEADER_HEIGHT,H=drawuiCore.UML_LINE_HEIGHT,Y=drawuiCore.UML_PADDING_X,j=drawuiCore.UML_PADDING_Y,ee=G?0:z.length>0?z.length*H+j*2:j*2,M=I.zoom,ue=(Z-Y*2)*M,xe=4*M,B=I.pageToScreen({x:E-_+Y,y:C}),Re=I.pageToScreen({x:E,y:C-Q+F/2}),ye=y=>I.pageToScreen({x:E,y}).y,se=H*M,Te=y=>C+(-Q+F+j+H/2+y*H),ke=y=>C+(-Q+F+ee+j+H/2+y*H),Ne=C+(-Q+F+ee),fe=C+Q,O={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},v=(y,$)=>{let P=z.find(q=>q.id===y);if(!P)return;let D=Ko($,"attribute",P.visibility);e.updateUmlClass(d,{attributes:z.map(q=>q.id===y?{...q,...D}:q)});},pe=(y,$)=>{let P=m.find(ne=>ne.id===y);if(!P)return;let D=Ko($,"method",P.visibility),q=m.map(ne=>ne.id===y?{...ne,...D}:ne);G?e.updateUmlInterface(d,{methods:q}):e.updateUmlClass(d,{methods:q});},oe=(y,$,P)=>{x.current={section:y,from:$},P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("text/plain",`${y}:${$}`);},le=y=>{y.preventDefault(),y.dataTransfer.dropEffect="move";},X=(y,$,P)=>{P.preventDefault();let D=x.current;!D||D.section!==y||(y==="attribute"?e.reorderUmlAttribute(d,D.from,$):e.reorderUmlMethod(d,D.from,$),x.current=null);},He=(y,$,P,D)=>{let q=ye(D),ne=c?.section===y&&c.rowId===P.id,Ie=(P.fontSize||drawuiCore.UML_FONT_SIZE)*M,u=P.textColor||"#1f2937",W={position:"absolute",left:B.x-qt*M-xe,top:q-se/2,width:qt*M+xe+ue+Ao*M,height:se,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},i={...O,width:ue,height:se-2,fontSize:Ie,color:u,textDecoration:P.strikethrough?"line-through":"none",pointerEvents:"auto",...ne?{borderColor:"var(--dw-primary)"}:{}},T={width:qt*M,height:se-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*M,lineHeight:1,opacity:ne?1:.55,pointerEvents:"auto"},f={width:Ao*M,height:se-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*M,opacity:ne?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:W,onDragOver:le,onDrop:k=>X(y,$,k),children:[jsxRuntime.jsx("span",{style:T,draggable:true,onDragStart:k=>oe(y,$,k),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:i,value:g&&g.rowId===P.id?g.text:Gn(y,P),onChange:k=>{p({rowId:P.id,text:k.target.value}),y==="attribute"?v(P.id,k.target.value):pe(P.id,k.target.value);},onFocus:()=>N(y,P.id),onBlur:()=>{p(null),K();},spellCheck:false}),jsxRuntime.jsx("button",{style:f,onMouseDown:k=>k.preventDefault(),onClick:()=>{y==="attribute"?e.removeUmlAttribute(d,P.id):e.removeUmlMethod(d,P.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},P.id)},me=(y,$,P)=>{let D=ye($),q=y==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:ne=>ne.preventDefault(),onClick:()=>q?e.addUmlAttribute(d):e.addUmlMethod(d),className:"drawui-uml-add-row",style:{position:"absolute",left:B.x,top:D-9*M,height:18*M,padding:`0 ${6*M}px`,fontSize:11*M,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},"data-drawui-tip":P,children:[jsxRuntime.jsx("span",{style:{fontSize:13*M,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:P})]},`add-${y}`)},We=()=>{if(!c||c.section==="className")return null;let y=c.section,$=c.rowId,D=(y==="attribute"?z:m).find(R=>R.id===$);if(!D)return null;let q=224*M,ne=30*M,Ie=I.pageToScreen({x:E,y:C}).x,u=I.pageToScreen({x:E,y:C-Q}).y,W=20*M,i=u-ne-W,T=Ie-q/2,f=i+ne,k=D.textColor||"#1f2937",ce=D.fontSize||drawuiCore.UML_FONT_SIZE,Pe=!!D.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ie-.5,top:f,width:1,height:W,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:T,top:i,width:q,height:ne,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*M,padding:`0 ${6*M}px`,pointerEvents:"auto",zIndex:60,fontSize:12*M},onMouseDown:R=>R.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>S(R=>!R),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsxRuntime.jsx("span",{style:{fontWeight:700,color:k,fontSize:13*M,textDecoration:Pe?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*M,height:2*M,background:k,marginLeft:3,borderRadius:1}})]}),l&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(d,y,D.id,{textColor:null}),S(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),Un.map(R=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(d,y,D.id,{textColor:R}),S(false);},style:{width:14,height:14,border:"none",background:R,cursor:"pointer",borderRadius:2},"data-drawui-tip":R},R))]})]}),jsxRuntime.jsx("select",{value:ce,onChange:R=>e.updateUmlRowStyle(d,y,D.id,{fontSize:Number(R.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*M}px`,fontSize:12*M,height:20*M,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:Zn.map(R=>jsxRuntime.jsx("option",{value:R,children:R},R))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(d,y,D.id,{strikethrough:!Pe}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:Pe?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*M,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{y==="attribute"?e.removeUmlAttribute(d,D.id):e.removeUmlMethod(d,D.id),a(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxRuntime.jsxs("svg",{width:14*M,height:14*M,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsxRuntime.jsx("path",{d:"M10 11v6"}),jsxRuntime.jsx("path",{d:"M14 11v6"}),jsxRuntime.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Ue=I.pageToScreen({x:E-_,y:C}).x,Ye=I.pageToScreen({x:E,y:C-Q}).y,je=Z*M,Ee=s*M;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Ue+1,top:Ye+1,width:Math.max(0,je-2),height:Math.max(0,Ee-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...O,position:"absolute",left:Re.x-ue/2,top:Re.y-F*M/2+2,width:ue,height:F*M-4,textAlign:"center",fontWeight:700,fontSize:(n.fontSize||drawuiCore.UML_FONT_SIZE)*M,color:n.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...c?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:w,onChange:y=>G?e.updateUmlInterface(d,{className:y.target.value}):e.updateUmlClass(d,{className:y.target.value}),onFocus:()=>N("className",""),onBlur:K,spellCheck:false}),!G&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[z.map((y,$)=>He("attribute",$,y,Te($))),me("attribute",Ne,"\u5C5E\u6027")]}),m.map((y,$)=>He("method",$,y,ke($))),me("method",fe,drawuiCore.t("uml.method")),We()]})});var _o=react.memo(function({editor:e,panelOpen:n,onOpenPanel:r}){let[,h]=react.useState(0);U(),react.useEffect(()=>{if(!e)return;let s=e.subscribe(()=>h(w=>w+1));return ()=>{s();}},[e]);let c=react.useRef(false),a=react.useRef(false),l=e?.getMindMapEditingShapeId()??null,S=e?.getMindMapSelectedNode()?.nodeId??"",g=l?`${l}\0${S}`:"";if(react.useEffect(()=>{c.current=false;},[g]),!e)return null;let p=e.getMindMapEditingShapeId();if(!p||n)return null;let b=e.getMindMapSelectedNode();if(!b||b.shapeId!==p)return null;let x=e.getMindMapNode(p,b.nodeId),N=e.getMindMapNodeScreenRect(p,b.nodeId);if(!x||!N)return null;let K=e.getCamera().getZoom(),I=drawuiCore.MINDMAP_FONT_SIZE*K,d=Math.max(100,N.width+24),E=N.height+8,C={position:"absolute",left:N.x+N.width/2,top:N.y-4,transform:"translateX(-50%)",width:d,height:E,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(x.icon?24:12)*K}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},Z={position:"absolute",left:N.x+N.width+12,top:N.y+N.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("input",{autoFocus:true,style:C,value:x.text,spellCheck:false,onChange:s=>{let w=!c.current;c.current=true,e.updateMindMapNode(p,b.nodeId,{text:s.target.value},w);},onBlur:()=>{if(a.current){a.current=false;return}e.exitMindMapEdit();},onKeyDown:s=>{s.key==="Enter"?s.target.blur():s.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:Z,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:s=>{s.preventDefault(),a.current=true,setTimeout(()=>{a.current=false;},300);},onClick:r,children:"\u22EF"})]})});var Zo=react.memo(function({editor:e,panelOpen:n}){let[,r]=react.useState(0);U(),react.useEffect(()=>{if(!e)return;let E=e.subscribe(()=>r(C=>C+1));return ()=>{E();}},[e]);let h=react.useRef(false),c=e?.getTableEditing()??null,a=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(react.useEffect(()=>{h.current=false;},[a]),!e||n)return null;let l=e.getTableEditing();if(!l)return null;let{shapeId:S,row:g,col:p}=l,b=e.getTableCell(S,g,p),x=e.getTableScreenRect(S,g,p);if(!b||!x)return null;let N=e.getSelectedTable(),K=b.fontSize||N?.fontSize||drawuiCore.TABLE_FONT_SIZE,I=e.getCamera().getZoom(),d={left:x.x-1,top:x.y-1,width:x.width+2,height:x.height+2,padding:`${drawuiCore.TABLE_CELL_PADDING_Y*I}px ${drawuiCore.TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:K*I,lineHeight:drawuiCore.TABLE_LINE_HEIGHT_RATIO,fontWeight:b.bold?700:400,color:b.textColor||N?.textColor||"#1f2937",textAlign:b.align==="center"?"center":b.align==="right"?"right":"left"};return jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsxRuntime.jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:d,value:b.text,spellCheck:false,onChange:E=>{let C=!h.current;h.current=true,e.updateTableCell(S,g,p,{text:E.target.value},C);},onBlur:()=>{e.exitTableEdit();},onKeyDown:E=>{(E.key==="Enter"||E.key==="Escape")&&(E.preventDefault(),E.target.blur());}})})});var Vo=react.memo(function({editor:e}){let[,n]=react.useState(0),[r,h]=react.useState(null),c=react.useRef(null);if(U(),react.useEffect(()=>{if(!e)return;let H=e.subscribe(()=>n(Y=>Y+1));return ()=>{H();}},[e]),react.useEffect(()=>{if(!r)return;let H=j=>{let ee=j.target;ee&&c.current?.contains(ee)||h(null);},Y=j=>{j.key==="Escape"&&h(null);};return window.addEventListener("pointerdown",H,true),window.addEventListener("keydown",Y),()=>{window.removeEventListener("pointerdown",H,true),window.removeEventListener("keydown",Y);}},[r]),!e)return null;let a=e.getSelectedTable();if(!a)return null;let l=e.getTableSelection();if(!l||l.shapeId!==a.id)return null;let S=e.getTableScreenRect(a.id);if(!S)return null;let g=a.cells.length,p=a.cells[0]?.length??0,b=drawuiCore.tableExpandRangeToMerges(a,l.anchor.row,l.anchor.col,l.focus.row,l.focus.col),{r1:x,c1:N,r2:K,c2:I}=b,d=drawuiCore.tableCoveredMap(a.cells),E=0;for(let H=x;H<=K;H++)for(let Y=N;Y<=I;Y++)d[H]?.[Y]||E++;let C=E>1,Z=drawuiCore.tableRangeHasMerge(a,x,N,K,I),s=x===K?`${x+1}`:`${x+1}\u2013${K+1}`,w=N===I?`${N+1}`:`${N+1}\u2013${I+1}`,m=g-(K-x+1)>=1,G=p-(I-N+1)>=1,_=S.y>56?S.y-40:S.y+S.height+10,Q=H=>H.stopPropagation(),F=H=>()=>{H(),h(null);};return jsxRuntime.jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:S.x+S.width/2,top:_},onPointerDown:Q,children:[jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(a.id,"below"),children:drawuiCore.t("table.insertRow")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${r==="row"?"active":""}`,"data-table-insert-row":true,title:`${drawuiCore.t("table.insertRowAbove")} / ${drawuiCore.t("table.insertRowBelow")}`,onClick:()=>h(r==="row"?null:"row"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r==="row"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsxRuntime.jsx("button",{onClick:F(()=>e.insertTableRowRelative(a.id,"above")),children:drawuiCore.t("table.insertRowAbove")}),jsxRuntime.jsx("button",{onClick:F(()=>e.insertTableRowRelative(a.id,"below")),children:drawuiCore.t("table.insertRowBelow")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteRow")} \xB7 ${s}`,disabled:!m,onClick:()=>e.deleteTableRowsInSelection(a.id),children:drawuiCore.t("table.deleteRow")}),jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(a.id,"right"),children:drawuiCore.t("table.insertCol")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${r==="col"?"active":""}`,"data-table-insert-col":true,title:`${drawuiCore.t("table.insertColLeft")} / ${drawuiCore.t("table.insertColRight")}`,onClick:()=>h(r==="col"?null:"col"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r==="col"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsxRuntime.jsx("button",{onClick:F(()=>e.insertTableColumnRelative(a.id,"left")),children:drawuiCore.t("table.insertColLeft")}),jsxRuntime.jsx("button",{onClick:F(()=>e.insertTableColumnRelative(a.id,"right")),children:drawuiCore.t("table.insertColRight")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteCol")} \xB7 ${w}`,disabled:!G,onClick:()=>e.deleteTableColsInSelection(a.id),children:drawuiCore.t("table.deleteCol")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.merge"),disabled:!C,onClick:()=>e.mergeTableCells(a.id),children:drawuiCore.t("table.merge")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.split"),disabled:!Z,onClick:()=>e.splitTableCells(a.id),children:drawuiCore.t("table.split")})]})});var Yo=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],jo=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],fr={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},Jt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Tt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},Lt={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},Qt={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},Xo=react.memo(function({editor:e,mindMap:n}){let[,r]=react.useState(0);U(),react.useEffect(()=>{if(!e)return;let s=e.subscribe(()=>r(w=>w+1));return ()=>{s();}},[e]);let h=react.useRef(null);if(!e||!n||e.getMindMapEditingShapeId()!==n.id)return null;let c=e.getMindMapSelectedNode();if(!c||c.shapeId!==n.id)return null;let a=s=>{if(s.id===c.nodeId)return s;for(let w of s.children??[]){let m=a(w);if(m)return m}return null},l=a(n.root);if(!l)return null;let S=e.getCamera(),p=drawuiCore.layoutMindMap(n.root).positions.get(l.id);if(!p)return null;let b=S.zoom,x=S.pageToScreen({x:n.x+p.x,y:n.y+p.y}),N=x.x+p.width*b/2+14,K=x.y-80,d=Math.max(8,Math.min(N,(window.innerWidth||1024)-232-8)),E=Math.max(8,Math.min(K,(window.innerHeight||768)-320)),C=s=>{e.updateMindMapNode(n.id,l.id,s);},Z=!!l.id&&l.id!==n.root.id;return jsxRuntime.jsxs("div",{ref:h,style:{...fr,left:d,top:E},onMouseDown:s=>s.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsxRuntime.jsx("span",{style:{fontWeight:600,fontSize:12},children:drawuiCore.t("mindmap.nodeText")}),jsxRuntime.jsx("button",{onClick:()=>e.exitMindMapEdit(),"data-drawui-tip":drawuiCore.t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsxRuntime.jsx("input",{style:{...Qt,marginBottom:8},value:l.text,onChange:s=>C({text:s.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:Lt,onClick:()=>e.addMindMapChild(n.id,l.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),Z&&jsxRuntime.jsxs("button",{style:Lt,onClick:()=>e.addMindMapSibling(n.id,l.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!l.children?.length&&jsxRuntime.jsx("button",{style:Lt,onClick:()=>e.toggleMindMapCollapse(n.id,l.id),children:l.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...Lt,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(n.id,l.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:Jt,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>C({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),Yo.map(s=>jsxRuntime.jsx("button",{"data-drawui-tip":s,onClick:()=>C({color:s}),style:{width:18,height:18,borderRadius:4,border:l.color===s?"2px solid #111827":"1px solid #d1d5db",background:s,cursor:"pointer",flexShrink:0}},s))]}),jsxRuntime.jsx("span",{style:Jt,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>C({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:l.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),jo.map(s=>jsxRuntime.jsx("button",{onClick:()=>C({icon:s}),style:{width:22,height:22,borderRadius:4,border:l.icon===s?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:s},s)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:l.icon&&!jo.includes(l.icon)?l.icon:"",onKeyDown:s=>{if(s.key==="Enter"){let w=s.target.value.trim();C({icon:w||void 0});}},onBlur:s=>{let w=s.target.value.trim();w!==l.icon&&C({icon:w||void 0});},style:{...Qt,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:Jt,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...Qt,marginBottom:6},value:l.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:s=>C({note:s.target.value||void 0}),spellCheck:false}),!!l.note&&jsxRuntime.jsxs("div",{style:{...Tt,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>C({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:l.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),Yo.map(s=>jsxRuntime.jsx("button",{onClick:()=>C({noteColor:s}),style:{width:16,height:16,borderRadius:3,border:l.noteColor===s?"2px solid #111827":"1px solid #d1d5db",background:s,cursor:"pointer"}},s))]})]})});var to=220,oo=140,vr="#fafafa";function xr(o,e){let n=Math.min(o.x,e.x),r=Math.min(o.y,e.y),h=Math.max(o.x+o.width,e.x+e.width),c=Math.max(o.y+o.height,e.y+e.height);return {x:n,y:r,width:h-n,height:c-r}}function kr(o){return {x:o.x+o.width/2,y:o.y+o.height/2}}function Cr(){return {x:0,y:0,width:0,height:0}}function Sr(o){let e=1/0,n=1/0,r=-1/0,h=-1/0,c=false;for(let a of o){let l=ro(a);l&&(c=true,l.x<e&&(e=l.x),l.y<n&&(n=l.y),l.x+l.width>r&&(r=l.x+l.width),l.y+l.height>h&&(h=l.y+l.height));}return c?{x:e,y:n,width:r-e,height:h-n}:null}function ro(o){switch(o.type){case "rectangle":case "sticky-note":case "icon":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "table":case "text":return {x:o.x-o.width/2,y:o.y-o.height/2,width:o.width,height:o.height};case "circle":return {x:o.x-o.radius,y:o.y-o.radius,width:o.radius*2,height:o.radius*2};case "line":case "arrow":{let e=o.points;if(!e||e.length===0)return null;let n=1/0,r=1/0,h=-1/0,c=-1/0;for(let a of e)a.x<n&&(n=a.x),a.y<r&&(r=a.y),a.x>h&&(h=a.x),a.y>c&&(c=a.y);return {x:n,y:r,width:h-n,height:c-r}}case "draw":{let e=o,n=e.width,r=e.height;if(typeof n=="number"&&typeof r=="number")return {x:e.x-n/2,y:e.y-r/2,width:n,height:r};let h=e.points;if(!h||h.length===0)return null;let c=1/0,a=1/0,l=-1/0,S=-1/0;for(let g of h){let p=g.x+e.x,b=g.y+e.y;p<c&&(c=p),b<a&&(a=b),p>l&&(l=p),b>S&&(S=b);}return {x:c,y:a,width:l-c,height:S-a}}default:return null}}function Mr(o){let e=o.getCamera(),n=e.screenToPage({x:0,y:0}),r=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:n.x,y:n.y,width:r.x-n.x,height:r.y-n.y}}function Tr(o,e,n){if(o.width<=0||o.height<=0)return {x:o.x-e/2,y:o.y-n/2,width:e,height:n};let r=e/n,h=o.width,c=h/r;c<o.height&&(c=o.height,h=c*r);let a=kr(o);return {x:a.x-h/2,y:a.y-c/2,width:h,height:c}}function no(o,e,n,r){let h=(o-n.left)/n.width,c=(e-n.top)/n.height;return {x:r.x+h*r.width,y:r.y+c*r.height}}var Qo=react.memo(function({editor:e}){let n=react.useRef(null),r=react.useRef(null),[h,c]=react.useState(false),[a,l]=react.useState(100),[S,g]=react.useState(false),[p,b]=react.useState(false);U();let x=react.useRef(null),N=react.useRef(null);react.useLayoutEffect(()=>{let s=n.current,w=r.current;if(!s||!w)return;let m=window.devicePixelRatio||1;s.width=Math.round(to*m),s.height=Math.round(oo*m),s.style.width=`${to}px`,s.style.height=`${oo}px`;},[h]);let K=react.useCallback(()=>{let s=n.current,w=r.current;if(!s||!w||!e)return;let m=s.getContext("2d");if(!m)return;let G=to,z=oo,_=s.width,Q=s.height,F=e.getShapes(),H=new Set(e.getSelectedIds()),Y=drawuiCore.getTheme(),j=drawuiCore.hexToRgba(Y.text,.16),ee=Y.primary,M=drawuiCore.hexToRgba(Y.primary,.18),ue=drawuiCore.hexToRgba(Y.primary,.85),xe=Sr(F),B=Mr(e),Re=xe?xr(xe,B):B.width>0?B:Cr(),ye=Tr(Re,G,z);N.current=ye;let se=_/ye.width,Te=Q/ye.height,ke=G/ye.width;m.setTransform(1,0,0,1,0,0),m.fillStyle=vr,m.fillRect(0,0,_,Q),m.setTransform(se,0,0,Te,-se*ye.x,-Te*ye.y),m.fillStyle=j;for(let O of F){let v=ro(O);v&&m.fillRect(v.x,v.y,v.width,v.height);}m.fillStyle=ee;for(let O of F){if(!H.has(O.id))continue;let v=ro(O);v&&m.fillRect(v.x,v.y,v.width,v.height);}m.fillStyle=M,m.fillRect(B.x,B.y,B.width,B.height);let Ne=1.5/ke;m.strokeStyle=ue,m.lineWidth=Ne,m.lineJoin="round";let fe=Math.min(B.width/6,B.height/6,6/ke);if(m.beginPath(),fe*ke<1)m.rect(B.x,B.y,B.width,B.height);else {let O=B.x,v=B.y,pe=B.width,oe=B.height,le=Math.min(fe,pe/2,oe/2);m.moveTo(O+le,v),m.lineTo(O+pe-le,v),m.quadraticCurveTo(O+pe,v,O+pe,v+le),m.lineTo(O+pe,v+oe-le),m.quadraticCurveTo(O+pe,v+oe,O+pe-le,v+oe),m.lineTo(O+le,v+oe),m.quadraticCurveTo(O,v+oe,O,v+oe-le),m.lineTo(O,v+le),m.quadraticCurveTo(O,v,O+le,v),m.closePath();}m.stroke(),m.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||h)return;K();let s=e.subscribe(K),w=drawuiCore.subscribeTheme(K),m=()=>K();return window.addEventListener("resize",m),()=>{s(),w(),window.removeEventListener("resize",m);}},[e,h,K]),react.useEffect(()=>{if(!e)return;let s=()=>{let m=e.getCamera().getZoom();l(Math.round(m*100));};s();let w=e.subscribe(s);return ()=>{w();}},[e]);let I=react.useCallback((s,w)=>{if(!e)return;let m=e.getCamera(),G=m.getZoom(),z=window.innerWidth/2,_=window.innerHeight/2,Q=m;Q.x=z-s*G,Q.y=_-w*G,e.requestRender();},[e]),d=s=>{if(!e||!r.current||s.button!==0)return;let w=r.current.getBoundingClientRect(),m=N.current;if(!m)return;let G=no(s.clientX,s.clientY,w,m);x.current={pointerId:s.pointerId,rect:{left:w.left,top:w.top,width:w.width,height:w.height},canvasBox:m},s.currentTarget.setPointerCapture(s.pointerId),b(true),I(G.x,G.y);},E=s=>{if(!p||!e||!x.current||!r.current)return;let w=x.current,m=no(s.clientX,s.clientY,w.rect,w.canvasBox);I(m.x,m.y);},C=s=>{if(p){b(false),x.current=null;try{s.currentTarget.releasePointerCapture(s.pointerId);}catch{}}},Z=s=>{if(!e||!r.current)return;let w=N.current;if(!w)return;let m=r.current.getBoundingClientRect(),G=no(s.clientX,s.clientY,m,w);I(G.x,G.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${h?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(s=>!s),"data-drawui-tip":h?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":h?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!h&&jsxRuntime.jsxs("div",{className:"drawui-minimap-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-minimap-header",children:[jsxRuntime.jsx("span",{className:"drawui-minimap-title",children:drawuiCore.t("minimap.title")}),jsxRuntime.jsxs("span",{className:"drawui-minimap-zoom",children:[a,"%"]})]}),jsxRuntime.jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:p?"grabbing":S?"pointer":"default"},onPointerEnter:()=>g(true),onPointerLeave:()=>g(false),children:jsxRuntime.jsx("canvas",{ref:n,className:"drawui-minimap-canvas",onPointerDown:d,onPointerMove:E,onPointerUp:C,onPointerCancel:C,onDoubleClick:Z})})]})]})});var we=o=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:o}),Er=[{type:"rectangle",labelKey:"shape.rectangle",glyph:we(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:we(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:we(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:we(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:we(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:we(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:we(jsxRuntime.jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:we(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:we(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:we(jsxRuntime.jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:we(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:we(jsxRuntime.jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"sticky-note",labelKey:"shape.sticky-note",glyph:we(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:we(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M3 15 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:we(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:we(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2"}),jsxRuntime.jsx("path",{d:"M7 12h2.6"}),jsxRuntime.jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsxRuntime.jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function en({editor:o,x:e,y:n,context:r,existingArrowId:h,defaultShapeType:c,onClose:a}){let l=react.useRef(null);U();let S=g=>{o?.createGeneratedConnection(r,{type:g,existingArrowId:h}),a();};return react.useEffect(()=>{let g=x=>{l.current&&!l.current.contains(x.target)&&a();},p=x=>{x.key==="Escape"&&(x.preventDefault(),a());},b=setTimeout(()=>{window.addEventListener("pointerdown",g,true),window.addEventListener("keydown",p,true);},0);return ()=>{clearTimeout(b),window.removeEventListener("pointerdown",g,true),window.removeEventListener("keydown",p,true);}},[a]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:l,style:{left:e,top:n},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:Er.map(g=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${g.type===c?" drawui-gen-shape-active":""}`,onClick:()=>S(g.type),"data-drawui-tip":drawuiCore.t(g.labelKey),children:[g.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(g.labelKey)})]},g.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var Pr={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","sticky-note":"tool.sticky-note",icon:"toolbar.icon","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map",table:"tool.table"};function Ar({initialTool:o="select",className:e="",themeColor:n,language:r="zh-CN",data:h,onChange:c,onReady:a}){let l=react.useRef(null),S=react.useRef(null),g=react.useRef(null),[p,b]=react.useState(null);U();let[x,N]=react.useState(o),[K,I]=react.useState(false),[d,E]=react.useState(0),[C,Z]=react.useState(false),[s,w]=react.useState("straight"),[m,G]=react.useState("end"),[z,_]=react.useState(false),[Q,F]=react.useState(void 0),[H,Y]=react.useState(100),[j,ee]=react.useState(null),[M,ue]=react.useState(null),[xe,B]=react.useState(false),[Re,ye]=react.useState(false),[se,Te]=react.useState(null),[ke,Ne]=react.useState(null),[fe,O]=react.useState(false),[v,pe]=react.useState(null),[oe,le]=react.useState(null),X=react.useRef(null),He=react.useRef(0),me=react.useRef(null),We=react.useRef(c);We.current=c;let Ue=react.useRef(a);Ue.current=a,react.useEffect(()=>{if(!l.current)return;let f=new drawuiCore.Editor(l.current,{theme:n?{primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(n,.1),shadow:n}}:void 0,language:r,shapes:h,persist:!h});g.current=f,b(f),window.__drawuiEditor=f,f.setHighlighterColor(mt()),f.setStickyNoteColor(bt()),Ue.current?.(f),o&&f.setActiveTool(o);let k=f.subscribe(()=>{N(f.getActiveTool());let R=f.getSelectedIds();E(R.length);let Ce=f.getShapes().filter($e=>R.includes($e.id)&&($e.type==="line"||$e.type==="arrow"));if(Z(Ce.length>0),Ce.length>0&&Ce[0].connectionType?w(Ce[0].connectionType):Ce.length>0&&w("straight"),Ce.length>0){let $e=Ce.find(At=>At.type==="arrow");$e&&(G($e.arrowHead??"end"),_($e.dashed??false));}Y(Math.round(f.getCamera().getZoom()*100)),F(f.getArrowStyle()),B(f.canUndo()),ye(f.canRedo());let Oe=f.getSelectedUml();Te(Oe),Oe||pe(null);let Ze=f.getSelectedMindMap();Ne(Ze),f.getMindMapEditingShapeId()||O(false),We.current?.(f.getData());}),ce=f.subscribeNotifications(R=>{ue({type:"success",text:R}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>ue(null),3500);}),Pe=f.subscribeUi(R=>{R.kind==="shapeTypeMenu"&&le({x:R.screenX,y:R.screenY,context:R.context,existingArrowId:R.existingArrowId,defaultShapeType:R.defaultShapeType});});return ()=>{k(),ce(),Pe(),X.current&&clearTimeout(X.current),cancelAnimationFrame(He.current),f.dispose();}},[o]),react.useEffect(()=>{if(!n)return;let f=S.current;f&&(f.style.setProperty("--dw-primary",n),f.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(n,-0.12)),f.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(n,.1)),f.style.setProperty("--dw-primary-contrast","#ffffff"),f.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(n,.3)}`)),g.current?.setTheme({primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(n,.1),shadow:n}});},[n]),react.useEffect(()=>{drawuiCore.setLanguage(r),g.current?.setLanguage(r);},[r]);let Ye=react.useCallback(f=>{g.current?.setActiveTool(f);},[]),je=react.useCallback(()=>{g.current?.zoomIn();},[]),Ee=react.useCallback(()=>{g.current?.zoomOut();},[]),y=react.useCallback(()=>{g.current?.resetZoom();},[]),$=react.useCallback(()=>{let f=!K;I(f),g.current?.setShowGrid(f);},[K]),P=react.useCallback(()=>{g.current?.undo();},[]),D=react.useCallback(()=>{g.current?.redo();},[]),q=react.useCallback(f=>{g.current?.downloadImage("drawui",f,{background:"#ffffff"});},[]),ne=react.useCallback(()=>{g.current?.downloadJSON("drawui-data");},[]),Ie=react.useCallback(f=>{let k=new FileReader;k.onload=()=>{let ce=typeof k.result=="string"?k.result:"";if(g.current?.importJSON(ce)??false){let R=g.current?.getShapes().length??0;ue({type:"success",text:drawuiCore.t("import.success",{n:R})});}else ue({type:"error",text:drawuiCore.t("import.fail")});X.current&&clearTimeout(X.current),X.current=setTimeout(()=>ue(null),3500);},k.onerror=()=>{ue({type:"error",text:drawuiCore.t("import.fail")}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>ue(null),3500);},k.readAsText(f,"utf-8");},[]),u=react.useCallback(f=>{let k=g.current,ce=l.current;if(!k||!ce)return;if(k.isPointerDown()){me.current!==null&&(me.current=null,ee(null));return}let Pe=f.clientX,R=f.clientY;cancelAnimationFrame(He.current),He.current=requestAnimationFrame(()=>{let tt=ce.getBoundingClientRect(),Ce=Pe-tt.left,Oe=R-tt.top,Ze=Ce+12,$e=Oe+12,At=k.getSelectedUml()?.id,ot=k.getUmlRowAtScreenPoint({x:Ce,y:Oe});if(ot&&ot.shape.id!==At&&ot.text&&k.isUmlRowTextTruncated(ot)){me.current!==ot.text&&(me.current=ot.text,ee({text:ot.text,x:Ze,y:$e}));return}let at=k.getShapeAtScreenPoint({x:Ce,y:Oe});at&&at.text&&k.isShapeTextTruncated(at.id)?me.current!==at.text&&(me.current=at.text,ee({text:at.text,x:Ze,y:$e})):me.current!==null&&(me.current=null,ee(null));});},[]),W=react.useCallback(()=>{ee(null);},[]),i=react.useCallback(f=>{let k=g.current,ce=l.current;if(!k||!ce)return;let Pe=ce.getBoundingClientRect(),R=f.clientX-Pe.left,tt=f.clientY-Pe.top,Ce=k.getUmlRowAtScreenPoint({x:R,y:tt});if(Ce){pe(Ce.shape.id);return}let Oe=k.getMindMapNodeAtScreenPoint({x:R,y:tt});if(Oe){k.beginMindMapEdit(Oe.shapeId,Oe.nodeId);return}let Ze=k.getTableAtScreenPoint({x:R,y:tt});Ze&&k.beginTableEdit(Ze.shapeId,Ze.row,Ze.col);},[]),T=react.useCallback(()=>{le(null);},[]);return jsxRuntime.jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,children:[jsxRuntime.jsx("canvas",{ref:l,className:"drawui-canvas",onMouseMove:u,onMouseLeave:W,onDoubleClick:i}),j&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:j.x,top:j.y},children:j.text}),jsxRuntime.jsx(Gt,{activeTool:x,onToolChange:Ye,showGrid:K,onToggleGrid:$,canUndo:xe,canRedo:Re,onUndo:P,onRedo:D,onExport:q,onExportData:ne,onImportData:Ie,onHighlighterColorChange:f=>g.current?.setHighlighterColor(f),onStickyNoteColorChange:f=>g.current?.setStickyNoteColor(f),onInsertIcon:f=>g.current?.insertIcon(f),onInsertTable:(f,k)=>g.current?.insertTable(f,k),arrowStyle:Q,onArrowStyleChange:f=>g.current?.setArrowStyle(f)}),jsxRuntime.jsx(Vt,{onZoomIn:je,onZoomOut:Ee,onReset:y,zoomLevel:H}),jsxRuntime.jsx(Ro,{editor:p,selectedCount:d,hasLineSelection:C,currentConnectionType:s,currentArrowHead:m,currentDashed:z}),jsxRuntime.jsx($o,{editor:p,umlClass:se,editing:v}),jsxRuntime.jsx(Vo,{editor:p}),jsxRuntime.jsx(Zo,{editor:p,panelOpen:fe}),jsxRuntime.jsx(_o,{editor:p,panelOpen:fe,onOpenPanel:()=>O(true)}),fe&&jsxRuntime.jsx(Xo,{editor:p,mindMap:ke}),jsxRuntime.jsx(Qo,{editor:p}),oe&&jsxRuntime.jsx(en,{editor:p,x:oe.x,y:oe.y,context:oe.context,existingArrowId:oe.existingArrowId,defaultShapeType:oe.defaultShapeType,onClose:T}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(Pr[x])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:d===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:d})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[H,"%"]})})]}),M&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[M.type==="success"?jsxRuntime.jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}):jsxRuntime.jsxs("svg",{className:"drawui-toast-icon drawui-toast-icon-error",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M.text]})]})}exports.CanvasBoard=Ar;exports.Toolbar=Gt;exports.ZoomControl=Vt;
|
|
1
|
+
'use strict';var react=require('react'),drawuiCore=require('drawui-core'),jsxRuntime=require('react/jsx-runtime');function Y(){let[t,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),t}var wn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],xn="drawui:highlighterColor";function Ct(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(xn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}catch{return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR}}function vn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(xn,t);}catch{}}var Cn="drawui:stickyNoteColor";function St(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(Cn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function Sn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Cn,t);}catch{}}function To({icon:t,size:e=24,ink:o=drawuiCore.ICON_DEFAULT_INK}){return jsxRuntime.jsxs("svg",{viewBox:`0 0 ${drawuiCore.ICON_GRID} ${drawuiCore.ICON_GRID}`,width:e,height:e,fill:"none","aria-hidden":"true",children:[t.disc&&jsxRuntime.jsx("circle",{cx:drawuiCore.ICON_GRID/2,cy:drawuiCore.ICON_GRID/2,r:drawuiCore.ICON_GRID/2-1,fill:t.disc}),t.layers.map((i,y)=>{let c=i.fill??"ink",a=i.stroke??"ink";return jsxRuntime.jsx("path",{d:i.d,fill:c==="none"?"none":c==="ink"?o:c,...a==="none"?{}:{stroke:a==="ink"?o:a,strokeWidth:i.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},y)}),t.label&&jsxRuntime.jsx("text",{x:drawuiCore.ICON_GRID/2,y:drawuiCore.ICON_GRID/2+.5,textAnchor:"middle",dominantBaseline:"central",fontFamily:"sans-serif",fontSize:t.label.size??13,fill:t.label.color,children:t.label.text})]})}var Nn="drawui:recentIcons",In=12;function Ft(t,e){let o=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!o)return t;let i=parseInt(o[1],16);return `rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${e})`}function Lo(){if(typeof window>"u")return [];try{let t=JSON.parse(window.localStorage.getItem(Nn)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string").slice(0,In):[]}catch{return []}}function Eo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Nn,JSON.stringify(t));}catch{}}var En=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":Ft(t,.12)}),Rn=react.memo(function({onPick:e,onClose:o}){Y();let[i,y]=react.useState(""),[c,a]=react.useState(drawuiCore.ICON_CATEGORIES[0].id),[d,v]=react.useState(Lo),C=react.useRef(null),s=react.useRef(null);react.useEffect(()=>{s.current?.focus();},[]),react.useEffect(()=>{let p=M=>{let F=C.current;F&&(F.contains(M.target)||M.target?.closest?.("[data-icon-toggle]")||o());},I=M=>{M.key==="Escape"&&(M.stopPropagation(),o());};return window.addEventListener("pointerdown",p),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",p),window.removeEventListener("keydown",I);}},[o]);let h=react.useMemo(()=>d.map(p=>drawuiCore.getIcon(p)).filter(p=>!!p),[d]),w=react.useMemo(()=>i.trim()?drawuiCore.searchIcons(i):c==="recent"?h:drawuiCore.iconsByCategory(c),[i,c,h]),E=c==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[c]??drawuiCore.ICON_DEFAULT_INK,O=i.trim()?drawuiCore.t("icon.search"):c==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(p=>p.id===c)?.labelKey??"icon.search"),N=p=>{e(p),v(I=>{let M=[p.id,...I.filter(F=>F!==p.id)].slice(0,In);return Eo(M),M});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:C,style:{"--dw-icon-accent":E,"--dw-icon-soft":Ft(E,.08),"--dw-icon-ring":Ft(E,.22)},children:[jsxRuntime.jsxs("label",{className:"drawui-icon-search",children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),jsxRuntime.jsx("path",{d:"M15.4 15.4L20 20"})]}),jsxRuntime.jsx("input",{ref:s,value:i,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Enter"&&w.length>0&&N(w[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:w.length})]}),!i.trim()&&jsxRuntime.jsxs("div",{className:"drawui-icon-cats",children:[h.length>0&&jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${c==="recent"?" active":""}`,style:En(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>a("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(p=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${c===p.id?" active":""}`,style:En(drawuiCore.ICON_CATEGORY_INK[p.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>a(p.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(p.labelKey)]},p.id))]}),jsxRuntime.jsxs("div",{className:"drawui-icon-card",children:[jsxRuntime.jsxs("div",{className:"drawui-icon-card-head",children:[jsxRuntime.jsx("span",{className:"drawui-icon-card-title",children:O}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:w.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[w.map(p=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${p.zh} / ${p.en}`,"aria-label":`${p.zh} ${p.en}`,onClick:()=>N(p),children:jsxRuntime.jsx(To,{icon:p,size:30,ink:drawuiCore.iconInk(p)})},p.id)),w.length===0&&jsxRuntime.jsx("div",{className:"drawui-icon-empty",children:drawuiCore.t("icon.empty")})]})]})]})});var Ie=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Hn=(t,e)=>{let o=e*Math.PI/180;return {x:t.x*Math.cos(o)-t.y*Math.sin(o),y:t.x*Math.sin(o)+t.y*Math.cos(o)}},ft={x:Math.SQRT1_2,y:-Math.SQRT1_2},Vt={x:4.6,y:19.4},gt={x:19,y:5};function Yt(t,e,o){let i={x:-o.y,y:o.x},y=a=>({x:e.x-o.x*a,y:e.y-o.y*a}),c=(a,d)=>({x:a.x+i.x*d,y:a.y+i.y*d});switch(t){case "end":{let a=y(5.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,2.7))} ${Ie(c(a,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let a=y(8.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,3.5))} ${Ie(c(a,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let a=y(4.3),d=y(8.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,2.7))} ${Ie(d)} ${Ie(c(a,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let a=Hn({x:-o.x,y:-o.y},30),d=Hn({x:-o.x,y:-o.y},-30);return jsxRuntime.jsx("path",{d:`M ${Ie({x:e.x+a.x*5.8,y:e.y+a.y*5.8})} L ${Ie(e)} L ${Ie({x:e.x+d.x*5.8,y:e.y+d.y*5.8})}`,fill:"none"})}default:return null}}function Be(t,e){let o=e||t==="dependency"||t==="realization",i=o?{x:gt.x-ft.x*8.6,y:gt.y-ft.y*8.6}:gt,y={x:-ft.x,y:-ft.y};return jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:Vt.x,y1:Vt.y,x2:i.x,y2:i.y,strokeDasharray:o?"3 2.6":void 0}),(t==="end"||t==="both")&&Yt("end",gt,ft),(t==="start"||t==="both")&&Yt("end",Vt,y),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?Yt(t,gt,ft):null]})}var Tt=t=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:t})}),Io=[{type:"straight",labelKey:"style.connection.straight",icon:Tt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Tt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Tt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Tt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],An=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Be("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Be("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Be("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Be("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Be("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Be("both",true)}],Kn=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Be("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Be("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Be("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Be("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Be("realization",true)}],Pn=[...An,...Kn];function Ro(t,e){let o=Pn.find(i=>i.arrowHead===t&&i.dashed===e);return o?o.key:Pn.find(i=>i.arrowHead===t)?.key}var Et=react.memo(function({connectionType:e,arrowHead:o,dashed:i,onConnectionTypeChange:y,onArrowStyleChange:c,onOptionHover:a,onOptionLeave:d}){Y();let v=Ro(o,i),C=s=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:s.map(h=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${v===h.key?" active":""}`,onClick:()=>c(h),"data-drawui-tip":a?void 0:drawuiCore.t(h.labelKey),onMouseEnter:a?w=>a(h.labelKey,w.currentTarget):void 0,onMouseLeave:a?d:void 0,"aria-label":drawuiCore.t(h.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:h.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(h.labelKey)})]},h.key))});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.connection")}),jsxRuntime.jsx("div",{className:"drawui-connection-row",children:Io.map(s=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===s.type?" active":""}`,onClick:()=>y(s.type),"data-drawui-tip":a?void 0:drawuiCore.t(s.labelKey),onMouseEnter:a?h=>a(s.labelKey,h.currentTarget):void 0,onMouseLeave:a?d:void 0,"aria-label":drawuiCore.t(s.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(s.labelKey)})]},s.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),C(An),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),C(Kn)]})});var On=[{type:"rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsxRuntime.jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsxRuntime.jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsxRuntime.jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsxRuntime.jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsxRuntime.jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsxRuntime.jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsxRuntime.jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon:jsxRuntime.jsx("path",{d:"M12 2L14.5 8.5L21 9L16 13.5L17.5 20L12 16.5L6.5 20L8 13.5L3 9L9.5 8.5Z"})},{type:"cylinder",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsxRuntime.jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon:jsxRuntime.jsx("path",{d:"M7 18.5h9.4a3.4 3.4 0 0 0 .3-6.8 5 5 0 0 0-9.5-1.2A3.9 3.9 0 0 0 7 18.5Z"})},{type:"heart",icon:jsxRuntime.jsx("path",{d:"M12 20.3S4.6 15.7 4.6 10.5A4.1 4.1 0 0 1 12 7.6a4.1 4.1 0 0 1 7.4 2.9c0 5.2-7.4 9.8-7.4 9.8Z"})},{type:"block-arrow-right",icon:jsxRuntime.jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsxRuntime.jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsxRuntime.jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsxRuntime.jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsxRuntime.jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsxRuntime.jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsxRuntime.jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsxRuntime.jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsxRuntime.jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsxRuntime.jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsxRuntime.jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsxRuntime.jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsxRuntime.jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsxRuntime.jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsxRuntime.jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsxRuntime.jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsxRuntime.jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsxRuntime.jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsxRuntime.jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsxRuntime.jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M1 1C3.9 1 5.1 2.4 5.1 5.1c0 3.7 1.2 6.9 2.9 6.9-1.7 0-2.9 3.2-2.9 6.9 0 2.7-1.2 4.1-4.1 4.1"}),jsxRuntime.jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M23 1c-2.9 0-4.1 1.4-4.1 4.1 0 3.7-1.2 6.9-2.9 6.9 1.7 0 2.9 3.2 2.9 6.9 0 2.7 1.2 4.1 4.1 4.1"}),jsxRuntime.jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsxRuntime.jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})},{type:"uml-interface",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsxRuntime.jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsxRuntime.jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})},{type:"class-catalog",icon:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsxRuntime.jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),jsxRuntime.jsx("line",{x1:"17.4",y1:"5",x2:"17.4",y2:"19"})]})}],Ao=[{key:"basic",labelKey:"shapeGroup.basic",items:[{type:"rectangle"},{type:"rounded-rectangle"},{type:"stadium"},{type:"circle"},{type:"ellipse"},{type:"diamond"},{type:"triangle"},{type:"right-triangle"},{type:"hexagon"},{type:"parallelogram"},{type:"trapezoid"},{type:"pentagon"},{type:"octagon"},{type:"star"},{type:"envelope"},{type:"checkbox"}]},{key:"flowchart",labelKey:"shapeGroup.flowchart",items:[{type:"rectangle",labelKey:"flow.process"},{type:"rounded-rectangle",labelKey:"flow.step"},{type:"stadium",labelKey:"flow.startEnd"},{type:"diamond",labelKey:"flow.decision"},{type:"parallelogram",labelKey:"flow.data"},{type:"trapezoid",labelKey:"flow.manual"},{type:"hexagon",labelKey:"flow.preparation"},{type:"cylinder",labelKey:"flow.database"},{type:"delay",labelKey:"flow.delay"},{type:"predefined-process"},{type:"document"},{type:"block-arrow-right"},{type:"block-arrow-left"},{type:"block-arrow-up"},{type:"block-arrow-down"},{type:"block-arrow-double"}]},{key:"uml",labelKey:"shapeGroup.uml",items:[{type:"uml-class"},{type:"uml-interface"},{type:"rounded-rectangle",labelKey:"class.plain"},{type:"class-catalog"}]},{key:"solid",labelKey:"shapeGroup.solid",items:[{type:"cylinder"},{type:"cube"},{type:"cuboid"},{type:"triangular-pyramid"},{type:"quadrangular-pyramid"},{type:"sphere"},{type:"ellipsoid"},{type:"pie"},{type:"hollow-pie"}]},{key:"other",labelKey:"shapeGroup.other",items:[{type:"cloud"},{type:"heart"},{type:"cross"},{type:"sector"},{type:"chevron"},{type:"speech-rect"},{type:"speech-round"},{type:"brace-left"},{type:"brace-right"}]}],Ko=new Map(On.map(t=>[t.type,t.icon])),Oo=new Set(On.map(t=>t.type)),$o=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),Do=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Bo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",jt=8,zo=6,Xt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",_o=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],qt=react.memo(function({activeTool:e,onToolChange:o,showGrid:i,onToggleGrid:y,canUndo:c=false,canRedo:a=false,onUndo:d,onRedo:v,onExport:C,onExportData:s,onImportData:h,onHighlighterColorChange:w,onStickyNoteColorChange:E,onInsertIcon:O,onInsertTable:N,onInsertImage:p,arrowStyle:I,onArrowStyleChange:M}){let[F,l]=react.useState(false),[g,f]=react.useState(false),[b,H]=react.useState(null),[W,B]=react.useState(false),[Q,$]=react.useState(false),[X,pe]=react.useState(Ct),[ye,S]=react.useState(false),[ke,V]=react.useState(St),[Z,Ae]=react.useState(false),[ge,Ce]=react.useState(false),Le=react.useRef(null),Ke=r=>{let _=Array.from(r.target.files||[]);_.length&&p?.(_),r.target.value="";},[Se,Re]=react.useState(null),z=react.useRef(null),k=react.useRef(null),ie=react.useRef(null),se=react.useRef(null),j=react.useRef(null);Y();let Ee=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],D=()=>{z.current&&(clearTimeout(z.current),z.current=null),B(true);},Oe=()=>{z.current=window.setTimeout(()=>B(false),200);},be=react.useRef(null),Xe=()=>{B(false),T(),be.current?.click();},qe=r=>{let _=r.target.files?.[0];_&&h?.(_),r.target.value="";},rt=()=>{k.current&&(clearTimeout(k.current),k.current=null),l(true);},at=()=>{k.current=window.setTimeout(()=>{l(false),T();},200);},x=()=>{ie.current&&(clearTimeout(ie.current),ie.current=null),f(true);},U=()=>{ie.current=window.setTimeout(()=>{f(false),T();},200);},P=(r,_)=>{let A=r.closest(".drawui-toolbar");if(!A)return;let q=r.getBoundingClientRect(),$e=A.getBoundingClientRect(),ae=q.bottom+46>window.innerHeight;H({label:_,x:q.left-$e.left+q.width/2,y:ae?q.top-$e.top-8:q.bottom-$e.top+8,above:ae});},T=()=>H(null),ee=()=>{se.current&&(clearTimeout(se.current),se.current=null),$(true);},re=()=>{se.current=window.setTimeout(()=>$(false),200);},He=r=>{pe(r),vn(r),w?.(r),o("highlighter");},Je=()=>{j.current&&(clearTimeout(j.current),j.current=null),S(true);},_e=()=>{j.current=window.setTimeout(()=>S(false),200);},u=r=>{V(r),Sn(r),E?.(r),o("sticky-note"),S(false);};return jsxRuntime.jsx("div",{className:"drawui-toolbar-container",children:jsxRuntime.jsxs("div",{className:"drawui-toolbar",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>o("select"),onMouseEnter:r=>P(r.currentTarget,"toolbar.select"),onMouseLeave:T,children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M6 3 6 19.6 10.3 15.7 13 21.1 15.8 19.8 13.1 14.5 18.6 14 Z"})})}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>o("hand"),onMouseEnter:r=>P(r.currentTarget,"toolbar.hand"),onMouseLeave:T,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsxRuntime.jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsxRuntime.jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),jsxRuntime.jsx("path",{d:"M16.6 11.8V8.1a1.5 1.5 0 0 1 3 0v6.6a6.2 6.2 0 0 1-6.2 6.2h-1.5a6.2 6.2 0 0 1-5-2.5l-3.2-4.4a1.5 1.5 0 0 1 2.3-1.9l2.6 2.5"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:rt,onMouseLeave:at,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Oo.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),l(false),T();},"data-drawui-tip":F?void 0:drawuiCore.t("toolbar.shapes"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),F&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsxRuntime.jsx("div",{className:"drawui-shape-menu-scroll",children:Ao.map(r=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(r.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:r.items.map(_=>{let A=_.labelKey??`tool.${_.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===_.type?"active":""}`,onClick:()=>{o(_.type),l(false),T();},onMouseEnter:q=>P(q.currentTarget,A),onMouseLeave:T,"aria-label":drawuiCore.t(A),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ko.get(_.type)})},`${r.key}-${_.type}`)})})]},r.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Je,onMouseLeave:_e,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{o("sticky-note"),S(false),T();},"data-drawui-tip":ye?void 0:drawuiCore.t("tool.sticky-note"),children:[jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:$o}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:ke}})]}),ye&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-sticky-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-sticky-panel-head",children:[jsxRuntime.jsx("span",{className:"drawui-sticky-panel-title",children:drawuiCore.t("tool.sticky-note")}),jsxRuntime.jsx("span",{className:"drawui-sticky-panel-key",children:"N"})]}),jsxRuntime.jsx("div",{className:"drawui-sticky-panel-grid",children:drawuiCore.STICKY_NOTE_COLORS.map(r=>jsxRuntime.jsx("button",{type:"button","aria-label":r,className:`drawui-sticky-swatch${ke.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>u(r)},r))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Z?"active":""}`,"data-icon-toggle":"","data-drawui-tip":Z?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{Ae(r=>!r),T();},children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"9"}),jsxRuntime.jsx("path",{d:"M8.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M15.5 10.2h0.01"}),jsxRuntime.jsx("path",{d:"M8.8 14.2c0.9 1 2 1.5 3.2 1.5s2.3 -0.5 3.2 -1.5"})]})}),Z&&jsxRuntime.jsx(Rn,{onPick:r=>O?.(r.id),onClose:()=>Ae(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:x,onMouseLeave:U,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),f(false),T();},"data-drawui-tip":g?void 0:drawuiCore.t("toolbar.arrow"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),g&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:r=>{r.target.closest("button")||(f(false),T());},children:jsxRuntime.jsx(Et,{connectionType:I?.connectionType??"straight",arrowHead:I?.arrowHead??"end",dashed:!!I?.dashed,onConnectionTypeChange:r=>{M?.({connectionType:r}),o("arrow"),f(false),T();},onArrowStyleChange:r=>{M?.({arrowHead:r.arrowHead,dashed:r.dashed}),o("arrow"),f(false),T();},onOptionHover:(r,_)=>P(_,r),onOptionLeave:T})})]}),Do.filter(r=>r.type!=="arrow").map(r=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":drawuiCore.t(r.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:r.icon})})},r.type)),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>o("pen"),"data-drawui-tip":drawuiCore.t("toolbar.pen"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:Bo})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ee,onMouseLeave:re,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:r=>P(r.currentTarget,"toolbar.highlighter"),onMouseLeave:T,children:[jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxRuntime.jsxs("g",{fill:"currentColor",stroke:"none",children:[jsxRuntime.jsx("path",{d:Xt,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:Xt,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:Xt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:X}})]}),Q&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:wn.map(r=>jsxRuntime.jsx("button",{type:"button","aria-label":r,className:`drawui-highlighter-swatch${X.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>He(r)},r))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),_o.map(r=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":drawuiCore.t(r.labelKey),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:r.icon})})},r.type)),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>o("mind-map"),"data-drawui-tip":drawuiCore.t("toolbar.mind-map"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsxRuntime.jsx("path",{d:"M7.4 12h3.6"}),jsxRuntime.jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsxRuntime.jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsxRuntime.jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:()=>Le.current?.click(),"data-drawui-tip":drawuiCore.t("toolbar.image"),"data-image-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),jsxRuntime.jsx("path",{d:"M21 15.5l-4.5-4.5L6 21"})]})}),jsxRuntime.jsx("input",{ref:Le,type:"file",accept:"image/*",multiple:true,style:{display:"none"},onChange:Ke}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${ge?"active":""}`,onClick:()=>Ce(r=>!r),"data-drawui-tip":drawuiCore.t("toolbar.table"),"data-table-toggle":true,children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsxRuntime.jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsxRuntime.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsxRuntime.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),ge&&jsxRuntime.jsxs("div",{className:"drawui-table-picker",children:[jsxRuntime.jsx("div",{className:"drawui-table-picker-hint",children:Se?`${Se.rows} \xD7 ${Se.cols}`:drawuiCore.t("table.pickHint")}),jsxRuntime.jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:zo*jt},(r,_)=>{let A=Math.floor(_/jt),q=_%jt,$e=Se&&A<Se.rows&&q<Se.cols;return jsxRuntime.jsx("button",{type:"button","aria-label":`${A+1}x${q+1}`,className:"drawui-table-picker-cell",style:$e?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Re({rows:A+1,cols:q+1}),onClick:()=>{N?.(A+1,q+1),Ce(false),Re(null),T();}},_)})})]})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${i?"active":""}`,onClick:y,"data-drawui-tip":drawuiCore.t("toolbar.grid"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsxRuntime.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:d,disabled:!c,style:c?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":drawuiCore.t("toolbar.undo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 7v6h6"}),jsxRuntime.jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsxRuntime.jsx("button",{className:"drawui-toolbar-button",onClick:v,disabled:!a,style:a?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":drawuiCore.t("toolbar.redo"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 7v6h-6"}),jsxRuntime.jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:D,onMouseLeave:Oe,children:[jsxRuntime.jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":W?void 0:drawuiCore.t("toolbar.export"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsxRuntime.jsx("polyline",{points:"7 10 12 15 17 10"}),jsxRuntime.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),W&&jsxRuntime.jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:[Ee.map(r=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{C?.(r.format),B(false);},"data-drawui-tip":drawuiCore.t(r.labelKey),children:drawuiCore.t(r.labelKey)},r.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{s?.(),B(false);},"data-drawui-tip":drawuiCore.t("toolbar.export.data"),children:drawuiCore.t("toolbar.export.data")}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:Xe,"data-drawui-tip":drawuiCore.t("toolbar.import.data"),children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:be,type:"file",accept:".json,application/json",style:{display:"none"},onChange:qe}),b&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${b.above?"is-above":"is-below"}`,style:{left:b.x,top:b.y},children:drawuiCore.t(b.label)})]})})});var Qt=react.memo(function({onZoomIn:e,onZoomOut:o,onReset:i,zoomLevel:y=100}){return Y(),jsxRuntime.jsxs("div",{className:"drawui-zoom-control",children:[jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":drawuiCore.t("zoom.in"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsxRuntime.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxRuntime.jsxs("div",{className:"drawui-zoom-level",children:[y,"%"]}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:o,"data-drawui-tip":drawuiCore.t("zoom.out"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsxRuntime.jsx("button",{className:"drawui-zoom-button",onClick:i,"data-drawui-tip":drawuiCore.t("zoom.reset"),children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})})]})});var Dn=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Bn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Yo=Dn.filter(t=>t!=="#f1f5f9"),jo=[...Yo,...Bn],Xo=[...Dn,...Bn],zn=15,_n="drawui:customColors";function qo(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(_n);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-zn):[]}catch{return []}}function Jo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(_n,JSON.stringify(t));}catch{}}var en=[{key:"fill",labelKey:"style.fill",hasTransparent:true,hasOpacity:true},{key:"stroke",labelKey:"style.stroke",hasTransparent:false,hasOpacity:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true,hasOpacity:true}],$n=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),wt=10,st=12,nt=t=>!t||t==="transparent",Wn=react.memo(function({editor:e,selectedCount:o,hasLineSelection:i,currentConnectionType:y,currentArrowHead:c,currentDashed:a}){Y();let d=!!e?.getEditingShapeId(),[v,C]=react.useState(null),[s,h]=react.useState(null),[,w]=react.useState(0),E=react.useRef(null),O=react.useRef(null),N=react.useRef(null),[p,I]=react.useState({tw:168,th:42,pw:228,ph:160}),[M,F]=react.useState(qo),l=react.useRef(null),g=react.useCallback(u=>{let r=u.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(r)&&F(_=>{let A=_.filter(q=>q!==r);for(A.push(r);A.length>zn;)A.shift();return Jo(A),A});},[]);if(react.useEffect(()=>{let u=l.current;if(!u)return;let r=()=>{u.value&&g(u.value);};return u.addEventListener("change",r),()=>u.removeEventListener("change",r)},[g,s]),react.useEffect(()=>{if(!e)return;let u=e.subscribe(()=>w(r=>(r+1)%1e6));return ()=>{u();}},[e]),react.useEffect(()=>{h(null);},[o,d]),react.useEffect(()=>{if(!s)return;let u=r=>{E.current&&!E.current.contains(r.target)&&h(null);};return document.addEventListener("pointerdown",u,true),()=>document.removeEventListener("pointerdown",u,true)},[s]),react.useLayoutEffect(()=>{let u=O.current?.offsetWidth??p.tw,r=O.current?.offsetHeight??p.th,_=N.current?.offsetWidth??p.pw,A=N.current?.offsetHeight??p.ph;I(q=>q.tw===u&&q.th===r&&q.pw===_&&q.ph===A?q:{tw:u,th:r,pw:_,ph:A});}),!e||o===0||d)return null;let f=e.getSelectedIds(),H=e.getShapes().filter(u=>f.includes(u.id)),W=H[0],B=W?.id??"",Q=W?.style.fillColor,$=W?.style.strokeColor??"#1f2937",X=W?.textColor??"#1f2937",pe=W?.highlightColor,ye={fill:Q,stroke:$,text:X,highlight:pe},S=H.length>0&&H.every(u=>u.type==="sticky-note"),ke={fill:W?.style.fillOpacity??1,stroke:W?.style.strokeOpacity??1,highlight:W?.highlightOpacity??1},V=u=>v&&v.key===`${B}:${u}`?v.value:ke[u]??1,Z=(u,r)=>{switch(u){case "stroke":e.updateSelectedShapesStyle({strokeColor:r});break;case "fill":e.updateSelectedShapesStyle({fillColor:r});break;case "text":e.updateSelectedShapesText({textColor:r});break;case "highlight":e.updateSelectedShapesText({highlightColor:r});break}},Ae=(u,r)=>{C({key:`${B}:${u}`,value:r}),u==="highlight"?e.updateSelectedShapesText({highlightOpacity:r}):u==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:r}):e.updateSelectedShapesStyle({fillOpacity:r});},ge=u=>e.updateConnectionType(u),Ce=u=>e.updateArrowStyle({arrowHead:u.arrowHead,dashed:u.dashed}),Le=!!i&&H.length>0&&H.every(u=>u.type==="line"||u.type==="arrow"),Ke=H.length>0&&H.every(u=>u.type==="text"),Se=H.length>0&&H.every(u=>u.type==="sticky-note"||u.type==="icon"),Re=Le?en.filter(u=>u.key==="stroke"):Se?en.filter(u=>u.key!=="stroke"):en,z=u=>u.key==="stroke"&&Le?"style.line":u.labelKey,k=s&&s!=="more"?Re.find(u=>u.key===s):void 0,ie=!!s&&(s==="more"||s==="prefix"||!!k),se=S&&k?.key==="fill",j=e.getCamera(),Ee=drawuiCore.getContentBounds(H,0),D=j.pageToScreen({x:Ee.x,y:Ee.y}),Oe=j.pageToScreen({x:Ee.x+Ee.width,y:Ee.y+Ee.height}),be=window.innerWidth,Xe=window.innerHeight,qe=Oe.y+wt,rt=D.y-wt,at=p.th+(ie?wt+p.ph:0),x=qe+at<=Xe-st,U=rt-at>=st,P=x||!U,T=(D.x+Oe.x)/2,ee=(u,r,_)=>Math.max(r,Math.min(u,Math.max(r,_))),re=ee(T-p.tw/2,st,be-p.tw-st),He=P?qe:rt-p.th,Je=ee(T-p.pw/2,st,be-p.pw-st),_e=ie?ee(P?He+p.th+wt:He-wt-p.ph,st,Xe-p.ph-st):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:E,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:O,style:{left:re,top:He},children:[Re.map(u=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${s===u.key?" active":""}`,onClick:()=>h(s===u.key?null:u.key),"data-drawui-tip":drawuiCore.t(z(u)),type:"button",children:[u.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${nt(Q)?" drawui-st-none":""}`,style:nt(Q)?void 0:{background:Q}}),u.key==="stroke"&&(Le?jsxRuntime.jsx("span",{className:`drawui-st-line${nt($)?" drawui-st-line-none":""}`,style:nt($)?void 0:{background:$}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${nt($)?" drawui-st-frame-none":""}`,style:nt($)?void 0:{borderColor:$}})),u.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:X},children:"A"}),u.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${nt(pe)?" drawui-st-none":""}`,style:nt(pe)?void 0:{background:pe},children:"A"})]},u.key)),i&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${s==="more"?" active":""}`,onClick:()=>h(s==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Ke&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${s==="prefix"?" active":""}`,onClick:()=>h(s==="prefix"?null:"prefix"),"data-drawui-tip":drawuiCore.t("style.prefix"),type:"button",children:jsxRuntime.jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsxRuntime.jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsxRuntime.jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),ie&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:N,style:{left:Je,top:_e},children:s==="prefix"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.prefix")}),jsxRuntime.jsx("div",{className:"drawui-muted-hint",children:drawuiCore.t("style.prefix.soon")})]}):k?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t(z(k))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[k.hasTransparent&&!se&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${nt(ye[k.key])?" active":""}`,onClick:()=>Z(k.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(se?drawuiCore.STICKY_NOTE_COLORS:k.hasTransparent?jo:Xo).map(u=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${$n(u,ye[k.key])?" active":""}`,style:{background:u},onClick:()=>Z(k.key,u),"aria-label":u,type:"button"},u)),M.map(u=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${$n(u,ye[k.key])?" active":""}`,style:{background:u},onClick:()=>Z(k.key,u),"aria-label":u,type:"button"},`custom-${u}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:l,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":drawuiCore.t("style.addColor")})]})]}),k.hasOpacity&&jsxRuntime.jsxs("div",{className:"drawui-opacity-row",children:[jsxRuntime.jsx("span",{className:"drawui-opacity-label",children:drawuiCore.t("style.opacity")}),jsxRuntime.jsx("input",{type:"range",min:0,max:100,value:Math.round(V(k.key)*100),onChange:u=>Ae(k.key,Number(u.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(V(k.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Et,{connectionType:y??"straight",arrowHead:c??"end",dashed:!!a,onConnectionTypeChange:ge,onArrowStyleChange:Ce})})})]})});var on=14,Gn=20,ar=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],ir=[12,14,16,18,20,24];function Fn(t,e){let o=t,i="",y=o.charAt(0);if(o.length>1&&(y==="+"||y==="-"||y==="#"||y==="~")&&o.charAt(1)===" "&&(i=y,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let s=o.indexOf(":");return s===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:o.slice(s+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let c=o.indexOf("(");if(c===-1){let s=o.lastIndexOf(":");return s===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(s+1).replace(/^\s+|\s+$/g,"")}}let a=o.slice(0,c).replace(/^\s+|\s+$/g,""),d=o.indexOf(")",c);if(d===-1)return {visibility:i,name:a,type:"",params:o.slice(c+1).replace(/^\s+|\s+$/g,""),returnType:""};let v=o.slice(c+1,d).replace(/^\s+|\s+$/g,""),C=o.slice(d+1).replace(/^\s+|\s+$/g,"");return C.startsWith(":")&&(C=C.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:i,name:a,type:"",params:v,returnType:C}}function sr(t,e){let o=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${o}${e.name}${e.type?`: ${e.type}`:""}`:`${o}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var Yn=react.memo(function({editor:e,umlClass:o,editing:i}){let[,y]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let x=e.subscribe(()=>y(U=>U+1));return ()=>{x();}},[e]);let[c,a]=react.useState(null),[d,v]=react.useState(false),[C,s]=react.useState(null),h=react.useRef(null),w=react.useRef(null),E=react.useCallback((x,U)=>{h.current&&(clearTimeout(h.current),h.current=null),a({section:x,rowId:U}),v(false);},[]),O=react.useCallback(()=>{h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{a(null),v(false);},150);},[]);if(!e||!o||i!==o.id)return null;let N=e.getCamera(),{id:p,x:I,y:M,width:F,height:l,className:g,methods:f}=o,b=o.type==="uml-interface",H=b?[]:o.attributes,W=F/2,B=l/2,Q=drawuiCore.UML_HEADER_HEIGHT,$=drawuiCore.UML_LINE_HEIGHT,X=drawuiCore.UML_PADDING_X,pe=drawuiCore.UML_PADDING_Y,ye=b?0:H.length>0?H.length*$+pe*2:pe*2,S=N.zoom,ke=(F-X*2)*S,V=4*S,Z=N.pageToScreen({x:I-W+X,y:M}),Ae=N.pageToScreen({x:I,y:M-B+Q/2}),ge=x=>N.pageToScreen({x:I,y:x}).y,Ce=$*S,Le=x=>M+(-B+Q+pe+$/2+x*$),Ke=x=>M+(-B+Q+ye+pe+$/2+x*$),Se=M+(-B+Q+ye),Re=M+B,z={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},k=(x,U)=>{if(!H.find(ee=>ee.id===x))return;let T=Fn(U,"attribute");e.updateUmlClass(p,{attributes:H.map(ee=>ee.id===x?{...ee,...T}:ee)});},ie=(x,U)=>{if(!f.find(re=>re.id===x))return;let T=Fn(U,"method"),ee=f.map(re=>re.id===x?{...re,...T}:re);b?e.updateUmlInterface(p,{methods:ee}):e.updateUmlClass(p,{methods:ee});},se=(x,U,P)=>{w.current={section:x,from:U},P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("text/plain",`${x}:${U}`);},j=x=>{x.preventDefault(),x.dataTransfer.dropEffect="move";},Ee=(x,U,P)=>{P.preventDefault();let T=w.current;!T||T.section!==x||(x==="attribute"?e.reorderUmlAttribute(p,T.from,U):e.reorderUmlMethod(p,T.from,U),w.current=null);},D=(x,U,P,T)=>{let ee=ge(T),re=c?.section===x&&c.rowId===P.id,He=(P.fontSize||drawuiCore.UML_FONT_SIZE)*S,Je=P.textColor||"#1f2937",_e={position:"absolute",left:Z.x-on*S-V,top:ee-Ce/2,width:on*S+V+ke+Gn*S,height:Ce,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},u={...z,width:ke,height:Ce-2,fontSize:He,color:Je,textDecoration:P.strikethrough?"line-through":"none",pointerEvents:"auto",...re?{borderColor:"var(--dw-primary)"}:{}},r={width:on*S,height:Ce-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*S,lineHeight:1,opacity:re?1:.55,pointerEvents:"auto"},_={width:Gn*S,height:Ce-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*S,opacity:re?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:_e,onDragOver:j,onDrop:A=>Ee(x,U,A),children:[jsxRuntime.jsx("span",{style:r,draggable:true,onDragStart:A=>se(x,U,A),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:u,value:C&&C.rowId===P.id?C.text:sr(x,P),onChange:A=>{s({rowId:P.id,text:A.target.value}),x==="attribute"?k(P.id,A.target.value):ie(P.id,A.target.value);},onFocus:()=>E(x,P.id),onBlur:()=>{s(null),O();},spellCheck:false}),jsxRuntime.jsx("button",{style:_,onMouseDown:A=>A.preventDefault(),onClick:()=>{x==="attribute"?e.removeUmlAttribute(p,P.id):e.removeUmlMethod(p,P.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},P.id)},Oe=(x,U,P)=>{let T=ge(U),ee=x==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:re=>re.preventDefault(),onClick:()=>ee?e.addUmlAttribute(p):e.addUmlMethod(p),className:"drawui-uml-add-row",style:{position:"absolute",left:Z.x,top:T-9*S,height:18*S,padding:`0 ${6*S}px`,fontSize:11*S,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},"data-drawui-tip":P,children:[jsxRuntime.jsx("span",{style:{fontSize:13*S,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:P})]},`add-${x}`)},be=()=>{if(!c||c.section==="className")return null;let x=c.section,U=c.rowId,T=(x==="attribute"?H:f).find(ae=>ae.id===U);if(!T)return null;let ee=224*S,re=30*S,He=N.pageToScreen({x:I,y:M}).x,Je=N.pageToScreen({x:I,y:M-B}).y,_e=20*S,u=Je-re-_e,r=He-ee/2,_=u+re,A=T.textColor||"#1f2937",q=T.fontSize||drawuiCore.UML_FONT_SIZE,$e=!!T.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:He-.5,top:_,width:1,height:_e,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:r,top:u,width:ee,height:re,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*S,padding:`0 ${6*S}px`,pointerEvents:"auto",zIndex:60,fontSize:12*S},onMouseDown:ae=>ae.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>v(ae=>!ae),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsxRuntime.jsx("span",{style:{fontWeight:700,color:A,fontSize:13*S,textDecoration:$e?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*S,height:2*S,background:A,marginLeft:3,borderRadius:1}})]}),d&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"100%",left:0,marginTop:4,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:4,padding:4,display:"flex",gap:2,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",zIndex:61},children:[jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(p,x,T.id,{textColor:null}),v(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":drawuiCore.t("uml.defaultColor")}),ar.map(ae=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(p,x,T.id,{textColor:ae}),v(false);},style:{width:14,height:14,border:"none",background:ae,cursor:"pointer",borderRadius:2},"data-drawui-tip":ae},ae))]})]}),jsxRuntime.jsx("select",{value:q,onChange:ae=>e.updateUmlRowStyle(p,x,T.id,{fontSize:Number(ae.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*S}px`,fontSize:12*S,height:20*S,background:"#ffffff"},"data-drawui-tip":drawuiCore.t("uml.fontSize"),children:ir.map(ae=>jsxRuntime.jsx("option",{value:ae,children:ae},ae))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(p,x,T.id,{strikethrough:!$e}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:$e?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsxRuntime.jsx("span",{style:{fontWeight:700,fontSize:13*S,textDecoration:"line-through"},children:"A"})}),jsxRuntime.jsx("button",{onClick:()=>{x==="attribute"?e.removeUmlAttribute(p,T.id):e.removeUmlMethod(p,T.id),a(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxRuntime.jsxs("svg",{width:14*S,height:14*S,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("polyline",{points:"3 6 5 6 21 6"}),jsxRuntime.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsxRuntime.jsx("path",{d:"M10 11v6"}),jsxRuntime.jsx("path",{d:"M14 11v6"}),jsxRuntime.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},Xe=N.pageToScreen({x:I-W,y:M}).x,qe=N.pageToScreen({x:I,y:M-B}).y,rt=F*S,at=l*S;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Xe+1,top:qe+1,width:Math.max(0,rt-2),height:Math.max(0,at-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...z,position:"absolute",left:Ae.x-ke/2,top:Ae.y-Q*S/2+2,width:ke,height:Q*S-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||drawuiCore.UML_FONT_SIZE)*S,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...c?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:g,onChange:x=>b?e.updateUmlInterface(p,{className:x.target.value}):e.updateUmlClass(p,{className:x.target.value}),onFocus:()=>E("className",""),onBlur:O,spellCheck:false}),!b&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[H.map((x,U)=>D("attribute",U,x,Le(U))),Oe("attribute",Se,"\u5C5E\u6027")]}),f.map((x,U)=>D("method",U,x,Ke(U))),Oe("method",Re,drawuiCore.t("uml.method")),be()]})});var Jn=react.memo(function({editor:e,panelOpen:o,onOpenPanel:i}){let[,y]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let l=e.subscribe(()=>y(g=>g+1));return ()=>{l();}},[e]);let c=react.useRef(false),a=react.useRef(false),d=e?.getMindMapEditingShapeId()??null,v=e?.getMindMapSelectedNode()?.nodeId??"",C=d?`${d}\0${v}`:"";if(react.useEffect(()=>{c.current=false;},[C]),!e)return null;let s=e.getMindMapEditingShapeId();if(!s||o)return null;let h=e.getMindMapSelectedNode();if(!h||h.shapeId!==s)return null;let w=e.getMindMapNode(s,h.nodeId),E=e.getMindMapNodeScreenRect(s,h.nodeId);if(!w||!E)return null;let O=e.getCamera().getZoom(),N=drawuiCore.MINDMAP_FONT_SIZE*O,p=Math.max(100,E.width+24),I=E.height+8,M={position:"absolute",left:E.x+E.width/2,top:E.y-4,transform:"translateX(-50%)",width:p,height:I,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(w.icon?24:12)*O}px`,fontFamily:"sans-serif",fontSize:N,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},F={position:"absolute",left:E.x+E.width+12,top:E.y+E.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("input",{autoFocus:true,style:M,value:w.text,spellCheck:false,onChange:l=>{let g=!c.current;c.current=true,e.updateMindMapNode(s,h.nodeId,{text:l.target.value},g);},onBlur:()=>{if(a.current){a.current=false;return}e.exitMindMapEdit();},onKeyDown:l=>{l.key==="Enter"?l.target.blur():l.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:F,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:l=>{l.preventDefault(),a.current=true,setTimeout(()=>{a.current=false;},300);},onClick:i,children:"\u22EF"})]})});var to=react.memo(function({editor:e,panelOpen:o}){let[,i]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let I=e.subscribe(()=>i(M=>M+1));return ()=>{I();}},[e]);let y=react.useRef(false),c=e?.getTableEditing()??null,a=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(react.useEffect(()=>{y.current=false;},[a]),!e||o)return null;let d=e.getTableEditing();if(!d)return null;let{shapeId:v,row:C,col:s}=d,h=e.getTableCell(v,C,s),w=e.getTableScreenRect(v,C,s);if(!h||!w)return null;let E=e.getSelectedTable(),O=h.fontSize||E?.fontSize||drawuiCore.TABLE_FONT_SIZE,N=e.getCamera().getZoom(),p={left:w.x-1,top:w.y-1,width:w.width+2,height:w.height+2,padding:`${drawuiCore.TABLE_CELL_PADDING_Y*N}px ${drawuiCore.TABLE_CELL_PADDING_X*N}px`,fontFamily:"sans-serif",fontSize:O*N,lineHeight:drawuiCore.TABLE_LINE_HEIGHT_RATIO,fontWeight:h.bold?700:400,color:h.textColor||E?.textColor||"#1f2937",textAlign:h.align==="center"?"center":h.align==="right"?"right":"left"};return jsxRuntime.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsxRuntime.jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:p,value:h.text,spellCheck:false,onChange:I=>{let M=!y.current;y.current=true,e.updateTableCell(v,C,s,{text:I.target.value},M);},onBlur:()=>{e.exitTableEdit();},onKeyDown:I=>{(I.key==="Enter"||I.key==="Escape")&&(I.preventDefault(),I.target.blur());}})})});var ro=react.memo(function({editor:e}){let[,o]=react.useState(0),[i,y]=react.useState(null),c=react.useRef(null);if(Y(),react.useEffect(()=>{if(!e)return;let $=e.subscribe(()=>o(X=>X+1));return ()=>{$();}},[e]),react.useEffect(()=>{if(!i)return;let $=pe=>{let ye=pe.target;ye&&c.current?.contains(ye)||y(null);},X=pe=>{pe.key==="Escape"&&y(null);};return window.addEventListener("pointerdown",$,true),window.addEventListener("keydown",X),()=>{window.removeEventListener("pointerdown",$,true),window.removeEventListener("keydown",X);}},[i]),!e)return null;let a=e.getSelectedTable();if(!a)return null;let d=e.getTableSelection();if(!d||d.shapeId!==a.id)return null;let v=e.getTableScreenRect(a.id);if(!v)return null;let C=a.cells.length,s=a.cells[0]?.length??0,h=drawuiCore.tableExpandRangeToMerges(a,d.anchor.row,d.anchor.col,d.focus.row,d.focus.col),{r1:w,c1:E,r2:O,c2:N}=h,p=drawuiCore.tableCoveredMap(a.cells),I=0;for(let $=w;$<=O;$++)for(let X=E;X<=N;X++)p[$]?.[X]||I++;let M=I>1,F=drawuiCore.tableRangeHasMerge(a,w,E,O,N),l=w===O?`${w+1}`:`${w+1}\u2013${O+1}`,g=E===N?`${E+1}`:`${E+1}\u2013${N+1}`,f=C-(O-w+1)>=1,b=s-(N-E+1)>=1,W=v.y>56?v.y-40:v.y+v.height+10,B=$=>$.stopPropagation(),Q=$=>()=>{$(),y(null);};return jsxRuntime.jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:v.x+v.width/2,top:W},onPointerDown:B,children:[jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(a.id,"below"),children:drawuiCore.t("table.insertRow")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${i==="row"?"active":""}`,"data-table-insert-row":true,title:`${drawuiCore.t("table.insertRowAbove")} / ${drawuiCore.t("table.insertRowBelow")}`,onClick:()=>y(i==="row"?null:"row"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),i==="row"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsxRuntime.jsx("button",{onClick:Q(()=>e.insertTableRowRelative(a.id,"above")),children:drawuiCore.t("table.insertRowAbove")}),jsxRuntime.jsx("button",{onClick:Q(()=>e.insertTableRowRelative(a.id,"below")),children:drawuiCore.t("table.insertRowBelow")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteRow")} \xB7 ${l}`,disabled:!f,onClick:()=>e.deleteTableRowsInSelection(a.id),children:drawuiCore.t("table.deleteRow")}),jsxRuntime.jsxs("div",{className:"drawui-table-split",children:[jsxRuntime.jsx("button",{className:"drawui-table-btn-main",title:drawuiCore.t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(a.id,"right"),children:drawuiCore.t("table.insertCol")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${i==="col"?"active":""}`,"data-table-insert-col":true,title:`${drawuiCore.t("table.insertColLeft")} / ${drawuiCore.t("table.insertColRight")}`,onClick:()=>y(i==="col"?null:"col"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsxRuntime.jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),i==="col"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsxRuntime.jsx("button",{onClick:Q(()=>e.insertTableColumnRelative(a.id,"left")),children:drawuiCore.t("table.insertColLeft")}),jsxRuntime.jsx("button",{onClick:Q(()=>e.insertTableColumnRelative(a.id,"right")),children:drawuiCore.t("table.insertColRight")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteCol")} \xB7 ${g}`,disabled:!b,onClick:()=>e.deleteTableColsInSelection(a.id),children:drawuiCore.t("table.deleteCol")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.merge"),disabled:!M,onClick:()=>e.mergeTableCells(a.id),children:drawuiCore.t("table.merge")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.split"),disabled:!F,onClick:()=>e.splitTableCells(a.id),children:drawuiCore.t("table.split")})]})});var ao=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],io=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Rr={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},rn={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Pt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},sn={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 6px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5,whiteSpace:"nowrap"},so={...sn,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},an={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},lo=react.memo(function({editor:e,mindMap:o}){let[,i]=react.useState(0);Y(),react.useEffect(()=>{if(!e)return;let l=e.subscribe(()=>i(g=>g+1));return ()=>{l();}},[e]);let y=react.useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let c=e.getMindMapSelectedNode();if(!c||c.shapeId!==o.id)return null;let a=l=>{if(l.id===c.nodeId)return l;for(let g of l.children??[]){let f=a(g);if(f)return f}return null},d=a(o.root);if(!d)return null;let v=e.getCamera(),s=drawuiCore.layoutMindMap(o.root).positions.get(d.id);if(!s)return null;let h=v.zoom,w=v.pageToScreen({x:o.x+s.x,y:o.y+s.y}),E=w.x+s.width*h/2+14,O=w.y-80,p=Math.max(8,Math.min(E,(window.innerWidth||1024)-232-8)),I=Math.max(8,Math.min(O,(window.innerHeight||768)-320)),M=l=>{e.updateMindMapNode(o.id,d.id,l);},F=!!d.id&&d.id!==o.root.id;return jsxRuntime.jsxs("div",{ref:y,style:{...Rr,left:p,top:I},onMouseDown:l=>l.stopPropagation(),children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsxRuntime.jsx("span",{style:{fontWeight:600,fontSize:12},children:drawuiCore.t("mindmap.nodeText")}),jsxRuntime.jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[!!d.children?.length&&jsxRuntime.jsx("button",{style:{...sn,padding:"1px 5px",color:"#6b7280"},"data-drawui-tip":d.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse"),onClick:()=>e.toggleMindMapCollapse(o.id,d.id),children:d.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{onClick:()=>e.exitMindMapEdit(),"data-drawui-tip":drawuiCore.t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]})]}),jsxRuntime.jsx("input",{style:{...an,marginBottom:8},value:d.text,onChange:l=>M({text:l.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...Pt,gap:4,marginBottom:10,flexWrap:"nowrap"},children:[jsxRuntime.jsxs("button",{style:so,onClick:()=>e.addMindMapChild(o.id,d.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),F&&jsxRuntime.jsxs("button",{style:so,onClick:()=>e.addMindMapSibling(o.id,d.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),jsxRuntime.jsx("button",{style:{...sn,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto",flexShrink:0},onClick:()=>e.deleteMindMapNode(o.id,d.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:rn,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Pt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.levelColor"),onClick:()=>M({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),ao.map(l=>jsxRuntime.jsx("button",{"data-drawui-tip":l,onClick:()=>M({color:l}),style:{width:18,height:18,borderRadius:4,border:d.color===l?"2px solid #111827":"1px solid #d1d5db",background:l,cursor:"pointer",flexShrink:0}},l))]}),jsxRuntime.jsx("span",{style:rn,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Pt,marginBottom:10},children:[jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noIcon"),onClick:()=>M({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:d.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),io.map(l=>jsxRuntime.jsx("button",{onClick:()=>M({icon:l}),style:{width:22,height:22,borderRadius:4,border:d.icon===l?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:l},l)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:d.icon&&!io.includes(d.icon)?d.icon:"",onKeyDown:l=>{if(l.key==="Enter"){let g=l.target.value.trim();M({icon:g||void 0});}},onBlur:l=>{let g=l.target.value.trim();g!==d.icon&&M({icon:g||void 0});},style:{...an,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:rn,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...an,marginBottom:6},value:d.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:l=>M({note:l.target.value||void 0}),spellCheck:false}),!!d.note&&jsxRuntime.jsxs("div",{style:{...Pt,marginTop:4},children:[jsxRuntime.jsx("span",{style:{fontSize:11,color:"#6b7280"},children:drawuiCore.t("mindmap.noteColor")}),jsxRuntime.jsx("button",{"data-drawui-tip":drawuiCore.t("mindmap.noteColorDefault"),onClick:()=>M({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:d.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),ao.map(l=>jsxRuntime.jsx("button",{onClick:()=>M({noteColor:l}),style:{width:16,height:16,borderRadius:3,border:d.noteColor===l?"2px solid #111827":"1px solid #d1d5db",background:l,cursor:"pointer"}},l))]})]})});var cn=220,dn=140,Or="#fafafa";function $r(t,e){let o=Math.min(t.x,e.x),i=Math.min(t.y,e.y),y=Math.max(t.x+t.width,e.x+e.width),c=Math.max(t.y+t.height,e.y+e.height);return {x:o,y:i,width:y-o,height:c-i}}function Dr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Br(){return {x:0,y:0,width:0,height:0}}function zr(t){let e=1/0,o=1/0,i=-1/0,y=-1/0,c=false;for(let a of t){let d=pn(a);d&&(c=true,d.x<e&&(e=d.x),d.y<o&&(o=d.y),d.x+d.width>i&&(i=d.x+d.width),d.y+d.height>y&&(y=d.y+d.height));}return c?{x:e,y:o,width:i-e,height:y-o}:null}function pn(t){switch(t.type){case "rectangle":case "sticky-note":case "icon":case "image":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "table":case "text":return {x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height};case "circle":return {x:t.x-t.radius,y:t.y-t.radius,width:t.radius*2,height:t.radius*2};case "line":case "arrow":{let e=t.points;if(!e||e.length===0)return null;let o=1/0,i=1/0,y=-1/0,c=-1/0;for(let a of e)a.x<o&&(o=a.x),a.y<i&&(i=a.y),a.x>y&&(y=a.x),a.y>c&&(c=a.y);return {x:o,y:i,width:y-o,height:c-i}}case "draw":{let e=t,o=e.width,i=e.height;if(typeof o=="number"&&typeof i=="number")return {x:e.x-o/2,y:e.y-i/2,width:o,height:i};let y=e.points;if(!y||y.length===0)return null;let c=1/0,a=1/0,d=-1/0,v=-1/0;for(let C of y){let s=C.x+e.x,h=C.y+e.y;s<c&&(c=s),h<a&&(a=h),s>d&&(d=s),h>v&&(v=h);}return {x:c,y:a,width:d-c,height:v-a}}default:return null}}function _r(t){let e=t.getCamera(),o=e.screenToPage({x:0,y:0}),i=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:i.x-o.x,height:i.y-o.y}}function Wr(t,e,o){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-o/2,width:e,height:o};let i=e/o,y=t.width,c=y/i;c<t.height&&(c=t.height,y=c*i);let a=Dr(t);return {x:a.x-y/2,y:a.y-c/2,width:y,height:c}}function un(t,e,o,i){let y=(t-o.left)/o.width,c=(e-o.top)/o.height;return {x:i.x+y*i.width,y:i.y+c*i.height}}var po=react.memo(function({editor:e}){let o=react.useRef(null),i=react.useRef(null),[y,c]=react.useState(false),[a,d]=react.useState(100),[v,C]=react.useState(false),[s,h]=react.useState(false);Y();let w=react.useRef(null),E=react.useRef(null);react.useLayoutEffect(()=>{let l=o.current,g=i.current;if(!l||!g)return;let f=window.devicePixelRatio||1;l.width=Math.round(cn*f),l.height=Math.round(dn*f),l.style.width=`${cn}px`,l.style.height=`${dn}px`;},[y]);let O=react.useCallback(()=>{let l=o.current,g=i.current;if(!l||!g||!e)return;let f=l.getContext("2d");if(!f)return;let b=cn,H=dn,W=l.width,B=l.height,Q=e.getShapes(),$=new Set(e.getSelectedIds()),X=drawuiCore.getTheme(),pe=drawuiCore.hexToRgba(X.text,.16),ye=X.primary,S=drawuiCore.hexToRgba(X.primary,.18),ke=drawuiCore.hexToRgba(X.primary,.85),V=zr(Q),Z=_r(e),Ae=V?$r(V,Z):Z.width>0?Z:Br(),ge=Wr(Ae,b,H);E.current=ge;let Ce=W/ge.width,Le=B/ge.height,Ke=b/ge.width;f.setTransform(1,0,0,1,0,0),f.fillStyle=Or,f.fillRect(0,0,W,B),f.setTransform(Ce,0,0,Le,-Ce*ge.x,-Le*ge.y),f.fillStyle=pe;for(let z of Q){let k=pn(z);k&&f.fillRect(k.x,k.y,k.width,k.height);}f.fillStyle=ye;for(let z of Q){if(!$.has(z.id))continue;let k=pn(z);k&&f.fillRect(k.x,k.y,k.width,k.height);}f.fillStyle=S,f.fillRect(Z.x,Z.y,Z.width,Z.height);let Se=1.5/Ke;f.strokeStyle=ke,f.lineWidth=Se,f.lineJoin="round";let Re=Math.min(Z.width/6,Z.height/6,6/Ke);if(f.beginPath(),Re*Ke<1)f.rect(Z.x,Z.y,Z.width,Z.height);else {let z=Z.x,k=Z.y,ie=Z.width,se=Z.height,j=Math.min(Re,ie/2,se/2);f.moveTo(z+j,k),f.lineTo(z+ie-j,k),f.quadraticCurveTo(z+ie,k,z+ie,k+j),f.lineTo(z+ie,k+se-j),f.quadraticCurveTo(z+ie,k+se,z+ie-j,k+se),f.lineTo(z+j,k+se),f.quadraticCurveTo(z,k+se,z,k+se-j),f.lineTo(z,k+j),f.quadraticCurveTo(z,k,z+j,k),f.closePath();}f.stroke(),f.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||y)return;O();let l=e.subscribe(O),g=drawuiCore.subscribeTheme(O),f=()=>O();return window.addEventListener("resize",f),()=>{l(),g(),window.removeEventListener("resize",f);}},[e,y,O]),react.useEffect(()=>{if(!e)return;let l=()=>{let f=e.getCamera().getZoom();d(Math.round(f*100));};l();let g=e.subscribe(l);return ()=>{g();}},[e]);let N=react.useCallback((l,g)=>{if(!e)return;let f=e.getCamera(),b=f.getZoom(),H=window.innerWidth/2,W=window.innerHeight/2,B=f;B.x=H-l*b,B.y=W-g*b,e.requestRender();},[e]),p=l=>{if(!e||!i.current||l.button!==0)return;let g=i.current.getBoundingClientRect(),f=E.current;if(!f)return;let b=un(l.clientX,l.clientY,g,f);w.current={pointerId:l.pointerId,rect:{left:g.left,top:g.top,width:g.width,height:g.height},canvasBox:f},l.currentTarget.setPointerCapture(l.pointerId),h(true),N(b.x,b.y);},I=l=>{if(!s||!e||!w.current||!i.current)return;let g=w.current,f=un(l.clientX,l.clientY,g.rect,g.canvasBox);N(f.x,f.y);},M=l=>{if(s){h(false),w.current=null;try{l.currentTarget.releasePointerCapture(l.pointerId);}catch{}}},F=l=>{if(!e||!i.current)return;let g=E.current;if(!g)return;let f=i.current.getBoundingClientRect(),b=un(l.clientX,l.clientY,f,g);N(b.x,b.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${y?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(l=>!l),"data-drawui-tip":y?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":y?drawuiCore.t("minimap.expand"):drawuiCore.t("minimap.collapse"),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:y?jsxRuntime.jsx("polyline",{points:"9 6 15 12 9 18"}):jsxRuntime.jsx("polyline",{points:"15 6 9 12 15 18"})})}),!y&&jsxRuntime.jsxs("div",{className:"drawui-minimap-panel",children:[jsxRuntime.jsxs("div",{className:"drawui-minimap-header",children:[jsxRuntime.jsx("span",{className:"drawui-minimap-title",children:drawuiCore.t("minimap.title")}),jsxRuntime.jsxs("span",{className:"drawui-minimap-zoom",children:[a,"%"]})]}),jsxRuntime.jsx("div",{ref:i,className:"drawui-minimap-canvas-wrap",style:{cursor:s?"grabbing":v?"pointer":"default"},onPointerEnter:()=>C(true),onPointerLeave:()=>C(false),children:jsxRuntime.jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:p,onPointerMove:I,onPointerUp:M,onPointerCancel:M,onDoubleClick:F})})]})]})});var ve=t=>jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",className:"drawui-gen-shape-glyph",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:t}),Gr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:ve(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:ve(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:ve(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:ve(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:ve(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:ve(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:ve(jsxRuntime.jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:ve(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:ve(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:ve(jsxRuntime.jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:ve(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:ve(jsxRuntime.jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"sticky-note",labelKey:"shape.sticky-note",glyph:ve(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:ve(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M3 15 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:ve(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsxRuntime.jsx("path",{d:"M3 9 H21"}),jsxRuntime.jsx("path",{d:"M6 6.5 H10"}),jsxRuntime.jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:ve(jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("circle",{cx:"5",cy:"12",r:"2"}),jsxRuntime.jsx("path",{d:"M7 12h2.6"}),jsxRuntime.jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsxRuntime.jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsxRuntime.jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function yo({editor:t,x:e,y:o,context:i,existingArrowId:y,defaultShapeType:c,onClose:a}){let d=react.useRef(null);Y();let v=C=>{t?.createGeneratedConnection(i,{type:C,existingArrowId:y}),a();};return react.useEffect(()=>{let C=w=>{d.current&&!d.current.contains(w.target)&&a();},s=w=>{w.key==="Escape"&&(w.preventDefault(),a());},h=setTimeout(()=>{window.addEventListener("pointerdown",C,true),window.addEventListener("keydown",s,true);},0);return ()=>{clearTimeout(h),window.removeEventListener("pointerdown",C,true),window.removeEventListener("keydown",s,true);}},[a]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:d,style:{left:e,top:o},children:[jsxRuntime.jsx("div",{className:"drawui-gen-menu-label",children:drawuiCore.t("menu.title")}),jsxRuntime.jsx("div",{className:"drawui-gen-shape-grid",children:Gr.map(C=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${C.type===c?" drawui-gen-shape-active":""}`,onClick:()=>v(C.type),"data-drawui-tip":drawuiCore.t(C.labelKey),children:[C.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(C.labelKey)})]},C.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var Yr=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function Pe(t){if(Yr)switch(t){case "copy":return "\u2318C";case "copyAsImage":return "\u21E7\u2318C";case "paste":return "\u2318V";case "duplicate":return "\u2318D";case "copyStyle":return "\u2325\u2318C";case "pasteStyle":return "\u2325\u2318V";case "lock":return "\u2325\u2318L";case "delete":return "\u232B";case "group":return "\u2318G";case "ungroup":return "\u21E7\u2318G"}switch(t){case "copy":return "Ctrl + C";case "copyAsImage":return "Ctrl + Shift + C";case "paste":return "Ctrl + V";case "duplicate":return "Ctrl + D";case "copyStyle":return "Ctrl + Alt + C";case "pasteStyle":return "Ctrl + Alt + V";case "lock":return "Ctrl + Alt + L";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var fo={sep:true},jr=t=>"sep"in t&&t.sep===true;function mo({editor:t,pos:e,onClose:o}){Y();let[,i]=react.useState(0),y=react.useRef(null),[c,a]=react.useState(null),[d,v]=react.useState(null);react.useEffect(()=>{let b=t.subscribe(()=>i(H=>H+1));return ()=>{b();}},[t]),react.useLayoutEffect(()=>{let b=y.current;if(!b)return;let H=b.getBoundingClientRect(),W=Math.max(8,Math.min(e.x,window.innerWidth-H.width-8)),B=Math.max(8,Math.min(e.y,window.innerHeight-H.height-8));a({left:W,top:B});},[e.x,e.y]),react.useEffect(()=>{let b=B=>{y.current&&!y.current.contains(B.target)&&o();},H=B=>{B.key==="Escape"&&(B.preventDefault(),o());},W=setTimeout(()=>{window.addEventListener("pointerdown",b,true),window.addEventListener("keydown",H,true);},0);return ()=>{clearTimeout(W),window.removeEventListener("pointerdown",b,true),window.removeEventListener("keydown",H,true);}},[o]);let C=t.getSelectedIds(),s=C.length>0,h=e.shapeId,w=h?t.isShapeLocked(h):false,E=s&&!w&&t.hasCopiedStyle(),O=t.hasClipboard(),N=s&&!w,p=s&&!w?t.getSelectedGroupId():null,I=s&&!w&&C.length>=2&&!p,F=(h?t.getShapes().find(b=>b.id===h):void 0)?.groupId??null,l=p?true:!!F&&!w,g=b=>()=>{b(),o();},f;return w?f=F?[{key:"ctx.ungroup",shortcut:Pe("ungroup"),action:g(()=>F&&t.ungroupIds([F]))}]:[{key:"ctx.unlock",action:()=>h&&t.setShapeLocked(h,false)}]:s?f=[{key:"ctx.copy",shortcut:Pe("copy"),action:g(()=>t.copySelected())},{key:"ctx.copyAsImage",shortcut:Pe("copyAsImage"),action:g(()=>{t.copySelectedAsImage();})},{key:"ctx.paste",shortcut:Pe("paste"),disabled:!O,action:g(()=>t.paste())},{key:"ctx.duplicate",shortcut:Pe("duplicate"),action:g(()=>t.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!N,action:()=>t.bringToFront()},{key:"ctx.bringForward",disabled:!N,action:()=>t.bringForward()},{key:"ctx.sendBackward",disabled:!N,action:()=>t.sendBackward()},{key:"ctx.sendToBack",disabled:!N,action:()=>t.sendToBack()}]},{key:"ctx.copyStyle",shortcut:Pe("copyStyle"),action:g(()=>t.copyStyle())},{key:"ctx.pasteStyle",shortcut:Pe("pasteStyle"),disabled:!E,action:g(()=>t.pasteStyle())},fo,{key:"ctx.rotate",submenu:[{key:"ctx.rotate90",action:()=>t.rotateSelected(90)},{key:"ctx.rotate180",action:()=>t.rotateSelected(180)},{key:"ctx.rotate270",action:()=>t.rotateSelected(270)}]},p?{key:"ctx.ungroup",shortcut:Pe("ungroup"),disabled:!l,action:g(()=>t.ungroupSelected())}:{key:"ctx.group",shortcut:Pe("group"),disabled:!I,action:g(()=>t.groupSelected())},fo,{key:"ctx.lock",shortcut:Pe("lock"),action:g(()=>t.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:Pe("delete"),action:g(()=>t.deleteSelected())}]:f=[{key:"ctx.paste",shortcut:Pe("paste"),disabled:!O,action:g(()=>t.paste())}],jsxRuntime.jsx("div",{ref:y,className:"drawui-context-menu",style:c?{left:c.left,top:c.top}:{visibility:"hidden",left:e.x,top:e.y},onContextMenu:b=>b.preventDefault(),children:f.map((b,H)=>jr(b)?jsxRuntime.jsx("div",{className:"drawui-context-sep"},`sep-${H}`):b.submenu?jsxRuntime.jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>v(b.key),onMouseLeave:()=>v(null),children:[jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:b.disabled,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(b.key)}),jsxRuntime.jsx("svg",{className:"drawui-context-caret",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"9 18 15 12 9 6"})})]}),d===b.key&&jsxRuntime.jsx("div",{className:"drawui-context-submenu",children:b.submenu.map(W=>jsxRuntime.jsx("button",{type:"button",className:"drawui-context-item",disabled:W.disabled,onClick:()=>{W.action(),o();},children:jsxRuntime.jsx("span",{children:drawuiCore.t(W.key)})},W.key))})]},b.key):jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:b.disabled,onClick:b.action,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(b.key)}),b.shortcut&&jsxRuntime.jsx("span",{className:"drawui-context-kbd",children:b.shortcut})]},b.key))})}var Qr={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","sticky-note":"tool.sticky-note",icon:"toolbar.icon","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map",table:"tool.table",image:"tool.image"};function gn(t){let e=t instanceof Error?t.message:String(t);return e.startsWith("image.tooLarge")?drawuiCore.t("image.tooLarge"):`${drawuiCore.t("image.uploadFailed")}\uFF1A${e}`}function ea({initialTool:t="select",className:e="",themeColor:o,language:i="zh-CN",data:y,onChange:c,onReady:a,imageUpload:d}){let v=react.useRef(null),C=react.useRef(null),s=react.useRef(null),[h,w]=react.useState(null);Y();let[E,O]=react.useState(t),[N,p]=react.useState(false),[I,M]=react.useState(0),[F,l]=react.useState(false),[g,f]=react.useState("straight"),[b,H]=react.useState("end"),[W,B]=react.useState(false),[Q,$]=react.useState(void 0),[X,pe]=react.useState(100),[ye,S]=react.useState(null),[ke,V]=react.useState(null),[Z,Ae]=react.useState(false),[ge,Ce]=react.useState(false),[Le,Ke]=react.useState(null),[Se,Re]=react.useState(null),[z,k]=react.useState(false),[ie,se]=react.useState(null),[j,Ee]=react.useState(null),D=react.useRef(null),Oe=react.useRef(0),be=react.useRef(null),Xe=react.useRef(c);Xe.current=c;let qe=react.useRef(a);qe.current=a,react.useEffect(()=>{if(!v.current)return;let m=new drawuiCore.Editor(v.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}}:void 0,language:i,shapes:y,persist:!y,imageUpload:d});s.current=m,w(m),window.__drawuiEditor=m,m.setHighlighterColor(Ct()),m.setStickyNoteColor(St()),qe.current?.(m),t&&m.setActiveTool(t);let R=m.subscribe(()=>{O(m.getActiveTool());let G=m.getSelectedIds();M(G.length);let Me=m.getShapes().filter(Ue=>G.includes(Ue.id)&&(Ue.type==="line"||Ue.type==="arrow"));if(l(Me.length>0),Me.length>0&&Me[0].connectionType?f(Me[0].connectionType):Me.length>0&&f("straight"),Me.length>0){let Ue=Me.find(zt=>zt.type==="arrow");Ue&&(H(Ue.arrowHead??"end"),B(Ue.dashed??false));}pe(Math.round(m.getCamera().getZoom()*100)),$(m.getArrowStyle()),Ae(m.canUndo()),Ce(m.canRedo());let We=m.getSelectedUml();Ke(We),We||se(null);let Qe=m.getSelectedMindMap();Re(Qe),m.getMindMapEditingShapeId()||k(false),Xe.current?.(m.getData());}),le=m.subscribeNotifications(G=>{V({type:"success",text:G}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);}),Ne=m.subscribeUi(G=>{if(G.kind==="imageError"){V({type:"error",text:gn(G.message)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);return}G.kind==="shapeTypeMenu"&&Ee({x:G.screenX,y:G.screenY,context:G.context,existingArrowId:G.existingArrowId,defaultShapeType:G.defaultShapeType});});return ()=>{R(),le(),Ne(),D.current&&clearTimeout(D.current),cancelAnimationFrame(Oe.current),m.dispose();}},[t]),react.useEffect(()=>{if(!o)return;let m=C.current;m&&(m.style.setProperty("--dw-primary",o),m.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(o,-0.12)),m.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(o,.1)),m.style.setProperty("--dw-primary-contrast","#ffffff"),m.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(o,.3)}`)),s.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(o,.1),shadow:o}});},[o]),react.useEffect(()=>{drawuiCore.setLanguage(i),s.current?.setLanguage(i);},[i]);let rt=react.useCallback(m=>{s.current?.setActiveTool(m);},[]),at=react.useCallback(()=>{s.current?.zoomIn();},[]),x=react.useCallback(()=>{s.current?.zoomOut();},[]),U=react.useCallback(()=>{s.current?.resetZoom();},[]),P=react.useCallback(()=>{let m=!N;p(m),s.current?.setShowGrid(m);},[N]),T=react.useCallback(()=>{s.current?.undo();},[]),ee=react.useCallback(()=>{s.current?.redo();},[]),re=react.useCallback(m=>{s.current?.downloadImage("drawui",m,{background:"#ffffff"});},[]),He=react.useCallback(()=>{s.current?.downloadJSON("drawui-data");},[]),Je=react.useCallback(m=>{let R=new FileReader;R.onload=()=>{let le=typeof R.result=="string"?R.result:"";if(s.current?.importJSON(le)??false){let G=s.current?.getShapes().length??0;V({type:"success",text:drawuiCore.t("import.success",{n:G})});}else V({type:"error",text:drawuiCore.t("import.fail")});D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);},R.onerror=()=>{V({type:"error",text:drawuiCore.t("import.fail")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);},R.readAsText(m,"utf-8");},[]),_e=react.useCallback(m=>{let R=s.current,le=v.current;if(!R||!le)return;if(R.isPointerDown()){be.current!==null&&(be.current=null,S(null));return}let Ne=m.clientX,G=m.clientY;cancelAnimationFrame(Oe.current),Oe.current=requestAnimationFrame(()=>{let De=le.getBoundingClientRect(),Me=Ne-De.left,We=G-De.top,Qe=Me+12,Ue=We+12,zt=R.getSelectedUml()?.id,dt=R.getUmlRowAtScreenPoint({x:Me,y:We});if(dt&&dt.shape.id!==zt&&dt.text&&R.isUmlRowTextTruncated(dt)){be.current!==dt.text&&(be.current=dt.text,S({text:dt.text,x:Qe,y:Ue}));return}let ht=R.getShapeAtScreenPoint({x:Me,y:We});ht&&ht.text&&R.isShapeTextTruncated(ht.id)?be.current!==ht.text&&(be.current=ht.text,S({text:ht.text,x:Qe,y:Ue})):be.current!==null&&(be.current=null,S(null));});},[]),u=react.useCallback(()=>{S(null);},[]),r=react.useCallback(m=>{let R=s.current,le=v.current;if(!R||!le)return;let Ne=le.getBoundingClientRect(),G=m.clientX-Ne.left,De=m.clientY-Ne.top,Me=R.getUmlRowAtScreenPoint({x:G,y:De});if(Me){se(Me.shape.id);return}let We=R.getMindMapNodeAtScreenPoint({x:G,y:De});if(We){R.beginMindMapEdit(We.shapeId,We.nodeId);return}let Qe=R.getTableAtScreenPoint({x:G,y:De});Qe&&R.beginTableEdit(Qe.shapeId,Qe.row,Qe.col);},[]),_=react.useCallback(()=>{Ee(null);},[]),[A,q]=react.useState(null),$e=react.useCallback(()=>q(null),[]),ae=react.useCallback(m=>{m.preventDefault();let R=s.current,le=v.current;if(!R||!le||R.isEditing())return;let Ne=le.getBoundingClientRect(),G=R.getShapeAtScreenPoint({x:m.clientX-Ne.left,y:m.clientY-Ne.top});G?R.isShapeLocked(G.id)?R.selectShapeRaw(G.id):R.getSelectedIds().includes(G.id)||R.selectShape(G.id,m.shiftKey):R.selectShape("",false),q({x:m.clientX,y:m.clientY,shapeId:G?.id??null});},[]),go=react.useCallback(m=>{m.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:C,className:`drawui-canvas-board ${e}`,onContextMenu:go,onDragOver:m=>{m.dataTransfer?.types?.includes("Files")&&(m.preventDefault(),m.dataTransfer.dropEffect="copy");},onDrop:m=>{let R=Array.from(m.dataTransfer?.files||[]).filter(De=>(De.type||"").startsWith("image/"));if(!R.length)return;m.preventDefault();let le=s.current;if(!le)return;let Ne=m.currentTarget.getBoundingClientRect(),G=le.getCamera().screenToPage({x:m.clientX-Ne.left,y:m.clientY-Ne.top});le.insertImageFiles(R,G).then(()=>{!le.hasImageUploader()&&le.hasTemporaryImages()&&(V({type:"success",text:drawuiCore.t("image.temporaryInserted")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3));}).catch(De=>{V({type:"error",text:gn(De)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);});},children:[jsxRuntime.jsx("canvas",{ref:v,className:"drawui-canvas",onMouseMove:_e,onMouseLeave:u,onDoubleClick:r,onContextMenu:ae}),ye&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:ye.x,top:ye.y},children:ye.text}),jsxRuntime.jsx(qt,{activeTool:E,onToolChange:rt,showGrid:N,onToggleGrid:P,canUndo:Z,canRedo:ge,onUndo:T,onRedo:ee,onExport:re,onExportData:He,onImportData:Je,onHighlighterColorChange:m=>s.current?.setHighlighterColor(m),onStickyNoteColorChange:m=>s.current?.setStickyNoteColor(m),onInsertIcon:m=>s.current?.insertIcon(m),onInsertTable:(m,R)=>s.current?.insertTable(m,R),onInsertImage:m=>{let R=s.current;R&&R.insertImageFiles(m).then(()=>{!R.hasImageUploader()&&R.hasTemporaryImages()&&(V({type:"success",text:drawuiCore.t("image.temporaryInserted")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3));}).catch(le=>{V({type:"error",text:gn(le)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);});},arrowStyle:Q,onArrowStyleChange:m=>s.current?.setArrowStyle(m)}),jsxRuntime.jsx(Qt,{onZoomIn:at,onZoomOut:x,onReset:U,zoomLevel:X}),jsxRuntime.jsx(Wn,{editor:h,selectedCount:I,hasLineSelection:F,currentConnectionType:g,currentArrowHead:b,currentDashed:W}),jsxRuntime.jsx(Yn,{editor:h,umlClass:Le,editing:ie}),jsxRuntime.jsx(ro,{editor:h}),jsxRuntime.jsx(to,{editor:h,panelOpen:z}),jsxRuntime.jsx(Jn,{editor:h,panelOpen:z,onOpenPanel:()=>k(true)}),z&&jsxRuntime.jsx(lo,{editor:h,mindMap:Se}),jsxRuntime.jsx(po,{editor:h}),j&&jsxRuntime.jsx(yo,{editor:h,x:j.x,y:j.y,context:j.context,existingArrowId:j.existingArrowId,defaultShapeType:j.defaultShapeType,onClose:_}),A&&h&&jsxRuntime.jsx(mo,{editor:h,pos:A,onClose:$e}),jsxRuntime.jsxs("div",{className:"drawui-status-bar",children:[jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:drawuiCore.t(Qr[E])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:I===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:I})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[X,"%"]})})]}),ke&&jsxRuntime.jsxs("div",{className:"drawui-toast",children:[ke.type==="success"?jsxRuntime.jsx("svg",{className:"drawui-toast-icon",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("polyline",{points:"20 6 9 17 4 12"})}):jsxRuntime.jsxs("svg",{className:"drawui-toast-icon drawui-toast-icon-error",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntime.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),ke.text]})]})}exports.CanvasBoard=ea;exports.Toolbar=qt;exports.ZoomControl=Qt;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import { ToolType, Language, Shape, EditorData, Editor, ExportFormat, ArrowStyle } from 'drawui-core';
|
|
2
|
+
import { ToolType, Language, Shape, EditorData, Editor, ImageUploadOption, ExportFormat, ArrowStyle } from 'drawui-core';
|
|
3
3
|
export { ToolType } from 'drawui-core';
|
|
4
4
|
|
|
5
5
|
interface CanvasBoardProps {
|
|
@@ -15,8 +15,14 @@ interface CanvasBoardProps {
|
|
|
15
15
|
onChange?: (data: EditorData) => void;
|
|
16
16
|
/** 编辑器实例就绪回调:可拿到 Editor 做完全控制(setShapes/undo/zoom 等) */
|
|
17
17
|
onReady?: (editor: Editor) => void;
|
|
18
|
+
/**
|
|
19
|
+
* 图片上传通道(「图片」按钮 / 粘贴 / 拖入文件时用):
|
|
20
|
+
* - `{ url }` 配置或自定义上传函数 → 图片传到接入方服务器,只存返回的 URL(刷新不丢)
|
|
21
|
+
* - 不传 → 退回本地临时 blob(图形带 temporary,刷新即失效)
|
|
22
|
+
*/
|
|
23
|
+
imageUpload?: ImageUploadOption;
|
|
18
24
|
}
|
|
19
|
-
declare function CanvasBoard({ initialTool, className, themeColor, language, data, onChange, onReady, }: CanvasBoardProps): react.JSX.Element;
|
|
25
|
+
declare function CanvasBoard({ initialTool, className, themeColor, language, data, onChange, onReady, imageUpload, }: CanvasBoardProps): react.JSX.Element;
|
|
20
26
|
|
|
21
27
|
interface ToolbarProps {
|
|
22
28
|
activeTool: ToolType;
|
|
@@ -40,6 +46,8 @@ interface ToolbarProps {
|
|
|
40
46
|
onInsertIcon?: (iconId: string) => void;
|
|
41
47
|
/** 「表格」行列选择器里选了 rows×cols:宿主负责插入画布 */
|
|
42
48
|
onInsertTable?: (rows: number, cols: number) => void;
|
|
49
|
+
/** 「图片」按钮选了文件(多选):宿主负责上传并插入画布 */
|
|
50
|
+
onInsertImage?: (files: File[]) => void;
|
|
43
51
|
/** 新建箭头的默认样式(工具栏「箭头」下拉里展示/修改) */
|
|
44
52
|
arrowStyle?: ArrowStyle;
|
|
45
53
|
onArrowStyleChange?: (updates: Partial<ArrowStyle>) => void;
|