import{b9 as g,u as C,bg as N,aC as S,aD as v,ar as w,r as y,q as D,j as e,$ as s,gQ as E,b as K,b2 as $,aN as q,ap as l,C as i,aO as I,b3 as z,f as B,b1 as m,au as L,aE as O}from"./index-46ma1THH.js";import{i as P}from"./index-DIN48ET6.js";const V=w().shape({subjectName:O.required().label("Kafka name"),schema:L().required().label("Schema")}),F=()=>{const o=g(),{id:d}=C(),{state:a={}}=N(),{register:x,control:u,formState:{errors:b},handleSubmit:h}=S({resolver:v(V),defaultValues:{subjectName:(a==null?void 0:a.subjectName)??"",schema:"[]"}}),[j,{isLoading:f,isError:p,error:r}]=P(),c=y.useCallback(()=>o(D.project.settings.kafka.view),[o]),k=async({subjectName:t,schema:n})=>{await j({id:d,subjectName:t,data:{schema:n}}).unwrap(),c()};return e.jsxs(s,{flexDirection:"column",children:[e.jsx(E,{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($,{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"),...q("subjectName",b)}),e.jsx(s,{mb:"20px",children:e.jsx(I,{name:"schema",control:u,render:({field:{value:t,onChange:n}})=>e.jsx(z,{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(B,{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:h(k),children:"Create Schema"})]})]})})]})};export{F as default};
