drawui-react 0.4.1 → 0.4.2
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 +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +91 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -59,6 +59,16 @@ export function App() {
|
|
|
59
59
|
|
|
60
60
|
## 更新日志
|
|
61
61
|
|
|
62
|
+
### v0.4.2
|
|
63
|
+
|
|
64
|
+
- 🖱️ **画布右键菜单(新增 `ContextMenu` 组件)**:选中图形右键弹出飞书式菜单 —— 复制 / 复制为图片 / 粘贴 / 创建副本 / **层级**(置于顶层 / 上移一层 / 下移一层 / 置于底层,悬停展开子菜单)/ 复制样式 / 粘贴样式 / 水平翻转 / 垂直翻转 / 旋转 / **成组 · 解组** / 锁定 / 删除,每项带快捷键标注,无操作能力的项自动置灰;空白处右键只显示「粘贴」,右键锁定的图形只显示「解锁 / 解组」。菜单自动贴边避让视口,点击外部或 `Esc` 关闭,文案随语言切换(7 种语言已补齐)。
|
|
65
|
+
- 🚫 **接管全部右键**:画板容器与 canvas 两层拦截 `contextmenu`,工具栏、样式面板、小地图上右键都不再弹出浏览器原生菜单(不会再出现「图片另存为」)。
|
|
66
|
+
- 🔒 **锁定**:锁定的图形由 core 在包围盒右上角画出**挂锁标记**(20×20 屏幕像素,随缩放不变),一眼可知「为什么点不动」。
|
|
67
|
+
- 👥 **分组 = 给多个图形绑一把锁**:选中多个图形右键「**成组**」`Ctrl+G` 后整组锁定,点不中拖不动;右键组内成员 → 「解锁本组 / 解组」解锁;解锁后点任一成员即选中整组,画布上有**虚线组框**。`Ctrl+Shift+G` 解组。
|
|
68
|
+
- ↔️ **水平 / 垂直翻转** `Shift+H` / `Shift+V`(菜单里也有入口),画布与导出同源呈现。
|
|
69
|
+
- 🖐️ **按住拖拽生成图形**:绘制工具按下后拖过 5px 即随手势放大缩小,圆形取拖拽长边做直径,矩形 / 圆角矩形等支持 `Shift` 锁定默认宽高比。
|
|
70
|
+
- 📦 依赖的 `drawui-core` 同步升级到 `0.4.2`。
|
|
71
|
+
|
|
62
72
|
### v0.4.1
|
|
63
73
|
|
|
64
74
|
- 📊 **新增「表格」图形与完整编辑体验**:工具栏独立「表格」按钮 + 8×6 选择器插入;选中后浮出**表格悬浮工具条**(插入 / 删除行列、合并 / 拆分单元格),双击单元格进入就地编辑。
|
|
@@ -215,6 +225,16 @@ export function App() {
|
|
|
215
225
|
|
|
216
226
|
## Changelog
|
|
217
227
|
|
|
228
|
+
### v0.4.2
|
|
229
|
+
|
|
230
|
+
- 🖱️ **Canvas context menu (new `ContextMenu` component)**: right-clicking a selected shape opens a Feishu-style menu — copy / copy as image / paste / duplicate / **layer** (hover to expand: bring to front / forward / backward / send to back) / copy style / paste style / flip horizontal / flip vertical / rotate / **group · ungroup** / lock / delete, each with its shortcut, unavailable entries greyed out. Right-clicking empty space shows only "Paste"; right-clicking a locked shape shows only "Unlock / Ungroup". The menu clamps itself into the viewport and closes on outside click or `Esc`; all copy is translated into 7 languages.
|
|
231
|
+
- 🚫 **Right-click fully taken over**: the board container and the canvas both intercept `contextmenu`, so right-clicking the toolbar, style panel or minimap no longer opens the browser's native menu (no more "Save image as").
|
|
232
|
+
- 🔒 **Locking**: locked shapes get a **padlock badge** drawn by core at the top-right of their bounds (20×20 screen pixels, zoom-independent) — you can see at a glance why a shape won't respond.
|
|
233
|
+
- 👥 **Groups = one lock shared by several shapes**: select several shapes and pick "**Group**" (`Ctrl+G`) to lock the whole group at once — it can't be picked, dragged or deleted. Right-click any member → "Unlock group / Ungroup" to release it. Once unlocked, clicking any member selects the entire group, and the canvas draws a **dashed frame** around it. `Ctrl+Shift+G` ungroups.
|
|
234
|
+
- ↔️ **Flip horizontal / vertical** with `Shift+H` / `Shift+V` (also available in the menu), rendered identically on canvas and in exports.
|
|
235
|
+
- 🖐️ **Drag to size while drawing**: press and drag past 5px on any shape tool to grow the shape live; circles take the longer drag edge as their diameter, and `Shift` locks each shape's default aspect ratio.
|
|
236
|
+
- 📦 Bundled `drawui-core` is bumped to `0.4.2`.
|
|
237
|
+
|
|
218
238
|
### v0.4.1
|
|
219
239
|
|
|
220
240
|
- 📊 **New `table` shape with a full editing experience**: a dedicated toolbar button with an 8×6 picker inserts a table; selecting it reveals a **floating table toolbar** (insert / delete rows & columns, merge / split cells), and double-clicking a cell opens the in-place editor.
|
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 Z(){let[t,e]=react.useState(drawuiCore.getLanguage());return react.useEffect(()=>drawuiCore.subscribeLanguage(()=>e(drawuiCore.getLanguage())),[]),t}var gn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],wn="drawui:highlighterColor";function Ct(){if(typeof window>"u")return drawuiCore.DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(wn);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(wn,t);}catch{}}var kn="drawui:stickyNoteColor";function St(){if(typeof window>"u")return drawuiCore.STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(kn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():drawuiCore.STICKY_NOTE_DEFAULT_COLOR}catch{return drawuiCore.STICKY_NOTE_DEFAULT_COLOR}}function Cn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(kn,t);}catch{}}function Co({icon:t,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:[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((a,y)=>{let c=a.fill??"ink",r=a.stroke??"ink";return jsxRuntime.jsx("path",{d:a.d,fill:c==="none"?"none":c==="ink"?n:c,...r==="none"?{}:{stroke:r==="ink"?n:r,strokeWidth:a.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",En=12;function Vt(t,e){let n=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;let a=parseInt(n[1],16);return `rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${e})`}function So(){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,En):[]}catch{return []}}function Mo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Nn,JSON.stringify(t));}catch{}}var Tn=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":Vt(t,.12)}),In=react.memo(function({onPick:e,onClose:n}){Z();let[a,y]=react.useState(""),[c,r]=react.useState(drawuiCore.ICON_CATEGORIES[0].id),[s,S]=react.useState(So),f=react.useRef(null),d=react.useRef(null);react.useEffect(()=>{d.current?.focus();},[]),react.useEffect(()=>{let u=C=>{let F=f.current;F&&(F.contains(C.target)||C.target?.closest?.("[data-icon-toggle]")||n());},E=C=>{C.key==="Escape"&&(C.stopPropagation(),n());};return window.addEventListener("pointerdown",u),window.addEventListener("keydown",E),()=>{window.removeEventListener("pointerdown",u),window.removeEventListener("keydown",E);}},[n]);let b=react.useMemo(()=>s.map(u=>drawuiCore.getIcon(u)).filter(u=>!!u),[s]),v=react.useMemo(()=>a.trim()?drawuiCore.searchIcons(a):c==="recent"?b:drawuiCore.iconsByCategory(c),[a,c,b]),T=c==="recent"?drawuiCore.ICON_CATEGORY_INK.status:drawuiCore.ICON_CATEGORY_INK[c]??drawuiCore.ICON_DEFAULT_INK,H=a.trim()?drawuiCore.t("icon.search"):c==="recent"?drawuiCore.t("icon.recent"):drawuiCore.t(drawuiCore.ICON_CATEGORIES.find(u=>u.id===c)?.labelKey??"icon.search"),I=u=>{e(u),S(E=>{let C=[u.id,...E.filter(F=>F!==u.id)].slice(0,En);return Mo(C),C});};return jsxRuntime.jsxs("div",{className:"drawui-icon-panel",ref:f,style:{"--dw-icon-accent":T,"--dw-icon-soft":Vt(T,.08),"--dw-icon-ring":Vt(T,.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:d,value:a,onChange:u=>y(u.target.value),onKeyDown:u=>{u.key==="Enter"&&v.length>0&&I(v[0]);},placeholder:drawuiCore.t("icon.search"),"aria-label":drawuiCore.t("icon.search")}),jsxRuntime.jsx("span",{className:"drawui-icon-count",children:v.length})]}),!a.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:Tn(drawuiCore.ICON_CATEGORY_INK.status),onClick:()=>r("recent"),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t("icon.recent")]}),drawuiCore.ICON_CATEGORIES.map(u=>jsxRuntime.jsxs("button",{type:"button",className:`drawui-icon-cat${c===u.id?" active":""}`,style:Tn(drawuiCore.ICON_CATEGORY_INK[u.id]??drawuiCore.ICON_DEFAULT_INK),onClick:()=>r(u.id),children:[jsxRuntime.jsx("i",{className:"drawui-icon-dot"}),drawuiCore.t(u.labelKey)]},u.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:H}),jsxRuntime.jsx("span",{className:"drawui-icon-card-count",children:v.length})]}),jsxRuntime.jsxs("div",{className:"drawui-icon-grid",children:[v.map(u=>jsxRuntime.jsx("button",{type:"button",className:"drawui-icon-item",title:`${u.zh} / ${u.en}`,"aria-label":`${u.zh} ${u.en}`,onClick:()=>I(u),children:jsxRuntime.jsx(Co,{icon:u,size:30,ink:drawuiCore.iconInk(u)})},u.id)),v.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)}`,Rn=(t,e)=>{let n=e*Math.PI/180;return {x:t.x*Math.cos(n)-t.y*Math.sin(n),y:t.x*Math.sin(n)+t.y*Math.cos(n)}},pt={x:Math.SQRT1_2,y:-Math.SQRT1_2},Yt={x:4.6,y:19.4},bt={x:19,y:5};function jt(t,e,n){let a={x:-n.y,y:n.x},y=r=>({x:e.x-n.x*r,y:e.y-n.y*r}),c=(r,s)=>({x:r.x+a.x*s,y:r.y+a.y*s});switch(t){case "end":{let r=y(5.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,2.7))} ${Ie(c(r,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let r=y(8.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,3.5))} ${Ie(c(r,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let r=y(4.3),s=y(8.6);return jsxRuntime.jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,2.7))} ${Ie(s)} ${Ie(c(r,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let r=Rn({x:-n.x,y:-n.y},30),s=Rn({x:-n.x,y:-n.y},-30);return jsxRuntime.jsx("path",{d:`M ${Ie({x:e.x+r.x*5.8,y:e.y+r.y*5.8})} L ${Ie(e)} L ${Ie({x:e.x+s.x*5.8,y:e.y+s.y*5.8})}`,fill:"none"})}default:return null}}function De(t,e){let n=e||t==="dependency"||t==="realization",a=n?{x:bt.x-pt.x*8.6,y:bt.y-pt.y*8.6}:bt,y={x:-pt.x,y:-pt.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:Yt.x,y1:Yt.y,x2:a.x,y2:a.y,strokeDasharray:n?"3 2.6":void 0}),(t==="end"||t==="both")&&jt("end",bt,pt),(t==="start"||t==="both")&&jt("end",Yt,y),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?jt(t,bt,pt):null]})}var Lt=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})}),To=[{type:"straight",labelKey:"style.connection.straight",icon:Lt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Lt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Lt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Lt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],Pn=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:De("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:De("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:De("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:De("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:De("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:De("both",true)}],An=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:De("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:De("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:De("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:De("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:De("realization",true)}],Hn=[...Pn,...An];function No(t,e){let n=Hn.find(a=>a.arrowHead===t&&a.dashed===e);return n?n.key:Hn.find(a=>a.arrowHead===t)?.key}var Nt=react.memo(function({connectionType:e,arrowHead:n,dashed:a,onConnectionTypeChange:y,onArrowStyleChange:c,onOptionHover:r,onOptionLeave:s}){Z();let S=No(n,a),f=d=>jsxRuntime.jsx("div",{className:"drawui-connection-row",children:d.map(b=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${S===b.key?" active":""}`,onClick:()=>c(b),"data-drawui-tip":r?void 0:drawuiCore.t(b.labelKey),onMouseEnter:r?v=>r(b.labelKey,v.currentTarget):void 0,onMouseLeave:r?s: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:To.map(d=>jsxRuntime.jsxs("button",{className:`drawui-connection-btn${e===d.type?" active":""}`,onClick:()=>y(d.type),"data-drawui-tip":r?void 0:drawuiCore.t(d.labelKey),onMouseEnter:r?b=>r(d.labelKey,b.currentTarget):void 0,onMouseLeave:r?s:void 0,"aria-label":drawuiCore.t(d.labelKey),type:"button",children:[jsxRuntime.jsx("span",{className:"drawui-connection-icon",children:d.icon}),jsxRuntime.jsx("span",{className:"drawui-connection-label",children:drawuiCore.t(d.labelKey)})]},d.type))}),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.arrow")}),f(Pn),jsxRuntime.jsx("div",{className:"drawui-style-popover-title",children:drawuiCore.t("style.uml")}),f(An)]})});var Kn=[{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"})]})}],Ro=[{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"}]}],Ho=new Map(Kn.map(t=>[t.type,t.icon])),Po=new Set(Kn.map(t=>t.type)),Ao=jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsxRuntime.jsx("path",{d:"M20 15h-5v5"})]}),Ko=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Oo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",Xt=8,$o=6,qt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Do=[{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"}],Jt=react.memo(function({activeTool:e,onToolChange:n,showGrid:a,onToggleGrid:y,canUndo:c=false,canRedo:r=false,onUndo:s,onRedo:S,onExport:f,onExportData:d,onImportData:b,onHighlighterColorChange:v,onStickyNoteColorChange:T,onInsertIcon:H,onInsertTable:I,arrowStyle:u,onArrowStyleChange:E}){let[C,F]=react.useState(false),[i,x]=react.useState(false),[p,_]=react.useState(null),[w,R]=react.useState(false),[B,O]=react.useState(false),[P,X]=react.useState(Ct),[q,te]=react.useState(false),[M,pe]=react.useState(St),[Se,U]=react.useState(false),[Ke,be]=react.useState(false),[ce,Ee]=react.useState(null),Me=react.useRef(null),Re=react.useRef(null),ge=react.useRef(null),$=react.useRef(null),k=react.useRef(null);Z();let ye=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],re=()=>{Me.current&&(clearTimeout(Me.current),Me.current=null),R(true);},de=()=>{Me.current=window.setTimeout(()=>R(false),200);},J=react.useRef(null),Oe=()=>{R(false),m(),J.current?.click();},we=h=>{let V=h.target.files?.[0];V&&b?.(V),h.target.value="";},Ye=()=>{Re.current&&(clearTimeout(Re.current),Re.current=null),F(true);},je=()=>{Re.current=window.setTimeout(()=>{F(false),m();},200);},et=()=>{ge.current&&(clearTimeout(ge.current),ge.current=null),x(true);},tt=()=>{ge.current=window.setTimeout(()=>{x(false),m();},200);},He=(h,V)=>{let l=h.closest(".drawui-toolbar");if(!l)return;let L=h.getBoundingClientRect(),ue=l.getBoundingClientRect(),G=L.bottom+46>window.innerHeight;_({label:V,x:L.left-ue.left+L.width/2,y:G?L.top-ue.top-8:L.bottom-ue.top+8,above:G});},m=()=>_(null),D=()=>{$.current&&(clearTimeout($.current),$.current=null),O(true);},z=()=>{$.current=window.setTimeout(()=>O(false),200);},W=h=>{X(h),vn(h),v?.(h),n("highlighter");},Q=()=>{k.current&&(clearTimeout(k.current),k.current=null),te(true);},ae=()=>{k.current=window.setTimeout(()=>te(false),200);},Pe=h=>{pe(h),Cn(h),T?.(h),n("sticky-note"),te(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:h=>He(h.currentTarget,"toolbar.select"),onMouseLeave:m,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:h=>He(h.currentTarget,"toolbar.hand"),onMouseLeave:m,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:Ye,onMouseLeave:je,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Po.has(e)?"active":""}`,onClick:()=>{n("rounded-rectangle"),F(false),m();},"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:Ro.map(h=>jsxRuntime.jsxs("div",{className:"drawui-shape-group",children:[jsxRuntime.jsx("div",{className:"drawui-shape-group-title",children:drawuiCore.t(h.labelKey)}),jsxRuntime.jsx("div",{className:"drawui-shape-group-grid",children:h.items.map(V=>{let l=V.labelKey??`tool.${V.type}`;return jsxRuntime.jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===V.type?"active":""}`,onClick:()=>{n(V.type),F(false),m();},onMouseEnter:L=>He(L.currentTarget,l),onMouseLeave:m,"aria-label":drawuiCore.t(l),children:jsxRuntime.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ho.get(V.type)})},`${h.key}-${V.type}`)})})]},h.key))})})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Q,onMouseLeave:ae,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{n("sticky-note"),te(false),m();},"data-drawui-tip":q?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:Ao}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:M}})]}),q&&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(h=>jsxRuntime.jsx("button",{type:"button","aria-label":h,className:`drawui-sticky-swatch${M.toLowerCase()===h.toLowerCase()?" active":""}`,style:{background:h},onClick:()=>Pe(h)},h))})]})]}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${Se?"active":""}`,"data-icon-toggle":"","data-drawui-tip":Se?void 0:drawuiCore.t("toolbar.icon"),onClick:()=>{U(h=>!h),m();},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"})]})}),Se&&jsxRuntime.jsx(In,{onPick:h=>H?.(h.id),onClose:()=>U(false)})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:et,onMouseLeave:tt,children:[jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{n("arrow"),x(false),m();},"data-drawui-tip":i?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"})})}),i&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:h=>{h.target.closest("button")||(x(false),m());},children:jsxRuntime.jsx(Nt,{connectionType:u?.connectionType??"straight",arrowHead:u?.arrowHead??"end",dashed:!!u?.dashed,onConnectionTypeChange:h=>{E?.({connectionType:h}),n("arrow"),x(false),m();},onArrowStyleChange:h=>{E?.({arrowHead:h.arrowHead,dashed:h.dashed}),n("arrow"),x(false),m();},onOptionHover:(h,V)=>He(V,h),onOptionLeave:m})})]}),Ko.filter(h=>h.type!=="arrow").map(h=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>n(h.type),"data-drawui-tip":drawuiCore.t(h.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:h.icon})})},h.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:Oo})})}),jsxRuntime.jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:D,onMouseLeave:z,children:[jsxRuntime.jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>n("highlighter"),onMouseEnter:h=>He(h.currentTarget,"toolbar.highlighter"),onMouseLeave:m,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:qt,transform:"translate(7.4 5.4) scale(2.4)"}),jsxRuntime.jsx("path",{d:qt,transform:"translate(18.4 3.4) scale(2.5)"}),jsxRuntime.jsx("path",{d:qt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsxRuntime.jsx("span",{className:"drawui-toolbar-color-chip",style:{background:P}})]}),B&&jsxRuntime.jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:gn.map(h=>jsxRuntime.jsx("button",{type:"button","aria-label":h,className:`drawui-highlighter-swatch${P.toLowerCase()===h.toLowerCase()?" active":""}`,style:{background:h},onClick:()=>W(h)},h))})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),Do.map(h=>jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>n(h.type),"data-drawui-tip":drawuiCore.t(h.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:h.icon})})},h.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 ${Ke?"active":""}`,onClick:()=>be(h=>!h),"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"})]})}),Ke&&jsxRuntime.jsxs("div",{className:"drawui-table-picker",children:[jsxRuntime.jsx("div",{className:"drawui-table-picker-hint",children:ce?`${ce.rows} \xD7 ${ce.cols}`:drawuiCore.t("table.pickHint")}),jsxRuntime.jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:$o*Xt},(h,V)=>{let l=Math.floor(V/Xt),L=V%Xt,ue=ce&&l<ce.rows&&L<ce.cols;return jsxRuntime.jsx("button",{type:"button","aria-label":`${l+1}x${L+1}`,className:"drawui-table-picker-cell",style:ue?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Ee({rows:l+1,cols:L+1}),onClick:()=>{I?.(l+1,L+1),be(false),Ee(null),m();}},V)})})]})]}),jsxRuntime.jsx("div",{className:"drawui-toolbar-divider"}),jsxRuntime.jsx("button",{className:`drawui-toolbar-button ${a?"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:s,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:!r,style:r?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:re,onMouseLeave:de,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:[ye.map(h=>jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{f?.(h.format),R(false);},"data-drawui-tip":drawuiCore.t(h.labelKey),children:drawuiCore.t(h.labelKey)},h.format)),jsxRuntime.jsx("div",{className:"drawui-toolbar-export-divider"}),jsxRuntime.jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{d?.(),R(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:Oe,"data-drawui-tip":drawuiCore.t("toolbar.import.data"),children:drawuiCore.t("toolbar.import.data")})]})]}),jsxRuntime.jsx("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:we}),p&&jsxRuntime.jsx("div",{className:`drawui-shape-tip ${p.above?"is-above":"is-below"}`,style:{left:p.x,top:p.y},children:drawuiCore.t(p.label)})]})})});var en=react.memo(function({onZoomIn:e,onZoomOut:n,onReset:a,zoomLevel:y=100}){return Z(),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: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:a,"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 $n=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Dn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Go=$n.filter(t=>t!=="#f1f5f9"),Fo=[...Go,...Dn],Vo=[...$n,...Dn],Bn=15,zn="drawui:customColors";function Yo(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(zn);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>typeof n=="string").slice(-Bn):[]}catch{return []}}function jo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(zn,JSON.stringify(t));}catch{}}var tn=[{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}],On=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),wt=10,ot=12,Qe=t=>!t||t==="transparent",_n=react.memo(function({editor:e,selectedCount:n,hasLineSelection:a,currentConnectionType:y,currentArrowHead:c,currentDashed:r}){Z();let s=!!e?.getEditingShapeId(),[S,f]=react.useState(null),[d,b]=react.useState(null),[,v]=react.useState(0),T=react.useRef(null),H=react.useRef(null),I=react.useRef(null),[u,E]=react.useState({tw:168,th:42,pw:228,ph:160}),[C,F]=react.useState(Yo),i=react.useRef(null),x=react.useCallback(l=>{let L=l.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(L)&&F(ue=>{let G=ue.filter($e=>$e!==L);for(G.push(L);G.length>Bn;)G.shift();return jo(G),G});},[]);if(react.useEffect(()=>{let l=i.current;if(!l)return;let L=()=>{l.value&&x(l.value);};return l.addEventListener("change",L),()=>l.removeEventListener("change",L)},[x,d]),react.useEffect(()=>{if(!e)return;let l=e.subscribe(()=>v(L=>(L+1)%1e6));return ()=>{l();}},[e]),react.useEffect(()=>{b(null);},[n,s]),react.useEffect(()=>{if(!d)return;let l=L=>{T.current&&!T.current.contains(L.target)&&b(null);};return document.addEventListener("pointerdown",l,true),()=>document.removeEventListener("pointerdown",l,true)},[d]),react.useLayoutEffect(()=>{let l=H.current?.offsetWidth??u.tw,L=H.current?.offsetHeight??u.th,ue=I.current?.offsetWidth??u.pw,G=I.current?.offsetHeight??u.ph;E($e=>$e.tw===l&&$e.th===L&&$e.pw===ue&&$e.ph===G?$e:{tw:l,th:L,pw:ue,ph:G});}),!e||n===0||s)return null;let p=e.getSelectedIds(),w=e.getShapes().filter(l=>p.includes(l.id)),R=w[0],B=R?.id??"",O=R?.style.fillColor,P=R?.style.strokeColor??"#1f2937",X=R?.textColor??"#1f2937",q=R?.highlightColor,te={fill:O,stroke:P,text:X,highlight:q},M=w.length>0&&w.every(l=>l.type==="sticky-note"),pe={fill:R?.style.fillOpacity??1,stroke:R?.style.strokeOpacity??1,highlight:R?.highlightOpacity??1},Se=l=>S&&S.key===`${B}:${l}`?S.value:pe[l]??1,U=(l,L)=>{switch(l){case "stroke":e.updateSelectedShapesStyle({strokeColor:L});break;case "fill":e.updateSelectedShapesStyle({fillColor:L});break;case "text":e.updateSelectedShapesText({textColor:L});break;case "highlight":e.updateSelectedShapesText({highlightColor:L});break}},Ke=(l,L)=>{f({key:`${B}:${l}`,value:L}),l==="highlight"?e.updateSelectedShapesText({highlightOpacity:L}):l==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:L}):e.updateSelectedShapesStyle({fillOpacity:L});},be=l=>e.updateConnectionType(l),ce=l=>e.updateArrowStyle({arrowHead:l.arrowHead,dashed:l.dashed}),Ee=!!a&&w.length>0&&w.every(l=>l.type==="line"||l.type==="arrow"),Me=w.length>0&&w.every(l=>l.type==="text"),Re=w.length>0&&w.every(l=>l.type==="sticky-note"||l.type==="icon"),ge=Ee?tn.filter(l=>l.key==="stroke"):Re?tn.filter(l=>l.key!=="stroke"):tn,$=l=>l.key==="stroke"&&Ee?"style.line":l.labelKey,k=d&&d!=="more"?ge.find(l=>l.key===d):void 0,ye=!!d&&(d==="more"||d==="prefix"||!!k),re=M&&k?.key==="fill",de=e.getCamera(),J=drawuiCore.getContentBounds(w,0),Oe=de.pageToScreen({x:J.x,y:J.y}),we=de.pageToScreen({x:J.x+J.width,y:J.y+J.height}),Ye=window.innerWidth,je=window.innerHeight,et=we.y+wt,tt=Oe.y-wt,He=u.th+(ye?wt+u.ph:0),m=et+He<=je-ot,D=tt-He>=ot,z=m||!D,W=(Oe.x+we.x)/2,Q=(l,L,ue)=>Math.max(L,Math.min(l,Math.max(L,ue))),ae=Q(W-u.tw/2,ot,Ye-u.tw-ot),Pe=z?et:tt-u.th,h=Q(W-u.pw/2,ot,Ye-u.pw-ot),V=ye?Q(z?Pe+u.th+wt:Pe-wt-u.ph,ot,je-u.ph-ot):0;return jsxRuntime.jsxs("div",{className:"drawui-style-floating",ref:T,children:[jsxRuntime.jsxs("div",{className:"drawui-style-toolbar",ref:H,style:{left:ae,top:Pe},children:[ge.map(l=>jsxRuntime.jsxs("button",{className:`drawui-style-tool-btn${d===l.key?" active":""}`,onClick:()=>b(d===l.key?null:l.key),"data-drawui-tip":drawuiCore.t($(l)),type:"button",children:[l.key==="fill"&&jsxRuntime.jsx("span",{className:`drawui-st-swatch${Qe(O)?" drawui-st-none":""}`,style:Qe(O)?void 0:{background:O}}),l.key==="stroke"&&(Ee?jsxRuntime.jsx("span",{className:`drawui-st-line${Qe(P)?" drawui-st-line-none":""}`,style:Qe(P)?void 0:{background:P}}):jsxRuntime.jsx("span",{className:`drawui-st-frame${Qe(P)?" drawui-st-frame-none":""}`,style:Qe(P)?void 0:{borderColor:P}})),l.key==="text"&&jsxRuntime.jsx("span",{className:"drawui-st-text",style:{color:X},children:"A"}),l.key==="highlight"&&jsxRuntime.jsx("span",{className:`drawui-st-hl${Qe(q)?" drawui-st-none":""}`,style:Qe(q)?void 0:{background:q},children:"A"})]},l.key)),a&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${d==="more"?" active":""}`,onClick:()=>b(d==="more"?null:"more"),"data-drawui-tip":drawuiCore.t("style.connection"),type:"button",children:"\u22EF"}),Me&&jsxRuntime.jsx("button",{className:`drawui-style-tool-btn${d==="prefix"?" active":""}`,onClick:()=>b(d==="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"})]})})]}),ye&&jsxRuntime.jsx("div",{className:"drawui-style-popover",ref:I,style:{left:h,top:V},children:d==="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($(k))}),jsxRuntime.jsxs("div",{className:"drawui-color-row",children:[k.hasTransparent&&!re&&jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${Qe(te[k.key])?" active":""}`,onClick:()=>U(k.key,"transparent"),"aria-label":drawuiCore.t("style.none"),type:"button"}),(re?drawuiCore.STICKY_NOTE_COLORS:k.hasTransparent?Fo:Vo).map(l=>jsxRuntime.jsx("button",{className:`drawui-color-swatch${On(l,te[k.key])?" active":""}`,style:{background:l},onClick:()=>U(k.key,l),"aria-label":l,type:"button"},l)),C.map(l=>jsxRuntime.jsx("button",{className:`drawui-color-swatch drawui-color-custom${On(l,te[k.key])?" active":""}`,style:{background:l},onClick:()=>U(k.key,l),"aria-label":l,type:"button"},`custom-${l}`)),jsxRuntime.jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":drawuiCore.t("style.addColor"),children:["+",jsxRuntime.jsx("input",{ref:i,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(Se(k.key)*100),onChange:l=>Ke(k.key,Number(l.target.value)/100),className:"drawui-opacity-slider"}),jsxRuntime.jsxs("span",{className:"drawui-opacity-value",children:[Math.round(Se(k.key)*100),"%"]})]})]}):jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx(Nt,{connectionType:y??"straight",arrowHead:c??"end",dashed:!!r,onConnectionTypeChange:be,onArrowStyleChange:ce})})})]})});var rn=14,Zn=20,nr=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],or=[12,14,16,18,20,24];function Gn(t,e){let n=t,a="",y=n.charAt(0);if(n.length>1&&(y==="+"||y==="-"||y==="#"||y==="~")&&n.charAt(1)===" "&&(a=y,n=n.slice(2)),n=n.replace(/^\s+|\s+$/g,""),e==="attribute"){let d=n.indexOf(":");return d===-1?{visibility:a,name:n,type:"",params:"",returnType:""}:{visibility:a,name:n.slice(0,d).replace(/^\s+|\s+$/g,""),type:n.slice(d+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let c=n.indexOf("(");if(c===-1){let d=n.lastIndexOf(":");return d===-1?{visibility:a,name:n,type:"",params:"",returnType:""}:{visibility:a,name:n.slice(0,d).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:n.slice(d+1).replace(/^\s+|\s+$/g,"")}}let r=n.slice(0,c).replace(/^\s+|\s+$/g,""),s=n.indexOf(")",c);if(s===-1)return {visibility:a,name:r,type:"",params:n.slice(c+1).replace(/^\s+|\s+$/g,""),returnType:""};let S=n.slice(c+1,s).replace(/^\s+|\s+$/g,""),f=n.slice(s+1).replace(/^\s+|\s+$/g,"");return f.startsWith(":")&&(f=f.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:a,name:r,type:"",params:S,returnType:f}}function rr(t,e){let n=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${n}${e.name}${e.type?`: ${e.type}`:""}`:`${n}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var Vn=react.memo(function({editor:e,umlClass:n,editing:a}){let[,y]=react.useState(0);Z(),react.useEffect(()=>{if(!e)return;let m=e.subscribe(()=>y(D=>D+1));return ()=>{m();}},[e]);let[c,r]=react.useState(null),[s,S]=react.useState(false),[f,d]=react.useState(null),b=react.useRef(null),v=react.useRef(null),T=react.useCallback((m,D)=>{b.current&&(clearTimeout(b.current),b.current=null),r({section:m,rowId:D}),S(false);},[]),H=react.useCallback(()=>{b.current&&clearTimeout(b.current),b.current=window.setTimeout(()=>{r(null),S(false);},150);},[]);if(!e||!n||a!==n.id)return null;let I=e.getCamera(),{id:u,x:E,y:C,width:F,height:i,className:x,methods:p}=n,_=n.type==="uml-interface",w=_?[]:n.attributes,R=F/2,B=i/2,O=drawuiCore.UML_HEADER_HEIGHT,P=drawuiCore.UML_LINE_HEIGHT,X=drawuiCore.UML_PADDING_X,q=drawuiCore.UML_PADDING_Y,te=_?0:w.length>0?w.length*P+q*2:q*2,M=I.zoom,pe=(F-X*2)*M,Se=4*M,U=I.pageToScreen({x:E-R+X,y:C}),Ke=I.pageToScreen({x:E,y:C-B+O/2}),be=m=>I.pageToScreen({x:E,y:m}).y,ce=P*M,Ee=m=>C+(-B+O+q+P/2+m*P),Me=m=>C+(-B+O+te+q+P/2+m*P),Re=C+(-B+O+te),ge=C+B,$={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},k=(m,D)=>{if(!w.find(Q=>Q.id===m))return;let W=Gn(D,"attribute");e.updateUmlClass(u,{attributes:w.map(Q=>Q.id===m?{...Q,...W}:Q)});},ye=(m,D)=>{if(!p.find(ae=>ae.id===m))return;let W=Gn(D,"method"),Q=p.map(ae=>ae.id===m?{...ae,...W}:ae);_?e.updateUmlInterface(u,{methods:Q}):e.updateUmlClass(u,{methods:Q});},re=(m,D,z)=>{v.current={section:m,from:D},z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",`${m}:${D}`);},de=m=>{m.preventDefault(),m.dataTransfer.dropEffect="move";},J=(m,D,z)=>{z.preventDefault();let W=v.current;!W||W.section!==m||(m==="attribute"?e.reorderUmlAttribute(u,W.from,D):e.reorderUmlMethod(u,W.from,D),v.current=null);},Oe=(m,D,z,W)=>{let Q=be(W),ae=c?.section===m&&c.rowId===z.id,Pe=(z.fontSize||drawuiCore.UML_FONT_SIZE)*M,h=z.textColor||"#1f2937",V={position:"absolute",left:U.x-rn*M-Se,top:Q-ce/2,width:rn*M+Se+pe+Zn*M,height:ce,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},l={...$,width:pe,height:ce-2,fontSize:Pe,color:h,textDecoration:z.strikethrough?"line-through":"none",pointerEvents:"auto",...ae?{borderColor:"var(--dw-primary)"}:{}},L={width:rn*M,height:ce-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*M,lineHeight:1,opacity:ae?1:.55,pointerEvents:"auto"},ue={width:Zn*M,height:ce-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*M,opacity:ae?1:.35,pointerEvents:"auto"};return jsxRuntime.jsxs("div",{style:V,onDragOver:de,onDrop:G=>J(m,D,G),children:[jsxRuntime.jsx("span",{style:L,draggable:true,onDragStart:G=>re(m,D,G),"data-drawui-tip":drawuiCore.t("uml.drag"),children:"\u22EE\u22EE"}),jsxRuntime.jsx("input",{style:l,value:f&&f.rowId===z.id?f.text:rr(m,z),onChange:G=>{d({rowId:z.id,text:G.target.value}),m==="attribute"?k(z.id,G.target.value):ye(z.id,G.target.value);},onFocus:()=>T(m,z.id),onBlur:()=>{d(null),H();},spellCheck:false}),jsxRuntime.jsx("button",{style:ue,onMouseDown:G=>G.preventDefault(),onClick:()=>{m==="attribute"?e.removeUmlAttribute(u,z.id):e.removeUmlMethod(u,z.id);},"data-drawui-tip":drawuiCore.t("uml.delete"),children:"\xD7"})]},z.id)},we=(m,D,z)=>{let W=be(D),Q=m==="attribute";return jsxRuntime.jsxs("button",{onMouseDown:ae=>ae.preventDefault(),onClick:()=>Q?e.addUmlAttribute(u):e.addUmlMethod(u),className:"drawui-uml-add-row",style:{position:"absolute",left:U.x,top:W-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":z,children:[jsxRuntime.jsx("span",{style:{fontSize:13*M,lineHeight:1},children:"+"}),jsxRuntime.jsx("span",{children:z})]},`add-${m}`)},Ye=()=>{if(!c||c.section==="className")return null;let m=c.section,D=c.rowId,W=(m==="attribute"?w:p).find(he=>he.id===D);if(!W)return null;let Q=224*M,ae=30*M,Pe=I.pageToScreen({x:E,y:C}).x,h=I.pageToScreen({x:E,y:C-B}).y,V=20*M,l=h-ae-V,L=Pe-Q/2,ue=l+ae,G=W.textColor||"#1f2937",$e=W.fontSize||drawuiCore.UML_FONT_SIZE,mt=!!W.strikethrough;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:Pe-.5,top:ue,width:1,height:V,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxRuntime.jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:L,top:l,width:Q,height:ae,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:he=>he.preventDefault(),children:[jsxRuntime.jsxs("div",{style:{position:"relative"},children:[jsxRuntime.jsxs("button",{onClick:()=>S(he=>!he),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:G,fontSize:13*M,textDecoration:mt?"line-through":"none"},children:"A"}),jsxRuntime.jsx("span",{style:{width:10*M,height:2*M,background:G,marginLeft:3,borderRadius:1}})]}),s&&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(u,m,W.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")}),nr.map(he=>jsxRuntime.jsx("button",{onClick:()=>{e.updateUmlRowStyle(u,m,W.id,{textColor:he}),S(false);},style:{width:14,height:14,border:"none",background:he,cursor:"pointer",borderRadius:2},"data-drawui-tip":he},he))]})]}),jsxRuntime.jsx("select",{value:$e,onChange:he=>e.updateUmlRowStyle(u,m,W.id,{fontSize:Number(he.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:or.map(he=>jsxRuntime.jsx("option",{value:he,children:he},he))}),jsxRuntime.jsx("button",{onClick:()=>e.updateUmlRowStyle(u,m,W.id,{strikethrough:!mt}),className:"drawui-uml-toolbar-btn","data-drawui-tip":drawuiCore.t("uml.strikethrough"),style:{border:"none",background:mt?"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:()=>{m==="attribute"?e.removeUmlAttribute(u,W.id):e.removeUmlMethod(u,W.id),r(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"})]})})]})]})},je=I.pageToScreen({x:E-R,y:C}).x,et=I.pageToScreen({x:E,y:C-B}).y,tt=F*M,He=i*M;return jsxRuntime.jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsxRuntime.jsx("div",{style:{position:"absolute",left:je+1,top:et+1,width:Math.max(0,tt-2),height:Math.max(0,He-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsxRuntime.jsx("input",{style:{...$,position:"absolute",left:Ke.x-pe/2,top:Ke.y-O*M/2+2,width:pe,height:O*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:x,onChange:m=>_?e.updateUmlInterface(u,{className:m.target.value}):e.updateUmlClass(u,{className:m.target.value}),onFocus:()=>T("className",""),onBlur:H,spellCheck:false}),!_&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[w.map((m,D)=>Oe("attribute",D,m,Ee(D))),we("attribute",Re,"\u5C5E\u6027")]}),p.map((m,D)=>Oe("method",D,m,Me(D))),we("method",ge,drawuiCore.t("uml.method")),Ye()]})});var qn=react.memo(function({editor:e,panelOpen:n,onOpenPanel:a}){let[,y]=react.useState(0);Z(),react.useEffect(()=>{if(!e)return;let i=e.subscribe(()=>y(x=>x+1));return ()=>{i();}},[e]);let c=react.useRef(false),r=react.useRef(false),s=e?.getMindMapEditingShapeId()??null,S=e?.getMindMapSelectedNode()?.nodeId??"",f=s?`${s}\0${S}`:"";if(react.useEffect(()=>{c.current=false;},[f]),!e)return null;let d=e.getMindMapEditingShapeId();if(!d||n)return null;let b=e.getMindMapSelectedNode();if(!b||b.shapeId!==d)return null;let v=e.getMindMapNode(d,b.nodeId),T=e.getMindMapNodeScreenRect(d,b.nodeId);if(!v||!T)return null;let H=e.getCamera().getZoom(),I=drawuiCore.MINDMAP_FONT_SIZE*H,u=Math.max(100,T.width+24),E=T.height+8,C={position:"absolute",left:T.x+T.width/2,top:T.y-4,transform:"translateX(-50%)",width:u,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 ${(v.icon?24:12)*H}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},F={position:"absolute",left:T.x+T.width+12,top:T.y+T.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:v.text,spellCheck:false,onChange:i=>{let x=!c.current;c.current=true,e.updateMindMapNode(d,b.nodeId,{text:i.target.value},x);},onBlur:()=>{if(r.current){r.current=false;return}e.exitMindMapEdit();},onKeyDown:i=>{i.key==="Enter"?i.target.blur():i.key==="Escape"&&e.exitMindMapEdit();}}),jsxRuntime.jsx("button",{style:F,"data-drawui-tip":drawuiCore.t("mindmap.more"),onMouseDown:i=>{i.preventDefault(),r.current=true,setTimeout(()=>{r.current=false;},300);},onClick:a,children:"\u22EF"})]})});var eo=react.memo(function({editor:e,panelOpen:n}){let[,a]=react.useState(0);Z(),react.useEffect(()=>{if(!e)return;let E=e.subscribe(()=>a(C=>C+1));return ()=>{E();}},[e]);let y=react.useRef(false),c=e?.getTableEditing()??null,r=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(react.useEffect(()=>{y.current=false;},[r]),!e||n)return null;let s=e.getTableEditing();if(!s)return null;let{shapeId:S,row:f,col:d}=s,b=e.getTableCell(S,f,d),v=e.getTableScreenRect(S,f,d);if(!b||!v)return null;let T=e.getSelectedTable(),H=b.fontSize||T?.fontSize||drawuiCore.TABLE_FONT_SIZE,I=e.getCamera().getZoom(),u={left:v.x-1,top:v.y-1,width:v.width+2,height:v.height+2,padding:`${drawuiCore.TABLE_CELL_PADDING_Y*I}px ${drawuiCore.TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:H*I,lineHeight:drawuiCore.TABLE_LINE_HEIGHT_RATIO,fontWeight:b.bold?700:400,color:b.textColor||T?.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:u,value:b.text,spellCheck:false,onChange:E=>{let C=!y.current;y.current=true,e.updateTableCell(S,f,d,{text:E.target.value},C);},onBlur:()=>{e.exitTableEdit();},onKeyDown:E=>{(E.key==="Enter"||E.key==="Escape")&&(E.preventDefault(),E.target.blur());}})})});var oo=react.memo(function({editor:e}){let[,n]=react.useState(0),[a,y]=react.useState(null),c=react.useRef(null);if(Z(),react.useEffect(()=>{if(!e)return;let P=e.subscribe(()=>n(X=>X+1));return ()=>{P();}},[e]),react.useEffect(()=>{if(!a)return;let P=q=>{let te=q.target;te&&c.current?.contains(te)||y(null);},X=q=>{q.key==="Escape"&&y(null);};return window.addEventListener("pointerdown",P,true),window.addEventListener("keydown",X),()=>{window.removeEventListener("pointerdown",P,true),window.removeEventListener("keydown",X);}},[a]),!e)return null;let r=e.getSelectedTable();if(!r)return null;let s=e.getTableSelection();if(!s||s.shapeId!==r.id)return null;let S=e.getTableScreenRect(r.id);if(!S)return null;let f=r.cells.length,d=r.cells[0]?.length??0,b=drawuiCore.tableExpandRangeToMerges(r,s.anchor.row,s.anchor.col,s.focus.row,s.focus.col),{r1:v,c1:T,r2:H,c2:I}=b,u=drawuiCore.tableCoveredMap(r.cells),E=0;for(let P=v;P<=H;P++)for(let X=T;X<=I;X++)u[P]?.[X]||E++;let C=E>1,F=drawuiCore.tableRangeHasMerge(r,v,T,H,I),i=v===H?`${v+1}`:`${v+1}\u2013${H+1}`,x=T===I?`${T+1}`:`${T+1}\u2013${I+1}`,p=f-(H-v+1)>=1,_=d-(I-T+1)>=1,R=S.y>56?S.y-40:S.y+S.height+10,B=P=>P.stopPropagation(),O=P=>()=>{P(),y(null);};return jsxRuntime.jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":r.id,style:{left:S.x+S.width/2,top:R},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(r.id,"below"),children:drawuiCore.t("table.insertRow")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${a==="row"?"active":""}`,"data-table-insert-row":true,title:`${drawuiCore.t("table.insertRowAbove")} / ${drawuiCore.t("table.insertRowBelow")}`,onClick:()=>y(a==="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"})})}),a==="row"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsxRuntime.jsx("button",{onClick:O(()=>e.insertTableRowRelative(r.id,"above")),children:drawuiCore.t("table.insertRowAbove")}),jsxRuntime.jsx("button",{onClick:O(()=>e.insertTableRowRelative(r.id,"below")),children:drawuiCore.t("table.insertRowBelow")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteRow")} \xB7 ${i}`,disabled:!p,onClick:()=>e.deleteTableRowsInSelection(r.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(r.id,"right"),children:drawuiCore.t("table.insertCol")}),jsxRuntime.jsx("button",{className:`drawui-table-btn-caret ${a==="col"?"active":""}`,"data-table-insert-col":true,title:`${drawuiCore.t("table.insertColLeft")} / ${drawuiCore.t("table.insertColRight")}`,onClick:()=>y(a==="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"})})}),a==="col"&&jsxRuntime.jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsxRuntime.jsx("button",{onClick:O(()=>e.insertTableColumnRelative(r.id,"left")),children:drawuiCore.t("table.insertColLeft")}),jsxRuntime.jsx("button",{onClick:O(()=>e.insertTableColumnRelative(r.id,"right")),children:drawuiCore.t("table.insertColRight")})]})]}),jsxRuntime.jsx("button",{title:`${drawuiCore.t("table.deleteCol")} \xB7 ${x}`,disabled:!_,onClick:()=>e.deleteTableColsInSelection(r.id),children:drawuiCore.t("table.deleteCol")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.merge"),disabled:!C,onClick:()=>e.mergeTableCells(r.id),children:drawuiCore.t("table.merge")}),jsxRuntime.jsx("button",{title:drawuiCore.t("table.split"),disabled:!F,onClick:()=>e.splitTableCells(r.id),children:drawuiCore.t("table.split")})]})});var ro=[...drawuiCore.MINDMAP_COLORS,"#1f2937","#9ca3af"],ao=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Nr={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"},an={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Pt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},At={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},sn={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},io=react.memo(function({editor:e,mindMap:n}){let[,a]=react.useState(0);Z(),react.useEffect(()=>{if(!e)return;let i=e.subscribe(()=>a(x=>x+1));return ()=>{i();}},[e]);let y=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 r=i=>{if(i.id===c.nodeId)return i;for(let x of i.children??[]){let p=r(x);if(p)return p}return null},s=r(n.root);if(!s)return null;let S=e.getCamera(),d=drawuiCore.layoutMindMap(n.root).positions.get(s.id);if(!d)return null;let b=S.zoom,v=S.pageToScreen({x:n.x+d.x,y:n.y+d.y}),T=v.x+d.width*b/2+14,H=v.y-80,u=Math.max(8,Math.min(T,(window.innerWidth||1024)-232-8)),E=Math.max(8,Math.min(H,(window.innerHeight||768)-320)),C=i=>{e.updateMindMapNode(n.id,s.id,i);},F=!!s.id&&s.id!==n.root.id;return jsxRuntime.jsxs("div",{ref:y,style:{...Nr,left:u,top:E},onMouseDown:i=>i.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:{...sn,marginBottom:8},value:s.text,onChange:i=>C({text:i.target.value}),spellCheck:false}),jsxRuntime.jsxs("div",{style:{...Pt,marginBottom:10},children:[jsxRuntime.jsxs("button",{style:At,onClick:()=>e.addMindMapChild(n.id,s.id),children:["+ ",drawuiCore.t("mindmap.addChild")]}),F&&jsxRuntime.jsxs("button",{style:At,onClick:()=>e.addMindMapSibling(n.id,s.id),children:["+ ",drawuiCore.t("mindmap.addSibling")]}),!!s.children?.length&&jsxRuntime.jsx("button",{style:At,onClick:()=>e.toggleMindMapCollapse(n.id,s.id),children:s.collapsed?drawuiCore.t("mindmap.expand"):drawuiCore.t("mindmap.collapse")}),jsxRuntime.jsx("button",{style:{...At,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(n.id,s.id),children:drawuiCore.t("mindmap.deleteNode")})]}),jsxRuntime.jsx("span",{style:an,children:drawuiCore.t("mindmap.color")}),jsxRuntime.jsxs("div",{style:{...Pt,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}}),ro.map(i=>jsxRuntime.jsx("button",{"data-drawui-tip":i,onClick:()=>C({color:i}),style:{width:18,height:18,borderRadius:4,border:s.color===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer",flexShrink:0}},i))]}),jsxRuntime.jsx("span",{style:an,children:drawuiCore.t("mindmap.icon")}),jsxRuntime.jsxs("div",{style:{...Pt,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:s.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),ao.map(i=>jsxRuntime.jsx("button",{onClick:()=>C({icon:i}),style:{width:22,height:22,borderRadius:4,border:s.icon===i?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:i},i)),jsxRuntime.jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:s.icon&&!ao.includes(s.icon)?s.icon:"",onKeyDown:i=>{if(i.key==="Enter"){let x=i.target.value.trim();C({icon:x||void 0});}},onBlur:i=>{let x=i.target.value.trim();x!==s.icon&&C({icon:x||void 0});},style:{...sn,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsxRuntime.jsx("span",{style:an,children:drawuiCore.t("mindmap.note")}),jsxRuntime.jsx("input",{style:{...sn,marginBottom:6},value:s.note??"",placeholder:drawuiCore.t("mindmap.notePlaceholder"),onChange:i=>C({note:i.target.value||void 0}),spellCheck:false}),!!s.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:()=>C({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:s.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"}}),ro.map(i=>jsxRuntime.jsx("button",{onClick:()=>C({noteColor:i}),style:{width:16,height:16,borderRadius:3,border:s.noteColor===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer"}},i))]})]})});var cn=220,dn=140,Pr="#fafafa";function Ar(t,e){let n=Math.min(t.x,e.x),a=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:n,y:a,width:y-n,height:c-a}}function Kr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Or(){return {x:0,y:0,width:0,height:0}}function $r(t){let e=1/0,n=1/0,a=-1/0,y=-1/0,c=false;for(let r of t){let s=pn(r);s&&(c=true,s.x<e&&(e=s.x),s.y<n&&(n=s.y),s.x+s.width>a&&(a=s.x+s.width),s.y+s.height>y&&(y=s.y+s.height));}return c?{x:e,y:n,width:a-e,height:y-n}:null}function pn(t){switch(t.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: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 n=1/0,a=1/0,y=-1/0,c=-1/0;for(let r of e)r.x<n&&(n=r.x),r.y<a&&(a=r.y),r.x>y&&(y=r.x),r.y>c&&(c=r.y);return {x:n,y:a,width:y-n,height:c-a}}case "draw":{let e=t,n=e.width,a=e.height;if(typeof n=="number"&&typeof a=="number")return {x:e.x-n/2,y:e.y-a/2,width:n,height:a};let y=e.points;if(!y||y.length===0)return null;let c=1/0,r=1/0,s=-1/0,S=-1/0;for(let f of y){let d=f.x+e.x,b=f.y+e.y;d<c&&(c=d),b<r&&(r=b),d>s&&(s=d),b>S&&(S=b);}return {x:c,y:r,width:s-c,height:S-r}}default:return null}}function Dr(t){let e=t.getCamera(),n=e.screenToPage({x:0,y:0}),a=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:n.x,y:n.y,width:a.x-n.x,height:a.y-n.y}}function Br(t,e,n){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-n/2,width:e,height:n};let a=e/n,y=t.width,c=y/a;c<t.height&&(c=t.height,y=c*a);let r=Kr(t);return {x:r.x-y/2,y:r.y-c/2,width:y,height:c}}function un(t,e,n,a){let y=(t-n.left)/n.width,c=(e-n.top)/n.height;return {x:a.x+y*a.width,y:a.y+c*a.height}}var co=react.memo(function({editor:e}){let n=react.useRef(null),a=react.useRef(null),[y,c]=react.useState(false),[r,s]=react.useState(100),[S,f]=react.useState(false),[d,b]=react.useState(false);Z();let v=react.useRef(null),T=react.useRef(null);react.useLayoutEffect(()=>{let i=n.current,x=a.current;if(!i||!x)return;let p=window.devicePixelRatio||1;i.width=Math.round(cn*p),i.height=Math.round(dn*p),i.style.width=`${cn}px`,i.style.height=`${dn}px`;},[y]);let H=react.useCallback(()=>{let i=n.current,x=a.current;if(!i||!x||!e)return;let p=i.getContext("2d");if(!p)return;let _=cn,w=dn,R=i.width,B=i.height,O=e.getShapes(),P=new Set(e.getSelectedIds()),X=drawuiCore.getTheme(),q=drawuiCore.hexToRgba(X.text,.16),te=X.primary,M=drawuiCore.hexToRgba(X.primary,.18),pe=drawuiCore.hexToRgba(X.primary,.85),Se=$r(O),U=Dr(e),Ke=Se?Ar(Se,U):U.width>0?U:Or(),be=Br(Ke,_,w);T.current=be;let ce=R/be.width,Ee=B/be.height,Me=_/be.width;p.setTransform(1,0,0,1,0,0),p.fillStyle=Pr,p.fillRect(0,0,R,B),p.setTransform(ce,0,0,Ee,-ce*be.x,-Ee*be.y),p.fillStyle=q;for(let $ of O){let k=pn($);k&&p.fillRect(k.x,k.y,k.width,k.height);}p.fillStyle=te;for(let $ of O){if(!P.has($.id))continue;let k=pn($);k&&p.fillRect(k.x,k.y,k.width,k.height);}p.fillStyle=M,p.fillRect(U.x,U.y,U.width,U.height);let Re=1.5/Me;p.strokeStyle=pe,p.lineWidth=Re,p.lineJoin="round";let ge=Math.min(U.width/6,U.height/6,6/Me);if(p.beginPath(),ge*Me<1)p.rect(U.x,U.y,U.width,U.height);else {let $=U.x,k=U.y,ye=U.width,re=U.height,de=Math.min(ge,ye/2,re/2);p.moveTo($+de,k),p.lineTo($+ye-de,k),p.quadraticCurveTo($+ye,k,$+ye,k+de),p.lineTo($+ye,k+re-de),p.quadraticCurveTo($+ye,k+re,$+ye-de,k+re),p.lineTo($+de,k+re),p.quadraticCurveTo($,k+re,$,k+re-de),p.lineTo($,k+de),p.quadraticCurveTo($,k,$+de,k),p.closePath();}p.stroke(),p.setTransform(1,0,0,1,0,0);},[e]);react.useEffect(()=>{if(!e||y)return;H();let i=e.subscribe(H),x=drawuiCore.subscribeTheme(H),p=()=>H();return window.addEventListener("resize",p),()=>{i(),x(),window.removeEventListener("resize",p);}},[e,y,H]),react.useEffect(()=>{if(!e)return;let i=()=>{let p=e.getCamera().getZoom();s(Math.round(p*100));};i();let x=e.subscribe(i);return ()=>{x();}},[e]);let I=react.useCallback((i,x)=>{if(!e)return;let p=e.getCamera(),_=p.getZoom(),w=window.innerWidth/2,R=window.innerHeight/2,B=p;B.x=w-i*_,B.y=R-x*_,e.requestRender();},[e]),u=i=>{if(!e||!a.current||i.button!==0)return;let x=a.current.getBoundingClientRect(),p=T.current;if(!p)return;let _=un(i.clientX,i.clientY,x,p);v.current={pointerId:i.pointerId,rect:{left:x.left,top:x.top,width:x.width,height:x.height},canvasBox:p},i.currentTarget.setPointerCapture(i.pointerId),b(true),I(_.x,_.y);},E=i=>{if(!d||!e||!v.current||!a.current)return;let x=v.current,p=un(i.clientX,i.clientY,x.rect,x.canvasBox);I(p.x,p.y);},C=i=>{if(d){b(false),v.current=null;try{i.currentTarget.releasePointerCapture(i.pointerId);}catch{}}},F=i=>{if(!e||!a.current)return;let x=T.current;if(!x)return;let p=a.current.getBoundingClientRect(),_=un(i.clientX,i.clientY,p,x);I(_.x,_.y);};return jsxRuntime.jsxs("div",{className:`drawui-minimap ${y?"collapsed":""}`,children:[jsxRuntime.jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(i=>!i),"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:[r,"%"]})]}),jsxRuntime.jsx("div",{ref:a,className:"drawui-minimap-canvas-wrap",style:{cursor:d?"grabbing":S?"pointer":"default"},onPointerEnter:()=>f(true),onPointerLeave:()=>f(false),children:jsxRuntime.jsx("canvas",{ref:n,className:"drawui-minimap-canvas",onPointerDown:u,onPointerMove:E,onPointerUp:C,onPointerCancel:C,onDoubleClick:F})})]})]})});var ke=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}),Wr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:ke(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:ke(jsxRuntime.jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:ke(jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:ke(jsxRuntime.jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:ke(jsxRuntime.jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:ke(jsxRuntime.jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:ke(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:ke(jsxRuntime.jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:ke(jsxRuntime.jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:ke(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:ke(jsxRuntime.jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:ke(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:ke(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:ke(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:ke(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:ke(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 uo({editor:t,x:e,y:n,context:a,existingArrowId:y,defaultShapeType:c,onClose:r}){let s=react.useRef(null);Z();let S=f=>{t?.createGeneratedConnection(a,{type:f,existingArrowId:y}),r();};return react.useEffect(()=>{let f=v=>{s.current&&!s.current.contains(v.target)&&r();},d=v=>{v.key==="Escape"&&(v.preventDefault(),r());},b=setTimeout(()=>{window.addEventListener("pointerdown",f,true),window.addEventListener("keydown",d,true);},0);return ()=>{clearTimeout(b),window.removeEventListener("pointerdown",f,true),window.removeEventListener("keydown",d,true);}},[r]),jsxRuntime.jsxs("div",{className:"drawui-gen-menu",ref:s,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:Wr.map(f=>jsxRuntime.jsxs("button",{className:`drawui-gen-shape-btn${f.type===c?" drawui-gen-shape-active":""}`,onClick:()=>S(f.type),"data-drawui-tip":drawuiCore.t(f.labelKey),children:[f.glyph,jsxRuntime.jsx("span",{className:"drawui-gen-shape-label",children:drawuiCore.t(f.labelKey)})]},f.type))}),jsxRuntime.jsx("div",{className:"drawui-gen-menu-hint",children:drawuiCore.t("menu.cancel")})]})}var Fr=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function Ne(t){if(Fr)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 "flipH":return "\u21E7H";case "flipV":return "\u21E7V";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 "flipH":return "Shift + H";case "flipV":return "Shift + V";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var yo={sep:true},Vr=t=>"sep"in t&&t.sep===true;function ho({editor:t,pos:e,onClose:n}){Z();let[,a]=react.useState(0),y=react.useRef(null),[c,r]=react.useState(null),[s,S]=react.useState(null);react.useEffect(()=>{let w=t.subscribe(()=>a(R=>R+1));return ()=>{w();}},[t]),react.useLayoutEffect(()=>{let w=y.current;if(!w)return;let R=w.getBoundingClientRect(),B=Math.max(8,Math.min(e.x,window.innerWidth-R.width-8)),O=Math.max(8,Math.min(e.y,window.innerHeight-R.height-8));r({left:B,top:O});},[e.x,e.y]),react.useEffect(()=>{let w=O=>{y.current&&!y.current.contains(O.target)&&n();},R=O=>{O.key==="Escape"&&(O.preventDefault(),n());},B=setTimeout(()=>{window.addEventListener("pointerdown",w,true),window.addEventListener("keydown",R,true);},0);return ()=>{clearTimeout(B),window.removeEventListener("pointerdown",w,true),window.removeEventListener("keydown",R,true);}},[n]);let f=t.getSelectedIds(),d=f.length>0,b=e.shapeId,v=b?t.isShapeLocked(b):false,T=t.getSelectedShapes().some(w=>!w.locked&&drawuiCore.isFlippableShapeType(w.type)),H=d&&!v&&t.hasCopiedStyle(),I=t.hasClipboard(),u=d&&!v,E=d&&!v?t.getSelectedGroupId():null,C=d&&!v&&f.length>=2&&!E,i=(b?t.getShapes().find(w=>w.id===b):void 0)?.groupId??null,x=E?true:!!i&&!v,p=w=>()=>{w(),n();},_;return v?_=i?[{key:"ctx.unlockGroup",action:p(()=>i&&t.setGroupLocked(i,false))},{key:"ctx.ungroup",shortcut:Ne("ungroup"),action:p(()=>i&&t.ungroupIds([i]))}]:[{key:"ctx.unlock",action:()=>b&&t.setShapeLocked(b,false)}]:d?_=[{key:"ctx.copy",shortcut:Ne("copy"),action:p(()=>t.copySelected())},{key:"ctx.copyAsImage",shortcut:Ne("copyAsImage"),action:p(()=>{t.copySelectedAsImage();})},{key:"ctx.paste",shortcut:Ne("paste"),disabled:!I,action:p(()=>t.paste())},{key:"ctx.duplicate",shortcut:Ne("duplicate"),action:p(()=>t.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!u,action:()=>t.bringToFront()},{key:"ctx.bringForward",disabled:!u,action:()=>t.bringForward()},{key:"ctx.sendBackward",disabled:!u,action:()=>t.sendBackward()},{key:"ctx.sendToBack",disabled:!u,action:()=>t.sendToBack()}]},{key:"ctx.copyStyle",shortcut:Ne("copyStyle"),action:p(()=>t.copyStyle())},{key:"ctx.pasteStyle",shortcut:Ne("pasteStyle"),disabled:!H,action:p(()=>t.pasteStyle())},yo,{key:"ctx.flipH",shortcut:Ne("flipH"),disabled:!T,action:p(()=>t.flipSelected("horizontal"))},{key:"ctx.flipV",shortcut:Ne("flipV"),disabled:!T,action:p(()=>t.flipSelected("vertical"))},{key:"ctx.rotate",action:p(()=>t.rotateSelected90(true))},E?{key:"ctx.ungroup",shortcut:Ne("ungroup"),disabled:!x,action:p(()=>t.ungroupSelected())}:{key:"ctx.group",shortcut:Ne("group"),disabled:!C,action:p(()=>t.groupSelected())},yo,{key:"ctx.lock",shortcut:Ne("lock"),action:p(()=>t.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:Ne("delete"),action:p(()=>t.deleteSelected())}]:_=[{key:"ctx.paste",shortcut:Ne("paste"),disabled:!I,action:p(()=>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:w=>w.preventDefault(),children:_.map((w,R)=>Vr(w)?jsxRuntime.jsx("div",{className:"drawui-context-sep"},`sep-${R}`):w.submenu?jsxRuntime.jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>S(w.key),onMouseLeave:()=>S(null),children:[jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:w.disabled,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(w.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"})})]}),s===w.key&&jsxRuntime.jsx("div",{className:"drawui-context-submenu",children:w.submenu.map(B=>jsxRuntime.jsx("button",{type:"button",className:"drawui-context-item",disabled:B.disabled,onClick:()=>{B.action(),n();},children:jsxRuntime.jsx("span",{children:drawuiCore.t(B.key)})},B.key))})]},w.key):jsxRuntime.jsxs("button",{type:"button",className:"drawui-context-item",disabled:w.disabled,onClick:w.action,children:[jsxRuntime.jsx("span",{children:drawuiCore.t(w.key)}),w.shortcut&&jsxRuntime.jsx("span",{className:"drawui-context-kbd",children:w.shortcut})]},w.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"};function Jr({initialTool:t="select",className:e="",themeColor:n,language:a="zh-CN",data:y,onChange:c,onReady:r}){let s=react.useRef(null),S=react.useRef(null),f=react.useRef(null),[d,b]=react.useState(null);Z();let[v,T]=react.useState(t),[H,I]=react.useState(false),[u,E]=react.useState(0),[C,F]=react.useState(false),[i,x]=react.useState("straight"),[p,_]=react.useState("end"),[w,R]=react.useState(false),[B,O]=react.useState(void 0),[P,X]=react.useState(100),[q,te]=react.useState(null),[M,pe]=react.useState(null),[Se,U]=react.useState(false),[Ke,be]=react.useState(false),[ce,Ee]=react.useState(null),[Me,Re]=react.useState(null),[ge,$]=react.useState(false),[k,ye]=react.useState(null),[re,de]=react.useState(null),J=react.useRef(null),Oe=react.useRef(0),we=react.useRef(null),Ye=react.useRef(c);Ye.current=c;let je=react.useRef(r);je.current=r,react.useEffect(()=>{if(!s.current)return;let g=new drawuiCore.Editor(s.current,{theme:n?{primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:drawuiCore.hexToRgba(n,.1),shadow:n}}:void 0,language:a,shapes:y,persist:!y});f.current=g,b(g),window.__drawuiEditor=g,g.setHighlighterColor(Ct()),g.setStickyNoteColor(St()),je.current?.(g),t&&g.setActiveTool(t);let K=g.subscribe(()=>{T(g.getActiveTool());let Y=g.getSelectedIds();E(Y.length);let Le=g.getShapes().filter(We=>Y.includes(We.id)&&(We.type==="line"||We.type==="arrow"));if(F(Le.length>0),Le.length>0&&Le[0].connectionType?x(Le[0].connectionType):Le.length>0&&x("straight"),Le.length>0){let We=Le.find(_t=>_t.type==="arrow");We&&(_(We.arrowHead??"end"),R(We.dashed??false));}X(Math.round(g.getCamera().getZoom()*100)),O(g.getArrowStyle()),U(g.canUndo()),be(g.canRedo());let _e=g.getSelectedUml();Ee(_e),_e||ye(null);let Xe=g.getSelectedMindMap();Re(Xe),g.getMindMapEditingShapeId()||$(false),Ye.current?.(g.getData());}),Ae=g.subscribeNotifications(Y=>{pe({type:"success",text:Y}),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);}),ze=g.subscribeUi(Y=>{Y.kind==="shapeTypeMenu"&&de({x:Y.screenX,y:Y.screenY,context:Y.context,existingArrowId:Y.existingArrowId,defaultShapeType:Y.defaultShapeType});});return ()=>{K(),Ae(),ze(),J.current&&clearTimeout(J.current),cancelAnimationFrame(Oe.current),g.dispose();}},[t]),react.useEffect(()=>{if(!n)return;let g=S.current;g&&(g.style.setProperty("--dw-primary",n),g.style.setProperty("--dw-primary-hover",drawuiCore.shadeColor(n,-0.12)),g.style.setProperty("--dw-primary-weak",drawuiCore.hexToRgba(n,.1)),g.style.setProperty("--dw-primary-contrast","#ffffff"),g.style.setProperty("--dw-shadow-primary",`0 2px 8px ${drawuiCore.hexToRgba(n,.3)}`)),f.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(a),f.current?.setLanguage(a);},[a]);let et=react.useCallback(g=>{f.current?.setActiveTool(g);},[]),tt=react.useCallback(()=>{f.current?.zoomIn();},[]),He=react.useCallback(()=>{f.current?.zoomOut();},[]),m=react.useCallback(()=>{f.current?.resetZoom();},[]),D=react.useCallback(()=>{let g=!H;I(g),f.current?.setShowGrid(g);},[H]),z=react.useCallback(()=>{f.current?.undo();},[]),W=react.useCallback(()=>{f.current?.redo();},[]),Q=react.useCallback(g=>{f.current?.downloadImage("drawui",g,{background:"#ffffff"});},[]),ae=react.useCallback(()=>{f.current?.downloadJSON("drawui-data");},[]),Pe=react.useCallback(g=>{let K=new FileReader;K.onload=()=>{let Ae=typeof K.result=="string"?K.result:"";if(f.current?.importJSON(Ae)??false){let Y=f.current?.getShapes().length??0;pe({type:"success",text:drawuiCore.t("import.success",{n:Y})});}else pe({type:"error",text:drawuiCore.t("import.fail")});J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);},K.onerror=()=>{pe({type:"error",text:drawuiCore.t("import.fail")}),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);},K.readAsText(g,"utf-8");},[]),h=react.useCallback(g=>{let K=f.current,Ae=s.current;if(!K||!Ae)return;if(K.isPointerDown()){we.current!==null&&(we.current=null,te(null));return}let ze=g.clientX,Y=g.clientY;cancelAnimationFrame(Oe.current),Oe.current=requestAnimationFrame(()=>{let st=Ae.getBoundingClientRect(),Le=ze-st.left,_e=Y-st.top,Xe=Le+12,We=_e+12,_t=K.getSelectedUml()?.id,lt=K.getUmlRowAtScreenPoint({x:Le,y:_e});if(lt&<.shape.id!==_t&<.text&&K.isUmlRowTextTruncated(lt)){we.current!==lt.text&&(we.current=lt.text,te({text:lt.text,x:Xe,y:We}));return}let ut=K.getShapeAtScreenPoint({x:Le,y:_e});ut&&ut.text&&K.isShapeTextTruncated(ut.id)?we.current!==ut.text&&(we.current=ut.text,te({text:ut.text,x:Xe,y:We})):we.current!==null&&(we.current=null,te(null));});},[]),V=react.useCallback(()=>{te(null);},[]),l=react.useCallback(g=>{let K=f.current,Ae=s.current;if(!K||!Ae)return;let ze=Ae.getBoundingClientRect(),Y=g.clientX-ze.left,st=g.clientY-ze.top,Le=K.getUmlRowAtScreenPoint({x:Y,y:st});if(Le){ye(Le.shape.id);return}let _e=K.getMindMapNodeAtScreenPoint({x:Y,y:st});if(_e){K.beginMindMapEdit(_e.shapeId,_e.nodeId);return}let Xe=K.getTableAtScreenPoint({x:Y,y:st});Xe&&K.beginTableEdit(Xe.shapeId,Xe.row,Xe.col);},[]),L=react.useCallback(()=>{de(null);},[]),[ue,G]=react.useState(null),$e=react.useCallback(()=>G(null),[]),mt=react.useCallback(g=>{g.preventDefault();let K=f.current,Ae=s.current;if(!K||!Ae||K.isEditing())return;let ze=Ae.getBoundingClientRect(),Y=K.getShapeAtScreenPoint({x:g.clientX-ze.left,y:g.clientY-ze.top});Y?K.isShapeLocked(Y.id)?K.selectShapeRaw(Y.id):K.getSelectedIds().includes(Y.id)||K.selectShape(Y.id,g.shiftKey):K.selectShape("",false),G({x:g.clientX,y:g.clientY,shapeId:Y?.id??null});},[]),he=react.useCallback(g=>{g.preventDefault();},[]);return jsxRuntime.jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,onContextMenu:he,children:[jsxRuntime.jsx("canvas",{ref:s,className:"drawui-canvas",onMouseMove:h,onMouseLeave:V,onDoubleClick:l,onContextMenu:mt}),q&&jsxRuntime.jsx("div",{className:"drawui-tooltip",style:{left:q.x,top:q.y},children:q.text}),jsxRuntime.jsx(Jt,{activeTool:v,onToolChange:et,showGrid:H,onToggleGrid:D,canUndo:Se,canRedo:Ke,onUndo:z,onRedo:W,onExport:Q,onExportData:ae,onImportData:Pe,onHighlighterColorChange:g=>f.current?.setHighlighterColor(g),onStickyNoteColorChange:g=>f.current?.setStickyNoteColor(g),onInsertIcon:g=>f.current?.insertIcon(g),onInsertTable:(g,K)=>f.current?.insertTable(g,K),arrowStyle:B,onArrowStyleChange:g=>f.current?.setArrowStyle(g)}),jsxRuntime.jsx(en,{onZoomIn:tt,onZoomOut:He,onReset:m,zoomLevel:P}),jsxRuntime.jsx(_n,{editor:d,selectedCount:u,hasLineSelection:C,currentConnectionType:i,currentArrowHead:p,currentDashed:w}),jsxRuntime.jsx(Vn,{editor:d,umlClass:ce,editing:k}),jsxRuntime.jsx(oo,{editor:d}),jsxRuntime.jsx(eo,{editor:d,panelOpen:ge}),jsxRuntime.jsx(qn,{editor:d,panelOpen:ge,onOpenPanel:()=>$(true)}),ge&&jsxRuntime.jsx(io,{editor:d,mindMap:Me}),jsxRuntime.jsx(co,{editor:d}),re&&jsxRuntime.jsx(uo,{editor:d,x:re.x,y:re.y,context:re.context,existingArrowId:re.existingArrowId,defaultShapeType:re.defaultShapeType,onClose:L}),ue&&d&&jsxRuntime.jsx(ho,{editor:d,pos:ue,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[v])})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsx("span",{children:u===0?drawuiCore.t("status.none"):drawuiCore.t("status.selected",{n:u})})}),jsxRuntime.jsx("div",{className:"drawui-status-item",children:jsxRuntime.jsxs("span",{children:[P,"%"]})})]}),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=Jr;exports.Toolbar=Jt;exports.ZoomControl=en;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {memo,useState,useRef,useEffect,useMemo,useCallback,useLayoutEffect}from'react';import {ICON_CATEGORIES,getIcon,searchIcons,iconsByCategory,ICON_CATEGORY_INK,ICON_DEFAULT_INK,t,iconInk,STICKY_NOTE_COLORS,getContentBounds,UML_FONT_SIZE,TABLE_FONT_SIZE,TABLE_LINE_HEIGHT_RATIO,tableExpandRangeToMerges,tableCoveredMap,tableRangeHasMerge,MINDMAP_COLORS,layoutMindMap,getTheme,hexToRgba,subscribeTheme,getLanguage,subscribeLanguage,ICON_GRID,DEFAULT_HIGHLIGHTER_COLOR,STICKY_NOTE_DEFAULT_COLOR,UML_LINE_HEIGHT,UML_PADDING_Y,UML_PADDING_X,UML_HEADER_HEIGHT,MINDMAP_FONT_SIZE,TABLE_CELL_PADDING_Y,TABLE_CELL_PADDING_X,Editor,shadeColor,setLanguage}from'drawui-core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function U(){let[o,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),o}var so=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],lo="drawui:highlighterColor";function mt(){if(typeof window>"u")return DEFAULT_HIGHLIGHTER_COLOR;try{let o=window.localStorage.getItem(lo);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():DEFAULT_HIGHLIGHTER_COLOR}catch{return 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 STICKY_NOTE_DEFAULT_COLOR;try{let o=window.localStorage.getItem(po);return o&&/^#[0-9a-fA-F]{6}$/.test(o)?o.toLowerCase():STICKY_NOTE_DEFAULT_COLOR}catch{return 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=ICON_DEFAULT_INK}){return jsxs("svg",{viewBox:`0 0 ${ICON_GRID} ${ICON_GRID}`,width:e,height:e,fill:"none","aria-hidden":"true",children:[o.disc&&jsx("circle",{cx:ICON_GRID/2,cy:ICON_GRID/2,r:ICON_GRID/2-1,fill:o.disc}),o.layers.map((r,h)=>{let c=r.fill??"ink",a=r.stroke??"ink";return 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&&jsx("text",{x:ICON_GRID/2,y: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=memo(function({onPick:e,onClose:n}){U();let[r,h]=useState(""),[c,a]=useState(ICON_CATEGORIES[0].id),[l,S]=useState(un),g=useRef(null),p=useRef(null);useEffect(()=>{p.current?.focus();},[]),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=useMemo(()=>l.map(d=>getIcon(d)).filter(d=>!!d),[l]),x=useMemo(()=>r.trim()?searchIcons(r):c==="recent"?b:iconsByCategory(c),[r,c,b]),N=c==="recent"?ICON_CATEGORY_INK.status:ICON_CATEGORY_INK[c]??ICON_DEFAULT_INK,K=r.trim()?t("icon.search"):c==="recent"?t("icon.recent"):t(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 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:[jsxs("label",{className:"drawui-icon-search",children:[jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),jsx("path",{d:"M15.4 15.4L20 20"})]}),jsx("input",{ref:p,value:r,onChange:d=>h(d.target.value),onKeyDown:d=>{d.key==="Enter"&&x.length>0&&I(x[0]);},placeholder:t("icon.search"),"aria-label":t("icon.search")}),jsx("span",{className:"drawui-icon-count",children:x.length})]}),!r.trim()&&jsxs("div",{className:"drawui-icon-cats",children:[b.length>0&&jsxs("button",{type:"button",className:`drawui-icon-cat${c==="recent"?" active":""}`,style:bo(ICON_CATEGORY_INK.status),onClick:()=>a("recent"),children:[jsx("i",{className:"drawui-icon-dot"}),t("icon.recent")]}),ICON_CATEGORIES.map(d=>jsxs("button",{type:"button",className:`drawui-icon-cat${c===d.id?" active":""}`,style:bo(ICON_CATEGORY_INK[d.id]??ICON_DEFAULT_INK),onClick:()=>a(d.id),children:[jsx("i",{className:"drawui-icon-dot"}),t(d.labelKey)]},d.id))]}),jsxs("div",{className:"drawui-icon-card",children:[jsxs("div",{className:"drawui-icon-card-head",children:[jsx("span",{className:"drawui-icon-card-title",children:K}),jsx("span",{className:"drawui-icon-card-count",children:x.length})]}),jsxs("div",{className:"drawui-icon-grid",children:[x.map(d=>jsx("button",{type:"button",className:"drawui-icon-item",title:`${d.zh} / ${d.en}`,"aria-label":`${d.zh} ${d.en}`,onClick:()=>I(d),children:jsx(dn,{icon:d,size:30,ink:iconInk(d)})},d.id)),x.length===0&&jsx("div",{className:"drawui-icon-empty",children: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 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 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 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 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 jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[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=>jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children: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=memo(function({connectionType:e,arrowHead:n,dashed:r,onConnectionTypeChange:h,onArrowStyleChange:c,onOptionHover:a,onOptionLeave:l}){U();let S=fn(n,r),g=p=>jsx("div",{className:"drawui-connection-row",children:p.map(b=>jsxs("button",{className:`drawui-connection-btn${S===b.key?" active":""}`,onClick:()=>c(b),"data-drawui-tip":a?void 0:t(b.labelKey),onMouseEnter:a?x=>a(b.labelKey,x.currentTarget):void 0,onMouseLeave:a?l:void 0,"aria-label":t(b.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:b.icon}),jsx("span",{className:"drawui-connection-label",children:t(b.labelKey)})]},b.key))});return jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:yn.map(p=>jsxs("button",{className:`drawui-connection-btn${e===p.type?" active":""}`,onClick:()=>h(p.type),"data-drawui-tip":a?void 0:t(p.labelKey),onMouseEnter:a?b=>a(p.labelKey,b.currentTarget):void 0,onMouseLeave:a?l:void 0,"aria-label":t(p.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:p.icon}),jsx("span",{className:"drawui-connection-label",children:t(p.labelKey)})]},p.type))}),jsx("div",{className:"drawui-style-popover-title",children:t("style.arrow")}),g(Co),jsx("div",{className:"drawui-style-popover-title",children:t("style.uml")}),g(So)]})});var Mo=[{type:"rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon: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:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon: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: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:jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsx(Fragment,{children:jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"9"}),jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxs(Fragment,{children:[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"}),jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxs(Fragment,{children:[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"}),jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})},{type:"uml-interface",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})},{type:"class-catalog",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),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=jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),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=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]=useState(false),[s,w]=useState(false),[m,G]=useState(null),[z,_]=useState(false),[Q,F]=useState(false),[H,Y]=useState(mt),[j,ee]=useState(false),[M,ue]=useState(bt),[xe,B]=useState(false),[Re,ye]=useState(false),[se,Te]=useState(null),ke=useRef(null),Ne=useRef(null),fe=useRef(null),O=useRef(null),v=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=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 jsx("div",{className:"drawui-toolbar-container",children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>n("select"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.select"),onMouseLeave:y,children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children: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"})})}),jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>n("hand"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.hand"),onMouseLeave:y,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),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"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:We,onMouseLeave:Ue,children:[jsx("button",{className:`drawui-toolbar-button ${vn.has(e)?"active":""}`,onClick:()=>{n("rounded-rectangle"),Z(false),y();},"data-drawui-tip":C?void 0:t("toolbar.shapes"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),C&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsx("div",{className:"drawui-shape-menu-scroll",children:gn.map(u=>jsxs("div",{className:"drawui-shape-group",children:[jsx("div",{className:"drawui-shape-group-title",children:t(u.labelKey)}),jsx("div",{className:"drawui-shape-group-grid",children:u.items.map(W=>{let i=W.labelKey??`tool.${W.type}`;return 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":t(i),children: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))})})]}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:q,onMouseLeave:ne,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{n("sticky-note"),ee(false),y();},"data-drawui-tip":j?void 0:t("tool.sticky-note"),children:[jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:xn}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:M}})]}),j&&jsxs("div",{className:"drawui-toolbar-shape-grid drawui-sticky-panel",children:[jsxs("div",{className:"drawui-sticky-panel-head",children:[jsx("span",{className:"drawui-sticky-panel-title",children:t("tool.sticky-note")}),jsx("span",{className:"drawui-sticky-panel-key",children:"N"})]}),jsx("div",{className:"drawui-sticky-panel-grid",children:STICKY_NOTE_COLORS.map(u=>jsx("button",{type:"button","aria-label":u,className:`drawui-sticky-swatch${M.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>Ie(u)},u))})]})]}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${xe?"active":""}`,"data-icon-toggle":"","data-drawui-tip":xe?void 0:t("toolbar.icon"),onClick:()=>{B(u=>!u),y();},children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"9"}),jsx("path",{d:"M8.5 10.2h0.01"}),jsx("path",{d:"M15.5 10.2h0.01"}),jsx("path",{d:"M8.8 14.2c0.9 1 2 1.5 3.2 1.5s2.3 -0.5 3.2 -1.5"})]})}),xe&&jsx(vo,{onPick:u=>K?.(u.id),onClose:()=>B(false)})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Ye,onMouseLeave:je,children:[jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{n("arrow"),w(false),y();},"data-drawui-tip":s?void 0:t("toolbar.arrow"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),s&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:u=>{u.target.closest("button")||(w(false),y());},children: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=>jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>n(u.type),"data-drawui-tip":t(u.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:u.icon})})},u.type)),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>n("pen"),"data-drawui-tip":t("toolbar.pen"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:Cn})})}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:$,onMouseLeave:P,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>n("highlighter"),onMouseEnter:u=>Ee(u.currentTarget,"toolbar.highlighter"),onMouseLeave:y,children:[jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxs("g",{fill:"currentColor",stroke:"none",children:[jsx("path",{d:Zt,transform:"translate(7.4 5.4) scale(2.4)"}),jsx("path",{d:Zt,transform:"translate(18.4 3.4) scale(2.5)"}),jsx("path",{d:Zt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:H}})]}),Q&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:so.map(u=>jsx("button",{type:"button","aria-label":u,className:`drawui-highlighter-swatch${H.toLowerCase()===u.toLowerCase()?" active":""}`,style:{background:u},onClick:()=>D(u)},u))})]}),jsx("div",{className:"drawui-toolbar-divider"}),Mn.map(u=>jsx("button",{className:`drawui-toolbar-button ${e===u.type?"active":""}`,onClick:()=>n(u.type),"data-drawui-tip":t(u.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:u.icon})})},u.type)),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>n("mind-map"),"data-drawui-tip":t("toolbar.mind-map"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsx("path",{d:"M7.4 12h3.6"}),jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${Re?"active":""}`,onClick:()=>ye(u=>!u),"data-drawui-tip":t("toolbar.table"),"data-table-toggle":true,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),Re&&jsxs("div",{className:"drawui-table-picker",children:[jsx("div",{className:"drawui-table-picker-hint",children:se?`${se.rows} \xD7 ${se.cols}`:t("table.pickHint")}),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 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)})})]})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${r?"active":""}`,onClick:h,"data-drawui-tip":t("toolbar.grid"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:"drawui-toolbar-button",onClick:l,disabled:!c,style:c?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":t("toolbar.undo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:S,disabled:!a,style:a?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":t("toolbar.redo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:oe,onMouseLeave:le,children:[jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":z?void 0:t("toolbar.export"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsx("polyline",{points:"7 10 12 15 17 10"}),jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),z&&jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:[pe.map(u=>jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{g?.(u.format),_(false);},"data-drawui-tip":t(u.labelKey),children:t(u.labelKey)},u.format)),jsx("div",{className:"drawui-toolbar-export-divider"}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{p?.(),_(false);},"data-drawui-tip":t("toolbar.export.data"),children:t("toolbar.export.data")}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:He,"data-drawui-tip":t("toolbar.import.data"),children:t("toolbar.import.data")})]})]}),jsx("input",{ref:X,type:"file",accept:".json,application/json",style:{display:"none"},onChange:me}),m&&jsx("div",{className:`drawui-shape-tip ${m.above?"is-above":"is-below"}`,style:{left:m.x,top:m.y},children:t(m.label)})]})})});var Vt=memo(function({onZoomIn:e,onZoomOut:n,onReset:r,zoomLevel:h=100}){return U(),jsxs("div",{className:"drawui-zoom-control",children:[jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":t("zoom.in"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxs("div",{className:"drawui-zoom-level",children:[h,"%"]}),jsx("button",{className:"drawui-zoom-button",onClick:n,"data-drawui-tip":t("zoom.out"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsx("button",{className:"drawui-zoom-button",onClick:r,"data-drawui-tip":t("zoom.reset"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),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=memo(function({editor:e,selectedCount:n,hasLineSelection:r,currentConnectionType:h,currentArrowHead:c,currentDashed:a}){U();let l=!!e?.getEditingShapeId(),[S,g]=useState(null),[p,b]=useState(null),[,x]=useState(0),N=useRef(null),K=useRef(null),I=useRef(null),[d,E]=useState({tw:168,th:42,pw:228,ph:160}),[C,Z]=useState(Kn),s=useRef(null),w=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(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]),useEffect(()=>{if(!e)return;let i=e.subscribe(()=>x(T=>(T+1)%1e6));return ()=>{i();}},[e]),useEffect(()=>{b(null);},[n,l]),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]),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=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 jsxs("div",{className:"drawui-style-floating",ref:N,children:[jsxs("div",{className:"drawui-style-toolbar",ref:K,style:{left:ne,top:Ie},children:[fe.map(i=>jsxs("button",{className:`drawui-style-tool-btn${p===i.key?" active":""}`,onClick:()=>b(p===i.key?null:i.key),"data-drawui-tip":t(O(i)),type:"button",children:[i.key==="fill"&&jsx("span",{className:`drawui-st-swatch${Ve(F)?" drawui-st-none":""}`,style:Ve(F)?void 0:{background:F}}),i.key==="stroke"&&(Te?jsx("span",{className:`drawui-st-line${Ve(H)?" drawui-st-line-none":""}`,style:Ve(H)?void 0:{background:H}}):jsx("span",{className:`drawui-st-frame${Ve(H)?" drawui-st-frame-none":""}`,style:Ve(H)?void 0:{borderColor:H}})),i.key==="text"&&jsx("span",{className:"drawui-st-text",style:{color:Y},children:"A"}),i.key==="highlight"&&jsx("span",{className:`drawui-st-hl${Ve(j)?" drawui-st-none":""}`,style:Ve(j)?void 0:{background:j},children:"A"})]},i.key)),r&&jsx("button",{className:`drawui-style-tool-btn${p==="more"?" active":""}`,onClick:()=>b(p==="more"?null:"more"),"data-drawui-tip":t("style.connection"),type:"button",children:"\u22EF"}),ke&&jsx("button",{className:`drawui-style-tool-btn${p==="prefix"?" active":""}`,onClick:()=>b(p==="prefix"?null:"prefix"),"data-drawui-tip":t("style.prefix"),type:"button",children:jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),pe&&jsx("div",{className:"drawui-style-popover",ref:I,style:{left:u,top:W},children:p==="prefix"?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.prefix")}),jsx("div",{className:"drawui-muted-hint",children:t("style.prefix.soon")})]}):v?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t(O(v))}),jsxs("div",{className:"drawui-color-row",children:[v.hasTransparent&&!oe&&jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${Ve(ee[v.key])?" active":""}`,onClick:()=>B(v.key,"transparent"),"aria-label":t("style.none"),type:"button"}),(oe?STICKY_NOTE_COLORS:v.hasTransparent?Pn:An).map(i=>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=>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}`)),jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":t("style.addColor"),children:["+",jsx("input",{ref:s,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":t("style.addColor")})]})]}),v.hasOpacity&&jsxs("div",{className:"drawui-opacity-row",children:[jsx("span",{className:"drawui-opacity-label",children:t("style.opacity")}),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"}),jsxs("span",{className:"drawui-opacity-value",children:[Math.round(xe(v.key)*100),"%"]})]})]}):jsx(Fragment,{children: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=memo(function({editor:e,umlClass:n,editing:r}){let[,h]=useState(0);U(),useEffect(()=>{if(!e)return;let y=e.subscribe(()=>h($=>$+1));return ()=>{y();}},[e]);let[c,a]=useState(null),[l,S]=useState(false),[g,p]=useState(null),b=useRef(null),x=useRef(null),N=useCallback((y,$)=>{b.current&&(clearTimeout(b.current),b.current=null),a({section:y,rowId:$}),S(false);},[]),K=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=UML_HEADER_HEIGHT,H=UML_LINE_HEIGHT,Y=UML_PADDING_X,j=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||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 jsxs("div",{style:W,onDragOver:le,onDrop:k=>X(y,$,k),children:[jsx("span",{style:T,draggable:true,onDragStart:k=>oe(y,$,k),"data-drawui-tip":t("uml.drag"),children:"\u22EE\u22EE"}),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}),jsx("button",{style:f,onMouseDown:k=>k.preventDefault(),onClick:()=>{y==="attribute"?e.removeUmlAttribute(d,P.id):e.removeUmlMethod(d,P.id);},"data-drawui-tip":t("uml.delete"),children:"\xD7"})]},P.id)},me=(y,$,P)=>{let D=ye($),q=y==="attribute";return 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:[jsx("span",{style:{fontSize:13*M,lineHeight:1},children:"+"}),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||UML_FONT_SIZE,Pe=!!D.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ie-.5,top:f,width:1,height:W,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),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:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>S(R=>!R),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsx("span",{style:{fontWeight:700,color:k,fontSize:13*M,textDecoration:Pe?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*M,height:2*M,background:k,marginLeft:3,borderRadius:1}})]}),l&&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:[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":t("uml.defaultColor")}),Un.map(R=>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))]})]}),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":t("uml.fontSize"),children:Zn.map(R=>jsx("option",{value:R,children:R},R))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(d,y,D.id,{strikethrough:!Pe}),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.strikethrough"),style:{border:"none",background:Pe?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*M,textDecoration:"line-through"},children:"A"})}),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":t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxs("svg",{width:14*M,height:14*M,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsx("path",{d:"M10 11v6"}),jsx("path",{d:"M14 11v6"}),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 jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[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}}),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||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&&jsxs(Fragment,{children:[z.map((y,$)=>He("attribute",$,y,Te($))),me("attribute",Ne,"\u5C5E\u6027")]}),m.map((y,$)=>He("method",$,y,ke($))),me("method",fe,t("uml.method")),We()]})});var _o=memo(function({editor:e,panelOpen:n,onOpenPanel:r}){let[,h]=useState(0);U(),useEffect(()=>{if(!e)return;let s=e.subscribe(()=>h(w=>w+1));return ()=>{s();}},[e]);let c=useRef(false),a=useRef(false),l=e?.getMindMapEditingShapeId()??null,S=e?.getMindMapSelectedNode()?.nodeId??"",g=l?`${l}\0${S}`:"";if(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=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 jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[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();}}),jsx("button",{style:Z,"data-drawui-tip":t("mindmap.more"),onMouseDown:s=>{s.preventDefault(),a.current=true,setTimeout(()=>{a.current=false;},300);},onClick:r,children:"\u22EF"})]})});var Zo=memo(function({editor:e,panelOpen:n}){let[,r]=useState(0);U(),useEffect(()=>{if(!e)return;let E=e.subscribe(()=>r(C=>C+1));return ()=>{E();}},[e]);let h=useRef(false),c=e?.getTableEditing()??null,a=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(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||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:`${TABLE_CELL_PADDING_Y*I}px ${TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:K*I,lineHeight: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 jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children: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=memo(function({editor:e}){let[,n]=useState(0),[r,h]=useState(null),c=useRef(null);if(U(),useEffect(()=>{if(!e)return;let H=e.subscribe(()=>n(Y=>Y+1));return ()=>{H();}},[e]),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=tableExpandRangeToMerges(a,l.anchor.row,l.anchor.col,l.focus.row,l.focus.col),{r1:x,c1:N,r2:K,c2:I}=b,d=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=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 jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:S.x+S.width/2,top:_},onPointerDown:Q,children:[jsxs("div",{className:"drawui-table-split",children:[jsx("button",{className:"drawui-table-btn-main",title:t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(a.id,"below"),children:t("table.insertRow")}),jsx("button",{className:`drawui-table-btn-caret ${r==="row"?"active":""}`,"data-table-insert-row":true,title:`${t("table.insertRowAbove")} / ${t("table.insertRowBelow")}`,onClick:()=>h(r==="row"?null:"row"),children:jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r==="row"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsx("button",{onClick:F(()=>e.insertTableRowRelative(a.id,"above")),children:t("table.insertRowAbove")}),jsx("button",{onClick:F(()=>e.insertTableRowRelative(a.id,"below")),children:t("table.insertRowBelow")})]})]}),jsx("button",{title:`${t("table.deleteRow")} \xB7 ${s}`,disabled:!m,onClick:()=>e.deleteTableRowsInSelection(a.id),children:t("table.deleteRow")}),jsxs("div",{className:"drawui-table-split",children:[jsx("button",{className:"drawui-table-btn-main",title:t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(a.id,"right"),children:t("table.insertCol")}),jsx("button",{className:`drawui-table-btn-caret ${r==="col"?"active":""}`,"data-table-insert-col":true,title:`${t("table.insertColLeft")} / ${t("table.insertColRight")}`,onClick:()=>h(r==="col"?null:"col"),children:jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),r==="col"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsx("button",{onClick:F(()=>e.insertTableColumnRelative(a.id,"left")),children:t("table.insertColLeft")}),jsx("button",{onClick:F(()=>e.insertTableColumnRelative(a.id,"right")),children:t("table.insertColRight")})]})]}),jsx("button",{title:`${t("table.deleteCol")} \xB7 ${w}`,disabled:!G,onClick:()=>e.deleteTableColsInSelection(a.id),children:t("table.deleteCol")}),jsx("button",{title:t("table.merge"),disabled:!C,onClick:()=>e.mergeTableCells(a.id),children:t("table.merge")}),jsx("button",{title:t("table.split"),disabled:!Z,onClick:()=>e.splitTableCells(a.id),children:t("table.split")})]})});var Yo=[...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=memo(function({editor:e,mindMap:n}){let[,r]=useState(0);U(),useEffect(()=>{if(!e)return;let s=e.subscribe(()=>r(w=>w+1));return ()=>{s();}},[e]);let h=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=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 jsxs("div",{ref:h,style:{...fr,left:d,top:E},onMouseDown:s=>s.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsx("span",{style:{fontWeight:600,fontSize:12},children:t("mindmap.nodeText")}),jsx("button",{onClick:()=>e.exitMindMapEdit(),"data-drawui-tip":t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsx("input",{style:{...Qt,marginBottom:8},value:l.text,onChange:s=>C({text:s.target.value}),spellCheck:false}),jsxs("div",{style:{...Tt,marginBottom:10},children:[jsxs("button",{style:Lt,onClick:()=>e.addMindMapChild(n.id,l.id),children:["+ ",t("mindmap.addChild")]}),Z&&jsxs("button",{style:Lt,onClick:()=>e.addMindMapSibling(n.id,l.id),children:["+ ",t("mindmap.addSibling")]}),!!l.children?.length&&jsx("button",{style:Lt,onClick:()=>e.toggleMindMapCollapse(n.id,l.id),children:l.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),jsx("button",{style:{...Lt,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(n.id,l.id),children:t("mindmap.deleteNode")})]}),jsx("span",{style:Jt,children:t("mindmap.color")}),jsxs("div",{style:{...Tt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":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=>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))]}),jsx("span",{style:Jt,children:t("mindmap.icon")}),jsxs("div",{style:{...Tt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":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=>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)),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"}})]}),jsx("span",{style:Jt,children:t("mindmap.note")}),jsx("input",{style:{...Qt,marginBottom:6},value:l.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:s=>C({note:s.target.value||void 0}),spellCheck:false}),!!l.note&&jsxs("div",{style:{...Tt,marginTop:4},children:[jsx("span",{style:{fontSize:11,color:"#6b7280"},children:t("mindmap.noteColor")}),jsx("button",{"data-drawui-tip":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=>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=memo(function({editor:e}){let n=useRef(null),r=useRef(null),[h,c]=useState(false),[a,l]=useState(100),[S,g]=useState(false),[p,b]=useState(false);U();let x=useRef(null),N=useRef(null);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=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=getTheme(),j=hexToRgba(Y.text,.16),ee=Y.primary,M=hexToRgba(Y.primary,.18),ue=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]);useEffect(()=>{if(!e||h)return;K();let s=e.subscribe(K),w=subscribeTheme(K),m=()=>K();return window.addEventListener("resize",m),()=>{s(),w(),window.removeEventListener("resize",m);}},[e,h,K]),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=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 jsxs("div",{className:`drawui-minimap ${h?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(s=>!s),"data-drawui-tip":h?t("minimap.expand"):t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":h?t("minimap.expand"):t("minimap.collapse"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:h?jsx("polyline",{points:"9 6 15 12 9 18"}):jsx("polyline",{points:"15 6 9 12 15 18"})})}),!h&&jsxs("div",{className:"drawui-minimap-panel",children:[jsxs("div",{className:"drawui-minimap-header",children:[jsx("span",{className:"drawui-minimap-title",children:t("minimap.title")}),jsxs("span",{className:"drawui-minimap-zoom",children:[a,"%"]})]}),jsx("div",{ref:r,className:"drawui-minimap-canvas-wrap",style:{cursor:p?"grabbing":S?"pointer":"default"},onPointerEnter:()=>g(true),onPointerLeave:()=>g(false),children:jsx("canvas",{ref:n,className:"drawui-minimap-canvas",onPointerDown:d,onPointerMove:E,onPointerUp:C,onPointerCancel:C,onDoubleClick:Z})})]})]})});var we=o=>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(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:we(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:we(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:we(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:we(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:we(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:we(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(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:we(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:we(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(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:we(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(jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:we(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M3 15 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:we(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:we(jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"2"}),jsx("path",{d:"M7 12h2.6"}),jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),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=useRef(null);U();let S=g=>{o?.createGeneratedConnection(r,{type:g,existingArrowId:h}),a();};return 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]),jsxs("div",{className:"drawui-gen-menu",ref:l,style:{left:e,top:n},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:Er.map(g=>jsxs("button",{className:`drawui-gen-shape-btn${g.type===c?" drawui-gen-shape-active":""}`,onClick:()=>S(g.type),"data-drawui-tip":t(g.labelKey),children:[g.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(g.labelKey)})]},g.type))}),jsx("div",{className:"drawui-gen-menu-hint",children: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=useRef(null),S=useRef(null),g=useRef(null),[p,b]=useState(null);U();let[x,N]=useState(o),[K,I]=useState(false),[d,E]=useState(0),[C,Z]=useState(false),[s,w]=useState("straight"),[m,G]=useState("end"),[z,_]=useState(false),[Q,F]=useState(void 0),[H,Y]=useState(100),[j,ee]=useState(null),[M,ue]=useState(null),[xe,B]=useState(false),[Re,ye]=useState(false),[se,Te]=useState(null),[ke,Ne]=useState(null),[fe,O]=useState(false),[v,pe]=useState(null),[oe,le]=useState(null),X=useRef(null),He=useRef(0),me=useRef(null),We=useRef(c);We.current=c;let Ue=useRef(a);Ue.current=a,useEffect(()=>{if(!l.current)return;let f=new Editor(l.current,{theme:n?{primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill: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]),useEffect(()=>{if(!n)return;let f=S.current;f&&(f.style.setProperty("--dw-primary",n),f.style.setProperty("--dw-primary-hover",shadeColor(n,-0.12)),f.style.setProperty("--dw-primary-weak",hexToRgba(n,.1)),f.style.setProperty("--dw-primary-contrast","#ffffff"),f.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(n,.3)}`)),g.current?.setTheme({primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:hexToRgba(n,.1),shadow:n}});},[n]),useEffect(()=>{setLanguage(r),g.current?.setLanguage(r);},[r]);let Ye=useCallback(f=>{g.current?.setActiveTool(f);},[]),je=useCallback(()=>{g.current?.zoomIn();},[]),Ee=useCallback(()=>{g.current?.zoomOut();},[]),y=useCallback(()=>{g.current?.resetZoom();},[]),$=useCallback(()=>{let f=!K;I(f),g.current?.setShowGrid(f);},[K]),P=useCallback(()=>{g.current?.undo();},[]),D=useCallback(()=>{g.current?.redo();},[]),q=useCallback(f=>{g.current?.downloadImage("drawui",f,{background:"#ffffff"});},[]),ne=useCallback(()=>{g.current?.downloadJSON("drawui-data");},[]),Ie=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:t("import.success",{n:R})});}else ue({type:"error",text:t("import.fail")});X.current&&clearTimeout(X.current),X.current=setTimeout(()=>ue(null),3500);},k.onerror=()=>{ue({type:"error",text:t("import.fail")}),X.current&&clearTimeout(X.current),X.current=setTimeout(()=>ue(null),3500);},k.readAsText(f,"utf-8");},[]),u=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=useCallback(()=>{ee(null);},[]),i=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=useCallback(()=>{le(null);},[]);return jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,children:[jsx("canvas",{ref:l,className:"drawui-canvas",onMouseMove:u,onMouseLeave:W,onDoubleClick:i}),j&&jsx("div",{className:"drawui-tooltip",style:{left:j.x,top:j.y},children:j.text}),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)}),jsx(Vt,{onZoomIn:je,onZoomOut:Ee,onReset:y,zoomLevel:H}),jsx(Ro,{editor:p,selectedCount:d,hasLineSelection:C,currentConnectionType:s,currentArrowHead:m,currentDashed:z}),jsx($o,{editor:p,umlClass:se,editing:v}),jsx(Vo,{editor:p}),jsx(Zo,{editor:p,panelOpen:fe}),jsx(_o,{editor:p,panelOpen:fe,onOpenPanel:()=>O(true)}),fe&&jsx(Xo,{editor:p,mindMap:ke}),jsx(Qo,{editor:p}),oe&&jsx(en,{editor:p,x:oe.x,y:oe.y,context:oe.context,existingArrowId:oe.existingArrowId,defaultShapeType:oe.defaultShapeType,onClose:T}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(Pr[x])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:d===0?t("status.none"):t("status.selected",{n:d})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[H,"%"]})})]}),M&&jsxs("div",{className:"drawui-toast",children:[M.type==="success"?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:jsx("polyline",{points:"20 6 9 17 4 12"})}):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:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M.text]})]})}export{Ar as CanvasBoard,Gt as Toolbar,Vt as ZoomControl};
|
|
1
|
+
import {memo,useState,useRef,useEffect,useMemo,useCallback,useLayoutEffect}from'react';import {ICON_CATEGORIES,getIcon,searchIcons,iconsByCategory,ICON_CATEGORY_INK,ICON_DEFAULT_INK,t,iconInk,STICKY_NOTE_COLORS,getContentBounds,UML_FONT_SIZE,TABLE_FONT_SIZE,TABLE_LINE_HEIGHT_RATIO,tableExpandRangeToMerges,tableCoveredMap,tableRangeHasMerge,MINDMAP_COLORS,layoutMindMap,getTheme,hexToRgba,subscribeTheme,getLanguage,subscribeLanguage,ICON_GRID,DEFAULT_HIGHLIGHTER_COLOR,STICKY_NOTE_DEFAULT_COLOR,UML_LINE_HEIGHT,UML_PADDING_Y,UML_PADDING_X,UML_HEADER_HEIGHT,MINDMAP_FONT_SIZE,TABLE_CELL_PADDING_Y,TABLE_CELL_PADDING_X,Editor,shadeColor,setLanguage,isFlippableShapeType}from'drawui-core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function Z(){let[t,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),t}var gn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],wn="drawui:highlighterColor";function Ct(){if(typeof window>"u")return DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(wn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():DEFAULT_HIGHLIGHTER_COLOR}catch{return DEFAULT_HIGHLIGHTER_COLOR}}function vn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(wn,t);}catch{}}var kn="drawui:stickyNoteColor";function St(){if(typeof window>"u")return STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(kn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():STICKY_NOTE_DEFAULT_COLOR}catch{return STICKY_NOTE_DEFAULT_COLOR}}function Cn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(kn,t);}catch{}}function Co({icon:t,size:e=24,ink:n=ICON_DEFAULT_INK}){return jsxs("svg",{viewBox:`0 0 ${ICON_GRID} ${ICON_GRID}`,width:e,height:e,fill:"none","aria-hidden":"true",children:[t.disc&&jsx("circle",{cx:ICON_GRID/2,cy:ICON_GRID/2,r:ICON_GRID/2-1,fill:t.disc}),t.layers.map((a,y)=>{let c=a.fill??"ink",r=a.stroke??"ink";return jsx("path",{d:a.d,fill:c==="none"?"none":c==="ink"?n:c,...r==="none"?{}:{stroke:r==="ink"?n:r,strokeWidth:a.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},y)}),t.label&&jsx("text",{x:ICON_GRID/2,y: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",En=12;function Vt(t,e){let n=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;let a=parseInt(n[1],16);return `rgba(${a>>16&255}, ${a>>8&255}, ${a&255}, ${e})`}function So(){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,En):[]}catch{return []}}function Mo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Nn,JSON.stringify(t));}catch{}}var Tn=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":Vt(t,.12)}),In=memo(function({onPick:e,onClose:n}){Z();let[a,y]=useState(""),[c,r]=useState(ICON_CATEGORIES[0].id),[s,S]=useState(So),f=useRef(null),d=useRef(null);useEffect(()=>{d.current?.focus();},[]),useEffect(()=>{let u=C=>{let F=f.current;F&&(F.contains(C.target)||C.target?.closest?.("[data-icon-toggle]")||n());},E=C=>{C.key==="Escape"&&(C.stopPropagation(),n());};return window.addEventListener("pointerdown",u),window.addEventListener("keydown",E),()=>{window.removeEventListener("pointerdown",u),window.removeEventListener("keydown",E);}},[n]);let b=useMemo(()=>s.map(u=>getIcon(u)).filter(u=>!!u),[s]),v=useMemo(()=>a.trim()?searchIcons(a):c==="recent"?b:iconsByCategory(c),[a,c,b]),T=c==="recent"?ICON_CATEGORY_INK.status:ICON_CATEGORY_INK[c]??ICON_DEFAULT_INK,H=a.trim()?t("icon.search"):c==="recent"?t("icon.recent"):t(ICON_CATEGORIES.find(u=>u.id===c)?.labelKey??"icon.search"),I=u=>{e(u),S(E=>{let C=[u.id,...E.filter(F=>F!==u.id)].slice(0,En);return Mo(C),C});};return jsxs("div",{className:"drawui-icon-panel",ref:f,style:{"--dw-icon-accent":T,"--dw-icon-soft":Vt(T,.08),"--dw-icon-ring":Vt(T,.22)},children:[jsxs("label",{className:"drawui-icon-search",children:[jsxs("svg",{viewBox:"0 0 24 24",width:"15",height:"15",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsx("circle",{cx:"10.5",cy:"10.5",r:"6.5"}),jsx("path",{d:"M15.4 15.4L20 20"})]}),jsx("input",{ref:d,value:a,onChange:u=>y(u.target.value),onKeyDown:u=>{u.key==="Enter"&&v.length>0&&I(v[0]);},placeholder:t("icon.search"),"aria-label":t("icon.search")}),jsx("span",{className:"drawui-icon-count",children:v.length})]}),!a.trim()&&jsxs("div",{className:"drawui-icon-cats",children:[b.length>0&&jsxs("button",{type:"button",className:`drawui-icon-cat${c==="recent"?" active":""}`,style:Tn(ICON_CATEGORY_INK.status),onClick:()=>r("recent"),children:[jsx("i",{className:"drawui-icon-dot"}),t("icon.recent")]}),ICON_CATEGORIES.map(u=>jsxs("button",{type:"button",className:`drawui-icon-cat${c===u.id?" active":""}`,style:Tn(ICON_CATEGORY_INK[u.id]??ICON_DEFAULT_INK),onClick:()=>r(u.id),children:[jsx("i",{className:"drawui-icon-dot"}),t(u.labelKey)]},u.id))]}),jsxs("div",{className:"drawui-icon-card",children:[jsxs("div",{className:"drawui-icon-card-head",children:[jsx("span",{className:"drawui-icon-card-title",children:H}),jsx("span",{className:"drawui-icon-card-count",children:v.length})]}),jsxs("div",{className:"drawui-icon-grid",children:[v.map(u=>jsx("button",{type:"button",className:"drawui-icon-item",title:`${u.zh} / ${u.en}`,"aria-label":`${u.zh} ${u.en}`,onClick:()=>I(u),children:jsx(Co,{icon:u,size:30,ink:iconInk(u)})},u.id)),v.length===0&&jsx("div",{className:"drawui-icon-empty",children:t("icon.empty")})]})]})]})});var Ie=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Rn=(t,e)=>{let n=e*Math.PI/180;return {x:t.x*Math.cos(n)-t.y*Math.sin(n),y:t.x*Math.sin(n)+t.y*Math.cos(n)}},pt={x:Math.SQRT1_2,y:-Math.SQRT1_2},Yt={x:4.6,y:19.4},bt={x:19,y:5};function jt(t,e,n){let a={x:-n.y,y:n.x},y=r=>({x:e.x-n.x*r,y:e.y-n.y*r}),c=(r,s)=>({x:r.x+a.x*s,y:r.y+a.y*s});switch(t){case "end":{let r=y(5.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,2.7))} ${Ie(c(r,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let r=y(8.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,3.5))} ${Ie(c(r,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let r=y(4.3),s=y(8.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(r,2.7))} ${Ie(s)} ${Ie(c(r,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let r=Rn({x:-n.x,y:-n.y},30),s=Rn({x:-n.x,y:-n.y},-30);return jsx("path",{d:`M ${Ie({x:e.x+r.x*5.8,y:e.y+r.y*5.8})} L ${Ie(e)} L ${Ie({x:e.x+s.x*5.8,y:e.y+s.y*5.8})}`,fill:"none"})}default:return null}}function De(t,e){let n=e||t==="dependency"||t==="realization",a=n?{x:bt.x-pt.x*8.6,y:bt.y-pt.y*8.6}:bt,y={x:-pt.x,y:-pt.y};return jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:Yt.x,y1:Yt.y,x2:a.x,y2:a.y,strokeDasharray:n?"3 2.6":void 0}),(t==="end"||t==="both")&&jt("end",bt,pt),(t==="start"||t==="both")&&jt("end",Yt,y),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?jt(t,bt,pt):null]})}var Lt=t=>jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:t})}),To=[{type:"straight",labelKey:"style.connection.straight",icon:Lt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Lt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Lt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Lt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],Pn=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:De("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:De("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:De("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:De("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:De("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:De("both",true)}],An=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:De("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:De("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:De("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:De("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:De("realization",true)}],Hn=[...Pn,...An];function No(t,e){let n=Hn.find(a=>a.arrowHead===t&&a.dashed===e);return n?n.key:Hn.find(a=>a.arrowHead===t)?.key}var Nt=memo(function({connectionType:e,arrowHead:n,dashed:a,onConnectionTypeChange:y,onArrowStyleChange:c,onOptionHover:r,onOptionLeave:s}){Z();let S=No(n,a),f=d=>jsx("div",{className:"drawui-connection-row",children:d.map(b=>jsxs("button",{className:`drawui-connection-btn${S===b.key?" active":""}`,onClick:()=>c(b),"data-drawui-tip":r?void 0:t(b.labelKey),onMouseEnter:r?v=>r(b.labelKey,v.currentTarget):void 0,onMouseLeave:r?s:void 0,"aria-label":t(b.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:b.icon}),jsx("span",{className:"drawui-connection-label",children:t(b.labelKey)})]},b.key))});return jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:To.map(d=>jsxs("button",{className:`drawui-connection-btn${e===d.type?" active":""}`,onClick:()=>y(d.type),"data-drawui-tip":r?void 0:t(d.labelKey),onMouseEnter:r?b=>r(d.labelKey,b.currentTarget):void 0,onMouseLeave:r?s:void 0,"aria-label":t(d.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:d.icon}),jsx("span",{className:"drawui-connection-label",children:t(d.labelKey)})]},d.type))}),jsx("div",{className:"drawui-style-popover-title",children:t("style.arrow")}),f(Pn),jsx("div",{className:"drawui-style-popover-title",children:t("style.uml")}),f(An)]})});var Kn=[{type:"rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"0"})},{type:"rounded-rectangle",icon:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4"})},{type:"circle",icon:jsx("circle",{cx:"12",cy:"12",r:"8"})},{type:"ellipse",icon:jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"6"})},{type:"diamond",icon:jsx("path",{d:"M12 3L21 12L12 21L3 12Z"})},{type:"triangle",icon:jsx("path",{d:"M12 4L20 19L4 19Z"})},{type:"hexagon",icon:jsx("path",{d:"M12 3L20 7.5V16.5L12 21L4 16.5V7.5Z"})},{type:"parallelogram",icon:jsx("path",{d:"M7 5L20 5L17 19L4 19Z"})},{type:"trapezoid",icon:jsx("path",{d:"M6 5L18 5L21 19L3 19Z"})},{type:"pentagon",icon:jsx("path",{d:"M12 3L21 10L17.5 21L6.5 21L3 10Z"})},{type:"octagon",icon:jsx("path",{d:"M8 3L16 3L21 8L21 16L16 21L8 21L3 16L3 8Z"})},{type:"star",icon: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:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"6.5",rx:"6",ry:"2.8"}),jsx("path",{d:"M6 6.5v11c0 1.5 2.7 2.8 6 2.8s6-1.3 6-2.8v-11"})]})},{type:"cloud",icon: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: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:jsx("path",{d:"M3 9h9V5l9 7-9 7v-4H3Z"})},{type:"block-arrow-left",icon:jsx("path",{d:"M21 9h-9V5L3 12l9 7v-4h9Z"})},{type:"block-arrow-up",icon:jsx("path",{d:"M9 21v-9H5l7-9 7 9h-4v9Z"})},{type:"block-arrow-down",icon:jsx("path",{d:"M9 3v9H5l7 9 7-9h-4V3Z"})},{type:"block-arrow-double",icon:jsx("path",{d:"M2 12l4.5-6v3.5h11V6L22 12l-4.5 6v-3.5h-11V18Z"})},{type:"right-triangle",icon:jsx("path",{d:"M4 4v16h16Z"})},{type:"cross",icon:jsx("path",{d:"M9.5 3h5v6.5H21v5h-6.5V21h-5v-6.5H3v-5h6.5Z"})},{type:"envelope",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsx("path",{d:"M3 5l18 14M21 5L3 19"})]})},{type:"checkbox",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),jsx("path",{d:"M7.8 12.3l2.7 2.7 5.7-6.2"})]})},{type:"speech-rect",icon:jsx(Fragment,{children:jsx("path",{d:"M3 5h18v11H8l-3.2 3.2V16H3Z"})})},{type:"speech-round",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"10.5",rx:"9",ry:"6.5"}),jsx("path",{d:"M8 16.2 6 21l5-3.4"})]})},{type:"cube",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 20 7.5v9L12 21 4 16.5v-9Z"}),jsx("path",{d:"M4 7.5 12 12l8-4.5M12 12v9"})]})},{type:"cuboid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 4 21 8.5v7L12 20 3 15.5v-7Z"}),jsx("path",{d:"M3 8.5 12 13l9-4.5M12 13v7"})]})},{type:"triangular-pyramid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 21.5 16.5 12 21 2.5 16.5Z"}),jsx("path",{d:"M12 3v18M2.5 16.5h19"})]})},{type:"quadrangular-pyramid",icon:jsxs(Fragment,{children:[jsx("path",{d:"M12 3 22.5 17 12 21 1.5 17Z"}),jsx("path",{d:"M12 3v18M12 12 1.5 17M12 12l10.5 5"})]})},{type:"sphere",icon:jsxs(Fragment,{children:[jsx("circle",{cx:"12",cy:"12",r:"9"}),jsx("ellipse",{cx:"12",cy:"12",rx:"9",ry:"2.5"})]})},{type:"ellipsoid",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"6.5"}),jsx("ellipse",{cx:"12",cy:"12",rx:"10",ry:"1.9"})]})},{type:"pie",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsx("path",{d:"M12 9 5.6 12M12 9l6.4 3"})]})},{type:"hollow-pie",icon:jsxs(Fragment,{children:[jsx("ellipse",{cx:"12",cy:"9",rx:"9",ry:"3.5"}),jsx("path",{d:"M3 9v5c0 1.9 4 3.5 9 3.5s9-1.6 9-3.5V9"}),jsx("ellipse",{cx:"12",cy:"9",rx:"3.6",ry:"1.5"})]})},{type:"sector",icon:jsx("path",{d:"M12 3a9 9 0 1 0 9 9h-9Z"})},{type:"delay",icon:jsx("path",{d:"M3 5h12a7 7 0 0 1 0 14H3Z"})},{type:"predefined-process",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14"}),jsx("path",{d:"M6.5 5v14M17.5 5v14"})]})},{type:"document",icon:jsx("path",{d:"M3 5h18v10.5c-5 3.5-13-3.5-18 0Z"})},{type:"stadium",icon:jsx("rect",{x:"3",y:"6.5",width:"18",height:"11",rx:"5.5"})},{type:"chevron",icon:jsx("path",{d:"M2 4h9l9 8-9 8H2l8-8Z"})},{type:"brace-left",icon:jsxs(Fragment,{children:[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"}),jsx("path",{d:"M12 9.6h10M12 14.4h10"})]})},{type:"brace-right",icon:jsxs(Fragment,{children:[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"}),jsx("path",{d:"M2 9.6h10M2 14.4h10"})]})},{type:"uml-class",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"3",y1:"15",x2:"21",y2:"15"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"}),jsx("line",{x1:"7",y1:"18",x2:"11",y2:"18"})]})},{type:"uml-interface",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),jsx("line",{x1:"7",y1:"6",x2:"17",y2:"6"}),jsx("line",{x1:"7",y1:"12",x2:"13",y2:"12"})]})},{type:"class-catalog",icon:jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"1.5"}),jsx("line",{x1:"6.6",y1:"5",x2:"6.6",y2:"19"}),jsx("line",{x1:"17.4",y1:"5",x2:"17.4",y2:"19"})]})}],Ro=[{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"}]}],Ho=new Map(Kn.map(t=>[t.type,t.icon])),Po=new Set(Kn.map(t=>t.type)),Ao=jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}),Ko=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Oo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",Xt=8,$o=6,qt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Do=[{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"}],Jt=memo(function({activeTool:e,onToolChange:n,showGrid:a,onToggleGrid:y,canUndo:c=false,canRedo:r=false,onUndo:s,onRedo:S,onExport:f,onExportData:d,onImportData:b,onHighlighterColorChange:v,onStickyNoteColorChange:T,onInsertIcon:H,onInsertTable:I,arrowStyle:u,onArrowStyleChange:E}){let[C,F]=useState(false),[i,x]=useState(false),[p,_]=useState(null),[w,R]=useState(false),[B,O]=useState(false),[P,X]=useState(Ct),[q,te]=useState(false),[M,pe]=useState(St),[Se,U]=useState(false),[Ke,be]=useState(false),[ce,Ee]=useState(null),Me=useRef(null),Re=useRef(null),ge=useRef(null),$=useRef(null),k=useRef(null);Z();let ye=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],re=()=>{Me.current&&(clearTimeout(Me.current),Me.current=null),R(true);},de=()=>{Me.current=window.setTimeout(()=>R(false),200);},J=useRef(null),Oe=()=>{R(false),m(),J.current?.click();},we=h=>{let V=h.target.files?.[0];V&&b?.(V),h.target.value="";},Ye=()=>{Re.current&&(clearTimeout(Re.current),Re.current=null),F(true);},je=()=>{Re.current=window.setTimeout(()=>{F(false),m();},200);},et=()=>{ge.current&&(clearTimeout(ge.current),ge.current=null),x(true);},tt=()=>{ge.current=window.setTimeout(()=>{x(false),m();},200);},He=(h,V)=>{let l=h.closest(".drawui-toolbar");if(!l)return;let L=h.getBoundingClientRect(),ue=l.getBoundingClientRect(),G=L.bottom+46>window.innerHeight;_({label:V,x:L.left-ue.left+L.width/2,y:G?L.top-ue.top-8:L.bottom-ue.top+8,above:G});},m=()=>_(null),D=()=>{$.current&&(clearTimeout($.current),$.current=null),O(true);},z=()=>{$.current=window.setTimeout(()=>O(false),200);},W=h=>{X(h),vn(h),v?.(h),n("highlighter");},Q=()=>{k.current&&(clearTimeout(k.current),k.current=null),te(true);},ae=()=>{k.current=window.setTimeout(()=>te(false),200);},Pe=h=>{pe(h),Cn(h),T?.(h),n("sticky-note"),te(false);};return jsx("div",{className:"drawui-toolbar-container",children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>n("select"),onMouseEnter:h=>He(h.currentTarget,"toolbar.select"),onMouseLeave:m,children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children: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"})})}),jsx("button",{className:`drawui-toolbar-button ${e==="hand"?"active":""}`,onClick:()=>n("hand"),onMouseEnter:h=>He(h.currentTarget,"toolbar.hand"),onMouseLeave:m,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M7.6 12.6V5.6a1.5 1.5 0 0 1 3 0v4.6"}),jsx("path",{d:"M10.6 10.2V4.1a1.5 1.5 0 0 1 3 0v6.1"}),jsx("path",{d:"M13.6 10.4V5.2a1.5 1.5 0 0 1 3 0v6.6"}),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"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Ye,onMouseLeave:je,children:[jsx("button",{className:`drawui-toolbar-button ${Po.has(e)?"active":""}`,onClick:()=>{n("rounded-rectangle"),F(false),m();},"data-drawui-tip":C?void 0:t("toolbar.shapes"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"4",ry:"4"})})}),C&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsx("div",{className:"drawui-shape-menu-scroll",children:Ro.map(h=>jsxs("div",{className:"drawui-shape-group",children:[jsx("div",{className:"drawui-shape-group-title",children:t(h.labelKey)}),jsx("div",{className:"drawui-shape-group-grid",children:h.items.map(V=>{let l=V.labelKey??`tool.${V.type}`;return jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===V.type?"active":""}`,onClick:()=>{n(V.type),F(false),m();},onMouseEnter:L=>He(L.currentTarget,l),onMouseLeave:m,"aria-label":t(l),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ho.get(V.type)})},`${h.key}-${V.type}`)})})]},h.key))})})]}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Q,onMouseLeave:ae,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{n("sticky-note"),te(false),m();},"data-drawui-tip":q?void 0:t("tool.sticky-note"),children:[jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ao}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:M}})]}),q&&jsxs("div",{className:"drawui-toolbar-shape-grid drawui-sticky-panel",children:[jsxs("div",{className:"drawui-sticky-panel-head",children:[jsx("span",{className:"drawui-sticky-panel-title",children:t("tool.sticky-note")}),jsx("span",{className:"drawui-sticky-panel-key",children:"N"})]}),jsx("div",{className:"drawui-sticky-panel-grid",children:STICKY_NOTE_COLORS.map(h=>jsx("button",{type:"button","aria-label":h,className:`drawui-sticky-swatch${M.toLowerCase()===h.toLowerCase()?" active":""}`,style:{background:h},onClick:()=>Pe(h)},h))})]})]}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${Se?"active":""}`,"data-icon-toggle":"","data-drawui-tip":Se?void 0:t("toolbar.icon"),onClick:()=>{U(h=>!h),m();},children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"9"}),jsx("path",{d:"M8.5 10.2h0.01"}),jsx("path",{d:"M15.5 10.2h0.01"}),jsx("path",{d:"M8.8 14.2c0.9 1 2 1.5 3.2 1.5s2.3 -0.5 3.2 -1.5"})]})}),Se&&jsx(In,{onPick:h=>H?.(h.id),onClose:()=>U(false)})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:et,onMouseLeave:tt,children:[jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{n("arrow"),x(false),m();},"data-drawui-tip":i?void 0:t("toolbar.arrow"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M5 12h14M12 5l7 7-7 7"})})}),i&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:h=>{h.target.closest("button")||(x(false),m());},children:jsx(Nt,{connectionType:u?.connectionType??"straight",arrowHead:u?.arrowHead??"end",dashed:!!u?.dashed,onConnectionTypeChange:h=>{E?.({connectionType:h}),n("arrow"),x(false),m();},onArrowStyleChange:h=>{E?.({arrowHead:h.arrowHead,dashed:h.dashed}),n("arrow"),x(false),m();},onOptionHover:(h,V)=>He(V,h),onOptionLeave:m})})]}),Ko.filter(h=>h.type!=="arrow").map(h=>jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>n(h.type),"data-drawui-tip":t(h.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:h.icon})})},h.type)),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>n("pen"),"data-drawui-tip":t("toolbar.pen"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:Oo})})}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:D,onMouseLeave:z,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>n("highlighter"),onMouseEnter:h=>He(h.currentTarget,"toolbar.highlighter"),onMouseLeave:m,children:[jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M4.6 19.6 12.8 11.4",strokeWidth:"3.6",strokeLinecap:"square"}),jsx("path",{d:"M14.6 9.6 16.2 8",strokeWidth:"3.6",strokeLinecap:"square"}),jsxs("g",{fill:"currentColor",stroke:"none",children:[jsx("path",{d:qt,transform:"translate(7.4 5.4) scale(2.4)"}),jsx("path",{d:qt,transform:"translate(18.4 3.4) scale(2.5)"}),jsx("path",{d:qt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:P}})]}),B&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:gn.map(h=>jsx("button",{type:"button","aria-label":h,className:`drawui-highlighter-swatch${P.toLowerCase()===h.toLowerCase()?" active":""}`,style:{background:h},onClick:()=>W(h)},h))})]}),jsx("div",{className:"drawui-toolbar-divider"}),Do.map(h=>jsx("button",{className:`drawui-toolbar-button ${e===h.type?"active":""}`,onClick:()=>n(h.type),"data-drawui-tip":t(h.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:h.icon})})},h.type)),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>n("mind-map"),"data-drawui-tip":t("toolbar.mind-map"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"5",cy:"12",r:"2.4"}),jsx("path",{d:"M7.4 12h3.6"}),jsx("path",{d:"M11 12c0-2.6 1.6-4.4 3.4-4.4"}),jsx("path",{d:"M11 12c0 2.6 1.6 4.4 3.4 4.4"}),jsx("circle",{cx:"17.4",cy:"7.6",r:"1.7"}),jsx("circle",{cx:"17.4",cy:"16.4",r:"1.7"}),jsx("circle",{cx:"15.6",cy:"12",r:"1.7"})]})}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${Ke?"active":""}`,onClick:()=>be(h=>!h),"data-drawui-tip":t("toolbar.table"),"data-table-toggle":true,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("line",{x1:"3",y1:"9.3",x2:"21",y2:"9.3"}),jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}),Ke&&jsxs("div",{className:"drawui-table-picker",children:[jsx("div",{className:"drawui-table-picker-hint",children:ce?`${ce.rows} \xD7 ${ce.cols}`:t("table.pickHint")}),jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:$o*Xt},(h,V)=>{let l=Math.floor(V/Xt),L=V%Xt,ue=ce&&l<ce.rows&&L<ce.cols;return jsx("button",{type:"button","aria-label":`${l+1}x${L+1}`,className:"drawui-table-picker-cell",style:ue?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Ee({rows:l+1,cols:L+1}),onClick:()=>{I?.(l+1,L+1),be(false),Ee(null),m();}},V)})})]})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${a?"active":""}`,onClick:y,"data-drawui-tip":t("toolbar.grid"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"}),jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:"drawui-toolbar-button",onClick:s,disabled:!c,style:c?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":t("toolbar.undo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 7v6h6"}),jsx("path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:S,disabled:!r,style:r?void 0:{opacity:.4,cursor:"default"},"data-drawui-tip":t("toolbar.redo"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 7v6h-6"}),jsx("path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3L21 13"})]})}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:re,onMouseLeave:de,children:[jsx("button",{className:"drawui-toolbar-button","data-drawui-tip":w?void 0:t("toolbar.export"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),jsx("polyline",{points:"7 10 12 15 17 10"}),jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),w&&jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-export-grid",children:[ye.map(h=>jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{f?.(h.format),R(false);},"data-drawui-tip":t(h.labelKey),children:t(h.labelKey)},h.format)),jsx("div",{className:"drawui-toolbar-export-divider"}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{d?.(),R(false);},"data-drawui-tip":t("toolbar.export.data"),children:t("toolbar.export.data")}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:Oe,"data-drawui-tip":t("toolbar.import.data"),children:t("toolbar.import.data")})]})]}),jsx("input",{ref:J,type:"file",accept:".json,application/json",style:{display:"none"},onChange:we}),p&&jsx("div",{className:`drawui-shape-tip ${p.above?"is-above":"is-below"}`,style:{left:p.x,top:p.y},children:t(p.label)})]})})});var en=memo(function({onZoomIn:e,onZoomOut:n,onReset:a,zoomLevel:y=100}){return Z(),jsxs("div",{className:"drawui-zoom-control",children:[jsx("button",{className:"drawui-zoom-button",onClick:e,"data-drawui-tip":t("zoom.in"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),jsxs("div",{className:"drawui-zoom-level",children:[y,"%"]}),jsx("button",{className:"drawui-zoom-button",onClick:n,"data-drawui-tip":t("zoom.out"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"})})}),jsx("button",{className:"drawui-zoom-button",onClick:a,"data-drawui-tip":t("zoom.reset"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})})]})});var $n=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Dn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Go=$n.filter(t=>t!=="#f1f5f9"),Fo=[...Go,...Dn],Vo=[...$n,...Dn],Bn=15,zn="drawui:customColors";function Yo(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(zn);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(n=>typeof n=="string").slice(-Bn):[]}catch{return []}}function jo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(zn,JSON.stringify(t));}catch{}}var tn=[{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}],On=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),wt=10,ot=12,Qe=t=>!t||t==="transparent",_n=memo(function({editor:e,selectedCount:n,hasLineSelection:a,currentConnectionType:y,currentArrowHead:c,currentDashed:r}){Z();let s=!!e?.getEditingShapeId(),[S,f]=useState(null),[d,b]=useState(null),[,v]=useState(0),T=useRef(null),H=useRef(null),I=useRef(null),[u,E]=useState({tw:168,th:42,pw:228,ph:160}),[C,F]=useState(Yo),i=useRef(null),x=useCallback(l=>{let L=l.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(L)&&F(ue=>{let G=ue.filter($e=>$e!==L);for(G.push(L);G.length>Bn;)G.shift();return jo(G),G});},[]);if(useEffect(()=>{let l=i.current;if(!l)return;let L=()=>{l.value&&x(l.value);};return l.addEventListener("change",L),()=>l.removeEventListener("change",L)},[x,d]),useEffect(()=>{if(!e)return;let l=e.subscribe(()=>v(L=>(L+1)%1e6));return ()=>{l();}},[e]),useEffect(()=>{b(null);},[n,s]),useEffect(()=>{if(!d)return;let l=L=>{T.current&&!T.current.contains(L.target)&&b(null);};return document.addEventListener("pointerdown",l,true),()=>document.removeEventListener("pointerdown",l,true)},[d]),useLayoutEffect(()=>{let l=H.current?.offsetWidth??u.tw,L=H.current?.offsetHeight??u.th,ue=I.current?.offsetWidth??u.pw,G=I.current?.offsetHeight??u.ph;E($e=>$e.tw===l&&$e.th===L&&$e.pw===ue&&$e.ph===G?$e:{tw:l,th:L,pw:ue,ph:G});}),!e||n===0||s)return null;let p=e.getSelectedIds(),w=e.getShapes().filter(l=>p.includes(l.id)),R=w[0],B=R?.id??"",O=R?.style.fillColor,P=R?.style.strokeColor??"#1f2937",X=R?.textColor??"#1f2937",q=R?.highlightColor,te={fill:O,stroke:P,text:X,highlight:q},M=w.length>0&&w.every(l=>l.type==="sticky-note"),pe={fill:R?.style.fillOpacity??1,stroke:R?.style.strokeOpacity??1,highlight:R?.highlightOpacity??1},Se=l=>S&&S.key===`${B}:${l}`?S.value:pe[l]??1,U=(l,L)=>{switch(l){case "stroke":e.updateSelectedShapesStyle({strokeColor:L});break;case "fill":e.updateSelectedShapesStyle({fillColor:L});break;case "text":e.updateSelectedShapesText({textColor:L});break;case "highlight":e.updateSelectedShapesText({highlightColor:L});break}},Ke=(l,L)=>{f({key:`${B}:${l}`,value:L}),l==="highlight"?e.updateSelectedShapesText({highlightOpacity:L}):l==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:L}):e.updateSelectedShapesStyle({fillOpacity:L});},be=l=>e.updateConnectionType(l),ce=l=>e.updateArrowStyle({arrowHead:l.arrowHead,dashed:l.dashed}),Ee=!!a&&w.length>0&&w.every(l=>l.type==="line"||l.type==="arrow"),Me=w.length>0&&w.every(l=>l.type==="text"),Re=w.length>0&&w.every(l=>l.type==="sticky-note"||l.type==="icon"),ge=Ee?tn.filter(l=>l.key==="stroke"):Re?tn.filter(l=>l.key!=="stroke"):tn,$=l=>l.key==="stroke"&&Ee?"style.line":l.labelKey,k=d&&d!=="more"?ge.find(l=>l.key===d):void 0,ye=!!d&&(d==="more"||d==="prefix"||!!k),re=M&&k?.key==="fill",de=e.getCamera(),J=getContentBounds(w,0),Oe=de.pageToScreen({x:J.x,y:J.y}),we=de.pageToScreen({x:J.x+J.width,y:J.y+J.height}),Ye=window.innerWidth,je=window.innerHeight,et=we.y+wt,tt=Oe.y-wt,He=u.th+(ye?wt+u.ph:0),m=et+He<=je-ot,D=tt-He>=ot,z=m||!D,W=(Oe.x+we.x)/2,Q=(l,L,ue)=>Math.max(L,Math.min(l,Math.max(L,ue))),ae=Q(W-u.tw/2,ot,Ye-u.tw-ot),Pe=z?et:tt-u.th,h=Q(W-u.pw/2,ot,Ye-u.pw-ot),V=ye?Q(z?Pe+u.th+wt:Pe-wt-u.ph,ot,je-u.ph-ot):0;return jsxs("div",{className:"drawui-style-floating",ref:T,children:[jsxs("div",{className:"drawui-style-toolbar",ref:H,style:{left:ae,top:Pe},children:[ge.map(l=>jsxs("button",{className:`drawui-style-tool-btn${d===l.key?" active":""}`,onClick:()=>b(d===l.key?null:l.key),"data-drawui-tip":t($(l)),type:"button",children:[l.key==="fill"&&jsx("span",{className:`drawui-st-swatch${Qe(O)?" drawui-st-none":""}`,style:Qe(O)?void 0:{background:O}}),l.key==="stroke"&&(Ee?jsx("span",{className:`drawui-st-line${Qe(P)?" drawui-st-line-none":""}`,style:Qe(P)?void 0:{background:P}}):jsx("span",{className:`drawui-st-frame${Qe(P)?" drawui-st-frame-none":""}`,style:Qe(P)?void 0:{borderColor:P}})),l.key==="text"&&jsx("span",{className:"drawui-st-text",style:{color:X},children:"A"}),l.key==="highlight"&&jsx("span",{className:`drawui-st-hl${Qe(q)?" drawui-st-none":""}`,style:Qe(q)?void 0:{background:q},children:"A"})]},l.key)),a&&jsx("button",{className:`drawui-style-tool-btn${d==="more"?" active":""}`,onClick:()=>b(d==="more"?null:"more"),"data-drawui-tip":t("style.connection"),type:"button",children:"\u22EF"}),Me&&jsx("button",{className:`drawui-style-tool-btn${d==="prefix"?" active":""}`,onClick:()=>b(d==="prefix"?null:"prefix"),"data-drawui-tip":t("style.prefix"),type:"button",children:jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[jsx("circle",{cx:"5",cy:"8",r:"1.7",fill:"currentColor",stroke:"none"}),jsx("circle",{cx:"5",cy:"16",r:"1.7",fill:"currentColor",stroke:"none"}),jsx("line",{x1:"10.5",y1:"8",x2:"20",y2:"8"}),jsx("line",{x1:"10.5",y1:"16",x2:"20",y2:"16"})]})})]}),ye&&jsx("div",{className:"drawui-style-popover",ref:I,style:{left:h,top:V},children:d==="prefix"?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.prefix")}),jsx("div",{className:"drawui-muted-hint",children:t("style.prefix.soon")})]}):k?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t($(k))}),jsxs("div",{className:"drawui-color-row",children:[k.hasTransparent&&!re&&jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${Qe(te[k.key])?" active":""}`,onClick:()=>U(k.key,"transparent"),"aria-label":t("style.none"),type:"button"}),(re?STICKY_NOTE_COLORS:k.hasTransparent?Fo:Vo).map(l=>jsx("button",{className:`drawui-color-swatch${On(l,te[k.key])?" active":""}`,style:{background:l},onClick:()=>U(k.key,l),"aria-label":l,type:"button"},l)),C.map(l=>jsx("button",{className:`drawui-color-swatch drawui-color-custom${On(l,te[k.key])?" active":""}`,style:{background:l},onClick:()=>U(k.key,l),"aria-label":l,type:"button"},`custom-${l}`)),jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":t("style.addColor"),children:["+",jsx("input",{ref:i,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":t("style.addColor")})]})]}),k.hasOpacity&&jsxs("div",{className:"drawui-opacity-row",children:[jsx("span",{className:"drawui-opacity-label",children:t("style.opacity")}),jsx("input",{type:"range",min:0,max:100,value:Math.round(Se(k.key)*100),onChange:l=>Ke(k.key,Number(l.target.value)/100),className:"drawui-opacity-slider"}),jsxs("span",{className:"drawui-opacity-value",children:[Math.round(Se(k.key)*100),"%"]})]})]}):jsx(Fragment,{children:jsx(Nt,{connectionType:y??"straight",arrowHead:c??"end",dashed:!!r,onConnectionTypeChange:be,onArrowStyleChange:ce})})})]})});var rn=14,Zn=20,nr=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],or=[12,14,16,18,20,24];function Gn(t,e){let n=t,a="",y=n.charAt(0);if(n.length>1&&(y==="+"||y==="-"||y==="#"||y==="~")&&n.charAt(1)===" "&&(a=y,n=n.slice(2)),n=n.replace(/^\s+|\s+$/g,""),e==="attribute"){let d=n.indexOf(":");return d===-1?{visibility:a,name:n,type:"",params:"",returnType:""}:{visibility:a,name:n.slice(0,d).replace(/^\s+|\s+$/g,""),type:n.slice(d+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let c=n.indexOf("(");if(c===-1){let d=n.lastIndexOf(":");return d===-1?{visibility:a,name:n,type:"",params:"",returnType:""}:{visibility:a,name:n.slice(0,d).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:n.slice(d+1).replace(/^\s+|\s+$/g,"")}}let r=n.slice(0,c).replace(/^\s+|\s+$/g,""),s=n.indexOf(")",c);if(s===-1)return {visibility:a,name:r,type:"",params:n.slice(c+1).replace(/^\s+|\s+$/g,""),returnType:""};let S=n.slice(c+1,s).replace(/^\s+|\s+$/g,""),f=n.slice(s+1).replace(/^\s+|\s+$/g,"");return f.startsWith(":")&&(f=f.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:a,name:r,type:"",params:S,returnType:f}}function rr(t,e){let n=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${n}${e.name}${e.type?`: ${e.type}`:""}`:`${n}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var Vn=memo(function({editor:e,umlClass:n,editing:a}){let[,y]=useState(0);Z(),useEffect(()=>{if(!e)return;let m=e.subscribe(()=>y(D=>D+1));return ()=>{m();}},[e]);let[c,r]=useState(null),[s,S]=useState(false),[f,d]=useState(null),b=useRef(null),v=useRef(null),T=useCallback((m,D)=>{b.current&&(clearTimeout(b.current),b.current=null),r({section:m,rowId:D}),S(false);},[]),H=useCallback(()=>{b.current&&clearTimeout(b.current),b.current=window.setTimeout(()=>{r(null),S(false);},150);},[]);if(!e||!n||a!==n.id)return null;let I=e.getCamera(),{id:u,x:E,y:C,width:F,height:i,className:x,methods:p}=n,_=n.type==="uml-interface",w=_?[]:n.attributes,R=F/2,B=i/2,O=UML_HEADER_HEIGHT,P=UML_LINE_HEIGHT,X=UML_PADDING_X,q=UML_PADDING_Y,te=_?0:w.length>0?w.length*P+q*2:q*2,M=I.zoom,pe=(F-X*2)*M,Se=4*M,U=I.pageToScreen({x:E-R+X,y:C}),Ke=I.pageToScreen({x:E,y:C-B+O/2}),be=m=>I.pageToScreen({x:E,y:m}).y,ce=P*M,Ee=m=>C+(-B+O+q+P/2+m*P),Me=m=>C+(-B+O+te+q+P/2+m*P),Re=C+(-B+O+te),ge=C+B,$={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},k=(m,D)=>{if(!w.find(Q=>Q.id===m))return;let W=Gn(D,"attribute");e.updateUmlClass(u,{attributes:w.map(Q=>Q.id===m?{...Q,...W}:Q)});},ye=(m,D)=>{if(!p.find(ae=>ae.id===m))return;let W=Gn(D,"method"),Q=p.map(ae=>ae.id===m?{...ae,...W}:ae);_?e.updateUmlInterface(u,{methods:Q}):e.updateUmlClass(u,{methods:Q});},re=(m,D,z)=>{v.current={section:m,from:D},z.dataTransfer.effectAllowed="move",z.dataTransfer.setData("text/plain",`${m}:${D}`);},de=m=>{m.preventDefault(),m.dataTransfer.dropEffect="move";},J=(m,D,z)=>{z.preventDefault();let W=v.current;!W||W.section!==m||(m==="attribute"?e.reorderUmlAttribute(u,W.from,D):e.reorderUmlMethod(u,W.from,D),v.current=null);},Oe=(m,D,z,W)=>{let Q=be(W),ae=c?.section===m&&c.rowId===z.id,Pe=(z.fontSize||UML_FONT_SIZE)*M,h=z.textColor||"#1f2937",V={position:"absolute",left:U.x-rn*M-Se,top:Q-ce/2,width:rn*M+Se+pe+Zn*M,height:ce,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},l={...$,width:pe,height:ce-2,fontSize:Pe,color:h,textDecoration:z.strikethrough?"line-through":"none",pointerEvents:"auto",...ae?{borderColor:"var(--dw-primary)"}:{}},L={width:rn*M,height:ce-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*M,lineHeight:1,opacity:ae?1:.55,pointerEvents:"auto"},ue={width:Zn*M,height:ce-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*M,opacity:ae?1:.35,pointerEvents:"auto"};return jsxs("div",{style:V,onDragOver:de,onDrop:G=>J(m,D,G),children:[jsx("span",{style:L,draggable:true,onDragStart:G=>re(m,D,G),"data-drawui-tip":t("uml.drag"),children:"\u22EE\u22EE"}),jsx("input",{style:l,value:f&&f.rowId===z.id?f.text:rr(m,z),onChange:G=>{d({rowId:z.id,text:G.target.value}),m==="attribute"?k(z.id,G.target.value):ye(z.id,G.target.value);},onFocus:()=>T(m,z.id),onBlur:()=>{d(null),H();},spellCheck:false}),jsx("button",{style:ue,onMouseDown:G=>G.preventDefault(),onClick:()=>{m==="attribute"?e.removeUmlAttribute(u,z.id):e.removeUmlMethod(u,z.id);},"data-drawui-tip":t("uml.delete"),children:"\xD7"})]},z.id)},we=(m,D,z)=>{let W=be(D),Q=m==="attribute";return jsxs("button",{onMouseDown:ae=>ae.preventDefault(),onClick:()=>Q?e.addUmlAttribute(u):e.addUmlMethod(u),className:"drawui-uml-add-row",style:{position:"absolute",left:U.x,top:W-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":z,children:[jsx("span",{style:{fontSize:13*M,lineHeight:1},children:"+"}),jsx("span",{children:z})]},`add-${m}`)},Ye=()=>{if(!c||c.section==="className")return null;let m=c.section,D=c.rowId,W=(m==="attribute"?w:p).find(he=>he.id===D);if(!W)return null;let Q=224*M,ae=30*M,Pe=I.pageToScreen({x:E,y:C}).x,h=I.pageToScreen({x:E,y:C-B}).y,V=20*M,l=h-ae-V,L=Pe-Q/2,ue=l+ae,G=W.textColor||"#1f2937",$e=W.fontSize||UML_FONT_SIZE,mt=!!W.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Pe-.5,top:ue,width:1,height:V,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:L,top:l,width:Q,height:ae,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:he=>he.preventDefault(),children:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>S(he=>!he),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.textColor"),style:{border:"none",background:"transparent",cursor:"pointer",padding:2,display:"flex",alignItems:"center",borderRadius:3},children:[jsx("span",{style:{fontWeight:700,color:G,fontSize:13*M,textDecoration:mt?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*M,height:2*M,background:G,marginLeft:3,borderRadius:1}})]}),s&&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:[jsx("button",{onClick:()=>{e.updateUmlRowStyle(u,m,W.id,{textColor:null}),S(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":t("uml.defaultColor")}),nr.map(he=>jsx("button",{onClick:()=>{e.updateUmlRowStyle(u,m,W.id,{textColor:he}),S(false);},style:{width:14,height:14,border:"none",background:he,cursor:"pointer",borderRadius:2},"data-drawui-tip":he},he))]})]}),jsx("select",{value:$e,onChange:he=>e.updateUmlRowStyle(u,m,W.id,{fontSize:Number(he.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":t("uml.fontSize"),children:or.map(he=>jsx("option",{value:he,children:he},he))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(u,m,W.id,{strikethrough:!mt}),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.strikethrough"),style:{border:"none",background:mt?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*M,textDecoration:"line-through"},children:"A"})}),jsx("button",{onClick:()=>{m==="attribute"?e.removeUmlAttribute(u,W.id):e.removeUmlMethod(u,W.id),r(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxs("svg",{width:14*M,height:14*M,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("polyline",{points:"3 6 5 6 21 6"}),jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),jsx("path",{d:"M10 11v6"}),jsx("path",{d:"M14 11v6"}),jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]})]})},je=I.pageToScreen({x:E-R,y:C}).x,et=I.pageToScreen({x:E,y:C-B}).y,tt=F*M,He=i*M;return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("div",{style:{position:"absolute",left:je+1,top:et+1,width:Math.max(0,tt-2),height:Math.max(0,He-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsx("input",{style:{...$,position:"absolute",left:Ke.x-pe/2,top:Ke.y-O*M/2+2,width:pe,height:O*M-4,textAlign:"center",fontWeight:700,fontSize:(n.fontSize||UML_FONT_SIZE)*M,color:n.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...c?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:x,onChange:m=>_?e.updateUmlInterface(u,{className:m.target.value}):e.updateUmlClass(u,{className:m.target.value}),onFocus:()=>T("className",""),onBlur:H,spellCheck:false}),!_&&jsxs(Fragment,{children:[w.map((m,D)=>Oe("attribute",D,m,Ee(D))),we("attribute",Re,"\u5C5E\u6027")]}),p.map((m,D)=>Oe("method",D,m,Me(D))),we("method",ge,t("uml.method")),Ye()]})});var qn=memo(function({editor:e,panelOpen:n,onOpenPanel:a}){let[,y]=useState(0);Z(),useEffect(()=>{if(!e)return;let i=e.subscribe(()=>y(x=>x+1));return ()=>{i();}},[e]);let c=useRef(false),r=useRef(false),s=e?.getMindMapEditingShapeId()??null,S=e?.getMindMapSelectedNode()?.nodeId??"",f=s?`${s}\0${S}`:"";if(useEffect(()=>{c.current=false;},[f]),!e)return null;let d=e.getMindMapEditingShapeId();if(!d||n)return null;let b=e.getMindMapSelectedNode();if(!b||b.shapeId!==d)return null;let v=e.getMindMapNode(d,b.nodeId),T=e.getMindMapNodeScreenRect(d,b.nodeId);if(!v||!T)return null;let H=e.getCamera().getZoom(),I=MINDMAP_FONT_SIZE*H,u=Math.max(100,T.width+24),E=T.height+8,C={position:"absolute",left:T.x+T.width/2,top:T.y-4,transform:"translateX(-50%)",width:u,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 ${(v.icon?24:12)*H}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},F={position:"absolute",left:T.x+T.width+12,top:T.y+T.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 jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("input",{autoFocus:true,style:C,value:v.text,spellCheck:false,onChange:i=>{let x=!c.current;c.current=true,e.updateMindMapNode(d,b.nodeId,{text:i.target.value},x);},onBlur:()=>{if(r.current){r.current=false;return}e.exitMindMapEdit();},onKeyDown:i=>{i.key==="Enter"?i.target.blur():i.key==="Escape"&&e.exitMindMapEdit();}}),jsx("button",{style:F,"data-drawui-tip":t("mindmap.more"),onMouseDown:i=>{i.preventDefault(),r.current=true,setTimeout(()=>{r.current=false;},300);},onClick:a,children:"\u22EF"})]})});var eo=memo(function({editor:e,panelOpen:n}){let[,a]=useState(0);Z(),useEffect(()=>{if(!e)return;let E=e.subscribe(()=>a(C=>C+1));return ()=>{E();}},[e]);let y=useRef(false),c=e?.getTableEditing()??null,r=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(useEffect(()=>{y.current=false;},[r]),!e||n)return null;let s=e.getTableEditing();if(!s)return null;let{shapeId:S,row:f,col:d}=s,b=e.getTableCell(S,f,d),v=e.getTableScreenRect(S,f,d);if(!b||!v)return null;let T=e.getSelectedTable(),H=b.fontSize||T?.fontSize||TABLE_FONT_SIZE,I=e.getCamera().getZoom(),u={left:v.x-1,top:v.y-1,width:v.width+2,height:v.height+2,padding:`${TABLE_CELL_PADDING_Y*I}px ${TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:H*I,lineHeight:TABLE_LINE_HEIGHT_RATIO,fontWeight:b.bold?700:400,color:b.textColor||T?.textColor||"#1f2937",textAlign:b.align==="center"?"center":b.align==="right"?"right":"left"};return jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:u,value:b.text,spellCheck:false,onChange:E=>{let C=!y.current;y.current=true,e.updateTableCell(S,f,d,{text:E.target.value},C);},onBlur:()=>{e.exitTableEdit();},onKeyDown:E=>{(E.key==="Enter"||E.key==="Escape")&&(E.preventDefault(),E.target.blur());}})})});var oo=memo(function({editor:e}){let[,n]=useState(0),[a,y]=useState(null),c=useRef(null);if(Z(),useEffect(()=>{if(!e)return;let P=e.subscribe(()=>n(X=>X+1));return ()=>{P();}},[e]),useEffect(()=>{if(!a)return;let P=q=>{let te=q.target;te&&c.current?.contains(te)||y(null);},X=q=>{q.key==="Escape"&&y(null);};return window.addEventListener("pointerdown",P,true),window.addEventListener("keydown",X),()=>{window.removeEventListener("pointerdown",P,true),window.removeEventListener("keydown",X);}},[a]),!e)return null;let r=e.getSelectedTable();if(!r)return null;let s=e.getTableSelection();if(!s||s.shapeId!==r.id)return null;let S=e.getTableScreenRect(r.id);if(!S)return null;let f=r.cells.length,d=r.cells[0]?.length??0,b=tableExpandRangeToMerges(r,s.anchor.row,s.anchor.col,s.focus.row,s.focus.col),{r1:v,c1:T,r2:H,c2:I}=b,u=tableCoveredMap(r.cells),E=0;for(let P=v;P<=H;P++)for(let X=T;X<=I;X++)u[P]?.[X]||E++;let C=E>1,F=tableRangeHasMerge(r,v,T,H,I),i=v===H?`${v+1}`:`${v+1}\u2013${H+1}`,x=T===I?`${T+1}`:`${T+1}\u2013${I+1}`,p=f-(H-v+1)>=1,_=d-(I-T+1)>=1,R=S.y>56?S.y-40:S.y+S.height+10,B=P=>P.stopPropagation(),O=P=>()=>{P(),y(null);};return jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":r.id,style:{left:S.x+S.width/2,top:R},onPointerDown:B,children:[jsxs("div",{className:"drawui-table-split",children:[jsx("button",{className:"drawui-table-btn-main",title:t("table.insertRowBelow"),onClick:()=>e.insertTableRowRelative(r.id,"below"),children:t("table.insertRow")}),jsx("button",{className:`drawui-table-btn-caret ${a==="row"?"active":""}`,"data-table-insert-row":true,title:`${t("table.insertRowAbove")} / ${t("table.insertRowBelow")}`,onClick:()=>y(a==="row"?null:"row"),children:jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),a==="row"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsx("button",{onClick:O(()=>e.insertTableRowRelative(r.id,"above")),children:t("table.insertRowAbove")}),jsx("button",{onClick:O(()=>e.insertTableRowRelative(r.id,"below")),children:t("table.insertRowBelow")})]})]}),jsx("button",{title:`${t("table.deleteRow")} \xB7 ${i}`,disabled:!p,onClick:()=>e.deleteTableRowsInSelection(r.id),children:t("table.deleteRow")}),jsxs("div",{className:"drawui-table-split",children:[jsx("button",{className:"drawui-table-btn-main",title:t("table.insertColRight"),onClick:()=>e.insertTableColumnRelative(r.id,"right"),children:t("table.insertCol")}),jsx("button",{className:`drawui-table-btn-caret ${a==="col"?"active":""}`,"data-table-insert-col":true,title:`${t("table.insertColLeft")} / ${t("table.insertColRight")}`,onClick:()=>y(a==="col"?null:"col"),children:jsx("svg",{viewBox:"0 0 10 10",width:"8",height:"8","aria-hidden":"true",children:jsx("path",{d:"M1 3l4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),a==="col"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsx("button",{onClick:O(()=>e.insertTableColumnRelative(r.id,"left")),children:t("table.insertColLeft")}),jsx("button",{onClick:O(()=>e.insertTableColumnRelative(r.id,"right")),children:t("table.insertColRight")})]})]}),jsx("button",{title:`${t("table.deleteCol")} \xB7 ${x}`,disabled:!_,onClick:()=>e.deleteTableColsInSelection(r.id),children:t("table.deleteCol")}),jsx("button",{title:t("table.merge"),disabled:!C,onClick:()=>e.mergeTableCells(r.id),children:t("table.merge")}),jsx("button",{title:t("table.split"),disabled:!F,onClick:()=>e.splitTableCells(r.id),children:t("table.split")})]})});var ro=[...MINDMAP_COLORS,"#1f2937","#9ca3af"],ao=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Nr={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"},an={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Pt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},At={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 8px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5},sn={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},io=memo(function({editor:e,mindMap:n}){let[,a]=useState(0);Z(),useEffect(()=>{if(!e)return;let i=e.subscribe(()=>a(x=>x+1));return ()=>{i();}},[e]);let y=useRef(null);if(!e||!n||e.getMindMapEditingShapeId()!==n.id)return null;let c=e.getMindMapSelectedNode();if(!c||c.shapeId!==n.id)return null;let r=i=>{if(i.id===c.nodeId)return i;for(let x of i.children??[]){let p=r(x);if(p)return p}return null},s=r(n.root);if(!s)return null;let S=e.getCamera(),d=layoutMindMap(n.root).positions.get(s.id);if(!d)return null;let b=S.zoom,v=S.pageToScreen({x:n.x+d.x,y:n.y+d.y}),T=v.x+d.width*b/2+14,H=v.y-80,u=Math.max(8,Math.min(T,(window.innerWidth||1024)-232-8)),E=Math.max(8,Math.min(H,(window.innerHeight||768)-320)),C=i=>{e.updateMindMapNode(n.id,s.id,i);},F=!!s.id&&s.id!==n.root.id;return jsxs("div",{ref:y,style:{...Nr,left:u,top:E},onMouseDown:i=>i.stopPropagation(),children:[jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[jsx("span",{style:{fontWeight:600,fontSize:12},children:t("mindmap.nodeText")}),jsx("button",{onClick:()=>e.exitMindMapEdit(),"data-drawui-tip":t("mindmap.close"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#9ca3af",fontSize:14,lineHeight:1,padding:2},children:"\xD7"})]}),jsx("input",{style:{...sn,marginBottom:8},value:s.text,onChange:i=>C({text:i.target.value}),spellCheck:false}),jsxs("div",{style:{...Pt,marginBottom:10},children:[jsxs("button",{style:At,onClick:()=>e.addMindMapChild(n.id,s.id),children:["+ ",t("mindmap.addChild")]}),F&&jsxs("button",{style:At,onClick:()=>e.addMindMapSibling(n.id,s.id),children:["+ ",t("mindmap.addSibling")]}),!!s.children?.length&&jsx("button",{style:At,onClick:()=>e.toggleMindMapCollapse(n.id,s.id),children:s.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),jsx("button",{style:{...At,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto"},onClick:()=>e.deleteMindMapNode(n.id,s.id),children:t("mindmap.deleteNode")})]}),jsx("span",{style:an,children:t("mindmap.color")}),jsxs("div",{style:{...Pt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":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}}),ro.map(i=>jsx("button",{"data-drawui-tip":i,onClick:()=>C({color:i}),style:{width:18,height:18,borderRadius:4,border:s.color===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer",flexShrink:0}},i))]}),jsx("span",{style:an,children:t("mindmap.icon")}),jsxs("div",{style:{...Pt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":t("mindmap.noIcon"),onClick:()=>C({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:s.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),ao.map(i=>jsx("button",{onClick:()=>C({icon:i}),style:{width:22,height:22,borderRadius:4,border:s.icon===i?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:i},i)),jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:s.icon&&!ao.includes(s.icon)?s.icon:"",onKeyDown:i=>{if(i.key==="Enter"){let x=i.target.value.trim();C({icon:x||void 0});}},onBlur:i=>{let x=i.target.value.trim();x!==s.icon&&C({icon:x||void 0});},style:{...sn,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsx("span",{style:an,children:t("mindmap.note")}),jsx("input",{style:{...sn,marginBottom:6},value:s.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:i=>C({note:i.target.value||void 0}),spellCheck:false}),!!s.note&&jsxs("div",{style:{...Pt,marginTop:4},children:[jsx("span",{style:{fontSize:11,color:"#6b7280"},children:t("mindmap.noteColor")}),jsx("button",{"data-drawui-tip":t("mindmap.noteColorDefault"),onClick:()=>C({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:s.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"}}),ro.map(i=>jsx("button",{onClick:()=>C({noteColor:i}),style:{width:16,height:16,borderRadius:3,border:s.noteColor===i?"2px solid #111827":"1px solid #d1d5db",background:i,cursor:"pointer"}},i))]})]})});var cn=220,dn=140,Pr="#fafafa";function Ar(t,e){let n=Math.min(t.x,e.x),a=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:n,y:a,width:y-n,height:c-a}}function Kr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Or(){return {x:0,y:0,width:0,height:0}}function $r(t){let e=1/0,n=1/0,a=-1/0,y=-1/0,c=false;for(let r of t){let s=pn(r);s&&(c=true,s.x<e&&(e=s.x),s.y<n&&(n=s.y),s.x+s.width>a&&(a=s.x+s.width),s.y+s.height>y&&(y=s.y+s.height));}return c?{x:e,y:n,width:a-e,height:y-n}:null}function pn(t){switch(t.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: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 n=1/0,a=1/0,y=-1/0,c=-1/0;for(let r of e)r.x<n&&(n=r.x),r.y<a&&(a=r.y),r.x>y&&(y=r.x),r.y>c&&(c=r.y);return {x:n,y:a,width:y-n,height:c-a}}case "draw":{let e=t,n=e.width,a=e.height;if(typeof n=="number"&&typeof a=="number")return {x:e.x-n/2,y:e.y-a/2,width:n,height:a};let y=e.points;if(!y||y.length===0)return null;let c=1/0,r=1/0,s=-1/0,S=-1/0;for(let f of y){let d=f.x+e.x,b=f.y+e.y;d<c&&(c=d),b<r&&(r=b),d>s&&(s=d),b>S&&(S=b);}return {x:c,y:r,width:s-c,height:S-r}}default:return null}}function Dr(t){let e=t.getCamera(),n=e.screenToPage({x:0,y:0}),a=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:n.x,y:n.y,width:a.x-n.x,height:a.y-n.y}}function Br(t,e,n){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-n/2,width:e,height:n};let a=e/n,y=t.width,c=y/a;c<t.height&&(c=t.height,y=c*a);let r=Kr(t);return {x:r.x-y/2,y:r.y-c/2,width:y,height:c}}function un(t,e,n,a){let y=(t-n.left)/n.width,c=(e-n.top)/n.height;return {x:a.x+y*a.width,y:a.y+c*a.height}}var co=memo(function({editor:e}){let n=useRef(null),a=useRef(null),[y,c]=useState(false),[r,s]=useState(100),[S,f]=useState(false),[d,b]=useState(false);Z();let v=useRef(null),T=useRef(null);useLayoutEffect(()=>{let i=n.current,x=a.current;if(!i||!x)return;let p=window.devicePixelRatio||1;i.width=Math.round(cn*p),i.height=Math.round(dn*p),i.style.width=`${cn}px`,i.style.height=`${dn}px`;},[y]);let H=useCallback(()=>{let i=n.current,x=a.current;if(!i||!x||!e)return;let p=i.getContext("2d");if(!p)return;let _=cn,w=dn,R=i.width,B=i.height,O=e.getShapes(),P=new Set(e.getSelectedIds()),X=getTheme(),q=hexToRgba(X.text,.16),te=X.primary,M=hexToRgba(X.primary,.18),pe=hexToRgba(X.primary,.85),Se=$r(O),U=Dr(e),Ke=Se?Ar(Se,U):U.width>0?U:Or(),be=Br(Ke,_,w);T.current=be;let ce=R/be.width,Ee=B/be.height,Me=_/be.width;p.setTransform(1,0,0,1,0,0),p.fillStyle=Pr,p.fillRect(0,0,R,B),p.setTransform(ce,0,0,Ee,-ce*be.x,-Ee*be.y),p.fillStyle=q;for(let $ of O){let k=pn($);k&&p.fillRect(k.x,k.y,k.width,k.height);}p.fillStyle=te;for(let $ of O){if(!P.has($.id))continue;let k=pn($);k&&p.fillRect(k.x,k.y,k.width,k.height);}p.fillStyle=M,p.fillRect(U.x,U.y,U.width,U.height);let Re=1.5/Me;p.strokeStyle=pe,p.lineWidth=Re,p.lineJoin="round";let ge=Math.min(U.width/6,U.height/6,6/Me);if(p.beginPath(),ge*Me<1)p.rect(U.x,U.y,U.width,U.height);else {let $=U.x,k=U.y,ye=U.width,re=U.height,de=Math.min(ge,ye/2,re/2);p.moveTo($+de,k),p.lineTo($+ye-de,k),p.quadraticCurveTo($+ye,k,$+ye,k+de),p.lineTo($+ye,k+re-de),p.quadraticCurveTo($+ye,k+re,$+ye-de,k+re),p.lineTo($+de,k+re),p.quadraticCurveTo($,k+re,$,k+re-de),p.lineTo($,k+de),p.quadraticCurveTo($,k,$+de,k),p.closePath();}p.stroke(),p.setTransform(1,0,0,1,0,0);},[e]);useEffect(()=>{if(!e||y)return;H();let i=e.subscribe(H),x=subscribeTheme(H),p=()=>H();return window.addEventListener("resize",p),()=>{i(),x(),window.removeEventListener("resize",p);}},[e,y,H]),useEffect(()=>{if(!e)return;let i=()=>{let p=e.getCamera().getZoom();s(Math.round(p*100));};i();let x=e.subscribe(i);return ()=>{x();}},[e]);let I=useCallback((i,x)=>{if(!e)return;let p=e.getCamera(),_=p.getZoom(),w=window.innerWidth/2,R=window.innerHeight/2,B=p;B.x=w-i*_,B.y=R-x*_,e.requestRender();},[e]),u=i=>{if(!e||!a.current||i.button!==0)return;let x=a.current.getBoundingClientRect(),p=T.current;if(!p)return;let _=un(i.clientX,i.clientY,x,p);v.current={pointerId:i.pointerId,rect:{left:x.left,top:x.top,width:x.width,height:x.height},canvasBox:p},i.currentTarget.setPointerCapture(i.pointerId),b(true),I(_.x,_.y);},E=i=>{if(!d||!e||!v.current||!a.current)return;let x=v.current,p=un(i.clientX,i.clientY,x.rect,x.canvasBox);I(p.x,p.y);},C=i=>{if(d){b(false),v.current=null;try{i.currentTarget.releasePointerCapture(i.pointerId);}catch{}}},F=i=>{if(!e||!a.current)return;let x=T.current;if(!x)return;let p=a.current.getBoundingClientRect(),_=un(i.clientX,i.clientY,p,x);I(_.x,_.y);};return jsxs("div",{className:`drawui-minimap ${y?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(i=>!i),"data-drawui-tip":y?t("minimap.expand"):t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":y?t("minimap.expand"):t("minimap.collapse"),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:y?jsx("polyline",{points:"9 6 15 12 9 18"}):jsx("polyline",{points:"15 6 9 12 15 18"})})}),!y&&jsxs("div",{className:"drawui-minimap-panel",children:[jsxs("div",{className:"drawui-minimap-header",children:[jsx("span",{className:"drawui-minimap-title",children:t("minimap.title")}),jsxs("span",{className:"drawui-minimap-zoom",children:[r,"%"]})]}),jsx("div",{ref:a,className:"drawui-minimap-canvas-wrap",style:{cursor:d?"grabbing":S?"pointer":"default"},onPointerEnter:()=>f(true),onPointerLeave:()=>f(false),children:jsx("canvas",{ref:n,className:"drawui-minimap-canvas",onPointerDown:u,onPointerMove:E,onPointerUp:C,onPointerCancel:C,onDoubleClick:F})})]})]})});var ke=t=>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}),Wr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:ke(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:ke(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:ke(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:ke(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:ke(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:ke(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:ke(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:ke(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:ke(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:ke(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:ke(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:ke(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:ke(jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:ke(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M3 15 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"uml-interface",labelKey:"shape.uml-interface",glyph:ke(jsxs(Fragment,{children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),jsx("path",{d:"M3 9 H21"}),jsx("path",{d:"M6 6.5 H10"}),jsx("path",{d:"M6 12.5 H12"})]}))},{type:"mind-map",labelKey:"shape.mind-map",glyph:ke(jsxs(Fragment,{children:[jsx("circle",{cx:"5",cy:"12",r:"2"}),jsx("path",{d:"M7 12h2.6"}),jsx("path",{d:"M9.6 12c0-2 1.2-3.4 2.6-3.4"}),jsx("path",{d:"M9.6 12c0 2 1.2 3.4 2.6 3.4"}),jsx("circle",{cx:"15.2",cy:"8.6",r:"1.3"}),jsx("circle",{cx:"15.2",cy:"15.4",r:"1.3"}),jsx("circle",{cx:"13.6",cy:"12",r:"1.3"})]}))}];function uo({editor:t$1,x:e,y:n,context:a,existingArrowId:y,defaultShapeType:c,onClose:r}){let s=useRef(null);Z();let S=f=>{t$1?.createGeneratedConnection(a,{type:f,existingArrowId:y}),r();};return useEffect(()=>{let f=v=>{s.current&&!s.current.contains(v.target)&&r();},d=v=>{v.key==="Escape"&&(v.preventDefault(),r());},b=setTimeout(()=>{window.addEventListener("pointerdown",f,true),window.addEventListener("keydown",d,true);},0);return ()=>{clearTimeout(b),window.removeEventListener("pointerdown",f,true),window.removeEventListener("keydown",d,true);}},[r]),jsxs("div",{className:"drawui-gen-menu",ref:s,style:{left:e,top:n},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:Wr.map(f=>jsxs("button",{className:`drawui-gen-shape-btn${f.type===c?" drawui-gen-shape-active":""}`,onClick:()=>S(f.type),"data-drawui-tip":t(f.labelKey),children:[f.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(f.labelKey)})]},f.type))}),jsx("div",{className:"drawui-gen-menu-hint",children:t("menu.cancel")})]})}var Fr=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function Ne(t){if(Fr)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 "flipH":return "\u21E7H";case "flipV":return "\u21E7V";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 "flipH":return "Shift + H";case "flipV":return "Shift + V";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var yo={sep:true},Vr=t=>"sep"in t&&t.sep===true;function ho({editor:t$1,pos:e,onClose:n}){Z();let[,a]=useState(0),y=useRef(null),[c,r]=useState(null),[s,S]=useState(null);useEffect(()=>{let w=t$1.subscribe(()=>a(R=>R+1));return ()=>{w();}},[t$1]),useLayoutEffect(()=>{let w=y.current;if(!w)return;let R=w.getBoundingClientRect(),B=Math.max(8,Math.min(e.x,window.innerWidth-R.width-8)),O=Math.max(8,Math.min(e.y,window.innerHeight-R.height-8));r({left:B,top:O});},[e.x,e.y]),useEffect(()=>{let w=O=>{y.current&&!y.current.contains(O.target)&&n();},R=O=>{O.key==="Escape"&&(O.preventDefault(),n());},B=setTimeout(()=>{window.addEventListener("pointerdown",w,true),window.addEventListener("keydown",R,true);},0);return ()=>{clearTimeout(B),window.removeEventListener("pointerdown",w,true),window.removeEventListener("keydown",R,true);}},[n]);let f=t$1.getSelectedIds(),d=f.length>0,b=e.shapeId,v=b?t$1.isShapeLocked(b):false,T=t$1.getSelectedShapes().some(w=>!w.locked&&isFlippableShapeType(w.type)),H=d&&!v&&t$1.hasCopiedStyle(),I=t$1.hasClipboard(),u=d&&!v,E=d&&!v?t$1.getSelectedGroupId():null,C=d&&!v&&f.length>=2&&!E,i=(b?t$1.getShapes().find(w=>w.id===b):void 0)?.groupId??null,x=E?true:!!i&&!v,p=w=>()=>{w(),n();},_;return v?_=i?[{key:"ctx.unlockGroup",action:p(()=>i&&t$1.setGroupLocked(i,false))},{key:"ctx.ungroup",shortcut:Ne("ungroup"),action:p(()=>i&&t$1.ungroupIds([i]))}]:[{key:"ctx.unlock",action:()=>b&&t$1.setShapeLocked(b,false)}]:d?_=[{key:"ctx.copy",shortcut:Ne("copy"),action:p(()=>t$1.copySelected())},{key:"ctx.copyAsImage",shortcut:Ne("copyAsImage"),action:p(()=>{t$1.copySelectedAsImage();})},{key:"ctx.paste",shortcut:Ne("paste"),disabled:!I,action:p(()=>t$1.paste())},{key:"ctx.duplicate",shortcut:Ne("duplicate"),action:p(()=>t$1.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!u,action:()=>t$1.bringToFront()},{key:"ctx.bringForward",disabled:!u,action:()=>t$1.bringForward()},{key:"ctx.sendBackward",disabled:!u,action:()=>t$1.sendBackward()},{key:"ctx.sendToBack",disabled:!u,action:()=>t$1.sendToBack()}]},{key:"ctx.copyStyle",shortcut:Ne("copyStyle"),action:p(()=>t$1.copyStyle())},{key:"ctx.pasteStyle",shortcut:Ne("pasteStyle"),disabled:!H,action:p(()=>t$1.pasteStyle())},yo,{key:"ctx.flipH",shortcut:Ne("flipH"),disabled:!T,action:p(()=>t$1.flipSelected("horizontal"))},{key:"ctx.flipV",shortcut:Ne("flipV"),disabled:!T,action:p(()=>t$1.flipSelected("vertical"))},{key:"ctx.rotate",action:p(()=>t$1.rotateSelected90(true))},E?{key:"ctx.ungroup",shortcut:Ne("ungroup"),disabled:!x,action:p(()=>t$1.ungroupSelected())}:{key:"ctx.group",shortcut:Ne("group"),disabled:!C,action:p(()=>t$1.groupSelected())},yo,{key:"ctx.lock",shortcut:Ne("lock"),action:p(()=>t$1.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:Ne("delete"),action:p(()=>t$1.deleteSelected())}]:_=[{key:"ctx.paste",shortcut:Ne("paste"),disabled:!I,action:p(()=>t$1.paste())}],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:w=>w.preventDefault(),children:_.map((w,R)=>Vr(w)?jsx("div",{className:"drawui-context-sep"},`sep-${R}`):w.submenu?jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>S(w.key),onMouseLeave:()=>S(null),children:[jsxs("button",{type:"button",className:"drawui-context-item",disabled:w.disabled,children:[jsx("span",{children:t(w.key)}),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:jsx("polyline",{points:"9 18 15 12 9 6"})})]}),s===w.key&&jsx("div",{className:"drawui-context-submenu",children:w.submenu.map(B=>jsx("button",{type:"button",className:"drawui-context-item",disabled:B.disabled,onClick:()=>{B.action(),n();},children:jsx("span",{children:t(B.key)})},B.key))})]},w.key):jsxs("button",{type:"button",className:"drawui-context-item",disabled:w.disabled,onClick:w.action,children:[jsx("span",{children:t(w.key)}),w.shortcut&&jsx("span",{className:"drawui-context-kbd",children:w.shortcut})]},w.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"};function Jr({initialTool:t$1="select",className:e="",themeColor:n,language:a="zh-CN",data:y,onChange:c,onReady:r}){let s=useRef(null),S=useRef(null),f=useRef(null),[d,b]=useState(null);Z();let[v,T]=useState(t$1),[H,I]=useState(false),[u,E]=useState(0),[C,F]=useState(false),[i,x]=useState("straight"),[p,_]=useState("end"),[w,R]=useState(false),[B,O]=useState(void 0),[P,X]=useState(100),[q,te]=useState(null),[M,pe]=useState(null),[Se,U]=useState(false),[Ke,be]=useState(false),[ce,Ee]=useState(null),[Me,Re]=useState(null),[ge,$]=useState(false),[k,ye]=useState(null),[re,de]=useState(null),J=useRef(null),Oe=useRef(0),we=useRef(null),Ye=useRef(c);Ye.current=c;let je=useRef(r);je.current=r,useEffect(()=>{if(!s.current)return;let g=new Editor(s.current,{theme:n?{primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:hexToRgba(n,.1),shadow:n}}:void 0,language:a,shapes:y,persist:!y});f.current=g,b(g),window.__drawuiEditor=g,g.setHighlighterColor(Ct()),g.setStickyNoteColor(St()),je.current?.(g),t$1&&g.setActiveTool(t$1);let K=g.subscribe(()=>{T(g.getActiveTool());let Y=g.getSelectedIds();E(Y.length);let Le=g.getShapes().filter(We=>Y.includes(We.id)&&(We.type==="line"||We.type==="arrow"));if(F(Le.length>0),Le.length>0&&Le[0].connectionType?x(Le[0].connectionType):Le.length>0&&x("straight"),Le.length>0){let We=Le.find(_t=>_t.type==="arrow");We&&(_(We.arrowHead??"end"),R(We.dashed??false));}X(Math.round(g.getCamera().getZoom()*100)),O(g.getArrowStyle()),U(g.canUndo()),be(g.canRedo());let _e=g.getSelectedUml();Ee(_e),_e||ye(null);let Xe=g.getSelectedMindMap();Re(Xe),g.getMindMapEditingShapeId()||$(false),Ye.current?.(g.getData());}),Ae=g.subscribeNotifications(Y=>{pe({type:"success",text:Y}),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);}),ze=g.subscribeUi(Y=>{Y.kind==="shapeTypeMenu"&&de({x:Y.screenX,y:Y.screenY,context:Y.context,existingArrowId:Y.existingArrowId,defaultShapeType:Y.defaultShapeType});});return ()=>{K(),Ae(),ze(),J.current&&clearTimeout(J.current),cancelAnimationFrame(Oe.current),g.dispose();}},[t$1]),useEffect(()=>{if(!n)return;let g=S.current;g&&(g.style.setProperty("--dw-primary",n),g.style.setProperty("--dw-primary-hover",shadeColor(n,-0.12)),g.style.setProperty("--dw-primary-weak",hexToRgba(n,.1)),g.style.setProperty("--dw-primary-contrast","#ffffff"),g.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(n,.3)}`)),f.current?.setTheme({primary:n,editBorder:n,selection:{outline:n,handleStroke:n,handleFill:"#ffffff",outlineFill:hexToRgba(n,.1),shadow:n}});},[n]),useEffect(()=>{setLanguage(a),f.current?.setLanguage(a);},[a]);let et=useCallback(g=>{f.current?.setActiveTool(g);},[]),tt=useCallback(()=>{f.current?.zoomIn();},[]),He=useCallback(()=>{f.current?.zoomOut();},[]),m=useCallback(()=>{f.current?.resetZoom();},[]),D=useCallback(()=>{let g=!H;I(g),f.current?.setShowGrid(g);},[H]),z=useCallback(()=>{f.current?.undo();},[]),W=useCallback(()=>{f.current?.redo();},[]),Q=useCallback(g=>{f.current?.downloadImage("drawui",g,{background:"#ffffff"});},[]),ae=useCallback(()=>{f.current?.downloadJSON("drawui-data");},[]),Pe=useCallback(g=>{let K=new FileReader;K.onload=()=>{let Ae=typeof K.result=="string"?K.result:"";if(f.current?.importJSON(Ae)??false){let Y=f.current?.getShapes().length??0;pe({type:"success",text:t("import.success",{n:Y})});}else pe({type:"error",text:t("import.fail")});J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);},K.onerror=()=>{pe({type:"error",text:t("import.fail")}),J.current&&clearTimeout(J.current),J.current=setTimeout(()=>pe(null),3500);},K.readAsText(g,"utf-8");},[]),h=useCallback(g=>{let K=f.current,Ae=s.current;if(!K||!Ae)return;if(K.isPointerDown()){we.current!==null&&(we.current=null,te(null));return}let ze=g.clientX,Y=g.clientY;cancelAnimationFrame(Oe.current),Oe.current=requestAnimationFrame(()=>{let st=Ae.getBoundingClientRect(),Le=ze-st.left,_e=Y-st.top,Xe=Le+12,We=_e+12,_t=K.getSelectedUml()?.id,lt=K.getUmlRowAtScreenPoint({x:Le,y:_e});if(lt&<.shape.id!==_t&<.text&&K.isUmlRowTextTruncated(lt)){we.current!==lt.text&&(we.current=lt.text,te({text:lt.text,x:Xe,y:We}));return}let ut=K.getShapeAtScreenPoint({x:Le,y:_e});ut&&ut.text&&K.isShapeTextTruncated(ut.id)?we.current!==ut.text&&(we.current=ut.text,te({text:ut.text,x:Xe,y:We})):we.current!==null&&(we.current=null,te(null));});},[]),V=useCallback(()=>{te(null);},[]),l=useCallback(g=>{let K=f.current,Ae=s.current;if(!K||!Ae)return;let ze=Ae.getBoundingClientRect(),Y=g.clientX-ze.left,st=g.clientY-ze.top,Le=K.getUmlRowAtScreenPoint({x:Y,y:st});if(Le){ye(Le.shape.id);return}let _e=K.getMindMapNodeAtScreenPoint({x:Y,y:st});if(_e){K.beginMindMapEdit(_e.shapeId,_e.nodeId);return}let Xe=K.getTableAtScreenPoint({x:Y,y:st});Xe&&K.beginTableEdit(Xe.shapeId,Xe.row,Xe.col);},[]),L=useCallback(()=>{de(null);},[]),[ue,G]=useState(null),$e=useCallback(()=>G(null),[]),mt=useCallback(g=>{g.preventDefault();let K=f.current,Ae=s.current;if(!K||!Ae||K.isEditing())return;let ze=Ae.getBoundingClientRect(),Y=K.getShapeAtScreenPoint({x:g.clientX-ze.left,y:g.clientY-ze.top});Y?K.isShapeLocked(Y.id)?K.selectShapeRaw(Y.id):K.getSelectedIds().includes(Y.id)||K.selectShape(Y.id,g.shiftKey):K.selectShape("",false),G({x:g.clientX,y:g.clientY,shapeId:Y?.id??null});},[]),he=useCallback(g=>{g.preventDefault();},[]);return jsxs("div",{ref:S,className:`drawui-canvas-board ${e}`,onContextMenu:he,children:[jsx("canvas",{ref:s,className:"drawui-canvas",onMouseMove:h,onMouseLeave:V,onDoubleClick:l,onContextMenu:mt}),q&&jsx("div",{className:"drawui-tooltip",style:{left:q.x,top:q.y},children:q.text}),jsx(Jt,{activeTool:v,onToolChange:et,showGrid:H,onToggleGrid:D,canUndo:Se,canRedo:Ke,onUndo:z,onRedo:W,onExport:Q,onExportData:ae,onImportData:Pe,onHighlighterColorChange:g=>f.current?.setHighlighterColor(g),onStickyNoteColorChange:g=>f.current?.setStickyNoteColor(g),onInsertIcon:g=>f.current?.insertIcon(g),onInsertTable:(g,K)=>f.current?.insertTable(g,K),arrowStyle:B,onArrowStyleChange:g=>f.current?.setArrowStyle(g)}),jsx(en,{onZoomIn:tt,onZoomOut:He,onReset:m,zoomLevel:P}),jsx(_n,{editor:d,selectedCount:u,hasLineSelection:C,currentConnectionType:i,currentArrowHead:p,currentDashed:w}),jsx(Vn,{editor:d,umlClass:ce,editing:k}),jsx(oo,{editor:d}),jsx(eo,{editor:d,panelOpen:ge}),jsx(qn,{editor:d,panelOpen:ge,onOpenPanel:()=>$(true)}),ge&&jsx(io,{editor:d,mindMap:Me}),jsx(co,{editor:d}),re&&jsx(uo,{editor:d,x:re.x,y:re.y,context:re.context,existingArrowId:re.existingArrowId,defaultShapeType:re.defaultShapeType,onClose:L}),ue&&d&&jsx(ho,{editor:d,pos:ue,onClose:$e}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(qr[v])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:u===0?t("status.none"):t("status.selected",{n:u})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[P,"%"]})})]}),M&&jsxs("div",{className:"drawui-toast",children:[M.type==="success"?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:jsx("polyline",{points:"20 6 9 17 4 12"})}):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:[jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),M.text]})]})}export{Jr as CanvasBoard,Jt as Toolbar,en as ZoomControl};
|
package/dist/styles.css
CHANGED
|
@@ -1405,3 +1405,94 @@
|
|
|
1405
1405
|
overflow: hidden;
|
|
1406
1406
|
resize: none;
|
|
1407
1407
|
}
|
|
1408
|
+
.drawui-context-menu {
|
|
1409
|
+
position: absolute;
|
|
1410
|
+
display: flex;
|
|
1411
|
+
flex-direction: column;
|
|
1412
|
+
min-width: 224px;
|
|
1413
|
+
padding: 6px;
|
|
1414
|
+
background: var(--dw-panel-bg);
|
|
1415
|
+
backdrop-filter: blur(16px);
|
|
1416
|
+
-webkit-backdrop-filter: blur(16px);
|
|
1417
|
+
border-radius: 12px;
|
|
1418
|
+
box-shadow: var(--dw-shadow-xl);
|
|
1419
|
+
border: 1px solid var(--dw-panel-border);
|
|
1420
|
+
z-index: 500;
|
|
1421
|
+
user-select: none;
|
|
1422
|
+
animation: drawui-context-menu-in 0.18s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1423
|
+
}
|
|
1424
|
+
@keyframes drawui-context-menu-in {
|
|
1425
|
+
from {
|
|
1426
|
+
opacity: 0;
|
|
1427
|
+
transform: scale(0.96);
|
|
1428
|
+
}
|
|
1429
|
+
to {
|
|
1430
|
+
opacity: 1;
|
|
1431
|
+
transform: scale(1);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
.drawui-context-item {
|
|
1435
|
+
display: flex;
|
|
1436
|
+
align-items: center;
|
|
1437
|
+
justify-content: space-between;
|
|
1438
|
+
gap: 24px;
|
|
1439
|
+
width: 100%;
|
|
1440
|
+
padding: 7px 10px;
|
|
1441
|
+
border: none;
|
|
1442
|
+
border-radius: 10px;
|
|
1443
|
+
background: transparent;
|
|
1444
|
+
font-size: 13px;
|
|
1445
|
+
font-family: inherit;
|
|
1446
|
+
color: var(--dw-text-ink);
|
|
1447
|
+
text-align: left;
|
|
1448
|
+
cursor: pointer;
|
|
1449
|
+
white-space: nowrap;
|
|
1450
|
+
}
|
|
1451
|
+
.drawui-context-item:hover {
|
|
1452
|
+
background: var(--dw-hover-bg);
|
|
1453
|
+
}
|
|
1454
|
+
.drawui-context-item.is-danger:hover {
|
|
1455
|
+
background: rgba(239, 68, 68, 0.08);
|
|
1456
|
+
color: var(--dw-danger);
|
|
1457
|
+
}
|
|
1458
|
+
.drawui-context-item:disabled {
|
|
1459
|
+
opacity: 0.38;
|
|
1460
|
+
cursor: default;
|
|
1461
|
+
}
|
|
1462
|
+
.drawui-context-item:disabled:hover {
|
|
1463
|
+
background: transparent;
|
|
1464
|
+
}
|
|
1465
|
+
.drawui-context-kbd {
|
|
1466
|
+
font-size: 11px;
|
|
1467
|
+
color: var(--dw-text-faint);
|
|
1468
|
+
font-family: inherit;
|
|
1469
|
+
}
|
|
1470
|
+
.drawui-context-caret {
|
|
1471
|
+
color: var(--dw-text-faint);
|
|
1472
|
+
flex-shrink: 0;
|
|
1473
|
+
}
|
|
1474
|
+
.drawui-context-sep {
|
|
1475
|
+
height: 1px;
|
|
1476
|
+
margin: 4px 8px;
|
|
1477
|
+
background: var(--dw-panel-border);
|
|
1478
|
+
}
|
|
1479
|
+
.drawui-context-sub {
|
|
1480
|
+
position: relative;
|
|
1481
|
+
}
|
|
1482
|
+
.drawui-context-submenu {
|
|
1483
|
+
position: absolute;
|
|
1484
|
+
left: calc(100% + 4px);
|
|
1485
|
+
top: -6px;
|
|
1486
|
+
display: flex;
|
|
1487
|
+
flex-direction: column;
|
|
1488
|
+
min-width: 148px;
|
|
1489
|
+
padding: 6px;
|
|
1490
|
+
background: var(--dw-panel-bg);
|
|
1491
|
+
backdrop-filter: blur(16px);
|
|
1492
|
+
-webkit-backdrop-filter: blur(16px);
|
|
1493
|
+
border-radius: 12px;
|
|
1494
|
+
box-shadow: var(--dw-shadow-xl);
|
|
1495
|
+
border: 1px solid var(--dw-panel-border);
|
|
1496
|
+
z-index: 500;
|
|
1497
|
+
animation: drawui-context-menu-in 0.18s cubic-bezier(0.4, 0, 0.2, 1);
|
|
1498
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drawui-react",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "React wrapper for drawui-core canvas drawing (PNG / SVG / PDF export, table, UML, mind map)",
|
|
5
|
+
"description": "React wrapper for drawui-core canvas drawing (PNG / SVG / PDF export, table, UML, mind map, context menu, group lock)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"drawui-core": "0.4.
|
|
33
|
+
"drawui-core": "0.4.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": "^18.3.1"
|