import{t as e,u as n,T as r,v as t,h as a,E as o,o as i}from"./2c1ab0fe.Dbn2KvkT.js";import{ba as c,bb as s,bc as l,bd as p,be as u,bf as d,Q as v,bg as f,bh as m,bi as h,bj as b,bk as S,bl as k,bm as x,bn as g,bo as q,aT as E,bp as y,bq as z,br as _}from"./164ad2e3.FTBuhkTQ.js";import{aX as w,aY as R}from"./4b4bc88f.z1yoAwwH.js";import"./app.CooG55fE.js";var A={Content:"xhuvqpk xhuvqpj _1fragem108 _1fragem10n _1fragemzt _1fragem112 _1fragemup _1fragemv4 _1fragemws _1fragem131 _1fragem133",Popover:"xhuvqp1 xhuvqp0 _1fragemws _1fragemy5 _1fragem133",popoverConnectorVariant:{arrow:"xhuvqp5",none:"xhuvqp6"},popoverPlacementVariant:{blockStart:"xhuvqp7",blockStartSpanInlineEnd:"xhuvqp8",blockStartSpanInlineStart:"xhuvqp9",blockEnd:"xhuvqpa",blockEndSpanInlineEnd:"xhuvqpb",blockEndSpanInlineStart:"xhuvqpc",inlineStart:"xhuvqpd",inlineStartSpanBlockEnd:"xhuvqpe",inlineStartSpanBlockStart:"xhuvqpf",inlineEnd:"xhuvqpg",inlineEndSpanBlockEnd:"xhuvqph",inlineEndSpanBlockStart:"xhuvqpi"}};function B(r){const t=c(),{active:a,setActive:o}=t||{},{onHide:i}=r,p=e(()=>{o?.(!1),"function"==typeof i&&i()},[o,i]);if(t){t.setActivatorAttributes({"aria-expanded":t.active,"aria-controls":r.id}),t.attach("onClick",()=>{a&&p(),o?.(!a)});const{children:e}=r;return n(C,{...r,onHide:p,open:a,children:s(e)&&n(l,{children:e})})}return n(C,{...r})}const C=p(u(function({blockSize:o="auto",children:i,connector:s,offset:l,id:p,inlineSize:u="auto",keepMounted:y=!1,maxBlockSize:z="none",maxInlineSize:_="none",minBlockSize:w="0",minInlineSize:R="0",onHide:A,onShow:B,padding:C="base",positionArea:j="block-start",open:N=!1}){const P=c(),L=d(p),V=r(N),D=r(N),H=r(null),{popover:{connector:K="arrow",cornerRadius:T}}=v(),M=s??K,{className:O,style:Q}=f({blockSize:o,inlineSize:u,padding:C,maxBlockSize:z,maxInlineSize:_,minBlockSize:w,minInlineSize:R}),W=t(()=>P?P.activatorRef.current??null:m(L)&&L.invokerRef?.current?L.invokerRef.current:null,[L,P]),X=e(()=>{A?.()},[A]);return a(()=>{const e=e=>{const n=h(H.current),r=b(e),t=S(W);!(e.target instanceof Node&&document.contains(e.target))||H.current?.contains(e.target)||W?.contains(e.target)||!n&&r||!t&&S(e.target)||!N||X()};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[W,X,N]),a(()=>{const e=e=>{if(!N)return;const n=W&&k(W),r=H.current&&x(H.current),t=H.current&&g(H.current),a=h(H.current);switch(e.key){case"Escape":case"Esc":a&&(X(),W?.focus());break;case"Tab":q(W)&&e.shiftKey?X():q(W)?(e.preventDefault(),r?.focus()):q(r)&&e.shiftKey?(e.preventDefault(),W?.focus(),X()):q(t)&&!e.shiftKey&&(e.preventDefault(),n?.focus(),X())}};return N&&document.addEventListener("keydown",e,!1),!V.current&&N&&B?.(),V.current=N,N&&(D.current=!0),()=>{document.removeEventListener("keydown",e,!1)}},[W,X,B,N]),N||y&&D.current?n(E,{activator:W,offset:l??"arrow"===M?15:5,positionArea:j,preventOverflow:!0,id:p,hidden:!N,children:n(I,{positionArea:j,connector:M,cornerRadius:T,popoverRef:H,responsiveClassNames:O,responsiveStyle:Q,children:i})}):null},{overlayType:"popover"}),{focusActivatorWhenClosing:!0});function I({children:e,positionArea:r,connector:t,cornerRadius:a,popoverRef:c,responsiveClassNames:s,responsiveStyle:p}){const u=o(y),d=u?z(u.position,u.alignment):w(r);return n(l,{children:n("div",{className:i(A.Popover,A.popoverPlacementVariant[d],A.popoverConnectorVariant[t]),ref:c,style:{...null!=a&&{borderRadius:R(a)}},children:n("div",{className:i(A.Content,s),style:p,children:n(_,{children:e})})})})}export{B as P};