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