import{d as T,S as x,u as N,al as P,v as V,g as o,bH as m,h as A,c as r,a as u,o as n,i as p,m as k,cp as D,cq as F,Z as H,cr as J,k as q,cs as w,J as v,ct as z,bg as G}from"./index-CWv_Pcr2.js";import{u as L}from"./usePageTitle-DY9DP8zZ.js";const j=T({__name:"BlocksCatalogCreate",setup(R){const s=x(),t=N(),i=P("redirect"),b=V("blockTypeSlug"),y=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,y),e=o(()=>d.response),f=o(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,f),l=o(()=>h.response);function S(a){s.blockDocuments.createBlockDocument(a).then(({id:c})=>g(c)).catch(c=>{v("Failed to create block","error"),console.error(c)})}function _(){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(G.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return L(B),(a,c)=>{const C=A("p-layout-default");return e.value?(n(),r(C,{key:0,class:"blocks-catalog-create"},{header:p(()=>[q(k(w),{"block-type":e.value},null,8,["block-type"])]),default:p(()=>[e.value?(n(),r(k(D),{key:0,"block-type":e.value},{default:p(()=>[l.value?(n(),r(k(F),H({key:l.value.id,"block-schema":l.value},J({submit:S,cancel:_})),null,16,["block-schema"])):u("",!0)]),_:1},8,["block-type"])):u("",!0)]),_:1})):u("",!0)}}});export{j as default};
//# sourceMappingURL=BlocksCatalogCreate-CII5coul.js.map
