import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { GithubFilled, HomeFilled, InfoCircleFilled, QuestionCircleFilled } from "@ant-design/icons";
import { PageContainer, ProConfigProvider, ProLayout } from "@ant-design/pro-components";
import { Button, Dropdown } from "antd";
import { useLocation, useNavigate } from "react-router";
import { useApp } from "../../index.mjs";
import { SettingsMenu, useCurrentUserContext } from "../../user/index.mjs";
import { NoticeArea } from "../admin-layout/index.mjs";
import { AdminProvider } from "../admin-layout/AdminProvider.mjs";
import { useSystemSettings } from "../system-settings/index.mjs";
import { useStyles } from "./style.mjs";
const SettingLayout = (param)=>{
    let { selectedKeys, onClick, route, children, fullscreen } = param;
    var _result_data_data, _result_data, _result_data_data_logo, _result_data_data1, _result_data1, _data_data, _data_data1, _data_data2;
    const settings = {
        fixSiderbar: true,
        layout: 'mix',
        splitMenus: false,
        navTheme: 'light',
        contentWidth: 'Fluid',
        fixedHeader: true,
        siderMenuType: 'sub'
    };
    const app = useApp();
    const location = useLocation();
    const navigate = useNavigate();
    const { data } = useCurrentUserContext();
    const result = useSystemSettings();
    const { styles } = useStyles();
    const redirectToUserHome = ()=>{
        if (app.adminUrl.startsWith('/')) navigate(app.adminUrl);
        else window.location.href = app.adminUrl;
    };
    return /*#__PURE__*/ jsx(AdminProvider, {
        children: /*#__PURE__*/ jsx(ProConfigProvider, {
            hashed: false,
            children: /*#__PURE__*/ jsx(ProLayout, {
                className: styles.settingLayout,
                title: null == result ? void 0 : null == (_result_data = result.data) ? void 0 : null == (_result_data_data = _result_data.data) ? void 0 : _result_data_data.title,
                logo: /*#__PURE__*/ jsx("img", {
                    src: null == result ? void 0 : null == (_result_data1 = result.data) ? void 0 : null == (_result_data_data1 = _result_data1.data) ? void 0 : null == (_result_data_data_logo = _result_data_data1.logo) ? void 0 : _result_data_data_logo.url
                }),
                onMenuHeaderClick: redirectToUserHome,
                bgLayoutImgList: [
                    {
                        src: 'https://img.alicdn.com/imgextra/i2/O1CN01O4etvp1DvpFLKfuWq_!!6000000000279-2-tps-609-606.png',
                        left: 85,
                        bottom: 100,
                        height: '303px'
                    },
                    {
                        src: 'https://img.alicdn.com/imgextra/i2/O1CN01O4etvp1DvpFLKfuWq_!!6000000000279-2-tps-609-606.png',
                        bottom: -68,
                        right: -45,
                        height: '303px'
                    },
                    {
                        src: 'https://img.alicdn.com/imgextra/i3/O1CN018NxReL1shX85Yz6Cx_!!6000000005798-2-tps-884-496.png',
                        bottom: 0,
                        left: 0,
                        width: '331px'
                    }
                ],
                route: route,
                token: {
                    header: {
                        colorBgMenuItemSelected: 'rgba(0,0,0,0.04)'
                    }
                },
                location: location,
                siderMenuType: "group",
                menuProps: {
                    onClick,
                    selectedKeys
                },
                menu: {
                    collapsedShowGroupTitle: true
                },
                avatarProps: {
                    src: 'https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg',
                    size: 'small',
                    title: (null == data ? void 0 : null == (_data_data = data.data) ? void 0 : _data_data.nickname) || (null == data ? void 0 : null == (_data_data1 = data.data) ? void 0 : _data_data1.username) || (null == data ? void 0 : null == (_data_data2 = data.data) ? void 0 : _data_data2.email),
                    render: (props, dom)=>/*#__PURE__*/ jsx(Dropdown, {
                            dropdownRender: ()=>/*#__PURE__*/ jsx(SettingsMenu, {}),
                            children: dom
                        })
                },
                actionsRender: (props)=>{
                    if (props.isMobile) return [];
                    if ('undefined' == typeof window) return [];
                    return [
                        /*#__PURE__*/ jsx(Button, {
                            type: "text",
                            onClick: ()=>{
                                navigate('/admin');
                            },
                            icon: /*#__PURE__*/ jsx(HomeFilled, {}, "HomeFilled")
                        }),
                        /*#__PURE__*/ jsx(Button, {
                            type: "text",
                            target: "_blank",
                            href: "https://tachybase.org",
                            icon: /*#__PURE__*/ jsx(InfoCircleFilled, {}, "InfoCircleFilled")
                        }),
                        /*#__PURE__*/ jsx(Button, {
                            type: "text",
                            target: "_blank",
                            href: "https://github.com/tachybase/tachybase/issues",
                            icon: /*#__PURE__*/ jsx(QuestionCircleFilled, {}, "QuestionCircleFilled")
                        }),
                        /*#__PURE__*/ jsx(Button, {
                            type: "text",
                            target: "_blank",
                            href: "https://github.com/tachybase/tachybase",
                            icon: /*#__PURE__*/ jsx(GithubFilled, {}, "GithubFilled")
                        })
                    ];
                },
                pageTitleRender: false,
                headerTitleRender: (logo, title, _)=>{
                    const defaultDom = /*#__PURE__*/ jsxs(Fragment, {
                        children: [
                            logo,
                            title
                        ]
                    });
                    if ('undefined' == typeof window) return defaultDom;
                    if (document.body.clientWidth < 1400) return defaultDom;
                    if (_.isMobile) return defaultDom;
                    return /*#__PURE__*/ jsx(Fragment, {
                        children: defaultDom
                    });
                },
                ...settings,
                headerContentRender: ()=>/*#__PURE__*/ jsx(NoticeArea, {}),
                contentStyle: {
                    padding: 0
                },
                children: fullscreen ? children : /*#__PURE__*/ jsx(PageContainer, {
                    children: children
                })
            })
        })
    });
};
export { SettingLayout };
