import{c as E}from"/build/_shared/chunk-4W6Q3ICG.js";import{a as N,b as T}from"/build/_shared/chunk-SYLZIOTS.js";import{d as x}from"/build/_shared/chunk-G5WX4PPA.js";function w(e,n,{checkForDefaultPrevented:t=!0}={}){return function(r){if(e?.(r),t===!1||!r.defaultPrevented)return n?.(r)}}var d=x(N(),1);function U(e,n){let t=(0,d.createContext)(n);function o(a){let{children:s,...u}=a,i=(0,d.useMemo)(()=>u,Object.values(u));return(0,d.createElement)(t.Provider,{value:i},s)}function r(a){let s=(0,d.useContext)(t);if(s)return s;if(n!==void 0)return n;throw new Error(`\`${a}\` must be used within \`${e}\``)}return o.displayName=e+"Provider",[o,r]}function k(e,n=[]){let t=[];function o(a,s){let u=(0,d.createContext)(s),i=t.length;t=[...t,s];function c($){let{scope:l,children:p,...v}=$,q=l?.[e][i]||u,M=(0,d.useMemo)(()=>v,Object.values(v));return(0,d.createElement)(q.Provider,{value:M},p)}function m($,l){let p=l?.[e][i]||u,v=(0,d.useContext)(p);if(v)return v;if(s!==void 0)return s;throw new Error(`\`${$}\` must be used within \`${a}\``)}return c.displayName=a+"Provider",[c,m]}let r=()=>{let a=t.map(s=>(0,d.createContext)(s));return function(u){let i=u?.[e]||a;return(0,d.useMemo)(()=>({[`__scope${e}`]:{...u,[e]:i}}),[u,i])}};return r.scopeName=e,[o,y(r,...n)]}function y(...e){let n=e[0];if(e.length===1)return n;let t=()=>{let o=e.map(r=>({useScope:r(),scopeName:r.scopeName}));return function(a){let s=o.reduce((u,{useScope:i,scopeName:c})=>{let $=i(a)[`__scope${c}`];return{...u,...$}},{});return(0,d.useMemo)(()=>({[`__scope${n.scopeName}`]:s}),[s])}};return t.scopeName=n.scopeName,t}var b=x(N(),1);function j(e){let n=(0,b.useRef)(e);return(0,b.useEffect)(()=>{n.current=e}),(0,b.useMemo)(()=>(...t)=>{var o;return(o=n.current)===null||o===void 0?void 0:o.call(n,...t)},[])}var h=x(N(),1),O=(0,h.createContext)(void 0);function K(e){let n=(0,h.useContext)(O);return e||n||"ltr"}var P=x(N(),1),C=Boolean(globalThis?.document)?P.useLayoutEffect:()=>{};var f=x(N(),1),S=x(T(),1);function R(e,n){return(0,f.useReducer)((t,o)=>{let r=n[t][o];return r??t},e)}var g=e=>{let{present:n,children:t}=e,o=_(n),r=typeof t=="function"?t({present:o.isPresent}):f.Children.only(t),a=E(o.ref,r.ref);return typeof t=="function"||o.isPresent?(0,f.cloneElement)(r,{ref:a}):null};g.displayName="Presence";function _(e){let[n,t]=(0,f.useState)(),o=(0,f.useRef)({}),r=(0,f.useRef)(e),a=(0,f.useRef)("none"),s=e?"mounted":"unmounted",[u,i]=R(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return(0,f.useEffect)(()=>{let c=A(o.current);a.current=u==="mounted"?c:"none"},[u]),C(()=>{let c=o.current,m=r.current;if(m!==e){let l=a.current,p=A(c);e?i("MOUNT"):p==="none"||c?.display==="none"?i("UNMOUNT"):i(m&&l!==p?"ANIMATION_OUT":"UNMOUNT"),r.current=e}},[e,i]),C(()=>{if(n){let c=$=>{let p=A(o.current).includes($.animationName);$.target===n&&p&&(0,S.flushSync)(()=>i("ANIMATION_END"))},m=$=>{$.target===n&&(a.current=A(o.current))};return n.addEventListener("animationstart",m),n.addEventListener("animationcancel",c),n.addEventListener("animationend",c),()=>{n.removeEventListener("animationstart",m),n.removeEventListener("animationcancel",c),n.removeEventListener("animationend",c)}}else i("ANIMATION_END")},[n,i]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:(0,f.useCallback)(c=>{c&&(o.current=getComputedStyle(c)),t(c)},[])}}function A(e){return e?.animationName||"none"}export{w as a,U as b,k as c,j as d,K as e,C as f,g};
