import{d as B,ao as D,b as C,i as k,u as e,c as w,w as c,m as x,r as g,ah as A,o as E,a as s,bz as F,bA as I,F as L,a4 as N,bu as P}from"./index-4d9fe32c-718dc5d9.js";import{L as i}from"./prefect-design-a921a7c6.js";import{u as S}from"./vue-compositions-55710141.js";import{u as T}from"./usePageTitle-e8e2e29d.js";import{r as V}from"./routes-1bd54f1a.js";const j=B({__name:"BlockEdit",async setup(z){let t,l;const n=D(),u=A(),r=S("blockDocumentId"),o=([t,l]=C(()=>n.blockDocuments.getBlockDocument(r.value)),t=await t,l(),t),{blockType:b,blockSchema:f}=o,m=k(o.data),d=k(o.name);function _(p){n.blockDocuments.updateBlockDocument(o.id,p).then(()=>{i("Block updated successfully","success"),u.push(V.block(r.value))}).catch(a=>{i("Failed to update block","error"),console.error(a)})}function h(){u.back()}return T(`Edit Block: ${d.value}`),(p,a)=>{const y=g("p-layout-default");return e(o)?(E(),w(y,{key:0,class:"block-edit"},{header:c(()=>[s(e(F),{"block-document":e(o)},null,8,["block-document"])]),default:c(()=>[s(e(P),{"block-type":e(b)},{default:c(()=>[s(e(I),L({data:m.value,"onUpdate:data":a[0]||(a[0]=v=>m.value=v)},{name:d.value,blockSchema:e(f)},N({submit:_,cancel:h})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):x("",!0)}}});export{j as default};
