"use strict";const e=require("react/jsx-runtime"),r=require("react"),w=require("@chakra-ui/react/styled-system"),n=require("./select-Dq_6o0BB.cjs.js"),H=require("./search-input-BNXlpYtP.cjs.js"),J=require("./extract-style-props-B4hqila-.cjs.js"),Q=require("./index-CVXB9mwf.cjs.js"),U=require("@chakra-ui/react"),c=require("./normalize-messages-CaDzkuUm.cjs.js"),{withProvider:X,withContext:S}=U.createSlotRecipeContext({key:"scopedSearchInput"}),Y=X("div","root"),Z=S("div","container"),ee=S("div","selectWrapper"),se=S("div","searchWrapper"),ae=l=>!l.text||l.text.trim().length===0,te={searchLabel:"Search",selectLabel:"Filter by"},re={searchLabel:"Suche",selectLabel:"Filtern nach"},ce={searchLabel:"Buscar",selectLabel:"Filtrar por"},le={searchLabel:"Rechercher",selectLabel:"Filtrer par"},ne={searchLabel:"Pesquisa",selectLabel:"Filtrar por"},oe={en:c.normalizeMessages(te),de:c.normalizeMessages(re),es:c.normalizeMessages(ce),"fr-FR":c.normalizeMessages(le),"pt-BR":c.normalizeMessages(ne)},g=l=>{const{value:a,onValueChange:o,onTextChange:I,onOptionChange:m,onSubmit:x,onReset:y,options:q,selectPlaceholder:P,searchPlaceholder:z,selectAriaLabel:F,searchAriaLabel:D,isClearable:O=!0,isDisabled:i,isReadOnly:d,isInvalid:k,isRequired:C,id:_,"aria-describedby":R,"aria-labelledby":L,size:v}=l,f=c.useLocalizedStringFormatter(oe),W=w.useSlotRecipe({recipe:Q.scopedSearchInputSlotRecipe}),[$,A]=W.splitVariantProps(l),[B,E]=J.extractStyleProps(A),T=r.useId(),M=_||T,V=`${M}-select`,j=`${M}-search`,u=r.useRef(null),h=r.useCallback(s=>{I?.(s),o?.({...a,text:s})},[a,I,o]),G=r.useCallback(s=>{if(s===null)return;const t=String(s);m?.(t),o?.({...a,option:t}),u.current&&!i&&!d&&setTimeout(()=>{u.current?.focus()},0)},[a,m,o,i,d]),K=r.useCallback(()=>{x(a)},[a,x]),N=r.useCallback(()=>{y?.(),h("")},[y,h]);return e.jsx(Y,{...$,...B,...E,children:e.jsxs(Z,{children:[e.jsx(ee,{asChild:!0,children:e.jsx(n.Select.Root,{id:V,selectedKey:a.option,onSelectionChange:d?void 0:G,placeholder:P,"aria-label":F||f.format("selectLabel"),"aria-controls":j,"aria-describedby":R,"aria-labelledby":L,size:v,isClearable:!1,isDisabled:i,isRequired:C,children:e.jsx(n.Select.Options,{children:q.map(s=>{if("options"in s){const b=s;return e.jsx(n.Select.OptionGroup,{label:b.label,children:b.options.map(p=>e.jsx(n.Select.Option,{id:p.value,isDisabled:p.isDisabled,children:p.label},p.value))},b.label)}const t=s;return e.jsx(n.Select.Option,{id:t.value,isDisabled:t.isDisabled,children:t.label},t.value)})})})}),e.jsx(se,{asChild:!0,children:e.jsx(H.SearchInput,{ref:u,id:j,value:a.text,onChange:h,onSubmit:K,onClear:O?N:void 0,placeholder:z,"aria-label":D||f.format("searchLabel"),"aria-describedby":R,"aria-labelledby":L,size:v,isDisabled:i,isReadOnly:d,isInvalid:k,isRequired:C})})]})})};g.isEmpty=ae;g.displayName="ScopedSearchInput";exports.ScopedSearchInput=g;
//# sourceMappingURL=scoped-search-input-DKCK7idN.cjs.js.map
