import{R as o,bI as c,db as p,a as l,aT as i,q as m,j as n,d as r}from"./index-Dz5JRQhj.js";const u=["can_delete","can_edit"],P=async(e,a)=>{const t=new URLSearchParams;return t.set("recursion","1"),t.set("project",e),p(t,a,u),fetch(`${o}/1.0/placement-groups?${t.toString()}`).then(c).then(s=>s.metadata)},h=async(e,a,t)=>{const s=new URLSearchParams;return s.set("project",a),p(s,t,u),fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e)}?${s.toString()}`).then(c).then(d=>d.metadata)},g=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups?${t.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:e}).then(c)},E=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e.name)}?${t.toString()}`,{method:"PUT",body:JSON.stringify(e),headers:{"Content-Type":"application/json"}}).then(c)},C=async(e,a)=>{const t=new URLSearchParams;t.set("project",a),await fetch(`${o}/1.0/placement-groups/${encodeURIComponent(e)}?${t.toString()}`,{method:"DELETE"}).then(c)},T=e=>{const{isFineGrained:a}=l();return i({queryKey:[m.placementGroups,e],queryFn:async()=>P(e,a)})},_=(e,a)=>{const{isFineGrained:t}=l();return i({queryKey:[m.placementGroups,a,e],queryFn:async()=>h(e,a,t)})},y="compact",b="spread",R="strict",S="permissive",I=({formik:e,isEdit:a=!1})=>{const t=s=>e.touched[s]?e.errors[s]:void 0;return n.jsxs(r.Form,{onSubmit:e.handleSubmit,children:[n.jsx(r.Input,{type:"submit",hidden:!0,value:"Hidden input"}),n.jsx(r.Input,{...e.getFieldProps("name"),type:"text",label:"Name",required:!0,autoFocus:!a,error:t("name"),placeholder:"Enter name",disabled:a,title:a?"Placement groups can't be renamed":void 0}),n.jsx(r.Input,{...e.getFieldProps("description"),type:"text",autoFocus:a,label:"Description",placeholder:"Enter description",error:t("description")}),n.jsx(r.Select,{...e.getFieldProps("policy"),label:"Policy",options:[{value:y,label:"Compact"},{value:b,label:"Spread"}],help:"Compact packs instances on as few members as possible. Spread distributes instances across members."}),n.jsx(r.Select,{...e.getFieldProps("rigor"),label:"Rigor",options:[{value:R,label:"Strict"},{value:S,label:"Permissive"}],help:"Strict fails instance creation if no matching member is available. Permissive allows creation to other members."})]})};export{y as P,R as a,I as b,g as c,_ as d,E as e,C as f,T as u};
