import{jsx as e,jsxs as i}from"react/jsx-runtime";import{memo as b,useMemo as g}from"react";import{ClearButton as j}from"../ClearButton/index.js";import{normalizeText as m}from"../../../utils/index.js";import{Arrow as v}from"./styled.js";function z({options:o,onChange:c,handleClear:p,clearable:u,placeholder:n,value:a="",className:x}){const f=t=>{const{selectedIndex:s}=t.target,l=n||!a?s-1:s;c(o[l])},h=g(()=>o.map(({idx:t,value:s,title:l},C)=>{const d=m(s);return e("option",{value:d,className:"dropdown-option",children:l||d},t||d+C)}),[o]),r=m(a),w=o.find(t=>t.value===a)?.title||r;return i("div",{className:x+" dropdown-wrapper",children:[e(v,{}),u&&r?.length>0&&e(j,{handleClear:p}),i("select",{onChange:f,value:r,className:"dropdown-select","aria-label":"dropdown select",children:[n&&e("option",{disabled:!0,hidden:!0,value:n,children:n}),!r&&!n&&e("option",{disabled:!0}),h]}),e("label",{children:w})]})}const B=b(z);export{B as Select};
