"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Chainable_1 = require("../Chainable");
const SteemOperationNumber_1 = require("../../blockchain/SteemOperationNumber");
class OperationNumberFilter extends Chainable_1.ChainableFilter {
    constructor(mode, tn) {
        super();
        this.limiter = false;
        this.mode = mode;
        this.tn = tn;
    }
    me() {
        return this;
    }
    take(error, rawTx) {
        if (error)
            throw error;
        const tn = SteemOperationNumber_1.SteemOperationNumber.fromTransaction(rawTx);
        if (this.mode === "<" && tn.isLesserThan(this.tn)) {
            return this.give(undefined, rawTx);
        }
        else if (this.mode === "<_solveOpInTrxBug" && tn.isLesserThan_solveOpInTrxBug(this.tn)) {
            return this.give(undefined, rawTx);
        }
        else if (this.mode === "<=" && (tn.isLesserThan(this.tn) || tn.isEqual(this.tn))) {
            return this.give(undefined, rawTx);
        }
        else if (this.mode === ">" && tn.isGreaterThan(this.tn)) {
            return this.give(undefined, rawTx);
        }
        else if (this.mode === ">=" && (tn.isGreaterThan(this.tn) || tn.isEqual(this.tn))) {
            return this.give(undefined, rawTx);
        }
        else {
            return !this.limiter; // true if filter, false if limiter
        }
    }
    makeLimiter() {
        this.limiter = true;
        return this;
    }
}
exports.OperationNumberFilter = OperationNumberFilter;
//# sourceMappingURL=OperationNumberFilter.js.map