"use strict";const r=require("react"),v=require("./index-kcwFA4Dv.js"),S=require("./index-_XxjJPRD.js"),M=require("./index-Hk_HrrHM.js"),m=require("react/jsx-runtime");function y(s){const u=s+"CollectionProvider",[A,N]=v.createContextScope(u),[E,d]=A(u,{collectionRef:{current:null},itemMap:new Map}),C=c=>{const{scope:e,children:l}=c,t=r.useRef(null),o=r.useRef(new Map).current;return m.jsx(E,{scope:e,itemMap:o,collectionRef:t,children:l})};C.displayName=u;const a=s+"CollectionSlot",T=M.createSlot(a),p=r.forwardRef((c,e)=>{const{scope:l,children:t}=c,o=d(a,l),n=S.useComposedRefs(e,o.collectionRef);return m.jsx(T,{ref:n,children:t})});p.displayName=a;const f=s+"CollectionItemSlot",R="data-radix-collection-item",O=M.createSlot(f),x=r.forwardRef((c,e)=>{const{scope:l,children:t,...o}=c,n=r.useRef(null),I=S.useComposedRefs(e,n),i=d(f,l);return r.useEffect(()=>(i.itemMap.set(n,{ref:n,...o}),()=>{i.itemMap.delete(n)})),m.jsx(O,{[R]:"",ref:I,children:t})});x.displayName=f;function _(c){const e=d(s+"CollectionConsumer",c);return r.useCallback(()=>{const t=e.collectionRef.current;if(!t)return[];const o=Array.from(t.querySelectorAll(`[${R}]`));return Array.from(e.itemMap.values()).sort((i,q)=>o.indexOf(i.ref.current)-o.indexOf(q.ref.current))},[e.collectionRef,e.itemMap])}return[{Provider:C,Slot:p,ItemSlot:x},_,N]}exports.createCollection=y;
//# sourceMappingURL=index-BG6K_yAm.js.map
