import{d as C,M as x,_ as A,I as w,U as I,h as c,aA as m,k as N,c as r,l as u,a as n,o as k,n as P,u as p,bv as D,bw as F,bx as M,by as U,bz as V,b2 as y,bA as W,af as $}from"./index-gULJbqdd.js";import{u as j}from"./usePageTitle-HrbxxOEb.js";const R=C({__name:"BlocksCatalogCreate",setup(z){const s=x(),a=A(),b=w("redirect"),i=I("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})=>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"),b.value){const o=a.resolve(W(b.value));a.push(o);return}a.push($.block(t))}const B=c(()=>e.value?`Create ${e.value.name} Block`:"Create Block");return j(B),(t,o)=>{const T=N("p-layout-default");return e.value?(k(),r(T,{key:0,class:"blocks-catalog-create"},{header:u(()=>[P(p(D),{"block-type":e.value},null,8,["block-type"])]),default:u(()=>[e.value?(k(),r(p(F),{key:0,"block-type":e.value},{default:u(()=>[l.value?(k(),r(p(M),U({key:l.value.id,"block-schema":l.value},V({submit:h,cancel:S})),null,16,["block-schema"])):n("",!0)]),_:1},8,["block-type"])):n("",!0)]),_:1})):n("",!0)}}});export{R as default};
