import{r as p,j as a}from"./index-D4ZMoJFe.js";const f=e=>{var t,i,c;return String(((i=(t=e==null?void 0:e.companies)==null?void 0:t[0])==null?void 0:i.id)||(e==null?void 0:e.companyId)||((c=e==null?void 0:e.company)==null?void 0:c.id)||"")},r=e=>{var i;const t=Array.isArray(e==null?void 0:e.companies)?e.companies:[];return t.length?t:(i=e==null?void 0:e.company)!=null&&i.id?[e.company]:[]};function N({user:e,companyId:t,onCompanyChange:i,companyLabel:c="Société",companyRequired:s=!0,className:o=""}){const m=p.useMemo(()=>r(e),[e]);return a.jsxs("label",{className:`space-y-2 ${o}`,children:[a.jsx("span",{className:"text-sm font-medium text-text",children:c}),a.jsxs("select",{required:s,className:"input-dark",value:t||"",onChange:l=>i(l.target.value),children:[a.jsx("option",{value:"",children:"Sélectionner"}),m.map(l=>a.jsx("option",{value:l.id,children:l.name},l.id))]})]})}function u({user:e,companyId:t,depotId:i,depots:c,onCompanyChange:s,onDepotChange:o,companyLabel:m="Société",depotLabel:l="Dépôt",companyRequired:h=!0,depotRequired:j=!0,depotPlaceholder:g="Sélectionner",className:d=""}){const v=p.useMemo(()=>r(e),[e]);return a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:`space-y-2 ${d}`,children:[a.jsx("span",{className:"text-sm font-medium text-text",children:m}),a.jsxs("select",{required:h,className:"input-dark",value:t||"",onChange:n=>s(n.target.value),children:[a.jsx("option",{value:"",children:"Sélectionner"}),v.map(n=>a.jsx("option",{value:n.id,children:n.name},n.id))]})]}),a.jsxs("label",{className:`space-y-2 ${d}`,children:[a.jsx("span",{className:"text-sm font-medium text-text",children:l}),a.jsxs("select",{required:j,className:"input-dark",value:i||"",onChange:n=>o(n.target.value),disabled:!t,children:[a.jsx("option",{value:"",children:g}),(c||[]).map(n=>{var x;return a.jsx("option",{value:n.id,children:(x=n.company)!=null&&x.name?`${n.label} · ${n.company.name}`:n.label},n.id)})]})]})]})}export{u as M,N as a,f as g};
