import { jsx, jsxs } from "react/jsx-runtime";
import { useMemo } from "react";
import { ArrowLeftOutlined } from "@ant-design/icons";
import { Typography } from "antd";
import { useNavigate } from "react-router-dom";
import { useRequest } from "../../api-client/index.mjs";
import { useCompile } from "../../schema-component/index.mjs";
import { useDocumentTitle } from "../document-title/index.mjs";
import { useStyles } from "./PageNavBar.style.mjs";
const { Title } = Typography;
const PageNavBar = (param)=>{
    let { uid } = param;
    var _data_data;
    const compile = useCompile();
    const navigate = useNavigate();
    const { data } = useRequest({
        url: "/uiSchemas:getJsonSchema/".concat(uid)
    });
    const currentTitle = null == data ? void 0 : null == (_data_data = data.data) ? void 0 : _data_data.title;
    const { styles } = useStyles();
    const { title: documentTitle } = useDocumentTitle();
    const title = useMemo(()=>compile(currentTitle || documentTitle), [
        currentTitle,
        documentTitle
    ]);
    const handleBack = ()=>{
        navigate(-1);
    };
    return /*#__PURE__*/ jsx("div", {
        className: styles['page-nav-bar'],
        children: /*#__PURE__*/ jsxs("div", {
            className: "nav-title",
            onClick: handleBack,
            children: [
                /*#__PURE__*/ jsx(ArrowLeftOutlined, {}),
                /*#__PURE__*/ jsx(Title, {
                    level: 4,
                    style: {
                        margin: 0
                    },
                    children: title
                })
            ]
        })
    });
};
export { PageNavBar };
