import { jsx } from "react/jsx-runtime";
import { RecursionField, observer, useField, useFieldSchema } from "@tachybase/schema";
import { OpenMode, useActionContext } from "./index.mjs";
import { useIsMobile } from "../../../block-provider/index.mjs";
import { PageStyle } from "../../../built-in/page-style/PageStyle.provider.mjs";
import { usePageStyle } from "../../../built-in/page-style/usePageStyle.mjs";
import { ActionDrawer } from "./Action.Drawer.mjs";
import { ActionModal } from "./Action.Modal.mjs";
import { ActionPage } from "./Action.Page.mjs";
import { ActionSheet } from "./Action.Sheet.mjs";
const ActionContainer = observer((props)=>{
    const { openMode } = useActionContext();
    const isMobile = useIsMobile();
    const pageStyle = usePageStyle();
    if (openMode === OpenMode.DRAWER_MODE) return /*#__PURE__*/ jsx(ActionDrawer, {
        footerNodeName: 'Action.Container.Footer',
        ...props
    });
    if (openMode === OpenMode.MODAL) return /*#__PURE__*/ jsx(ActionModal, {
        footerNodeName: 'Action.Container.Footer',
        ...props
    });
    if (openMode === OpenMode.SHEET) return /*#__PURE__*/ jsx(ActionSheet, {
        footerNodeName: 'Action.Container.Footer',
        ...props
    });
    if (openMode === OpenMode.PAGE) return /*#__PURE__*/ jsx(ActionPage, {
        footerNodeName: 'Action.Container.Footer',
        ...props
    });
    if (!openMode || [
        OpenMode.DEFAULT,
        OpenMode.DRAWER
    ].includes(openMode)) {
        if (isMobile || pageStyle === PageStyle.TAB_STYLE) return /*#__PURE__*/ jsx(ActionPage, {
            footerNodeName: 'Action.Container.Footer',
            ...props
        });
        return /*#__PURE__*/ jsx(ActionDrawer, {
            footerNodeName: 'Action.Container.Footer',
            ...props
        });
    }
    return /*#__PURE__*/ jsx(ActionPage, {
        footerNodeName: 'Action.Container.Footer',
        ...props
    });
}, {
    displayName: 'ActionContainer'
});
ActionContainer.Footer = observer(()=>{
    const field = useField();
    const schema = useFieldSchema();
    return /*#__PURE__*/ jsx(RecursionField, {
        basePath: field.address,
        schema: schema,
        onlyRenderProperties: true
    });
}, {
    displayName: 'ActionContainer.Footer'
});
const Action_Container = ActionContainer;
export { ActionContainer, Action_Container as default };
