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