import{d as C,aE as x,am as A,W as D,e as o,bG as m,c as r,f as u,a as n,g as P,u as X,o as p,h as $,i as k,cz as z,cA as F,cB as N,X as V,cC as W,$ as y,cD as w,bl as E}from"./index-BOEdKJ1D.js";import{u as G}from"./usePageTitle-BkurcLK2.js";const Q=C({__name:"BlocksCatalogCreate",setup(H){const s=x(),a=X(),i=A("redirect"),b=D("blockTypeSlug"),f=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,f),e=o(()=>d.response),v=o(()=>e.value?[e.value.id]:null),h=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>h.response);function _(t){s.blockDocuments.createBlockDocument(t).then(({id:c})=>g(c)).catch(c=>{y("Failed to create block","error"),console.error(c)})}function S(){a.back()}function g(t){if(y("Block created successfully","success"),i.value){const c=a.resolve(w(i.value));a.push(c);return}a.push(E.block(t))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return G(B),(t,c)=>{const T=P("p-layout-default");return e.value?(p(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[$(k(z),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(p(),r(k(F),{key:0,"block-type":e.value},{default:u(()=>[l.value?(p(),r(k(N),V({key:l.value.id,"block-schema":l.value},W({submit:_,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{Q as default};
//# sourceMappingURL=BlocksCatalogCreate-BQgLd90m.js.map
