import { jsx, jsxs } from "react/jsx-runtime";
import { Card } from "antd";
import { useParams } from "react-router-dom";
import { AppNotFound } from "../index.mjs";
import { DataBlockProvider } from "../../data-source/index.mjs";
import { RecordContext_deprecated, RecordProvider } from "../../record-provider/index.mjs";
import { RemoteSchemaComponent } from "../../schema-component/index.mjs";
import { useStyles } from "./DynamicPage.style.mjs";
import { PageNavBar } from "./PageNavBar.mjs";
import { PathHandler } from "./utils.mjs";
const DynamicPage = ()=>{
    const { styles } = useStyles();
    const params = useParams();
    const pathParams = PathHandler.getInstance().parse(params['*'], params.name);
    if (!pathParams) return /*#__PURE__*/ jsx(RemoteSchemaComponent, {
        uid: params.name,
        onlyRenderProperties: true
    });
    if (!pathParams.sub || !pathParams.collection || !pathParams.filterByTk || !pathParams.schemaId) return /*#__PURE__*/ jsx(AppNotFound, {});
    return /*#__PURE__*/ jsx("div", {
        className: styles['dynamic-page'],
        children: /*#__PURE__*/ jsx(DataBlockProvider, {
            params: {
                filterByTk: pathParams.filterByTk
            },
            action: "get",
            collection: pathParams.collection,
            children: /*#__PURE__*/ jsx(RecordContext_deprecated.Provider, {
                value: {
                    id: pathParams.filterByTk
                },
                children: /*#__PURE__*/ jsxs(RecordProvider, {
                    record: {
                        id: pathParams.filterByTk
                    },
                    children: [
                        /*#__PURE__*/ jsx(PageNavBar, {
                            uid: pathParams.sub
                        }),
                        /*#__PURE__*/ jsx(Card, {
                            className: "page-content",
                            children: /*#__PURE__*/ jsx(RemoteSchemaComponent, {
                                uid: pathParams.sub,
                                onlyRenderProperties: true
                            })
                        })
                    ]
                })
            })
        })
    });
};
export { DynamicPage };
