"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __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__, {
    useSchemaInitializerSubMenuContext: ()=>useSchemaInitializerSubMenuContext,
    SchemaInitializerSubMenuInternal: ()=>SchemaInitializerSubMenuInternal,
    SchemaInitializerMenu: ()=>SchemaInitializerMenu,
    SchemaInitializerSubMenu: ()=>SchemaInitializerSubMenu
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const schema_namespaceObject = require("@tachybase/schema");
const icons_namespaceObject = require("@ant-design/icons");
var icons_default = /*#__PURE__*/ __webpack_require__.n(icons_namespaceObject);
const external_antd_namespaceObject = require("antd");
const external_antd_style_namespaceObject = require("antd-style");
const index_js_namespaceObject = require("../../../schema-component/index.js");
const external_context_index_js_namespaceObject = require("../context/index.js");
const external_hooks_index_js_namespaceObject = require("../hooks/index.js");
const external_style_js_namespaceObject = require("./style.js");
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      box-shadow: none !important;\n      border-inline-end: 0 !important;\n      .ant-menu-sub {\n        max-height: 50vh !important;\n      }\n      .ant-menu-item {\n        margin-block: 0;\n      }\n      .ant-menu-root {\n        margin: 0 -",
        "px;\n        .ant-menu-submenu-title,\n        .ant-menu-item-only-child {\n          margin-inline: 0;\n          margin-block: 0;\n          width: 100%;\n        }\n      }\n      // associated issue https://github.com/ant-design/ant-design/issues/51361\n      .ant-menu-title-content {\n        display: inline;\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css, token } = param;
    return {
        menu: css(_templateObject(), token.margin)
    };
});
const SchemaInitializerSubMenuContext = /*#__PURE__*/ external_react_default().createContext({});
const SchemaInitializerMenuProvider = (props)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerSubMenuContext.Provider, {
        value: {
            isInMenu: true
        },
        children: props.children
    });
const useSchemaInitializerSubMenuContext = ()=>external_react_default().useContext(SchemaInitializerSubMenuContext);
const SchemaInitializerMenu = (props)=>{
    const { componentCls, hashId } = (0, external_style_js_namespaceObject.useSchemaInitializerStyles)();
    const { items, ...others } = props;
    const { token } = external_antd_namespaceObject.theme.useToken();
    const { styles } = useStyles();
    const itemsWithPopupClass = (0, external_react_namespaceObject.useMemo)(()=>items.map((item)=>({
                ...item,
                popupClassName: "".concat(hashId, " ").concat(componentCls, "-menu-sub")
            })), [
        componentCls,
        hashId,
        items
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerMenuProvider, {
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Menu, {
            selectable: false,
            expandIcon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.RightOutlined, {
                style: {
                    fontSize: token.fontSizeSM,
                    color: token.colorTextDescription
                }
            }),
            rootClassName: styles.menu,
            items: itemsWithPopupClass,
            ...others
        })
    });
};
const SchemaInitializerSubMenu = (props)=>{
    const { children, title, name = (0, schema_namespaceObject.uid)(), onOpenChange, icon, ...others } = props;
    const compile = (0, index_js_namespaceObject.useCompile)();
    const validChildren = null == children ? void 0 : children.filter((item)=>!item.useVisible || item.useVisible());
    const childrenItems = (0, external_hooks_index_js_namespaceObject.useSchemaInitializerMenuItems)(validChildren, name);
    const items = (0, external_react_namespaceObject.useMemo)(()=>[
            {
                ...others,
                key: name,
                label: compile(title),
                icon: 'string' == typeof icon ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_default(), {
                    type: icon
                }) : icon,
                children: childrenItems
            }
        ], [
        childrenItems,
        compile,
        icon,
        name,
        others,
        title
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerMenu, {
        onOpenChange: onOpenChange,
        items: items
    });
};
const SchemaInitializerSubMenuInternal = ()=>{
    const itemConfig = (0, external_context_index_js_namespaceObject.useSchemaInitializerItem)();
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SchemaInitializerSubMenu, {
        ...itemConfig
    });
};
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
});
