import{d as B,u as D,ao as w,O as k,e as C,r as g,g as e,o as x,f as $,w as c,k as s,aM as I,aN as N,aH as P,aI as T,aF as A,h as E,ay as p,a4 as _,t as F}from"./index.647f6a83.js";import{u as H}from"./useRouteParam.58df0b75.js";const q=B({__name:"BlockEdit",async setup(R){let o,n;const l=D(),u=H("blockDocumentId"),a=([o,n]=w(()=>p.getBlockDocument(u.value)),o=await o,n(),o),{blockType:i,blockSchema:f}=a,r=k(a.data),m=k(a.name);function b(d){p.updateBlockDocument(a.id,d).then(()=>{_("Block updated successfully","success"),l.push(F.block(u.value))}).catch(t=>{_("Failed to update block","error"),console.error(t)})}function y(){l.back()}return C(`Edit Block: ${m.value}`),(d,t)=>{const h=g("p-layout-default");return e(a)?(x(),$(h,{key:0,class:"block-edit"},{header:c(()=>[s(e(I),{"block-document":e(a)},null,8,["block-document"])]),default:c(()=>[s(e(A),{"block-type":e(i)},{default:c(()=>[s(e(N),P({data:r.value,"onUpdate:data":t[0]||(t[0]=v=>r.value=v)},{name:m.value,blockSchema:e(f)},T({submit:b,cancel:y})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):E("",!0)}}});export{q as default};
