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_classnames__ from "classnames";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__ from "../../../application/Plugin.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_TableBlockProvider_mjs__ from "../../../block-provider/TableBlockProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../collection-manager/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__modules_blocks_filter_blocks_collapse_filterCollapseItemInitializer_mjs__ from "../../../modules/blocks/filter-blocks/collapse/filterCollapseItemInitializer.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__common_index_mjs__ from "../../common/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__AssociationFilter_BlockDesigner_mjs__ from "./AssociationFilter.BlockDesigner.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__AssociationFilter_Initializer_mjs__ from "./AssociationFilter.Initializer.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__AssociationFilter_Item_mjs__ from "./AssociationFilter.Item.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__AssociationFilter_Item_Designer_mjs__ from "./AssociationFilter.Item.Designer.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      height: 100%;\n      overflow-y: auto;\n      position: relative;\n      border-radius: ",
        "px;\n      &:hover {\n        > .general-schema-designer {\n          display: block;\n        }\n      }\n      &.tb-form-item:hover {\n        > .general-schema-designer {\n          background: var(--colorBgSettingsHover) !important;\n          border: 0 !important;\n          top: -5px !important;\n          bottom: -5px !important;\n          left: -5px !important;\n          right: -5px !important;\n        }\n      }\n      > .general-schema-designer {\n        position: absolute;\n        z-index: 999;\n        top: 0;\n        bottom: 0;\n        left: 0;\n        right: 0;\n        display: none;\n        border: 2px solid var(--colorBorderSettingsHover);\n        pointer-events: none;\n        > .general-schema-designer-icons {\n          position: absolute;\n          right: 2px;\n          top: 2px;\n          line-height: 16px;\n          pointer-events: all;\n          .ant-space-item {\n            background-color: var(--colorSettings);\n            color: #fff;\n            line-height: 16px;\n            width: 16px;\n            padding-left: 1px;\n            align-self: stretch;\n          }\n        }\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const useStyles = (0, __WEBPACK_EXTERNAL_MODULE_antd_style__.createStyles)((param)=>{
    let { css, token } = param;
    return {
        container: css(_templateObject(), token.borderRadiusLG)
    };
});
const AssociationFilter = (props)=>{
    const Designer = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesigner)();
    const filedSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { styles } = useStyles();
    const { render } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaInitializerRender)(filedSchema['x-initializer'], filedSchema['x-initializer-props']);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__common_index_mjs__.DndContext, {
        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__common_index_mjs__.SortableItem, {
            className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])('tb-block-item', props.className, styles.container),
            children: [
                /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Designer, {}),
                props.children,
                render()
            ]
        })
    });
};
AssociationFilter.Provider = __WEBPACK_EXTERNAL_MODULE__block_provider_TableBlockProvider_mjs__.TableBlockProvider;
AssociationFilter.Item = __WEBPACK_EXTERNAL_MODULE__AssociationFilter_Item_mjs__.AssociationFilterItem;
AssociationFilter.Item.Designer = __WEBPACK_EXTERNAL_MODULE__AssociationFilter_Item_Designer_mjs__.AssociationFilterItemDesigner;
AssociationFilter.BlockDesigner = __WEBPACK_EXTERNAL_MODULE__AssociationFilter_BlockDesigner_mjs__.AssociationFilterBlockDesigner;
AssociationFilter.useAssociationField = ()=>{
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const { getField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
    return __WEBPACK_EXTERNAL_MODULE_react__["default"].useMemo(()=>getField(fieldSchema.name), [
        fieldSchema.name
    ]);
};
class AssociationFilterPlugin extends __WEBPACK_EXTERNAL_MODULE__application_Plugin_mjs__.Plugin {
    async load() {
        this.app.schemaInitializerManager.add(__WEBPACK_EXTERNAL_MODULE__modules_blocks_filter_blocks_collapse_filterCollapseItemInitializer_mjs__.associationFilterFilterBlockInitializer);
        this.app.schemaInitializerManager.add(__WEBPACK_EXTERNAL_MODULE__modules_blocks_filter_blocks_collapse_filterCollapseItemInitializer_mjs__.filterCollapseItemInitializer);
        this.app.schemaInitializerManager.add(__WEBPACK_EXTERNAL_MODULE__AssociationFilter_Initializer_mjs__.associationFilterInitializer);
    }
}
export { AssociationFilter, AssociationFilterPlugin };
