import{K as B,g as i,N as m,l as s,P as D,Q as p,T as R,ae as H,a1 as K,ac as V,ad as q,af as Q,ag as U,av as Y,ao as Z,O as z,ai as C}from"./index-DvLxuDtt.js";var _="Dialog",[P,ie]=B(_),[J,u]=P(_),O=e=>{const{__scopeDialog:o,children:r,open:a,defaultOpen:n,onOpenChange:t,modal:c=!0}=e,l=i.useRef(null),d=i.useRef(null),[f=!1,x]=z({prop:a,defaultProp:n,onChange:t});return s.jsx(J,{scope:o,triggerRef:l,contentRef:d,contentId:C(),titleId:C(),descriptionId:C(),open:f,onOpenChange:x,onOpenToggle:i.useCallback(()=>x($=>!$),[x]),modal:c,children:r})};O.displayName=_;var y="DialogTrigger",I=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(y,r),t=m(o,n.triggerRef);return s.jsx(D.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":N(n.open),...a,ref:t,onClick:p(e.onClick,n.onOpenToggle)})});I.displayName=y;var h="DialogPortal",[X,T]=P(h,{forceMount:void 0}),A=e=>{const{__scopeDialog:o,forceMount:r,children:a,container:n}=e,t=u(h,o);return s.jsx(X,{scope:o,forceMount:r,children:i.Children.map(a,c=>s.jsx(R,{present:r||t.open,children:s.jsx(Z,{asChild:!0,container:n,children:c})}))})};A.displayName=h;var v="DialogOverlay",b=i.forwardRef((e,o)=>{const r=T(v,e.__scopeDialog),{forceMount:a=r.forceMount,...n}=e,t=u(v,e.__scopeDialog);return t.modal?s.jsx(R,{present:a||t.open,children:s.jsx(ee,{...n,ref:o})}):null});b.displayName=v;var ee=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(v,r);return s.jsx(H,{as:K,allowPinchZoom:!0,shards:[n.contentRef],children:s.jsx(D.div,{"data-state":N(n.open),...a,ref:o,style:{pointerEvents:"auto",...a.style}})})}),g="DialogContent",j=i.forwardRef((e,o)=>{const r=T(g,e.__scopeDialog),{forceMount:a=r.forceMount,...n}=e,t=u(g,e.__scopeDialog);return s.jsx(R,{present:a||t.open,children:t.modal?s.jsx(te,{...n,ref:o}):s.jsx(oe,{...n,ref:o})})});j.displayName=g;var te=i.forwardRef((e,o)=>{const r=u(g,e.__scopeDialog),a=i.useRef(null),n=m(o,r.contentRef,a);return i.useEffect(()=>{const t=a.current;if(t)return V(t)},[]),s.jsx(M,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:p(e.onCloseAutoFocus,t=>{var c;t.preventDefault(),(c=r.triggerRef.current)==null||c.focus()}),onPointerDownOutside:p(e.onPointerDownOutside,t=>{const c=t.detail.originalEvent,l=c.button===0&&c.ctrlKey===!0;(c.button===2||l)&&t.preventDefault()}),onFocusOutside:p(e.onFocusOutside,t=>t.preventDefault())})}),oe=i.forwardRef((e,o)=>{const r=u(g,e.__scopeDialog),a=i.useRef(!1),n=i.useRef(!1);return s.jsx(M,{...e,ref:o,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var c,l;(c=e.onCloseAutoFocus)==null||c.call(e,t),t.defaultPrevented||(a.current||(l=r.triggerRef.current)==null||l.focus(),t.preventDefault()),a.current=!1,n.current=!1},onInteractOutside:t=>{var d,f;(d=e.onInteractOutside)==null||d.call(e,t),t.defaultPrevented||(a.current=!0,t.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const c=t.target;((f=r.triggerRef.current)==null?void 0:f.contains(c))&&t.preventDefault(),t.detail.originalEvent.type==="focusin"&&n.current&&t.preventDefault()}})}),M=i.forwardRef((e,o)=>{const{__scopeDialog:r,trapFocus:a,onOpenAutoFocus:n,onCloseAutoFocus:t,...c}=e,l=u(g,r),d=i.useRef(null),f=m(o,d);return q(),s.jsxs(s.Fragment,{children:[s.jsx(Q,{asChild:!0,loop:!0,trapped:a,onMountAutoFocus:n,onUnmountAutoFocus:t,children:s.jsx(U,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":N(l.open),...c,ref:f,onDismiss:()=>l.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(ne,{titleId:l.titleId}),s.jsx(ae,{contentRef:d,descriptionId:l.descriptionId})]})]})}),E="DialogTitle",w=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(E,r);return s.jsx(D.h2,{id:n.titleId,...a,ref:o})});w.displayName=E;var F="DialogDescription",S=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(F,r);return s.jsx(D.p,{id:n.descriptionId,...a,ref:o})});S.displayName=F;var W="DialogClose",k=i.forwardRef((e,o)=>{const{__scopeDialog:r,...a}=e,n=u(W,r);return s.jsx(D.button,{type:"button",...a,ref:o,onClick:p(e.onClick,()=>n.onOpenChange(!1))})});k.displayName=W;function N(e){return e?"open":"closed"}var G="DialogTitleWarning",[ce,L]=Y(G,{contentName:g,titleName:E,docsSlug:"dialog"}),ne=({titleId:e})=>{const o=L(G),r=`\`${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(r))},[r,e]),null},re="DialogDescriptionWarning",ae=({contentRef:e,descriptionId:o})=>{const a=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${L(re).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(a))},[a,e,o]),null},le=O,ue=I,de=A,ge=b,fe=j,pe=w,De=S,ve=k;export{fe as C,De as D,ge as O,de as P,le as R,pe as T,ve as a,ue as b};
