"use client";
import { jsx } from 'react/jsx-runtime';
import { lazy } from 'react';
import { usePluginOverrides } from '@btst/stack/context';
import { ComposedRoute } from '@btst/stack/client/components';
import { DefaultError } from '../shared/default-error.mjs';
import { PostsLoading } from '../loading/index.mjs';
import { NotFoundPage } from './404-page.mjs';

const HomePage = lazy(
  () => import('./home-page.internal.mjs').then((m) => ({ default: m.HomePage }))
);
function HomePageComponent({
  published = true
}) {
  const { onRouteError } = usePluginOverrides("blog");
  return /* @__PURE__ */ jsx(
    ComposedRoute,
    {
      path: published ? "/blog" : "/blog/drafts",
      PageComponent: HomePage,
      ErrorComponent: DefaultError,
      LoadingComponent: PostsLoading,
      NotFoundComponent: NotFoundPage,
      props: { published },
      onError: (error) => {
        if (onRouteError) {
          onRouteError("posts", error, {
            path: published ? "/blog" : "/blog/drafts",
            isSSR: typeof window === "undefined",
            published
          });
        }
      }
    }
  );
}

export { HomePageComponent };
