import{r as c,j as o,c_ as j,h as C}from"./react-vendor-xYZnmIII.js";import{a2 as b,a3 as w,B as y,a4 as N,ay as g,az as E,aA as R,aB as _,aC as B,aD as I,c as P}from"./ui-components-CQM92IK3.js";const O=({data:r,placeholder:h,onSelect:l,defaultValue:s,translate:n})=>{var x,d,f;const[u,p]=c.useState(!1),[a,t]=c.useState(s||""),i=c.useRef(!0);c.useEffect(()=>{if(s&&(i.current||s!==a)){const e=r.find(m=>m.value===s);e&&(t(s),i.current||l(e))}i.current=!1},[s,r,a,l]);const v=e=>{const m=e.value===a?"":e.value;t(m),l(e),p(!1)};return o.jsxs(b,{open:u,onOpenChange:p,children:[o.jsx(w,{className:"w-full",children:o.jsxs(y,{type:"button",variant:"outline",role:"combobox","aria-expanded":u,className:"w-full justify-between",children:[a?(x=r.find(e=>e.value===a))==null?void 0:x.label:h,o.jsx(j,{className:"opacity-50"})]})}),o.jsx(N,{className:"w-[var(--radix-popover-trigger-width)] p-0",children:o.jsxs(g,{children:[o.jsx(E,{placeholder:((d=n==null?void 0:n.input)==null?void 0:d.search_placeholder)||"Search element...",className:"focus:border-none focus:ring-0 focus:outline-none"}),o.jsxs(R,{children:[o.jsx(_,{children:((f=n==null?void 0:n.frontend)==null?void 0:f.no_element_found)||"No element found."}),o.jsx(B,{className:"max-h-[300px] overflow-y-auto",children:r.map(e=>o.jsxs(I,{value:e.value,onSelect:()=>v(e),children:[e.label,o.jsx(C,{className:P("ml-auto",a===e.value?"opacity-100":"opacity-0")})]},e.value))})]})]})})]})};export{O as C};
