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__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd_style__ from "antd-style";
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
import * as __WEBPACK_EXTERNAL_MODULE__acl_index_mjs__ from "../acl/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__context_mjs__ from "./context.mjs";
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    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const PinnedPluginListProvider = (props)=>{
    const { children, items } = props;
    const ctx = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__context_mjs__.PinnedPluginListContext);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__context_mjs__.PinnedPluginListContext.Provider, {
        value: {
            items: {
                ...ctx.items,
                ...items
            }
        },
        children: children
    });
};
const useStyles = (0, __WEBPACK_EXTERNAL_MODULE_antd_style__.createStyles)((param)=>{
    let { css } = param;
    return {
        container: css(_templateObject())
    };
});
const PinnedPluginList = ()=>{
    const { allowAll, snippets } = (0, __WEBPACK_EXTERNAL_MODULE__acl_index_mjs__.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();
    const ctx = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__context_mjs__.PinnedPluginListContext);
    const { components } = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.SchemaOptionsContext);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
        className: styles.container,
        children: Object.keys(ctx.items).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, __WEBPACK_EXTERNAL_MODULE_lodash__.get)(components, ctx.items[key].component);
            return Action ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Action, {}, key) : null;
        })
    });
};
export { PinnedPluginList, PinnedPluginListProvider };
