import{j as s,d as c,b0 as p,r as f}from"./index-DET0E_3l.js";import{S as x}from"./StoragePoolSize-BLDpiQif.js";const S=({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(x,{pool:e},e.name)},"usage")]}),j=()=>{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})},P=({value:e,setValue:t,selectProps:o,invalidDrivers:l})=>{const u=c.useNotify(),{data:d=[],error:i,isLoading:g}=p(),r=d.filter(a=>!(l!=null&&l.includes(a.driver)));if(f.useEffect(()=>{!e&&r.length>0&&t(r[0].name)},[e,r]),g)return s.jsx(c.Spinner,{className:"u-loader",text:"Loading storage pools..."});i&&u.failure("Loading storage pools failed",i);const m=()=>{const a=[];return r&&(r.forEach(n=>{a.push({label:s.jsx(S,{pool:n}),value:n.name,disabled:!1,text:`${n.name} (${n.driver})`})}),r.length===0&&a.unshift({label:"No storage pool available",value:"",disabled:!0})),a},h=a=>{t(a)};return s.jsx(c.CustomSelect,{name:"pool","aria-label":"Storage Pool",searchable:"auto",...o,options:m(),onChange:h,value:e,dropdownClassName:"storage-pool-select-dropdown",header:s.jsx(j,{})})};export{P as S};
