import{r as i,j as r}from"./app-DBtZ8h0a.js";import{c as L}from"./utils-B0kY8eQi.js";import{b as $,c as B,u as v,e as H,P as m,R as V,h as Y,a as x,f as q,F as z,D as K,j as U}from"./Combination-T3b6BNU6.js";import{S as Z,u as h}from"./index-ClrXUyoj.js";import{P as C}from"./index-BW9zw9n8.js";var R="Dialog",[_,ve]=B(R),[J,d]=_(R),E=e=>{const{__scopeDialog:o,children:a,open:s,defaultOpen:n,onOpenChange:t,modal:l=!0}=e,c=i.useRef(null),u=i.useRef(null),[f=!1,p]=$({prop:s,defaultProp:n,onChange:t});return r.jsx(J,{scope:o,triggerRef:c,contentRef:u,contentId:v(),titleId:v(),descriptionId:v(),open:f,onOpenChange:p,onOpenToggle:i.useCallback(()=>p(G=>!G),[p]),modal:l,children:a})};E.displayName=R;var j="DialogTrigger",Q=i.forwardRef((e,o)=>{const{__scopeDialog:a,...s}=e,n=d(j,a),t=h(o,n.triggerRef);return r.jsx(m.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":N(n.open),...s,ref:t,onClick:x(e.onClick,n.onOpenToggle)})});Q.displayName=j;var b="DialogPortal",[X,P]=_(b,{forceMount:void 0}),I=e=>{const{__scopeDialog:o,forceMount:a,children:s,container:n}=e,t=d(b,o);return r.jsx(X,{scope:o,forceMount:a,children:i.Children.map(s,l=>r.jsx(C,{present:a||t.open,children:r.jsx(H,{asChild:!0,container:n,children:l})}))})};I.displayName=b;var D="DialogOverlay",O=i.forwardRef((e,o)=>{const a=P(D,e.__scopeDialog),{forceMount:s=a.forceMount,...n}=e,t=d(D,e.__scopeDialog);return t.modal?r.jsx(C,{present:s||t.open,children:r.jsx(ee,{...n,ref:o})}):null});O.displayName=D;var ee=i.forwardRef((e,o)=>{const{__scopeDialog:a,...s}=e,n=d(D,a);return r.jsx(V,{as:Z,allowPinchZoom:!0,shards:[n.contentRef],children:r.jsx(m.div,{"data-state":N(n.open),...s,ref:o,style:{pointerEvents:"auto",...s.style}})})}),g="DialogContent",A=i.forwardRef((e,o)=>{const a=P(g,e.__scopeDialog),{forceMount:s=a.forceMount,...n}=e,t=d(g,e.__scopeDialog);return r.jsx(C,{present:s||t.open,children:t.modal?r.jsx(te,{...n,ref:o}):r.jsx(oe,{...n,ref:o})})});A.displayName=g;var te=i.forwardRef((e,o)=>{const a=d(g,e.__scopeDialog),s=i.useRef(null),n=h(o,a.contentRef,s);return i.useEffect(()=>{const t=s.current;if(t)return Y(t)},[]),r.jsx(w,{...e,ref:n,trapFocus:a.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:x(e.onCloseAutoFocus,t=>{var l;t.preventDefault(),(l=a.triggerRef.current)==null||l.focus()}),onPointerDownOutside:x(e.onPointerDownOutside,t=>{const l=t.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&t.preventDefault()}),onFocusOutside:x(e.onFocusOutside,t=>t.preventDefault())})}),oe=i.forwardRef((e,o)=>{const a=d(g,e.__scopeDialog),s=i.useRef(!1),n=i.useRef(!1);return r.jsx(w,{...e,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,t),t.defaultPrevented||(s.current||(c=a.triggerRef.current)==null||c.focus(),t.preventDefault()),s.current=!1,n.current=!1},onInteractOutside:t=>{var u,f;(u=e.onInteractOutside)==null||u.call(e,t),t.defaultPrevented||(s.current=!0,t.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const l=t.target;((f=a.triggerRef.current)==null?void 0:f.contains(l))&&t.preventDefault(),t.detail.originalEvent.type==="focusin"&&n.current&&t.preventDefault()}})}),w=i.forwardRef((e,o)=>{const{__scopeDialog:a,trapFocus:s,onOpenAutoFocus:n,onCloseAutoFocus:t,...l}=e,c=d(g,a),u=i.useRef(null),f=h(o,u);return q(),r.jsxs(r.Fragment,{children:[r.jsx(z,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:n,onUnmountAutoFocus:t,children:r.jsx(K,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":N(c.open),...l,ref:f,onDismiss:()=>c.onOpenChange(!1)})}),r.jsxs(r.Fragment,{children:[r.jsx(re,{titleId:c.titleId}),r.jsx(se,{contentRef:u,descriptionId:c.descriptionId})]})]})}),y="DialogTitle",T=i.forwardRef((e,o)=>{const{__scopeDialog:a,...s}=e,n=d(y,a);return r.jsx(m.h2,{id:n.titleId,...s,ref:o})});T.displayName=y;var M="DialogDescription",F=i.forwardRef((e,o)=>{const{__scopeDialog:a,...s}=e,n=d(M,a);return r.jsx(m.p,{id:n.descriptionId,...s,ref:o})});F.displayName=M;var S="DialogClose",ne=i.forwardRef((e,o)=>{const{__scopeDialog:a,...s}=e,n=d(S,a);return r.jsx(m.button,{type:"button",...s,ref:o,onClick:x(e.onClick,()=>n.onOpenChange(!1))})});ne.displayName=S;function N(e){return e?"open":"closed"}var k="DialogTitleWarning",[he,W]=U(k,{contentName:g,titleName:y,docsSlug:"dialog"}),re=({titleId:e})=>{const o=W(k),a=`\`${o.contentName}\` requires a \`${o.titleName}\` for the component to be accessible for screen reader users.

If you want to hide the \`${o.titleName}\`, you can wrap it with our VisuallyHidden component.

For more information, see https://radix-ui.com/primitives/docs/components/${o.docsSlug}`;return i.useEffect(()=>{e&&(document.getElementById(e)||console.error(a))},[a,e]),null},ae="DialogDescriptionWarning",se=({contentRef:e,descriptionId:o})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${W(ae).contentName}}.`;return i.useEffect(()=>{var t;const n=(t=e.current)==null?void 0:t.getAttribute("aria-describedby");o&&n&&(document.getElementById(o)||console.warn(s))},[s,e,o]),null},ie=E,le=I,ce=O,ue=A,de=T,fe=F;function Ce({open:e,onOpenChange:o,title:a,description:s,confirmText:n="Ya",cancelText:t="Batal",onConfirm:l,closeOnConfirm:c=!0,children:u,variant:f="danger"}){const p=i.useCallback(()=>{l(),c&&o(!1)},[l,o,c]);return r.jsxs(ie,{open:e,onOpenChange:o,children:[u&&u,r.jsxs(le,{children:[r.jsx(ce,{className:"fixed inset-0 bg-black/30 backdrop-blur-sm"}),r.jsxs(ue,{className:"fixed top-1/2 left-1/2 z-50 w-[90vw] max-w-sm -translate-x-1/2 -translate-y-1/2 rounded-lg bg-white p-6 shadow-lg",children:[r.jsx(de,{className:"mb-2 text-xl font-bold text-gray-800",children:a}),r.jsx(fe,{className:"mb-4 text-sm text-gray-600",children:s}),r.jsxs("div",{className:"flex justify-end space-x-3",children:[t!==null&&r.jsx("button",{onClick:()=>o(!1),className:"rounded-md bg-gray-100 px-4 py-2 text-sm hover:bg-gray-200",children:t}),r.jsx("button",{onClick:p,className:L("rounded-md px-4 py-2 text-sm text-white",f==="danger"?"bg-red-600 hover:bg-red-700":"bg-blue-600 hover:bg-blue-700"),children:n})]})]})]})]})}export{Ce as C};
