"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__, {
    FormFilterScope: ()=>FormFilterScope
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const components_namespaceObject = require("@tachybase/components");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_style_namespaceObject = require("antd-style");
const index_js_namespaceObject = require("../../block-provider/index.js");
const external_collection_manager_index_js_namespaceObject = require("../../collection-manager/index.js");
const external_record_provider_index_js_namespaceObject = require("../../record-provider/index.js");
const external_schema_component_index_js_namespaceObject = require("../../schema-component/index.js");
const external_VariableInput_index_js_namespaceObject = require("../VariableInput/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                    position: relative;\n                    width: 100%;\n                    margin-left: 10px;\n                  "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const FormFilterScope = (0, schema_namespaceObject.observer)((props)=>{
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const { useProps, dynamicComponent } = props;
    const { options, defaultValues, collectionName, form, formBlockType, variables, localVariables, record } = useProps();
    const { getAllCollectionsInheritChain } = (0, external_collection_manager_index_js_namespaceObject.useCollectionManager_deprecated)();
    const components = (0, external_react_namespaceObject.useMemo)(()=>({
            ArrayCollapse: components_namespaceObject.ArrayCollapse
        }), []);
    const schema = (0, external_react_namespaceObject.useMemo)(()=>({
            type: 'object',
            properties: {
                condition: {
                    'x-component': 'Filter',
                    default: defaultValues,
                    'x-component-props': {
                        collectionName,
                        useProps () {
                            return {
                                options,
                                className: (0, external_antd_style_namespaceObject.css)(_templateObject())
                            };
                        },
                        dynamicComponent: (props)=>{
                            const { collectionField } = props;
                            return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_VariableInput_index_js_namespaceObject.VariableInput, {
                                ...props,
                                form: form,
                                record: record,
                                collectionField: props.collectionField,
                                shouldChange: (0, external_VariableInput_index_js_namespaceObject.getShouldChange)({
                                    collectionField,
                                    variables,
                                    localVariables,
                                    getAllCollectionsInheritChain
                                })
                            });
                        }
                    }
                }
            }
        }), [
        collectionName,
        defaultValues,
        form,
        localVariables,
        options,
        props,
        record,
        variables
    ]);
    const value = (0, external_react_namespaceObject.useMemo)(()=>({
            field: options,
            fieldSchema,
            dynamicComponent,
            options: options || []
        }), [
        dynamicComponent,
        fieldSchema,
        options
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.FormBlockContext.Provider, {
        value: {
            form,
            type: formBlockType,
            collectionName: collectionName
        },
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_record_provider_index_js_namespaceObject.RecordProvider, {
            record: record,
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_context_js_namespaceObject.FilterContext.Provider, {
                value: value,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_component_index_js_namespaceObject.SchemaComponent, {
                    components: components,
                    schema: schema
                })
            })
        })
    });
}, {
    displayName: 'FormFilterScope'
});
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
});
