import { c as createCommonjsModule, u as unwrapExports } from './23e44913.js';

var Either = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Right = exports.Left = exports.Either = void 0;

exports.Either = {
    of(value) {
        return right(value);
    },
    lefts(list) {
        let result = [];
        for (const x of list) {
            if (x.isLeft()) {
                result.push(x.extract());
            }
        }
        return result;
    },
    rights(list) {
        let result = [];
        for (const x of list) {
            if (x.isRight()) {
                result.push(x.extract());
            }
        }
        return result;
    },
    encase(throwsF) {
        try {
            return right(throwsF());
        }
        catch (e) {
            return left(e);
        }
    },
    sequence(eithers) {
        let res = [];
        for (const e of eithers) {
            if (e.isLeft()) {
                return e;
            }
            res.push(e.extract());
        }
        return right(res);
    },
    'fantasy-land/of'(value) {
        return exports.Either.of(value);
    }
};
class Right {
    constructor(__value) {
        this.__value = __value;
        this._ = 'R';
    }
    isLeft() {
        return false;
    }
    isRight() {
        return true;
    }
    toJSON() {
        return this.__value;
    }
    inspect() {
        return `Right(${JSON.stringify(this.__value)})`;
    }
    toString() {
        return this.inspect();
    }
    bimap(_, g) {
        return right(g(this.__value));
    }
    map(f) {
        return right(f(this.__value));
    }
    mapLeft(_) {
        return this;
    }
    ap(other) {
        return other.isRight() ? this.map(other.extract()) : other;
    }
    equals(other) {
        return other.isRight() ? this.__value === other.extract() : false;
    }
    chain(f) {
        return f(this.__value);
    }
    chainLeft(_) {
        return this;
    }
    join() {
        return this.__value;
    }
    alt(_) {
        return this;
    }
    reduce(reducer, initialValue) {
        return reducer(initialValue, this.__value);
    }
    extend(f) {
        return right(f(this));
    }
    unsafeCoerce() {
        return this.__value;
    }
    caseOf(patterns) {
        return '_' in patterns ? patterns._() : patterns.Right(this.__value);
    }
    leftOrDefault(defaultValue) {
        return defaultValue;
    }
    orDefault(_) {
        return this.__value;
    }
    orDefaultLazy(_) {
        return this.__value;
    }
    leftOrDefaultLazy(getDefaultValue) {
        return getDefaultValue();
    }
    ifLeft(_) {
        return this;
    }
    ifRight(effect) {
        return effect(this.__value), this;
    }
    toMaybe() {
        return Maybe.Just(this.__value);
    }
    leftToMaybe() {
        return Maybe.Nothing;
    }
    either(_, ifRight) {
        return ifRight(this.__value);
    }
    extract() {
        return this.__value;
    }
    swap() {
        return left(this.__value);
    }
    'fantasy-land/bimap'(f, g) {
        return this.bimap(f, g);
    }
    'fantasy-land/map'(f) {
        return this.map(f);
    }
    'fantasy-land/ap'(other) {
        return this.ap(other);
    }
    'fantasy-land/equals'(other) {
        return this.equals(other);
    }
    'fantasy-land/chain'(f) {
        return this.chain(f);
    }
    'fantasy-land/alt'(other) {
        return this.alt(other);
    }
    'fantasy-land/reduce'(reducer, initialValue) {
        return this.reduce(reducer, initialValue);
    }
    'fantasy-land/extend'(f) {
        return this.extend(f);
    }
}
Right.prototype.constructor = exports.Either;
class Left {
    constructor(__value) {
        this.__value = __value;
        this._ = 'L';
    }
    isLeft() {
        return true;
    }
    isRight() {
        return false;
    }
    toJSON() {
        return this.__value;
    }
    inspect() {
        return `Left(${JSON.stringify(this.__value)})`;
    }
    toString() {
        return this.inspect();
    }
    bimap(f, _) {
        return left(f(this.__value));
    }
    map(_) {
        return this;
    }
    mapLeft(f) {
        return left(f(this.__value));
    }
    ap(other) {
        return other.isLeft() ? other : this;
    }
    equals(other) {
        return other.isLeft() ? other.extract() === this.__value : false;
    }
    chain(_) {
        return this;
    }
    chainLeft(f) {
        return f(this.__value);
    }
    join() {
        return this;
    }
    alt(other) {
        return other;
    }
    reduce(_, initialValue) {
        return initialValue;
    }
    extend(_) {
        return this;
    }
    unsafeCoerce() {
        throw new Error('Either got coerced to a Left');
    }
    caseOf(patterns) {
        return '_' in patterns ? patterns._() : patterns.Left(this.__value);
    }
    leftOrDefault(_) {
        return this.__value;
    }
    orDefault(defaultValue) {
        return defaultValue;
    }
    orDefaultLazy(getDefaultValue) {
        return getDefaultValue();
    }
    leftOrDefaultLazy(_) {
        return this.__value;
    }
    ifLeft(effect) {
        return effect(this.__value), this;
    }
    ifRight(_) {
        return this;
    }
    toMaybe() {
        return Maybe.Nothing;
    }
    leftToMaybe() {
        return Maybe.Just(this.__value);
    }
    either(ifLeft, _) {
        return ifLeft(this.__value);
    }
    extract() {
        return this.__value;
    }
    swap() {
        return right(this.__value);
    }
    'fantasy-land/bimap'(f, g) {
        return this.bimap(f, g);
    }
    'fantasy-land/map'(f) {
        return this.map(f);
    }
    'fantasy-land/ap'(other) {
        return this.ap(other);
    }
    'fantasy-land/equals'(other) {
        return this.equals(other);
    }
    'fantasy-land/chain'(f) {
        return this.chain(f);
    }
    'fantasy-land/alt'(other) {
        return this.alt(other);
    }
    'fantasy-land/reduce'(reducer, initialValue) {
        return this.reduce(reducer, initialValue);
    }
    'fantasy-land/extend'(f) {
        return this.extend(f);
    }
}
Left.prototype.constructor = exports.Either;
const left = (value) => new Left(value);
exports.Left = left;
const right = (value) => new Right(value);
exports.Right = right;
});

