/**
 * amis v3.1.0
 * Copyright 2018-2023 baidu
 */

import { __extends, __rest, __assign, __decorate, __metadata } from 'tslib';
import React from 'react';
import { filterDate, parseDuration, FormItem } from 'amis-core';
import cx from 'classnames';
import DateRangeControl from './InputDateRange.js';
import { DateRangePicker } from 'amis-ui';
import { supportStatic } from './StaticHoc.js';

var YearRangeControl = /** @class */ (function (_super) {
    __extends(YearRangeControl, _super);
    function YearRangeControl() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    YearRangeControl.prototype.render = function () {
        var _a = this.props, className = _a.className; _a.style; var ns = _a.classPrefix, minDate = _a.minDate, maxDate = _a.maxDate, minDuration = _a.minDuration, maxDuration = _a.maxDuration, data = _a.data, format = _a.format; _a.env; var rest = __rest(_a, ["className", "style", "classPrefix", "minDate", "maxDate", "minDuration", "maxDuration", "data", "format", "env"]);
        return (React.createElement("div", { className: cx("".concat(ns, "DateRangeControl"), className) },
            React.createElement(DateRangePicker, __assign({ viewMode: "years", format: format, classPrefix: ns, data: data }, rest, { minDate: minDate ? filterDate(minDate, data, format) : undefined, maxDate: maxDate ? filterDate(maxDate, data, format) : undefined, minDuration: minDuration ? parseDuration(minDuration) : undefined, maxDuration: maxDuration ? parseDuration(maxDuration) : undefined, onChange: this.handleChange, onFocus: this.dispatchEvent, onBlur: this.dispatchEvent }))));
    };
    __decorate([
        supportStatic(),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", []),
        __metadata("design:returntype", void 0)
    ], YearRangeControl.prototype, "render", null);
    return YearRangeControl;
}(DateRangeControl));
/** @class */ ((function (_super) {
    __extends(YearRangeControlRenderer, _super);
    function YearRangeControlRenderer() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    YearRangeControlRenderer.defaultProps = {
        format: 'X',
        inputFormat: 'YYYY',
        joinValues: true,
        delimiter: ',',
        timeFormat: '',
        /** shortcuts的兼容配置 */
        ranges: 'thisyear,prevyear',
        shortcuts: 'thisyear,prevyear',
        animation: true
    };
    YearRangeControlRenderer = __decorate([
        FormItem({
            type: 'input-year-range'
        })
    ], YearRangeControlRenderer);
    return YearRangeControlRenderer;
})(YearRangeControl));

export { YearRangeControl as default };
