"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__, {
    FilterItem: ()=>FilterItem
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const icons_namespaceObject = require("@ant-design/icons");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const external_index_js_namespaceObject = require("../../index.js");
const external_context_js_namespaceObject = require("./context.js");
const external_DynamicComponent_js_namespaceObject = require("./DynamicComponent.js");
const external_useValues_js_namespaceObject = require("./useValues.js");
const FilterItem = (0, schema_namespaceObject.observer)((props)=>{
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const compile = (0, external_index_js_namespaceObject.useCompile)();
    const remove = (0, external_react_namespaceObject.useContext)(external_context_js_namespaceObject.RemoveConditionContext);
    const { schema, fields, operators, dataIndex, operator, setDataIndex, setOperator, value, setValue, collectionField } = (0, external_useValues_js_namespaceObject.useValues)();
    const style = (0, external_react_namespaceObject.useMemo)(()=>({
            marginBottom: 8
        }), []);
    const fieldNames = (0, external_react_namespaceObject.useMemo)(()=>({
            label: 'title',
            value: 'name',
            children: 'children'
        }), []);
    const onChange = (0, external_react_namespaceObject.useCallback)((value)=>{
        setDataIndex(value);
    }, [
        setDataIndex
    ]);
    const onOperatorsChange = (0, external_react_namespaceObject.useCallback)((value)=>{
        setOperator(value);
    }, [
        setOperator
    ]);
    const removeStyle = (0, external_react_namespaceObject.useMemo)(()=>({
            color: '#bfbfbf'
        }), []);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        style: style,
        className: "nc-filter-item",
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Space, {
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Cascader, {
                    "data-testid": "select-filter-field",
                    style: {
                        width: '160px'
                    },
                    fieldNames: fieldNames,
                    changeOnSelect: false,
                    value: dataIndex,
                    options: compile(fields),
                    onChange: onChange,
                    placeholder: t('Select field')
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Select, {
                    "data-testid": "select-filter-operator",
                    style: {
                        minWidth: '110px'
                    },
                    popupMatchSelectWidth: false,
                    value: null == operator ? void 0 : operator.value,
                    options: compile(operators),
                    onChange: onOperatorsChange,
                    placeholder: t('Comparision')
                }),
                (null == operator ? void 0 : operator.noValue) ? null : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_DynamicComponent_js_namespaceObject.DynamicComponent, {
                    value: value,
                    schema: schema,
                    collectionField: collectionField,
                    onChange: setValue
                }),
                !props.disabled && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
                    role: "button",
                    "aria-label": "icon-close",
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icons_namespaceObject.CloseCircleOutlined, {
                        onClick: remove,
                        style: removeStyle
                    })
                })
            ]
        })
    });
}, {
    displayName: 'FilterItem'
});
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
});
