import{j as s,d as S,p as x,g as j,q as v,ak as b,U as N,r as y,L as P}from"./index-CzUo07dn.js";import{C as L}from"./CustomSelect-D8P9H5Av.js";import{S as C}from"./StoragePoolSize-DCNPXe9o.js";const E=({pool:e})=>s.jsxs("div",{className:"label",children:[s.jsx("span",{title:e.name||"-",className:"resource u-truncate",children:e.name||"-"},"name"),s.jsx("span",{title:e.driver||"-",className:"resource-driver u-truncate",children:e.driver||"-"},"driver"),s.jsx("span",{title:"Usage",className:"resource-usage u-truncate",children:s.jsx(C,{pool:e},e.name)},"usage")]}),q=()=>{const e=["name","driver","usage"];if(e.length<2)return null;const t=e.map(o=>s.jsx("span",{className:"resource u-no-margin--bottom",children:o},o));return s.jsx("div",{className:"header",children:t})},w=({value:e,setValue:t,selectProps:o,hidePoolsWithUnsupportedDrivers:c=!1})=>{const d=S.useNotify(),{data:u}=x(),{data:i=[],error:l,isLoading:g}=j({queryKey:[v.storage],queryFn:()=>b()}),m=N(u),p=i.filter(r=>m.has(r.driver)),a=c?p:i;if(y.useEffect(()=>{!e&&a.length>0&&t(a[0].name)},[e,a]),g)return s.jsx(P,{text:"Loading storage pools..."});l&&d.failure("Loading storage pools failed",l);const h=()=>{const r=[];return a&&(a.forEach(n=>{r.push({label:s.jsx(E,{pool:n}),value:n.name,disabled:!1,text:`${n.name} (${n.driver})`})}),a.length===0&&r.unshift({label:"No storage pool available",value:"",disabled:!0})),r},f=r=>{t(r)};return s.jsx(L,{name:"pool","aria-label":"Storage Pool",searchable:"auto",...o,options:h(),onChange:f,value:e,dropdownClassName:"storage-pool-select-dropdown",header:s.jsx(q,{})})};export{w as S};
