"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__, {
    AssociationFilterPlugin: ()=>AssociationFilterPlugin,
    AssociationFilter: ()=>AssociationFilter
});
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 external_antd_style_namespaceObject = require("antd-style");
const external_classnames_namespaceObject = require("classnames");
var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_classnames_namespaceObject);
const index_js_namespaceObject = require("../../../application/index.js");
const Plugin_js_namespaceObject = require("../../../application/Plugin.js");
const TableBlockProvider_js_namespaceObject = require("../../../block-provider/TableBlockProvider.js");
const external_collection_manager_index_js_namespaceObject = require("../../../collection-manager/index.js");
const filterCollapseItemInitializer_js_namespaceObject = require("../../../modules/blocks/filter-blocks/collapse/filterCollapseItemInitializer.js");
const external_common_index_js_namespaceObject = require("../../common/index.js");
const external_hooks_index_js_namespaceObject = require("../../hooks/index.js");
const external_AssociationFilter_BlockDesigner_js_namespaceObject = require("./AssociationFilter.BlockDesigner.js");
const external_AssociationFilter_Initializer_js_namespaceObject = require("./AssociationFilter.Initializer.js");
const external_AssociationFilter_Item_js_namespaceObject = require("./AssociationFilter.Item.js");
const external_AssociationFilter_Item_Designer_js_namespaceObject = require("./AssociationFilter.Item.Designer.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      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, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css, token } = param;
    return {
        container: css(_templateObject(), token.borderRadiusLG)
    };
});
const AssociationFilter = (props)=>{
    const Designer = (0, external_hooks_index_js_namespaceObject.useDesigner)();
    const filedSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { styles } = useStyles();
    const { render } = (0, index_js_namespaceObject.useSchemaInitializerRender)(filedSchema['x-initializer'], filedSchema['x-initializer-props']);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_common_index_js_namespaceObject.DndContext, {
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_common_index_js_namespaceObject.SortableItem, {
            className: external_classnames_default()('tb-block-item', props.className, styles.container),
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Designer, {}),
                props.children,
                render()
            ]
        })
    });
};
AssociationFilter.Provider = TableBlockProvider_js_namespaceObject.TableBlockProvider;
AssociationFilter.Item = external_AssociationFilter_Item_js_namespaceObject.AssociationFilterItem;
AssociationFilter.Item.Designer = external_AssociationFilter_Item_Designer_js_namespaceObject.AssociationFilterItemDesigner;
AssociationFilter.BlockDesigner = external_AssociationFilter_BlockDesigner_js_namespaceObject.AssociationFilterBlockDesigner;
AssociationFilter.useAssociationField = ()=>{
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { getField } = (0, external_collection_manager_index_js_namespaceObject.useCollection_deprecated)();
    return external_react_default().useMemo(()=>getField(fieldSchema.name), [
        fieldSchema.name
    ]);
};
class AssociationFilterPlugin extends Plugin_js_namespaceObject.Plugin {
    async load() {
        this.app.schemaInitializerManager.add(filterCollapseItemInitializer_js_namespaceObject.associationFilterFilterBlockInitializer);
        this.app.schemaInitializerManager.add(filterCollapseItemInitializer_js_namespaceObject.filterCollapseItemInitializer);
        this.app.schemaInitializerManager.add(external_AssociationFilter_Initializer_js_namespaceObject.associationFilterInitializer);
    }
}
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
});
