import {c}from'./chunk-MGEN6GOE.mjs';import'./chunk-TAUMSKRE.mjs';import {useState,useEffect,useCallback}from'react';import {jsx,jsxs}from'react/jsx-runtime';var T={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},k={backgroundColor:"white",borderRadius:8,boxShadow:"0 4px 20px rgba(0, 0, 0, 0.15)",minWidth:360,maxWidth:440,width:"100%",margin:20},j={padding:"16px 20px 12px",borderBottom:"1px solid var(--doc-border)",fontSize:16,fontWeight:600},R={padding:"16px 20px",display:"flex",flexDirection:"column",gap:12},b={display:"flex",alignItems:"center",gap:12},u={width:80,fontSize:13,color:"var(--doc-text-muted)"},P={flex:1,padding:"6px 8px",border:"1px solid var(--doc-border)",borderRadius:4,fontSize:13},x={...P},z={padding:"12px 20px 16px",borderTop:"1px solid var(--doc-border)",display:"flex",justifyContent:"flex-end",gap:8},m={padding:"6px 16px",fontSize:13,border:"1px solid var(--doc-border)",borderRadius:4,cursor:"pointer"};function I({isOpen:n,onClose:a,onApply:y,currentProps:l}){let{t:e}=c(),[s,g]=useState(l?.width||0),[r,f]=useState(l?.widthType||"auto"),[p,h]=useState(l?.justification||"left");useEffect(()=>{n&&(g(l?.width||0),f(l?.widthType||"auto"),h(l?.justification||"left"));},[n,l]);let d=useCallback(()=>{let t={};r==="auto"?(t.width=null,t.widthType="auto"):(t.width=s,t.widthType=r),t.justification=p,y(t),a();},[s,r,p,y,a]),w=useCallback(t=>{t.key==="Escape"&&a(),t.key==="Enter"&&d();},[a,d]);return n?jsx("div",{style:T,onClick:a,onKeyDown:w,children:jsxs("div",{style:k,onClick:t=>t.stopPropagation(),role:"dialog","aria-label":e("dialogs.tableProperties.title"),children:[jsx("div",{style:j,children:e("dialogs.tableProperties.title")}),jsxs("div",{style:R,children:[jsxs("div",{style:b,children:[jsx("label",{style:u,children:e("dialogs.tableProperties.widthType")}),jsxs("select",{style:x,value:r,onChange:t=>f(t.target.value),children:[jsx("option",{value:"auto",children:e("dialogs.tableProperties.widthTypes.auto")}),jsx("option",{value:"dxa",children:e("dialogs.tableProperties.widthTypes.fixed")}),jsx("option",{value:"pct",children:e("dialogs.tableProperties.widthTypes.percentage")})]})]}),r!=="auto"&&jsxs("div",{style:b,children:[jsx("label",{style:u,children:e("dialogs.tableProperties.widthLabel")}),jsx("input",{type:"number",style:P,min:0,step:r==="pct"?5:100,value:s,onChange:t=>g(Number(t.target.value)||0)}),jsx("span",{style:{fontSize:11,color:"var(--doc-text-muted)"},children:e(r==="pct"?"dialogs.tableProperties.units.fiftiethsPercent":"dialogs.tableProperties.units.twips")})]}),jsxs("div",{style:b,children:[jsx("label",{style:u,children:e("dialogs.tableProperties.alignmentLabel")}),jsxs("select",{style:x,value:p,onChange:t=>h(t.target.value),children:[jsx("option",{value:"left",children:e("dialogs.tableProperties.alignOptions.left")}),jsx("option",{value:"center",children:e("dialogs.tableProperties.alignOptions.center")}),jsx("option",{value:"right",children:e("dialogs.tableProperties.alignOptions.right")})]})]})]}),jsxs("div",{style:z,children:[jsx("button",{type:"button",style:m,onClick:a,children:e("common.cancel")}),jsx("button",{type:"button",style:{...m,backgroundColor:"var(--doc-primary)",color:"white",borderColor:"var(--doc-primary)"},onClick:d,children:e("common.apply")})]})]})}):null}export{I as TablePropertiesDialog};