drawui-react 0.5.0 → 0.5.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/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 Y(){let[t,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),t}var wn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],xn="drawui:highlighterColor";function Ct(){if(typeof window>"u")return DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(xn);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(xn,t);}catch{}}var Cn="drawui:stickyNoteColor";function St(){if(typeof window>"u")return STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(Cn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():STICKY_NOTE_DEFAULT_COLOR}catch{return STICKY_NOTE_DEFAULT_COLOR}}function Sn(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Cn,t);}catch{}}function To({icon:t,size:e=24,ink:o=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((i,y)=>{let c=i.fill??"ink",a=i.stroke??"ink";return jsx("path",{d:i.d,fill:c==="none"?"none":c==="ink"?o:c,...a==="none"?{}:{stroke:a==="ink"?o:a,strokeWidth:i.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},y)}),t.label&&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",In=12;function Ft(t,e){let o=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!o)return t;let i=parseInt(o[1],16);return `rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${e})`}function Lo(){if(typeof window>"u")return [];try{let t=JSON.parse(window.localStorage.getItem(Nn)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string").slice(0,In):[]}catch{return []}}function Eo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Nn,JSON.stringify(t));}catch{}}var En=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":Ft(t,.12)}),Rn=memo(function({onPick:e,onClose:o}){Y();let[i,y]=useState(""),[c,a]=useState(ICON_CATEGORIES[0].id),[d,v]=useState(Lo),C=useRef(null),s=useRef(null);useEffect(()=>{s.current?.focus();},[]),useEffect(()=>{let p=M=>{let F=C.current;F&&(F.contains(M.target)||M.target?.closest?.("[data-icon-toggle]")||o());},I=M=>{M.key==="Escape"&&(M.stopPropagation(),o());};return window.addEventListener("pointerdown",p),window.addEventListener("keydown",I),()=>{window.removeEventListener("pointerdown",p),window.removeEventListener("keydown",I);}},[o]);let h=useMemo(()=>d.map(p=>getIcon(p)).filter(p=>!!p),[d]),w=useMemo(()=>i.trim()?searchIcons(i):c==="recent"?h:iconsByCategory(c),[i,c,h]),E=c==="recent"?ICON_CATEGORY_INK.status:ICON_CATEGORY_INK[c]??ICON_DEFAULT_INK,O=i.trim()?t("icon.search"):c==="recent"?t("icon.recent"):t(ICON_CATEGORIES.find(p=>p.id===c)?.labelKey??"icon.search"),N=p=>{e(p),v(I=>{let M=[p.id,...I.filter(F=>F!==p.id)].slice(0,In);return Eo(M),M});};return jsxs("div",{className:"drawui-icon-panel",ref:C,style:{"--dw-icon-accent":E,"--dw-icon-soft":Ft(E,.08),"--dw-icon-ring":Ft(E,.22)},children:[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:s,value:i,onChange:p=>y(p.target.value),onKeyDown:p=>{p.key==="Enter"&&w.length>0&&N(w[0]);},placeholder:t("icon.search"),"aria-label":t("icon.search")}),jsx("span",{className:"drawui-icon-count",children:w.length})]}),!i.trim()&&jsxs("div",{className:"drawui-icon-cats",children:[h.length>0&&jsxs("button",{type:"button",className:`drawui-icon-cat${c==="recent"?" active":""}`,style:En(ICON_CATEGORY_INK.status),onClick:()=>a("recent"),children:[jsx("i",{className:"drawui-icon-dot"}),t("icon.recent")]}),ICON_CATEGORIES.map(p=>jsxs("button",{type:"button",className:`drawui-icon-cat${c===p.id?" active":""}`,style:En(ICON_CATEGORY_INK[p.id]??ICON_DEFAULT_INK),onClick:()=>a(p.id),children:[jsx("i",{className:"drawui-icon-dot"}),t(p.labelKey)]},p.id))]}),jsxs("div",{className:"drawui-icon-card",children:[jsxs("div",{className:"drawui-icon-card-head",children:[jsx("span",{className:"drawui-icon-card-title",children:O}),jsx("span",{className:"drawui-icon-card-count",children:w.length})]}),jsxs("div",{className:"drawui-icon-grid",children:[w.map(p=>jsx("button",{type:"button",className:"drawui-icon-item",title:`${p.zh} / ${p.en}`,"aria-label":`${p.zh} ${p.en}`,onClick:()=>N(p),children:jsx(To,{icon:p,size:30,ink:iconInk(p)})},p.id)),w.length===0&&jsx("div",{className:"drawui-icon-empty",children:t("icon.empty")})]})]})]})});var Ie=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Hn=(t,e)=>{let o=e*Math.PI/180;return {x:t.x*Math.cos(o)-t.y*Math.sin(o),y:t.x*Math.sin(o)+t.y*Math.cos(o)}},ft={x:Math.SQRT1_2,y:-Math.SQRT1_2},Vt={x:4.6,y:19.4},gt={x:19,y:5};function Yt(t,e,o){let i={x:-o.y,y:o.x},y=a=>({x:e.x-o.x*a,y:e.y-o.y*a}),c=(a,d)=>({x:a.x+i.x*d,y:a.y+i.y*d});switch(t){case "end":{let a=y(5.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,2.7))} ${Ie(c(a,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let a=y(8.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,3.5))} ${Ie(c(a,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let a=y(4.3),d=y(8.6);return jsx("polygon",{points:`${Ie(e)} ${Ie(c(a,2.7))} ${Ie(d)} ${Ie(c(a,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let a=Hn({x:-o.x,y:-o.y},30),d=Hn({x:-o.x,y:-o.y},-30);return jsx("path",{d:`M ${Ie({x:e.x+a.x*5.8,y:e.y+a.y*5.8})} L ${Ie(e)} L ${Ie({x:e.x+d.x*5.8,y:e.y+d.y*5.8})}`,fill:"none"})}default:return null}}function Be(t,e){let o=e||t==="dependency"||t==="realization",i=o?{x:gt.x-ft.x*8.6,y:gt.y-ft.y*8.6}:gt,y={x:-ft.x,y:-ft.y};return 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:Vt.x,y1:Vt.y,x2:i.x,y2:i.y,strokeDasharray:o?"3 2.6":void 0}),(t==="end"||t==="both")&&Yt("end",gt,ft),(t==="start"||t==="both")&&Yt("end",Vt,y),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?Yt(t,gt,ft):null]})}var Tt=t=>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})}),Io=[{type:"straight",labelKey:"style.connection.straight",icon:Tt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Tt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Tt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Tt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],An=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Be("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Be("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Be("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Be("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Be("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Be("both",true)}],Kn=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Be("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Be("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Be("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Be("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Be("realization",true)}],Pn=[...An,...Kn];function Ro(t,e){let o=Pn.find(i=>i.arrowHead===t&&i.dashed===e);return o?o.key:Pn.find(i=>i.arrowHead===t)?.key}var Et=memo(function({connectionType:e,arrowHead:o,dashed:i,onConnectionTypeChange:y,onArrowStyleChange:c,onOptionHover:a,onOptionLeave:d}){Y();let v=Ro(o,i),C=s=>jsx("div",{className:"drawui-connection-row",children:s.map(h=>jsxs("button",{className:`drawui-connection-btn${v===h.key?" active":""}`,onClick:()=>c(h),"data-drawui-tip":a?void 0:t(h.labelKey),onMouseEnter:a?w=>a(h.labelKey,w.currentTarget):void 0,onMouseLeave:a?d:void 0,"aria-label":t(h.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:h.icon}),jsx("span",{className:"drawui-connection-label",children:t(h.labelKey)})]},h.key))});return jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:Io.map(s=>jsxs("button",{className:`drawui-connection-btn${e===s.type?" active":""}`,onClick:()=>y(s.type),"data-drawui-tip":a?void 0:t(s.labelKey),onMouseEnter:a?h=>a(s.labelKey,h.currentTarget):void 0,onMouseLeave:a?d:void 0,"aria-label":t(s.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:s.icon}),jsx("span",{className:"drawui-connection-label",children:t(s.labelKey)})]},s.type))}),jsx("div",{className:"drawui-style-popover-title",children:t("style.arrow")}),C(An),jsx("div",{className:"drawui-style-popover-title",children:t("style.uml")}),C(Kn)]})});var On=[{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"})]})}],Ao=[{key:"basic",labelKey:"shapeGroup.basic",items:[{type:"rectangle"},{type:"rounded-rectangle"},{type:"stadium"},{type:"circle"},{type:"ellipse"},{type:"diamond"},{type:"triangle"},{type:"right-triangle"},{type:"hexagon"},{type:"parallelogram"},{type:"trapezoid"},{type:"pentagon"},{type:"octagon"},{type:"star"},{type:"envelope"},{type:"checkbox"}]},{key:"flowchart",labelKey:"shapeGroup.flowchart",items:[{type:"rectangle",labelKey:"flow.process"},{type:"rounded-rectangle",labelKey:"flow.step"},{type:"stadium",labelKey:"flow.startEnd"},{type:"diamond",labelKey:"flow.decision"},{type:"parallelogram",labelKey:"flow.data"},{type:"trapezoid",labelKey:"flow.manual"},{type:"hexagon",labelKey:"flow.preparation"},{type:"cylinder",labelKey:"flow.database"},{type:"delay",labelKey:"flow.delay"},{type:"predefined-process"},{type:"document"},{type:"block-arrow-right"},{type:"block-arrow-left"},{type:"block-arrow-up"},{type:"block-arrow-down"},{type:"block-arrow-double"}]},{key:"uml",labelKey:"shapeGroup.uml",items:[{type:"uml-class"},{type:"uml-interface"},{type:"rounded-rectangle",labelKey:"class.plain"},{type:"class-catalog"}]},{key:"solid",labelKey:"shapeGroup.solid",items:[{type:"cylinder"},{type:"cube"},{type:"cuboid"},{type:"triangular-pyramid"},{type:"quadrangular-pyramid"},{type:"sphere"},{type:"ellipsoid"},{type:"pie"},{type:"hollow-pie"}]},{key:"other",labelKey:"shapeGroup.other",items:[{type:"cloud"},{type:"heart"},{type:"cross"},{type:"sector"},{type:"chevron"},{type:"speech-rect"},{type:"speech-round"},{type:"brace-left"},{type:"brace-right"}]}],Ko=new Map(On.map(t=>[t.type,t.icon])),Oo=new Set(On.map(t=>t.type)),$o=jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}),Do=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Bo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",jt=8,zo=6,Xt="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",_o=[{type:"eraser",icon:"M7 21l-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21M22 21H7M5 11l9 9",labelKey:"toolbar.eraser"}],qt=memo(function({activeTool:e,onToolChange:o,showGrid:i,onToggleGrid:y,canUndo:c=false,canRedo:a=false,onUndo:d,onRedo:v,onExport:C,onExportData:s,onImportData:h,onHighlighterColorChange:w,onStickyNoteColorChange:E,onInsertIcon:O,onInsertTable:N,onInsertImage:p,arrowStyle:I,onArrowStyleChange:M}){let[F,l]=useState(false),[g,f]=useState(false),[b,H]=useState(null),[W,B]=useState(false),[Q,$]=useState(false),[X,pe]=useState(Ct),[ye,S]=useState(false),[ke,V]=useState(St),[Z,Ae]=useState(false),[ge,Ce]=useState(false),Le=useRef(null),Ke=r=>{let _=Array.from(r.target.files||[]);_.length&&p?.(_),r.target.value="";},[Se,Re]=useState(null),z=useRef(null),k=useRef(null),ie=useRef(null),se=useRef(null),j=useRef(null);Y();let Ee=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],D=()=>{z.current&&(clearTimeout(z.current),z.current=null),B(true);},Oe=()=>{z.current=window.setTimeout(()=>B(false),200);},be=useRef(null),Xe=()=>{B(false),T(),be.current?.click();},qe=r=>{let _=r.target.files?.[0];_&&h?.(_),r.target.value="";},rt=()=>{k.current&&(clearTimeout(k.current),k.current=null),l(true);},at=()=>{k.current=window.setTimeout(()=>{l(false),T();},200);},x=()=>{ie.current&&(clearTimeout(ie.current),ie.current=null),f(true);},U=()=>{ie.current=window.setTimeout(()=>{f(false),T();},200);},P=(r,_)=>{let A=r.closest(".drawui-toolbar");if(!A)return;let q=r.getBoundingClientRect(),$e=A.getBoundingClientRect(),ae=q.bottom+46>window.innerHeight;H({label:_,x:q.left-$e.left+q.width/2,y:ae?q.top-$e.top-8:q.bottom-$e.top+8,above:ae});},T=()=>H(null),ee=()=>{se.current&&(clearTimeout(se.current),se.current=null),$(true);},re=()=>{se.current=window.setTimeout(()=>$(false),200);},He=r=>{pe(r),vn(r),w?.(r),o("highlighter");},Je=()=>{j.current&&(clearTimeout(j.current),j.current=null),S(true);},_e=()=>{j.current=window.setTimeout(()=>S(false),200);},u=r=>{V(r),Sn(r),E?.(r),o("sticky-note"),S(false);};return jsx("div",{className:"drawui-toolbar-container",children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>o("select"),onMouseEnter:r=>P(r.currentTarget,"toolbar.select"),onMouseLeave:T,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:()=>o("hand"),onMouseEnter:r=>P(r.currentTarget,"toolbar.hand"),onMouseLeave:T,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:rt,onMouseLeave:at,children:[jsx("button",{className:`drawui-toolbar-button ${Oo.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),l(false),T();},"data-drawui-tip":F?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"})})}),F&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsx("div",{className:"drawui-shape-menu-scroll",children:Ao.map(r=>jsxs("div",{className:"drawui-shape-group",children:[jsx("div",{className:"drawui-shape-group-title",children:t(r.labelKey)}),jsx("div",{className:"drawui-shape-group-grid",children:r.items.map(_=>{let A=_.labelKey??`tool.${_.type}`;return jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===_.type?"active":""}`,onClick:()=>{o(_.type),l(false),T();},onMouseEnter:q=>P(q.currentTarget,A),onMouseLeave:T,"aria-label":t(A),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Ko.get(_.type)})},`${r.key}-${_.type}`)})})]},r.key))})})]}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Je,onMouseLeave:_e,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{o("sticky-note"),S(false),T();},"data-drawui-tip":ye?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:$o}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:ke}})]}),ye&&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(r=>jsx("button",{type:"button","aria-label":r,className:`drawui-sticky-swatch${ke.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>u(r)},r))})]})]}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${Z?"active":""}`,"data-icon-toggle":"","data-drawui-tip":Z?void 0:t("toolbar.icon"),onClick:()=>{Ae(r=>!r),T();},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"})]})}),Z&&jsx(Rn,{onPick:r=>O?.(r.id),onClose:()=>Ae(false)})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:x,onMouseLeave:U,children:[jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),f(false),T();},"data-drawui-tip":g?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"})})}),g&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:r=>{r.target.closest("button")||(f(false),T());},children:jsx(Et,{connectionType:I?.connectionType??"straight",arrowHead:I?.arrowHead??"end",dashed:!!I?.dashed,onConnectionTypeChange:r=>{M?.({connectionType:r}),o("arrow"),f(false),T();},onArrowStyleChange:r=>{M?.({arrowHead:r.arrowHead,dashed:r.dashed}),o("arrow"),f(false),T();},onOptionHover:(r,_)=>P(_,r),onOptionLeave:T})})]}),Do.filter(r=>r.type!=="arrow").map(r=>jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":t(r.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:r.icon})})},r.type)),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>o("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:Bo})})}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ee,onMouseLeave:re,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:r=>P(r.currentTarget,"toolbar.highlighter"),onMouseLeave:T,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:Xt,transform:"translate(7.4 5.4) scale(2.4)"}),jsx("path",{d:Xt,transform:"translate(18.4 3.4) scale(2.5)"}),jsx("path",{d:Xt,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:X}})]}),Q&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:wn.map(r=>jsx("button",{type:"button","aria-label":r,className:`drawui-highlighter-swatch${X.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>He(r)},r))})]}),jsx("div",{className:"drawui-toolbar-divider"}),_o.map(r=>jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":t(r.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:r.icon})})},r.type)),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>o("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"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:()=>Le.current?.click(),"data-drawui-tip":t("toolbar.image"),"data-image-toggle":true,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),jsx("path",{d:"M21 15.5l-4.5-4.5L6 21"})]})}),jsx("input",{ref:Le,type:"file",accept:"image/*",multiple:true,style:{display:"none"},onChange:Ke}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${ge?"active":""}`,onClick:()=>Ce(r=>!r),"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"})]})}),ge&&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:zo*jt},(r,_)=>{let A=Math.floor(_/jt),q=_%jt,$e=Se&&A<Se.rows&&q<Se.cols;return jsx("button",{type:"button","aria-label":`${A+1}x${q+1}`,className:"drawui-table-picker-cell",style:$e?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Re({rows:A+1,cols:q+1}),onClick:()=>{N?.(A+1,q+1),Ce(false),Re(null),T();}},_)})})]})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${i?"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:d,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:v,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:D,onMouseLeave:Oe,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:[Ee.map(r=>jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{C?.(r.format),B(false);},"data-drawui-tip":t(r.labelKey),children:t(r.labelKey)},r.format)),jsx("div",{className:"drawui-toolbar-export-divider"}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{s?.(),B(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:Xe,"data-drawui-tip":t("toolbar.import.data"),children:t("toolbar.import.data")})]})]}),jsx("input",{ref:be,type:"file",accept:".json,application/json",style:{display:"none"},onChange:qe}),b&&jsx("div",{className:`drawui-shape-tip ${b.above?"is-above":"is-below"}`,style:{left:b.x,top:b.y},children:t(b.label)})]})})});var Qt=memo(function({onZoomIn:e,onZoomOut:o,onReset:i,zoomLevel:y=100}){return Y(),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:o,"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:i,"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 Dn=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Bn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],Yo=Dn.filter(t=>t!=="#f1f5f9"),jo=[...Yo,...Bn],Xo=[...Dn,...Bn],zn=15,_n="drawui:customColors";function qo(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(_n);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-zn):[]}catch{return []}}function Jo(t){if(!(typeof window>"u"))try{window.localStorage.setItem(_n,JSON.stringify(t));}catch{}}var en=[{key:"fill",labelKey:"style.fill",hasTransparent:true,hasOpacity:true},{key:"stroke",labelKey:"style.stroke",hasTransparent:false,hasOpacity:true},{key:"text",labelKey:"style.text",hasTransparent:false},{key:"highlight",labelKey:"style.highlight",hasTransparent:true,hasOpacity:true}],$n=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),wt=10,st=12,nt=t=>!t||t==="transparent",Wn=memo(function({editor:e,selectedCount:o,hasLineSelection:i,currentConnectionType:y,currentArrowHead:c,currentDashed:a}){Y();let d=!!e?.getEditingShapeId(),[v,C]=useState(null),[s,h]=useState(null),[,w]=useState(0),E=useRef(null),O=useRef(null),N=useRef(null),[p,I]=useState({tw:168,th:42,pw:228,ph:160}),[M,F]=useState(qo),l=useRef(null),g=useCallback(u=>{let r=u.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(r)&&F(_=>{let A=_.filter(q=>q!==r);for(A.push(r);A.length>zn;)A.shift();return Jo(A),A});},[]);if(useEffect(()=>{let u=l.current;if(!u)return;let r=()=>{u.value&&g(u.value);};return u.addEventListener("change",r),()=>u.removeEventListener("change",r)},[g,s]),useEffect(()=>{if(!e)return;let u=e.subscribe(()=>w(r=>(r+1)%1e6));return ()=>{u();}},[e]),useEffect(()=>{h(null);},[o,d]),useEffect(()=>{if(!s)return;let u=r=>{E.current&&!E.current.contains(r.target)&&h(null);};return document.addEventListener("pointerdown",u,true),()=>document.removeEventListener("pointerdown",u,true)},[s]),useLayoutEffect(()=>{let u=O.current?.offsetWidth??p.tw,r=O.current?.offsetHeight??p.th,_=N.current?.offsetWidth??p.pw,A=N.current?.offsetHeight??p.ph;I(q=>q.tw===u&&q.th===r&&q.pw===_&&q.ph===A?q:{tw:u,th:r,pw:_,ph:A});}),!e||o===0||d)return null;let f=e.getSelectedIds(),H=e.getShapes().filter(u=>f.includes(u.id)),W=H[0],B=W?.id??"",Q=W?.style.fillColor,$=W?.style.strokeColor??"#1f2937",X=W?.textColor??"#1f2937",pe=W?.highlightColor,ye={fill:Q,stroke:$,text:X,highlight:pe},S=H.length>0&&H.every(u=>u.type==="sticky-note"),ke={fill:W?.style.fillOpacity??1,stroke:W?.style.strokeOpacity??1,highlight:W?.highlightOpacity??1},V=u=>v&&v.key===`${B}:${u}`?v.value:ke[u]??1,Z=(u,r)=>{switch(u){case "stroke":e.updateSelectedShapesStyle({strokeColor:r});break;case "fill":e.updateSelectedShapesStyle({fillColor:r});break;case "text":e.updateSelectedShapesText({textColor:r});break;case "highlight":e.updateSelectedShapesText({highlightColor:r});break}},Ae=(u,r)=>{C({key:`${B}:${u}`,value:r}),u==="highlight"?e.updateSelectedShapesText({highlightOpacity:r}):u==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:r}):e.updateSelectedShapesStyle({fillOpacity:r});},ge=u=>e.updateConnectionType(u),Ce=u=>e.updateArrowStyle({arrowHead:u.arrowHead,dashed:u.dashed}),Le=!!i&&H.length>0&&H.every(u=>u.type==="line"||u.type==="arrow"),Ke=H.length>0&&H.every(u=>u.type==="text"),Se=H.length>0&&H.every(u=>u.type==="sticky-note"||u.type==="icon"),Re=Le?en.filter(u=>u.key==="stroke"):Se?en.filter(u=>u.key!=="stroke"):en,z=u=>u.key==="stroke"&&Le?"style.line":u.labelKey,k=s&&s!=="more"?Re.find(u=>u.key===s):void 0,ie=!!s&&(s==="more"||s==="prefix"||!!k),se=S&&k?.key==="fill",j=e.getCamera(),Ee=getContentBounds(H,0),D=j.pageToScreen({x:Ee.x,y:Ee.y}),Oe=j.pageToScreen({x:Ee.x+Ee.width,y:Ee.y+Ee.height}),be=window.innerWidth,Xe=window.innerHeight,qe=Oe.y+wt,rt=D.y-wt,at=p.th+(ie?wt+p.ph:0),x=qe+at<=Xe-st,U=rt-at>=st,P=x||!U,T=(D.x+Oe.x)/2,ee=(u,r,_)=>Math.max(r,Math.min(u,Math.max(r,_))),re=ee(T-p.tw/2,st,be-p.tw-st),He=P?qe:rt-p.th,Je=ee(T-p.pw/2,st,be-p.pw-st),_e=ie?ee(P?He+p.th+wt:He-wt-p.ph,st,Xe-p.ph-st):0;return jsxs("div",{className:"drawui-style-floating",ref:E,children:[jsxs("div",{className:"drawui-style-toolbar",ref:O,style:{left:re,top:He},children:[Re.map(u=>jsxs("button",{className:`drawui-style-tool-btn${s===u.key?" active":""}`,onClick:()=>h(s===u.key?null:u.key),"data-drawui-tip":t(z(u)),type:"button",children:[u.key==="fill"&&jsx("span",{className:`drawui-st-swatch${nt(Q)?" drawui-st-none":""}`,style:nt(Q)?void 0:{background:Q}}),u.key==="stroke"&&(Le?jsx("span",{className:`drawui-st-line${nt($)?" drawui-st-line-none":""}`,style:nt($)?void 0:{background:$}}):jsx("span",{className:`drawui-st-frame${nt($)?" drawui-st-frame-none":""}`,style:nt($)?void 0:{borderColor:$}})),u.key==="text"&&jsx("span",{className:"drawui-st-text",style:{color:X},children:"A"}),u.key==="highlight"&&jsx("span",{className:`drawui-st-hl${nt(pe)?" drawui-st-none":""}`,style:nt(pe)?void 0:{background:pe},children:"A"})]},u.key)),i&&jsx("button",{className:`drawui-style-tool-btn${s==="more"?" active":""}`,onClick:()=>h(s==="more"?null:"more"),"data-drawui-tip":t("style.connection"),type:"button",children:"\u22EF"}),Ke&&jsx("button",{className:`drawui-style-tool-btn${s==="prefix"?" active":""}`,onClick:()=>h(s==="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"})]})})]}),ie&&jsx("div",{className:"drawui-style-popover",ref:N,style:{left:Je,top:_e},children:s==="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(z(k))}),jsxs("div",{className:"drawui-color-row",children:[k.hasTransparent&&!se&&jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${nt(ye[k.key])?" active":""}`,onClick:()=>Z(k.key,"transparent"),"aria-label":t("style.none"),type:"button"}),(se?STICKY_NOTE_COLORS:k.hasTransparent?jo:Xo).map(u=>jsx("button",{className:`drawui-color-swatch${$n(u,ye[k.key])?" active":""}`,style:{background:u},onClick:()=>Z(k.key,u),"aria-label":u,type:"button"},u)),M.map(u=>jsx("button",{className:`drawui-color-swatch drawui-color-custom${$n(u,ye[k.key])?" active":""}`,style:{background:u},onClick:()=>Z(k.key,u),"aria-label":u,type:"button"},`custom-${u}`)),jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":t("style.addColor"),children:["+",jsx("input",{ref:l,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(V(k.key)*100),onChange:u=>Ae(k.key,Number(u.target.value)/100),className:"drawui-opacity-slider"}),jsxs("span",{className:"drawui-opacity-value",children:[Math.round(V(k.key)*100),"%"]})]})]}):jsx(Fragment,{children:jsx(Et,{connectionType:y??"straight",arrowHead:c??"end",dashed:!!a,onConnectionTypeChange:ge,onArrowStyleChange:Ce})})})]})});var on=14,Gn=20,ar=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],ir=[12,14,16,18,20,24];function Fn(t,e){let o=t,i="",y=o.charAt(0);if(o.length>1&&(y==="+"||y==="-"||y==="#"||y==="~")&&o.charAt(1)===" "&&(i=y,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let s=o.indexOf(":");return s===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:o.slice(s+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let c=o.indexOf("(");if(c===-1){let s=o.lastIndexOf(":");return s===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,s).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(s+1).replace(/^\s+|\s+$/g,"")}}let a=o.slice(0,c).replace(/^\s+|\s+$/g,""),d=o.indexOf(")",c);if(d===-1)return {visibility:i,name:a,type:"",params:o.slice(c+1).replace(/^\s+|\s+$/g,""),returnType:""};let v=o.slice(c+1,d).replace(/^\s+|\s+$/g,""),C=o.slice(d+1).replace(/^\s+|\s+$/g,"");return C.startsWith(":")&&(C=C.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:i,name:a,type:"",params:v,returnType:C}}function sr(t,e){let o=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${o}${e.name}${e.type?`: ${e.type}`:""}`:`${o}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var Yn=memo(function({editor:e,umlClass:o,editing:i}){let[,y]=useState(0);Y(),useEffect(()=>{if(!e)return;let x=e.subscribe(()=>y(U=>U+1));return ()=>{x();}},[e]);let[c,a]=useState(null),[d,v]=useState(false),[C,s]=useState(null),h=useRef(null),w=useRef(null),E=useCallback((x,U)=>{h.current&&(clearTimeout(h.current),h.current=null),a({section:x,rowId:U}),v(false);},[]),O=useCallback(()=>{h.current&&clearTimeout(h.current),h.current=window.setTimeout(()=>{a(null),v(false);},150);},[]);if(!e||!o||i!==o.id)return null;let N=e.getCamera(),{id:p,x:I,y:M,width:F,height:l,className:g,methods:f}=o,b=o.type==="uml-interface",H=b?[]:o.attributes,W=F/2,B=l/2,Q=UML_HEADER_HEIGHT,$=UML_LINE_HEIGHT,X=UML_PADDING_X,pe=UML_PADDING_Y,ye=b?0:H.length>0?H.length*$+pe*2:pe*2,S=N.zoom,ke=(F-X*2)*S,V=4*S,Z=N.pageToScreen({x:I-W+X,y:M}),Ae=N.pageToScreen({x:I,y:M-B+Q/2}),ge=x=>N.pageToScreen({x:I,y:x}).y,Ce=$*S,Le=x=>M+(-B+Q+pe+$/2+x*$),Ke=x=>M+(-B+Q+ye+pe+$/2+x*$),Se=M+(-B+Q+ye),Re=M+B,z={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},k=(x,U)=>{if(!H.find(ee=>ee.id===x))return;let T=Fn(U,"attribute");e.updateUmlClass(p,{attributes:H.map(ee=>ee.id===x?{...ee,...T}:ee)});},ie=(x,U)=>{if(!f.find(re=>re.id===x))return;let T=Fn(U,"method"),ee=f.map(re=>re.id===x?{...re,...T}:re);b?e.updateUmlInterface(p,{methods:ee}):e.updateUmlClass(p,{methods:ee});},se=(x,U,P)=>{w.current={section:x,from:U},P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("text/plain",`${x}:${U}`);},j=x=>{x.preventDefault(),x.dataTransfer.dropEffect="move";},Ee=(x,U,P)=>{P.preventDefault();let T=w.current;!T||T.section!==x||(x==="attribute"?e.reorderUmlAttribute(p,T.from,U):e.reorderUmlMethod(p,T.from,U),w.current=null);},D=(x,U,P,T)=>{let ee=ge(T),re=c?.section===x&&c.rowId===P.id,He=(P.fontSize||UML_FONT_SIZE)*S,Je=P.textColor||"#1f2937",_e={position:"absolute",left:Z.x-on*S-V,top:ee-Ce/2,width:on*S+V+ke+Gn*S,height:Ce,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},u={...z,width:ke,height:Ce-2,fontSize:He,color:Je,textDecoration:P.strikethrough?"line-through":"none",pointerEvents:"auto",...re?{borderColor:"var(--dw-primary)"}:{}},r={width:on*S,height:Ce-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*S,lineHeight:1,opacity:re?1:.55,pointerEvents:"auto"},_={width:Gn*S,height:Ce-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*S,opacity:re?1:.35,pointerEvents:"auto"};return jsxs("div",{style:_e,onDragOver:j,onDrop:A=>Ee(x,U,A),children:[jsx("span",{style:r,draggable:true,onDragStart:A=>se(x,U,A),"data-drawui-tip":t("uml.drag"),children:"\u22EE\u22EE"}),jsx("input",{style:u,value:C&&C.rowId===P.id?C.text:sr(x,P),onChange:A=>{s({rowId:P.id,text:A.target.value}),x==="attribute"?k(P.id,A.target.value):ie(P.id,A.target.value);},onFocus:()=>E(x,P.id),onBlur:()=>{s(null),O();},spellCheck:false}),jsx("button",{style:_,onMouseDown:A=>A.preventDefault(),onClick:()=>{x==="attribute"?e.removeUmlAttribute(p,P.id):e.removeUmlMethod(p,P.id);},"data-drawui-tip":t("uml.delete"),children:"\xD7"})]},P.id)},Oe=(x,U,P)=>{let T=ge(U),ee=x==="attribute";return jsxs("button",{onMouseDown:re=>re.preventDefault(),onClick:()=>ee?e.addUmlAttribute(p):e.addUmlMethod(p),className:"drawui-uml-add-row",style:{position:"absolute",left:Z.x,top:T-9*S,height:18*S,padding:`0 ${6*S}px`,fontSize:11*S,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},"data-drawui-tip":P,children:[jsx("span",{style:{fontSize:13*S,lineHeight:1},children:"+"}),jsx("span",{children:P})]},`add-${x}`)},be=()=>{if(!c||c.section==="className")return null;let x=c.section,U=c.rowId,T=(x==="attribute"?H:f).find(ae=>ae.id===U);if(!T)return null;let ee=224*S,re=30*S,He=N.pageToScreen({x:I,y:M}).x,Je=N.pageToScreen({x:I,y:M-B}).y,_e=20*S,u=Je-re-_e,r=He-ee/2,_=u+re,A=T.textColor||"#1f2937",q=T.fontSize||UML_FONT_SIZE,$e=!!T.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:He-.5,top:_,width:1,height:_e,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:r,top:u,width:ee,height:re,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*S,padding:`0 ${6*S}px`,pointerEvents:"auto",zIndex:60,fontSize:12*S},onMouseDown:ae=>ae.preventDefault(),children:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>v(ae=>!ae),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:A,fontSize:13*S,textDecoration:$e?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*S,height:2*S,background:A,marginLeft:3,borderRadius:1}})]}),d&&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(p,x,T.id,{textColor:null}),v(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":t("uml.defaultColor")}),ar.map(ae=>jsx("button",{onClick:()=>{e.updateUmlRowStyle(p,x,T.id,{textColor:ae}),v(false);},style:{width:14,height:14,border:"none",background:ae,cursor:"pointer",borderRadius:2},"data-drawui-tip":ae},ae))]})]}),jsx("select",{value:q,onChange:ae=>e.updateUmlRowStyle(p,x,T.id,{fontSize:Number(ae.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*S}px`,fontSize:12*S,height:20*S,background:"#ffffff"},"data-drawui-tip":t("uml.fontSize"),children:ir.map(ae=>jsx("option",{value:ae,children:ae},ae))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(p,x,T.id,{strikethrough:!$e}),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.strikethrough"),style:{border:"none",background:$e?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*S,textDecoration:"line-through"},children:"A"})}),jsx("button",{onClick:()=>{x==="attribute"?e.removeUmlAttribute(p,T.id):e.removeUmlMethod(p,T.id),a(null);},className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.delete"),style:{border:"none",background:"transparent",cursor:"pointer",color:"#ef4444",padding:2,marginLeft:"auto",borderRadius:3},children:jsxs("svg",{width:14*S,height:14*S,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"})]})})]})]})},Xe=N.pageToScreen({x:I-W,y:M}).x,qe=N.pageToScreen({x:I,y:M-B}).y,rt=F*S,at=l*S;return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("div",{style:{position:"absolute",left:Xe+1,top:qe+1,width:Math.max(0,rt-2),height:Math.max(0,at-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsx("input",{style:{...z,position:"absolute",left:Ae.x-ke/2,top:Ae.y-Q*S/2+2,width:ke,height:Q*S-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||UML_FONT_SIZE)*S,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...c?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:g,onChange:x=>b?e.updateUmlInterface(p,{className:x.target.value}):e.updateUmlClass(p,{className:x.target.value}),onFocus:()=>E("className",""),onBlur:O,spellCheck:false}),!b&&jsxs(Fragment,{children:[H.map((x,U)=>D("attribute",U,x,Le(U))),Oe("attribute",Se,"\u5C5E\u6027")]}),f.map((x,U)=>D("method",U,x,Ke(U))),Oe("method",Re,t("uml.method")),be()]})});var Jn=memo(function({editor:e,panelOpen:o,onOpenPanel:i}){let[,y]=useState(0);Y(),useEffect(()=>{if(!e)return;let l=e.subscribe(()=>y(g=>g+1));return ()=>{l();}},[e]);let c=useRef(false),a=useRef(false),d=e?.getMindMapEditingShapeId()??null,v=e?.getMindMapSelectedNode()?.nodeId??"",C=d?`${d}\0${v}`:"";if(useEffect(()=>{c.current=false;},[C]),!e)return null;let s=e.getMindMapEditingShapeId();if(!s||o)return null;let h=e.getMindMapSelectedNode();if(!h||h.shapeId!==s)return null;let w=e.getMindMapNode(s,h.nodeId),E=e.getMindMapNodeScreenRect(s,h.nodeId);if(!w||!E)return null;let O=e.getCamera().getZoom(),N=MINDMAP_FONT_SIZE*O,p=Math.max(100,E.width+24),I=E.height+8,M={position:"absolute",left:E.x+E.width/2,top:E.y-4,transform:"translateX(-50%)",width:p,height:I,border:"1.5px solid var(--dw-primary, #3b82f6)",borderRadius:6,background:"#ffffff",boxShadow:"0 2px 10px rgba(0,0,0,0.15)",outline:"none",padding:`0 ${(w.icon?24:12)*O}px`,fontFamily:"sans-serif",fontSize:N,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},F={position:"absolute",left:E.x+E.width+12,top:E.y+E.height/2-11,width:22,height:22,border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:"50%",cursor:"pointer",color:"#6b7280",fontSize:13,lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",pointerEvents:"auto",zIndex:55};return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("input",{autoFocus:true,style:M,value:w.text,spellCheck:false,onChange:l=>{let g=!c.current;c.current=true,e.updateMindMapNode(s,h.nodeId,{text:l.target.value},g);},onBlur:()=>{if(a.current){a.current=false;return}e.exitMindMapEdit();},onKeyDown:l=>{l.key==="Enter"?l.target.blur():l.key==="Escape"&&e.exitMindMapEdit();}}),jsx("button",{style:F,"data-drawui-tip":t("mindmap.more"),onMouseDown:l=>{l.preventDefault(),a.current=true,setTimeout(()=>{a.current=false;},300);},onClick:i,children:"\u22EF"})]})});var to=memo(function({editor:e,panelOpen:o}){let[,i]=useState(0);Y(),useEffect(()=>{if(!e)return;let I=e.subscribe(()=>i(M=>M+1));return ()=>{I();}},[e]);let y=useRef(false),c=e?.getTableEditing()??null,a=c?`${c.shapeId}\0${c.row}\0${c.col}`:"";if(useEffect(()=>{y.current=false;},[a]),!e||o)return null;let d=e.getTableEditing();if(!d)return null;let{shapeId:v,row:C,col:s}=d,h=e.getTableCell(v,C,s),w=e.getTableScreenRect(v,C,s);if(!h||!w)return null;let E=e.getSelectedTable(),O=h.fontSize||E?.fontSize||TABLE_FONT_SIZE,N=e.getCamera().getZoom(),p={left:w.x-1,top:w.y-1,width:w.width+2,height:w.height+2,padding:`${TABLE_CELL_PADDING_Y*N}px ${TABLE_CELL_PADDING_X*N}px`,fontFamily:"sans-serif",fontSize:O*N,lineHeight:TABLE_LINE_HEIGHT_RATIO,fontWeight:h.bold?700:400,color:h.textColor||E?.textColor||"#1f2937",textAlign:h.align==="center"?"center":h.align==="right"?"right":"left"};return jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:jsx("textarea",{autoFocus:true,rows:1,className:"drawui-table-cell-input",style:p,value:h.text,spellCheck:false,onChange:I=>{let M=!y.current;y.current=true,e.updateTableCell(v,C,s,{text:I.target.value},M);},onBlur:()=>{e.exitTableEdit();},onKeyDown:I=>{(I.key==="Enter"||I.key==="Escape")&&(I.preventDefault(),I.target.blur());}})})});var ro=memo(function({editor:e}){let[,o]=useState(0),[i,y]=useState(null),c=useRef(null);if(Y(),useEffect(()=>{if(!e)return;let $=e.subscribe(()=>o(X=>X+1));return ()=>{$();}},[e]),useEffect(()=>{if(!i)return;let $=pe=>{let ye=pe.target;ye&&c.current?.contains(ye)||y(null);},X=pe=>{pe.key==="Escape"&&y(null);};return window.addEventListener("pointerdown",$,true),window.addEventListener("keydown",X),()=>{window.removeEventListener("pointerdown",$,true),window.removeEventListener("keydown",X);}},[i]),!e)return null;let a=e.getSelectedTable();if(!a)return null;let d=e.getTableSelection();if(!d||d.shapeId!==a.id)return null;let v=e.getTableScreenRect(a.id);if(!v)return null;let C=a.cells.length,s=a.cells[0]?.length??0,h=tableExpandRangeToMerges(a,d.anchor.row,d.anchor.col,d.focus.row,d.focus.col),{r1:w,c1:E,r2:O,c2:N}=h,p=tableCoveredMap(a.cells),I=0;for(let $=w;$<=O;$++)for(let X=E;X<=N;X++)p[$]?.[X]||I++;let M=I>1,F=tableRangeHasMerge(a,w,E,O,N),l=w===O?`${w+1}`:`${w+1}\u2013${O+1}`,g=E===N?`${E+1}`:`${E+1}\u2013${N+1}`,f=C-(O-w+1)>=1,b=s-(N-E+1)>=1,W=v.y>56?v.y-40:v.y+v.height+10,B=$=>$.stopPropagation(),Q=$=>()=>{$(),y(null);};return jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:v.x+v.width/2,top:W},onPointerDown:B,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 ${i==="row"?"active":""}`,"data-table-insert-row":true,title:`${t("table.insertRowAbove")} / ${t("table.insertRowBelow")}`,onClick:()=>y(i==="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"})})}),i==="row"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-row-menu":true,children:[jsx("button",{onClick:Q(()=>e.insertTableRowRelative(a.id,"above")),children:t("table.insertRowAbove")}),jsx("button",{onClick:Q(()=>e.insertTableRowRelative(a.id,"below")),children:t("table.insertRowBelow")})]})]}),jsx("button",{title:`${t("table.deleteRow")} \xB7 ${l}`,disabled:!f,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 ${i==="col"?"active":""}`,"data-table-insert-col":true,title:`${t("table.insertColLeft")} / ${t("table.insertColRight")}`,onClick:()=>y(i==="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"})})}),i==="col"&&jsxs("div",{className:"drawui-table-menu",ref:c,"data-table-col-menu":true,children:[jsx("button",{onClick:Q(()=>e.insertTableColumnRelative(a.id,"left")),children:t("table.insertColLeft")}),jsx("button",{onClick:Q(()=>e.insertTableColumnRelative(a.id,"right")),children:t("table.insertColRight")})]})]}),jsx("button",{title:`${t("table.deleteCol")} \xB7 ${g}`,disabled:!b,onClick:()=>e.deleteTableColsInSelection(a.id),children:t("table.deleteCol")}),jsx("button",{title:t("table.merge"),disabled:!M,onClick:()=>e.mergeTableCells(a.id),children:t("table.merge")}),jsx("button",{title:t("table.split"),disabled:!F,onClick:()=>e.splitTableCells(a.id),children:t("table.split")})]})});var ao=[...MINDMAP_COLORS,"#1f2937","#9ca3af"],io=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Rr={position:"absolute",width:232,background:"rgba(255,255,255,0.96)",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 6px 20px rgba(0,0,0,0.12)",padding:"10px 12px",fontSize:12,color:"#1f2937",zIndex:70,boxSizing:"border-box",fontFamily:"sans-serif"},rn={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Pt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},sn={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 6px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5,whiteSpace:"nowrap"},so={...sn,minWidth:0,overflow:"hidden",textOverflow:"ellipsis"},an={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},lo=memo(function({editor:e,mindMap:o}){let[,i]=useState(0);Y(),useEffect(()=>{if(!e)return;let l=e.subscribe(()=>i(g=>g+1));return ()=>{l();}},[e]);let y=useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let c=e.getMindMapSelectedNode();if(!c||c.shapeId!==o.id)return null;let a=l=>{if(l.id===c.nodeId)return l;for(let g of l.children??[]){let f=a(g);if(f)return f}return null},d=a(o.root);if(!d)return null;let v=e.getCamera(),s=layoutMindMap(o.root).positions.get(d.id);if(!s)return null;let h=v.zoom,w=v.pageToScreen({x:o.x+s.x,y:o.y+s.y}),E=w.x+s.width*h/2+14,O=w.y-80,p=Math.max(8,Math.min(E,(window.innerWidth||1024)-232-8)),I=Math.max(8,Math.min(O,(window.innerHeight||768)-320)),M=l=>{e.updateMindMapNode(o.id,d.id,l);},F=!!d.id&&d.id!==o.root.id;return jsxs("div",{ref:y,style:{...Rr,left:p,top:I},onMouseDown:l=>l.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")}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[!!d.children?.length&&jsx("button",{style:{...sn,padding:"1px 5px",color:"#6b7280"},"data-drawui-tip":d.collapsed?t("mindmap.expand"):t("mindmap.collapse"),onClick:()=>e.toggleMindMapCollapse(o.id,d.id),children:d.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),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:{...an,marginBottom:8},value:d.text,onChange:l=>M({text:l.target.value}),spellCheck:false}),jsxs("div",{style:{...Pt,gap:4,marginBottom:10,flexWrap:"nowrap"},children:[jsxs("button",{style:so,onClick:()=>e.addMindMapChild(o.id,d.id),children:["+ ",t("mindmap.addChild")]}),F&&jsxs("button",{style:so,onClick:()=>e.addMindMapSibling(o.id,d.id),children:["+ ",t("mindmap.addSibling")]}),jsx("button",{style:{...sn,color:"#ef4444",borderColor:"#fecaca",marginLeft:"auto",flexShrink:0},onClick:()=>e.deleteMindMapNode(o.id,d.id),children:t("mindmap.deleteNode")})]}),jsx("span",{style:rn,children:t("mindmap.color")}),jsxs("div",{style:{...Pt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":t("mindmap.levelColor"),onClick:()=>M({color:void 0}),style:{width:18,height:18,borderRadius:4,border:"1.5px solid #d1d5db",background:"conic-gradient(#ef4444, #f59e0b, #10b981, #3b82f6, #8b5cf6, #ec4899, #ef4444)",cursor:"pointer",flexShrink:0}}),ao.map(l=>jsx("button",{"data-drawui-tip":l,onClick:()=>M({color:l}),style:{width:18,height:18,borderRadius:4,border:d.color===l?"2px solid #111827":"1px solid #d1d5db",background:l,cursor:"pointer",flexShrink:0}},l))]}),jsx("span",{style:rn,children:t("mindmap.icon")}),jsxs("div",{style:{...Pt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":t("mindmap.noIcon"),onClick:()=>M({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:d.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),io.map(l=>jsx("button",{onClick:()=>M({icon:l}),style:{width:22,height:22,borderRadius:4,border:d.icon===l?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:l},l)),jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:d.icon&&!io.includes(d.icon)?d.icon:"",onKeyDown:l=>{if(l.key==="Enter"){let g=l.target.value.trim();M({icon:g||void 0});}},onBlur:l=>{let g=l.target.value.trim();g!==d.icon&&M({icon:g||void 0});},style:{...an,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsx("span",{style:rn,children:t("mindmap.note")}),jsx("input",{style:{...an,marginBottom:6},value:d.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:l=>M({note:l.target.value||void 0}),spellCheck:false}),!!d.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:()=>M({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:d.noteColor?"1px solid #d1d5db":"2px solid #111827",background:"repeating-conic-gradient(#ef4444 0% 25%, #f59e0b 0% 50%, #10b981 0% 75%, #3b82f6 0% 100%)",cursor:"pointer"}}),ao.map(l=>jsx("button",{onClick:()=>M({noteColor:l}),style:{width:16,height:16,borderRadius:3,border:d.noteColor===l?"2px solid #111827":"1px solid #d1d5db",background:l,cursor:"pointer"}},l))]})]})});var cn=220,dn=140,Or="#fafafa";function $r(t,e){let o=Math.min(t.x,e.x),i=Math.min(t.y,e.y),y=Math.max(t.x+t.width,e.x+e.width),c=Math.max(t.y+t.height,e.y+e.height);return {x:o,y:i,width:y-o,height:c-i}}function Dr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Br(){return {x:0,y:0,width:0,height:0}}function zr(t){let e=1/0,o=1/0,i=-1/0,y=-1/0,c=false;for(let a of t){let d=pn(a);d&&(c=true,d.x<e&&(e=d.x),d.y<o&&(o=d.y),d.x+d.width>i&&(i=d.x+d.width),d.y+d.height>y&&(y=d.y+d.height));}return c?{x:e,y:o,width:i-e,height:y-o}:null}function pn(t){switch(t.type){case "rectangle":case "sticky-note":case "icon":case "image":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "table":case "text":return {x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height};case "circle":return {x:t.x-t.radius,y:t.y-t.radius,width:t.radius*2,height:t.radius*2};case "line":case "arrow":{let e=t.points;if(!e||e.length===0)return null;let o=1/0,i=1/0,y=-1/0,c=-1/0;for(let a of e)a.x<o&&(o=a.x),a.y<i&&(i=a.y),a.x>y&&(y=a.x),a.y>c&&(c=a.y);return {x:o,y:i,width:y-o,height:c-i}}case "draw":{let e=t,o=e.width,i=e.height;if(typeof o=="number"&&typeof i=="number")return {x:e.x-o/2,y:e.y-i/2,width:o,height:i};let y=e.points;if(!y||y.length===0)return null;let c=1/0,a=1/0,d=-1/0,v=-1/0;for(let C of y){let s=C.x+e.x,h=C.y+e.y;s<c&&(c=s),h<a&&(a=h),s>d&&(d=s),h>v&&(v=h);}return {x:c,y:a,width:d-c,height:v-a}}default:return null}}function _r(t){let e=t.getCamera(),o=e.screenToPage({x:0,y:0}),i=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:i.x-o.x,height:i.y-o.y}}function Wr(t,e,o){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-o/2,width:e,height:o};let i=e/o,y=t.width,c=y/i;c<t.height&&(c=t.height,y=c*i);let a=Dr(t);return {x:a.x-y/2,y:a.y-c/2,width:y,height:c}}function un(t,e,o,i){let y=(t-o.left)/o.width,c=(e-o.top)/o.height;return {x:i.x+y*i.width,y:i.y+c*i.height}}var po=memo(function({editor:e}){let o=useRef(null),i=useRef(null),[y,c]=useState(false),[a,d]=useState(100),[v,C]=useState(false),[s,h]=useState(false);Y();let w=useRef(null),E=useRef(null);useLayoutEffect(()=>{let l=o.current,g=i.current;if(!l||!g)return;let f=window.devicePixelRatio||1;l.width=Math.round(cn*f),l.height=Math.round(dn*f),l.style.width=`${cn}px`,l.style.height=`${dn}px`;},[y]);let O=useCallback(()=>{let l=o.current,g=i.current;if(!l||!g||!e)return;let f=l.getContext("2d");if(!f)return;let b=cn,H=dn,W=l.width,B=l.height,Q=e.getShapes(),$=new Set(e.getSelectedIds()),X=getTheme(),pe=hexToRgba(X.text,.16),ye=X.primary,S=hexToRgba(X.primary,.18),ke=hexToRgba(X.primary,.85),V=zr(Q),Z=_r(e),Ae=V?$r(V,Z):Z.width>0?Z:Br(),ge=Wr(Ae,b,H);E.current=ge;let Ce=W/ge.width,Le=B/ge.height,Ke=b/ge.width;f.setTransform(1,0,0,1,0,0),f.fillStyle=Or,f.fillRect(0,0,W,B),f.setTransform(Ce,0,0,Le,-Ce*ge.x,-Le*ge.y),f.fillStyle=pe;for(let z of Q){let k=pn(z);k&&f.fillRect(k.x,k.y,k.width,k.height);}f.fillStyle=ye;for(let z of Q){if(!$.has(z.id))continue;let k=pn(z);k&&f.fillRect(k.x,k.y,k.width,k.height);}f.fillStyle=S,f.fillRect(Z.x,Z.y,Z.width,Z.height);let Se=1.5/Ke;f.strokeStyle=ke,f.lineWidth=Se,f.lineJoin="round";let Re=Math.min(Z.width/6,Z.height/6,6/Ke);if(f.beginPath(),Re*Ke<1)f.rect(Z.x,Z.y,Z.width,Z.height);else {let z=Z.x,k=Z.y,ie=Z.width,se=Z.height,j=Math.min(Re,ie/2,se/2);f.moveTo(z+j,k),f.lineTo(z+ie-j,k),f.quadraticCurveTo(z+ie,k,z+ie,k+j),f.lineTo(z+ie,k+se-j),f.quadraticCurveTo(z+ie,k+se,z+ie-j,k+se),f.lineTo(z+j,k+se),f.quadraticCurveTo(z,k+se,z,k+se-j),f.lineTo(z,k+j),f.quadraticCurveTo(z,k,z+j,k),f.closePath();}f.stroke(),f.setTransform(1,0,0,1,0,0);},[e]);useEffect(()=>{if(!e||y)return;O();let l=e.subscribe(O),g=subscribeTheme(O),f=()=>O();return window.addEventListener("resize",f),()=>{l(),g(),window.removeEventListener("resize",f);}},[e,y,O]),useEffect(()=>{if(!e)return;let l=()=>{let f=e.getCamera().getZoom();d(Math.round(f*100));};l();let g=e.subscribe(l);return ()=>{g();}},[e]);let N=useCallback((l,g)=>{if(!e)return;let f=e.getCamera(),b=f.getZoom(),H=window.innerWidth/2,W=window.innerHeight/2,B=f;B.x=H-l*b,B.y=W-g*b,e.requestRender();},[e]),p=l=>{if(!e||!i.current||l.button!==0)return;let g=i.current.getBoundingClientRect(),f=E.current;if(!f)return;let b=un(l.clientX,l.clientY,g,f);w.current={pointerId:l.pointerId,rect:{left:g.left,top:g.top,width:g.width,height:g.height},canvasBox:f},l.currentTarget.setPointerCapture(l.pointerId),h(true),N(b.x,b.y);},I=l=>{if(!s||!e||!w.current||!i.current)return;let g=w.current,f=un(l.clientX,l.clientY,g.rect,g.canvasBox);N(f.x,f.y);},M=l=>{if(s){h(false),w.current=null;try{l.currentTarget.releasePointerCapture(l.pointerId);}catch{}}},F=l=>{if(!e||!i.current)return;let g=E.current;if(!g)return;let f=i.current.getBoundingClientRect(),b=un(l.clientX,l.clientY,f,g);N(b.x,b.y);};return jsxs("div",{className:`drawui-minimap ${y?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>c(l=>!l),"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:[a,"%"]})]}),jsx("div",{ref:i,className:"drawui-minimap-canvas-wrap",style:{cursor:s?"grabbing":v?"pointer":"default"},onPointerEnter:()=>C(true),onPointerLeave:()=>C(false),children:jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:p,onPointerMove:I,onPointerUp:M,onPointerCancel:M,onDoubleClick:F})})]})]})});var ve=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}),Gr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:ve(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:ve(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:ve(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:ve(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:ve(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:ve(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:ve(jsx("path",{d:"M12 3 L19.5 7.5 V16.5 L12 21 L4.5 16.5 V7.5 Z"}))},{type:"parallelogram",labelKey:"shape.parallelogram",glyph:ve(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:ve(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:ve(jsx("path",{d:"M12 4 L19.5 9.5 L16.5 18.5 H7.5 L4.5 9.5 Z"}))},{type:"octagon",labelKey:"shape.octagon",glyph:ve(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:ve(jsx("path",{d:"M12 3 L14 9.5 L20.5 10 L15.5 14 L17.5 20.5 L12 16.8 L6.5 20.5 L8.5 14 L3.5 10 L10 9.5 Z"}))},{type:"sticky-note",labelKey:"shape.sticky-note",glyph:ve(jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:ve(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:ve(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:ve(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 yo({editor:t$1,x:e,y:o,context:i,existingArrowId:y,defaultShapeType:c,onClose:a}){let d=useRef(null);Y();let v=C=>{t$1?.createGeneratedConnection(i,{type:C,existingArrowId:y}),a();};return useEffect(()=>{let C=w=>{d.current&&!d.current.contains(w.target)&&a();},s=w=>{w.key==="Escape"&&(w.preventDefault(),a());},h=setTimeout(()=>{window.addEventListener("pointerdown",C,true),window.addEventListener("keydown",s,true);},0);return ()=>{clearTimeout(h),window.removeEventListener("pointerdown",C,true),window.removeEventListener("keydown",s,true);}},[a]),jsxs("div",{className:"drawui-gen-menu",ref:d,style:{left:e,top:o},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:Gr.map(C=>jsxs("button",{className:`drawui-gen-shape-btn${C.type===c?" drawui-gen-shape-active":""}`,onClick:()=>v(C.type),"data-drawui-tip":t(C.labelKey),children:[C.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(C.labelKey)})]},C.type))}),jsx("div",{className:"drawui-gen-menu-hint",children:t("menu.cancel")})]})}var Yr=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function Pe(t){if(Yr)switch(t){case "copy":return "\u2318C";case "copyAsImage":return "\u21E7\u2318C";case "paste":return "\u2318V";case "duplicate":return "\u2318D";case "copyStyle":return "\u2325\u2318C";case "pasteStyle":return "\u2325\u2318V";case "lock":return "\u2325\u2318L";case "delete":return "\u232B";case "group":return "\u2318G";case "ungroup":return "\u21E7\u2318G"}switch(t){case "copy":return "Ctrl + C";case "copyAsImage":return "Ctrl + Shift + C";case "paste":return "Ctrl + V";case "duplicate":return "Ctrl + D";case "copyStyle":return "Ctrl + Alt + C";case "pasteStyle":return "Ctrl + Alt + V";case "lock":return "Ctrl + Alt + L";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var fo={sep:true},jr=t=>"sep"in t&&t.sep===true;function mo({editor:t$1,pos:e,onClose:o}){Y();let[,i]=useState(0),y=useRef(null),[c,a]=useState(null),[d,v]=useState(null);useEffect(()=>{let b=t$1.subscribe(()=>i(H=>H+1));return ()=>{b();}},[t$1]),useLayoutEffect(()=>{let b=y.current;if(!b)return;let H=b.getBoundingClientRect(),W=Math.max(8,Math.min(e.x,window.innerWidth-H.width-8)),B=Math.max(8,Math.min(e.y,window.innerHeight-H.height-8));a({left:W,top:B});},[e.x,e.y]),useEffect(()=>{let b=B=>{y.current&&!y.current.contains(B.target)&&o();},H=B=>{B.key==="Escape"&&(B.preventDefault(),o());},W=setTimeout(()=>{window.addEventListener("pointerdown",b,true),window.addEventListener("keydown",H,true);},0);return ()=>{clearTimeout(W),window.removeEventListener("pointerdown",b,true),window.removeEventListener("keydown",H,true);}},[o]);let C=t$1.getSelectedIds(),s=C.length>0,h=e.shapeId,w=h?t$1.isShapeLocked(h):false,E=s&&!w&&t$1.hasCopiedStyle(),O=t$1.hasClipboard(),N=s&&!w,p=s&&!w?t$1.getSelectedGroupId():null,I=s&&!w&&C.length>=2&&!p,F=(h?t$1.getShapes().find(b=>b.id===h):void 0)?.groupId??null,l=p?true:!!F&&!w,g=b=>()=>{b(),o();},f;return w?f=F?[{key:"ctx.ungroup",shortcut:Pe("ungroup"),action:g(()=>F&&t$1.ungroupIds([F]))}]:[{key:"ctx.unlock",action:()=>h&&t$1.setShapeLocked(h,false)}]:s?f=[{key:"ctx.copy",shortcut:Pe("copy"),action:g(()=>t$1.copySelected())},{key:"ctx.copyAsImage",shortcut:Pe("copyAsImage"),action:g(()=>{t$1.copySelectedAsImage();})},{key:"ctx.paste",shortcut:Pe("paste"),disabled:!O,action:g(()=>t$1.paste())},{key:"ctx.duplicate",shortcut:Pe("duplicate"),action:g(()=>t$1.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!N,action:()=>t$1.bringToFront()},{key:"ctx.bringForward",disabled:!N,action:()=>t$1.bringForward()},{key:"ctx.sendBackward",disabled:!N,action:()=>t$1.sendBackward()},{key:"ctx.sendToBack",disabled:!N,action:()=>t$1.sendToBack()}]},{key:"ctx.copyStyle",shortcut:Pe("copyStyle"),action:g(()=>t$1.copyStyle())},{key:"ctx.pasteStyle",shortcut:Pe("pasteStyle"),disabled:!E,action:g(()=>t$1.pasteStyle())},fo,{key:"ctx.rotate",submenu:[{key:"ctx.rotate90",action:()=>t$1.rotateSelected(90)},{key:"ctx.rotate180",action:()=>t$1.rotateSelected(180)},{key:"ctx.rotate270",action:()=>t$1.rotateSelected(270)}]},p?{key:"ctx.ungroup",shortcut:Pe("ungroup"),disabled:!l,action:g(()=>t$1.ungroupSelected())}:{key:"ctx.group",shortcut:Pe("group"),disabled:!I,action:g(()=>t$1.groupSelected())},fo,{key:"ctx.lock",shortcut:Pe("lock"),action:g(()=>t$1.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:Pe("delete"),action:g(()=>t$1.deleteSelected())}]:f=[{key:"ctx.paste",shortcut:Pe("paste"),disabled:!O,action:g(()=>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:b=>b.preventDefault(),children:f.map((b,H)=>jr(b)?jsx("div",{className:"drawui-context-sep"},`sep-${H}`):b.submenu?jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>v(b.key),onMouseLeave:()=>v(null),children:[jsxs("button",{type:"button",className:"drawui-context-item",disabled:b.disabled,children:[jsx("span",{children:t(b.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"})})]}),d===b.key&&jsx("div",{className:"drawui-context-submenu",children:b.submenu.map(W=>jsx("button",{type:"button",className:"drawui-context-item",disabled:W.disabled,onClick:()=>{W.action(),o();},children:jsx("span",{children:t(W.key)})},W.key))})]},b.key):jsxs("button",{type:"button",className:"drawui-context-item",disabled:b.disabled,onClick:b.action,children:[jsx("span",{children:t(b.key)}),b.shortcut&&jsx("span",{className:"drawui-context-kbd",children:b.shortcut})]},b.key))})}var Qr={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","sticky-note":"tool.sticky-note",icon:"toolbar.icon","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map",table:"tool.table",image:"tool.image"};function gn(t$1){let e=t$1 instanceof Error?t$1.message:String(t$1);return e.startsWith("image.tooLarge")?t("image.tooLarge"):`${t("image.uploadFailed")}\uFF1A${e}`}function ea({initialTool:t$1="select",className:e="",themeColor:o,language:i="zh-CN",data:y,onChange:c,onReady:a,imageUpload:d}){let v=useRef(null),C=useRef(null),s=useRef(null),[h,w]=useState(null);Y();let[E,O]=useState(t$1),[N,p]=useState(false),[I,M]=useState(0),[F,l]=useState(false),[g,f]=useState("straight"),[b,H]=useState("end"),[W,B]=useState(false),[Q,$]=useState(void 0),[X,pe]=useState(100),[ye,S]=useState(null),[ke,V]=useState(null),[Z,Ae]=useState(false),[ge,Ce]=useState(false),[Le,Ke]=useState(null),[Se,Re]=useState(null),[z,k]=useState(false),[ie,se]=useState(null),[j,Ee]=useState(null),D=useRef(null),Oe=useRef(0),be=useRef(null),Xe=useRef(c);Xe.current=c;let qe=useRef(a);qe.current=a,useEffect(()=>{if(!v.current)return;let m=new Editor(v.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:hexToRgba(o,.1),shadow:o}}:void 0,language:i,shapes:y,persist:!y,imageUpload:d});s.current=m,w(m),window.__drawuiEditor=m,m.setHighlighterColor(Ct()),m.setStickyNoteColor(St()),qe.current?.(m),t$1&&m.setActiveTool(t$1);let R=m.subscribe(()=>{O(m.getActiveTool());let G=m.getSelectedIds();M(G.length);let Me=m.getShapes().filter(Ue=>G.includes(Ue.id)&&(Ue.type==="line"||Ue.type==="arrow"));if(l(Me.length>0),Me.length>0&&Me[0].connectionType?f(Me[0].connectionType):Me.length>0&&f("straight"),Me.length>0){let Ue=Me.find(zt=>zt.type==="arrow");Ue&&(H(Ue.arrowHead??"end"),B(Ue.dashed??false));}pe(Math.round(m.getCamera().getZoom()*100)),$(m.getArrowStyle()),Ae(m.canUndo()),Ce(m.canRedo());let We=m.getSelectedUml();Ke(We),We||se(null);let Qe=m.getSelectedMindMap();Re(Qe),m.getMindMapEditingShapeId()||k(false),Xe.current?.(m.getData());}),le=m.subscribeNotifications(G=>{V({type:"success",text:G}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);}),Ne=m.subscribeUi(G=>{if(G.kind==="imageError"){V({type:"error",text:gn(G.message)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);return}G.kind==="shapeTypeMenu"&&Ee({x:G.screenX,y:G.screenY,context:G.context,existingArrowId:G.existingArrowId,defaultShapeType:G.defaultShapeType});});return ()=>{R(),le(),Ne(),D.current&&clearTimeout(D.current),cancelAnimationFrame(Oe.current),m.dispose();}},[t$1]),useEffect(()=>{if(!o)return;let m=C.current;m&&(m.style.setProperty("--dw-primary",o),m.style.setProperty("--dw-primary-hover",shadeColor(o,-0.12)),m.style.setProperty("--dw-primary-weak",hexToRgba(o,.1)),m.style.setProperty("--dw-primary-contrast","#ffffff"),m.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(o,.3)}`)),s.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:hexToRgba(o,.1),shadow:o}});},[o]),useEffect(()=>{setLanguage(i),s.current?.setLanguage(i);},[i]);let rt=useCallback(m=>{s.current?.setActiveTool(m);},[]),at=useCallback(()=>{s.current?.zoomIn();},[]),x=useCallback(()=>{s.current?.zoomOut();},[]),U=useCallback(()=>{s.current?.resetZoom();},[]),P=useCallback(()=>{let m=!N;p(m),s.current?.setShowGrid(m);},[N]),T=useCallback(()=>{s.current?.undo();},[]),ee=useCallback(()=>{s.current?.redo();},[]),re=useCallback(m=>{s.current?.downloadImage("drawui",m,{background:"#ffffff"});},[]),He=useCallback(()=>{s.current?.downloadJSON("drawui-data");},[]),Je=useCallback(m=>{let R=new FileReader;R.onload=()=>{let le=typeof R.result=="string"?R.result:"";if(s.current?.importJSON(le)??false){let G=s.current?.getShapes().length??0;V({type:"success",text:t("import.success",{n:G})});}else V({type:"error",text:t("import.fail")});D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);},R.onerror=()=>{V({type:"error",text:t("import.fail")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),3500);},R.readAsText(m,"utf-8");},[]),_e=useCallback(m=>{let R=s.current,le=v.current;if(!R||!le)return;if(R.isPointerDown()){be.current!==null&&(be.current=null,S(null));return}let Ne=m.clientX,G=m.clientY;cancelAnimationFrame(Oe.current),Oe.current=requestAnimationFrame(()=>{let De=le.getBoundingClientRect(),Me=Ne-De.left,We=G-De.top,Qe=Me+12,Ue=We+12,zt=R.getSelectedUml()?.id,dt=R.getUmlRowAtScreenPoint({x:Me,y:We});if(dt&&dt.shape.id!==zt&&dt.text&&R.isUmlRowTextTruncated(dt)){be.current!==dt.text&&(be.current=dt.text,S({text:dt.text,x:Qe,y:Ue}));return}let ht=R.getShapeAtScreenPoint({x:Me,y:We});ht&&ht.text&&R.isShapeTextTruncated(ht.id)?be.current!==ht.text&&(be.current=ht.text,S({text:ht.text,x:Qe,y:Ue})):be.current!==null&&(be.current=null,S(null));});},[]),u=useCallback(()=>{S(null);},[]),r=useCallback(m=>{let R=s.current,le=v.current;if(!R||!le)return;let Ne=le.getBoundingClientRect(),G=m.clientX-Ne.left,De=m.clientY-Ne.top,Me=R.getUmlRowAtScreenPoint({x:G,y:De});if(Me){se(Me.shape.id);return}let We=R.getMindMapNodeAtScreenPoint({x:G,y:De});if(We){R.beginMindMapEdit(We.shapeId,We.nodeId);return}let Qe=R.getTableAtScreenPoint({x:G,y:De});Qe&&R.beginTableEdit(Qe.shapeId,Qe.row,Qe.col);},[]),_=useCallback(()=>{Ee(null);},[]),[A,q]=useState(null),$e=useCallback(()=>q(null),[]),ae=useCallback(m=>{m.preventDefault();let R=s.current,le=v.current;if(!R||!le||R.isEditing())return;let Ne=le.getBoundingClientRect(),G=R.getShapeAtScreenPoint({x:m.clientX-Ne.left,y:m.clientY-Ne.top});G?R.isShapeLocked(G.id)?R.selectShapeRaw(G.id):R.getSelectedIds().includes(G.id)||R.selectShape(G.id,m.shiftKey):R.selectShape("",false),q({x:m.clientX,y:m.clientY,shapeId:G?.id??null});},[]),go=useCallback(m=>{m.preventDefault();},[]);return jsxs("div",{ref:C,className:`drawui-canvas-board ${e}`,onContextMenu:go,onDragOver:m=>{m.dataTransfer?.types?.includes("Files")&&(m.preventDefault(),m.dataTransfer.dropEffect="copy");},onDrop:m=>{let R=Array.from(m.dataTransfer?.files||[]).filter(De=>(De.type||"").startsWith("image/"));if(!R.length)return;m.preventDefault();let le=s.current;if(!le)return;let Ne=m.currentTarget.getBoundingClientRect(),G=le.getCamera().screenToPage({x:m.clientX-Ne.left,y:m.clientY-Ne.top});le.insertImageFiles(R,G).then(()=>{!le.hasImageUploader()&&le.hasTemporaryImages()&&(V({type:"success",text:t("image.temporaryInserted")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3));}).catch(De=>{V({type:"error",text:gn(De)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);});},children:[jsx("canvas",{ref:v,className:"drawui-canvas",onMouseMove:_e,onMouseLeave:u,onDoubleClick:r,onContextMenu:ae}),ye&&jsx("div",{className:"drawui-tooltip",style:{left:ye.x,top:ye.y},children:ye.text}),jsx(qt,{activeTool:E,onToolChange:rt,showGrid:N,onToggleGrid:P,canUndo:Z,canRedo:ge,onUndo:T,onRedo:ee,onExport:re,onExportData:He,onImportData:Je,onHighlighterColorChange:m=>s.current?.setHighlighterColor(m),onStickyNoteColorChange:m=>s.current?.setStickyNoteColor(m),onInsertIcon:m=>s.current?.insertIcon(m),onInsertTable:(m,R)=>s.current?.insertTable(m,R),onInsertImage:m=>{let R=s.current;R&&R.insertImageFiles(m).then(()=>{!R.hasImageUploader()&&R.hasTemporaryImages()&&(V({type:"success",text:t("image.temporaryInserted")}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3));}).catch(le=>{V({type:"error",text:gn(le)}),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>V(null),4e3);});},arrowStyle:Q,onArrowStyleChange:m=>s.current?.setArrowStyle(m)}),jsx(Qt,{onZoomIn:at,onZoomOut:x,onReset:U,zoomLevel:X}),jsx(Wn,{editor:h,selectedCount:I,hasLineSelection:F,currentConnectionType:g,currentArrowHead:b,currentDashed:W}),jsx(Yn,{editor:h,umlClass:Le,editing:ie}),jsx(ro,{editor:h}),jsx(to,{editor:h,panelOpen:z}),jsx(Jn,{editor:h,panelOpen:z,onOpenPanel:()=>k(true)}),z&&jsx(lo,{editor:h,mindMap:Se}),jsx(po,{editor:h}),j&&jsx(yo,{editor:h,x:j.x,y:j.y,context:j.context,existingArrowId:j.existingArrowId,defaultShapeType:j.defaultShapeType,onClose:_}),A&&h&&jsx(mo,{editor:h,pos:A,onClose:$e}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(Qr[E])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:I===0?t("status.none"):t("status.selected",{n:I})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[X,"%"]})})]}),ke&&jsxs("div",{className:"drawui-toast",children:[ke.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"})]}),ke.text]})]})}export{ea as CanvasBoard,qt as Toolbar,Qt 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,DEFAULT_PAGE_THEME,setTheme,PAGE_THEMES,setLanguage}from'drawui-core';import {jsxs,jsx,Fragment}from'react/jsx-runtime';function V(){let[t,e]=useState(getLanguage());return useEffect(()=>subscribeLanguage(()=>e(getLanguage())),[]),t}var Mn=["#ffeb3b","#22c55e","#3b82f6","#ec4899","#8b5cf6","#f97316"],Tn="drawui:highlighterColor";function Et(){if(typeof window>"u")return DEFAULT_HIGHLIGHTER_COLOR;try{let t=window.localStorage.getItem(Tn);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():DEFAULT_HIGHLIGHTER_COLOR}catch{return DEFAULT_HIGHLIGHTER_COLOR}}function Ln(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Tn,t);}catch{}}var En="drawui:stickyNoteColor";function It(){if(typeof window>"u")return STICKY_NOTE_DEFAULT_COLOR;try{let t=window.localStorage.getItem(En);return t&&/^#[0-9a-fA-F]{6}$/.test(t)?t.toLowerCase():STICKY_NOTE_DEFAULT_COLOR}catch{return STICKY_NOTE_DEFAULT_COLOR}}function In(t){if(!(typeof window>"u"))try{window.localStorage.setItem(En,t);}catch{}}function Ho({icon:t,size:e=24,ink:o=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((i,d)=>{let s=i.fill??"ink",l=i.stroke??"ink";return jsx("path",{d:i.d,fill:s==="none"?"none":s==="ink"?o:s,...l==="none"?{}:{stroke:l==="ink"?o:l,strokeWidth:i.w??1.8,strokeLinecap:"round",strokeLinejoin:"round"}},d)}),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 Kn="drawui:recentIcons",On=12;function tn(t,e){let o=/^#?([0-9a-f]{6})$/i.exec(t.trim());if(!o)return t;let i=parseInt(o[1],16);return `rgba(${i>>16&255}, ${i>>8&255}, ${i&255}, ${e})`}function Ao(){if(typeof window>"u")return [];try{let t=JSON.parse(window.localStorage.getItem(Kn)||"[]");return Array.isArray(t)?t.filter(e=>typeof e=="string").slice(0,On):[]}catch{return []}}function Ko(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Kn,JSON.stringify(t));}catch{}}var An=t=>({"--dw-icon-cat":t,"--dw-icon-cat-soft":tn(t,.12)}),$n=memo(function({onPick:e,onClose:o}){V();let[i,d]=useState(""),[s,l]=useState(ICON_CATEGORIES[0].id),[a,L]=useState(Ao),w=useRef(null),f=useRef(null);useEffect(()=>{f.current?.focus();},[]),useEffect(()=>{let y=T=>{let b=w.current;b&&(b.contains(T.target)||T.target?.closest?.("[data-icon-toggle]")||o());},k=T=>{T.key==="Escape"&&(T.stopPropagation(),o());};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",k),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",k);}},[o]);let u=useMemo(()=>a.map(y=>getIcon(y)).filter(y=>!!y),[a]),p=useMemo(()=>i.trim()?searchIcons(i):s==="recent"?u:iconsByCategory(s),[i,s,u]),M=s==="recent"?ICON_CATEGORY_INK.status:ICON_CATEGORY_INK[s]??ICON_DEFAULT_INK,O=i.trim()?t("icon.search"):s==="recent"?t("icon.recent"):t(ICON_CATEGORIES.find(y=>y.id===s)?.labelKey??"icon.search"),I=y=>{e(y),L(k=>{let T=[y.id,...k.filter(b=>b!==y.id)].slice(0,On);return Ko(T),T});};return jsxs("div",{className:"drawui-icon-panel",ref:w,style:{"--dw-icon-accent":M,"--dw-icon-soft":tn(M,.08),"--dw-icon-ring":tn(M,.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:f,value:i,onChange:y=>d(y.target.value),onKeyDown:y=>{y.key==="Enter"&&p.length>0&&I(p[0]);},placeholder:t("icon.search"),"aria-label":t("icon.search")}),jsx("span",{className:"drawui-icon-count",children:p.length})]}),!i.trim()&&jsxs("div",{className:"drawui-icon-cats",children:[u.length>0&&jsxs("button",{type:"button",className:`drawui-icon-cat${s==="recent"?" active":""}`,style:An(ICON_CATEGORY_INK.status),onClick:()=>l("recent"),children:[jsx("i",{className:"drawui-icon-dot"}),t("icon.recent")]}),ICON_CATEGORIES.map(y=>jsxs("button",{type:"button",className:`drawui-icon-cat${s===y.id?" active":""}`,style:An(ICON_CATEGORY_INK[y.id]??ICON_DEFAULT_INK),onClick:()=>l(y.id),children:[jsx("i",{className:"drawui-icon-dot"}),t(y.labelKey)]},y.id))]}),jsxs("div",{className:"drawui-icon-card",children:[jsxs("div",{className:"drawui-icon-card-head",children:[jsx("span",{className:"drawui-icon-card-title",children:O}),jsx("span",{className:"drawui-icon-card-count",children:p.length})]}),jsxs("div",{className:"drawui-icon-grid",children:[p.map(y=>jsx("button",{type:"button",className:"drawui-icon-item",title:`${y.zh} / ${y.en}`,"aria-label":`${y.zh} ${y.en}`,onClick:()=>I(y),children:jsx(Ho,{icon:y,size:30,ink:iconInk(y)})},y.id)),p.length===0&&jsx("div",{className:"drawui-icon-empty",children:t("icon.empty")})]})]})]})});var Ke=t=>`${t.x.toFixed(1)},${t.y.toFixed(1)}`,Dn=(t,e)=>{let o=e*Math.PI/180;return {x:t.x*Math.cos(o)-t.y*Math.sin(o),y:t.x*Math.sin(o)+t.y*Math.cos(o)}},wt={x:Math.SQRT1_2,y:-Math.SQRT1_2},nn={x:4.6,y:19.4},kt={x:19,y:5};function on(t,e,o){let i={x:-o.y,y:o.x},d=l=>({x:e.x-o.x*l,y:e.y-o.y*l}),s=(l,a)=>({x:l.x+i.x*a,y:l.y+i.y*a});switch(t){case "end":{let l=d(5.6);return jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,2.7))} ${Ke(s(l,-2.7))}`,fill:"currentColor",stroke:"none"})}case "inheritance":case "realization":{let l=d(8.6);return jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,3.5))} ${Ke(s(l,-3.5))}`,fill:"none"})}case "aggregation":case "composition":{let l=d(4.3),a=d(8.6);return jsx("polygon",{points:`${Ke(e)} ${Ke(s(l,2.7))} ${Ke(a)} ${Ke(s(l,-2.7))}`,fill:t==="composition"?"currentColor":"none",stroke:"currentColor"})}case "dependency":{let l=Dn({x:-o.x,y:-o.y},30),a=Dn({x:-o.x,y:-o.y},-30);return jsx("path",{d:`M ${Ke({x:e.x+l.x*5.8,y:e.y+l.y*5.8})} L ${Ke(e)} L ${Ke({x:e.x+a.x*5.8,y:e.y+a.y*5.8})}`,fill:"none"})}default:return null}}function Ge(t,e){let o=e||t==="dependency"||t==="realization",i=o?{x:kt.x-wt.x*8.6,y:kt.y-wt.y*8.6}:kt,d={x:-wt.x,y:-wt.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:nn.x,y1:nn.y,x2:i.x,y2:i.y,strokeDasharray:o?"3 2.6":void 0}),(t==="end"||t==="both")&&on("end",kt,wt),(t==="start"||t==="both")&&on("end",nn,d),t!=="none"&&t!=="start"&&t!=="end"&&t!=="both"?on(t,kt,wt):null]})}var Pt=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})}),$o=[{type:"straight",labelKey:"style.connection.straight",icon:Pt("M3 12h18")},{type:"polyline",labelKey:"style.connection.polyline",icon:Pt("M4 8 C 12 8, 12 16, 20 16")},{type:"orthogonal",labelKey:"style.connection.orthogonal",icon:Pt("M5 5v14h14")},{type:"curve",labelKey:"style.connection.curve",icon:Pt("M3 13 C 6 7, 9 7, 12 12 C 15 17, 18 17, 21 11")}],zn=[{key:"none",arrowHead:"none",dashed:false,labelKey:"style.arrowhead.none",icon:Ge("none",false)},{key:"end",arrowHead:"end",dashed:false,labelKey:"style.arrowhead.end",icon:Ge("end",false)},{key:"start",arrowHead:"start",dashed:false,labelKey:"style.arrowhead.start",icon:Ge("start",false)},{key:"both",arrowHead:"both",dashed:false,labelKey:"style.arrowhead.both",icon:Ge("both",false)},{key:"none-dashed",arrowHead:"none",dashed:true,labelKey:"style.arrowhead.none-dashed",icon:Ge("none",true)},{key:"both-dashed",arrowHead:"both",dashed:true,labelKey:"style.arrowhead.both-dashed",icon:Ge("both",true)}],_n=[{key:"inheritance",arrowHead:"inheritance",dashed:false,labelKey:"style.arrowhead.inheritance",icon:Ge("inheritance",false)},{key:"composition",arrowHead:"composition",dashed:false,labelKey:"style.arrowhead.composition",icon:Ge("composition",false)},{key:"aggregation",arrowHead:"aggregation",dashed:false,labelKey:"style.arrowhead.aggregation",icon:Ge("aggregation",false)},{key:"dependency",arrowHead:"dependency",dashed:true,labelKey:"style.arrowhead.dependency",icon:Ge("dependency",true)},{key:"realization",arrowHead:"realization",dashed:true,labelKey:"style.arrowhead.realization",icon:Ge("realization",true)}],Bn=[...zn,..._n];function Do(t,e){let o=Bn.find(i=>i.arrowHead===t&&i.dashed===e);return o?o.key:Bn.find(i=>i.arrowHead===t)?.key}var At=memo(function({connectionType:e,arrowHead:o,dashed:i,onConnectionTypeChange:d,onArrowStyleChange:s,onOptionHover:l,onOptionLeave:a}){V();let L=Do(o,i),w=f=>jsx("div",{className:"drawui-connection-row",children:f.map(u=>jsxs("button",{className:`drawui-connection-btn${L===u.key?" active":""}`,onClick:()=>s(u),"data-drawui-tip":l?void 0:t(u.labelKey),onMouseEnter:l?p=>l(u.labelKey,p.currentTarget):void 0,onMouseLeave:l?a:void 0,"aria-label":t(u.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:u.icon}),jsx("span",{className:"drawui-connection-label",children:t(u.labelKey)})]},u.key))});return jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("style.connection")}),jsx("div",{className:"drawui-connection-row",children:$o.map(f=>jsxs("button",{className:`drawui-connection-btn${e===f.type?" active":""}`,onClick:()=>d(f.type),"data-drawui-tip":l?void 0:t(f.labelKey),onMouseEnter:l?u=>l(f.labelKey,u.currentTarget):void 0,onMouseLeave:l?a:void 0,"aria-label":t(f.labelKey),type:"button",children:[jsx("span",{className:"drawui-connection-icon",children:f.icon}),jsx("span",{className:"drawui-connection-label",children:t(f.labelKey)})]},f.type))}),jsx("div",{className:"drawui-style-popover-title",children:t("style.arrow")}),w(zn),jsx("div",{className:"drawui-style-popover-title",children:t("style.uml")}),w(_n)]})});var Wn=[{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"})]})}],_o=[{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"}]}],Wo=new Map(Wn.map(t=>[t.type,t.icon])),Uo=new Set(Wn.map(t=>t.type)),Go=jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}),Zo=[{type:"arrow",icon:"M5 12h14M12 5l7 7-7 7",labelKey:"toolbar.arrow"},{type:"text",icon:"M4 7V4h16v3M9 20h6M12 4v16",labelKey:"toolbar.text"}],Fo="M17 3a2.85 2.85 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3Z",rn=8,Vo=6,an="M0 -1Q0.24 -0.24 1 0Q0.24 0.24 0 1Q-0.24 0.24 -1 0Q-0.24 -0.24 0 -1Z",Yo=[{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"}],sn=memo(function({activeTool:e,onToolChange:o,showGrid:i,onToggleGrid:d,pageTheme:s="light",onPageThemeChange:l,canUndo:a=false,canRedo:L=false,onUndo:w,onRedo:f,onExport:u,onExportData:p,onImportData:M,onHighlighterColorChange:O,onStickyNoteColorChange:I,onInsertIcon:y,onInsertTable:k,onInsertImage:T,arrowStyle:b,onArrowStyleChange:m,hidden:C=false}){let[g,x]=useState(false),[U,P]=useState(false),[A,ue]=useState(null),[ee,E]=useState(false),[q,pe]=useState(false),[S,se]=useState(Et),[ve,$]=useState(false),[G,xe]=useState(It),[ke,$e]=useState(false),[Ne,Fe]=useState(false),_e=useRef(null),Y=r=>{let Z=Array.from(r.target.files||[]);Z.length&&T?.(Z),r.target.value="";},[H,Ce]=useState(null),fe=useRef(null),te=useRef(null),De=useRef(null),X=useRef(null),Ee=useRef(null);V();let He=[{format:"png",labelKey:"toolbar.export.png"},{format:"svg",labelKey:"toolbar.export.svg"},{format:"pdf",labelKey:"toolbar.export.pdf"}],tt=()=>{fe.current&&(clearTimeout(fe.current),fe.current=null),E(true);},K=()=>{fe.current=window.setTimeout(()=>E(false),200);},Ve=["light","warm","gray","purple","green","eye-care"],Le={light:"#fafafa",warm:"#f8f5e9",gray:"#f1f3f5",purple:"#f7f5ff",green:"#f0fdf4","eye-care":"#f5f0e1"},v=useRef(null),D=()=>{E(false),j(),v.current?.click();},_=r=>{let Z=r.target.files?.[0];Z&&M?.(Z),r.target.value="";},W=()=>{te.current&&(clearTimeout(te.current),te.current=null),x(true);},J=()=>{te.current=window.setTimeout(()=>{x(false),j();},200);},le=()=>{De.current&&(clearTimeout(De.current),De.current=null),P(true);},Ye=()=>{De.current=window.setTimeout(()=>{P(false),j();},200);},Ie=(r,Z)=>{let ce=r.closest(".drawui-toolbar");if(!ce)return;let ne=r.getBoundingClientRect(),pt=ce.getBoundingClientRect(),xt=ne.bottom+46>window.innerHeight;ue({label:Z,x:ne.left-pt.left+ne.width/2,y:xt?ne.top-pt.top-8:ne.bottom-pt.top+8,above:xt});},j=()=>ue(null),Be=()=>{X.current&&(clearTimeout(X.current),X.current=null),pe(true);},nt=()=>{X.current=window.setTimeout(()=>pe(false),200);},We=r=>{se(r),Ln(r),O?.(r),o("highlighter");},ge=()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null),$(true);},ut=()=>{Ee.current=window.setTimeout(()=>$(false),200);},c=r=>{xe(r),In(r),I?.(r),o("sticky-note"),$(false);};return jsx("div",{className:"drawui-toolbar-container",style:{display:C?"none":void 0},children:jsxs("div",{className:"drawui-toolbar",children:[jsx("button",{className:`drawui-toolbar-button ${e==="select"?"active":""}`,onClick:()=>o("select"),onMouseEnter:r=>Ie(r.currentTarget,"toolbar.select"),onMouseLeave:j,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:()=>o("hand"),onMouseEnter:r=>Ie(r.currentTarget,"toolbar.hand"),onMouseLeave:j,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:W,onMouseLeave:J,children:[jsx("button",{className:`drawui-toolbar-button ${Uo.has(e)?"active":""}`,onClick:()=>{o("rounded-rectangle"),x(false),j();},"data-drawui-tip":g?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"})})}),g&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-shape-menu",children:jsx("div",{className:"drawui-shape-menu-scroll",children:_o.map(r=>jsxs("div",{className:"drawui-shape-group",children:[jsx("div",{className:"drawui-shape-group-title",children:t(r.labelKey)}),jsx("div",{className:"drawui-shape-group-grid",children:r.items.map(Z=>{let ce=Z.labelKey??`tool.${Z.type}`;return jsx("button",{type:"button",className:`drawui-toolbar-shape-item ${e===Z.type?"active":""}`,onClick:()=>{o(Z.type),x(false),j();},onMouseEnter:ne=>Ie(ne.currentTarget,ce),onMouseLeave:j,"aria-label":t(ce),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:Wo.get(Z.type)})},`${r.key}-${Z.type}`)})})]},r.key))})})]}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:ge,onMouseLeave:ut,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="sticky-note"?"active":""}`,onClick:()=>{o("sticky-note"),$(false),j();},"data-drawui-tip":ve?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:Go}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:G}})]}),ve&&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(r=>jsx("button",{type:"button","aria-label":r,className:`drawui-sticky-swatch${G.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>c(r)},r))})]})]}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${ke?"active":""}`,"data-icon-toggle":"","data-drawui-tip":ke?void 0:t("toolbar.icon"),onClick:()=>{$e(r=>!r),j();},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"})]})}),ke&&jsx($n,{onPick:r=>y?.(r.id),onClose:()=>$e(false)})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:le,onMouseLeave:Ye,children:[jsx("button",{className:`drawui-toolbar-button ${e==="arrow"?"active":""}`,onClick:()=>{o("arrow"),P(false),j();},"data-drawui-tip":U?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"})})}),U&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-arrow-menu",onPointerDown:r=>{r.target.closest("button")||(P(false),j());},children:jsx(At,{connectionType:b?.connectionType??"straight",arrowHead:b?.arrowHead??"end",dashed:!!b?.dashed,onConnectionTypeChange:r=>{m?.({connectionType:r}),o("arrow"),P(false),j();},onArrowStyleChange:r=>{m?.({arrowHead:r.arrowHead,dashed:r.dashed}),o("arrow"),P(false),j();},onOptionHover:(r,Z)=>Ie(Z,r),onOptionLeave:j})})]}),Zo.filter(r=>r.type!=="arrow").map(r=>jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":t(r.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:r.icon})})},r.type)),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:`drawui-toolbar-button ${e==="pen"?"active":""}`,onClick:()=>o("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:Fo})})}),jsxs("div",{className:"drawui-toolbar-dropdown",onMouseEnter:Be,onMouseLeave:nt,children:[jsxs("button",{className:`drawui-toolbar-button ${e==="highlighter"?"active":""}`,onClick:()=>o("highlighter"),onMouseEnter:r=>Ie(r.currentTarget,"toolbar.highlighter"),onMouseLeave:j,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:an,transform:"translate(7.4 5.4) scale(2.4)"}),jsx("path",{d:an,transform:"translate(18.4 3.4) scale(2.5)"}),jsx("path",{d:an,transform:"translate(21 10.6) scale(2.2)"})]})]}),jsx("span",{className:"drawui-toolbar-color-chip",style:{background:S}})]}),q&&jsx("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-highlighter-grid",children:Mn.map(r=>jsx("button",{type:"button","aria-label":r,className:`drawui-highlighter-swatch${S.toLowerCase()===r.toLowerCase()?" active":""}`,style:{background:r},onClick:()=>We(r)},r))})]}),jsx("div",{className:"drawui-toolbar-divider"}),Yo.map(r=>jsx("button",{className:`drawui-toolbar-button ${e===r.type?"active":""}`,onClick:()=>o(r.type),"data-drawui-tip":t(r.labelKey),children:jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:r.icon})})},r.type)),jsx("button",{className:`drawui-toolbar-button ${e==="mind-map"?"active":""}`,onClick:()=>o("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("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]})}),jsx("button",{className:"drawui-toolbar-button",onClick:()=>_e.current?.click(),"data-drawui-tip":t("toolbar.image"),"data-image-toggle":true,children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),jsx("circle",{cx:"8.5",cy:"9.5",r:"1.6"}),jsx("path",{d:"M21 15.5l-4.5-4.5L6 21"})]})}),jsx("input",{ref:_e,type:"file",accept:"image/*",multiple:true,style:{display:"none"},onChange:Y}),jsxs("div",{className:"drawui-toolbar-dropdown",children:[jsx("button",{className:`drawui-toolbar-button ${Ne?"active":""}`,onClick:()=>Fe(r=>!r),"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"})]})}),Ne&&jsxs("div",{className:"drawui-table-picker",children:[jsx("div",{className:"drawui-table-picker-hint",children:H?`${H.rows} \xD7 ${H.cols}`:t("table.pickHint")}),jsx("div",{className:"drawui-table-picker-grid",children:Array.from({length:Vo*rn},(r,Z)=>{let ce=Math.floor(Z/rn),ne=Z%rn,pt=H&&ce<H.rows&&ne<H.cols;return jsx("button",{type:"button","aria-label":`${ce+1}x${ne+1}`,className:"drawui-table-picker-cell",style:pt?{borderColor:"var(--dw-primary)",background:"var(--dw-primary-weak)"}:void 0,onMouseEnter:()=>Ce({rows:ce+1,cols:ne+1}),onClick:()=>{k?.(ce+1,ne+1),Fe(false),Ce(null),j();}},Z)})})]})]}),jsx("div",{className:"drawui-toolbar-divider"}),jsx("button",{className:"drawui-toolbar-button",onClick:w,disabled:!a,style:a?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:f,disabled:!L,style:L?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:tt,onMouseLeave:K,children:[jsx("button",{className:`drawui-toolbar-button ${ee?"active":""}`,"data-drawui-tip":ee?void 0:t("toolbar.more"),children:jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"5",cy:"12",r:"1.8",fill:"currentColor"}),jsx("circle",{cx:"12",cy:"12",r:"1.8",fill:"currentColor"}),jsx("circle",{cx:"19",cy:"12",r:"1.8",fill:"currentColor"})]})}),ee&&jsxs("div",{className:"drawui-toolbar-shape-grid drawui-toolbar-more-grid",children:[jsxs("button",{className:"drawui-toolbar-more-row",onClick:()=>{d(),E(false);},children:[jsx("span",{className:"drawui-toolbar-more-icon",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("span",{className:"drawui-toolbar-more-label",children:t("toolbar.grid")}),i&&jsx("svg",{className:"drawui-toolbar-more-check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("polyline",{points:"20 6 9 17 4 12"})})]}),jsxs("div",{className:"drawui-toolbar-more-section",children:[jsx("div",{className:"drawui-toolbar-more-section-title",children:t("toolbar.pageTheme")}),jsx("div",{className:"drawui-toolbar-more-themes",children:Ve.map(r=>jsx("button",{type:"button",className:`drawui-toolbar-more-theme-swatch${s===r?" active":""}`,style:{background:Le[r]},onClick:()=>{l?.(r),E(false);},title:t(`pageTheme.${r}`),"aria-label":t(`pageTheme.${r}`)},r))})]}),jsx("div",{className:"drawui-toolbar-export-divider"}),He.map(r=>jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{u?.(r.format),E(false);},children:t(r.labelKey)},r.format)),jsx("div",{className:"drawui-toolbar-export-divider"}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:()=>{p?.(),E(false);},children:t("toolbar.export.data")}),jsx("button",{className:"drawui-toolbar-shape-item drawui-toolbar-export-item",onClick:D,children:t("toolbar.import.data")})]})]}),jsx("input",{ref:v,type:"file",accept:".json,application/json",style:{display:"none"},onChange:_}),A&&jsx("div",{className:`drawui-shape-tip ${A.above?"is-above":"is-below"}`,style:{left:A.x,top:A.y},children:t(A.label)})]})})});var cn=memo(function({onZoomIn:e,onZoomOut:o,onReset:i,zoomLevel:d=100}){return V(),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:[d,"%"]}),jsx("button",{className:"drawui-zoom-button",onClick:o,"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:i,"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 Gn=["#ffffff","#f1f5f9","#e2e8f0","#ede9fe","#dbeafe","#e0e7ff","#dcfce7","#fef9c3","#fee2e2"],Zn=["#0f172a","#475569","#94a3b8","#8b5cf6","#3b82f6","#1d4ed8","#16a34a","#eab308","#dc2626"],tr=Gn.filter(t=>t!=="#f1f5f9"),nr=[...tr,...Zn],or=[...Gn,...Zn],Fn=15,Vn="drawui:customColors";function rr(){if(typeof window>"u")return [];try{let t=window.localStorage.getItem(Vn);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e.filter(o=>typeof o=="string").slice(-Fn):[]}catch{return []}}function ar(t){if(!(typeof window>"u"))try{window.localStorage.setItem(Vn,JSON.stringify(t));}catch{}}var dn=[{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}],Un=(t,e)=>!!t&&!!e&&t.toLowerCase()===e.toLowerCase(),St=10,lt=12,it=t=>!t||t==="transparent",Yn=memo(function({editor:e,selectedCount:o,hasLineSelection:i,currentConnectionType:d,currentArrowHead:s,currentDashed:l,hidden:a=false}){V();let L=!!e?.getEditingShapeId(),[w,f]=useState(null),[u,p]=useState(null),[,M]=useState(0),O=useRef(null),I=useRef(null),y=useRef(null),[k,T]=useState({tw:168,th:42,pw:228,ph:160}),[b,m]=useState(rr),C=useRef(null),g=useCallback(c=>{let r=c.trim().toLowerCase();/^#[0-9a-f]{6}$/.test(r)&&m(Z=>{let ce=Z.filter(ne=>ne!==r);for(ce.push(r);ce.length>Fn;)ce.shift();return ar(ce),ce});},[]);if(useEffect(()=>{let c=C.current;if(!c)return;let r=()=>{c.value&&g(c.value);};return c.addEventListener("change",r),()=>c.removeEventListener("change",r)},[g,u]),useEffect(()=>{if(!e)return;let c=e.subscribe(()=>M(r=>(r+1)%1e6));return ()=>{c();}},[e]),useEffect(()=>{p(null);},[o,L]),useEffect(()=>{if(!u)return;let c=r=>{O.current&&!O.current.contains(r.target)&&p(null);};return document.addEventListener("pointerdown",c,true),()=>document.removeEventListener("pointerdown",c,true)},[u]),useLayoutEffect(()=>{let c=I.current?.offsetWidth??k.tw,r=I.current?.offsetHeight??k.th,Z=y.current?.offsetWidth??k.pw,ce=y.current?.offsetHeight??k.ph;T(ne=>ne.tw===c&&ne.th===r&&ne.pw===Z&&ne.ph===ce?ne:{tw:c,th:r,pw:Z,ph:ce});}),!e||o===0||L)return null;let x=e.getSelectedIds(),P=e.getShapes().filter(c=>x.includes(c.id)),A=P[0],ue=A?.id??"",ee=P.length===1&&P[0].type==="mind-map"?e.getMindMapSelectedNode():null,E=ee&&ee.shapeId===P[0].id?ee:null,q=E?e.canPromoteMindMapNode(E.shapeId,E.nodeId,1):false,pe=E?e.canPromoteMindMapNode(E.shapeId,E.nodeId,2):false,S=A?.style.fillColor,se=A?.style.strokeColor??"#1f2937",ve=A?.textColor??"#1f2937",$=A?.highlightColor,G={fill:S,stroke:se,text:ve,highlight:$},xe=P.length>0&&P.every(c=>c.type==="sticky-note"),ke={fill:A?.style.fillOpacity??1,stroke:A?.style.strokeOpacity??1,highlight:A?.highlightOpacity??1},$e=c=>w&&w.key===`${ue}:${c}`?w.value:ke[c]??1,Ne=(c,r)=>{switch(c){case "stroke":e.updateSelectedShapesStyle({strokeColor:r});break;case "fill":e.updateSelectedShapesStyle({fillColor:r});break;case "text":e.updateSelectedShapesText({textColor:r});break;case "highlight":e.updateSelectedShapesText({highlightColor:r});break}},Fe=(c,r)=>{f({key:`${ue}:${c}`,value:r}),c==="highlight"?e.updateSelectedShapesText({highlightOpacity:r}):c==="stroke"?e.updateSelectedShapesStyle({strokeOpacity:r}):e.updateSelectedShapesStyle({fillOpacity:r});},_e=c=>e.updateConnectionType(c),Y=c=>e.updateArrowStyle({arrowHead:c.arrowHead,dashed:c.dashed}),H=!!i&&P.length>0&&P.every(c=>c.type==="line"||c.type==="arrow"),Ce=P.length>0&&P.every(c=>c.type==="text"),fe=P.length>0&&P.every(c=>c.type==="sticky-note"||c.type==="icon"),te=H?dn.filter(c=>c.key==="stroke"):fe?dn.filter(c=>c.key!=="stroke"):dn,De=c=>c.key==="stroke"&&H?"style.line":c.labelKey,X=u&&u!=="more"?te.find(c=>c.key===u):void 0,Ee=!!u&&(u==="more"||u==="prefix"||u==="level"||!!X),He=xe&&X?.key==="fill",tt=e.getCamera(),K=getContentBounds(P,0),Ve=tt.pageToScreen({x:K.x,y:K.y}),Le=tt.pageToScreen({x:K.x+K.width,y:K.y+K.height}),v=window.innerWidth,D=window.innerHeight,_=Le.y+St,W=Ve.y-St,J=k.th+(Ee?St+k.ph:0),le=_+J<=D-lt,Ye=W-J>=lt,Ie=le||!Ye,j=(Ve.x+Le.x)/2,Be=(c,r,Z)=>Math.max(r,Math.min(c,Math.max(r,Z))),nt=Be(j-k.tw/2,lt,v-k.tw-lt),We=Ie?_:W-k.th,ge=Be(j-k.pw/2,lt,v-k.pw-lt),ut=Ee?Be(Ie?We+k.th+St:We-St-k.ph,lt,D-k.ph-lt):0;return jsxs("div",{className:"drawui-style-floating",ref:O,style:a?{display:"none"}:void 0,children:[jsxs("div",{className:"drawui-style-toolbar",ref:I,style:{left:nt,top:We},children:[te.map(c=>jsxs("button",{className:`drawui-style-tool-btn${u===c.key?" active":""}`,onClick:()=>p(u===c.key?null:c.key),"data-drawui-tip":t(De(c)),type:"button",children:[c.key==="fill"&&jsx("span",{className:`drawui-st-swatch${it(S)?" drawui-st-none":""}`,style:it(S)?void 0:{background:S}}),c.key==="stroke"&&(H?jsx("span",{className:`drawui-st-line${it(se)?" drawui-st-line-none":""}`,style:it(se)?void 0:{background:se}}):jsx("span",{className:`drawui-st-frame${it(se)?" drawui-st-frame-none":""}`,style:it(se)?void 0:{borderColor:se}})),c.key==="text"&&jsx("span",{className:"drawui-st-text",style:{color:ve},children:"A"}),c.key==="highlight"&&jsx("span",{className:`drawui-st-hl${it($)?" drawui-st-none":""}`,style:it($)?void 0:{background:$},children:"A"})]},c.key)),E&&jsx("button",{className:`drawui-style-tool-btn${u==="level"?" active":""}`,onClick:()=>p(u==="level"?null:"level"),"data-drawui-tip":t("mindmap.level"),type:"button",children:jsxs("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("line",{x1:"12",y1:"20",x2:"12",y2:"5"}),jsx("polyline",{points:"6 11 12 5 18 11"})]})}),i&&jsx("button",{className:`drawui-style-tool-btn${u==="more"?" active":""}`,onClick:()=>p(u==="more"?null:"more"),"data-drawui-tip":t("style.connection"),type:"button",children:"\u22EF"}),Ce&&jsx("button",{className:`drawui-style-tool-btn${u==="prefix"?" active":""}`,onClick:()=>p(u==="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"})]})})]}),Ee&&jsx("div",{className:"drawui-style-popover",ref:y,style:{left:ge,top:ut},children:u==="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")})]}):u==="level"?E?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t("mindmap.level")}),jsxs("div",{style:{display:"flex",gap:8},children:[jsx("button",{type:"button",disabled:!q,onClick:()=>e.promoteMindMapNode(E.shapeId,E.nodeId,1),"data-drawui-tip":q?t("mindmap.promote1"):t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:q?"#ffffff":"#f9fafb",color:q?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:q?"pointer":"not-allowed"},children:t("mindmap.promote1")}),jsx("button",{type:"button",disabled:!pe,onClick:()=>e.promoteMindMapNode(E.shapeId,E.nodeId,2),"data-drawui-tip":pe?t("mindmap.promote2"):t("mindmap.promoteDisabled"),style:{border:"1px solid #bfdbfe",background:pe?"#ffffff":"#f9fafb",color:pe?"#3b82f6":"#9ca3af",borderRadius:5,padding:"4px 10px",fontSize:12,cursor:pe?"pointer":"not-allowed"},children:t("mindmap.promote2")})]})]}):null:X?jsxs(Fragment,{children:[jsx("div",{className:"drawui-style-popover-title",children:t(De(X))}),jsxs("div",{className:"drawui-color-row",children:[X.hasTransparent&&!He&&jsx("button",{className:`drawui-color-swatch drawui-color-swatch-transparent${it(G[X.key])?" active":""}`,onClick:()=>Ne(X.key,"transparent"),"aria-label":t("style.none"),type:"button"}),(He?STICKY_NOTE_COLORS:X.hasTransparent?nr:or).map(c=>jsx("button",{className:`drawui-color-swatch${Un(c,G[X.key])?" active":""}`,style:{background:c},onClick:()=>Ne(X.key,c),"aria-label":c,type:"button"},c)),b.map(c=>jsx("button",{className:`drawui-color-swatch drawui-color-custom${Un(c,G[X.key])?" active":""}`,style:{background:c},onClick:()=>Ne(X.key,c),"aria-label":c,type:"button"},`custom-${c}`)),jsxs("span",{className:"drawui-color-swatch drawui-color-add","data-drawui-tip":t("style.addColor"),children:["+",jsx("input",{ref:C,type:"color",defaultValue:"#3b82f6",className:"drawui-color-add-input","aria-label":t("style.addColor")})]})]}),X.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($e(X.key)*100),onChange:c=>Fe(X.key,Number(c.target.value)/100),className:"drawui-opacity-slider"}),jsxs("span",{className:"drawui-opacity-value",children:[Math.round($e(X.key)*100),"%"]})]})]}):jsx(Fragment,{children:jsx(At,{connectionType:d??"straight",arrowHead:s??"end",dashed:!!l,onConnectionTypeChange:_e,onArrowStyleChange:Y})})})]})});var pn=14,qn=20,pr=["#1f2937","#ef4444","#f97316","#facc15","#22c55e","#3b82f6","#8b5cf6","#ec4899","#9ca3af"],hr=[12,14,16,18,20,24];function Jn(t,e){let o=t,i="",d=o.charAt(0);if(o.length>1&&(d==="+"||d==="-"||d==="#"||d==="~")&&o.charAt(1)===" "&&(i=d,o=o.slice(2)),o=o.replace(/^\s+|\s+$/g,""),e==="attribute"){let f=o.indexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:o.slice(f+1).replace(/^\s+|\s+$/g,""),params:"",returnType:""}}let s=o.indexOf("(");if(s===-1){let f=o.lastIndexOf(":");return f===-1?{visibility:i,name:o,type:"",params:"",returnType:""}:{visibility:i,name:o.slice(0,f).replace(/^\s+|\s+$/g,""),type:"",params:"",returnType:o.slice(f+1).replace(/^\s+|\s+$/g,"")}}let l=o.slice(0,s).replace(/^\s+|\s+$/g,""),a=o.indexOf(")",s);if(a===-1)return {visibility:i,name:l,type:"",params:o.slice(s+1).replace(/^\s+|\s+$/g,""),returnType:""};let L=o.slice(s+1,a).replace(/^\s+|\s+$/g,""),w=o.slice(a+1).replace(/^\s+|\s+$/g,"");return w.startsWith(":")&&(w=w.slice(1).replace(/^\s+|\s+$/g,"")),{visibility:i,name:l,type:"",params:L,returnType:w}}function yr(t,e){let o=e.visibility?`${e.visibility} `:"";return t==="attribute"?`${o}${e.name}${e.type?`: ${e.type}`:""}`:`${o}${e.name}(${e.params??""})${e.returnType?`: ${e.returnType}`:""}`}var eo=memo(function({editor:e,umlClass:o,editing:i}){let[,d]=useState(0);V(),useEffect(()=>{if(!e)return;let v=e.subscribe(()=>d(D=>D+1));return ()=>{v();}},[e]);let[s,l]=useState(null),[a,L]=useState(false),[w,f]=useState(null),u=useRef(null),p=useRef(null),M=useCallback((v,D)=>{u.current&&(clearTimeout(u.current),u.current=null),l({section:v,rowId:D}),L(false);},[]),O=useCallback(()=>{u.current&&clearTimeout(u.current),u.current=window.setTimeout(()=>{l(null),L(false);},150);},[]);if(!e||!o||i!==o.id)return null;let I=e.getCamera(),{id:y,x:k,y:T,width:b,height:m,className:C,methods:g}=o,x=o.type==="uml-interface",U=x?[]:o.attributes,P=b/2,A=m/2,ue=UML_HEADER_HEIGHT,ee=UML_LINE_HEIGHT,E=UML_PADDING_X,q=UML_PADDING_Y,pe=x?0:U.length>0?U.length*ee+q*2:q*2,S=I.zoom,se=(b-E*2)*S,ve=4*S,$=I.pageToScreen({x:k-P+E,y:T}),G=I.pageToScreen({x:k,y:T-A+ue/2}),xe=v=>I.pageToScreen({x:k,y:v}).y,ke=ee*S,$e=v=>T+(-A+ue+q+ee/2+v*ee),Ne=v=>T+(-A+ue+pe+q+ee/2+v*ee),Fe=T+(-A+ue+pe),_e=T+A,Y={background:"#ffffff",borderWidth:1,borderStyle:"solid",borderColor:"transparent",outline:"none",padding:0,fontFamily:"sans-serif",boxSizing:"border-box"},H=(v,D)=>{if(!U.find(J=>J.id===v))return;let W=Jn(D,"attribute");e.updateUmlClass(y,{attributes:U.map(J=>J.id===v?{...J,...W}:J)});},Ce=(v,D)=>{if(!g.find(le=>le.id===v))return;let W=Jn(D,"method"),J=g.map(le=>le.id===v?{...le,...W}:le);x?e.updateUmlInterface(y,{methods:J}):e.updateUmlClass(y,{methods:J});},fe=(v,D,_)=>{p.current={section:v,from:D},_.dataTransfer.effectAllowed="move",_.dataTransfer.setData("text/plain",`${v}:${D}`);},te=v=>{v.preventDefault(),v.dataTransfer.dropEffect="move";},De=(v,D,_)=>{_.preventDefault();let W=p.current;!W||W.section!==v||(v==="attribute"?e.reorderUmlAttribute(y,W.from,D):e.reorderUmlMethod(y,W.from,D),p.current=null);},X=(v,D,_,W)=>{let J=xe(W),le=s?.section===v&&s.rowId===_.id,Ye=(_.fontSize||UML_FONT_SIZE)*S,Ie=_.textColor||"#1f2937",j={position:"absolute",left:$.x-pn*S-ve,top:J-ke/2,width:pn*S+ve+se+qn*S,height:ke,display:"flex",alignItems:"center",gap:2,pointerEvents:"none",zIndex:53},Be={...Y,width:se,height:ke-2,fontSize:Ye,color:Ie,textDecoration:_.strikethrough?"line-through":"none",pointerEvents:"auto",...le?{borderColor:"var(--dw-primary)"}:{}},nt={width:pn*S,height:ke-2,cursor:"grab",color:"#9ca3af",display:"flex",alignItems:"center",justifyContent:"center",userSelect:"none",fontSize:12*S,lineHeight:1,opacity:le?1:.55,pointerEvents:"auto"},We={width:qn*S,height:ke-6,border:"none",background:"transparent",color:"#9ca3af",cursor:"pointer",borderRadius:3,fontSize:14*S,opacity:le?1:.35,pointerEvents:"auto"};return jsxs("div",{style:j,onDragOver:te,onDrop:ge=>De(v,D,ge),children:[jsx("span",{style:nt,draggable:true,onDragStart:ge=>fe(v,D,ge),"data-drawui-tip":t("uml.drag"),children:"\u22EE\u22EE"}),jsx("input",{style:Be,value:w&&w.rowId===_.id?w.text:yr(v,_),onChange:ge=>{f({rowId:_.id,text:ge.target.value}),v==="attribute"?H(_.id,ge.target.value):Ce(_.id,ge.target.value);},onFocus:()=>M(v,_.id),onBlur:()=>{f(null),O();},spellCheck:false}),jsx("button",{style:We,onMouseDown:ge=>ge.preventDefault(),onClick:()=>{v==="attribute"?e.removeUmlAttribute(y,_.id):e.removeUmlMethod(y,_.id);},"data-drawui-tip":t("uml.delete"),children:"\xD7"})]},_.id)},Ee=(v,D,_)=>{let W=xe(D),J=v==="attribute";return jsxs("button",{onMouseDown:le=>le.preventDefault(),onClick:()=>J?e.addUmlAttribute(y):e.addUmlMethod(y),className:"drawui-uml-add-row",style:{position:"absolute",left:$.x,top:W-9*S,height:18*S,padding:`0 ${6*S}px`,fontSize:11*S,lineHeight:1,border:"1px dashed #cbd5e1",background:"rgba(255,255,255,0.85)",color:"#64748b",borderRadius:3,cursor:"pointer",pointerEvents:"auto",display:"flex",alignItems:"center",gap:3,whiteSpace:"nowrap",zIndex:53},"data-drawui-tip":_,children:[jsx("span",{style:{fontSize:13*S,lineHeight:1},children:"+"}),jsx("span",{children:_})]},`add-${v}`)},He=()=>{if(!s||s.section==="className")return null;let v=s.section,D=s.rowId,W=(v==="attribute"?U:g).find(r=>r.id===D);if(!W)return null;let J=224*S,le=30*S,Ye=I.pageToScreen({x:k,y:T}).x,Ie=I.pageToScreen({x:k,y:T-A}).y,j=20*S,Be=Ie-le-j,nt=Ye-J/2,We=Be+le,ge=W.textColor||"#1f2937",ut=W.fontSize||UML_FONT_SIZE,c=!!W.strikethrough;return jsxs(Fragment,{children:[jsx("div",{style:{position:"absolute",left:Ye-.5,top:We,width:1,height:j,background:"#d1d5db",pointerEvents:"none",zIndex:59}}),jsxs("div",{className:"drawui-uml-toolbar",style:{position:"absolute",left:nt,top:Be,width:J,height:le,background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:6,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.1)",display:"flex",alignItems:"center",gap:4*S,padding:`0 ${6*S}px`,pointerEvents:"auto",zIndex:60,fontSize:12*S},onMouseDown:r=>r.preventDefault(),children:[jsxs("div",{style:{position:"relative"},children:[jsxs("button",{onClick:()=>L(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:ge,fontSize:13*S,textDecoration:c?"line-through":"none"},children:"A"}),jsx("span",{style:{width:10*S,height:2*S,background:ge,marginLeft:3,borderRadius:1}})]}),a&&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(y,v,W.id,{textColor:null}),L(false);},style:{width:14,height:14,border:"1px solid #e5e7eb",background:"transparent",cursor:"pointer",borderRadius:2},"data-drawui-tip":t("uml.defaultColor")}),pr.map(r=>jsx("button",{onClick:()=>{e.updateUmlRowStyle(y,v,W.id,{textColor:r}),L(false);},style:{width:14,height:14,border:"none",background:r,cursor:"pointer",borderRadius:2},"data-drawui-tip":r},r))]})]}),jsx("select",{value:ut,onChange:r=>e.updateUmlRowStyle(y,v,W.id,{fontSize:Number(r.target.value)}),style:{border:"1px solid #e5e7eb",borderRadius:3,padding:`0 ${2*S}px`,fontSize:12*S,height:20*S,background:"#ffffff"},"data-drawui-tip":t("uml.fontSize"),children:hr.map(r=>jsx("option",{value:r,children:r},r))}),jsx("button",{onClick:()=>e.updateUmlRowStyle(y,v,W.id,{strikethrough:!c}),className:"drawui-uml-toolbar-btn","data-drawui-tip":t("uml.strikethrough"),style:{border:"none",background:c?"var(--dw-primary-weak)":"transparent",cursor:"pointer",padding:2,borderRadius:3},children:jsx("span",{style:{fontWeight:700,fontSize:13*S,textDecoration:"line-through"},children:"A"})}),jsx("button",{onClick:()=>{v==="attribute"?e.removeUmlAttribute(y,W.id):e.removeUmlMethod(y,W.id),l(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*S,height:14*S,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"})]})})]})]})},tt=I.pageToScreen({x:k-P,y:T}).x,K=I.pageToScreen({x:k,y:T-A}).y,Ve=b*S,Le=m*S;return jsxs("div",{style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:50},children:[jsx("div",{style:{position:"absolute",left:tt+1,top:K+1,width:Math.max(0,Ve-2),height:Math.max(0,Le-2),background:"#ffffff",pointerEvents:"none",zIndex:51}}),jsx("input",{style:{...Y,position:"absolute",left:G.x-se/2,top:G.y-ue*S/2+2,width:se,height:ue*S-4,textAlign:"center",fontWeight:700,fontSize:(o.fontSize||UML_FONT_SIZE)*S,color:o.textColor||"#1f2937",pointerEvents:"auto",zIndex:52,...s?.section==="className"?{borderColor:"var(--dw-primary)"}:{}},value:C,onChange:v=>x?e.updateUmlInterface(y,{className:v.target.value}):e.updateUmlClass(y,{className:v.target.value}),onFocus:()=>M("className",""),onBlur:O,spellCheck:false}),!x&&jsxs(Fragment,{children:[U.map((v,D)=>X("attribute",D,v,$e(D))),Ee("attribute",Fe,"\u5C5E\u6027")]}),g.map((v,D)=>X("method",D,v,Ne(D))),Ee("method",_e,t("uml.method")),He()]})});var ro=memo(function({editor:e,panelOpen:o,onOpenPanel:i}){let[,d]=useState(0);V(),useEffect(()=>{if(!e)return;let m=e.subscribe(()=>d(C=>C+1));return ()=>{m();}},[e]);let s=useRef(false),l=useRef(false),a=e?.getMindMapEditingShapeId()??null,L=e?.getMindMapSelectedNode()?.nodeId??"",w=a?`${a}\0${L}`:"";if(useEffect(()=>{s.current=false;},[w]),!e)return null;let f=e.getMindMapEditingShapeId();if(!f||o)return null;let u=e.getMindMapSelectedNode();if(!u||u.shapeId!==f)return null;let p=e.getMindMapNode(f,u.nodeId),M=e.getMindMapNodeScreenRect(f,u.nodeId);if(!p||!M)return null;let O=e.getCamera().getZoom(),I=MINDMAP_FONT_SIZE*O,y=Math.max(100,M.width+24),k=M.height+8,T={position:"absolute",left:M.x+M.width/2,top:M.y-4,transform:"translateX(-50%)",width:y,height:k,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 ${(p.icon?24:12)*O}px`,fontFamily:"sans-serif",fontSize:I,color:"#1f2937",boxSizing:"border-box",pointerEvents:"auto",zIndex:55},b={position:"absolute",left:M.x+M.width+12,top:M.y+M.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:T,value:p.text,spellCheck:false,onChange:m=>{let C=!s.current;s.current=true,e.updateMindMapNode(f,u.nodeId,{text:m.target.value},C);},onBlur:()=>{if(l.current){l.current=false;return}let m=e.getMindMapSelectedNode();m&&(m.shapeId!==f||m.nodeId!==u.nodeId)||e.exitMindMapEdit();},onKeyDown:m=>{m.key==="Enter"?m.target.blur():m.key==="Escape"&&e.exitMindMapEdit();}}),jsx("button",{style:b,"data-drawui-tip":t("mindmap.more"),onMouseDown:m=>{m.preventDefault(),l.current=true,setTimeout(()=>{l.current=false;},300);},onClick:i,children:"\u22EF"})]})});var so=memo(function({editor:e,panelOpen:o}){let[,i]=useState(0);V(),useEffect(()=>{if(!e)return;let k=e.subscribe(()=>i(T=>T+1));return ()=>{k();}},[e]);let d=useRef(false),s=e?.getTableEditing()??null,l=s?`${s.shapeId}\0${s.row}\0${s.col}`:"";if(useEffect(()=>{d.current=false;},[l]),!e||o)return null;let a=e.getTableEditing();if(!a)return null;let{shapeId:L,row:w,col:f}=a,u=e.getTableCell(L,w,f),p=e.getTableScreenRect(L,w,f);if(!u||!p)return null;let M=e.getSelectedTable(),O=u.fontSize||M?.fontSize||TABLE_FONT_SIZE,I=e.getCamera().getZoom(),y={left:p.x-1,top:p.y-1,width:p.width+2,height:p.height+2,padding:`${TABLE_CELL_PADDING_Y*I}px ${TABLE_CELL_PADDING_X*I}px`,fontFamily:"sans-serif",fontSize:O*I,lineHeight:TABLE_LINE_HEIGHT_RATIO,fontWeight:u.bold?700:400,color:u.textColor||M?.textColor||"#1f2937",textAlign:u.align==="center"?"center":u.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:y,value:u.text,spellCheck:false,onChange:k=>{let T=!d.current;d.current=true,e.updateTableCell(L,w,f,{text:k.target.value},T);},onBlur:()=>{e.exitTableEdit();},onKeyDown:k=>{(k.key==="Enter"||k.key==="Escape")&&(k.preventDefault(),k.target.blur());}})})});var uo=memo(function({editor:e,hidden:o=false}){let[,i]=useState(0),[d,s]=useState(null),l=useRef(null);if(V(),useEffect(()=>{if(!e)return;let E=e.subscribe(()=>i(q=>q+1));return ()=>{E();}},[e]),useEffect(()=>{if(!d)return;let E=pe=>{let S=pe.target;S&&l.current?.contains(S)||s(null);},q=pe=>{pe.key==="Escape"&&s(null);};return window.addEventListener("pointerdown",E,true),window.addEventListener("keydown",q),()=>{window.removeEventListener("pointerdown",E,true),window.removeEventListener("keydown",q);}},[d]),!e||o)return null;let a=e.getSelectedTable();if(!a)return null;let L=e.getTableSelection();if(!L||L.shapeId!==a.id)return null;let w=e.getTableScreenRect(a.id);if(!w)return null;let f=a.cells.length,u=a.cells[0]?.length??0,p=tableExpandRangeToMerges(a,L.anchor.row,L.anchor.col,L.focus.row,L.focus.col),{r1:M,c1:O,r2:I,c2:y}=p,k=tableCoveredMap(a.cells),T=0;for(let E=M;E<=I;E++)for(let q=O;q<=y;q++)k[E]?.[q]||T++;let b=T>1,m=tableRangeHasMerge(a,M,O,I,y),C=M===I?`${M+1}`:`${M+1}\u2013${I+1}`,g=O===y?`${O+1}`:`${O+1}\u2013${y+1}`,x=f-(I-M+1)>=1,U=u-(y-O+1)>=1,A=w.y>56?w.y-40:w.y+w.height+10,ue=E=>E.stopPropagation(),ee=E=>()=>{E(),s(null);};return jsxs("div",{className:"drawui-table-toolbar","data-table-toolbar":a.id,style:{left:w.x+w.width/2,top:A},onPointerDown:ue,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 ${d==="row"?"active":""}`,"data-table-insert-row":true,title:`${t("table.insertRowAbove")} / ${t("table.insertRowBelow")}`,onClick:()=>s(d==="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"})})}),d==="row"&&jsxs("div",{className:"drawui-table-menu",ref:l,"data-table-row-menu":true,children:[jsx("button",{onClick:ee(()=>e.insertTableRowRelative(a.id,"above")),children:t("table.insertRowAbove")}),jsx("button",{onClick:ee(()=>e.insertTableRowRelative(a.id,"below")),children:t("table.insertRowBelow")})]})]}),jsx("button",{title:`${t("table.deleteRow")} \xB7 ${C}`,disabled:!x,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 ${d==="col"?"active":""}`,"data-table-insert-col":true,title:`${t("table.insertColLeft")} / ${t("table.insertColRight")}`,onClick:()=>s(d==="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"})})}),d==="col"&&jsxs("div",{className:"drawui-table-menu",ref:l,"data-table-col-menu":true,children:[jsx("button",{onClick:ee(()=>e.insertTableColumnRelative(a.id,"left")),children:t("table.insertColLeft")}),jsx("button",{onClick:ee(()=>e.insertTableColumnRelative(a.id,"right")),children:t("table.insertColRight")})]})]}),jsx("button",{title:`${t("table.deleteCol")} \xB7 ${g}`,disabled:!U,onClick:()=>e.deleteTableColsInSelection(a.id),children:t("table.deleteCol")}),jsx("button",{title:t("table.merge"),disabled:!b,onClick:()=>e.mergeTableCells(a.id),children:t("table.merge")}),jsx("button",{title:t("table.split"),disabled:!m,onClick:()=>e.splitTableCells(a.id),children:t("table.split")})]})});var po=[...MINDMAP_COLORS,"#1f2937","#9ca3af"],ho=["\u{1F4A1}","\u2B50","\u{1F525}","\u{1F4CC}","\u2705","\u2757","\u26A0\uFE0F","\u{1F3F7}\uFE0F"],Dr={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"},zt={fontSize:11,color:"#6b7280",marginBottom:4,display:"block"},Tt={display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},_t={border:"1px solid #e5e7eb",background:"#ffffff",borderRadius:5,padding:"3px 6px",fontSize:12,color:"#374151",cursor:"pointer",lineHeight:1.5,whiteSpace:"nowrap"},hn={width:"100%",border:"1px solid #e5e7eb",borderRadius:5,padding:"4px 8px",fontSize:12,outline:"none",boxSizing:"border-box",background:"#ffffff",color:"#1f2937"},yo=memo(function({editor:e,mindMap:o}){let[,i]=useState(0);V(),useEffect(()=>{if(!e)return;let b=e.subscribe(()=>i(m=>m+1));return ()=>{b();}},[e]);let d=useRef(null);if(!e||!o||e.getMindMapEditingShapeId()!==o.id)return null;let s=e.getMindMapSelectedNode();if(!s||s.shapeId!==o.id)return null;let l=b=>{if(b.id===s.nodeId)return b;for(let m of b.children??[]){let C=l(m);if(C)return C}return null},a=l(o.root);if(!a)return null;let L=e.getCamera(),f=layoutMindMap(o.root).positions.get(a.id);if(!f)return null;let u=L.zoom,p=L.pageToScreen({x:o.x+f.x,y:o.y+f.y}),M=p.x+f.width*u/2+14,O=p.y-80,y=Math.max(8,Math.min(M,(window.innerWidth||1024)-232-8)),k=Math.max(8,Math.min(O,(window.innerHeight||768)-320)),T=b=>{e.updateMindMapNode(o.id,a.id,b);};return jsxs("div",{ref:d,style:{...Dr,left:y,top:k},onMouseDown:b=>b.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")}),jsxs("span",{style:{display:"flex",alignItems:"center",gap:2},children:[!!a.children?.length&&jsx("button",{style:{..._t,padding:"1px 5px",color:"#6b7280"},"data-drawui-tip":a.collapsed?t("mindmap.expand"):t("mindmap.collapse"),onClick:()=>e.toggleMindMapCollapse(o.id,a.id),children:a.collapsed?t("mindmap.expand"):t("mindmap.collapse")}),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:{...hn,marginBottom:8},value:a.text,onChange:b=>T({text:b.target.value}),spellCheck:false}),jsx("span",{style:zt,children:t("mindmap.level")}),jsxs("div",{style:{...Tt,marginBottom:10,justifyContent:"flex-start"},children:[jsx("button",{style:{..._t,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,a.id,1),onClick:()=>e.promoteMindMapNode(o.id,a.id,1),"data-drawui-tip":e.canPromoteMindMapNode(o.id,a.id,1)?t("mindmap.promote1"):t("mindmap.promoteDisabled"),children:t("mindmap.promote1")}),jsx("button",{style:{..._t,color:"#3b82f6",borderColor:"#bfdbfe"},disabled:!e.canPromoteMindMapNode(o.id,a.id,2),onClick:()=>e.promoteMindMapNode(o.id,a.id,2),"data-drawui-tip":e.canPromoteMindMapNode(o.id,a.id,2)?t("mindmap.promote2"):t("mindmap.promoteDisabled"),children:t("mindmap.promote2")})]}),jsx("div",{style:{...Tt,gap:4,marginBottom:10,flexWrap:"nowrap",justifyContent:"flex-end"},children:jsx("button",{style:{..._t,color:"#ef4444",borderColor:"#fecaca"},onClick:()=>e.deleteMindMapNode(o.id,a.id),children:t("mindmap.deleteNode")})}),jsx("span",{style:zt,children:t("mindmap.color")}),jsxs("div",{style:{...Tt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":t("mindmap.levelColor"),onClick:()=>T({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}}),po.map(b=>jsx("button",{"data-drawui-tip":b,onClick:()=>T({color:b}),style:{width:18,height:18,borderRadius:4,border:a.color===b?"2px solid #111827":"1px solid #d1d5db",background:b,cursor:"pointer",flexShrink:0}},b))]}),jsx("span",{style:zt,children:t("mindmap.icon")}),jsxs("div",{style:{...Tt,marginBottom:10},children:[jsx("button",{"data-drawui-tip":t("mindmap.noIcon"),onClick:()=>T({icon:void 0}),style:{width:22,height:22,borderRadius:4,border:a.icon?"1px solid #d1d5db":"2px solid #111827",background:"#f9fafb",cursor:"pointer",fontSize:11,color:"#9ca3af",lineHeight:1},children:"\u2205"}),ho.map(b=>jsx("button",{onClick:()=>T({icon:b}),style:{width:22,height:22,borderRadius:4,border:a.icon===b?"2px solid #111827":"1px solid #d1d5db",background:"#f9fafb",cursor:"pointer",fontSize:13,lineHeight:1},children:b},b)),jsx("input",{placeholder:"\u270F\uFE0F",defaultValue:a.icon&&!ho.includes(a.icon)?a.icon:"",onKeyDown:b=>{if(b.key==="Enter"){let m=b.target.value.trim();T({icon:m||void 0});}},onBlur:b=>{let m=b.target.value.trim();m!==a.icon&&T({icon:m||void 0});},style:{...hn,width:56,padding:"2px 4px",textAlign:"center"}})]}),jsx("span",{style:zt,children:t("mindmap.note")}),jsx("input",{style:{...hn,marginBottom:6},value:a.note??"",placeholder:t("mindmap.notePlaceholder"),onChange:b=>T({note:b.target.value||void 0}),spellCheck:false}),!!a.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:()=>T({noteColor:void 0}),style:{width:16,height:16,borderRadius:3,border:a.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"}}),po.map(b=>jsx("button",{onClick:()=>T({noteColor:b}),style:{width:16,height:16,borderRadius:3,border:a.noteColor===b?"2px solid #111827":"1px solid #d1d5db",background:b,cursor:"pointer"}},b))]})]})});var mn=220,fn=140,Ur="#fafafa";function Gr(t,e){let o=Math.min(t.x,e.x),i=Math.min(t.y,e.y),d=Math.max(t.x+t.width,e.x+e.width),s=Math.max(t.y+t.height,e.y+e.height);return {x:o,y:i,width:d-o,height:s-i}}function Zr(t){return {x:t.x+t.width/2,y:t.y+t.height/2}}function Fr(){return {x:0,y:0,width:0,height:0}}function Vr(t){let e=1/0,o=1/0,i=-1/0,d=-1/0,s=false;for(let l of t){let a=bn(l);a&&(s=true,a.x<e&&(e=a.x),a.y<o&&(o=a.y),a.x+a.width>i&&(i=a.x+a.width),a.y+a.height>d&&(d=a.y+a.height));}return s?{x:e,y:o,width:i-e,height:d-o}:null}function bn(t){switch(t.type){case "rectangle":case "sticky-note":case "icon":case "image":case "rounded-rectangle":case "ellipse":case "diamond":case "triangle":case "hexagon":case "parallelogram":case "trapezoid":case "pentagon":case "octagon":case "star":case "cylinder":case "cloud":case "heart":case "block-arrow-right":case "block-arrow-left":case "block-arrow-up":case "block-arrow-down":case "block-arrow-double":case "right-triangle":case "cross":case "speech-rect":case "speech-round":case "cube":case "sector":case "delay":case "predefined-process":case "document":case "stadium":case "class-catalog":case "chevron":case "brace-left":case "brace-right":case "envelope":case "checkbox":case "triangular-pyramid":case "quadrangular-pyramid":case "cuboid":case "sphere":case "ellipsoid":case "pie":case "hollow-pie":case "uml-class":case "uml-interface":case "mind-map":case "table":case "text":return {x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height};case "circle":return {x:t.x-t.radius,y:t.y-t.radius,width:t.radius*2,height:t.radius*2};case "line":case "arrow":{let e=t.points;if(!e||e.length===0)return null;let o=1/0,i=1/0,d=-1/0,s=-1/0;for(let l of e)l.x<o&&(o=l.x),l.y<i&&(i=l.y),l.x>d&&(d=l.x),l.y>s&&(s=l.y);return {x:o,y:i,width:d-o,height:s-i}}case "draw":{let e=t,o=e.width,i=e.height;if(typeof o=="number"&&typeof i=="number")return {x:e.x-o/2,y:e.y-i/2,width:o,height:i};let d=e.points;if(!d||d.length===0)return null;let s=1/0,l=1/0,a=-1/0,L=-1/0;for(let w of d){let f=w.x+e.x,u=w.y+e.y;f<s&&(s=f),u<l&&(l=u),f>a&&(a=f),u>L&&(L=u);}return {x:s,y:l,width:a-s,height:L-l}}default:return null}}function Yr(t){let e=t.getCamera(),o=e.screenToPage({x:0,y:0}),i=e.screenToPage({x:window.innerWidth,y:window.innerHeight});return {x:o.x,y:o.y,width:i.x-o.x,height:i.y-o.y}}function jr(t,e,o){if(t.width<=0||t.height<=0)return {x:t.x-e/2,y:t.y-o/2,width:e,height:o};let i=e/o,d=t.width,s=d/i;s<t.height&&(s=t.height,d=s*i);let l=Zr(t);return {x:l.x-d/2,y:l.y-s/2,width:d,height:s}}function gn(t,e,o,i){let d=(t-o.left)/o.width,s=(e-o.top)/o.height;return {x:i.x+d*i.width,y:i.y+s*i.height}}var go=memo(function({editor:e}){let o=useRef(null),i=useRef(null),[d,s]=useState(false),[l,a]=useState(100),[L,w]=useState(false),[f,u]=useState(false);V();let p=useRef(null),M=useRef(null);useLayoutEffect(()=>{let m=o.current,C=i.current;if(!m||!C)return;let g=window.devicePixelRatio||1;m.width=Math.round(mn*g),m.height=Math.round(fn*g),m.style.width=`${mn}px`,m.style.height=`${fn}px`;},[d]);let O=useCallback(()=>{let m=o.current,C=i.current;if(!m||!C||!e)return;let g=m.getContext("2d");if(!g)return;let x=mn,U=fn,P=m.width,A=m.height,ue=e.getShapes(),ee=new Set(e.getSelectedIds()),E=getTheme(),q=hexToRgba(E.text,.16),pe=E.primary,S=hexToRgba(E.primary,.18),se=hexToRgba(E.primary,.85),ve=Vr(ue),$=Yr(e),G=ve?Gr(ve,$):$.width>0?$:Fr(),xe=jr(G,x,U);M.current=xe;let ke=P/xe.width,$e=A/xe.height,Ne=x/xe.width;g.setTransform(1,0,0,1,0,0),g.fillStyle=Ur,g.fillRect(0,0,P,A),g.setTransform(ke,0,0,$e,-ke*xe.x,-$e*xe.y),g.fillStyle=q;for(let Y of ue){let H=bn(Y);H&&g.fillRect(H.x,H.y,H.width,H.height);}g.fillStyle=pe;for(let Y of ue){if(!ee.has(Y.id))continue;let H=bn(Y);H&&g.fillRect(H.x,H.y,H.width,H.height);}g.fillStyle=S,g.fillRect($.x,$.y,$.width,$.height);let Fe=1.5/Ne;g.strokeStyle=se,g.lineWidth=Fe,g.lineJoin="round";let _e=Math.min($.width/6,$.height/6,6/Ne);if(g.beginPath(),_e*Ne<1)g.rect($.x,$.y,$.width,$.height);else {let Y=$.x,H=$.y,Ce=$.width,fe=$.height,te=Math.min(_e,Ce/2,fe/2);g.moveTo(Y+te,H),g.lineTo(Y+Ce-te,H),g.quadraticCurveTo(Y+Ce,H,Y+Ce,H+te),g.lineTo(Y+Ce,H+fe-te),g.quadraticCurveTo(Y+Ce,H+fe,Y+Ce-te,H+fe),g.lineTo(Y+te,H+fe),g.quadraticCurveTo(Y,H+fe,Y,H+fe-te),g.lineTo(Y,H+te),g.quadraticCurveTo(Y,H,Y+te,H),g.closePath();}g.stroke(),g.setTransform(1,0,0,1,0,0);},[e]);useEffect(()=>{if(!e||d)return;O();let m=e.subscribe(O),C=subscribeTheme(O),g=()=>O();return window.addEventListener("resize",g),()=>{m(),C(),window.removeEventListener("resize",g);}},[e,d,O]),useEffect(()=>{if(!e)return;let m=()=>{let g=e.getCamera().getZoom();a(Math.round(g*100));};m();let C=e.subscribe(m);return ()=>{C();}},[e]);let I=useCallback((m,C)=>{if(!e)return;let g=e.getCamera(),x=g.getZoom(),U=window.innerWidth/2,P=window.innerHeight/2,A=g;A.x=U-m*x,A.y=P-C*x,e.requestRender();},[e]),y=m=>{if(!e||!i.current||m.button!==0)return;let C=i.current.getBoundingClientRect(),g=M.current;if(!g)return;let x=gn(m.clientX,m.clientY,C,g);p.current={pointerId:m.pointerId,rect:{left:C.left,top:C.top,width:C.width,height:C.height},canvasBox:g},m.currentTarget.setPointerCapture(m.pointerId),u(true),I(x.x,x.y);},k=m=>{if(!f||!e||!p.current||!i.current)return;let C=p.current,g=gn(m.clientX,m.clientY,C.rect,C.canvasBox);I(g.x,g.y);},T=m=>{if(f){u(false),p.current=null;try{m.currentTarget.releasePointerCapture(m.pointerId);}catch{}}},b=m=>{if(!e||!i.current)return;let C=M.current;if(!C)return;let g=i.current.getBoundingClientRect(),x=gn(m.clientX,m.clientY,g,C);I(x.x,x.y);};return jsxs("div",{className:`drawui-minimap ${d?"collapsed":""}`,children:[jsx("button",{className:"drawui-minimap-toggle",onClick:()=>s(m=>!m),"data-drawui-tip":d?t("minimap.expand"):t("minimap.collapse"),"data-drawui-tip-pos":"top","aria-label":d?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:d?jsx("polyline",{points:"9 6 15 12 9 18"}):jsx("polyline",{points:"15 6 9 12 15 18"})})}),!d&&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:[l,"%"]})]}),jsx("div",{ref:i,className:"drawui-minimap-canvas-wrap",style:{cursor:f?"grabbing":L?"pointer":"default"},onPointerEnter:()=>w(true),onPointerLeave:()=>w(false),children:jsx("canvas",{ref:o,className:"drawui-minimap-canvas",onPointerDown:y,onPointerMove:k,onPointerUp:T,onPointerCancel:T,onDoubleClick:b})})]})]})});var Te=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}),Jr=[{type:"rectangle",labelKey:"shape.rectangle",glyph:Te(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"1"}))},{type:"rounded-rectangle",labelKey:"shape.rounded-rectangle",glyph:Te(jsx("rect",{x:"4",y:"7",width:"16",height:"10",rx:"4"}))},{type:"circle",labelKey:"shape.circle",glyph:Te(jsx("circle",{cx:"12",cy:"12",r:"5.5"}))},{type:"ellipse",labelKey:"shape.ellipse",glyph:Te(jsx("ellipse",{cx:"12",cy:"12",rx:"7",ry:"4.5"}))},{type:"diamond",labelKey:"shape.diamond",glyph:Te(jsx("path",{d:"M12 5 L19 12 L12 19 L5 12 Z"}))},{type:"triangle",labelKey:"shape.triangle",glyph:Te(jsx("path",{d:"M12 4 L20 19 H4 Z"}))},{type:"hexagon",labelKey:"shape.hexagon",glyph:Te(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:Te(jsx("path",{d:"M6 7 L19 7 L16 17 H7 Z"}))},{type:"trapezoid",labelKey:"shape.trapezoid",glyph:Te(jsx("path",{d:"M7 6 H17 L20 18 H4 Z"}))},{type:"pentagon",labelKey:"shape.pentagon",glyph:Te(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:Te(jsx("path",{d:"M8 4 H16 L20 8 V16 L16 20 H8 L4 16 V8 Z"}))},{type:"star",labelKey:"shape.star",glyph:Te(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:Te(jsxs(Fragment,{children:[jsx("path",{d:"M4 4h16v11l-5 5H4Z"}),jsx("path",{d:"M20 15h-5v5"})]}))},{type:"uml-class",labelKey:"shape.uml-class",glyph:Te(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:Te(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:Te(jsxs(Fragment,{children:[jsx("rect",{x:"2.2",y:"9",width:"6.6",height:"6",rx:"2"}),jsx("rect",{x:"15.4",y:"3.8",width:"6.4",height:"5.2",rx:"1.8"}),jsx("rect",{x:"15.4",y:"15",width:"6.4",height:"5.2",rx:"1.8"}),jsx("path",{d:"M8.8 12 C 12.2 12 12.2 6.4 15.4 6.4"}),jsx("path",{d:"M8.8 12 C 12.2 12 12.2 17.6 15.4 17.6"})]}))}];function bo({editor:t$1,x:e,y:o,context:i,existingArrowId:d,defaultShapeType:s,onClose:l}){let a=useRef(null);V();let L=w=>{t$1?.createGeneratedConnection(i,{type:w,existingArrowId:d}),l();};return useEffect(()=>{let w=p=>{a.current&&!a.current.contains(p.target)&&l();},f=p=>{p.key==="Escape"&&(p.preventDefault(),l());},u=setTimeout(()=>{window.addEventListener("pointerdown",w,true),window.addEventListener("keydown",f,true);},0);return ()=>{clearTimeout(u),window.removeEventListener("pointerdown",w,true),window.removeEventListener("keydown",f,true);}},[l]),jsxs("div",{className:"drawui-gen-menu",ref:a,style:{left:e,top:o},children:[jsx("div",{className:"drawui-gen-menu-label",children:t("menu.title")}),jsx("div",{className:"drawui-gen-shape-grid",children:Jr.map(w=>jsxs("button",{className:`drawui-gen-shape-btn${w.type===s?" drawui-gen-shape-active":""}`,onClick:()=>L(w.type),"data-drawui-tip":t(w.labelKey),children:[w.glyph,jsx("span",{className:"drawui-gen-shape-label",children:t(w.labelKey)})]},w.type))}),jsx("div",{className:"drawui-gen-menu-hint",children:t("menu.cancel")})]})}var ta=typeof navigator<"u"&&/mac|iphone|ipad/i.test(navigator.platform||navigator.userAgent);function ze(t){if(ta)switch(t){case "copy":return "\u2318C";case "copyAsImage":return "\u21E7\u2318C";case "paste":return "\u2318V";case "duplicate":return "\u2318D";case "copyStyle":return "\u2325\u2318C";case "pasteStyle":return "\u2325\u2318V";case "lock":return "\u2325\u2318L";case "delete":return "\u232B";case "group":return "\u2318G";case "ungroup":return "\u21E7\u2318G"}switch(t){case "copy":return "Ctrl + C";case "copyAsImage":return "Ctrl + Shift + C";case "paste":return "Ctrl + V";case "duplicate":return "Ctrl + D";case "copyStyle":return "Ctrl + Alt + C";case "pasteStyle":return "Ctrl + Alt + V";case "lock":return "Ctrl + Alt + L";case "delete":return "Del";case "group":return "Ctrl + G";case "ungroup":return "Ctrl + Shift + G"}}var vo={sep:true},na=t=>"sep"in t&&t.sep===true;function xo({editor:t$1,pos:e,onClose:o}){V();let[,i]=useState(0),d=useRef(null),[s,l]=useState(null),[a,L]=useState(null);useEffect(()=>{let x=t$1.subscribe(()=>i(U=>U+1));return ()=>{x();}},[t$1]),useLayoutEffect(()=>{let x=d.current;if(!x)return;let U=x.getBoundingClientRect(),P=Math.max(8,Math.min(e.x,window.innerWidth-U.width-8)),A=Math.max(8,Math.min(e.y,window.innerHeight-U.height-8));l({left:P,top:A});},[e.x,e.y]),useEffect(()=>{let x=A=>{d.current&&!d.current.contains(A.target)&&o();},U=A=>{A.key==="Escape"&&(A.preventDefault(),o());},P=setTimeout(()=>{window.addEventListener("pointerdown",x,true),window.addEventListener("keydown",U,true);},0);return ()=>{clearTimeout(P),window.removeEventListener("pointerdown",x,true),window.removeEventListener("keydown",U,true);}},[o]);let w=t$1.getSelectedIds(),f=w.length>0,u=e.shapeId,p=u?t$1.isShapeLocked(u):false,M=f&&!p&&t$1.hasCopiedStyle(),O=t$1.hasClipboard(),I=f&&!p,y=f&&!p?t$1.getSelectedGroupId():null,k=f&&!p&&w.length>=2&&!y,b=(u?t$1.getShapes().find(x=>x.id===u):void 0)?.groupId??null,m=y?true:!!b&&!p,C=x=>()=>{x(),o();},g;return p?g=b?[{key:"ctx.ungroup",shortcut:ze("ungroup"),action:C(()=>b&&t$1.ungroupIds([b]))}]:[{key:"ctx.unlock",action:()=>u&&t$1.setShapeLocked(u,false)}]:f?g=[{key:"ctx.copy",shortcut:ze("copy"),action:C(()=>t$1.copySelected())},{key:"ctx.copyAsImage",shortcut:ze("copyAsImage"),action:C(()=>{t$1.copySelectedAsImage();})},{key:"ctx.paste",shortcut:ze("paste"),disabled:!O,action:C(()=>t$1.paste())},{key:"ctx.duplicate",shortcut:ze("duplicate"),action:C(()=>t$1.duplicateSelected())},{key:"ctx.layer",submenu:[{key:"ctx.bringToFront",disabled:!I,action:()=>t$1.bringToFront()},{key:"ctx.bringForward",disabled:!I,action:()=>t$1.bringForward()},{key:"ctx.sendBackward",disabled:!I,action:()=>t$1.sendBackward()},{key:"ctx.sendToBack",disabled:!I,action:()=>t$1.sendToBack()}]},{key:"ctx.copyStyle",shortcut:ze("copyStyle"),action:C(()=>t$1.copyStyle())},{key:"ctx.pasteStyle",shortcut:ze("pasteStyle"),disabled:!M,action:C(()=>t$1.pasteStyle())},vo,{key:"ctx.rotate",submenu:[{key:"ctx.rotate90",action:()=>t$1.rotateSelected(90)},{key:"ctx.rotate180",action:()=>t$1.rotateSelected(180)},{key:"ctx.rotate270",action:()=>t$1.rotateSelected(270)}]},y?{key:"ctx.ungroup",shortcut:ze("ungroup"),disabled:!m,action:C(()=>t$1.ungroupSelected())}:{key:"ctx.group",shortcut:ze("group"),disabled:!k,action:C(()=>t$1.groupSelected())},vo,{key:"ctx.lock",shortcut:ze("lock"),action:C(()=>t$1.setSelectedShapesLocked(true))},{key:"ctx.delete",shortcut:ze("delete"),action:C(()=>t$1.deleteSelected())}]:g=[{key:"ctx.paste",shortcut:ze("paste"),disabled:!O,action:C(()=>t$1.paste())}],jsx("div",{ref:d,className:"drawui-context-menu",style:s?{left:s.left,top:s.top}:{visibility:"hidden",left:e.x,top:e.y},onContextMenu:x=>x.preventDefault(),children:g.map((x,U)=>na(x)?jsx("div",{className:"drawui-context-sep"},`sep-${U}`):x.submenu?jsxs("div",{className:"drawui-context-sub",onMouseEnter:()=>L(x.key),onMouseLeave:()=>L(null),children:[jsxs("button",{type:"button",className:"drawui-context-item",disabled:x.disabled,children:[jsx("span",{children:t(x.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"})})]}),a===x.key&&jsx("div",{className:"drawui-context-submenu",children:x.submenu.map(P=>jsx("button",{type:"button",className:"drawui-context-item",disabled:P.disabled,onClick:()=>{P.action(),o();},children:jsx("span",{children:t(P.key)})},P.key))})]},x.key):jsxs("button",{type:"button",className:"drawui-context-item",disabled:x.disabled,onClick:x.action,children:[jsx("span",{children:t(x.key)}),x.shortcut&&jsx("span",{className:"drawui-context-kbd",children:x.shortcut})]},x.key))})}var ca={select:"tool.select",hand:"tool.hand",rectangle:"tool.rectangle","rounded-rectangle":"tool.rounded-rectangle",circle:"tool.circle",ellipse:"tool.ellipse",diamond:"tool.diamond",triangle:"tool.triangle",hexagon:"tool.hexagon",parallelogram:"tool.parallelogram",trapezoid:"tool.trapezoid",pentagon:"tool.pentagon",octagon:"tool.octagon",star:"tool.star",cylinder:"tool.cylinder",cloud:"tool.cloud",heart:"tool.heart","block-arrow-right":"tool.block-arrow-right","block-arrow-left":"tool.block-arrow-left","block-arrow-up":"tool.block-arrow-up","block-arrow-down":"tool.block-arrow-down","block-arrow-double":"tool.block-arrow-double","right-triangle":"tool.right-triangle",cross:"tool.cross","speech-rect":"tool.speech-rect","speech-round":"tool.speech-round",cube:"tool.cube",sector:"tool.sector",delay:"tool.delay","predefined-process":"tool.predefined-process",document:"tool.document",stadium:"tool.stadium","class-catalog":"tool.class-catalog",chevron:"tool.chevron","brace-left":"tool.brace-left","brace-right":"tool.brace-right",envelope:"tool.envelope",checkbox:"tool.checkbox","sticky-note":"tool.sticky-note",icon:"toolbar.icon","triangular-pyramid":"tool.triangular-pyramid","quadrangular-pyramid":"tool.quadrangular-pyramid",cuboid:"tool.cuboid",sphere:"tool.sphere",ellipsoid:"tool.ellipsoid",pie:"tool.pie","hollow-pie":"tool.hollow-pie","uml-class":"tool.uml-class","uml-interface":"tool.uml-interface",line:"tool.line",arrow:"tool.arrow",text:"tool.text",draw:"tool.draw",pen:"tool.pen",highlighter:"tool.highlighter",eraser:"tool.eraser","mind-map":"tool.mind-map",table:"tool.table",image:"tool.image"};function kn(t$1){let e=t$1 instanceof Error?t$1.message:String(t$1);return e.startsWith("image.tooLarge")?t("image.tooLarge"):`${t("image.uploadFailed")}\uFF1A${e}`}function da({initialTool:t$1="select",className:e="",themeColor:o,theme:i,onThemeChange:d,language:s="zh-CN",data:l,onChange:a,onReady:L,imageUpload:w}){let f=useRef(null),u=useRef(null),p=useRef(null),[M,O]=useState(null);V();let[I,y]=useState(t$1),[k,T]=useState(false),[b,m]=useState(0),[C,g]=useState(false),[x,U]=useState("straight"),[P,A]=useState("end"),[ue,ee]=useState(false),[E,q]=useState(void 0),[pe,S]=useState(100),[se,ve]=useState(null),[$,G]=useState(null),[xe,ke]=useState(false),[$e,Ne]=useState(false),[Fe,_e]=useState(false),[Y,H]=useState(null),[Ce,fe]=useState(null),[te,De]=useState(false),[X,Ee]=useState(null),[He,tt]=useState(null),K=useRef(null),Ve=useRef(0),Le=useRef(null),v=useRef(a);v.current=a;let D=useRef(L);D.current=L,useEffect(()=>{if(!f.current)return;let h=new Editor(f.current,{theme:o?{primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:hexToRgba(o,.1),shadow:o}}:void 0,language:s,shapes:l,persist:!l,imageUpload:w});p.current=h,O(h),window.__drawuiEditor=h,h.setHighlighterColor(Et()),h.setStickyNoteColor(It()),D.current?.(h),t$1&&h.setActiveTool(t$1);let R=h.subscribe(()=>{y(h.getActiveTool());let z=h.getSelectedIds();m(z.length);let Re=h.getShapes().filter(Xe=>z.includes(Xe.id)&&(Xe.type==="line"||Xe.type==="arrow"));if(g(Re.length>0),Re.length>0&&Re[0].connectionType?U(Re[0].connectionType):Re.length>0&&U("straight"),Re.length>0){let Xe=Re.find(jt=>jt.type==="arrow");Xe&&(A(Xe.arrowHead??"end"),ee(Xe.dashed??false));}S(Math.round(h.getCamera().getZoom()*100)),q(h.getArrowStyle()),Ne(h.canUndo()),_e(h.canRedo());let je=h.getSelectedUml();H(je),je||Ee(null);let ot=h.getSelectedMindMap();fe(ot),h.getMindMapEditingShapeId()||De(false),v.current?.(h.getData());}),he=h.subscribeNotifications(z=>{G({type:"success",text:z}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);}),Ae=h.subscribeUi(z=>{if(z.kind==="imageError"){G({type:"error",text:kn(z.message)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);return}if(z.kind==="drag"){ke(z.active);return}z.kind==="shapeTypeMenu"&&tt({x:z.screenX,y:z.screenY,context:z.context,existingArrowId:z.existingArrowId,defaultShapeType:z.defaultShapeType});});return ()=>{R(),he(),Ae(),K.current&&clearTimeout(K.current),cancelAnimationFrame(Ve.current),h.dispose();}},[t$1]),useEffect(()=>{if(!o)return;let h=u.current;h&&(h.style.setProperty("--dw-primary",o),h.style.setProperty("--dw-primary-hover",shadeColor(o,-0.12)),h.style.setProperty("--dw-primary-weak",hexToRgba(o,.1)),h.style.setProperty("--dw-primary-contrast","#ffffff"),h.style.setProperty("--dw-shadow-primary",`0 2px 8px ${hexToRgba(o,.3)}`)),p.current?.setTheme({primary:o,editBorder:o,selection:{outline:o,handleStroke:o,handleFill:"#ffffff",outlineFill:hexToRgba(o,.1),shadow:o}});},[o]);let[_,W]=useState(i??DEFAULT_PAGE_THEME),J=i??_,le=useCallback(h=>{W(h),d?.(h);},[d]);useEffect(()=>{document.documentElement.setAttribute("data-theme",J),setTheme({grid:PAGE_THEMES[J].grid}),p.current?.requestRender();},[J]),useEffect(()=>{setLanguage(s),p.current?.setLanguage(s);},[s]);let Ye=useCallback(h=>{p.current?.setActiveTool(h);},[]),Ie=useCallback(()=>{p.current?.zoomIn();},[]),j=useCallback(()=>{p.current?.zoomOut();},[]),Be=useCallback(()=>{p.current?.resetZoom();},[]),nt=useCallback(()=>{let h=!k;T(h),p.current?.setShowGrid(h);},[k]),We=useCallback(()=>{p.current?.undo();},[]),ge=useCallback(()=>{p.current?.redo();},[]),ut=useCallback(h=>{p.current?.downloadImage("drawui",h,{background:"#ffffff"});},[]),c=useCallback(()=>{p.current?.downloadJSON("drawui-data");},[]),r=useCallback(h=>{let R=new FileReader;R.onload=()=>{let he=typeof R.result=="string"?R.result:"";if(p.current?.importJSON(he)??false){let z=p.current?.getShapes().length??0;G({type:"success",text:t("import.success",{n:z})});}else G({type:"error",text:t("import.fail")});K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);},R.onerror=()=>{G({type:"error",text:t("import.fail")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),3500);},R.readAsText(h,"utf-8");},[]),Z=useCallback(h=>{let R=p.current,he=f.current;if(!R||!he)return;if(R.isPointerDown()){Le.current!==null&&(Le.current=null,ve(null));return}let Ae=h.clientX,z=h.clientY;cancelAnimationFrame(Ve.current),Ve.current=requestAnimationFrame(()=>{let Ue=he.getBoundingClientRect(),Re=Ae-Ue.left,je=z-Ue.top,ot=Re+12,Xe=je+12,jt=R.getSelectedUml()?.id,ht=R.getUmlRowAtScreenPoint({x:Re,y:je});if(ht&&ht.shape.id!==jt&&ht.text&&R.isUmlRowTextTruncated(ht)){Le.current!==ht.text&&(Le.current=ht.text,ve({text:ht.text,x:ot,y:Xe}));return}let bt=R.getShapeAtScreenPoint({x:Re,y:je});bt&&bt.text&&R.isShapeTextTruncated(bt.id)?Le.current!==bt.text&&(Le.current=bt.text,ve({text:bt.text,x:ot,y:Xe})):Le.current!==null&&(Le.current=null,ve(null));});},[]),ce=useCallback(()=>{ve(null);},[]),ne=useCallback(h=>{let R=p.current,he=f.current;if(!R||!he)return;let Ae=he.getBoundingClientRect(),z=h.clientX-Ae.left,Ue=h.clientY-Ae.top,Re=R.getUmlRowAtScreenPoint({x:z,y:Ue});if(Re){Ee(Re.shape.id);return}let je=R.getMindMapNodeAtScreenPoint({x:z,y:Ue});if(je){R.beginMindMapEdit(je.shapeId,je.nodeId);return}let ot=R.getTableAtScreenPoint({x:z,y:Ue});ot&&R.beginTableEdit(ot.shapeId,ot.row,ot.col);},[]),pt=useCallback(()=>{tt(null);},[]),[xt,Cn]=useState(null),ko=useCallback(()=>Cn(null),[]),Co=useCallback(h=>{h.preventDefault();let R=p.current,he=f.current;if(!R||!he||R.isEditing())return;let Ae=he.getBoundingClientRect(),z=R.getShapeAtScreenPoint({x:h.clientX-Ae.left,y:h.clientY-Ae.top});z?R.isShapeLocked(z.id)?R.selectShapeRaw(z.id):R.getSelectedIds().includes(z.id)||R.selectShape(z.id,h.shiftKey):R.selectShape("",false),Cn({x:h.clientX,y:h.clientY,shapeId:z?.id??null});},[]),So=useCallback(h=>{h.preventDefault();},[]);return jsxs("div",{ref:u,className:`drawui-canvas-board ${e}`,onContextMenu:So,onDragOver:h=>{h.dataTransfer?.types?.includes("Files")&&(h.preventDefault(),h.dataTransfer.dropEffect="copy");},onDrop:h=>{let R=Array.from(h.dataTransfer?.files||[]).filter(Ue=>(Ue.type||"").startsWith("image/"));if(!R.length)return;h.preventDefault();let he=p.current;if(!he)return;let Ae=h.currentTarget.getBoundingClientRect(),z=he.getCamera().screenToPage({x:h.clientX-Ae.left,y:h.clientY-Ae.top});he.insertImageFiles(R,z).then(()=>{!he.hasImageUploader()&&he.hasTemporaryImages()&&(G({type:"success",text:t("image.temporaryInserted")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3));}).catch(Ue=>{G({type:"error",text:kn(Ue)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);});},children:[jsx("canvas",{ref:f,className:"drawui-canvas",onMouseMove:Z,onMouseLeave:ce,onDoubleClick:ne,onContextMenu:Co}),se&&jsx("div",{className:"drawui-tooltip",style:{left:se.x,top:se.y},children:se.text}),jsx(sn,{activeTool:I,onToolChange:Ye,showGrid:k,onToggleGrid:nt,pageTheme:J,onPageThemeChange:le,canUndo:$e,canRedo:Fe,onUndo:We,onRedo:ge,onExport:ut,onExportData:c,onImportData:r,onHighlighterColorChange:h=>p.current?.setHighlighterColor(h),onStickyNoteColorChange:h=>p.current?.setStickyNoteColor(h),onInsertIcon:h=>p.current?.insertIcon(h),onInsertTable:(h,R)=>p.current?.insertTable(h,R),onInsertImage:h=>{let R=p.current;R&&R.insertImageFiles(h).then(()=>{!R.hasImageUploader()&&R.hasTemporaryImages()&&(G({type:"success",text:t("image.temporaryInserted")}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3));}).catch(he=>{G({type:"error",text:kn(he)}),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>G(null),4e3);});},arrowStyle:E,onArrowStyleChange:h=>p.current?.setArrowStyle(h),hidden:xe}),jsx(cn,{onZoomIn:Ie,onZoomOut:j,onReset:Be,zoomLevel:pe}),jsx(Yn,{editor:M,selectedCount:b,hasLineSelection:C,currentConnectionType:x,currentArrowHead:P,currentDashed:ue,hidden:xe}),jsx(eo,{editor:M,umlClass:Y,editing:X}),jsx(uo,{editor:M,hidden:xe}),jsx(so,{editor:M,panelOpen:te}),jsx(ro,{editor:M,panelOpen:te,onOpenPanel:()=>De(true)}),te&&jsx(yo,{editor:M,mindMap:Ce}),jsx(go,{editor:M}),He&&jsx(bo,{editor:M,x:He.x,y:He.y,context:He.context,existingArrowId:He.existingArrowId,defaultShapeType:He.defaultShapeType,onClose:pt}),xt&&M&&jsx(xo,{editor:M,pos:xt,onClose:ko}),jsxs("div",{className:"drawui-status-bar",children:[jsx("div",{className:"drawui-status-item",children:jsx("span",{children:t(ca[I])})}),jsx("div",{className:"drawui-status-item",children:jsx("span",{children:b===0?t("status.none"):t("status.selected",{n:b})})}),jsx("div",{className:"drawui-status-item",children:jsxs("span",{children:[pe,"%"]})})]}),$&&jsxs("div",{className:"drawui-toast",children:[$.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"})]}),$.text]})]})}export{da as CanvasBoard,sn as Toolbar,cn as ZoomControl};