import{n as e,o as t}from"./rolldown-runtime-C0FnF6B9.js";import{t as n}from"./react-C21x__mS.js";import{n as r}from"./iframe-GrlyTB2d.js";import{a as i,i as a}from"./utils-DUM89eIj.js";import{a as o,d as s,g as c,l,m as u,n as d,p as f,r as p}from"./floating-ui.react-TvNkEeW6.js";import{a as m,i as h,n as g,r as _}from"./dom-B3G_GtJw.js";import{i as v,r as y}from"./FloatingPopover-CKJVdjqA.js";import{n as b}from"./error-BZrNlEUO.js";var x,S,C,w;function T(){return(T=e((()=>{x=`JK2Y7t`,S=`_5QtpCJ`,C=`hZuysP`,w={popover:x,primary:S,secondary:C}})))()}function E(){let e=(0,D.useContext)(O);if(!e)throw b({hookName:`usePopoverContext`,providerName:`Popover`});return e}var D,O;function k(){return(k=e((()=>{D=n(),O=(0,D.createContext)(null)})))()}var A,j,M;function N(){return(N=e((()=>{A=t(n(),1),p(),_(),a(),v(),T(),k(),j=r(),M=({children:e,onClose:t,closeOnOutside:n=!0,closeOnEscape:r=!0,disableOutsideClick:a=!1,background:o=`secondary`})=>{let{open:s,setOpen:c,refs:l,floatingStyles:u,middlewareData:f,placement:p,arrowRef:_}=E(),v=(0,A.useRef)(null),b=(0,A.useCallback)(e=>{v.current=e,l.setFloating(e)},[l]),x=m({active:s,initialFocus:`container`,restoreFocus:!0,containerRef:v}),S=(0,A.useCallback)(()=>{s&&(c(!1),t?.())},[c,t,s]);g({active:s,enabled:r,onDismiss:S,containerRef:x});let C=(0,A.useCallback)(()=>{!s||a||n&&S()},[s,a,n,S]);return h([l.floating,l.reference],C),s?(0,j.jsx)(d,{children:(0,j.jsxs)(`div`,{ref:b,style:u,className:i(w.popover,w[o]),role:`dialog`,"aria-modal":`true`,tabIndex:-1,children:[typeof e==`function`?e({setClose:S}):e,(0,j.jsx)(y,{ref:_,placement:p,middlewareData:f})]})}):null},M.__docgenInfo={description:`Содержимое Popover, отображаемое в портале.`,methods:[],displayName:`PopoverContent`,props:{children:{required:!0,tsType:{name:`union`,raw:`React.ReactNode | ((ctx: { setClose: () => void }) => React.ReactNode)`,elements:[{name:`ReactReactNode`,raw:`React.ReactNode`},{name:`unknown`}]},description:``},onClose:{required:!1,tsType:{name:`signature`,type:`function`,raw:`() => void`,signature:{arguments:[],return:{name:`void`}}},description:``},closeOnOutside:{required:!1,tsType:{name:`boolean`},description:``,defaultValue:{value:`true`,computed:!1}},closeOnEscape:{required:!1,tsType:{name:`boolean`},description:``,defaultValue:{value:`true`,computed:!1}},disableOutsideClick:{required:!1,tsType:{name:`boolean`},description:``,defaultValue:{value:`false`,computed:!1}},background:{required:!1,tsType:{name:`union`,raw:`"primary" | "secondary"`,elements:[{name:`literal`,value:`"primary"`},{name:`literal`,value:`"secondary"`}]},description:``,defaultValue:{value:`"secondary"`,computed:!1}}}}})))()}var P,F;function I(){return(I=e((()=>{P=n(),k(),F=({passive:e,children:t})=>{let{open:n,setOpen:r,refs:i}=E(),a=(0,P.useCallback)(n=>{t.props.onClick&&t.props.onClick(n),!n.defaultPrevented&&(n.preventDefault(),n.stopPropagation(),!e&&r(e=>!e))},[t,r,e]);return(0,P.cloneElement)(t,{ref:i.setReference,"aria-expanded":n,onClick:a})},F.__docgenInfo={description:``,methods:[],displayName:`PopoverTrigger`,props:{passive:{required:!1,tsType:{name:`literal`,value:`true`},description:``},children:{required:!0,tsType:{name:`ReactReactElement`,raw:`React.ReactElement<React.HTMLAttributes<Element> & { ref?: React.Ref<Element> }>`,elements:[{name:`intersection`,raw:`React.HTMLAttributes<Element> & { ref?: React.Ref<Element> }`,elements:[{name:`ReactHTMLAttributes`,raw:`React.HTMLAttributes<Element>`,elements:[{name:`Element`}]},{name:`signature`,type:`object`,raw:`{ ref?: React.Ref<Element> }`,signature:{properties:[{key:`ref`,value:{name:`ReactRef`,raw:`React.Ref<Element>`,elements:[{name:`Element`}],required:!1}}]}}]}]},description:``}}}})))()}var L,R,z,B;function V(){return(V=e((()=>{L=t(n(),1),p(),N(),k(),I(),R=r(),z=({children:e,open:t,defaultOpen:n,onOpenChange:r,placement:i=`bottom`})=>{let[a,d]=(0,L.useState)(n??!1),p=t!==void 0,m=p?t:a,h=(0,L.useCallback)(e=>{let t=typeof e==`function`?e(m):e;p||d(t),r?.(t)},[p,r,m]),g=(0,L.useRef)(null),{refs:_,floatingStyles:v,middlewareData:y,placement:b}=o({open:m,onOpenChange:h,placement:i,middleware:[f(8),s(),u({padding:16}),l({element:g.current})],whileElementsMounted:c});return(0,R.jsx)(O.Provider,{value:{open:m,setOpen:h,refs:_,floatingStyles:v,placement:b,middlewareData:y,arrowRef:g},children:e})},B=Object.assign(z,{Trigger:F,Content:M}),z.__docgenInfo={description:`Контролируемый Popover.
Используется в связке с Popover.Trigger и Popover.Content.`,methods:[],displayName:`PopoverRoot`,props:{children:{required:!0,tsType:{name:`ReactReactNode`,raw:`React.ReactNode`},description:``},placement:{required:!1,tsType:{name:`Placement`},description:``,defaultValue:{value:`"bottom"`,computed:!1}},open:{required:!1,tsType:{name:`boolean`},description:``},defaultOpen:{required:!1,tsType:{name:`boolean`},description:``},onOpenChange:{required:!1,tsType:{name:`signature`,type:`function`,raw:`(open: boolean) => void`,signature:{arguments:[{type:{name:`boolean`},name:`open`}],return:{name:`void`}}},description:``}}}})))()}export{V as n,B as t};