import{ba as g,u as C,bp as N,aA as S,aB as v,r as w,x as y,j as e,q as s,gS as q,f as K,aH as B,aY as D,ao as l,v as i,aZ as E,aI as I,d as P,aJ as m,Z as V,as as Z,dt as $}from"./index-C6OVXshM.js";import{h as z}from"./index-KEKA6gJs.js";const A=V().shape({subjectName:$.required().label("Kafka name"),schema:Z().required().label("Schema")}),M=()=>{const o=g(),{id:d}=C(),{state:a={}}=N(),{register:x,control:h,formState:{errors:u},handleSubmit:j}=S({resolver:v(A),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[b,{isLoading:f,isError:p,error:r}]=z(),c=w.useCallback(()=>o(y.project.settings.kafka.view),[o]),k=async({subjectName:t,schema:n})=>{await b({id:d,subjectName:t,data:{schema:n}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(q,{mr:"auto",mode:"highlight",onClick:c,children:"<- back to all Kafka Topics"}),e.jsx(K,{my:"20px",title:"Create a new Kafka schema",children:e.jsxs(s,{flexDirection:"column",sx:{gap:"20px"},children:[e.jsx(B,{label:"Name",placeholder:"kafka schema name",disabled:!!(a!=null&&a.subjectName),labelAction:e.jsx(l,{size:"xs",ml:"8px",icon:i.info_block}),...x("subjectName"),...D("subjectName",u)}),e.jsx(s,{mb:"20px",children:e.jsx(E,{name:"schema",control:h,render:({field:{value:t,onChange:n}})=>e.jsx(I,{height:"300px",mode:"json",label:"avro schema",value:t,readOnly:!1,onChange:n})})}),p&&e.jsxs(s,{mt:"-10px",flexDirection:"row",alignItems:"center",children:[e.jsx(l,{mr:"5px",size:"sm",color:"labels.red",icon:i.error}),e.jsx(P,{color:"labels.red",children:r==null?void 0:r.response.data.message})]}),e.jsxs(s,{justifyContent:"flex-end",children:[e.jsx(m,{mr:"8px",intent:"secondary",onClick:c,children:"Back"}),e.jsx(m,{disabled:f,onClick:j(k),children:"Create Schema"})]})]})})]})};export{M as default};
