import{n as p,f as k,d as n,k as y,l as N,o as j,g as h,c as F,q as a,j as o,e as g}from"./index-Cziemgsu.js";import{N as v,t as x,a as b}from"./NetworkForwardForm-BzYNysJR.js";import{c as C}from"./network-forwards-BsCG3hGt.js";import{B as L}from"./BaseLayout-7LTMOawH.js";import{H as q}from"./HelpLink-C4E8LWq2.js";import{F as $}from"./FormFooterLayout-BJQGpdhQ.js";import{d as A}from"./networks-mhWNV24c.js";import"./index.esm-dDZ7-lOE.js";import"./NotificationRow-BJRTvUVl.js";import"./ClusterMemberSelector--J9qxfzT.js";import"./formFields-BDRvqvBI.js";import"./ScrollableContainer-C6sud4ax.js";const G=()=>{const d=p(),c=k(),u=n.useNotify(),m=y(),f=N(),{network:s,project:e}=j(),{data:r}=h({queryKey:[a.projects,e,a.networks,s],queryFn:()=>A(s??"",e??"")}),t=F({initialValues:{listenAddress:(r==null?void 0:r.type)!=="ovn"?"":(r==null?void 0:r.config["ipv4.address"])!=="none"?"0.0.0.0":(r==null?void 0:r.config["ipv6.address"])!=="none"?"::":"",ports:[]},validationSchema:v,onSubmit:l=>{const i=x(l);C(s??"",i,e??"").then(()=>{f.invalidateQueries({queryKey:[a.projects,e,a.networks,r,a.forwards]}),c(`/ui/project/${e}/network/${s}/forwards`),m.success(`Network forward ${i.listen_address} created.`)}).catch(w=>{t.setSubmitting(!1),u.failure("Network forward creation failed",w)})}});return o.jsxs(L,{title:o.jsx(q,{href:`${d}/howto/network_forwards/`,title:"Learn more about network forwards",children:"Create a network forward"}),contentClassName:"create-network",children:[o.jsx(b,{formik:t,network:r}),o.jsxs($,{children:[o.jsx(g,{className:"p-button--base",to:`/ui/project/${e}/network/${s}/forwards`,children:"Cancel"}),o.jsx(n.ActionButton,{loading:t.isSubmitting,disabled:!t.isValid||!t.values.listenAddress,onClick:()=>void t.submitForm(),children:"Create"})]})]})};export{G as default};
