drawui-react 0.5.3 → 0.6.1

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