import{d as C,ao as w,j as c,u as e,c as u,w as n,m as p,r as x,ah as F,o as i,a as P,bt as A,bu as D,bv as L,F as N,a4 as V,bw as j}from"./index-4d9fe32c-718dc5d9.js";import{L as b}from"./prefect-design-a921a7c6.js";import{a as H,u as J,v as f}from"./vue-compositions-55710141.js";import{u as R}from"./usePageTitle-e8e2e29d.js";import"./index-558d177a.js";import{r as $}from"./routes-1bd54f1a.js";import"./meta-26546594.js";const Q=C({__name:"BlocksCatalogCreate",setup(q){const s=w(),a=F(),k=H("redirect"),m=J("blockTypeSlug"),d=c(()=>m.value?[m.value]:null),y=f(s.blockTypes.getBlockTypeBySlug,d),o=c(()=>y.response),h=c(()=>o.value?[o.value.id]:null),_=f(s.blockSchemas.getBlockSchemaForBlockType,h),l=c(()=>_.response);function v(r){s.blockDocuments.createBlockDocument(r).then(({id:t})=>g(t)).catch(t=>{b("Failed to create block","error"),console.error(t)})}function S(){a.back()}function g(r){if(b("Block created successfully","success"),k.value){const t=a.resolve(j(k.value));a.push(t);return}a.push($.block(r))}const B=c(()=>o.value?`Create ${o.value.name} Block`:"Create Block");return R(B),(r,t)=>{const T=x("p-layout-default");return e(o)?(i(),u(T,{key:0,class:"blocks-catalog-create"},{header:n(()=>[P(e(A),{"block-type":e(o)},null,8,["block-type"])]),default:n(()=>[e(o)?(i(),u(e(D),{key:0,"block-type":e(o)},{default:n(()=>[e(l)?(i(),u(e(L),N({key:e(l).id,"block-schema":e(l)},V({submit:v,cancel:S})),null,16,["block-schema"])):p("",!0)]),_:1},8,["block-type"])):p("",!0)]),_:1})):p("",!0)}}});export{Q as default};
