const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./vendor-design-system.DjS4_282.css","./vendor-grid-core.BImjir2J.css","./platform-core.Bem9LYx-.css"])))=>i.map(i=>d[i]);
function t(){const t=h({strict:!1}).id,{state:s}=u(),c=s.config?.path,x=v(c),j=()=>{const t=globalThis.location.hash,e=new URLSearchParams(t.split("?")[1]||"").get("fleek-window");if(e){const t=v(e);if(t)return t}return null},N=()=>{const t=globalThis.location.hash,e=y.exec(t);if(e?.[1])return e[1];const s=g.exec(t);return s?.[1]??null},k=t||x||j()||N();a("MAIN","PostEditPage extracted ID",{routeId:t,modalPathId:x,modalPath:c,modalId:j(),hashId:N(),currentHash:globalThis.location.hash});const[w,I]=m.useState(null),[T,C]=m.useState(!0),[P,E]=m.useState(null);return m.useEffect(()=>{(async()=>{if(!k)return E("No post ID provided"),void C(!1);try{C(!0),E(null);const{apiClient:t}=await e(async()=>{const{apiClient:t}=await import("./platform-core.tlhrBXt0.js").then(t=>t.bk);return{apiClient:t}},__vite__mapDeps([0,1,2]),import.meta.url),s=(await t.get(`/wp-json/fleekdash/v1/posts/${k}`)).data;let a;a=s&&"object"==typeof s&&"success"in s&&!0===s.success&&"data"in s?s.data:s,I(a)}catch(t){r("API","Error fetching post data",t);const e=t instanceof Error?t.message:o("Failed to load post data");E(e),n(t instanceof Error?t.message:o("Failed to load post data"),{id:`post-edit-load-error-${k}`,translate:!1})}finally{C(!1)}})()},[k]),T?p.jsx("div",{className:"flex h-64 items-center justify-center",children:p.jsx(f.Centered,{text:o("Loading post...")})}):P||!k?p.jsx("div",{className:"flex h-64 items-center justify-center",children:p.jsxs("div",{className:"text-center",children:[p.jsx("p",{className:"text-destructive mb-4",children:P||o("No post ID provided")}),p.jsx("button",{onClick:()=>globalThis.history.back(),className:"bg-primary text-primary-foreground rounded-md px-4 py-2",children:o("Go Back")})]})}):w?p.jsxs("div",{className:"mx-auto max-w-4xl",children:[p.jsx("div",{className:"mb-6",children:p.jsxs("h1",{className:"text-2xl font-bold",children:[" ",b(w.title)]})}),p.jsx(d,{post:w,postType:"post",onSuccess:t=>{i(l("post",t),{id:`post-edit-save-success-${t.id}`}),globalThis.history.back()},onCancel:()=>{globalThis.history.back()}})]}):p.jsx("div",{className:"flex h-64 items-center justify-center",children:p.jsxs("div",{className:"text-center",children:[p.jsx("p",{className:"text-muted-foreground mb-4",children:o("Post not found")}),p.jsx("button",{onClick:()=>globalThis.history.back(),className:"bg-primary text-primary-foreground rounded-md px-4 py-2",children:o("Go Back")})]})})}import{_ as e,q as s}from"./app-components.OQnGA3jf.js";import{d as a,i as o,l as r,c as n,e as i,ad as c}from"./platform-core.tlhrBXt0.js";import{O as d,Q as l}from"./domain-posts.D4WJHctN.js";import{r as m,j as p}from"./vendor-react.DHNfi5sm.js";import{o as h}from"./vendor-tanstack.B8CEPVlN.js";import{u}from"./window-core.CeoFlrKP.js";import{k as f}from"./vendor-design-system.Cz5A3ECO.js";import{R as x}from"./main.B9BFFe6b.js";const j=/\/?post-edit\/(\d+)/,y=/^#\/post-edit\/(\d+)/,g=/post-edit\/(\d+)/,b=t=>{if("string"==typeof t)return t;if(t&&"object"==typeof t&&"rendered"in t){const e=t,s="string"==typeof e.rendered?e.rendered:void 0,a="string"==typeof e.raw?e.raw:void 0;return s??a??o("Untitled")}return o("Untitled")},v=t=>{if(!t)return null;const e=j.exec(t);return e?.[1]??null},N=()=>p.jsx(s,{className:x,children:p.jsx(c,{children:p.jsx(t,{})})});export{N as component};
//# sourceMappingURL=post-edit._id.CzXcvGS-.js.map
