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