"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__, {
    PinnedPluginListProvider: ()=>PinnedPluginListProvider,
    PinnedPluginList: ()=>PinnedPluginList
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_style_namespaceObject = require("antd-style");
const external_lodash_namespaceObject = require("lodash");
const index_js_namespaceObject = require("../acl/index.js");
const external_context_js_namespaceObject = require("./context.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      display: inline-block;\n      .ant-btn {\n        border: 0;\n        height: var(--tb-header-height);\n        width: 46px;\n        border-radius: 0;\n        background: none;\n        color: rgba(255, 255, 255, 0.65);\n        &:hover {\n          background: rgba(255, 255, 255, 0.1) !important;\n        }\n      }\n      .ant-float-btn {\n        margin-bottom: 16px;\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const PinnedPluginListProvider = (props)=>{
    const { children, items } = props;
    const ctx = (0, external_react_namespaceObject.useContext)(external_context_js_namespaceObject.PinnedPluginListContext);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_context_js_namespaceObject.PinnedPluginListContext.Provider, {
        value: {
            items: {
                ...ctx.items,
                ...items
            }
        },
        children: children
    });
};
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        container: css(_templateObject())
    };
});
const PinnedPluginList = (param)=>{
    let { belongToFilter } = param;
    const { allowAll, snippets } = (0, index_js_namespaceObject.useACLRoleContext)();
    const getSnippetsAllow = function(aclKey) {
        let isPublic = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
        return allowAll || isPublic || (null == snippets ? void 0 : snippets.includes(aclKey));
    };
    const { styles } = useStyles(belongToFilter);
    const ctx = (0, external_react_namespaceObject.useContext)(external_context_js_namespaceObject.PinnedPluginListContext);
    const { components } = (0, external_react_namespaceObject.useContext)(schema_namespaceObject.SchemaOptionsContext);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        className: styles.container,
        children: Object.keys(ctx.items).filter((key)=>ctx.items[key].belongTo === belongToFilter).sort((a, b)=>ctx.items[a].order - ctx.items[b].order).filter((key)=>getSnippetsAllow(ctx.items[key].snippet, ctx.items[key].isPublic)).map((key)=>{
            const Action = (0, external_lodash_namespaceObject.get)(components, ctx.items[key].component);
            return Action ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Action, {}, key) : null;
        })
    });
};
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
});
