import OneUptimeDate from "../Date";
import BadDataException from "../Exception/BadDataException";
import { ObjectType } from "../JSON";
import QueryOperator from "./QueryOperator";
export default class InBetween extends QueryOperator {
    get startValue() {
        return this._startValue;
    }
    set startValue(v) {
        this._startValue = v;
    }
    get endValue() {
        return this._endValue;
    }
    set endValue(v) {
        this._endValue = v;
    }
    constructor(startValue, endValue) {
        super();
        this.startValue = startValue;
        this.endValue = endValue;
    }
    toJSON() {
        return {
            _type: ObjectType.InBetween,
            startValue: this.startValue,
            endValue: this.endValue,
        };
    }
    static fromJSON(json) {
        if (json["_type"] === ObjectType.InBetween) {
            return new InBetween(json["startValue"], json["endValue"]);
        }
        throw new BadDataException("Invalid JSON: " + JSON.stringify(json));
    }
    toString() {
        let startValue = this.startValue;
        let endValue = this.endValue;
        if (startValue instanceof Date) {
            startValue = OneUptimeDate.asDateForDatabaseQuery(startValue);
        }
        if (endValue instanceof Date) {
            endValue = OneUptimeDate.asDateForDatabaseQuery(endValue);
        }
        if (startValue.toString() === endValue.toString()) {
            return this.startValue.toString();
        }
        return this.startValue.toString() + " - " + this.endValue.toString();
    }
    toStartValueString() {
        return this.startValue.toString();
    }
    toEndValueString() {
        return this.endValue.toString();
    }
}
//# sourceMappingURL=InBetween.js.map