import{C as e,F as t,L as n,M as r,N as i,V as a,W as o,et as s,gt as c,l,q as u,rt as d,xt as f}from"./dist-B4ulKgpj.js";import{r as p}from"./Primitive-CN38JRWA.js";import{f as m,i as h,n as g}from"./useForwardExpose-EAYoNPYk.js";function _(e,t){let r=typeof e==`string`&&!t?`${e}Context`:t,i=Symbol(r);return[t=>{let r=n(i,t);if(r||r===null)return r;throw Error(`Injection \`${i.toString()}\` not found. Component must be used within ${Array.isArray(e)?`one of the following components: ${e.join(`, `)}`:`\`${e}\``}`)},e=>(u(i,e),e)]}function v(){let e=document.activeElement;if(e==null)return null;for(;e!=null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function y(e){return e==null}var[b,x]=_(`ConfigProvider`),S=0;function C(e,t=`reka`){if(e)return e;let n;return n=`useId`in l?s?.():b({useId:void 0}).useId?.()??`${++S}`,t?`${t}-${n}`:n}function w(e,t){let n=c(e);function r(e){return t[n.value][e]??n.value}return{state:n,dispatch:e=>{n.value=r(e)}}}function T(t,n){let r=c({}),i=c(`none`),s=c(t),l=t.value?`mounted`:`unmounted`,u,f=n.value?.ownerDocument.defaultView??g,{state:p,dispatch:h}=w(l,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}}),_=e=>{if(m){let t=new CustomEvent(e,{bubbles:!1,cancelable:!1});n.value?.dispatchEvent(t)}};d(t,async(e,t)=>{let o=t!==e;if(await a(),o){let a=i.value,o=E(n.value);e?(h(`MOUNT`),_(`enter`),o===`none`&&_(`after-enter`)):o===`none`||o===`undefined`||r.value?.display===`none`?(h(`UNMOUNT`),_(`leave`),_(`after-leave`)):t&&a!==o?(h(`ANIMATION_OUT`),_(`leave`)):(h(`UNMOUNT`),_(`after-leave`))}},{immediate:!0});let v=e=>{let t=E(n.value),r=t.includes(CSS.escape(e.animationName)),i=p.value===`mounted`?`enter`:`leave`;if(e.target===n.value&&r&&(_(`after-${i}`),h(`ANIMATION_END`),!s.value)){let e=n.value.style.animationFillMode;n.value.style.animationFillMode=`forwards`,u=f?.setTimeout(()=>{n.value?.style.animationFillMode===`forwards`&&(n.value.style.animationFillMode=e)})}e.target===n.value&&t===`none`&&h(`ANIMATION_END`)},y=e=>{e.target===n.value&&(i.value=E(n.value))},b=d(n,(e,t)=>{e?(r.value=getComputedStyle(e),e.addEventListener(`animationstart`,y),e.addEventListener(`animationcancel`,v),e.addEventListener(`animationend`,v)):(h(`ANIMATION_END`),u!==void 0&&f?.clearTimeout(u),t?.removeEventListener(`animationstart`,y),t?.removeEventListener(`animationcancel`,v),t?.removeEventListener(`animationend`,v))},{immediate:!0}),x=d(p,()=>{let e=E(n.value);i.value=p.value===`mounted`?e:`none`});return o(()=>{b(),x()}),{isPresent:e(()=>[`mounted`,`unmountSuspended`].includes(p.value))}}function E(e){return e&&getComputedStyle(e).animationName||`none`}var D=r({name:`Presence`,props:{present:{type:Boolean,required:!0},forceMount:{type:Boolean}},slots:{},setup(e,{slots:n,expose:r}){let{present:a,forceMount:o}=f(e),s=c(),{isPresent:l}=T(a,s);r({present:l});let u=n.default({present:l.value});u=p(u||[]);let d=i();if(u&&u?.length>1){let e=d?.parent?.type.name?`<${d.parent.type.name} />`:`component`;throw Error([`Detected an invalid children for \`${e}\` for  \`Presence\` component.`,``,"Note: Presence works similarly to `v-if` directly, but it waits for animation/transition to finished before unmounting. So it expect only one direct child of valid VNode type.",`You can apply a few solutions:`,["Provide a single child element so that `presence` directive attach correctly.",`Ensure the first child is an actual element instead of a raw text node or comment node.`].map(e=>`  - ${e}`).join(`
`)].join(`
`))}return()=>o.value||a.value||l.value?t(n.default({present:l.value})[0],{ref:e=>{let t=h(e);return t?.hasAttribute===void 0||(t?.hasAttribute(`data-reka-popper-content-wrapper`)?s.value=t.firstElementChild:s.value=t),t}}):null}});export{v as a,y as i,C as n,_ as o,b as r,D as t};