import{r as C,j as a}from"./vendor-react-wBh_31cN.js";import{r as N,G as l,ar as k,as as v,bo as g}from"./index-dNe6i2rS.js";import{u as S,C as B}from"./index.esm-CAGtek53.js";import{o as q}from"./yup-XkUC3UEH.js";import{B as w}from"./back-button-CQo-pvZ0.js";import{C as y,a as I,b as K,c as L}from"./card-BeQtvmcJ.js";import{C as V}from"./code-input-W_9wcAaJ.js";import{I as z}from"./input-DFI7JniT.js";import{L as E}from"./label-gPWmc6ow.js";import{V as H}from"./value-7N0Keti9.js";import{u as P}from"./useProjectNavigate-BM67yKhl.js";import{h as T}from"./index-DoDc9bBo.js";import{g as $}from"./getInputValidation-B3ahFDSx.js";import{c as A,a as F}from"./vendor-router-D1GqFWiT.js";import{Q as G}from"./vendor-icons-BUUmD6ht.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-utils-OeoE2qq_.js";import"./vendor-radix-BRyWS4bQ.js";import"./vendor-grid-CeFlDWv4.js";const M=k().shape({subjectName:g.required().label("Kafka name"),schema:v().required().label("Schema")}),ia=()=>{var c,i;const o=P(),{id:n}=A(),{state:e={}}=F(),{register:d,control:u,formState:{errors:f},handleSubmit:p}=S({resolver:q(M),defaultValues:{subjectName:(e==null?void 0:e.subjectName)??"",schema:"[]"}}),[h,{isLoading:j,isError:x,error:s}]=T(),r=C.useCallback(()=>o(N.project.settings.kafka.view),[o]),b=async({subjectName:t,schema:m})=>{await h({id:n,subjectName:t,data:{schema:m}}).unwrap(),r()};return a.jsxs("div",{className:"flex flex-col",children:[a.jsx(w,{className:"mr-auto",onClick:r,children:"back to all Kafka Topics"}),a.jsxs(y,{className:"my-5",children:[a.jsx(I,{children:a.jsx(K,{children:"Create a new Kafka schema"})}),a.jsx(L,{children:a.jsxs("div",{className:"flex flex-col gap-5",children:[a.jsxs("div",{children:[a.jsx(E,{className:"mb-1.5",children:"Name"}),a.jsx(z,{placeholder:"kafka schema name",disabled:!!(e!=null&&e.subjectName),...d("subjectName"),...$("subjectName",f)})]}),a.jsx("div",{className:"mb-5",children:a.jsx(B,{name:"schema",control:u,render:({field:{value:t,onChange:m}})=>a.jsx(V,{height:"300px",mode:"json",label:"avro schema",value:t,readOnly:!1,onChange:m})})}),x&&a.jsxs("div",{className:"-mt-2.5 flex items-center text-quartz-label-red",children:[a.jsx(G,{className:"mr-1.5 size-4"}),a.jsx(H,{className:"text-quartz-label-red",children:(i=(c=s==null?void 0:s.response)==null?void 0:c.data)==null?void 0:i.message})]}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(l,{variant:"outline",onClick:r,children:"Back"}),a.jsx(l,{disabled:j,onClick:p(b),children:"Create Schema"})]})]})})]})]})};export{ia as default};
