import{c as k,r as C,b as z,j as t}from"./app-BiexncSX.js";import{B as $}from"./button-Cwvd_D5X.js";import{D as H,a as P,b as q,f as A,g as G,c as J,d as K,e as M}from"./dialog-CRgq9Gqn.js";import{I as Q}from"./input-C7geQw3H.js";import{L as U}from"./label-BACPLsln.js";import{S as V}from"./spinner-BshPoFqP.js";import{t as B}from"./index-BphRgCCf.js";import{c as W}from"./utils-DvRnx1Xn.js";import{T as X}from"./lucide-react-C-jOYeYF.js";import{T as Y}from"./trash-2-B8EoOc8P.js";function ce(R){const e=k.c(39),{deleteId:y,model:_,title:s,onDeleted:u,className:N}=R,[l,I]=C.useState(""),[r,O]=C.useState(!1),[a,x]=C.useState(!1);let p;e[0]!==l||e[1]!==y||e[2]!==_||e[3]!==u?(p=()=>{if(l!=="DELETE")return B.warning('Type "DELETE" to confirm');x(!0),z.delete(`/dashboard/${_}/${y}`,{onSuccess:()=>{B.success("Successfuly Deleted..!"),x(!1),O(!1),u&&u()},onError:F=>{B.error(F.message),x(!1)},onFinish:()=>{x(!1)}})},e[0]=l,e[1]=y,e[2]=_,e[3]=u,e[4]=p):p=e[4];const L=p;let g,D;e[5]!==r?(g=()=>{r||(I(""),x(!1))},D=[r],e[5]=r,e[6]=g,e[7]=D):(g=e[6],D=e[7]),C.useEffect(g,D);let i;e[8]!==N?(i=W("text-destructive hover:border-destructive/10 hover:text-destructive hover:scale-105 active:scale-98 ",N),e[8]=N,e[9]=i):i=e[9];let j;e[10]===Symbol.for("react.memo_cache_sentinel")?(j=t.jsx(X,{}),e[10]=j):j=e[10];let o;e[11]!==i?(o=t.jsx(H,{asChild:!0,children:t.jsxs($,{size:"icon-sm",variant:"outline",className:i,children:[" ",j," "]})}),e[11]=i,e[12]=o):o=e[12];let E;e[13]===Symbol.for("react.memo_cache_sentinel")?(E=t.jsx(Y,{className:"w-4.5 h-4.5 text-destructive"}),e[13]=E):E=e[13];let n;e[14]!==s?(n=t.jsxs(P,{children:[t.jsxs(q,{className:"flex gap-2 items-center",children:[E," Delete ",s]}),t.jsxs(A,{children:["Deleting the ",s," will permanently remove it from your database."]})]}),e[14]=s,e[15]=n):n=e[15];let v;e[16]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsxs(U,{htmlFor:"confirmText",children:["Enter ",t.jsx("span",{className:"font-bold text-red-600",children:'"DELETE"'})," to confirm"]}),e[16]=v):v=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=F=>I(F.target.value),e[17]=b):b=e[17];let c;e[18]!==l||e[19]!==a?(c=t.jsxs("div",{className:"grid gap-3",children:[v,t.jsx(Q,{id:"confirmText",name:"delete",value:l,onChange:b,placeholder:"DELETE",disabled:a,autoComplete:"delete"})]}),e[18]=l,e[19]=a,e[20]=c):c=e[20];let T;e[21]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(G,{asChild:!0,children:t.jsx($,{variant:"outline",children:"Cancel"})}),e[21]=T):T=e[21];const w=a||l!=="DELETE";let m;e[22]!==a||e[23]!==s?(m=a?t.jsxs(t.Fragment,{children:[t.jsx(V,{className:"mr-2"})," Deleting..."]}):`Delete ${s}`,e[22]=a,e[23]=s,e[24]=m):m=e[24];let f;e[25]!==L||e[26]!==w||e[27]!==m?(f=t.jsxs(J,{children:[T,t.jsx($,{type:"button",variant:"destructive",onClick:L,disabled:w,children:m})]}),e[25]=L,e[26]=w,e[27]=m,e[28]=f):f=e[28];let d;e[29]!==c||e[30]!==f?(d=t.jsxs("div",{className:"flex flex-col gap-4",children:[c,f]}),e[29]=c,e[30]=f,e[31]=d):d=e[31];let h;e[32]!==d||e[33]!==n?(h=t.jsxs(K,{className:"sm:max-w-106.25  border-red-900 ",children:[n,d]}),e[32]=d,e[33]=n,e[34]=h):h=e[34];let S;return e[35]!==r||e[36]!==h||e[37]!==o?(S=t.jsxs(M,{open:r,onOpenChange:O,children:[o,h]}),e[35]=r,e[36]=h,e[37]=o,e[38]=S):S=e[38],S}export{ce as D};
