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