import{d as C,v as w,B as x,aI as F,E as N,c,ag as m,a as P,e as r,w as u,i as n,o as p,m as A,g as k,b6 as D,b7 as E,b8 as V,b9 as Z,ba as H,aF as d,bb as I,Z as K}from"./index-a91efef8.js";import{u as M}from"./usePageTitle-6b86fe3b.js";const q=C({__name:"BlocksCatalogCreate",setup(R){const s=w(),a=x(),b=F("redirect"),i=N("blockTypeSlug"),f=c(()=>i.value?[i.value]:null),v=m(s.blockTypes.getBlockTypeBySlug,f),e=c(()=>v.response),y=c(()=>e.value?[e.value.id]:null),_=m(s.blockSchemas.getBlockSchemaForBlockType,y),l=c(()=>_.response);function h(t){s.blockDocuments.createBlockDocument(t).then(({id:o})=>S(o)).catch(o=>{d("Failed to create block","error"),console.error(o)})}function g(){a.back()}function S(t){if(d("Block created successfully","success"),b.value){const o=a.resolve(I(b.value));a.push(o);return}a.push(K.block(t))}const B=c(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return M(B),(t,o)=>{const T=P("p-layout-default");return e.value?(p(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[A(k(D),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(p(),r(k(E),{key:0,"block-type":e.value},{default:u(()=>[l.value?(p(),r(k(V),Z({key:l.value.id,"block-schema":l.value},H({submit:h,cancel:g})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{q as default};
