import{z as h,j as t,d as r,r as u,A as g,n as x,f as y,q as d,p as S}from"./index-3c1b2661.js";import{D as j}from"./DiskSizeSelector-f5c6feab.js";import{A as F}from"./AutoExpandingTextArea-38ef4775.js";import{F as C}from"./FormMenuItem-c982b037.js";import{u as b}from"./updateMaxHeight-4e644a5f.js";import{M as v}from"./StorageVolumeFormMenu-3787a809.js";import{i as f}from"./settings-c23f9009.js";const n="dir",c="btrfs",N="lvm",m="zfs",D=[{label:"Directory",value:n},{label:"Btrfs",value:c},{label:"LVM",value:N},{label:"ZFS",value:m}],p={dir:"Optional, path to an existing directory",lvm:"Optional, path to an existing block device, loop file or LVM volume group",zfs:"Optional, path to an existing block device, loop file or ZFS dataset/pool"},z=e=>Object.keys(p).includes(e)?p[e]:"Not available",B=(e,a)=>["deduplicate","A storage pool with this name already exists",s=>h(s,e,a,"storage-pools")],M=({formik:e})=>{const a=s=>({id:s,name:s,onBlur:e.handleBlur,onChange:e.handleChange,value:e.values[s],error:e.touched[s]?e.errors[s]:null,placeholder:`Enter ${s.replaceAll("_"," ")}`});return t.jsx(r.Row,{children:t.jsxs(r.Col,{size:8,children:[t.jsx(r.Input,{...a("name"),type:"text",label:"Name",required:!0,disabled:!e.values.isCreating||e.values.isReadOnly,help:e.values.isCreating?void 0:"Cannot rename storage pools"}),t.jsx(F,{...a("description"),label:"Description",disabled:e.values.isReadOnly,dynamicHeight:!0}),t.jsx(r.Select,{id:"driver",name:"driver",help:e.values.isCreating?e.values.driver===m?"ZFS gives best performance and reliability":void 0:"Driver can't be changed",label:"Driver",options:D,onChange:s=>{const l=s.target.value;l===n&&e.setFieldValue("size",""),l===c&&e.setFieldValue("source",""),e.setFieldValue("driver",l)},value:e.values.driver,required:!0,disabled:!e.values.isCreating||e.values.isReadOnly}),t.jsx(j,{label:"Size",value:e.values.size,help:e.values.driver===n?"Not available":"When left blank, defaults to 20% of free disk space. Default will be between 5GiB and 30GiB",setMemoryLimit:s=>void e.setFieldValue("size",s),disabled:e.values.driver===n||e.values.isReadOnly}),t.jsx(r.Input,{...a("source"),type:"text",disabled:e.values.driver===c||!e.values.isCreating||e.values.isReadOnly,help:e.values.isCreating?z(e.values.driver):"Source can't be changed",label:"Source"})]})})},O="Main configuration",A=({active:e,setActive:a})=>{var i;const s=r.useNotify(),l={active:e,setActive:a},o=()=>{b("form-navigation","p-bottom-controls")};return u.useEffect(o,[(i=s.notification)==null?void 0:i.message]),g("resize",o),t.jsx("div",{className:"p-side-navigation--accordion form-navigation",children:t.jsx("nav",{"aria-label":"Storage pool form navigation",children:t.jsx("ul",{className:"p-side-navigation__list",children:t.jsx(C,{label:O,...l})})})})},H=({formik:e})=>{var i;const a=r.useNotify(),[s,l]=u.useState(v),o=()=>{b("form-contents","p-bottom-controls")};return u.useEffect(o,[(i=a.notification)==null?void 0:i.message,s]),g("resize",o),t.jsxs(r.Form,{className:"form storage-pool-form",onSubmit:e.handleSubmit,children:[t.jsx(r.Input,{type:"submit",hidden:!0}),t.jsx(A,{active:s,setActive:l}),t.jsx(r.Row,{className:"form-contents",children:t.jsx(r.Col,{size:12,children:s===v&&t.jsx(M,{formik:e})})},s)]})},_=()=>{const{data:e}=x(),a=f(e);return y({queryKey:[d.cluster,d.members],queryFn:S,enabled:a})};export{H as S,c as b,B as t,_ as u,m as z};
