"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.done = exports.as = exports.contramap = exports.map = exports.toDone = exports.makeContinue = exports.makeDone = exports.Continue = exports.Done = void 0;
// ets_tracing: off
const T = __importStar(require("../effect"));
class Done {
    constructor(out) {
        this.out = out;
        this._tag = "Done";
    }
}
exports.Done = Done;
class Continue {
    constructor(out, interval, next) {
        this.out = out;
        this.interval = interval;
        this.next = next;
        this._tag = "Continue";
    }
}
exports.Continue = Continue;
function makeDone(o) {
    return new Done(o);
}
exports.makeDone = makeDone;
function makeContinue(out, interval, next) {
    return new Continue(out, interval, next);
}
exports.makeContinue = makeContinue;
function toDone(self) {
    switch (self._tag) {
        case "Done": {
            return self;
        }
        case "Continue": {
            return new Done(self.out);
        }
    }
}
exports.toDone = toDone;
function map(f) {
    return (self) => {
        switch (self._tag) {
            case "Done": {
                return new Done(f(self.out));
            }
            case "Continue": {
                return new Continue(f(self.out), self.interval, (n, i) => T.map_(self.next(n, i), map(f)));
            }
        }
    };
}
exports.map = map;
function contramap(f) {
    return (self) => {
        switch (self._tag) {
            case "Done": {
                return self;
            }
            case "Continue": {
                return new Continue(self.out, self.interval, (n, i) => T.map_(self.next(n, f(i)), contramap(f)));
            }
        }
    };
}
exports.contramap = contramap;
function as(o) {
    return (self) => map(() => o)(self);
}
exports.as = as;
function done(a) {
    return () => T.succeed(new Done(a));
}
exports.done = done;
//# sourceMappingURL=index.js.map