import{r as a}from"./vendor-react-CTtPmzVP.js";import{D as x,J as b,j as s,b5 as _,$ as z,bf as F,aZ as L,R as N,a6 as O,at as Q,Y as V,W as o}from"./vendor-mui-core-DnR6WYuU.js";import{V as Y,J as y}from"./vendor-ux-DMZIE6wA.js";import"./index-DwyzCfdd.js";import{f as Z}from"./index-DBs9Ljax.js";function G(){const e=x();return{minWidth:b(e.breakpoints.down("md"))?300:e.breakpoints.values.sm}}function H({title:e,description:n,showCancel:l=!0,showConfirm:C=!0,cancel:j="",confirm:k="Confirm",color:D="error",params:w={},onCancel:S=()=>{},onConfirm:E,loading:c=!1,displayError:P=!0,children:R=void 0,...T}){const[r,W]=a.useState(w),[$,d]=a.useState(!0),[m,p]=a.useState(!1),[f,u]=a.useState(""),{t:v}=Y(),q=x(),h=async t=>{if(typeof t=="function"){p(!0);try{if(await t(r)===!1)return;d(!1)}catch(i){u(Z(i)),console.error(i)}finally{p(!1)}}else d(!1)},B=typeof e=="function"?e():e,M=typeof n=="function"?n(r,W,u):n,A=b(q.breakpoints.down("md")),J=t=>{t.stopPropagation()},{minWidth:g}=G();return s.jsxs(I,{onClick:J,fullScreen:A,open:$,style:{minWidth:g},...T,children:[s.jsx(_,{children:B}),s.jsxs(z,{style:{minWidth:g},children:[s.jsx(F,{component:"div",children:M}),!!f&&P&&s.jsx(L,{severity:"error",style:{width:"100%",marginTop:8},children:f}),R]}),s.jsxs(N,{className:"delete-actions",style:{padding:"8px 24px 24px"},children:[l&&s.jsx(y,{onClick:t=>{t.stopPropagation(),h(S)},color:"inherit","data-cy":"cancel-confirm-dialog",children:j||v("common.cancel")}),C&&s.jsxs(y,{onClick:t=>{t.stopPropagation(),h(E)},color:D,disabled:r.__disableConfirm||m||c,variant:"contained","data-cy":"submit-confirm-dialog",autoFocus:!0,children:[(m||c)&&s.jsx(O,{size:16,sx:{mr:1}}),k]})]})]})}H.propTypes={title:o.any.isRequired,description:o.any.isRequired,showCancel:o.bool,showConfirm:o.bool,cancel:o.string,color:o.string,confirm:o.string,params:o.object,onCancel:o.func,onConfirm:o.func.isRequired,loading:o.bool,displayError:o.bool,children:o.any};const I=Q(V)`
  .delete-actions .Mui-disabled {
    color: ${({theme:e})=>`${e.palette.text.primary} !important`};
    box-shadow: none;
    background-color: ${({theme:e})=>`${e.palette.action.disabled} !important`};
  }
`;export{H as C};
