"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    SettingsCenterDropdown: ()=>SettingsCenterDropdown
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const icons_namespaceObject = require("@ant-design/icons");
const external_antd_namespaceObject = require("antd");
const external_react_router_dom_namespaceObject = require("react-router-dom");
const index_js_namespaceObject = require("../../application/index.js");
const external_schema_component_index_js_namespaceObject = require("../../schema-component/index.js");
const external_style_index_js_namespaceObject = require("../../style/index.js");
const SettingsCenterDropdown = ()=>{
    const compile = (0, external_schema_component_index_js_namespaceObject.useCompile)();
    const { token } = (0, external_style_index_js_namespaceObject.useToken)();
    const app = (0, index_js_namespaceObject.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, jsx_runtime_namespaceObject.jsx)(external_react_router_dom_namespaceObject.Link, {
                to: setting.path,
                children: compile(setting.title)
            })
        });
    });
    settingItem.push({
        type: 'divider'
    });
    const menuItems = (0, external_react_namespaceObject.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, jsx_runtime_namespaceObject.jsx)(external_react_router_dom_namespaceObject.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, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Dropdown, {
        menu: {
            style: {
                maxHeight: '70vh',
                overflow: 'auto'
            },
            items: settingItem
        },
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Button, {
            "data-testid": "plugin-settings-button",
            icon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.SettingOutlined, {
                style: {
                    color: token.colorTextHeaderMenu
                }
            })
        })
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
