import{d as C,g as P,al as F,W as x,f as o,bG as m,c as r,i as u,a as n,j as D,u as A,o as k,k as N,l as p,co as V,cp as W,cq as $,Y as j,cr as q,P as f,cs as w,bk as G}from"./index-BBlvj0M_.js";import{u as H}from"./usePageTitle-lBdMRcrQ.js";const Y=C({__name:"BlocksCatalogCreate",setup(I){const s=P(),t=A(),i=F("redirect"),b=x("blockTypeSlug"),y=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,y),e=o(()=>d.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})=>S(c)).catch(c=>{f("Failed to create block","error"),console.error(c)})}function g(){t.back()}function S(a){if(f("Block created successfully","success"),i.value){const c=t.resolve(w(i.value));t.push(c);return}t.push(G.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return H(B),(a,c)=>{const T=D("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[N(p(V),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(W),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p($),j({key:l.value.id,"block-schema":l.value},q({submit:_,cancel:g})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{Y as default};
//# sourceMappingURL=BlocksCatalogCreate-J88awIhN.js.map
