import{d as C,a as x,T as F,R as P,M as R,c,av as m,b as w,e as r,w as u,f as n,o as p,h as A,u as b,bm as D,bn as M,bo as N,bp as V,bq as q,aW as f,br as H,ab as J}from"./index-562c8470.js";import{u as Q}from"./usePageTitle-ad3dbf10.js";const z=C({__name:"BlocksCatalogCreate",setup(W){const s=x(),a=F(),k=P("redirect"),i=R("blockTypeSlug"),v=c(()=>i.value?[i.value]:null),y=m(s.blockTypes.getBlockTypeBySlug,v),e=c(()=>y.response),d=c(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,d),l=c(()=>_.response);function h(t){s.blockDocuments.createBlockDocument(t).then(({id:o})=>g(o)).catch(o=>{f("Failed to create block","error"),console.error(o)})}function S(){a.back()}function g(t){if(f("Block created successfully","success"),k.value){const o=a.resolve(H(k.value));a.push(o);return}a.push(J.block(t))}const B=c(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return Q(B),(t,o)=>{const T=w("p-layout-default");return e.value?(p(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[A(b(D),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(p(),r(b(M),{key:0,"block-type":e.value},{default:u(()=>[l.value?(p(),r(b(N),V({key:l.value.id,"block-schema":l.value},q({submit:h,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{z as default};
