import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
import * as __WEBPACK_EXTERNAL_MODULE__ant_design_icons__ from "@ant-design/icons";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_react_router_dom__ from "react-router-dom";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__style_index_mjs__ from "../../style/index.mjs";
const SettingsCenterDropdown = ()=>{
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useCompile)();
    const { token } = (0, __WEBPACK_EXTERNAL_MODULE__style_index_mjs__.useToken)();
    const app = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useApp)();
    const userSettings = app.userSettingsManager.getList();
    const settingItem = [];
    userSettings.filter((v)=>false !== v.isTopLevel).forEach((setting)=>{
        settingItem.push({
            key: 'userSetting:' + setting.name,
            icon: setting.icon,
            label: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_router_dom__.Link, {
                to: setting.path,
                children: compile(setting.title)
            })
        });
    });
    settingItem.push({
        type: 'divider'
    });
    const menuItems = (0, __WEBPACK_EXTERNAL_MODULE_react__.useMemo)(()=>{
        const list = app.systemSettingsManager.getList();
        function traverse(settings) {
            return settings.filter((item)=>!item.path.includes(':')).map((item)=>{
                var _item_children;
                item.title = compile(item.title);
                item.label = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_router_dom__.Link, {
                    to: item.path,
                    children: compile(item.title)
                });
                if (null === (_item_children = item.children) || void 0 === _item_children ? void 0 : _item_children.length) {
                    item.children = traverse(item.children);
                    item.label = compile(item.title);
                }
                return {
                    key: item.key,
                    label: item.label,
                    path: item.path,
                    children: item.children,
                    name: item.title
                };
            });
        }
        return traverse(list);
    }, [
        app.systemSettingsManager,
        compile
    ]);
    settingItem.push(...menuItems);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Dropdown, {
        menu: {
            style: {
                maxHeight: '70vh',
                overflow: 'auto'
            },
            items: settingItem
        },
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Button, {
            "data-testid": "plugin-settings-button",
            icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__ant_design_icons__.SettingOutlined, {
                style: {
                    color: token.colorTextHeaderMenu
                }
            })
        })
    });
};
export { SettingsCenterDropdown };
