import{d as C,v as x,ao as D,W as P,e as o,bK as m,c as r,g as u,a as n,h as w,u as A,o as k,j as F,k as p,cs as N,ct as V,cu as W,_ as X,cv as j,L as v,cw as z,bo as H}from"./index-Bp1Bhxow.js";import{u as I}from"./usePageTitle-CccNdtFw.js";const Z=C({__name:"BlocksCatalogCreate",setup(K){const s=x(),t=A(),i=D("redirect"),b=P("blockTypeSlug"),d=o(()=>b.value?[b.value]:null),y=m(s.blockTypes.getBlockTypeBySlug,d),e=o(()=>y.response),f=o(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,f),l=o(()=>h.response);function _(a){s.blockDocuments.createBlockDocument(a).then(({id:c})=>g(c)).catch(c=>{v("Failed to create block","error"),console.error(c)})}function S(){t.back()}function g(a){if(v("Block created successfully","success"),i.value){const c=t.resolve(z(i.value));t.push(c);return}t.push(H.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return I(B),(a,c)=>{const T=w("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[F(p(N),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(V),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(W),X({key:l.value.id,"block-schema":l.value},j({submit:_,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{Z as default};
//# sourceMappingURL=BlocksCatalogCreate-CnCKbYse.js.map
