"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__, {
    useURLAndHTMLSchema: ()=>useURLAndHTMLSchema
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const schema_namespaceObject = require("@tachybase/schema");
const css_namespaceObject = require("@emotion/css");
const external_react_i18next_namespaceObject = require("react-i18next");
const FormBlockProvider_js_namespaceObject = require("../../../block-provider/FormBlockProvider.js");
const index_js_namespaceObject = require("../../../record-provider/index.js");
const Variable_js_namespaceObject = require("../../../schema-component/antd/variable/Variable.js");
const useVariableOptions_js_namespaceObject = require("../../../schema-settings/VariableInput/hooks/useVariableOptions.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                & > .ant-space-item:first-child,\n                & > .ant-space-item:last-child {\n                  flex-shrink: 0;\n                }\n              "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
const getVariableComponentWithScope = (Com)=>(props)=>{
        const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
        const { form } = (0, FormBlockProvider_js_namespaceObject.useFormBlockContext)();
        const record = (0, index_js_namespaceObject.useRecord)();
        const scope = (0, useVariableOptions_js_namespaceObject.useVariableOptions)({
            collectionField: {
                uiSchema: fieldSchema
            },
            form,
            record,
            uiSchema: fieldSchema,
            noDisabled: true
        });
        return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Com, {
            ...props,
            scope: scope
        });
    };
const useURLAndHTMLSchema = ()=>{
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const Com = (0, external_react_namespaceObject.useMemo)(()=>getVariableComponentWithScope(Variable_js_namespaceObject.Variable.TextArea), []);
    const urlSchema = (0, external_react_namespaceObject.useMemo)(()=>({
            title: t('URL'),
            type: 'string',
            'x-decorator': 'FormItem',
            'x-component': Com,
            description: t('Do not concatenate search params in the URL'),
            'x-reactions': {
                dependencies: [
                    'mode'
                ],
                fulfill: {
                    state: {
                        hidden: '{{$deps[0] === "html"}}'
                    }
                }
            }
        }), [
        t,
        Com
    ]);
    const modeSchema = (0, external_react_namespaceObject.useMemo)(()=>({
            title: '{{t("Mode")}}',
            'x-component': 'Radio.Group',
            'x-decorator': 'FormItem',
            default: 'url',
            enum: [
                {
                    value: 'url',
                    label: t('URL')
                },
                {
                    value: 'html',
                    label: t('HTML')
                }
            ]
        }), [
        t
    ]);
    const htmlSchema = (0, external_react_namespaceObject.useMemo)(()=>({
            title: t('html'),
            type: 'string',
            'x-decorator': 'FormItem',
            'x-component': getVariableComponentWithScope(Variable_js_namespaceObject.Variable.RawTextArea),
            'x-component-props': {
                rows: 10
            },
            'x-reactions': {
                dependencies: [
                    'mode'
                ],
                fulfill: {
                    state: {
                        hidden: '{{$deps[0] === "url"}}'
                    }
                }
            }
        }), [
        t
    ]);
    const paramsSchema = (0, external_react_namespaceObject.useMemo)(()=>({
            type: 'array',
            'x-component': 'ArrayItems',
            'x-decorator': 'FormItem',
            title: '{{t("Search parameters")}}',
            items: {
                type: 'object',
                properties: {
                    space: {
                        type: 'void',
                        'x-component': 'Space',
                        'x-component-props': {
                            style: {
                                flexWrap: 'nowrap',
                                maxWidth: '100%'
                            },
                            className: (0, css_namespaceObject.css)(_templateObject())
                        },
                        properties: {
                            name: {
                                type: 'string',
                                'x-decorator': 'FormItem',
                                'x-component': 'Input',
                                'x-component-props': {
                                    placeholder: '{{t("Name")}}'
                                }
                            },
                            value: {
                                type: 'string',
                                'x-decorator': 'FormItem',
                                'x-component': Com,
                                'x-component-props': {
                                    placeholder: '{{t("Value")}}',
                                    useTypedConstant: true,
                                    changeOnSelect: true
                                }
                            },
                            remove: {
                                type: 'void',
                                'x-decorator': 'FormItem',
                                'x-component': 'ArrayItems.Remove'
                            }
                        }
                    }
                }
            },
            'x-reactions': {
                dependencies: [
                    'mode'
                ],
                fulfill: {
                    state: {
                        hidden: '{{$deps[0] === "html"}}'
                    }
                }
            },
            properties: {
                add: {
                    type: 'void',
                    title: '{{t("Add parameter")}}',
                    'x-component': 'ArrayItems.Addition'
                }
            }
        }), [
        Com
    ]);
    const openInNewWindowSchema = (0, external_react_namespaceObject.useMemo)(()=>({
            type: 'boolean',
            'x-content': t('Open in new window'),
            'x-decorator': 'FormItem',
            'x-component': 'Checkbox',
            'x-reactions': {
                dependencies: [
                    'mode'
                ],
                fulfill: {
                    state: {
                        hidden: '{{$deps[0] === "html"}}'
                    }
                }
            }
        }), [
        t
    ]);
    return {
        urlSchema,
        paramsSchema,
        openInNewWindowSchema,
        modeSchema,
        htmlSchema
    };
};
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
});
