import { ExchangeState } from "../subgraph";
export var ExtendedExchangeState;
(function (ExtendedExchangeState) {
    ExtendedExchangeState["NotRedeemableYet"] = "NOT REDEEMABLE YET";
    ExtendedExchangeState["Expired"] = "EXPIRED";
})(ExtendedExchangeState || (ExtendedExchangeState = {}));
export function getExchangeState(exchange) {
    const { offer } = exchange;
    if (Number(offer.voucherRedeemableFromDate) * 1000 > Date.now()) {
        return ExtendedExchangeState.NotRedeemableYet;
    }
    if (exchange.state === ExchangeState.COMMITTED &&
        Number(exchange.validUntilDate) * 1000 < Date.now()) {
        return ExtendedExchangeState.Expired;
    }
    return exchange.state;
}
//# sourceMappingURL=getExchangeState.js.map