import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_interface_CollectionFieldInterface_mjs__ from "../../data-source/collection-field-interface/CollectionFieldInterface.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__ from "../../i18n/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__ from "./properties/index.mjs";
function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
(0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.registerValidateRules)({
    username (value) {
        return /^[^@.<>"'/]{2,16}$/.test(value) || __WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Must be 2-16 characters in length (excluding @.<>"\'/)');
    }
});
class InputFieldInterface extends __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_interface_CollectionFieldInterface_mjs__.CollectionFieldInterface {
    schemaInitialize(schema, param) {
        let { block } = param;
        if ([
            'Table',
            'Kanban'
        ].includes(block)) {
            schema['x-component-props'] = schema['x-component-props'] || {};
            schema['x-component-props']['ellipsis'] = true;
        }
    }
    validateSchema(fieldSchema) {
        return {
            max: {
                type: 'number',
                title: '{{ t("Max length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                },
                'x-reactions': "{{(field) => {\n          const targetValue = field.query('.min').value();\n          field.selfErrors =\n            !!targetValue && !!field.value && targetValue > field.value ? '".concat(__WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Max length must greater than min length'), "' : ''\n        }}}")
            },
            min: {
                type: 'number',
                title: '{{ t("Min length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                },
                'x-reactions': {
                    dependencies: [
                        '.max'
                    ],
                    fulfill: {
                        state: {
                            selfErrors: "{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(__WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Min length must less than max length'), "' : ''}}")
                        }
                    }
                }
            },
            len: {
                type: 'number',
                title: '{{ t("Length") }}',
                minimum: 0,
                'x-decorator': 'FormItem',
                'x-component': 'InputNumber',
                'x-component-props': {
                    precision: 0
                }
            },
            format: {
                type: 'string',
                title: '{{ t("Format") }}',
                'x-decorator': 'FormItem',
                'x-component': 'Select',
                'x-component-props': {
                    allowClear: true
                },
                enum: [
                    {
                        label: '{{ t("url") }}',
                        value: 'url'
                    },
                    {
                        label: '{{ t("email") }}',
                        value: 'email'
                    },
                    {
                        label: '{{ t("ipv6") }}',
                        value: 'ipv6'
                    },
                    {
                        label: '{{ t("ipv4") }}',
                        value: 'ipv4'
                    },
                    {
                        label: '{{ t("number") }}',
                        value: 'number'
                    },
                    {
                        label: '{{ t("integer") }}',
                        value: 'integer'
                    },
                    {
                        label: '{{ t("idcard") }}',
                        value: 'idcard'
                    },
                    {
                        label: '{{ t("qq") }}',
                        value: 'qq'
                    },
                    {
                        label: '{{ t("phone") }}',
                        value: 'phone'
                    },
                    {
                        label: '{{ t("money") }}',
                        value: 'money'
                    },
                    {
                        label: '{{ t("zh") }}',
                        value: 'zh'
                    },
                    {
                        label: '{{ t("date") }}',
                        value: 'date'
                    },
                    {
                        label: '{{ t("zip") }}',
                        value: 'zip'
                    }
                ]
            },
            pattern: {
                type: 'string',
                title: '{{ t("Regular expression") }}',
                'x-decorator': 'FormItem',
                'x-component': 'Input',
                'x-component-props': {
                    prefix: '/',
                    suffix: '/'
                }
            }
        };
    }
    constructor(...args){
        super(...args), _define_property(this, "name", 'input'), _define_property(this, "type", 'object'), _define_property(this, "group", 'basic'), _define_property(this, "order", 1), _define_property(this, "title", '{{t("Single line text")}}'), _define_property(this, "sortable", true), _define_property(this, "default", {
            interface: 'input',
            type: 'string',
            uiSchema: {
                type: 'string',
                'x-component': 'Input'
            }
        }), _define_property(this, "availableTypes", [
            'string',
            'uid'
        ]), _define_property(this, "hasDefaultValue", true), _define_property(this, "properties", {
            ...__WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.defaultProps,
            layout: {
                type: 'void',
                title: '{{t("Index")}}',
                'x-component': 'Space',
                'x-decorator': 'FormItem',
                'x-decorator-props': {
                    style: {
                        marginBottom: '0px'
                    }
                },
                properties: {
                    primaryKey: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.primaryKey,
                    unique: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.unique
                }
            }
        }), _define_property(this, "filterable", {
            operators: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.operators.string
        }), _define_property(this, "titleUsable", true);
    }
}
export { InputFieldInterface };
