import{d as T,h as F,u as x,al as P,W as w,j as o,bF as m,k as A,c as r,a as u,o as n,l as p,p as k,cn as D,co as N,_ as O,cp as V,m as W,cq as j,K as y,cr as q,be as H}from"./index-C_HOOOpe.js";import{u as I}from"./usePageTitle-DzYzWO1v.js";const X=T({__name:"BlocksCatalogCreate",setup(K){const s=F(),t=x(),i=P("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(q(i.value));t.push(c);return}t.push(H.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return I(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(j),{"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(N),O({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{X as default};
//# sourceMappingURL=BlocksCatalogCreate-DacQIAUh.js.map
