"use client";
'use strict';

const jsxRuntime = require('react/jsx-runtime');
const context = require('@btst/stack/context');
const postForms = require('../forms/post-forms.cjs');
const pageHeader = require('../shared/page-header.cjs');
const pageWrapper = require('../shared/page-wrapper.cjs');
const index = require('../../localization/index.cjs');
const useRouteLifecycle = require('../../../../../../../ui/src/hooks/use-route-lifecycle.cjs');

function EditPostPage({ slug }) {
  const overrides = context.usePluginOverrides("blog", {
    localization: index.BLOG_LOCALIZATION
  });
  const { localization, navigate } = overrides;
  const basePath = context.useBasePath();
  useRouteLifecycle.useRouteLifecycle({
    routeName: "editPost",
    context: {
      path: `/blog/${slug}/edit`,
      params: { slug },
      isSSR: typeof window === "undefined"
    },
    overrides,
    beforeRenderHook: (overrides2, context) => {
      if (overrides2.onBeforeEditPostPageRendered) {
        return overrides2.onBeforeEditPostPageRendered(slug, context);
      }
      return true;
    }
  });
  const handleClose = () => {
    navigate(`${basePath}/blog`);
  };
  const handleSuccess = (post) => {
    navigate(`${basePath}/blog/${post.slug}`);
  };
  const handleDelete = () => {
    navigate(`${basePath}/blog`);
  };
  return /* @__PURE__ */ jsxRuntime.jsxs(pageWrapper.PageWrapper, { className: "gap-6", testId: "edit-post-page", children: [
    /* @__PURE__ */ jsxRuntime.jsx(
      pageHeader.PageHeader,
      {
        title: localization.BLOG_POST_EDIT_TITLE,
        description: localization.BLOG_POST_EDIT_DESCRIPTION
      }
    ),
    /* @__PURE__ */ jsxRuntime.jsx(
      postForms.EditPostForm,
      {
        postSlug: slug,
        onClose: handleClose,
        onSuccess: handleSuccess,
        onDelete: handleDelete
      }
    )
  ] });
}

exports.EditPostPage = EditPostPage;
