drawui-react 0.5.1 → 0.5.3

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