import{ak as k,r as I,B as S,H as B,J as q,m as b,d as M,L as x,a7 as C,a9 as G,ag as V,ab as j,I as K,al as Y,o as z,g as W,w as _,b as H,e as N,M as J}from"./app-D9-EssCM.js";import{r as Q,S as O,P as X}from"./index-CcjNLu6f.js";import{n as Z,i as ee,d as te,e as ne}from"./useForwardExpose-MNmriUeS.js";import{e as R,g as P,c as ae,a as oe}from"./VisuallyHidden-DG35s1YI.js";function Ie(t,e="reka"){return`${e}-${k?.()}`}function re(t,e){const i=I(t);function a(d){return e[i.value][d]??i.value}return{state:i,dispatch:d=>{i.value=a(d)}}}function ie(t,e){const i=I({}),a=I("none"),s=I(t),d=t.value?"mounted":"unmounted";let c;const v=e.value?.ownerDocument.defaultView??Z,{state:m,dispatch:u}=re(d,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}}),n=o=>{if(ee){const r=new CustomEvent(o,{bubbles:!1,cancelable:!1});e.value?.dispatchEvent(r)}};S(t,async(o,r)=>{const h=r!==o;if(await B(),h){const E=a.value,p=w(e.value);o?(u("MOUNT"),n("enter"),p==="none"&&n("after-enter")):p==="none"||p==="undefined"||i.value?.display==="none"?(u("UNMOUNT"),n("leave"),n("after-leave")):r&&E!==p?(u("ANIMATION_OUT"),n("leave")):(u("UNMOUNT"),n("after-leave"))}},{immediate:!0});const l=o=>{const r=w(e.value),h=r.includes(o.animationName),E=m.value==="mounted"?"enter":"leave";if(o.target===e.value&&h&&(n(`after-${E}`),u("ANIMATION_END"),!s.value)){const p=e.value.style.animationFillMode;e.value.style.animationFillMode="forwards",c=v?.setTimeout(()=>{e.value?.style.animationFillMode==="forwards"&&(e.value.style.animationFillMode=p)})}o.target===e.value&&r==="none"&&u("ANIMATION_END")},f=o=>{o.target===e.value&&(a.value=w(e.value))},g=S(e,(o,r)=>{o?(i.value=getComputedStyle(o),o.addEventListener("animationstart",f),o.addEventListener("animationcancel",l),o.addEventListener("animationend",l)):(u("ANIMATION_END"),c!==void 0&&v?.clearTimeout(c),r?.removeEventListener("animationstart",f),r?.removeEventListener("animationcancel",l),r?.removeEventListener("animationend",l))},{immediate:!0}),A=S(m,()=>{const o=w(e.value);a.value=m.value==="mounted"?o:"none"});return q(()=>{g(),A()}),{isPresent:b(()=>["mounted","unmountSuspended"].includes(m.value))}}function w(t){return t&&getComputedStyle(t).animationName||"none"}var Ee=M({name:"Presence",props:{present:{type:Boolean,required:!0},forceMount:{type:Boolean}},slots:{},setup(t,{slots:e,expose:i}){const{present:a,forceMount:s}=x(t),d=I(),{isPresent:c}=ie(a,d);i({present:c});let v=e.default({present:c.value});v=Q(v||[]);const m=G();if(v&&v?.length>1){const u=m?.parent?.type.name?`<${m.parent.type.name} />`:"component";throw new Error([`Detected an invalid children for \`${u}\` 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(n=>`  - ${n}`).join(`
`)].join(`
`))}return()=>s.value||a.value||c.value?C(e.default({present:c.value})[0],{ref:u=>{const n=te(u);return typeof n?.hasAttribute>"u"||(n?.hasAttribute("data-reka-popper-content-wrapper")?d.value=n.firstElementChild:d.value=n),n}}):null}});const U="data-reka-collection-item";function se(t={}){const{key:e="",isProvider:i=!1}=t,a=`${e}CollectionProvider`;let s;if(i){const n=I(new Map);s={collectionRef:I(),itemMap:n},V(a,s)}else s=j(a);const d=(n=!1)=>{const l=s.collectionRef.value;if(!l)return[];const f=Array.from(l.querySelectorAll(`[${U}]`)),A=Array.from(s.itemMap.value.values()).sort((T,o)=>f.indexOf(T.ref)-f.indexOf(o.ref));return n?A:A.filter(T=>T.ref.dataset.disabled!=="")},c=M({name:"CollectionSlot",setup(n,{slots:l}){const{primitiveElement:f,currentElement:g}=R();return S(g,()=>{s.collectionRef.value=g.value}),()=>C(O,{ref:f},l)}}),v=M({name:"CollectionItem",inheritAttrs:!1,props:{value:{validator:()=>!0}},setup(n,{slots:l,attrs:f}){const{primitiveElement:g,currentElement:A}=R();return K(T=>{if(A.value){const o=Y(A.value);s.itemMap.value.set(o,{ref:A.value,value:n.value}),T(()=>s.itemMap.value.delete(o))}}),()=>C(O,{...f,[U]:"",ref:g},l)}}),m=b(()=>Array.from(s.itemMap.value.values())),u=b(()=>s.itemMap.value.size);return{getItems:d,reactiveItems:m,itemMapSize:u,CollectionSlot:c,CollectionItem:v}}const ue="rovingFocusGroup.onEntryFocus",le={bubbles:!1,cancelable:!0},ce={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function de(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ye(t,e,i){const a=de(t.key,i);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(a))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(a)))return ce[a]}function fe(t,e=!1){const i=P();for(const a of t)if(a===i||(a.focus({preventScroll:e}),P()!==i))return}function Te(t,e){return t.map((i,a)=>t[(e+a)%t.length])}const[Ne,me]=ae("RovingFocusGroup");var ve=M({__name:"RovingFocusGroup",props:{orientation:{type:String,required:!1,default:void 0},dir:{type:String,required:!1},loop:{type:Boolean,required:!1,default:!1},currentTabStopId:{type:[String,null],required:!1},defaultCurrentTabStopId:{type:String,required:!1},preventScrollOnEntryFocus:{type:Boolean,required:!1,default:!1},asChild:{type:Boolean,required:!1},as:{type:null,required:!1}},emits:["entryFocus","update:currentTabStopId"],setup(t,{expose:e,emit:i}){const a=t,s=i,{loop:d,orientation:c,dir:v}=x(a),m=oe(v),u=ne(a,"currentTabStopId",s,{defaultValue:a.defaultCurrentTabStopId,passive:a.currentTabStopId===void 0}),n=I(!1),l=I(!1),f=I(0),{getItems:g,CollectionSlot:A}=se({isProvider:!0});function T(r){const h=!l.value;if(r.currentTarget&&r.target===r.currentTarget&&h&&!n.value){const E=new CustomEvent(ue,le);if(r.currentTarget.dispatchEvent(E),s("entryFocus",E),!E.defaultPrevented){const p=g().map(y=>y.ref).filter(y=>y.dataset.disabled!==""),F=p.find(y=>y.getAttribute("data-active")===""),D=p.find(y=>y.getAttribute("data-highlighted")===""),L=p.find(y=>y.id===u.value),$=[F,D,L,...p].filter(Boolean);fe($,a.preventScrollOnEntryFocus)}}l.value=!1}function o(){setTimeout(()=>{l.value=!1},1)}return e({getItems:g}),me({loop:d,dir:m,orientation:c,currentTabStopId:u,onItemFocus:r=>{u.value=r},onItemShiftTab:()=>{n.value=!0},onFocusableItemAdd:()=>{f.value++},onFocusableItemRemove:()=>{f.value--}}),(r,h)=>(z(),W(N(A),null,{default:_(()=>[H(N(X),{tabindex:n.value||f.value===0?-1:0,"data-orientation":N(c),as:r.as,"as-child":r.asChild,dir:N(m),style:{outline:"none"},onMousedown:h[0]||(h[0]=E=>l.value=!0),onMouseup:o,onFocus:T,onBlur:h[1]||(h[1]=E=>n.value=!1)},{default:_(()=>[J(r.$slots,"default")]),_:3},8,["tabindex","data-orientation","as","as-child","dir"])]),_:3}))}}),we=ve;export{Ee as P,we as R,se as a,fe as f,ye as g,Ne as i,Ie as u,Te as w};
