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