function e(){const e=globalThis.location.hash,s=x.exec(e);return s?s[1]:"post"}function s(){const s=function(){const[s,t]=c.useState(()=>e());return c.useEffect(()=>{let o=s,a=!1;const n=()=>{const s=e();return s!==o&&(o=s,t(s),a=!1,!0)},i=()=>{n()||a&&setTimeout(()=>{a&&(n(),a=!1)},50)},p=()=>queueMicrotask(n),r=()=>queueMicrotask(n),l=e=>{const s=e.target.closest("a");s?.href?.includes("#/posts")&&s.href.includes("post_type=")&&(a=!0,requestAnimationFrame(i))};return globalThis.addEventListener("hashchange",p),globalThis.addEventListener("popstate",r),document.addEventListener("click",l,!0),()=>{globalThis.removeEventListener("hashchange",p),globalThis.removeEventListener("popstate",r),document.removeEventListener("click",l,!0),a=!1}},[s]),s}(),{postTypeDisplayLabel:p}=h({postType:s}),d=c.useMemo(()=>{const e=u(s)??p??f(s);return t(e)},[p,s]),x=c.useMemo(()=>"post"===s?"edit.php":`edit.php?post_type=${s}`,[s]),w=c.useMemo(()=>[o({wpHref:`#/wp/edit.php?post_type=${s}&wp-mode=1`,storageKey:x}),a({storageKey:x,fleekHash:"post"===s?"#/posts":`#/posts?post_type=${s}`,toastIdPrefix:"posts-multiview-fleek"})],[s,x]);return m.jsxs("div",{className:"flex h-full flex-col",children:[m.jsx(n,{title:`${d}${r(" (Multi-View Test)")}`,topLevelActions:m.jsxs(m.Fragment,{children:[m.jsx(i,{wpHref:`#/wp/edit.php?post_type=${s}&wp-mode=1`,defaultModeStorageKey:x,modeMenuItems:w,activeModeId:"grid"}),m.jsxs(v,{variant:"default",size:"sm",className:"gap-2",onClick:()=>{const e="post"===s?"#/wp/post-new.php":`#/wp/post-new.php?post_type=${s}`;globalThis.location.hash=e},children:[m.jsx(j,{name:"plus",className:"h-4 w-4"}),m.jsx("span",{className:"hidden sm:inline",children:r("Add New")}),m.jsx("span",{className:"sm:hidden",children:r("Add")})]})]})}),m.jsx("div",{className:"min-h-0 flex-1",children:m.jsx(g,{postType:s,availableViews:["grid"],defaultView:"grid",onPostDeleted:e=>{l("PostsMultiView","Post deleted",{postId:e})}})})]})}import{v as t,d as o,e as a,g as n,P as i,q as p}from"./app-components.OQnGA3jf.js";import{i as r,d as l,ad as d}from"./platform-core.tlhrBXt0.js";import{r as c,j as m}from"./vendor-react.DHNfi5sm.js";import{l as h,m as u,n as f,o as g}from"./domain-posts.D4WJHctN.js";import{B as v,f as j}from"./vendor-design-system.Cz5A3ECO.js";const x=/post_type=([^&]+)/,w=()=>m.jsx(p,{defaultPadding:!0,children:m.jsx(d,{children:m.jsx(s,{})})});export{w as component};
//# sourceMappingURL=index.BnesYEUL.js.map
