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__.registerValidateFormats)({
    odd: /^-?\d*[13579]$/,
    even: /^-?\d*[02468]$/
});
class IntegerFieldInterface extends __WEBPACK_EXTERNAL_MODULE__data_source_collection_field_interface_CollectionFieldInterface_mjs__.CollectionFieldInterface {
    constructor(...args){
        super(...args), _define_property(this, "name", 'integer'), _define_property(this, "type", 'object'), _define_property(this, "group", 'basic'), _define_property(this, "order", 6), _define_property(this, "title", '{{t("Integer")}}'), _define_property(this, "sortable", true), _define_property(this, "default", {
            type: 'bigInt',
            uiSchema: {
                type: 'number',
                'x-component': 'InputNumber',
                'x-component-props': {
                    stringMode: true,
                    step: '1'
                },
                'x-validator': 'integer'
            }
        }), _define_property(this, "availableTypes", [
            'bigInt',
            'integer',
            'sort'
        ]), _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
                }
            },
            autoIncrement: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.autoIncrement,
            'uiSchema.x-component-props.addonBefore': {
                type: 'string',
                title: '{{t("Prefix")}}',
                'x-decorator': 'FormItem',
                'x-component': 'Input'
            },
            'uiSchema.x-component-props.addonAfter': {
                type: 'string',
                title: '{{t("Suffix")}}',
                'x-decorator': 'FormItem',
                'x-component': 'Input'
            }
        }), _define_property(this, "filterable", {
            operators: __WEBPACK_EXTERNAL_MODULE__properties_index_mjs__.operators.number
        }), _define_property(this, "titleUsable", true), _define_property(this, "validateSchema", (fieldSchema)=>({
                maximum: {
                    type: 'number',
                    title: '{{ t("Maximum") }}',
                    'x-decorator': 'FormItem',
                    'x-component': 'InputNumber',
                    'x-component-props': {
                        precision: 0
                    },
                    'x-reactions': "{{(field) => {\n          const targetValue = field.query('.minimum').value();\n          field.selfErrors =\n            !!targetValue && !!field.value && targetValue > field.value ? '".concat(__WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Maximum must greater than minimum'), "' : ''\n        }}}")
                },
                minimum: {
                    type: 'number',
                    title: '{{ t("Minimum") }}',
                    'x-decorator': 'FormItem',
                    'x-component': 'InputNumber',
                    'x-component-props': {
                        precision: 0
                    },
                    'x-reactions': {
                        dependencies: [
                            '.maximum'
                        ],
                        fulfill: {
                            state: {
                                selfErrors: "{{!!$deps[0] && !!$self.value && $deps[0] < $self.value ? '".concat(__WEBPACK_EXTERNAL_MODULE__i18n_index_mjs__.i18n.t('Minimum must less than maximum'), "' : ''}}")
                            }
                        }
                    }
                },
                format: {
                    type: 'string',
                    title: '{{ t("Format") }}',
                    'x-decorator': 'FormItem',
                    'x-component': 'Select',
                    'x-component-props': {
                        allowClear: true
                    },
                    enum: [
                        {
                            label: '{{ t("Odd") }}',
                            value: 'odd'
                        },
                        {
                            label: '{{ t("Even") }}',
                            value: 'even'
                        }
                    ]
                },
                pattern: {
                    type: 'string',
                    title: '{{ t("Regular expression") }}',
                    'x-decorator': 'FormItem',
                    'x-component': 'Input',
                    'x-component-props': {
                        prefix: '/',
                        suffix: '/'
                    }
                }
            }));
    }
}
export { IntegerFieldInterface };
