import{d as B,u as D,ap as w,O as p,e as C,r as $,g as e,o as g,f as x,w as c,k as s,aN as I,aO as N,aI as P,aJ as T,aG as A,h as E,az as k,a5 as _,t as J}from"./index.c3b9a55d.js";import{u as O}from"./useRouteParam.b592fab0.js";const z=B({__name:"BlockEdit",async setup(R){let t,n;const l=D(),u=O("blockDocumentId"),a=([t,n]=w(()=>k.getBlockDocument(u.value)),t=await t,n(),t),{blockType:i,blockSchema:f}=a,r=p(a.data),m=p(a.name);function b(d){k.updateBlockDocument(a.id,d).then(()=>{_("Block updated successfully","success"),l.push(J.block(u.value))}).catch(o=>{_("Failed to update block","error"),console.error(o)})}function h(){l.back()}return C(`Edit Block: ${m.value}`),(d,o)=>{const y=$("p-layout-default");return e(a)?(g(),x(y,{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":o[0]||(o[0]=v=>r.value=v)},{name:m.value,blockSchema:e(f)},T({submit:b,cancel:h})),null,16,["data"])]),_:1},8,["block-type"])]),_:1})):E("",!0)}}});export{z as default};
