import{r as n,t as J,f as o,j as t,h as K,k,e as O,S as Q,F as U,B as W}from"./main-few-lands-burn.js";import{M as X}from"./mixinput-CX5xeb4d.js";import{S as Y}from"./usedebou-9GKFiQAC.js";import{T as F}from"./index-ubWv-fhI.js";import{S as Z}from"./index-BcDJZYeX.js";const{Text:j}=F;function D({direction:c="horizontal",helperText:r,invalidMessage:s,label:l,onRender:i,wrapperClassName:d,...h}){const m=n.useId(),{token:u}=J.useToken();n.useEffect(()=>{i?.()},[]);const f=c==="vertical";return o("div",{className:d,children:[o("div",{className:k(["flex",f?"flex-col-reverse items-start":"items-center"]),children:[t(Y,{className:"","data-testid":"switchComponent",id:m,...h}),l&&t("label",{className:k(["font-medium",f?"mb-1":"ml-2"]),css:K({color:u.colorText},"",""),htmlFor:m,children:l})]}),s&&t(j,{type:"danger",children:s}),!s&&r&&t(j,{type:"secondary",children:r})]})}const{Text:S}=F;function oe({className:c,helperText:r,invalidMessage:s,isLoadable:l=!1,isMappable:i=!1,isMapped:d,label:h,loadBtnText:m=O("Load More..."),onLoadData:u,onPopupScroll:f,onRender:v,onSearch:M,options:$,required:z,setIsMapped:B,showSearch:b,status:N,suffix:E,wrapperClassName:L,...a}){const x=n.useId(),[R,w]=n.useState(!1),T=n.useRef(1),[g,y]=n.useState(!1),C=n.useRef(!1);n.useEffect(()=>{v?.()},[]);const H=async e=>{u&&(w(!0),await u({count:T.current,event:e}),T.current+=1,w(!1))},P=e=>{M?.(e),l&&(C.current=e.length>0,g&&y(!1))},V=e=>{if(f?.(e),!l)return;const{clientHeight:p,scrollHeight:A,scrollTop:G}=e.target,I=A-G<=p+300;!g&&I&&!C.current?y(!0):g&&!I&&y(!1)},_=e=>{let p;e&&(p=a.value!==void 0&&a.value!==null&&typeof a.value=="string"?[{type:"string",value:String(a.value)}]:void 0),a.onChange?.(p)},q=e=>{B?.(e),_(e)};return o("div",{className:L,children:[o("div",{className:"flex items-start justify-between gap-2",children:[h&&o("label",{className:"d-b mb-1 font-medium",htmlFor:x,children:[h,z&&t(S,{className:"leading-none",type:"danger",children:"*"})]}),i&&t(D,{checked:d,label:O("Map"),onChange:q,size:"small"})]}),i&&d?t(X,{...a,className:c,id:x,onRender:v,placeholder:typeof a.placeholder=="string"?a.placeholder:""}):o(Q.Compact,{className:"w-100",children:[t(Z,{className:`${c} min-w-0 flex-1`,"data-testid":"selectComponent",id:x,...b&&{onSearch:P},showSearch:b,status:N,...a,dropdownRender:e=>o(U,{children:[e,l&&g&&t(W,{block:!0,className:k("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:R,onClick:H,size:"small",type:"link",children:m})]}),onPopupScroll:V,options:$}),E]}),N==="error"&&s&&t(S,{type:"danger",children:s}),!s&&r&&t(S,{type:"secondary",children:r})]})}export{oe as S,D as a};
