import {c}from'./chunk-MGEN6GOE.mjs';import'./chunk-TAUMSKRE.mjs';import {useState,useEffect,useCallback}from'react';import {jsx,jsxs}from'react/jsx-runtime';var I={position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e4},R={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:380,maxWidth:440,width:"100%",margin:20},D={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},E={padding:"16px 20px",display:"flex",flexDirection:"column",gap:16},C={display:"flex",flexDirection:"column",gap:8},w={fontSize:13,fontWeight:600,color:"var(--doc-text)"},v={display:"flex",alignItems:"center",gap:8},S={width:60,fontSize:12,color:"var(--doc-text-muted)"},p={flex:1,padding:"4px 6px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:12},T={...p},B={...p,minHeight:60,resize:"vertical",fontFamily:"inherit"},K={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},W={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function F({isOpen:g,onClose:l,onApply:u,currentData:d}){let{t:o}=c(),[y,m]=useState(""),[i,x]=useState(0),[a,c$1]=useState("#000000"),[s,f]=useState("solid");useEffect(()=>{g&&(m(d?.alt??""),x(d?.borderWidth??0),c$1(d?.borderColor??"#000000"),f(d?.borderStyle??"solid"));},[g,d]);let b=useCallback(()=>{u({alt:y||void 0,borderWidth:i>0?i:void 0,borderColor:i>0?a:void 0,borderStyle:i>0?s:void 0}),l();},[y,i,a,s,u,l]),k=useCallback(t=>{t.key==="Escape"&&l(),t.key==="Enter"&&!t.shiftKey&&b();},[l,b]);return g?jsx("div",{style:I,onClick:l,onKeyDown:k,children:jsxs("div",{style:R,onClick:t=>t.stopPropagation(),role:"dialog","aria-label":o("dialogs.imageProperties.title"),children:[jsx("div",{style:D,children:o("dialogs.imageProperties.title")}),jsxs("div",{style:E,children:[jsxs("div",{style:C,children:[jsx("div",{style:w,children:o("dialogs.imageProperties.altText")}),jsx("textarea",{style:B,value:y,onChange:t=>m(t.target.value),placeholder:o("dialogs.imageProperties.altTextPlaceholder")})]}),jsxs("div",{style:C,children:[jsx("div",{style:w,children:o("dialogs.imageProperties.border")}),jsxs("div",{style:v,children:[jsx("label",{style:S,children:o("dialogs.imageProperties.width")}),jsx("input",{type:"number",style:{...p,maxWidth:80},min:0,max:20,step:.5,value:i,onChange:t=>x(Number(t.target.value)||0)}),jsx("span",{style:{fontSize:12,color:"var(--doc-text-muted)"},children:o("common.px")})]}),jsxs("div",{style:v,children:[jsx("label",{style:S,children:o("dialogs.imageProperties.style")}),jsxs("select",{style:T,value:s,onChange:t=>f(t.target.value),children:[jsx("option",{value:"solid",children:o("dialogs.imageProperties.borderStyles.solid")}),jsx("option",{value:"dashed",children:o("dialogs.imageProperties.borderStyles.dashed")}),jsx("option",{value:"dotted",children:o("dialogs.imageProperties.borderStyles.dotted")}),jsx("option",{value:"double",children:o("dialogs.imageProperties.borderStyles.double")}),jsx("option",{value:"groove",children:o("dialogs.imageProperties.borderStyles.groove")}),jsx("option",{value:"ridge",children:o("dialogs.imageProperties.borderStyles.ridge")}),jsx("option",{value:"inset",children:o("dialogs.imageProperties.borderStyles.inset")}),jsx("option",{value:"outset",children:o("dialogs.imageProperties.borderStyles.outset")})]})]}),jsxs("div",{style:v,children:[jsx("label",{style:S,children:o("dialogs.imageProperties.color")}),jsx("input",{type:"color",value:a,onChange:t=>c$1(t.target.value),style:{width:32,height:24,padding:0,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"}}),jsx("input",{type:"text",style:{...p,maxWidth:90},value:a,onChange:t=>c$1(t.target.value)})]}),i>0&&jsx("div",{style:{marginTop:4,padding:8,border:`${i}px ${s} ${a}`,borderRadius:4,fontSize:11,color:"var(--doc-text-muted)",textAlign:"center"},children:o("dialogs.imageProperties.preview")})]})]}),jsxs("div",{style:K,children:[jsx("button",{type:"button",style:W,onClick:l,children:o("common.cancel")}),jsx("button",{type:"button",style:{...W,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:b,children:o("common.apply")})]})]})}):null}export{F as ImagePropertiesDialog};