react-animated-select 0.7.5 → 0.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +873 -670
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),o=require("react"),Ue=require("react-dom"),W=o.createContext(null),ee=o.createContext(null),te=o.createContext(null),it=(e,t)=>{const n=typeof t=="function"?t(e):t;return n===e?e:Object.keys(n).some(r=>!Object.is(n[r],e[r]))?{...e,...n}:e},ye=e=>{let t=e;const n=new Set;return{get:()=>t,set:s=>{Object.keys(s).every(r=>Object.is(s[r],t[r]))||(t={...t,...s},n.forEach(r=>r()))},subscribe:s=>(n.add(s),()=>n.delete(s))}},je=e=>{const t=o.useRef(e);o.useInsertionEffect(()=>{t.current=e});const[n]=o.useState(()=>Object.fromEntries(Object.keys(e).map(s=>[s,(...r)=>t.current[s](...r)])));return n},Ye=(e,t)=>{const[n,s]=o.useState(e);return n===e||t(n,e)?n:(s(e),e)},at=(e,t)=>e===t||!!e&&!!t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Object.is(e[n],t[n])),be=(e,t,n=0)=>{if(Object.is(e,t))return!0;if(n>12||typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;if(e.$$typeof||t.$$typeof)return e.$$typeof===t.$$typeof&&e.type===t.type&&e.key===t.key&&be(e.props,t.props,n+1);const s=Object.keys(e);return s.length===Object.keys(t).length&&s.every(r=>Object.hasOwn(t,r)&&be(e[r],t[r],n+1))},ct=new Set(["style","texts","icons","attrs"]),lt=(e,t)=>{const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(s=>ct.has(s)?at(e[s],t[s]):Object.is(e[s],t[s]))},ut=e=>Ye(e,lt),xe=e=>Ye(e,be),ie={XMark:({className:e="",...t})=>b.jsx("svg",{className:e,viewBox:"0 0 320 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:b.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),ArrowUp:({className:e="",...t})=>b.jsx("svg",{className:e,viewBox:"0 0 448 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:b.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),Checkmark:({className:e="",...t})=>b.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:b.jsx("path",{d:"M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z"})})},Z=(e,t)=>{if(!e)return null;const n=(s={})=>({...t,...s,style:{...t?.style,...s?.style}});if(typeof e=="string")return b.jsx("img",{src:e,...n(),className:ne("rac-icon",t?.className),alt:""});if(o.isValidElement(e))return o.cloneElement(e,n(e.props));if(typeof e=="function"||typeof e=="object"&&e.$$typeof){const s=e;return b.jsx(s,{...n()})}return null},de=(e,t)=>`${e}-${String(t).replace(/[^A-Za-z0-9-]/gu,n=>`_${n.codePointAt(0).toString(36)}_`)}`,K=e=>e?"":void 0,ne=(e,t)=>t?`${e} ${t}`:e,ke=(e,t,n)=>e.jsx||(t&&"original"in e?t(e.original,{selected:n,disabled:!!e.disabled}):null),Me=b.jsxs("span",{className:"rac-dots","aria-hidden":"true",children:[b.jsx("i",{}),b.jsx("i",{}),b.jsx("i",{})]}),dt=(()=>{try{return process.env.NODE_ENV!=="production"}catch{return!1}})(),Re=new Set,Q=(e,t)=>{!dt||Re.has(e)||(Re.add(e),console.warn(`[react-animated-select] ${t}`))},U=e=>{e?.stopPropagation(),e?.preventDefault()},ft={index:-1,fallback:-1,ready:!1},ce=({index:e,fallback:t})=>e===-1?t:e,gt=10,pt=500,ht=new Set(["ArrowDown","ArrowUp","PageDown","PageUp","Home","End"]),mt=(e,t)=>o.useMemo(()=>{const n=new Set(e.map(r=>r.group).filter(Boolean)),s=r=>!!r&&!r.disabled&&!r.loading&&(r.groupHeader?n.has(r.name):!r.group||t.has(r.group));return{reach:s,list:e.flatMap((r,u)=>s(r)?[u]:[])}},[e,t]),yt=(e,t,n,s)=>{const r=e.length-1;if(r<0)return-1;if(n==="Home")return e[0];if(n==="End")return e[r];const u=n==="ArrowUp"||n==="PageUp"?-1:1,a=e.indexOf(t);if(a===-1)return e[u>0?0:r];const c=a+u*(n.startsWith("Page")?gt:1);return c>=0&&c<=r?e[c]:n.startsWith("Page")||s?e[c<0?0:r]:e[(c+e.length)%e.length]},bt=(e,t,n,s)=>{const r=[...s].every(i=>i===s[0]),u=r?s[0]:s,a=t.filter(i=>"original"in e[i]),c=Math.max(a.indexOf(n)+(r?1:0),0);for(let i=0;i<a.length;i++){const h=a[(c+i)%a.length];if(String(e[h].name).toLowerCase().startsWith(u))return h}return-1};function xt({props:e,state:t,setState:n,normalizedOptions:s,expandedGroups:r,selected:u,selectedIDs:a,visibility:c,setVisibility:i,modelActions:h,loadMoreOnce:l,highlightStore:p}){const{disabled:x,multiple:m,hasMore:O,loadButton:S,loadOffset:g,loadAhead:y,icons:L,onFocus:$,onBlur:k}=e,{selectOption:D,clear:T,removeOption:f}=h,{deleting:E}=t,{reach:C,list:R}=mt(s,r),j=o.useRef({lastWindowFocusTime:0,justFocused:!1,focusTimeout:null,query:"",queryTimeout:null}),B=o.useMemo(()=>{const d=new Set(m?a.map(M=>M.id):u?[u.id]:[]),w=d.size?s.findIndex(M=>d.has(M.id)&&C(M)):-1;return w!==-1?w:R.find(M=>!s[M].groupHeader)??R[0]??-1},[s,u,a,m,C,R]),I=d=>{!S&&c&&O&&d>=s.length-y&&l()};o.useLayoutEffect(()=>{const{index:d}=p.get();p.set({fallback:B,index:d!==-1&&C(s[d])?d:-1}),I(ce(p.get()))}),o.useEffect(()=>{const d=j.current,w=()=>d.lastWindowFocusTime=Date.now();return window.addEventListener("focus",w),()=>{window.removeEventListener("focus",w),clearTimeout(d.focusTimeout),clearTimeout(d.queryTimeout)}},[]);const A=d=>{p.set({index:d}),I(d)},v=(d,w)=>{const M=j.current;clearTimeout(M.queryTimeout),M.queryTimeout=setTimeout(()=>M.query="",pt),M.query+=d.toLowerCase();const F=bt(s,R,w,M.query);F!==-1&&A(F),c||i(!0)};return je({highlight:A,handleListScroll:d=>{if(S)return;const{scrollTop:w,scrollHeight:M,clientHeight:F}=d.currentTarget;M-w<=F+g&&l()},handleBlur:d=>{const w=d.relatedTarget?.closest(".rac-options");d.currentTarget.contains(d.relatedTarget)||w||(k?.(d),E&&n({deleting:!1}),c&&i(!1))},handleFocus:d=>{d.currentTarget.contains(d.relatedTarget)||$?.(d),!(x||E||document.hidden||Date.now()-j.current.lastWindowFocusTime<100)&&(c||(clearTimeout(j.current.focusTimeout),j.current.focusTimeout=setTimeout(()=>j.current.justFocused=!1,200),j.current.justFocused=!0,i(!0)))},toggleVisibility:d=>{if(E){U(d),n({deleting:!1});return}x||j.current.justFocused||i(!c)},handleKeyDown:d=>{if(x||d.nativeEvent?.isComposing)return;const{key:w}=d,M=ce(p.get());if(w.length===1&&!d.ctrlKey&&!d.metaKey&&!d.altKey&&(w!==" "||j.current.query)){d.preventDefault(),v(w,M);return}if(ht.has(w)){d.preventDefault(),(c||w==="Home"||w==="End")&&A(yt(R,M,w,!S&&O)),c||i(!0);return}switch(w){case"Enter":case" ":d.preventDefault(),c?M!==-1&&s[M]&&(A(M),D(s[M],d)):i(!0);break;case"Escape":if(E)n({deleting:!1});else if(c)i(!1);else break;U(d);break;case"Tab":c&&i(!1);break;case"Backspace":case"Delete":{const F=a.at(-1);if(m&&w==="Backspace"&&L.remove&&F)f(F.id);else if(L.clear&&(u||F))T();else break;d.preventDefault();break}}}})}const vt=["group","disabled","options","items","children"],Te=["name","label","id","value"],re=e=>e!=null&&e!=="",Je=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),fe=e=>Je(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),wt=e=>{try{const t=String(e);return t.startsWith("[object ")?null:t}catch{return null}},Ie=(e,t=!1)=>{if(t&&typeof e.group=="string")return e.group;const n=Te.find(u=>re(e[u]));if(n)return String(e[n]);const s=!fe(e)&&wt(e);if(s)return s;const r=Object.entries(e).find(([u,a])=>!vt.includes(u)&&re(a));return r?String(r[1]):null},St=e=>fe(e)&&("options"in e||"group"in e&&!Te.some(t=>t in e)),$e=(e,t,n,s,r,{emptyOption:u,invalidOption:a,disabledOption:c})=>{const i=`${n}-${t}`;if(e==null||e==="")return{id:i,userId:null,name:u,raw:e,disabled:!0,type:"normal",group:s,groupDisabled:r};if(typeof e=="function")return{id:i,userId:null,name:a,raw:e,disabled:!0,invalid:!0,type:"normal",group:s};if(Je(e)){const h=r||e.disabled===!0,l=e.value!==void 0?e.value:e.id!==void 0?e.id:e,p=Ie(e)||(h?c:u);return{id:i,userId:e.id??e.value??e.name??e.label,name:p,raw:l,original:e,disabled:h||p===u,type:typeof l=="boolean"?"boolean":"normal",group:s||e.group||null,groupDisabled:r}}return{id:i,userId:e,name:String(e),raw:e,original:e,disabled:r,type:typeof e=="boolean"?"boolean":"normal",group:s}},Et=({options:e,jsxOptions:t,childrenFirst:n,hasMore:s,loadButton:r,loadPending:u,loadingTitle:a,emptyOption:c,invalidOption:i,disabledOption:h,emptyGroup:l})=>{const p={emptyOption:c,invalidOption:i,disabledOption:h},x=new Map,m=[],O=new Set,S=f=>{let E=f;for(let C=1;O.has(E);C++)E=`${f}~${C}`;return O.add(E),E},g=t.map((f,E)=>{if(f.isGroupMarker)return{...f,type:"group-marker"};const C=!f.label&&!re(f.userId)&&!re(f.value)&&!f.hasJsx;return{...f,id:S(`jsx-${f.id}`),index:E,userId:f.userId,raw:f.value,original:f.value,name:f.label||(re(f.value)?String(f.value):c),disabled:!!f.disabled||C,type:typeof f.value=="boolean"?"boolean":"normal",group:f.group||null}});let y=0;const L=(f,E=null,C=!1,R="0")=>{Array.isArray(f)||(f=[f]),f.forEach((j,B)=>{const I=`${R}-${B}`;if(St(j)){const A=Ie(j,!0)||l;x.has(A)||x.set(A,{disabled:!!j.disabled,items:[]}),j.options?L(j.options,A,C||!!j.disabled,I):m.push({id:`empty-${A}-${I}`,name:A,group:A,isPlaceholder:!0,type:"group-marker",index:y++})}else fe(j)&&!Te.some(A=>A in j)&&!j.group?Object.values(j).forEach((A,v)=>m.push({...$e(A,`${I}-${v}`,"default",E,C,p),index:y++})):m.push({...$e(j,I,"default",E,C,p),index:y++})})};L(e);const $=n?[...g,...m]:[...m,...g],k=[],D=new Set;$.forEach(f=>{if(!f.group){k.push({type:"item",data:f});return}D.has(f.group)||(D.add(f.group),k.push({type:"group",name:f.group})),x.has(f.group)||x.set(f.group,{items:[]});const E=x.get(f.group);f.isGroupMarker?(E.className=f.className,E.style=f.style,f.disabled&&(E.disabled=!0)):f.isPlaceholder||E.items.push(f)});const T=[];return k.forEach(f=>{if(f.type==="item"){T.push(f.data);return}const E=x.get(f.name);T.push({className:E?.className||"",id:`group-header-${f.name}`,disabled:!!E?.disabled,style:E?.style||{},groupHeader:!0,name:f.name,type:"group"}),E?.items.forEach(C=>T.push(C))}),s&&r&&T.push({id:"special-load-more-id",name:a,loadMore:!0,loading:u,type:"special"}),T},Ot=e=>{const t=()=>null;return t.racKind="define",t.racRender=e,t.displayName=`defineOption(${e.name||"anonymous"})`,t},Le={selected:null,selectedIDs:[]},se=e=>{try{return JSON.stringify(e)}catch{return}},Xe=(e,t)=>e===t||e!==e&&t!==t,le=e=>typeof e=="object"&&e!==null,Ct=(e,t)=>Xe(e,t)||le(e)&&le(t)&&se(e)!==void 0&&se(e)===se(t),jt=(e,t,n,s)=>{if(e==null||Array.isArray(e)&&e.length===0)return Le;const r=s.length?new Map(t.map(l=>[l.id,l])):null,u=r?[...s.map(l=>r.get(l)).filter(Boolean),...t]:t,a=new Set,c=new Map,i=l=>"original"in l&&!a.has(l.id),h=l=>{const p=le(l);let x=u.find(y=>i(y)&&Xe(y.original,l));const m=p?se(l):void 0;if(!x&&m!==void 0&&(x=u.find(y=>i(y)&&le(y.original)&&se(y.original)===m)),x)return a.add(x.id),x;const O=String(p?l.id||l.value||m||"object":l),S=(c.get(O)??-1)+1;c.set(O,S);const g=`virtual-${O}-${S}`;return p?{id:g,name:Ie(l)||String(l.id||"Selected Object"),raw:l.value??l.id??l,original:l,userId:l.id??l.value??null,virtual:!0}:{id:g,name:String(l),raw:l,original:l,userId:l,virtual:!0}};return n?{selected:null,selectedIDs:(Array.isArray(e)?e:[e]).map(h)}:{selected:h(Array.isArray(e)?e[0]:e),selectedIDs:Le.selectedIDs}},De={x:["width","marginLeft","marginRight","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],y:["height","marginTop","marginBottom","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"]},kt={x:{minWidth:"0px",maxWidth:"none"},y:{minHeight:"0px",maxHeight:"none"}},Ze=o.createContext(null);let ve=null;const Mt=()=>ve??=(queueMicrotask(()=>{ve=null}),{});function X({as:e="div",axis:t="y",fade:n=!1,in:s,unmountOnExit:r=!0,easing:u,duration:a,group:c,nodeRef:i,onEntered:h,onExited:l,...p}){const x=o.useContext(W),m=o.useContext(Ze),O=s===void 0&&!!m,S=O?m.present:!!s,g=a??x?.duration??300,y=u??x?.easing??"ease",L=o.useRef(null),$=i??L,k=o.useRef(null),D=o.useRef(!1),T=o.useRef({restart:()=>{}}),[f]=o.useState(()=>O&&m.appear?!S:S),E=o.useRef(f),[C,R]=o.useState(!S);S&&C&&R(!1);const j=o.useEffectEvent(()=>{if(c?.delete(T.current),S){k.current=null,h?.();return}l?.(),O&&m.onExited(),r&&(k.current=null,R(!0))});if(o.useLayoutEffect(()=>{const I=$.current;if(!I)return;const A=n?[...De[t],"opacity"]:De[t],v={overflow:"hidden",textOverflow:"clip",...kt[t]},d={...Object.fromEntries(A.map(P=>[P,P==="opacity"?0:"0px"])),...v},w=()=>{const P=getComputedStyle(I);return{...Object.fromEntries(A.map(H=>[H,P[H]])),...v}},M=(P,H)=>{const Y=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,q=k.current=I.animate([P,H],{duration:Y?0:g,easing:y,fill:E.current?"backwards":"both"});if(q.onfinish=()=>{k.current===q&&D.current&&j()},T.current.frames=[P,H],!c)return;const V=q.timeline?.currentTime;V!=null&&(q.startTime=V,q.currentTime=0),T.current.batch=Mt(),c.add(T.current)},F=()=>{const[P,H]=T.current.frames,Y=k.current.effect.getComputedTiming().progress??0,q=V=>parseFloat(P[V])+(parseFloat(H[V])-parseFloat(P[V]))*Y;return{...Object.fromEntries(A.map(V=>[V,V==="opacity"?q(V):`${q(V)}px`])),...v}};if(T.current.restart=P=>{const H=k.current;if(H?.playState!=="running"||!P&&T.current.batch===ve)return;const Y=F();H.cancel(),M(Y,E.current?w():d)},E.current===S){!S&&!k.current&&I.animate&&(k.current=I.animate([d,d],{fill:"forwards"}));return}E.current=S;const z=k.current;if(z?.playState==="running"){if(!c){z.reverse();return}T.current.restart(!0)}else{if(z?.cancel(),!I.animate){j();return}S?M(d,w()):M(w(),d)}c?.forEach(P=>P!==T.current&&P.restart())},[S,t,n,g,y,$,c]),o.useLayoutEffect(()=>{const I=T.current;return D.current=!0,k.current?.playState==="running"&&c?.add(I),()=>{D.current=!1,c?.delete(I)}},[c]),C&&r)return null;const B=e;return b.jsx(B,{ref:$,...p})}const Tt=({id:e,present:t,appear:n,onExited:s,children:r})=>{const u=o.useMemo(()=>({present:t,appear:n,onExited:()=>s(e)}),[e,t,n,s]);return b.jsx(Ze.Provider,{value:u,children:r})},Pe=(e,t,n=!0)=>{const s=o.Children.toArray(t).filter(o.isValidElement),r=new Set(s.map(i=>i.key)),u=new Map(e.map(i=>[i.key,i])),a=s.map(i=>({key:i.key,el:i,present:!0,appear:u.get(i.key)?.appear??n}));let c=0;return e.forEach(i=>{r.has(i.key)?i.present&&(c=a.findIndex(h=>h.key===i.key)+1):a.splice(c++,0,i.present?{...i,present:!1}:i)}),{children:t,list:a}};function we({children:e,hold:t=!1}){const[n,s]=o.useState(()=>({...Pe([],e,!1),hold:t}));let r=n;r.children!==e&&(r={...r,...Pe(r.list,e)}),r.hold!==t&&(r={...r,hold:t,list:t?r.list:r.list.filter(a=>a.present)}),r!==n&&s(r);const u=o.useCallback(a=>s(c=>!c.hold&&c.list.some(i=>i.key===a&&!i.present)?{...c,list:c.list.filter(i=>i.key!==a)}:c),[]);return n.list.map(({key:a,el:c,present:i,appear:h})=>b.jsx(Tt,{id:a,present:i,appear:h,onExited:u,children:c},a))}const Qe="rac-chip-slot",Se="rac-flip",Ne=[],It=.25,Nt={hoverId:null,swipedId:null,held:!1,breaks:Ne},Ee=()=>window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,ue=e=>Array.from(e.children).filter(t=>t.classList.contains(Qe)),Ve=e=>Array.from(e.children).some(t=>t.getAnimations?.().some(n=>n.constructor===Animation&&n.id!==Se&&n.playState==="running")),At=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),Rt=e=>{const t=[];let n=-1/0;for(const s of e){const r=s.getBoundingClientRect();r.top>=n-1&&(t.push([]),n=r.bottom),t.at(-1).push(s),n=Math.max(n,r.bottom)}return t},et=(e,t,n,s)=>{const r=e.cloneNode(!0),{height:u,paddingInlineEnd:a}=getComputedStyle(e);r.style.cssText=`visibility: hidden; pointer-events: none; height: ${u}; min-height: 0; padding-inline-end: calc(${a} + ${n}px)`,r.querySelectorAll(`:scope > :not(.${Qe})`).forEach(l=>l.remove()),s&&ue(r).forEach(l=>s.has(l.dataset.id)||l.remove()),n&&r.querySelectorAll(".rac-chip-del").forEach(l=>l.remove());const c=ue(r),i=new Map(c.map((l,p)=>[l.dataset.id,p]));t?.slice(1).forEach((l,p)=>{const x=Math.min(...l.map(O=>i.get(O)??1/0)),m=Math.max(...t[p].map(O=>i.get(O)??-1).filter(O=>O<x));m>=0&&c[m].after(Object.assign(document.createElement("div"),{className:"rac-spacer"}))}),e.style.position="absolute",e.after(r),r.getAnimations?.({subtree:!0}).forEach(l=>l.effect?.getComputedTiming().endTime<1/0&&l.finish());const h=Rt(c).map(l=>l.map(p=>p.dataset.id));return r.remove(),e.style.position="",h},tt=(e,t)=>{const n=t?t.slice(0,-1).map(r=>r.at(-1)):Ne,{breaks:s}=e.get();return At(s,n)?s:n},Be=(e,t,n,s)=>tt(e,s&&n.length?et(t,null,s,new Set(n.map(r=>r.id))):null),Fe=(e,t,n)=>{n.rows=et(t,n.rows,n.reserve),e.set({held:!0,breaks:tt(e,n.rows)})},He=(e,t,n,s)=>{if(!e.animate)return;e.getAnimations().forEach(c=>c.id===Se&&c.cancel());const r=e.getBoundingClientRect(),u=t.left-r.left,a=t.top-r.top;(Math.abs(u)>.5||Math.abs(a)>.5)&&e.animate([{transform:`translate(${u}px, ${a}px)`},{transform:"none"}],{id:Se,duration:n,easing:s})},$t=(e,t,n,s,r)=>{if(!e||n===t.value)return;const u=getComputedStyle(e),a=t.anim?u.height:t.root;t.anim?.cancel(),t.root=u.height;const c=!t.value||a===t.root||!e.animate||Ee();if(t.value=n,t.anim=null,c)return;const i={overflow:"hidden",alignItems:"flex-start"},h=t.anim=e.animate([{...i,height:a},{...i,height:t.root}],{duration:s,easing:r});h.onfinish=()=>{t.anim===h&&(t.anim=null)}};function Lt(e){const{selectRef:t,duration:n,easing:s,multiple:r,deleteInline:u,deleteAlways:a,icons:c}=o.useContext(W),{selectedIDs:i,deleting:h,visibility:l,active:p}=o.useContext(te),{setDeleting:x,setVisibility:m}=o.useContext(ee),[O,S]=o.useState(0),[g]=o.useState(()=>ye(Nt)),[y]=o.useState(()=>new Set),L=o.useSyncExternalStore(g.subscribe,()=>g.get().held,()=>!1),$=o.useSyncExternalStore(g.subscribe,()=>g.get().breaks,()=>Ne),k=o.useRef({rows:null,reserve:0,chips:e}),D=o.useRef(null),T=o.useRef({value:0,root:"",anim:null}),f=o.useRef(null),E=o.useRef(null),C=u&&!a&&!h&&!!c.remove,R=C?O+It:0,j=r&&C&&!O,B=o.useEffectEvent(v=>{const d=f.current,w=k.current;d&&(v&&g.get().held&&Fe(g,d,w),$t(t.current,T.current,d.offsetHeight,n,s),g.get().held||g.set({breaks:Be(g,d,w.chips,w.reserve)}))});o.useLayoutEffect(()=>{const v=k.current,d=f.current,w=v.chips!==e;Object.assign(v,{chips:e,reserve:R}),w&&d&&Ve(d)&&Fe(g,d,v),B(!w)},[e,R,g]),o.useLayoutEffect(()=>{const v=()=>B(!0),d=typeof ResizeObserver>"u"?null:new ResizeObserver(v);return d?.observe(f.current),document.fonts?.addEventListener("loadingdone",v),()=>{d?.disconnect(),document.fonts?.removeEventListener("loadingdone",v)}},[]);const I=o.useCallback(()=>{const v=f.current;if(!v||!g.get().held||Ve(v))return;const d=ue(v),w=d.map(F=>F.getBoundingClientRect()),M=Be(g,v,k.current.chips,k.current.reserve);k.current.rows=null,Ue.flushSync(()=>g.set({held:!1,breaks:M})),Ee()||d.forEach((F,z)=>F.isConnected&&He(F,w[z],n,s))},[g,n,s]),A=o.useCallback(()=>{f.current&&(D.current=new Map(ue(f.current).map(v=>[v,v.getBoundingClientRect()])))},[]);return o.useLayoutEffect(()=>{const v=D.current;!v||$!==g.get().breaks||(D.current=null,Ee()||v.forEach((d,w)=>w.isConnected&&He(w,d,n,s)))},[$,e,g,n,s]),o.useEffect(()=>()=>T.current.anim?.cancel(),[]),o.useEffect(()=>{h&&l&&m(!1),h&&(!i.length||!p)&&x(!1),g.set({hoverId:null,...!p&&{swipedId:null}})},[i.length,h,l,p,x,m,g]),o.useLayoutEffect(()=>{const v=E.current;if(!j||!v)return;const d=getComputedStyle(v);S(v.getBoundingClientRect().width+parseFloat(d.marginLeft)+parseFloat(d.marginRight))},[j]),{chipStore:g,delGroup:y,valueRef:f,delIconRef:E,probe:j,settle:I,held:L,snapshot:A}}const Ge=1,qe=2,Dt=600,Pt=10,We=30,Vt=o.memo(function({element:t,deleting:n,locked:s,chipStore:r,delGroup:u}){const{selectRef:a,deleteInline:c,deleteAlways:i,icons:h,texts:l,valueAsOption:p,renderOption:x}=o.useContext(W),m=!!h.remove,{setVisibility:O,setDeleting:S,removeOption:g}=o.useContext(ee),y=o.useRef({longPressTimer:null,longPress:!1,x:0,y:0}),L=o.useSyncExternalStore(r.subscribe,()=>{const{hoverId:v,swipedId:d}=r.get();return(v===t.id?Ge:0)|(d===t.id?qe:0)},()=>0),$=!!(L&Ge),k=!!(L&qe),D=o.useCallback(v=>{const{clientX:d,clientY:w}=v.touches[0];Object.assign(y.current,{x:d,y:w,longPress:!1}),clearTimeout(y.current.longPressTimer),m&&(y.current.longPressTimer=setTimeout(()=>{S(!0),y.current.longPress=!0,a.current?.focus(),O(!1),window.navigator.vibrate?.(50)},Dt))},[m,S,O,a]),T=o.useCallback(v=>{const{clientX:d,clientY:w}=v.touches[0],M=y.current.x-d;Math.hypot(M,y.current.y-w)>Pt&&clearTimeout(y.current.longPressTimer),M>We&&!k?r.set({hoverId:null,swipedId:t.id}):M<-We&&k&&r.set({swipedId:null})},[t.id,k,r]),f=o.useCallback(()=>clearTimeout(y.current.longPressTimer),[]),E=o.useCallback(()=>r.set({hoverId:t.id,swipedId:null}),[t.id,r]),C=o.useCallback(()=>{r.get().hoverId===t.id&&r.set({hoverId:null})},[t.id,r]);o.useEffect(()=>()=>clearTimeout(y.current.longPressTimer),[]);const R=p?ke(t,x,!0):null,j=R?b.jsx("div",{className:"rac-option-jsx",children:R}):b.jsx("span",{className:"rac-chip-text",children:t.name||l.emptyOption}),B=o.useCallback(v=>{r.set({swipedId:null}),g(t.id),U(v)},[t.id,g,r]),I=o.useCallback(v=>{U(v),y.current.longPress?y.current.longPress=!1:n&&B(v)},[n,B]),A=m&&(i||!s&&($||k||n));return b.jsxs("div",{className:ne("rac-chip",R&&t.className),style:R?t.style:void 0,...!s&&{onTouchStart:D,onTouchMove:T,onTouchEnd:f,onTouchCancel:f,onMouseEnter:E,onMouseLeave:C,onClick:I},children:[j,b.jsx(X,{"aria-label":`${l.remove} ${t.name??""}`.trim(),group:c&&!i&&!n?u:void 0,onMouseDown:U,onClick:B,className:"rac-chip-del",disabled:s,tabIndex:-1,type:"button",in:A,as:"button",axis:"x",children:Z(h.remove)})]})}),Bt=o.memo(function({element:t,chipStore:n,settle:s,...r}){const u=o.useSyncExternalStore(n.subscribe,()=>n.get().breaks.includes(t.id),()=>!1);return b.jsxs(o.Fragment,{children:[b.jsx(X,{className:"rac-chip-slot",onEntered:s,onExited:s,unmountOnExit:!1,"data-id":t.id,axis:"x",fade:!0,children:b.jsx(Vt,{element:t,chipStore:n,...r})}),u&&b.jsx("div",{className:"rac-spacer"})]})}),Ft={position:"absolute",visibility:"hidden",pointerEvents:"none"},Oe=[],Ht=()=>{},Gt=e=>e==null?"":typeof e=="object"?se(e)??"":String(e),qt=o.memo(function(){const{selectRef:t,multiple:n,name:s,required:r}=o.useContext(W),{selected:u,selectedIDs:a,disabled:c}=o.useContext(te);if(!s&&!r)return null;const i=(n?a:u?[u]:Oe).map(p=>Gt(p.original)),h=i.length?i:n&&!r?Oe:[""],l=()=>t.current?.focus();return h.map((p,x)=>b.jsx("input",{className:"rac-input",name:s,value:p,required:r&&!x,disabled:c,tabIndex:-1,"aria-hidden":"true",onChange:Ht,onFocus:l},x))});class Wt extends o.Component{getSnapshotBeforeUpdate(t){return t.chips!==this.props.chips&&this.props.take(),null}componentDidUpdate(){}render(){return null}}const ze=(e,t)=>{const n=new Set(e.map(a=>a.id)),s=new Map(t.map(([a,c])=>[c.id,a])),r=t.filter(([,a])=>!n.has(a.id)),u=new Set(t.map(([a])=>a));return e.map(a=>{if(s.has(a.id))return[s.get(a.id),a];const c=r.findIndex(([,h])=>Ct(h.original,a.original));if(c>=0)return[r.splice(c,1)[0][0],a];let i=a.id;for(;u.has(i);)i+="~";return u.add(i),[i,a]})},zt=e=>{const[t,n]=o.useState(()=>({chips:e,keyed:ze(e,[])}));if(t.chips===e)return t.keyed;const s=ze(e,t.keyed);return n({chips:e,keyed:s}),s},Kt=o.memo(function(){const{selectedText:t,icons:n,valueAsOption:s,renderOption:r}=o.useContext(W),{selectedIDs:u,title:a,valueOption:c,hasActualValue:i,loading:h,error:l,deleting:p,active:x}=o.useContext(te),m=u.length>0&&!t,O=m?u:Oe,{chipStore:S,delGroup:g,valueRef:y,delIconRef:L,probe:$,settle:k,held:D,snapshot:T}=Lt(O),f=zt(O),[E]=o.useState(()=>new Set),C=s&&c?ke(c,r,!0):null,R=h&&!l&&!i,j=`${C?c.id:a}${R?"-loading":""}`,B=c?.type==="boolean"?String(c.raw):void 0;return b.jsxs("div",{className:"rac-value",ref:y,children:[b.jsx(Wt,{chips:O,take:T}),b.jsx(we,{children:!m&&b.jsxs(X,{axis:"x",fade:!0,group:E,className:ne("rac-title",C&&c.className),style:C?c.style:void 0,"data-bool":B,onEntered:k,onExited:k,children:[C?b.jsx("div",{className:"rac-option-jsx",children:C}):a,R&&Me]},j)}),b.jsx(we,{hold:D,children:f.map(([I,A])=>b.jsx(Bt,{element:A,deleting:p,locked:!x,chipStore:S,delGroup:g,settle:k},I))}),$&&b.jsx("button",{type:"button",className:"rac-chip-del",tabIndex:-1,"aria-hidden":"true",ref:L,style:Ft,children:Z(n.remove)})]})}),_t=o.memo(function(){const{selectRef:t,selectId:n,highlightStore:s,positionStore:r,className:u,style:a,duration:c,easing:i,deleteInline:h,icons:l,texts:p,placeholder:x,id:m,required:O,attrs:S}=o.useContext(W),{visibility:g,active:y,hasActualValue:L,deleting:$,loading:k,loadPending:D,error:T,normalizedOptions:f}=o.useContext(te),{handleBlur:E,handleFocus:C,handleKeyDown:R,toggleVisibility:j,clear:B}=o.useContext(ee),I=o.useSyncExternalStore(r.subscribe,()=>r.get().upward,()=>!1),A=o.useSyncExternalStore(s.subscribe,()=>{const w=g?f[ce(s.get())]:null;return w?de(n,w.id):void 0},()=>{}),v=!!l.clear&&L&&y&&!$,d=!!l.arrow&&y&&!$;return b.jsxs("div",{...S,id:m,ref:t,style:{"--rac-duration":`${c}ms`,"--rac-ease":i,...a},className:ne("rac-select",u),...y&&{onKeyDown:R,onFocus:C,onClick:j,onBlur:E},"aria-disabled":!y,"aria-activedescendant":A,"aria-controls":`${n}-listbox`,tabIndex:y?0:-1,"aria-expanded":g,"aria-busy":k||D||void 0,"aria-label":S["aria-label"]??(S["aria-labelledby"]?void 0:x),"aria-required":O||void 0,"aria-haspopup":"listbox",role:"combobox","data-placement":I?"top":"bottom","data-inline-delete":K(h),"data-empty":K(!L),"data-deleting":K($),"data-error":K(T),children:[b.jsx(Kt,{}),b.jsxs(we,{children:[v&&b.jsx(X,{as:"button",type:"button",axis:"x",className:"rac-clear",tabIndex:-1,"aria-label":p.clear,onMouseDown:U,onClick:B,children:Z(l.clear)},"clear"),d&&b.jsx(X,{axis:"x",className:"rac-arrow","aria-hidden":"true",children:Z(l.arrow)},"arrow")]}),b.jsx(qt,{})]})}),pe=0,Ut=1,Ke=2,nt=e=>{const{highlightStore:t}=o.useContext(W),n=o.useRef(null),s=o.useSyncExternalStore(t.subscribe,()=>{const r=t.get();return ce(r)!==e?pe:r.ready?Ke:Ut},()=>pe);return o.useLayoutEffect(()=>{s===Ke&&n.current?.scrollIntoView?.({block:"nearest"})},[s]),[n,s!==pe]},Yt=o.memo(function({option:t,index:n,open:s,hasChildren:r}){const{selectId:u,icons:a}=o.useContext(W),{selectOption:c,highlight:i}=o.useContext(ee),[h,l]=nt(n),p=r&&!t.disabled;return b.jsxs("div",{className:ne("rac-group",t.className),onMouseEnter:()=>p&&i(n),onClick:x=>c(t,x),"data-highlighted":K(l),"data-disabled":K(t.disabled),id:de(u,t.id),"data-open":K(s),style:t.style,ref:h,children:[b.jsx("span",{className:"rac-group-text",children:t.name}),b.jsx(X,{axis:"x",in:r&&!t.disabled,className:"rac-group-arrow","aria-hidden":"true",children:Z(a.arrow)})]})}),Jt=o.memo(function({option:t,index:n,isSelected:s,showCheckbox:r}){const{selectId:u,icons:a,renderOption:c}=o.useContext(W),{selectOption:i,highlight:h}=o.useContext(ee),[l,p]=nt(n),x=!t.disabled&&!t.loading,m=ke(t,c,s);return b.jsxs("div",{className:ne("rac-option",t.className),onMouseEnter:()=>x&&h(n),onClick:O=>!t.loading&&i(t,O),"aria-disabled":t.disabled||t.loading,"data-invalid":K(t.invalid),"data-bool":typeof t.raw=="boolean"?String(t.raw):void 0,"data-highlighted":K(p),"data-loading":K(t.loading),id:de(u,t.id),"aria-selected":s,style:t.style,role:"option",ref:l,children:[m?b.jsx("div",{className:"rac-option-jsx",children:m}):b.jsx("span",{className:"rac-option-text",children:t.name}),t.loading&&Me,r&&b.jsxs("div",{className:"rac-check","data-default":K(!a.checkbox),children:[Z(a.check,{className:"rac-checkmark"}),Z(a.checkbox,{className:"rac-check-icon"})]})]})}),Xt=o.memo(function(){const{selectId:t,multiple:n}=o.useContext(W),{normalizedOptions:s,selected:r,selectedIDs:u,expandedGroups:a}=o.useContext(te),c=r?.id;return o.useMemo(()=>{const i=new Set(u.map(g=>g.id)),h=s.reduce((g,y)=>(y.group&&(g[y.group]=(g[y.group]||0)+1),g),{}),l=[];let p=[],x=null,m=null;const O=()=>{x!==null&&p.length&&l.push(b.jsx(X,{axis:"y",in:a.has(x),className:"rac-group-items",role:"group","aria-labelledby":m,children:p},`slide-${x}`)),p=[]},S=(g,y)=>b.jsx(Jt,{isSelected:i.has(g.id)||c===g.id,showCheckbox:n&&!g.disabled,option:g,index:y},g.id);return s.forEach((g,y)=>{g.groupHeader?(O(),x=g.name,m=de(t,g.id),l.push(b.jsx(Yt,{hasChildren:h[g.name]>0,open:a.has(g.name),option:g,index:y},g.id))):g.group?p.push(S(g,y)):(O(),x=null,l.push(S(g,y)))}),O(),l},[s,c,u,a,n,t])}),Zt=(e={})=>Object.fromEntries(Object.entries(e).filter(([t])=>t.startsWith("--"))),Qt=(e,t,n,s)=>{const r=e.getBoundingClientRect(),u=getComputedStyle(e),a=r.left-parseFloat(u.marginLeft)-t.left,c=n?r.bottom+parseFloat(u.marginBottom)-t.top+s:r.top-parseFloat(u.marginTop)-t.bottom-s;Math.abs(a)>.5&&(e.style.left=`${t.left-a}px`),Math.abs(c)>.5&&(e.style[n?"bottom":"top"]=`${parseFloat(e.style[n?"bottom":"top"])+(n?c:-c)}px`)},en=({selectRef:e,panelRef:t,open:n,offset:s,store:r})=>{const u=o.useRef(0),a=o.useCallback(i=>{const h=e.current;if(!h)return;const l=n&&i?i.scrollHeight:0;l&&(u.current=l),u.current||(u.current=parseFloat(getComputedStyle(h).getPropertyValue("--rac-list-max-height"))||250);const p=h.getBoundingClientRect(),x=window.innerHeight-p.bottom,m=x<u.current&&p.top>x;r.set({upward:m}),!(!n||!i)&&(i.style.width=`${p.width}px`,i.style.left=`${p.left}px`,i.style.top=m?"auto":`${p.bottom+s}px`,i.style.bottom=m?`${window.innerHeight-p.top+s}px`:"auto",Qt(i,p,m,s))},[e,n,s,r]),c=o.useCallback(i=>{i&&a(i.parentElement)},[a]);return o.useLayoutEffect(()=>{const i=()=>a(t.current);i(),window.addEventListener("resize",i);const h=[()=>window.removeEventListener("resize",i)];if(n){if(window.addEventListener("scroll",i,{capture:!0,passive:!0}),h.push(()=>window.removeEventListener("scroll",i,{capture:!0})),typeof ResizeObserver<"u"){const l=new ResizeObserver(i);e.current&&l.observe(e.current),t.current&&l.observe(t.current),h.push(()=>l.disconnect())}}else if(typeof IntersectionObserver<"u"){const l=new IntersectionObserver(i,{threshold:[0,.25,.5,.75,1]});e.current&&l.observe(e.current),h.push(()=>l.disconnect())}return()=>h.forEach(l=>l())},[n,a,e,t]),[o.useSyncExternalStore(r.subscribe,()=>r.get().upward,()=>!1),c]},tn=e=>(typeof e=="function"?e():e)||document.body,nn=()=>()=>{},sn=o.memo(function(){const{selectRef:t,selectId:n,positionStore:s,multiple:r,offset:u,duration:a,easing:c,animateOpacity:i,keepMounted:h,optionsClassName:l,style:p,container:x,hasMore:m,loadButton:O,texts:S}=o.useContext(W),{visibility:g,normalizedOptions:y,loading:L,error:$}=o.useContext(te),{handleListScroll:k,setListReady:D}=o.useContext(ee),T=g&&y.length>0,f=o.useSyncExternalStore(nn,()=>!0,()=>!1),E=o.useRef(null),[C,R]=en({selectRef:t,panelRef:E,open:g&&f,offset:u,store:s}),j=o.useCallback(()=>D(!0),[D]);return f?Ue.createPortal(b.jsx(X,{axis:"y",fade:i,in:T,nodeRef:E,unmountOnExit:!h,onEntered:j,onMouseDown:B=>B.preventDefault(),className:ne("rac-options",l),"data-placement":C?"top":"bottom",style:{...Zt(p),"--rac-duration":`${a}ms`,"--rac-ease":c,pointerEvents:T?"auto":"none",position:"fixed"},children:b.jsxs("div",{onScroll:k,className:"rac-list","aria-multiselectable":r,id:`${n}-listbox`,"aria-label":S.list,role:"listbox",tabIndex:"-1",ref:R,children:[b.jsx(Xt,{}),$?b.jsx("div",{className:"rac-option","data-error":"",children:b.jsx("span",{className:"rac-option-text",children:S.error})}):(L||!O&&m)&&b.jsxs("div",{className:"rac-option","data-loading":"",children:[b.jsx("span",{className:"rac-option-text",children:L?S.loading:S.loadingMore}),Me]})]})}),tn(x)):null}),st=[];function rn({props:e,jsxOptions:t,state:n,setState:s,setVisibility:r,loadMoreOnce:u}){const{onChange:a,disabled:c,loading:i,error:h,multiple:l,childrenFirst:p,groupsClosed:x,hasMore:m,loadButton:O,placeholder:S,selectedText:g,texts:y}=e,{disabledOption:L,emptyOption:$,invalidOption:k,emptyGroup:D}=y,{loadPending:T,internalValue:f,toggledGroups:E,picked:C}=n,R=xe(e.options),j=xe(e.value),B=j!==void 0,I=B?j:f,A=T?y.loadingMore:y.loadMore,v=o.useMemo(()=>Et({options:R,jsxOptions:t,childrenFirst:p,hasMore:m,loadButton:O,loadPending:T,loadingTitle:A,emptyOption:$,invalidOption:k,disabledOption:L,emptyGroup:D}),[R,t,p,m,O,T,A,$,k,L,D]),d=o.useMemo(()=>new Set(v.filter(N=>N.groupHeader&&!N.disabled&&x===E.has(N.name)).map(N=>N.name)),[v,E,x]),{selected:w,selectedIDs:M}=o.useMemo(()=>jt(I,v,l,C),[I,v,l,C]),F=v.length>0,z=!c&&F,P=I!=null&&!(Array.isArray(I)&&!I.length)&&!(fe(I)&&!Object.keys(I).length),H=P&&g?null:w,Y=o.useMemo(()=>P&&g?g:w?w.name:h?y.error:i?y.loading:c?y.disabled:F?S:y.empty,[h,i,c,P,g,w,F,S,y]),q=N=>s(G=>{const J=new Set(G.toggledGroups);return J.has(N)?J.delete(N):J.add(N),{toggledGroups:J}}),V=(N,G,J)=>{s(B?{picked:J}:{internalValue:N,picked:J}),a?.(N,G)},oe=N=>V(N.map(G=>G.original),N.map(G=>G.userId),N.map(G=>G.id)),Ae=je({toggleGroup:q,selectOption:(N,G)=>{if(N.groupHeader){U(G),N.disabled||q(N.name);return}if(N.disabled||N.loadMore){U(G),N.loadMore&&!N.loading&&u();return}if(l){U(G);const J=M.some(ge=>ge.id===N.id);oe(J?M.filter(ge=>ge.id!==N.id):[...M,N]);return}w?.id!==N.id&&V(N.original,N.userId,[N.id]),r(!1)},clear:N=>{U(N),V(l?[]:null,l?[]:null,st)},removeOption:N=>oe(M.filter(G=>G.id!==N))});return{normalizedOptions:v,expandedGroups:d,selected:w,selectedIDs:M,hasOptions:F,active:z,hasActualValue:P,title:Y,valueOption:H,actions:Ae}}const on=e=>({internalVisibility:!1,deleting:!1,loadPending:!1,toggledGroups:new Set,internalValue:e.defaultValue,picked:st});function an(e,t){const{ref:n,open:s,onOpenChange:r,hasMore:u,loadMore:a,loadButton:c,error:i,disabled:h,loading:l}=e,p=o.useId(),x=o.useMemo(()=>p.replace(/:/g,""),[p]),m=o.useRef(null);o.useImperativeHandle(n,()=>m.current);const[O,S]=o.useReducer(it,e,on),{internalVisibility:g,deleting:y,loadPending:L}=O,[$]=o.useState(()=>ye(ft)),[k]=o.useState(()=>ye({upward:!1})),D=s!==void 0,T=D?!!s:g,f=o.useRef(!1),E=o.useRef(!1),C=je({setVisibility:V=>{V!==T&&(D||S({internalVisibility:V}),r?.(V))},loadMoreOnce:()=>{if(!u||f.current)return;if(!a)return Q("no loadMore","`hasMore` is set, but there is no `loadMore` to call.");f.current=!0,S({loadPending:!0});const V=()=>S({loadPending:!1});try{a()?.then?.(V,V)}catch(oe){f.current=!1,V(),(globalThis.reportError??console.error)(oe)}},setListReady:V=>$.set({ready:V}),setDeleting:V=>S({deleting:V})}),R=rn({props:e,jsxOptions:t,state:O,setState:S,setVisibility:C.setVisibility,loadMoreOnce:C.loadMoreOnce}),{normalizedOptions:j,expandedGroups:B,selected:I,selectedIDs:A,hasOptions:v,active:d,hasActualValue:w,title:M,valueOption:F,actions:z}=R,P=d&&T,H=xt({props:e,state:O,setState:S,normalizedOptions:j,expandedGroups:B,selected:I,selectedIDs:A,visibility:P,highlightStore:$,setVisibility:C.setVisibility,loadMoreOnce:C.loadMoreOnce,modelActions:z});o.useEffect(()=>{S({loadPending:!1})},[j.length,u,c]),o.useEffect(()=>{L||(f.current=!1)},[L]),o.useEffect(()=>{P&&m.current&&document.activeElement!==m.current&&m.current.focus(),P||$.set({index:-1,ready:!1})},[P,$]),o.useEffect(()=>{E.current&&!d&&C.setVisibility(!1),E.current=d},[d,C]);const Y=o.useMemo(()=>({...C,...z,...H}),[C,z,H]),q=o.useMemo(()=>({visibility:P,deleting:y,loadPending:L,expandedGroups:B,selectedIDs:A,normalizedOptions:j,selected:I,hasOptions:v,active:d,hasActualValue:w,title:M,valueOption:F,disabled:h,loading:l,error:i}),[P,y,L,B,A,j,I,v,d,w,M,F,h,l,i]);return{selectId:x,selectRef:m,highlightStore:$,positionStore:k,state:q,actions:Y}}const cn={},_=e=>e!=null&&e!=="",Ce=e=>e?typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Ce).join(" ").replace(/\s+/g," ").trim():o.isValidElement(e)?Ce(e.props.children):"":"",ln=({name:e,label:t,id:n,value:s,className:r,style:u,children:a,disabled:c,group:i},h,l)=>{const p=Ce(a),x=s!==void 0?s:p;return a!=null&&!p&&!_(t)&&!_(e)&&!_(n)&&!_(s)&&Q("no text","<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."),{id:_(n)?String(n):h,userId:_(n)?n:x,value:x,label:_(t)?String(t):_(e)?String(e):p||(_(n)?String(n):""),jsx:a,hasJsx:a!=null,className:r,style:u,disabled:!!c,group:i||l||null}},un=({name:e,label:t,value:n,id:s,disabled:r,className:u="",style:a=cn},c)=>{const i=e??t??s??n;return{disabled:!!r,isGroupMarker:!0,group:_(i)?String(i):c,className:u,style:a}},dn=e=>`<${typeof e=="string"?e:e?.displayName||e?.name||"Component"}>`,ae=(e,t,n=null,s="o",r=[])=>(o.Children.toArray(e).forEach(u=>{if(!o.isValidElement(u)){Q("text",`Text inside <Select> or <OptGroup> is ignored ("${String(u).slice(0,30)}"). Wrap it in <Option>.`);return}const a=`${s}-${String(u.key).slice(1).replace(/[:$]/g,i=>i===":"?"-":"k").replace(/[^\p{L}\p{N}-]/gu,"")}`,c=u.type?.racKind;if(u.type===o.Fragment)ae(u.props.children,t,n,a,r);else if(c==="option")r.push(ln(u.props,a,n));else if(c==="define")ae(u.type.racRender(u.props),t,n,a,r);else if(c==="group"){const i=un(u.props,t);r.push(i),ae(u.props.children,t,i.group,a,r)}else{const i=dn(u.type);Q(`child ${i}`,`${i} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`)}}),r),fn=new Set(["ref","options","value","defaultValue","onChange","children","loadMore","open","onOpenChange","onFocus","onBlur","childrenFirst","groupsClosed","disabled","loading","error"]),gn=/^(aria|data)-/,he={options:[],value:void 0,defaultValue:void 0,onChange:void 0,multiple:!1,childrenFirst:!1,groupsClosed:!1,disabled:!1,loading:!1,error:!1,open:void 0,onOpenChange:void 0,onFocus:void 0,onBlur:void 0,id:void 0,name:void 0,required:!1,hasMore:!1,loadMore:void 0,loadButton:!1,loadOffset:100,loadAhead:3,placeholder:"Choose option",selectedText:void 0,texts:{empty:"No options",disabled:"Disabled",loading:"Loading",error:"Failed to load",clear:"Clear selection",remove:"Remove",loadMore:"Load more",loadingMore:"Loading",emptyOption:"Empty option",invalidOption:"Invalid option",disabledOption:"Disabled option",emptyGroup:"Empty group",list:"Options"},renderOption:void 0,valueAsOption:!1,icons:{arrow:ie.ArrowUp,clear:ie.XMark,remove:ie.XMark,check:ie.Checkmark,checkbox:void 0},deleteInline:!1,deleteAlways:!1,className:"",optionsClassName:"",style:{},container:void 0,duration:300,easing:"ease",offset:1,animateOpacity:!0,keepMounted:!1},_e={visibility:"open",setVisibility:"onOpenChange",ownBehavior:"open without onOpenChange",onOpen:"onOpenChange",onClose:"onOpenChange",unmount:"keepMounted (inverted)",showDelete:"deleteAlways",OpenIcon:"icons.arrow",ClearIcon:"icons.clear",DelIcon:"icons.remove",Checkmark:"icons.check",Checkbox:"icons.checkbox",emptyText:"texts.empty",disabledText:"texts.disabled",loadingText:"texts.loading",errorText:"texts.error",clearText:"texts.clear",removeText:"texts.remove",loadButtonText:"texts.loadMore",loadMoreText:"texts.loadingMore",emptyOption:"texts.emptyOption",invalidOption:"texts.invalidOption",disabledOption:"texts.disabledOption"},me=(e,t)=>{const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n};function pn(e){for(const m in e)m in _e&&Q(`renamed ${m}`,`The \`${m}\` prop was removed. Use \`${_e[m]}\`.`);e.value!==void 0&&!e.onChange&&Q("read-only value","`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");const t=me(he,e);t.texts=me(he.texts,e.texts),t.icons=me(he.icons,e.icons);const n=t.texts.emptyGroup,s=xe(o.useMemo(()=>ae(t.children,n),[t.children,n])),{selectId:r,selectRef:u,highlightStore:a,positionStore:c,state:i,actions:h}=an(t,s),l={},p={};for(const m in t)fn.has(m)||((gn.test(m)?p:l)[m]=t[m]);const x=ut({...l,attrs:p,selectId:r,selectRef:u,highlightStore:a,positionStore:c});return b.jsx(W.Provider,{value:x,children:b.jsx(ee.Provider,{value:h,children:b.jsxs(te.Provider,{value:i,children:[b.jsx(_t,{}),b.jsx(sn,{})]})})})}function rt(){return Q("option outside","<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."),null}rt.racKind="option";function ot(){return null}ot.racKind="group";exports.OptGroup=ot;exports.Option=rt;exports.Select=pn;exports.defineOption=Ot;
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("react/jsx-runtime"),o=require("react"),Re=require("react-dom"),Y=o.createContext(null),ne=o.createContext(null),se=o.createContext(null),kt=(e,t)=>{const n=typeof t=="function"?t(e):t;return n===e?e:Object.keys(n).some(r=>!Object.is(n[r],e[r]))?{...e,...n}:e},at=e=>{let t=e;const n=new Set;return{get:()=>t,set:s=>{Object.keys(s).every(r=>Object.is(s[r],t[r]))||(t={...t,...s},n.forEach(r=>r()))},subscribe:s=>(n.add(s),()=>n.delete(s))}},Be=e=>{const t=o.useRef(e);o.useInsertionEffect(()=>{t.current=e});const[n]=o.useState(()=>Object.fromEntries(Object.keys(e).map(s=>[s,(...r)=>t.current[s](...r)])));return n},ct=(e,t)=>{const[n,s]=o.useState(e);return n===e||t(n,e)?n:(s(e),e)},jt=(e,t)=>e===t||!!e&&!!t&&Object.keys(e).length===Object.keys(t).length&&Object.keys(e).every(n=>Object.is(e[n],t[n])),ye=(e,t,n=0)=>{if(Object.is(e,t))return!0;if(n>12||typeof e!="object"||typeof t!="object"||e===null||t===null||Array.isArray(e)!==Array.isArray(t))return!1;if(e.$$typeof||t.$$typeof)return e.$$typeof===t.$$typeof&&e.type===t.type&&e.key===t.key&&ye(e.props,t.props,n+1);const s=Object.keys(e);return s.length===Object.keys(t).length&&s.every(r=>Object.hasOwn(t,r)&&ye(e[r],t[r],n+1))},Tt=new Set(["style","texts","icons","attrs"]),Mt=(e,t)=>{const n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(s=>Tt.has(s)?jt(e[s],t[s]):Object.is(e[s],t[s]))},It=e=>ct(e,Mt),$e=e=>ct(e,ye),he={XMark:({className:e="",...t})=>E.jsx("svg",{className:e,viewBox:"0 0 320 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:E.jsx("path",{d:"M310.6 361.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L160 301.3 54.6 406.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L114.7 256 9.4 150.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 210.7 265.4 105.4c12.5-12.5 32.8-12.5 45.3 0s12.5 32.8 0 45.3L205.3 256l105.3 105.4z"})}),ArrowUp:({className:e="",...t})=>E.jsx("svg",{className:e,viewBox:"0 0 448 512",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:E.jsx("path",{d:"M34.9 289.5l175.9-175.8c9.4-9.4 24.6-9.4 33.9 0L420.1 289.5c15.1 15.1 4.4 41-17 41H51.9c-21.4 0-32.1-25.9-17-41z"})}),Checkmark:({className:e="",...t})=>E.jsx("svg",{className:e,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",height:"1em",width:"1em",...t,children:E.jsx("path",{d:"M20.285 6.708a1 1 0 0 0-1.414-1.416l-9.192 9.192-4.243-4.244a1 1 0 1 0-1.414 1.416l5 5a1 1 0 0 0 1.414 0l9.849-9.948z"})})},ie=(e,t)=>{if(!e)return null;const n=(s={})=>({...t,...s,style:{...t?.style,...s?.style}});if(typeof e=="string")return E.jsx("img",{src:e,...n(),className:ae("rac-icon",t?.className),alt:""});if(o.isValidElement(e))return o.cloneElement(e,n(e.props));if(typeof e=="function"||typeof e=="object"&&e.$$typeof){const s=e;return E.jsx(s,{...n()})}return null},Ee=(e,t)=>`${e}-${String(t).replace(/[^A-Za-z0-9-]/gu,n=>`_${n.codePointAt(0).toString(36)}_`)}`,X=e=>e?"":void 0,ae=(e,t)=>t?`${e} ${t}`:e,Fe=(e,t,n)=>e.jsx||(t&&"original"in e?t(e.original,{selected:n,disabled:!!e.disabled}):null),Pe=E.jsxs("span",{className:"rac-dots","aria-hidden":"true",children:[E.jsx("i",{}),E.jsx("i",{}),E.jsx("i",{})]}),Rt=(()=>{try{return process.env.NODE_ENV!=="production"}catch{return!1}})(),We=new Set,ee=(e,t)=>{!Rt||We.has(e)||(We.add(e),console.warn(`[react-animated-select] ${t}`))},Z=e=>{e?.stopPropagation(),e?.preventDefault()},lt=(e,t)=>{e?.currentTarget.contains(document.activeElement)&&t.current?.focus()},$t={index:-1,fallback:-1,ready:!1},xe=({index:e,fallback:t})=>e===-1?t:e,At=10,Lt=500,Nt=new Set(["ArrowDown","ArrowUp","PageDown","PageUp","Home","End"]),Dt=(e,t)=>o.useMemo(()=>{const n=new Set(e.map(r=>r.group).filter(Boolean)),s=r=>!!r&&!r.disabled&&!r.loading&&(r.groupHeader?n.has(r.name):!r.group||t.has(r.group));return{reach:s,list:e.flatMap((r,i)=>s(r)?[i]:[])}},[e,t]),Bt=(e,t,n,s)=>{const r=e.length-1;if(r<0)return-1;if(n==="Home")return e[0];if(n==="End")return e[r];const i=n==="ArrowUp"||n==="PageUp"?-1:1,a=e.indexOf(t);if(a===-1)return e[i>0?0:r];const c=a+i*(n.startsWith("Page")?At:1);return c>=0&&c<=r?e[c]:n.startsWith("Page")||s?e[c<0?0:r]:e[(c+e.length)%e.length]},Ft=(e,t,n,s)=>{const r=[...s].every(u=>u===s[0]),i=r?s[0]:s,a=t.filter(u=>"original"in e[u]),c=Math.max(a.indexOf(n)+(r?1:0),0);for(let u=0;u<a.length;u++){const y=a[(c+u)%a.length];if(String(e[y].name).toLowerCase().startsWith(i))return y}return-1};function Pt({props:e,state:t,setState:n,normalizedOptions:s,expandedGroups:r,selected:i,selectedIDs:a,visibility:c,setVisibility:u,modelActions:y,loadMoreOnce:f,highlightStore:O}){const{disabled:d,multiple:l,hasMore:x,loadButton:w,loadOffset:g,loadAhead:p,icons:v,onFocus:$,onBlur:M,onKeyDown:H}=e,{selectOption:T,clear:h,removeOption:j}=y,{deleting:L}=t,{reach:B,list:I}=Dt(s,r),F=o.useRef({lastWindowFocusTime:0,justFocused:!1,focusTimeout:null,query:"",queryTimeout:null}),b=o.useMemo(()=>{const m=new Set(l?a.map(C=>C.id):i?[i.id]:[]),S=m.size?s.findIndex(C=>m.has(C.id)&&B(C)):-1;return S!==-1?S:I.find(C=>!s[C].groupHeader)??I[0]??-1},[s,i,a,l,B,I]),N=m=>{!w&&c&&x&&m>=s.length-p&&f()};o.useLayoutEffect(()=>{const{index:m}=O.get();O.set({fallback:b,index:m!==-1&&B(s[m])?m:-1}),N(xe(O.get()))}),o.useEffect(()=>{const m=F.current,S=()=>m.lastWindowFocusTime=Date.now();return window.addEventListener("focus",S),()=>{window.removeEventListener("focus",S),clearTimeout(m.focusTimeout),clearTimeout(m.queryTimeout)}},[]);const k=m=>{O.set({index:m}),N(m)},P=(m,S)=>{const C=F.current;clearTimeout(C.queryTimeout),C.queryTimeout=setTimeout(()=>C.query="",Lt),C.query+=m.toLowerCase();const R=Ft(s,I,S,C.query);R!==-1&&k(R),c||u(!0)};return Be({highlight:k,handleListScroll:m=>{if(w)return;const{scrollTop:S,scrollHeight:C,clientHeight:R}=m.currentTarget;C-S<=R+g&&f()},handleBlur:m=>{const S=m.relatedTarget?.closest(".rac-options");m.currentTarget.contains(m.relatedTarget)||S||(M?.(m),L&&n({deleting:!1}),c&&u(!1))},handleFocus:m=>{const S=m.currentTarget.contains(m.relatedTarget);S||$?.(m),!(S||m.target!==m.currentTarget||c||d||L||document.hidden||Date.now()-F.current.lastWindowFocusTime<100)&&(clearTimeout(F.current.focusTimeout),F.current.focusTimeout=setTimeout(()=>F.current.justFocused=!1,200),F.current.justFocused=!0,u(!0))},toggleVisibility:m=>{if(L){Z(m),n({deleting:!1});return}d||F.current.justFocused||u(!c)},handleKeyDown:m=>{if(H?.(m),m.defaultPrevented||d||m.nativeEvent?.isComposing)return;const{key:S}=m;if(m.target!==m.currentTarget&&(S==="Enter"||S.length===1))return;const C=xe(O.get());if(S.length===1&&!m.ctrlKey&&!m.metaKey&&!m.altKey&&(S!==" "||F.current.query)){m.preventDefault(),P(S,C);return}if(Nt.has(S)){m.preventDefault(),(c||S==="Home"||S==="End")&&k(Bt(I,C,S,!w&&x)),c||u(!0);return}switch(S){case"Enter":case" ":m.preventDefault(),c?C!==-1&&s[C]&&(k(C),T(s[C],m)):u(!0);break;case"Escape":if(L)n({deleting:!1});else if(c)u(!1);else break;Z(m);break;case"Tab":c&&u(!1);break;case"Backspace":case"Delete":{const R=a.at(-1);if(l&&S==="Backspace"&&v.remove&&R)j(R.id);else if(v.clear&&(i||R))h();else break;m.preventDefault();break}}}})}const Ht=["group","disabled","options","items","children"],He=["name","label","id","value"],pe=e=>e!=null&&e!=="",ut=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Oe=e=>ut(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),Vt=e=>{try{const t=String(e);return t.startsWith("[object ")?null:t}catch{return null}},Ve=(e,t=!1)=>{if(t&&typeof e.group=="string")return e.group;const n=He.find(i=>pe(e[i]));if(n)return String(e[n]);const s=!Oe(e)&&Vt(e);if(s)return s;const r=Object.entries(e).find(([i,a])=>!Ht.includes(i)&&pe(a));return r?String(r[1]):null},zt=e=>Oe(e)&&("options"in e||"group"in e&&!He.some(t=>t in e)),Ge=(e,t,n,s,r,{emptyOption:i,invalidOption:a,disabledOption:c})=>{const u=`${n}-${t}`;if(e==null||e==="")return{id:u,userId:null,name:i,raw:e,disabled:!0,type:"normal",group:s,groupDisabled:r};if(typeof e=="function")return{id:u,userId:null,name:a,raw:e,disabled:!0,invalid:!0,type:"normal",group:s};if(ut(e)){const y=r||e.disabled===!0,f=e.value!==void 0?e.value:e.id!==void 0?e.id:e,O=Ve(e)||(y?c:i);return{id:u,userId:e.id??e.value??e.name??e.label,name:O,raw:f,original:e,disabled:y||O===i,type:typeof f=="boolean"?"boolean":"normal",group:s||e.group||null,groupDisabled:r}}return{id:u,userId:e,name:String(e),raw:e,original:e,disabled:r,type:typeof e=="boolean"?"boolean":"normal",group:s}},qt=({options:e,jsxOptions:t,childrenFirst:n,hasMore:s,loadButton:r,loadPending:i,loadingTitle:a,emptyOption:c,invalidOption:u,disabledOption:y,emptyGroup:f})=>{const O={emptyOption:c,invalidOption:u,disabledOption:y},d=new Map,l=[],x=new Set,w=h=>{let j=h;for(let L=1;x.has(j);L++)j=`${h}~${L}`;return x.add(j),j},g=t.map((h,j)=>{if(h.isGroupMarker)return{...h,type:"group-marker"};const L=!h.label&&!pe(h.userId)&&!pe(h.value)&&!h.hasJsx;return{...h,id:w(`jsx-${h.id}`),index:j,userId:h.userId,raw:h.value,original:h.value,name:h.label||(pe(h.value)?String(h.value):c),disabled:!!h.disabled||L,type:typeof h.value=="boolean"?"boolean":"normal",group:h.group||null}});let p=0;const v=(h,j=null,L=!1,B="0")=>{Array.isArray(h)||(h=[h]),h.forEach((I,F)=>{const b=`${B}-${F}`;if(zt(I)){const N=Ve(I,!0)||f;d.has(N)||d.set(N,{disabled:!!I.disabled,items:[]}),I.options?v(I.options,N,L||!!I.disabled,b):l.push({id:`empty-${N}-${b}`,name:N,group:N,isPlaceholder:!0,type:"group-marker",index:p++})}else Oe(I)&&!He.some(N=>N in I)&&!I.group?Object.values(I).forEach((N,k)=>l.push({...Ge(N,`${b}-${k}`,"default",j,L,O),index:p++})):l.push({...Ge(I,b,"default",j,L,O),index:p++})})};v(e);const $=n?[...g,...l]:[...l,...g],M=[],H=new Set;$.forEach(h=>{if(!h.group){M.push({type:"item",data:h});return}H.has(h.group)||(H.add(h.group),M.push({type:"group",name:h.group})),d.has(h.group)||d.set(h.group,{items:[]});const j=d.get(h.group);h.isGroupMarker?(j.className=h.className,j.style=h.style,h.disabled&&(j.disabled=!0)):h.isPlaceholder||j.items.push(h)});const T=[];return M.forEach(h=>{if(h.type==="item"){T.push(h.data);return}const j=d.get(h.name);T.push({className:j?.className||"",id:`group-header-${h.name}`,disabled:!!j?.disabled,style:j?.style||{},groupHeader:!0,name:h.name,type:"group"}),j?.items.forEach(L=>T.push(L))}),s&&r&&T.push({id:"special-load-more-id",name:a,loadMore:!0,loading:i,type:"special"}),T},Wt=e=>{const t=()=>null;return t.racKind="define",t.racRender=e,t.displayName=`defineOption(${e.name||"anonymous"})`,t},Ke={selected:null,selectedIDs:[]},le=e=>{try{return JSON.stringify(e)}catch{return}},dt=(e,t)=>e===t||e!==e&&t!==t,ve=e=>typeof e=="object"&&e!==null,Gt=(e,t)=>dt(e,t)||ve(e)&&ve(t)&&le(e)!==void 0&&le(e)===le(t),_e=(e,t,n,s)=>{if(e==null||Array.isArray(e)&&e.length===0)return Ke;const r=s.length?new Map(t.map(f=>[f.id,f])):null,i=r?[...s.map(f=>r.get(f)).filter(Boolean),...t]:t,a=new Set,c=new Map,u=f=>"original"in f&&!a.has(f.id),y=f=>{const O=ve(f);let d=i.find(p=>u(p)&&dt(p.original,f));const l=O?le(f):void 0;if(!d&&l!==void 0&&(d=i.find(p=>u(p)&&ve(p.original)&&le(p.original)===l)),d)return a.add(d.id),d;const x=String(O?f.id||f.value||l||"object":f),w=(c.get(x)??-1)+1;c.set(x,w);const g=`virtual-${x}-${w}`;return O?{id:g,name:Ve(f)||String(f.id||"Selected Object"),raw:f.value??f.id??f,original:f,userId:f.id??f.value??null,virtual:!0}:{id:g,name:String(f),raw:f,original:f,userId:f,virtual:!0}};return n?{selected:null,selectedIDs:(Array.isArray(e)?e:[e]).map(y)}:{selected:y(Array.isArray(e)?e[0]:e),selectedIDs:Ke.selectedIDs}},Ue={x:["width","marginLeft","marginRight","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],y:["height","marginTop","marginBottom","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"]},Kt={x:{minWidth:"0px",maxWidth:"none"},y:{minHeight:"0px",maxHeight:"none"}},ft=o.createContext(null);let Ae=null;const _t=()=>Ae??=(queueMicrotask(()=>{Ae=null}),{});function te({as:e="div",axis:t="y",fade:n=!1,in:s,unmountOnExit:r=!0,easing:i,duration:a,group:c,nodeRef:u,onEntered:y,onExited:f,...O}){const d=o.useContext(Y),l=o.useContext(ft),x=s===void 0&&!!l,w=x?l.present:!!s,g=a??(d?.duration??300)/(x&&l.swap?2:1),p=i??d?.easing??"ease",v=o.useRef(null),$=u??v,M=o.useRef(null),H=o.useRef(!1),T=o.useRef({restart:()=>{}}),[h]=o.useState(()=>x&&l.appear?!w:w),j=o.useRef(h),[L,B]=o.useState(!w);w&&L&&B(!1);const I=o.useEffectEvent(()=>{if(c?.delete(T.current),w){M.current?.cancel(),M.current=null,y?.();return}f?.(),x&&l.onExited(),r&&(M.current=null,B(!0))});if(o.useLayoutEffect(()=>{const b=$.current;if(!b)return;const N=n?[...Ue[t],"opacity"]:Ue[t],k={overflow:"hidden",textOverflow:"clip",...Kt[t]},P={...Object.fromEntries(N.map(A=>[A,A==="opacity"?0:"0px"])),...k},m=()=>{const{overflow:A}=b.style;b.style.overflow="hidden";const V=getComputedStyle(b),K={...Object.fromEntries(N.map(z=>[z,V[z]])),...k};return b.style.overflow=A,K},S=(A,V)=>{const K=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches,z=M.current=b.animate([A,V],{duration:K?0:g,easing:p,fill:j.current?"backwards":"both"});if(z.onfinish=()=>{M.current===z&&H.current&&I()},T.current.frames=[A,V],!c)return;const q=z.timeline?.currentTime;q!=null&&(z.startTime=q,z.currentTime=0),T.current.batch=_t(),c.add(T.current)},C=()=>{const[A,V]=T.current.frames,K=M.current.effect.getComputedTiming().progress??0,z=q=>parseFloat(A[q])+(parseFloat(V[q])-parseFloat(A[q]))*K;return{...Object.fromEntries(N.map(q=>[q,q==="opacity"?z(q):`${z(q)}px`])),...k}};if(T.current.restart=A=>{const V=M.current;if(V?.playState!=="running"||!A&&T.current.batch===Ae)return;const K=C();V.cancel(),S(K,j.current?m():P)},j.current===w){!w&&!M.current&&b.animate&&(M.current=b.animate([P,P],{fill:"forwards"}));return}j.current=w;const R=M.current;if(R?.playState==="running"){if(!c){R.reverse();return}T.current.restart(!0)}else{if(R?.cancel(),!b.animate){I();return}w?S(P,m()):S(m(),P)}c?.forEach(A=>A!==T.current&&A.restart())},[w,t,n,g,p,$,c]),o.useLayoutEffect(()=>{const b=T.current;return H.current=!0,M.current?.playState==="running"&&c?.add(b),()=>{H.current=!1,c?.delete(b)}},[c]),L&&r)return null;const F=e;return E.jsx(F,{ref:$,...O})}const Ut=({id:e,present:t,appear:n,swap:s,onExited:r,children:i})=>{const a=o.useMemo(()=>({present:t,appear:n,swap:s,onExited:()=>r(e)}),[e,t,n,s,r]);return E.jsx(ft.Provider,{value:a,children:i})},Ye=(e,t,n,s=!0)=>{const r=o.Children.toArray(t).filter(o.isValidElement),i=new Set(r.map(d=>d.key)),a=new Map(e.map(d=>[d.key,d])),c=r.map(d=>({key:d.key,el:d,present:!0,appear:a.get(d.key)?.appear??s}));let u=0;const y=new Set;e.forEach(d=>{if(i.has(d.key))d.present&&(u=c.findIndex(l=>l.key===d.key)+1);else if(!d.pending){const l=d.present?{...d,present:!1,swap:!1}:d;d.present&&y.add(l),c.splice(u++,0,l)}});const f=d=>d.present&&(a.get(d.key)?.pending??!a.has(d.key)),O=n&&(y.size>0||e.some(d=>d.pending))&&c.some(d=>!d.present)&&c.some(f);return{children:t,list:O?c.map(d=>y.has(d)?{...d,swap:!0}:f(d)?{...d,pending:!0,swap:!0}:d):c}},Xe=e=>e.some(t=>!t.present)?e:e.map(t=>t.pending?{...t,pending:!1}:t);function Le({children:e,hold:t=!1,wait:n=!1}){const[s,r]=o.useState(()=>({...Ye([],e,n,!1),hold:t}));let i=s;i.children!==e&&(i={...i,...Ye(i.list,e,n)}),i.hold!==t&&(i={...i,hold:t,list:t?i.list:Xe(i.list.filter(c=>c.present))}),i!==s&&r(i);const a=o.useCallback(c=>r(u=>!u.hold&&u.list.some(y=>y.key===c&&!y.present)?{...u,list:Xe(u.list.filter(y=>y.key!==c))}:u),[]);return s.list.map(({key:c,el:u,present:y,appear:f,pending:O,swap:d=!1})=>!O&&E.jsx(Ut,{id:c,present:y,appear:f,swap:d,onExited:a,children:u},c))}const pt="rac-chip-slot",we="rac-flip",ze="rac-resize",qe=[],Je={overflow:"hidden",textOverflow:"clip",boxSizing:"border-box",minWidth:"0px",maxWidth:"none",minHeight:"0px",maxHeight:"none"},gt="(prefers-reduced-motion: reduce)",fe=()=>!!window.matchMedia?.(gt).matches,Yt=e=>{const t=window.matchMedia?.(gt);return t?.addEventListener("change",e),()=>t?.removeEventListener("change",e)},ge=e=>Array.from(e.children).filter(t=>t.classList.contains(pt)),Se=e=>e.firstElementChild?.firstElementChild,ht=(e,t)=>!!e?.getAnimations?.().some(n=>n.constructor===Animation&&t(n)),mt=(e,t)=>ht(e,n=>n.playState==="running"&&t(n)),bt=e=>ge(e).some(t=>mt(Se(t),n=>n.id===ze)),Ce=e=>Array.from(e.children).some(t=>mt(t,n=>n.id!==we))||bt(e),Xt=(e,t)=>e.length===t.length&&e.every((n,s)=>n===t[s]),Jt=e=>{const t=[];let n=-1/0;for(const s of e){const r=s.getBoundingClientRect();r.top>=n-1&&(t.push([]),n=r.bottom),t.at(-1).push(s),n=Math.max(n,r.bottom)}return t},yt=(e,t,n,s,r)=>{const i=e.cloneNode(!0),{height:a,paddingInlineEnd:c}=getComputedStyle(e),u=r?"":`height: ${a}; min-height: 0;`;i.style.cssText=`visibility: hidden; pointer-events: none; ${u} padding-inline-end: calc(${c} + ${n}px)`,i.querySelectorAll(`:scope > :not(.${pt})`).forEach(l=>l.remove()),s&&ge(i).forEach(l=>s.has(l.dataset.id)||l.remove()),n&&i.querySelectorAll(".rac-chip-del").forEach(l=>l.remove());const y=ge(i);y.forEach(l=>r?.has(l.dataset.id)&&Object.assign(Se(l)?.style??{},{minWidth:r.get(l.dataset.id),boxSizing:"border-box"}));const f=new Map(y.map((l,x)=>[l.dataset.id,x]));t?.slice(1).forEach((l,x)=>{const w=Math.min(...l.map(p=>f.get(p)??1/0)),g=Math.max(...t[x].map(p=>f.get(p)??-1).filter(p=>p<w));g>=0&&y[g].after(Object.assign(document.createElement("div"),{className:"rac-spacer"}))}),e.style.position="absolute",e.after(i),i.getAnimations?.({subtree:!0}).forEach(l=>l.effect?.getComputedTiming().endTime<1/0&&l.finish());const O=Jt(y).map(l=>l.map(x=>x.dataset.id)),d=i.offsetHeight;return i.remove(),e.style.position="",{rows:O,fit:d}},xt=(e,t)=>{const n=t?t.slice(0,-1).map(r=>r.at(-1)):qe,{breaks:s}=e.get();return Xt(s,n)?s:n},Ze=(e,t,n,s)=>xt(e,s&&n.length?yt(t,null,s,new Set(n.map(r=>r.id))).rows:null),me=(e,t,n)=>{const{rows:s,fit:r}=yt(t,n.rows,n.reserve,null,n.floor);Object.assign(n,{rows:s,fit:n.floor?r:null}),e.set({held:!0,breaks:xt(e,s)})},Zt=(e,t)=>new Map(ge(e).map(n=>{const{left:s,top:r}=n.getBoundingClientRect(),i=t&&Se(n);return[n,{left:s,top:r,label:i?vt(i):null}]})),Qe=(e,t,n,s)=>{if(!e.animate)return;e.getAnimations().forEach(c=>c.id===we&&c.cancel());const r=e.getBoundingClientRect(),i=t.left-r.left,a=t.top-r.top;(Math.abs(i)>.5||Math.abs(a)>.5)&&e.animate([{transform:`translate(${i}px, ${a}px)`},{transform:"none"}],{id:we,duration:n,easing:s})},vt=e=>{const t=getComputedStyle(e),n=(...s)=>`${s.reduce((r,i)=>r+parseFloat(t[i]),0)}px`;return t.boxSizing==="border-box"?{width:t.width,height:t.height}:{width:n("width","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"),height:n("height","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth")}},Qt=e=>{const t=[];e.forEach(({label:s},r)=>{const i=s&&r.isConnected&&Se(r);!i?.animate||ht(r,a=>a.id!==we)||(i.getAnimations().forEach(a=>a.id===ze&&a.cancel()),t.push({id:r.dataset.id,el:i,from:s}))});const n=(s,r)=>Math.abs(parseFloat(s)-parseFloat(r))>.5;return t.map(s=>({...s,to:vt(s.el)})).filter(({from:s,to:r})=>n(s.width,r.width)||n(s.height,r.height))},en=(e,t,n,s)=>e.forEach(({el:r,from:i,to:a})=>{r.animate([{...Je,...i},{...Je,...a}],{id:ze,duration:t,easing:n}).onfinish=s}),ke=(e,t,n,s,r,i)=>{if(!e||n===t.value)return;const a=getComputedStyle(e),c=t.anim?a.height:t.root;t.anim?.cancel(),i&&Object.assign(i.style,{height:`${n}px`,boxSizing:"border-box"}),t.root=a.height,i&&Object.assign(i.style,{height:"",boxSizing:""});const u=!t.value||c===t.root||!e.animate||fe();if(t.value=n,t.anim=null,u)return;const y={overflow:"hidden",alignItems:"flex-start"},f=t.anim=e.animate([{...y,height:c},{...y,height:t.root}],{duration:s,easing:r});f.onfinish=()=>{t.anim===f&&(t.anim=null)}},tn=.25,nn={hoverId:null,swipedId:null,held:!1,breaks:qe};function sn(e){const{selectRef:t,duration:n,easing:s,multiple:r,deleteInline:i,deleteAlways:a,icons:c,valueAsOption:u,renderOption:y}=o.useContext(Y),{selectedIDs:f,deleting:O,visibility:d,active:l}=o.useContext(se),{setDeleting:x,setVisibility:w}=o.useContext(ne),[g,p]=o.useState(0),[v]=o.useState(()=>at(nn)),[$]=o.useState(()=>new Set),M=o.useSyncExternalStore(v.subscribe,()=>v.get().held,()=>!1),H=o.useSyncExternalStore(v.subscribe,()=>v.get().breaks,()=>qe),T=o.useSyncExternalStore(Yt,fe,()=>!1),h=o.useRef({rows:null,reserve:0,chips:e,swap:!1,duration:n,easing:s}),j=o.useRef(null),L=o.useRef({value:0,root:"",anim:null}),B=o.useRef(null),I=o.useRef(null),F=i&&!a&&!O&&!!c.remove,b=F?g+tn:0,N=r&&F&&!g&&e.length>0,k=u?y?2:1:0,P=o.useEffectEvent((C,R)=>{const A=B.current,V=h.current;if(!A)return;const K=bt(A);if(K&&R)return;C&&v.get().held&&me(v,A,V);const z=V.swap?V.duration/2:V.duration;K?V.fit!=null&&ke(t.current,L.current,V.fit,z,V.easing,A):(R||L.current.value)&&ke(t.current,L.current,A.offsetHeight,z,V.easing),v.get().held||v.set({breaks:Ze(v,A,V.chips,V.reserve)})});o.useLayoutEffect(()=>{Object.assign(h.current,{duration:n,easing:s})},[n,s]),o.useLayoutEffect(()=>{const C=h.current,R=B.current,A=C.chips!==e;Object.assign(C,{chips:e,reserve:b}),A&&R&&Ce(R)&&me(v,R,C),P(!A)},[e,b,v]),o.useLayoutEffect(()=>{const C=()=>P(!0,!0),R=typeof ResizeObserver>"u"?null:new ResizeObserver(C);return R?R.observe(B.current):C(),document.fonts?.addEventListener("loadingdone",C),()=>{R?.disconnect(),document.fonts?.removeEventListener("loadingdone",C)}},[]);const m=o.useCallback(()=>{const C=B.current;if(!C||!v.get().held||Ce(C))return;const R=h.current,A=ge(C),V=A.map(z=>z.getBoundingClientRect()),K=Ze(v,C,R.chips,R.reserve);Object.assign(R,{rows:null,floor:null,fit:null}),Re.flushSync(()=>v.set({held:!1,breaks:K})),R.swap=Ce(C),R.swap&&Re.flushSync(()=>me(v,C,R)),fe()||A.forEach((z,q)=>z.isConnected&&Qe(z,V[q],R.swap?n/2:n,s))},[v,n,s]),S=o.useCallback(C=>{B.current&&(j.current=Zt(B.current,C))},[]);return o.useLayoutEffect(()=>{const C=B.current,R=h.current;if(!C||!j.current||!n||fe())return;const A=Qt(j.current);A.length&&(R.floor=new Map(A.map(({id:V,from:K})=>[V,K.width])),me(v,C,R),ke(t.current,L.current,R.fit,n,s,C),en(A,n,s,()=>{m(),P(!1,!0)}))},[k,v,n,s,t,m]),o.useLayoutEffect(()=>{const C=j.current;!C||H!==v.get().breaks||(j.current=null,fe()||C.forEach((R,A)=>A.isConnected&&Qe(A,R,n,s)))},[H,e,k,v,n,s]),o.useEffect(()=>()=>L.current.anim?.cancel(),[]),o.useEffect(()=>{O&&d&&w(!1),O&&(!f.length||!l)&&x(!1),v.set({hoverId:null,...!l&&{swipedId:null}})},[f.length,O,d,l,x,w,v]),o.useLayoutEffect(()=>{const C=I.current;if(!N||!C)return;const R=getComputedStyle(C);p(C.getBoundingClientRect().width+parseFloat(R.marginLeft)+parseFloat(R.marginRight))},[N]),{chipStore:v,delGroup:$,valueRef:B,delIconRef:I,probe:N,settle:m,held:M,snapshot:S,look:k,wait:n>0&&!T}}const et=1,tt=2,rn=600,on=10,nt=30,an=o.memo(function({element:t,deleting:n,locked:s,chipStore:r,delGroup:i}){const{selectRef:a,deleteInline:c,deleteAlways:u,icons:y,texts:f,valueAsOption:O,renderOption:d}=o.useContext(Y),l=!!y.remove,{setVisibility:x,setDeleting:w,removeOption:g}=o.useContext(ne),p=o.useRef({longPressTimer:null,longPress:!1,x:0,y:0}),v=o.useSyncExternalStore(r.subscribe,()=>{const{hoverId:k,swipedId:P}=r.get();return(k===t.id?et:0)|(P===t.id?tt:0)},()=>0),$=!!(v&et),M=!!(v&tt),H=o.useCallback(k=>{const{clientX:P,clientY:m}=k.touches[0];Object.assign(p.current,{x:P,y:m,longPress:!1}),clearTimeout(p.current.longPressTimer),l&&(p.current.longPressTimer=setTimeout(()=>{w(!0),p.current.longPress=!0,a.current?.focus(),x(!1),window.navigator.vibrate?.(50)},rn))},[l,w,x,a]),T=o.useCallback(k=>{const{clientX:P,clientY:m}=k.touches[0],S=p.current.x-P;Math.hypot(S,p.current.y-m)>on&&clearTimeout(p.current.longPressTimer),S>nt&&!M?r.set({hoverId:null,swipedId:t.id}):S<-nt&&M&&r.set({swipedId:null})},[t.id,M,r]),h=o.useCallback(k=>{clearTimeout(p.current.longPressTimer),p.current.longPress&&k.cancelable&&k.preventDefault(),p.current.longPress=!1},[]),j=o.useCallback(()=>r.set({hoverId:t.id,swipedId:null}),[t.id,r]),L=o.useCallback(()=>{r.get().hoverId===t.id&&r.set({hoverId:null})},[t.id,r]);o.useEffect(()=>()=>clearTimeout(p.current.longPressTimer),[]);const B=O?Fe(t,d,!0):null,I=B?E.jsx("div",{className:"rac-option-jsx",children:B}):E.jsx("span",{className:"rac-chip-text",children:t.name||f.emptyOption}),F=o.useCallback(k=>{r.set({swipedId:null}),lt(k,a),g(t.id),Z(k)},[t.id,g,r,a]),b=o.useCallback(k=>{Z(k),n&&F(k)},[n,F]),N=l&&(u||!s&&($||M||n));return E.jsxs("div",{className:ae("rac-chip",B&&t.className),style:B?t.style:void 0,...!s&&{onTouchStart:H,onTouchMove:T,onTouchEnd:h,onTouchCancel:h,onMouseEnter:j,onMouseLeave:L,onClick:b},children:[I,E.jsx(te,{"aria-label":`${f.remove} ${t.name??""}`.trim(),group:c&&!u&&!n?i:void 0,onMouseDown:Z,onClick:F,className:"rac-chip-del",disabled:s,tabIndex:-1,type:"button",in:N,as:"button",axis:"x",children:ie(y.remove)})]})}),cn=o.memo(function({element:t,chipStore:n,settle:s,...r}){const i=o.useSyncExternalStore(n.subscribe,()=>n.get().breaks.includes(t.id),()=>!1);return E.jsxs(o.Fragment,{children:[E.jsx(te,{className:"rac-chip-slot",onEntered:s,onExited:s,unmountOnExit:!1,"data-id":t.id,axis:"x",fade:!0,children:E.jsx(an,{element:t,chipStore:n,...r})}),i&&E.jsx("div",{className:"rac-spacer"})]})}),ln={position:"absolute",visibility:"hidden",pointerEvents:"none"},wt=[],un=()=>{},dn=e=>e==null?"":typeof e=="object"?le(e)??"":String(e),fn=o.memo(function(){const{selectRef:t,multiple:n,name:s,form:r,required:i}=o.useContext(Y),{selected:a,selectedIDs:c,disabled:u,fieldsetDisabled:y}=o.useContext(se),{reset:f,markInvalid:O}=o.useContext(ne),d=o.useRef(null);o.useEffect(()=>{const p=d.current?.getRootNode();let v;const $=M=>{M.target===d.current?.form&&(clearTimeout(v),v=setTimeout(()=>M.defaultPrevented||f()))};return p?.addEventListener("reset",$,!0),()=>{clearTimeout(v),p?.removeEventListener("reset",$,!0)}},[f]);const l=n?c:a?[a]:wt,x=!i&&(!s||n&&!l.length),w=x||!l.length?[""]:l.map(p=>dn(p.original)),g=()=>t.current?.focus();return w.map((p,v)=>E.jsx("input",{className:"rac-input",ref:v?void 0:d,name:x?void 0:s,form:r,value:p,hidden:x,required:i&&!v,disabled:u&&!y,tabIndex:-1,"aria-hidden":"true",autoComplete:"off",onChange:un,onInvalid:O,onFocus:g},v))});class pn extends o.Component{getSnapshotBeforeUpdate(t){const n=t.look!==this.props.look;return(n||t.chips!==this.props.chips)&&this.props.take(n),null}componentDidUpdate(){}render(){return null}}const st=(e,t)=>{const n=new Set(e.map(a=>a.id)),s=new Map(t.map(([a,c])=>[c.id,a])),r=t.filter(([,a])=>!n.has(a.id)),i=new Set(t.map(([a])=>a));return e.map(a=>{if(s.has(a.id))return[s.get(a.id),a];const c=r.findIndex(([,y])=>Gt(y.original,a.original));if(c>=0)return[r.splice(c,1)[0][0],a];let u=a.id;for(;i.has(u);)u+="~";return i.add(u),[u,a]})},gn=e=>{const[t,n]=o.useState(()=>({chips:e,keyed:st(e,[])}));if(t.chips===e)return t.keyed;const s=st(e,t.keyed);return n({chips:e,keyed:s}),s},hn=o.memo(function(){const{selectedText:t,icons:n,valueAsOption:s,renderOption:r}=o.useContext(Y),{selectedIDs:i,title:a,valueOption:c,hasActualValue:u,loading:y,error:f,deleting:O,active:d}=o.useContext(se),l=i.length>0&&!t,x=l?i:wt,{chipStore:w,delGroup:g,valueRef:p,delIconRef:v,probe:$,settle:M,held:H,snapshot:T,look:h,wait:j}=sn(x),L=gn(x),[B]=o.useState(()=>new Set),I=s&&c?Fe(c,r,!0):null,F=y&&!f&&!u,b=`${I?c.id:a}${F?"-loading":""}`,N=c?.type==="boolean"?String(c.raw):void 0;return E.jsxs("div",{className:"rac-value",ref:p,children:[E.jsx(pn,{chips:x,look:h,take:T}),E.jsx(Le,{children:!l&&E.jsxs(te,{axis:"x",fade:!0,group:B,className:ae("rac-title",I&&c.className),style:I?c.style:void 0,"data-bool":N,onEntered:M,onExited:M,children:[I?E.jsx("div",{className:"rac-option-jsx",children:I}):a,F&&Pe]},b)}),E.jsx(Le,{hold:H,wait:j,children:L.map(([k,P])=>E.jsx(cn,{element:P,deleting:O,locked:!d,chipStore:w,delGroup:g,settle:M},k))}),$&&E.jsx("button",{type:"button",className:"rac-chip-del",tabIndex:-1,"aria-hidden":"true",ref:v,style:ln,children:ie(n.remove)})]})}),mn=o.memo(function(){const{selectRef:t,selectId:n,highlightStore:s,className:r,style:i,duration:a,easing:c,deleteInline:u,icons:y,texts:f,placeholder:O,id:d,required:l,popup:x,attrs:w}=o.useContext(Y),{visibility:g,active:p,hasActualValue:v,deleting:$,loading:M,loadPending:H,error:T,invalid:h,normalizedOptions:j}=o.useContext(se),{handleBlur:L,handleFocus:B,handleKeyDown:I,toggleVisibility:F,clear:b}=o.useContext(ne),N=o.useSyncExternalStore(s.subscribe,()=>{const S=g?j[xe(s.get())]:null;return S?Ee(n,S.id):void 0},()=>{}),k=!!y.clear&&v&&p&&!$,P=!!y.arrow&&p&&!$&&x,m=x?{role:"combobox","aria-haspopup":"listbox","aria-controls":`${n}-listbox`,"aria-expanded":g,"aria-activedescendant":N,"aria-required":l||void 0}:{role:"group"};return E.jsxs("div",{...w,id:d,ref:t,style:{"--rac-duration":`${a}ms`,"--rac-ease":c,...i},className:ae("rac-select",r),...p&&{onKeyDown:I,onFocus:B,onClick:F,onBlur:L},...m,"aria-disabled":!p,tabIndex:p?0:-1,"aria-busy":M||H||void 0,"aria-label":w["aria-label"]??(w["aria-labelledby"]?void 0:O),"aria-invalid":h||w["aria-invalid"],"aria-describedby":[w["aria-describedby"],T&&`${n}-error`].filter(Boolean).join(" ")||void 0,"data-inline-delete":X(u),"data-empty":X(!v),"data-deleting":X($),"data-error":X(T),"data-invalid":X(h),children:[E.jsx(hn,{}),E.jsxs(Le,{children:[k&&E.jsx(te,{as:"button",type:"button",axis:"x",className:"rac-clear",tabIndex:-1,"aria-label":f.clear,onMouseDown:Z,onClick:S=>{lt(S,t),b(S)},children:ie(y.clear)},"clear"),P&&E.jsx(te,{axis:"x",className:"rac-arrow","aria-hidden":"true",children:ie(y.arrow)},"arrow")]}),E.jsx(fn,{})]})}),je=0,bn=1,rt=2,Et=e=>{const{highlightStore:t}=o.useContext(Y),n=o.useRef(null),s=o.useSyncExternalStore(t.subscribe,()=>{const r=t.get();return xe(r)!==e?je:r.ready?rt:bn},()=>je);return o.useLayoutEffect(()=>{s===rt&&n.current?.scrollIntoView?.({block:"nearest"})},[s]),[n,s!==je]},Ot=(e,t)=>`${Ee(e,t.id)}_l`,yn=o.memo(function({option:t,index:n,open:s,hasChildren:r}){const{selectId:i,icons:a,texts:c}=o.useContext(Y),{selectOption:u,highlight:y}=o.useContext(ne),[f,O]=Et(n),d=r&&!t.disabled;return E.jsxs("div",{className:ae("rac-group",t.className),onMouseEnter:()=>d&&y(n),onClick:l=>u(t,l),"aria-label":d?`${t.name}, ${s?c.groupOpen:c.groupClosed}`:void 0,"aria-disabled":!d||void 0,"data-highlighted":X(O),"data-disabled":X(t.disabled),id:Ee(i,t.id),"data-open":X(s),"aria-selected":"false",style:t.style,role:"option",ref:f,children:[E.jsx("span",{className:"rac-group-text",id:Ot(i,t),children:t.name}),E.jsx(te,{axis:"x",in:r&&!t.disabled,className:"rac-group-arrow","aria-hidden":"true",children:ie(a.arrow)})]})}),xn=o.memo(function({option:t,index:n,isSelected:s,showCheckbox:r}){const{selectId:i,icons:a,renderOption:c}=o.useContext(Y),{selectOption:u,highlight:y}=o.useContext(ne),[f,O]=Et(n),d=!t.disabled&&!t.loading,l=Fe(t,c,s);return E.jsxs("div",{className:ae("rac-option",t.className),onMouseEnter:()=>d&&y(n),onClick:x=>!t.loading&&u(t,x),"aria-disabled":t.disabled||t.loading,"data-invalid":X(t.invalid),"data-bool":typeof t.raw=="boolean"?String(t.raw):void 0,"data-highlighted":X(O),"data-loading":X(t.loading),id:Ee(i,t.id),"aria-selected":s,style:t.style,role:"option",ref:f,children:[l?E.jsx("div",{className:"rac-option-jsx",children:l}):E.jsx("span",{className:"rac-option-text",children:t.name}),t.loading&&Pe,r&&E.jsxs("div",{className:"rac-check","data-default":X(!a.checkbox),children:[ie(a.check,{className:"rac-checkmark"}),ie(a.checkbox,{className:"rac-check-icon"})]})]})}),vn=o.memo(function(){const{selectId:t,multiple:n}=o.useContext(Y),{normalizedOptions:s,selected:r,selectedIDs:i,expandedGroups:a}=o.useContext(se),c=r?.id;return o.useMemo(()=>{const u=new Set(i.map(g=>g.id)),y=s.reduce((g,p)=>(p.group&&(g[p.group]=(g[p.group]||0)+1),g),{}),f=[];let O=[],d=null,l=null;const x=()=>{d!==null&&O.length&&f.push(E.jsx(te,{axis:"y",in:a.has(d),className:"rac-group-items",role:"group","aria-labelledby":l,children:O},`slide-${d}`)),O=[]},w=(g,p)=>E.jsx(xn,{isSelected:u.has(g.id)||c===g.id,showCheckbox:n&&!g.disabled&&"original"in g,option:g,index:p},g.id);return s.forEach((g,p)=>{g.groupHeader?(x(),d=g.name,l=Ot(t,g),f.push(E.jsx(yn,{hasChildren:y[g.name]>0,open:a.has(g.name),option:g,index:p},g.id))):g.group?O.push(w(g,p)):(x(),d=null,f.push(w(g,p)))}),x(),f},[s,c,i,a,n,t])}),wn=(e,t,n,s)=>{const r=e.getBoundingClientRect(),i=getComputedStyle(e),a=r.left-parseFloat(i.marginLeft)-t.left,c=n?r.bottom+parseFloat(i.marginBottom)-t.top+s:r.top-parseFloat(i.marginTop)-t.bottom-s;Math.abs(a)>.5&&(e.style.left=`${t.left-a}px`),Math.abs(c)>.5&&(e.style[n?"bottom":"top"]=`${parseFloat(e.style[n?"bottom":"top"])+(n?c:-c)}px`)},En=(e,t)=>{e&&e.dataset.placement!==(t?"top":"bottom")&&(e.dataset.placement=t?"top":"bottom")},Te=()=>typeof IntersectionObserver<"u",ot=(e,t,n=window.innerHeight-e.bottom)=>n<t&&e.top>n,On=({selectRef:e,panelRef:t,open:n,frozen:s,offset:r,onFlip:i})=>{const a=o.useRef(0),c=o.useRef(s),u=o.useRef(i);o.useLayoutEffect(()=>{c.current=s,u.current=i});const y=o.useCallback(l=>[e.current,t.current].forEach(x=>En(x,l)),[e,t]),f=o.useCallback(l=>{const x=e.current;if(!x||!l)return;l.scrollHeight&&(a.current=l.scrollHeight);const w=x.getBoundingClientRect(),g=l.dataset.placement,p=a.current,v=g==="top"?w.top-r>=p:window.innerHeight-w.bottom-r>=p;let $=g&&(c.current||v)?g==="top":ot(w,p);g&&$!==(g==="top")&&(u.current?.(),$=g==="top"),y($),l.style.width=`${w.width}px`,l.style.left=`${w.left+window.scrollX}px`,l.style.top=$?"auto":`${w.bottom+window.scrollY+r}px`,l.style.bottom=$?`${window.innerHeight-w.top-window.scrollY+r}px`:"auto",wn(l,w,$,r)},[e,r,y]),O=o.useCallback(l=>{l&&f(l.parentElement)},[f]),d=o.useCallback(l=>{l?.removeAttribute("data-placement"),f(l)},[f]);return o.useEffect(()=>{const l=e.current;if(n||!l||!Te())return;a.current||=parseFloat(getComputedStyle(l).getPropertyValue("--rac-list-max-height"))||250;const x={fits:!0,lower:!1},w=(p,v,$)=>{const M=new IntersectionObserver(([{boundingClientRect:H,rootBounds:T}])=>{T&&($(H,T),y(!x.fits&&x.lower))},{rootMargin:p,threshold:v});return M.observe(l),M},g=[w(`0px 0px ${-a.current}px 0px`,[0,1],(p,v)=>{x.fits=p.bottom<=v.bottom}),w("0px 0px -50% 0px",[0,.5,1],(p,v)=>{x.lower=p.top+p.bottom>2*v.bottom})];return()=>g.forEach(p=>p.disconnect())},[n,e,y]),o.useLayoutEffect(()=>{const l=e.current;if(!n||!l)return;const x=l.ownerDocument,w=t.current;let g=0,p=0,v="",$=null;const M=()=>{const b=l.getBoundingClientRect(),N=t.current?.getBoundingClientRect()??b,k=ot(b,a.current),P=a.current+r;return[b.left-N.left,k?b.top-N.bottom:b.bottom-N.top,b.width,window.innerHeight,t.current?.scrollHeight,k,b.top>=P,window.innerHeight-b.bottom>=P].join()},H=()=>{if($?.disconnect(),!Te())return;const b=l.getBoundingClientRect(),{clientWidth:N,clientHeight:k}=x.documentElement,P=[b.top,N-b.right,k-b.bottom,b.left].map(S=>`${-Math.floor(S)}px`).join(" ");let m=!1;$=new IntersectionObserver(([S])=>{m&&S.intersectionRatio<1&&j(),m=S.intersectionRatio===1},{root:x,rootMargin:P,threshold:1}),$.observe(l)},T=()=>M()===v?!1:(f(t.current),v=M(),!0),h=()=>{if(g=0,T())p=0;else if(++p>1)return H();g=requestAnimationFrame(h)},j=()=>{p=0,g||=requestAnimationFrame(h)};t.current?.removeAttribute("data-offscreen"),f(t.current),v=M(),H(),window.addEventListener("scroll",j,{capture:!0,passive:!0}),window.addEventListener("resize",j);const L=typeof ResizeObserver<"u"&&new ResizeObserver(j);L&&[l,t.current].forEach(b=>b&&L.observe(b));const B=({target:b})=>!l.contains(b)&&!t.current?.contains(b),I=typeof MutationObserver<"u"&&new MutationObserver(b=>{b.some(B)&&T()&&j()});I&&I.observe(x.body,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const F=Te()&&new IntersectionObserver(([{isIntersecting:b,boundingClientRect:N,rootBounds:k}])=>{const P=!b&&!!k&&N.bottom>k.top&&N.top<k.bottom&&N.right>k.left&&N.left<k.right;t.current?.toggleAttribute("data-offscreen",P)});return F&&F.observe(l),()=>{cancelAnimationFrame(g),window.removeEventListener("scroll",j,{capture:!0}),window.removeEventListener("resize",j);for(const b of[L,I,F,$])b&&b.disconnect();w?.removeAttribute("data-placement")}},[n,f,r,e,t]),[O,d]},Sn=(e={})=>Object.fromEntries(Object.entries(e).filter(([t])=>t.startsWith("--"))),Cn=e=>(typeof e=="function"?e():e)||document.body,kn=()=>()=>{},jn=o.memo(function(){const{selectRef:t,selectId:n,multiple:s,offset:r,duration:i,easing:a,animateOpacity:c,keepMounted:u,optionsClassName:y,style:f,container:O,hasMore:d,loadButton:l,texts:x,popup:w}=o.useContext(Y),{visibility:g,normalizedOptions:p,loading:v,error:$}=o.useContext(se),{handleListScroll:M,setListReady:H}=o.useContext(ne),T=g&&p.length>0,h=o.useSyncExternalStore(kn,()=>!0,()=>!1),[j,L]=o.useState(!1);T&&h&&!j&&L(!0);const[B,I]=o.useState(null),F=o.useCallback(()=>I(S=>S||"out"),[]),b=o.useRef(null),[N,k]=On({selectRef:t,panelRef:b,open:j,frozen:!T||B==="out",offset:r,onFlip:F}),P=()=>{if(B==="out"&&T){k(b.current),I("in");return}I(null),L(!1)},m=()=>{I(null),H(!0)};return!h||!w?null:Re.createPortal(E.jsx(te,{axis:"y",fade:c,in:T&&B!=="out",duration:B?i/2:void 0,nodeRef:b,unmountOnExit:!u&&!(B&&T),onEntered:m,onExited:P,onMouseDown:S=>S.preventDefault(),className:ae("rac-options",y),style:{...Sn(f),"--rac-duration":`${i}ms`,"--rac-ease":a,pointerEvents:T?"auto":"none",position:"absolute"},children:E.jsxs("div",{onScroll:M,className:"rac-list","aria-multiselectable":s,id:`${n}-listbox`,"aria-label":x.list,role:"listbox",tabIndex:"-1",ref:N,children:[E.jsx(vn,{}),$?E.jsx("div",{className:"rac-option","data-error":"",children:E.jsx("span",{className:"rac-option-text",children:x.error})}):(v||!l&&d)&&E.jsxs("div",{className:"rac-option","data-loading":"",children:[E.jsx("span",{className:"rac-option-text",children:v?x.loading:x.loadingMore}),Pe]})]})}),Cn(O))}),Tn=250,Mn=5e3,In=[],Rn=()=>()=>{},ce=(e,t)=>typeof e=="function"?e(t):String(e??"").replace(/\{(n|label)\}/g,()=>t),$n=(e,t,n,s)=>{const r=[];if(e.picked.length&&!t.picked.length)r.push(ce(n.cleared));else if(s){const i=new Set(t.picked.map(u=>u.id)),a=new Set(e.picked.map(u=>u.id)),c=e.picked.filter(u=>!i.has(u.id));c.length&&r.push(ce(n.removed,c.map(u=>u.name).join(", "))),t.picked.some(u=>!a.has(u.id))&&r.push(ce(n.selected,t.picked.length))}return t.open&&e.count&&t.count>e.count&&r.push(ce(n.loaded,t.count-e.count)),t.error&&!e.error&&r.push(ce(n.error)),r.filter(Boolean).join(". ")},An=o.memo(function(){const{selectRef:t,selectId:n,multiple:s,texts:r}=o.useContext(Y),{selected:i,selectedIDs:a,normalizedOptions:c,visibility:u,deleting:y,error:f}=o.useContext(se),O=o.useSyncExternalStore(Rn,()=>!0,()=>!1),[d,l]=o.useState(""),x=o.useRef({base:null,timer:0,wipe:0,latest:null}),w=o.useMemo(()=>c.reduce((g,p)=>"original"in p?g+1:g,0),[c]);return o.useEffect(()=>{const g=s?a:i?[i]:In;x.current.latest={snap:{picked:g,count:w,open:u,error:!!f},texts:r,multiple:s,deleting:y}}),o.useEffect(()=>{const g=x.current,{snap:p,deleting:v}=g.latest;if(!g.base||!g.timer&&!v&&!t.current?.contains(document.activeElement)){g.base=p;return}clearTimeout(g.timer),g.timer=setTimeout(()=>{g.timer=0;const{snap:$,texts:M,multiple:H}=g.latest,T=$n(g.base,$,M,H);g.base=$,T&&(l(h=>h===T?`${T} `:T),clearTimeout(g.wipe),g.wipe=setTimeout(()=>l(""),Mn))},Tn)},[i,a,w,f,t]),o.useEffect(()=>{const g=x.current;return()=>{clearTimeout(g.timer),clearTimeout(g.wipe)}},[]),O?E.jsxs("div",{className:"rac-live",children:[E.jsx("div",{"aria-live":"polite","aria-atomic":"true",children:d}),f&&E.jsx("div",{id:`${n}-error`,children:ce(r.error)})]}):null}),Ne=[];function Ln({props:e,jsxOptions:t,state:n,setState:s,setVisibility:r,loadMoreOnce:i}){const{onChange:a,disabled:c,loading:u,error:y,multiple:f,childrenFirst:O,groupsClosed:d,hasMore:l,loadButton:x,placeholder:w,selectedText:g,texts:p}=e,{disabledOption:v,emptyOption:$,invalidOption:M,emptyGroup:H}=p,{loadPending:T,internalValue:h,toggledGroups:j,picked:L}=n,B=$e(e.options),I=$e(e.value),F=I!==void 0,b=F?I:h,N=T?p.loadingMore:p.loadMore,k=o.useMemo(()=>qt({options:B,jsxOptions:t,childrenFirst:O,hasMore:l,loadButton:x,loadPending:T,loadingTitle:N,emptyOption:$,invalidOption:M,disabledOption:v,emptyGroup:H}),[B,t,O,l,x,T,N,$,M,v,H]),P=o.useMemo(()=>new Set(k.filter(D=>D.groupHeader&&!D.disabled&&d===j.has(D.name)).map(D=>D.name)),[k,j,d]),{selected:m,selectedIDs:S}=o.useMemo(()=>_e(b,k,f,L),[b,k,f,L]),C=k.length>0,R=!c&&C,A=b!=null&&!(Array.isArray(b)&&!b.length)&&!(Oe(b)&&!Object.keys(b).length),V=A&&g?null:m,K=o.useMemo(()=>A&&g?g:m?m.name:y?p.error:u?p.loading:c?p.disabled:C?w:p.empty,[y,u,c,A,g,m,C,w,p]),z=D=>s(G=>{const _=new Set(G.toggledGroups);return _.has(D)?_.delete(D):_.add(D),{toggledGroups:_}}),q=(D,G,_)=>{s(F?{picked:_}:{internalValue:D,picked:_}),a?.(D,G)},ue=D=>q(D.map(G=>G.original),D.map(G=>G.userId),D.map(G=>G.id)),de=Be({toggleGroup:z,selectOption:(D,G)=>{if(D.groupHeader){Z(G),D.disabled||z(D.name);return}if(D.disabled||D.loadMore){Z(G),D.loadMore&&!D.loading&&i();return}if(f){Z(G);const _=S.some(re=>re.id===D.id);ue(_?S.filter(re=>re.id!==D.id):[...S,D]);return}m?.id!==D.id&&q(D.original,D.userId,[D.id]),r(!1)},clear:D=>{Z(D),q(f?[]:null,f?[]:null,Ne)},removeOption:D=>ue(S.filter(G=>G.id!==D)),reset:()=>{s({deleting:!1,invalid:!1}),r(!1);const D=f?[]:null,G=e.defaultValue??D,{selected:_,selectedIDs:re}=_e(G,k,f,Ne),W=f?re:_?[_]:[],U=f?S:m?[m]:[];ye(b??D,G)&&W.length===U.length&&W.every((Q,oe)=>Q.id===U[oe].id)||q(G,f?W.map(Q=>Q.userId):_?.userId??null,W.map(Q=>Q.id))}});return{normalizedOptions:k,expandedGroups:P,selected:m,selectedIDs:S,hasOptions:C,active:R,hasActualValue:A,title:K,valueOption:V,actions:de}}const Nn=e=>({internalVisibility:!1,deleting:!1,loadPending:!1,toggledGroups:new Set,internalValue:e.defaultValue,picked:Ne,fieldsetDisabled:!1,invalid:!1});function Dn(e,t){const[n,s]=o.useReducer(kt,e,Nn),{internalVisibility:r,deleting:i,loadPending:a,fieldsetDisabled:c}=n,u=o.useMemo(()=>c&&!e.disabled?{...e,disabled:!0}:e,[e,c]),{ref:y,open:f,onOpenChange:O,popup:d,hasMore:l,loadMore:x,loadButton:w,error:g,disabled:p,loading:v,required:$,texts:M}=u,H=o.useId(),T=o.useMemo(()=>H.replace(/:/g,""),[H]),h=o.useRef(null);o.useImperativeHandle(y,()=>h.current),o.useLayoutEffect(()=>{const W=h.current?.querySelector(".rac-input");if(!W)return;const U=()=>s({fieldsetDisabled:!e.disabled&&W.matches(":disabled")});U();const Q=new MutationObserver(U);for(let oe=W.parentElement;oe;oe=oe.parentElement)oe.tagName==="FIELDSET"&&Q.observe(oe,{attributeFilter:["disabled"]});return()=>Q.disconnect()},[e.disabled]);const[j]=o.useState(()=>at($t)),L=f!==void 0,B=L?!!f:r,I=o.useRef(!1),F=o.useRef(!1),b=Be({setVisibility:W=>{W===B||W&&!d||(L||s({internalVisibility:W}),O?.(W))},loadMoreOnce:()=>{if(!l||I.current)return;if(!x)return ee("no loadMore","`hasMore` is set, but there is no `loadMore` to call.");I.current=!0,s({loadPending:!0});const W=()=>s({loadPending:!1});try{x()?.then?.(W,W)}catch(U){I.current=!1,W(),(globalThis.reportError??console.error)(U)}},setListReady:W=>j.set({ready:W}),setDeleting:W=>s({deleting:W}),markInvalid:()=>s({invalid:!0})}),N=Ln({props:u,jsxOptions:t,state:n,setState:s,setVisibility:b.setVisibility,loadMoreOnce:b.loadMoreOnce}),{normalizedOptions:k,expandedGroups:P,selected:m,selectedIDs:S,hasOptions:C,active:R,hasActualValue:A,title:V,valueOption:K,actions:z}=N,q=R&&B&&d,ue=Pt({props:u,state:n,setState:s,normalizedOptions:k,expandedGroups:P,selected:m,selectedIDs:S,visibility:q,highlightStore:j,setVisibility:b.setVisibility,loadMoreOnce:b.loadMoreOnce,modelActions:z});o.useEffect(()=>{s({loadPending:!1})},[k.length,l,w]),o.useEffect(()=>{a||(I.current=!1)},[a]),o.useEffect(()=>{q&&h.current&&document.activeElement!==h.current&&h.current.focus(),q||j.set({index:-1,ready:!1})},[q,j]),o.useEffect(()=>{F.current&&!R&&b.setVisibility(!1),F.current=R},[R,b]);const de=o.useRef(null),D=u.value!==void 0;o.useEffect(()=>{const W={value:D,open:L};for(const U in W)de.current&&de.current[U]!==W[U]&&ee(`switch ${U}`,`\`${U}\` switched between controlled and uncontrolled (\`undefined\`) after mount. Pick one mode for the lifetime of the Select, like a React input${U==="value"?"; clear a controlled value with `null` or `[]`":""}.`);de.current=W},[D,L]),o.useLayoutEffect(()=>{h.current?.querySelector(".rac-input")?.setCustomValidity($&&!A&&M.required||"")},[$,A,M.required]);const G=n.invalid&&$&&!A&&!p,_=o.useMemo(()=>({...b,...z,...ue}),[b,z,ue]),re=o.useMemo(()=>({visibility:q,deleting:i,loadPending:a,expandedGroups:P,selectedIDs:S,normalizedOptions:k,selected:m,hasOptions:C,active:R,hasActualValue:A,title:V,valueOption:K,disabled:p,fieldsetDisabled:c,invalid:G,loading:v,error:g}),[q,i,a,P,S,k,m,C,R,A,V,K,p,c,G,v,g]);return{selectId:T,selectRef:h,highlightStore:j,state:re,actions:_}}const Bn={},J=e=>e!=null&&e!=="",De=e=>e?typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(De).join(" ").replace(/\s+/g," ").trim():o.isValidElement(e)?De(e.props.children):"":"",Fn=({name:e,label:t,id:n,value:s,className:r,style:i,children:a,disabled:c,group:u},y,f)=>{const O=De(a),d=s!==void 0?s:O;return a!=null&&!O&&!J(t)&&!J(e)&&!J(n)&&!J(s)&&ee("no text","<Option> has content but no text to show in the title or chips. Add a `label` (or `value`), or enable `valueAsOption`."),{id:J(n)?String(n):y,userId:J(n)?n:d,value:d,label:J(t)?String(t):J(e)?String(e):O||(J(n)?String(n):""),jsx:a,hasJsx:a!=null,className:r,style:i,disabled:!!c,group:u||f||null}},Pn=({name:e,label:t,value:n,id:s,disabled:r,className:i="",style:a=Bn},c)=>{const u=e??t??s??n;return{disabled:!!r,isGroupMarker:!0,group:J(u)?String(u):c,className:i,style:a}},Hn=e=>`<${typeof e=="string"?e:e?.displayName||e?.name||"Component"}>`,be=(e,t,n=null,s="o",r=[])=>(o.Children.toArray(e).forEach(i=>{if(!o.isValidElement(i)){ee("text",`Text inside <Select> or <OptGroup> is ignored ("${String(i).slice(0,30)}"). Wrap it in <Option>.`);return}const a=`${s}-${String(i.key).slice(1).replace(/[:$]/g,u=>u===":"?"-":"k").replace(/[^\p{L}\p{N}-]/gu,"")}`,c=i.type?.racKind;if(i.type===o.Fragment)be(i.props.children,t,n,a,r);else if(c==="option")r.push(Fn(i.props,a,n));else if(c==="define")be(i.type.racRender(i.props),t,n,a,r);else if(c==="group"){const u=Pn(i.props,t);r.push(u),be(i.props.children,t,u.group,a,r)}else{const u=Hn(i.type);ee(`child ${u}`,`${u} inside <Select> is ignored: only <Option/>, <OptGroup/> and defineOption() components are read. Put custom content inside <Option>, or wrap the component with defineOption().`)}}),r),Vn=new Set(["ref","options","value","defaultValue","onChange","children","loadMore","open","onOpenChange","onFocus","onBlur","onKeyDown","childrenFirst","groupsClosed","disabled","loading","error"]),zn=/^(aria|data)-/,Me={options:[],value:void 0,defaultValue:void 0,onChange:void 0,multiple:!1,childrenFirst:!1,groupsClosed:!1,disabled:!1,loading:!1,error:!1,open:void 0,onOpenChange:void 0,popup:!0,onFocus:void 0,onBlur:void 0,onKeyDown:void 0,id:void 0,name:void 0,form:void 0,required:!1,hasMore:!1,loadMore:void 0,loadButton:!1,loadOffset:100,loadAhead:3,placeholder:"Choose option",selectedText:void 0,texts:{empty:"No options",disabled:"Disabled",loading:"Loading",error:"Failed to load",clear:"Clear selection",remove:"Remove",loadMore:"Load more",loadingMore:"Loading",emptyOption:"Empty option",invalidOption:"Invalid option",disabledOption:"Disabled option",emptyGroup:"Empty group",groupOpen:"expanded",groupClosed:"collapsed",list:"Options",required:void 0,removed:"Removed {label}",cleared:"Selection cleared",selected:"{n} selected",loaded:"{n} more options loaded"},renderOption:void 0,valueAsOption:!1,icons:{arrow:he.ArrowUp,clear:he.XMark,remove:he.XMark,check:he.Checkmark,checkbox:void 0},deleteInline:!1,deleteAlways:!1,className:"",optionsClassName:"",style:{},container:void 0,duration:300,easing:"ease",offset:1,animateOpacity:!0,keepMounted:!1},it={visibility:"open",setVisibility:"onOpenChange",ownBehavior:"open without onOpenChange",onOpen:"onOpenChange",onClose:"onOpenChange",unmount:"keepMounted (inverted)",showDelete:"deleteAlways",OpenIcon:"icons.arrow",ClearIcon:"icons.clear",DelIcon:"icons.remove",Checkmark:"icons.check",Checkbox:"icons.checkbox",emptyText:"texts.empty",disabledText:"texts.disabled",loadingText:"texts.loading",errorText:"texts.error",clearText:"texts.clear",removeText:"texts.remove",loadButtonText:"texts.loadMore",loadMoreText:"texts.loadingMore",emptyOption:"texts.emptyOption",invalidOption:"texts.invalidOption",disabledOption:"texts.disabledOption"},Ie=(e,t)=>{const n={...e};for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n};function qn(e){for(const d in e)d in it&&ee(`renamed ${d}`,`The \`${d}\` prop was removed. Use \`${it[d]}\`.`);e.value!==void 0&&!e.onChange&&ee("read-only value","`value` is set without `onChange`, so the Select is read-only. Pass `onChange`, or `defaultValue` instead of `value`.");const t=Ie(Me,e);t.texts=Ie(Me.texts,e.texts),t.icons=Ie(Me.icons,e.icons);const n=t.texts.emptyGroup,s=$e(o.useMemo(()=>be(t.children,n),[t.children,n])),{selectId:r,selectRef:i,highlightStore:a,state:c,actions:u}=Dn(t,s),y={},f={};for(const d in t)Vn.has(d)||((zn.test(d)?f:y)[d]=t[d]);const O=It({...y,attrs:f,selectId:r,selectRef:i,highlightStore:a});return E.jsx(Y.Provider,{value:O,children:E.jsx(ne.Provider,{value:u,children:E.jsxs(se.Provider,{value:c,children:[E.jsx(mn,{}),E.jsx(jn,{}),E.jsx(An,{})]})})})}function St(){return ee("option outside","<Option/> was rendered outside <Select>, or inside a component that <Select> cannot read. Use it as a direct child, or wrap the component with defineOption()."),null}St.racKind="option";function Ct(){return null}Ct.racKind="group";exports.OptGroup=Ct;exports.Option=St;exports.Select=qn;exports.defineOption=Wt;
|
package/dist/index.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer rac.base,rac.theme;@property --rac-list-max-height{syntax: "<length>"; inherits: true; initial-value: 250px;}@layer rac.base{:root{--rac-row: 2em}.rac-select,.rac-options{--rac-duration-fast: calc(var(--rac-duration) * .5)}@media(prefers-reduced-motion:reduce){.rac-select,.rac-options{--rac-duration: 1ms !important}.rac-dots i{animation:none}}.rac-select{position:relative;display:flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;cursor:pointer}.rac-select[aria-busy=true]{cursor:progress}.rac-select[aria-disabled=true]{cursor:not-allowed}.rac-select[aria-disabled=true][aria-busy=true]{cursor:wait}.rac-value{flex:1;min-width:0;min-height:var(--rac-row);display:flex;flex-wrap:wrap;align-items:center}.rac-title{max-width:calc(100% - .25px);white-space:nowrap}.rac-title,.rac-chip-text{min-width:0;overflow-x:clip
|
|
1
|
+
@layer rac.base,rac.theme;@property --rac-list-max-height{syntax: "<length>"; inherits: true; initial-value: 250px;}@layer rac.base{:root{--rac-row: 2em}.rac-select,.rac-options{--rac-duration-fast: calc(var(--rac-duration) * .5)}@media(prefers-reduced-motion:reduce){.rac-select,.rac-options{--rac-duration: 1ms !important}.rac-dots i{animation:none}}.rac-select{position:relative;display:flex;align-items:center;box-sizing:border-box;min-width:0;max-width:100%;cursor:pointer}.rac-select:not([aria-haspopup]){cursor:default}.rac-select[aria-busy=true]{cursor:progress}.rac-select[aria-disabled=true]{cursor:not-allowed}.rac-select[aria-disabled=true][aria-busy=true]{cursor:wait}.rac-value{flex:1;min-width:0;min-height:var(--rac-row);display:flex;flex-wrap:wrap;align-items:center}.rac-title{max-width:calc(100% - .25px);white-space:nowrap}.rac-title,.rac-chip-text,.rac-chip>.rac-option-jsx{min-width:0;overflow-x:clip}.rac-title,.rac-chip-text{text-overflow:ellipsis}.rac-dots{display:inline-flex;gap:.17em;margin-inline-start:.25em}.rac-dots i{width:.25em;height:.25em;border-radius:50%;background:currentColor;animation:rac-blink 1.4s infinite both}.rac-dots i:nth-child(2){animation-delay:.2s}.rac-dots i:nth-child(3){animation-delay:.4s}.rac-clear,.rac-arrow{display:grid;place-items:center;align-self:center}.rac-clear,.rac-chip-del{padding:0;border:0;background:none;color:inherit;font:inherit;cursor:pointer}.rac-arrow,.rac-group-arrow{transition:rotate var(--rac-duration) var(--rac-ease)}.rac-select:not([data-placement=top],[aria-expanded=true]) .rac-arrow,.rac-select[data-placement=top][aria-expanded=true] .rac-arrow{rotate:180deg}.rac-icon{height:1em}.rac-input{position:absolute;inset:0;box-sizing:border-box;width:100%;height:100%;margin:0;padding:0;border:0;opacity:0;pointer-events:none}.rac-live{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}.rac-chip-slot{display:flex;align-items:center;max-width:100%}.rac-chip{position:relative;display:inline-flex;flex-shrink:0;align-items:center;box-sizing:border-box;max-width:inherit;white-space:nowrap;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent;touch-action:pan-y}.rac-chip-del{position:absolute;flex-shrink:0;inset-inline-end:0;height:100%;display:grid;align-items:center}.rac-chip-del:disabled{cursor:inherit}.rac-select:is([data-deleting],[data-inline-delete]) .rac-chip-del{position:relative}@media(any-pointer:coarse){.rac-clear{position:relative}.rac-arrow{pointer-events:none}.rac-clear:before,.rac-chip-del:before{content:"";position:absolute;inset:min(0px,50% - 12px)}}.rac-spacer{flex-basis:100%;height:0;margin-inline-end:1px}.rac-options{box-sizing:border-box;z-index:2147483647;overflow:clip}.rac-options{transition:opacity var(--rac-duration) var(--rac-ease),visibility 0s}.rac-options[data-offscreen]{opacity:0;visibility:hidden;transition-delay:0s,var(--rac-duration)}.rac-list{max-height:var(--rac-list-max-height);overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable;scroll-behavior:smooth}.rac-option{display:flex;justify-content:space-between;align-items:center;overflow-wrap:anywhere;cursor:pointer}.rac-option[aria-disabled=true]{cursor:not-allowed}.rac-option[data-error]{cursor:default}.rac-option[data-loading]{justify-content:start;align-items:baseline;cursor:wait}.rac-check{position:relative;display:flex;justify-content:center;align-items:center}.rac-check[data-default]{width:1em;height:1em;border:1px solid}.rac-checkmark{position:absolute;width:auto;height:1em;opacity:0;scale:0;transition:opacity var(--rac-duration) var(--rac-ease),scale var(--rac-duration) var(--rac-ease)}.rac-option[aria-selected=true] .rac-checkmark{opacity:1;scale:1}.rac-group{display:flex;justify-content:space-between;align-items:center;cursor:pointer}.rac-group[data-disabled]{cursor:not-allowed}.rac-group-arrow{display:grid}.rac-group[data-open]>.rac-group-arrow{rotate:180deg}@keyframes rac-blink{0%{opacity:.2}20%{opacity:1}to{opacity:.2}}}@layer rac.base,rac.theme;@layer rac.theme{:root{--rac-bg: color-mix(in srgb, Canvas 98%, CanvasText 2%);--rac-fg: CanvasText;--rac-danger: #e7000b;--rac-success: #4caf50;--rac-radius: 0px}.rac-select,.rac-options{--rac-tint-1: color-mix(in srgb, var(--rac-fg) 5%, var(--rac-bg));--rac-tint-2: color-mix(in srgb, var(--rac-fg) 10%, var(--rac-bg));--rac-tint-3: color-mix(in srgb, var(--rac-fg) 20%, var(--rac-bg));--rac-muted: color-mix(in srgb, var(--rac-fg) 55%, var(--rac-bg))}.rac-select,.rac-options{border-radius:var(--rac-radius)}.rac-select{padding:0 .5em;border:2px solid var(--rac-bg);background-color:var(--rac-bg);color:var(--rac-fg);transition:background-color var(--rac-duration) var(--rac-ease),border-color var(--rac-duration) var(--rac-ease),opacity var(--rac-duration) var(--rac-ease)}.rac-select[aria-haspopup]:not([aria-disabled=true]):hover{background-color:var(--rac-tint-1)}.rac-select[aria-haspopup]:not([aria-disabled=true],[data-error],[data-invalid]):hover{border-color:var(--rac-tint-1)}.rac-select[aria-disabled=true]{opacity:.75}.rac-select:is([data-error],[data-invalid]){border-color:var(--rac-danger)}.rac-select[aria-busy=true]:after{content:"";position:absolute;inset:0;border-radius:inherit;background:linear-gradient(90deg,transparent,var(--rac-muted),transparent) 0 100% / 40% 2px no-repeat;animation:rac-busy 1.5s ease-in-out infinite;pointer-events:none}@media(prefers-reduced-motion:reduce){.rac-select[aria-busy=true]:after{animation:none;background-size:100% 2px}}:is(.rac-title,.rac-option)[data-bool=true]{color:var(--rac-success)}:is(.rac-title,.rac-option)[data-bool=false]{color:var(--rac-danger)}.rac-chip{min-height:calc(var(--rac-row) - .5em);margin-block:.25em;margin-inline-end:.5em;padding-inline:.25em;border-radius:calc(var(--rac-radius) / 2);line-height:normal;background-color:var(--rac-tint-2);transition:background-color var(--rac-duration-fast) var(--rac-ease)}@media(hover:hover){.rac-chip:hover{background-color:var(--rac-tint-3)}}.rac-select[data-deleting] .rac-chip{background-color:color-mix(in srgb,var(--rac-danger) 15%,var(--rac-bg));animation:rac-shake .3s infinite}@media(prefers-reduced-motion:reduce){.rac-select[data-deleting] .rac-chip{animation:none}}.rac-chip-del{border-start-end-radius:inherit;border-end-end-radius:inherit;background-color:color-mix(in srgb,var(--rac-danger) 30%,var(--rac-bg));transition:color var(--rac-duration) var(--rac-ease),background-color var(--rac-duration) var(--rac-ease)}.rac-chip-del:hover{color:var(--rac-danger)}.rac-select:is([data-deleting],[data-inline-delete]) .rac-chip-del{background-color:transparent}.rac-list{background-color:var(--rac-bg);color:var(--rac-fg);scrollbar-color:var(--rac-tint-2) var(--rac-tint-1);scrollbar-width:thin;scroll-padding-block:.5em}.rac-option{gap:.5em;padding:.5em;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-option[data-highlighted]{background-color:var(--rac-tint-2)}.rac-option[aria-selected=true]{background-color:var(--rac-tint-3)}.rac-option[aria-selected=true][data-highlighted]{background-color:color-mix(in srgb,var(--rac-fg) 30%,var(--rac-bg))}.rac-option[aria-disabled=true]{color:var(--rac-muted)}.rac-option[data-invalid]{color:var(--rac-danger)}.rac-option[data-loading]{gap:0;color:var(--rac-muted)}.rac-option[data-error]{color:var(--rac-danger)}.rac-check{margin-inline-end:.2em}.rac-check[data-default]{border-color:var(--rac-muted)}.rac-group{padding:.5em;font-size:1.25em;font-weight:700;transition:background-color var(--rac-duration-fast) var(--rac-ease)}.rac-group[data-highlighted]{background-color:var(--rac-tint-2)}.rac-group[data-disabled]{color:var(--rac-muted)}.rac-group-items{padding-inline-start:1em}@keyframes rac-busy{0%{background-position-x:-100%}to{background-position-x:200%}}@keyframes rac-shake{0%{transform:rotate(0)}25%{transform:rotate(-1deg)}75%{transform:rotate(1deg)}to{transform:rotate(0)}}}
|