import{W as l,j as d}from"./markdown-9_JKOUHQ.js";import{g as y,h as S,i as M}from"./index-Z_QI94Zg.js";function h(s){const a=s+"CollectionProvider",[A,E]=y(a),[N,f]=A(a,{collectionRef:{current:null},itemMap:new Map}),p=c=>{const{scope:e,children:r}=c,o=l.useRef(null),t=l.useRef(new Map).current;return d.jsx(N,{scope:e,itemMap:t,collectionRef:o,children:r})};p.displayName=a;const m=s+"CollectionSlot",T=M(m),C=l.forwardRef((c,e)=>{const{scope:r,children:o}=c,t=f(m,r),n=S(e,t.collectionRef);return d.jsx(T,{ref:n,children:o})});C.displayName=m;const u=s+"CollectionItemSlot",R="data-radix-collection-item",O=M(u),x=l.forwardRef((c,e)=>{const{scope:r,children:o,...t}=c,n=l.useRef(null),I=S(e,n),i=f(u,r);return l.useEffect(()=>(i.itemMap.set(n,{ref:n,...t}),()=>{i.itemMap.delete(n)})),d.jsx(O,{[R]:"",ref:I,children:o})});x.displayName=u;function _(c){const e=f(s+"CollectionConsumer",c);return l.useCallback(()=>{const o=e.collectionRef.current;if(!o)return[];const t=Array.from(o.querySelectorAll(`[${R}]`));return Array.from(e.itemMap.values()).sort((i,v)=>t.indexOf(i.ref.current)-t.indexOf(v.ref.current))},[e.collectionRef,e.itemMap])}return[{Provider:p,Slot:C,ItemSlot:x},_,E]}export{h as c};
