import{c as E}from"/build/_shared/chunk-7Z6LVCRT.js";import{r as m,s as p}from"/build/_shared/chunk-VX2L2R2M.js";import{a as S}from"/build/_shared/chunk-XIQ3C74K.js";import{d as M}from"/build/_shared/chunk-G5WX4PPA.js";var a=M(S(),1),P=(0,a.createContext)(void 0);function T(s){let i=(0,a.useContext)(P);return s||i||"ltr"}var e=M(S(),1);function y(s){let i=s+"CollectionProvider",[h,I]=E(i),[O,f]=h(i,{collectionRef:{current:null},itemMap:new Map}),u=r=>{let{scope:t,children:l}=r,o=e.default.useRef(null),c=e.default.useRef(new Map).current;return e.default.createElement(O,{scope:t,itemMap:c,collectionRef:o},l)},$=s+"CollectionSlot",C=e.default.forwardRef((r,t)=>{let{scope:l,children:o}=r,c=f($,l),n=m(t,c.collectionRef);return e.default.createElement(p,{ref:n},o)}),x=s+"CollectionItemSlot",R="data-radix-collection-item",b=e.default.forwardRef((r,t)=>{let{scope:l,children:o,...c}=r,n=e.default.useRef(null),v=m(t,n),d=f(x,l);return e.default.useEffect(()=>(d.itemMap.set(n,{ref:n,...c}),()=>void d.itemMap.delete(n))),e.default.createElement(p,{[R]:"",ref:v},o)});function A(r){let t=f(s+"CollectionConsumer",r);return e.default.useCallback(()=>{let o=t.collectionRef.current;if(!o)return[];let c=Array.from(o.querySelectorAll(`[${R}]`));return Array.from(t.itemMap.values()).sort((d,N)=>c.indexOf(d.ref.current)-c.indexOf(N.ref.current))},[t.collectionRef,t.itemMap])}return[{Provider:u,Slot:C,ItemSlot:b},A,I]}export{y as a,T as b};
