import{r as s,a as o,j as r,S as H,F as I,B as $,_ as z,l as q}from"./main-tangy-colts-beg.js";import{T as G}from"./index-tangy-colts-beg-131.js";import{S as J}from"./index-tangy-colts-beg-596.js";globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,a){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,a),a)}};const{Text:g}=G;function U({className:e,helperText:a,invalidMessage:i,isLoadable:l=!1,label:u,loadBtnText:w=z("Load More..."),onLoadData:m,onPopupScroll:n,onRender:h,onSearch:d,options:T,required:N,showSearch:p,status:b,suffix:S,wrapperClassName:A,...M}){const y=s.useId(),[O,k]=s.useState(!1),x=s.useRef(1),[c,f]=s.useState(!1),C=s.useRef(!1);s.useEffect(()=>{h==null||h()},[]);const B=async t=>{m&&(k(!0),await m({count:x.current,event:t}),x.current+=1,k(!1))},F=t=>{d==null||d(t),l&&(C.current=t.length>0,c&&f(!1))},L=t=>{if(n==null||n(t),!l)return;const{clientHeight:_,scrollHeight:v,scrollTop:E}=t.target,j=v-E<=_+300;!c&&j&&!C.current?f(!0):c&&!j&&f(!1)};return o("div",{className:A,children:[u&&o("label",{className:"d-b mb-1 font-medium",htmlFor:y,children:[u,N&&r(g,{className:"leading-none",type:"danger",children:"*"})]}),o(H.Compact,{className:"w-100",children:[r(J,{className:`${e} min-w-0 flex-1`,"data-testid":"selectComponent",id:y,...p&&{onSearch:F},showSearch:p,status:b,...M,dropdownRender:t=>o(I,{children:[t,l&&c&&r($,{block:!0,className:q("bg-slate-100 text-slate-600 hover:bg-slate-200 hover:text-blue-600","dark:bg-slate-950 dark:bg-opacity-40 dark:text-slate-200 dark:hover:bg-slate-950 dark:hover:bg-opacity-100 dark:hover:text-blue-400"),loading:O,onClick:B,size:"small",type:"link",children:w})]}),onPopupScroll:L,options:T}),S]}),b==="error"&&i&&r(g,{type:"danger",children:i}),!i&&a&&r(g,{type:"secondary",children:a})]})}globalThis.jotaiAtomCache=globalThis.jotaiAtomCache||{cache:new Map,get(e,a){return this.cache.has(e)?this.cache.get(e):(this.cache.set(e,a),a)}};export{U as S};
