import{r as c}from"./index-CqIc3cxq.js";import{c as A,u as I,R as L,a as G,b as H,d as O,P as _,e as P,A as E,f as w,g as K,h as $,D as U,C as V,i as W}from"./tooltip-Tlsyx2YO.js";import{h as Z,R as q,u as z,F as B}from"./index-ynYvVAOK.js";import{j as p}from"./jsx-runtime-C5WNSv3b.js";var x="Popover",[j]=G(x,[A]),g=A(),[J,u]=j(x),b=e=>{const{__scopePopover:n,children:t,open:s,defaultOpen:o,onOpenChange:r,modal:a=!1}=e,i=g(n),f=c.useRef(null),[v,h]=c.useState(!1),[C,l]=I({prop:s,defaultProp:o??!1,onChange:r,caller:x});return p.jsx(L,{...i,children:p.jsx(J,{scope:n,contentId:H(),triggerRef:f,open:C,onOpenChange:l,onOpenToggle:c.useCallback(()=>l(R=>!R),[l]),hasCustomAnchor:v,onCustomAnchorAdd:c.useCallback(()=>h(!0),[]),onCustomAnchorRemove:c.useCallback(()=>h(!1),[]),modal:a,children:t})})};b.displayName=x;var F="PopoverAnchor",Q=c.forwardRef((e,n)=>{const{__scopePopover:t,...s}=e,o=u(F,t),r=g(t),{onCustomAnchorAdd:a,onCustomAnchorRemove:i}=o;return c.useEffect(()=>(a(),()=>i()),[a,i]),p.jsx(E,{...r,...s,ref:n})});Q.displayName=F;var N="PopoverTrigger",S=c.forwardRef((e,n)=>{const{__scopePopover:t,...s}=e,o=u(N,t),r=g(t),a=O(n,o.triggerRef),i=p.jsx(_.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":k(o.open),...s,ref:a,onClick:P(e.onClick,o.onOpenToggle)});return o.hasCustomAnchor?i:p.jsx(E,{asChild:!0,...r,children:i})});S.displayName=N;var m="PopoverPortal",[X,Y]=j(m,{forceMount:void 0}),y=e=>{const{__scopePopover:n,forceMount:t,children:s,container:o}=e,r=u(m,n);return p.jsx(X,{scope:n,forceMount:t,children:p.jsx(w,{present:t||r.open,children:p.jsx(K,{asChild:!0,container:o,children:s})})})};y.displayName=m;var d="PopoverContent",D=c.forwardRef((e,n)=>{const t=Y(d,e.__scopePopover),{forceMount:s=t.forceMount,...o}=e,r=u(d,e.__scopePopover);return p.jsx(w,{present:s||r.open,children:r.modal?p.jsx(oe,{...o,ref:n}):p.jsx(re,{...o,ref:n})})});D.displayName=d;var ee=$("PopoverContent.RemoveScroll"),oe=c.forwardRef((e,n)=>{const t=u(d,e.__scopePopover),s=c.useRef(null),o=O(n,s),r=c.useRef(!1);return c.useEffect(()=>{const a=s.current;if(a)return Z(a)},[]),p.jsx(q,{as:ee,allowPinchZoom:!0,children:p.jsx(M,{...e,ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:P(e.onCloseAutoFocus,a=>{a.preventDefault(),r.current||t.triggerRef.current?.focus()}),onPointerDownOutside:P(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,f=i.button===0&&i.ctrlKey===!0,v=i.button===2||f;r.current=v},{checkForDefaultPrevented:!1}),onFocusOutside:P(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),re=c.forwardRef((e,n)=>{const t=u(d,e.__scopePopover),s=c.useRef(!1),o=c.useRef(!1);return p.jsx(M,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:r=>{e.onCloseAutoFocus?.(r),r.defaultPrevented||(s.current||t.triggerRef.current?.focus(),r.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(s.current=!0,r.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=r.target;t.triggerRef.current?.contains(a)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&o.current&&r.preventDefault()}})}),M=c.forwardRef((e,n)=>{const{__scopePopover:t,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:r,disableOutsidePointerEvents:a,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:v,onInteractOutside:h,...C}=e,l=u(d,t),R=g(t);return z(),p.jsx(B,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:r,children:p.jsx(U,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:h,onEscapeKeyDown:i,onPointerDownOutside:f,onFocusOutside:v,onDismiss:()=>l.onOpenChange(!1),children:p.jsx(V,{"data-state":k(l.open),role:"dialog",id:l.contentId,...R,...C,ref:n,style:{...C.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),T="PopoverClose",te=c.forwardRef((e,n)=>{const{__scopePopover:t,...s}=e,o=u(T,t);return p.jsx(_.button,{type:"button",...s,ref:n,onClick:P(e.onClick,()=>o.onOpenChange(!1))})});te.displayName=T;var ne="PopoverArrow",se=c.forwardRef((e,n)=>{const{__scopePopover:t,...s}=e,o=g(t);return p.jsx(W,{...o,...s,ref:n})});se.displayName=ne;function k(e){return e?"open":"closed"}var ue=b,le=S,de=y,fe=D;export{fe as C,de as P,ue as R,le as T};
//# sourceMappingURL=index-CmflCPTU.js.map
