import{X as w,r as j,j as e,aU as d,av as p,ai as C,bK as S,bB as E,V as o,aK as N}from"./index-BLPf7Sv2.js";const U={en:{unableToUpdate:"Unable to update",updateSuccessfully:"Successfully updated"},pt:{unableToUpdate:"Não foi possível atualizar",updateSuccessfully:"Atualizado com sucesso"}},R=({cardTitle:m,submitPromise:f,canEdit:h=!0,showAllOperations:n=!0,startEditing:l=!1,innerRef:x,successMessage:r,errorMessage:i,...b})=>{const t=w("editContent",U),[s,a]=j.useState(l),y=async c=>{try{await f?.(c),o.showToaster({type:"success",message:r?r(c):t.editContent.updateSuccessfully}),!l&&a(!1)}catch(u){if(i)o.showToaster({type:"error",message:i(u)});else{const g=N({error:u,prefix:t.editContent.unableToUpdate});o.showToaster({type:"error",message:g})}}},T=()=>{a(!1)};return e.jsxs(d,{className:"fill-width",gap:"1rem",children:[e.jsxs(p,{className:"fill-width",justify:"space-between",align:"center",children:[e.jsx(C,{as:"h2",appearance:"h5",children:m}),h?e.jsx(S,{type:"button",icon:"edit",appearance:"round",onClick:()=>a(!s)}):null]}),e.jsx(p,{className:"fill-width",children:e.jsx(d,{className:"fill-width",gap:"1rem",children:e.jsx(E,{...b,addReset:!0,submitText:t.global.save,resetText:t.global.cancel,onAfterReset:T,disableAll:!s,showAllOperations:n&&s,onSubmit:y,innerRef:x})})})]})};export{R as E};