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