import{d as T,g as x,ao as N,f as P,j as o,bK as m,c as r,k as u,a as n,l as w,i as A,o as k,m as D,n as p,cr as F,cs as M,ct as V,_ as j,cu as q,N as f,cv as H,bo as I}from"./index-CgvuCQfr.js";import{u as K}from"./usePageTitle-DVT0B9Gy.js";const X=T({__name:"BlocksCatalogCreate",setup(Q){const s=x(),t=A(),i=N("redirect"),b=P("blockTypeSlug"),y=o(()=>b.value?[b.value]:null),d=m(s.blockTypes.getBlockTypeBySlug,y),e=o(()=>d.response),v=o(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,v),l=o(()=>_.response);function h(a){s.blockDocuments.createBlockDocument(a).then(({id:c})=>g(c)).catch(c=>{f("Failed to create block","error"),console.error(c)})}function S(){t.back()}function g(a){if(f("Block created successfully","success"),i.value){const c=t.resolve(H(i.value));t.push(c);return}t.push(I.block(a))}const B=o(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return K(B),(a,c)=>{const C=w("p-layout-default");return e.value?(k(),r(C,{key:0,class:"blocks-catalog-create"},{header:u(()=>[D(p(F),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(M),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(V),j({key:l.value.id,"block-schema":l.value},q({submit:h,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{X as default};
//# sourceMappingURL=BlocksCatalogCreate-0Q4fAaI-.js.map
