import { HttpStep } from '../../HttpStep.js';
export const GreaterThanAssertionKind = 'HttpAction#GreaterThanAssertion';
/**
 * An assertion that makes sure the input value is greater [or equal] to the set value.
 */
export class GreaterThanAssertion extends HttpStep {
    kind = GreaterThanAssertionKind;
    /**
     * The value to compare to.
     */
    value;
    /**
     * When set it treats the assertion as "greater than or equal"
     */
    equal;
    constructor(valueOrInit, equal) {
        super();
        if (typeof valueOrInit === 'object') {
            const typed = valueOrInit;
            this.new(typed);
        }
        else if (typeof valueOrInit === 'number') {
            this.new({
                kind: GreaterThanAssertionKind,
                value: valueOrInit,
                equal,
                enabled: true,
            });
        }
    }
    new(init) {
        super.new(init);
        this.kind = GreaterThanAssertionKind;
        this.value = init.value;
        if (typeof init.equal === 'boolean') {
            this.equal = init.equal;
        }
        else {
            this.equal = undefined;
        }
    }
    checkValidity() {
        return typeof this.value === 'number';
    }
    toJSON() {
        const result = {
            ...super.toJSON(),
            kind: GreaterThanAssertionKind,
        };
        if (typeof this.value === 'number') {
            result.value = this.value;
        }
        if (typeof this.equal === 'boolean') {
            result.equal = this.equal;
        }
        return result;
    }
}
//# sourceMappingURL=GreaterThanAssertion.js.map