unwrapExports(Either);
var Either_1 = Either.Right;
var Either_2 = Either.Left;
var Either_3 = Either.Either;

var Maybe = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Nothing = exports.Just = exports.Maybe = void 0;

exports.Maybe = {
    of(value) {
        return just(value);
    },
    empty() {
        return nothing;
    },
    zero() {
        return nothing;
    },
    fromNullable(value) {
        return value == null ? nothing : just(value);
    },
    fromFalsy(value) {
        return value ? just(value) : nothing;
    },
    fromPredicate(pred, value) {
        switch (arguments.length) {
            case 1:
                return (value) => exports.Maybe.fromPredicate(pred, value);
            default:
                return pred(value) ? just(value) : nothing;
        }
    },
    mapMaybe(f, list) {
        switch (arguments.length) {
            case 1:
                return (list) => exports.Maybe.mapMaybe(f, list);
            default:
                return exports.Maybe.catMaybes(list.map(f));
        }
    },
    catMaybes(list) {
        let res = [];
        for (const e of list) {
            if (e.isJust()) {
                res.push(e.extract());
            }
        }
        return res;
    },
    encase(thunk) {
        try {
            return just(thunk());
        }
        catch (_a) {
            return nothing;
        }
    },
    'fantasy-land/of'(value) {
        return this.of(value);
    },
    'fantasy-land/empty'() {
        return this.empty();
    },
    'fantasy-land/zero'() {
        return this.zero();
    }
};
class Just {
    constructor(__value) {
        this.__value = __value;
    }
    isJust() {
        return true;
    }
    isNothing() {
        return false;
    }
    inspect() {
        return `Just(${JSON.stringify(this.__value)})`;
    }
    toString() {
        return this.inspect();
    }
    toJSON() {
        return this.__value;
    }
    equals(other) {
        return this.extract() === other.extract();
    }
    map(f) {
        return just(f(this.__value));
    }
    ap(maybeF) {
        return maybeF.isJust() ? this.map(maybeF.extract()) : nothing;
    }
    alt(_) {
        return this;
    }
    chain(f) {
        return f(this.__value);
    }
    chainNullable(f) {
        return exports.Maybe.fromNullable(f(this.__value));
    }
    join() {
        return this.__value;
    }
    reduce(reducer, initialValue) {
        return reducer(initialValue, this.__value);
    }
    extend(f) {
        return just(f(this));
    }
    unsafeCoerce() {
        return this.__value;
    }
    caseOf(patterns) {
        return '_' in patterns ? patterns._() : patterns.Just(this.__value);
    }
    orDefault(_) {
        return this.__value;
    }
    orDefaultLazy(_) {
        return this.__value;
    }
    toList() {
        return [this.__value];
    }
    mapOrDefault(f, _) {
        return f(this.__value);
    }
    extract() {
        return this.__value;
    }
    extractNullable() {
        return this.__value;
    }
    toEither(_) {
        return Either.Right(this.__value);
    }
    ifJust(effect) {
        return effect(this.__value), this;
    }
    ifNothing(_) {
        return this;
    }
    filter(pred) {
        return pred(this.__value) ? just(this.__value) : nothing;
    }
    'fantasy-land/equals'(other) {
        return this.equals(other);
    }
    'fantasy-land/map'(f) {
        return this.map(f);
    }
    'fantasy-land/ap'(maybeF) {
        return this.ap(maybeF);
    }
    'fantasy-land/alt'(other) {
        return this.alt(other);
    }
    'fantasy-land/chain'(f) {
        return this.chain(f);
    }
    'fantasy-land/reduce'(reducer, initialValue) {
        return this.reduce(reducer, initialValue);
    }
    'fantasy-land/extend'(f) {
        return this.extend(f);
    }
    'fantasy-land/filter'(pred) {
        return this.filter(pred);
    }
}
Just.prototype.constructor = exports.Maybe;
class Nothing {
    isJust() {
        return false;
    }
    isNothing() {
        return true;
    }
    inspect() {
        return 'Nothing';
    }
    toString() {
        return this.inspect();
    }
    toJSON() {
        return this.__value;
    }
    equals(other) {
        return this.extract() === other.extract();
    }
    map(_) {
        return nothing;
    }
    ap(_) {
        return nothing;
    }
    alt(other) {
        return other;
    }
    chain(_) {
        return nothing;
    }
    chainNullable(_) {
        return nothing;
    }
    join() {
        return nothing;
    }
    reduce(_, initialValue) {
        return initialValue;
    }
    extend(_) {
        return nothing;
    }
    unsafeCoerce() {
        throw new Error('Maybe got coerced to a null');
    }
    caseOf(patterns) {
        return '_' in patterns ? patterns._() : patterns.Nothing();
    }
    orDefault(defaultValue) {
        return defaultValue;
    }
    orDefaultLazy(getDefaultValue) {
        return getDefaultValue();
    }
    toList() {
        return [];
    }
    mapOrDefault(_, defaultValue) {
        return defaultValue;
    }
    extract() {
        return undefined;
    }
    extractNullable() {
        return null;
    }
    toEither(left) {
        return Either.Left(left);
    }
    ifJust(_) {
        return this;
    }
    ifNothing(effect) {
        return effect(), this;
    }
    filter(_) {
        return nothing;
    }
    'fantasy-land/equals'(other) {
        return this.equals(other);
    }
    'fantasy-land/map'(f) {
        return this.map(f);
    }
    'fantasy-land/ap'(maybeF) {
        return this.ap(maybeF);
    }
    'fantasy-land/alt'(other) {
        return this.alt(other);
    }
    'fantasy-land/chain'(f) {
        return this.chain(f);
    }
    'fantasy-land/reduce'(reducer, initialValue) {
        return this.reduce(reducer, initialValue);
    }
    'fantasy-land/extend'(f) {
        return this.extend(f);
    }
    'fantasy-land/filter'(pred) {
        return this.filter(pred);
    }
}
Nothing.prototype.constructor = exports.Maybe;
/** Constructs a Just. Represents an optional value that exists */
const just = (value) => new Just(value);
exports.Just = just;
/** Represents a missing value, you can think of it as a smart 'null' */
const nothing = new Nothing();
exports.Nothing = nothing;
});

unwrapExports(Maybe);
var Maybe_1 = Maybe.Nothing;
var Maybe_2 = Maybe.Just;
var Maybe_3 = Maybe.Maybe;

export { Maybe_3 as M };
//# sourceMappingURL=d76d6172.js.map
