'use strict';

const _commonjsHelpers = require('./_commonjsHelpers-fc53004f.js');

var Result_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Result = void 0;
var Result;
(function (Result) {
    function is(value) {
        return (typeof value == "object" &&
            typeof value.status == "number" &&
            (value.header == undefined ||
                (typeof value.header == "object" && (value.header.eTag == undefined || typeof value.header.eTag == "string"))));
    }
    Result.is = is;
    function hasBody(value) {
        return typeof value == "object" && typeof value.status == "number" && value.body != undefined && value.body != null;
    }
    Result.hasBody = hasBody;
    function getBody(value, fallback) {
        return hasBody(value) ? value.body : fallback;
    }
    Result.getBody = getBody;
})(Result = exports.Result || (exports.Result = {}));

});

var _Error = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Error = void 0;

var Error;
(function (Error) {
    function is(value) {
        return typeof value == "object" && typeof value.type == "string" && Result_1.Result.is(value) && value.status >= 400;
    }
    Error.is = is;
})(Error = exports.Error || (exports.Error = {}));

});

var Flaw_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Flaw = void 0;
var Flaw;
(function (Flaw) {
    function is(value) {
        return (typeof value == "object" &&
            (value.property == undefined || typeof value.property == "string") &&
            typeof value.type == "string" &&
            (value.flaws == undefined || (Array.isArray(value.flaws) && value.flaws.every(Flaw.is))) &&
            (value.condition == undefined || typeof value.condition == "string"));
    }
    Flaw.is = is;
})(Flaw = exports.Flaw || (exports.Flaw = {}));

});

var created_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.created = void 0;

function created(body) {
    return { status: 201, body };
}
exports.created = created;
(function (created) {
    function is(value) {
        return typeof value == "object" && value.body && Result_1.Result.is(value) && value.status == 201;
    }
    created.is = is;
})(created = exports.created || (exports.created = {}));

});

var noContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.noContent = void 0;

function noContent() {
    return { status: 204 };
}
exports.noContent = noContent;
(function (noContent) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 204;
    }
    noContent.is = is;
})(noContent = exports.noContent || (exports.noContent = {}));

});

var ok_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.ok = void 0;

function ok(body, eTag) {
    return { status: 200, body, header: { eTag } };
}
exports.ok = ok;
(function (ok) {
    function is(value) {
        return typeof value == "object" && value.body && Result_1.Result.is(value) && value.status == 200;
    }
    ok.is = is;
})(ok = exports.ok || (exports.ok = {}));

});

var success = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.ok = exports.noContent = exports.created = void 0;

Object.defineProperty(exports, "created", { enumerable: true, get: function () { return created_1.created; } });

Object.defineProperty(exports, "noContent", { enumerable: true, get: function () { return noContent_1.noContent; } });

Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return ok_1.ok; } });

});

var permanent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.permanent = void 0;

function permanent(location) {
    return { status: 301, location };
}
exports.permanent = permanent;
(function (permanent) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 301;
    }
    permanent.is = is;
})(permanent = exports.permanent || (exports.permanent = {}));

});

var found_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.found = void 0;

function found(location) {
    return { status: 302, location };
}
exports.found = found;
(function (found) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 302;
    }
    found.is = is;
})(found = exports.found || (exports.found = {}));

});

var notModified_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.notModified = void 0;

function notModified(eTag) {
    return { status: 304, header: { eTag: eTag } };
}
exports.notModified = notModified;
(function (notModified) {
    function is(value) {
        return (typeof value == "object" &&
            Result_1.Result.is(value) &&
            value.status == 304 &&
            typeof value.header == "object" &&
            typeof value.header.eTag == "string");
    }
    notModified.is = is;
})(notModified = exports.notModified || (exports.notModified = {}));

});

var redirect = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.notModified = exports.found = exports.permanent = void 0;

Object.defineProperty(exports, "permanent", { enumerable: true, get: function () { return permanent_1.permanent; } });

Object.defineProperty(exports, "found", { enumerable: true, get: function () { return found_1.found; } });

Object.defineProperty(exports, "notModified", { enumerable: true, get: function () { return notModified_1.notModified; } });

});

var flawedContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.flawedContent = void 0;

function flawedContent(content) {
    return { status: 400, type: "flawed content", content };
}
exports.flawedContent = flawedContent;
(function (flawedContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "flawed content";
    }
    flawedContent.is = is;
})(flawedContent = exports.flawedContent || (exports.flawedContent = {}));

});

var invalidContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidContent = void 0;

function invalidContent(type, description, details) {
    return { status: 400, type: "invalid content", content: { type, description, details } };
}
exports.invalidContent = invalidContent;
(function (invalidContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid content";
    }
    invalidContent.is = is;
})(invalidContent = exports.invalidContent || (exports.invalidContent = {}));

});

var invalidPathArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidPathArgument = void 0;

function invalidPathArgument(pattern, name, type, description) {
    return { status: 400, type: "invalid path argument", pattern, argument: { name, type, description } };
}
exports.invalidPathArgument = invalidPathArgument;
(function (invalidPathArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid path argument";
    }
    invalidPathArgument.is = is;
})(invalidPathArgument = exports.invalidPathArgument || (exports.invalidPathArgument = {}));

});

var invalidQueryArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidQueryArgument = void 0;

function invalidQueryArgument(name, type, description) {
    return { status: 400, type: "invalid query argument", argument: { name, type, description } };
}
exports.invalidQueryArgument = invalidQueryArgument;
(function (invalidQueryArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid query argument";
    }
    invalidQueryArgument.is = is;
})(invalidQueryArgument = exports.invalidQueryArgument || (exports.invalidQueryArgument = {}));

});

var malformedContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.malformedContent = void 0;

function malformedContent(property, type, description, details) {
    return { status: 400, type: "malformed content", content: { property, type, description, details } };
}
exports.malformedContent = malformedContent;
(function (malformedContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "malformed content";
    }
    malformedContent.is = is;
})(malformedContent = exports.malformedContent || (exports.malformedContent = {}));

});

var methodNotAllowed_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.methodNotAllowed = void 0;

const methods = ["GET", "POST", "DELETE", "HEAD", "PATCH", "PUT", "OPTIONS", "TRACE", "CONNECT"];
function methodNotAllowed(...allow) {
    return { status: 405, type: "method not allowed", header: { allow } };
}
exports.methodNotAllowed = methodNotAllowed;
(function (methodNotAllowed) {
    function is(value) {
        return (typeof value == "object" &&
            value.status == 405 &&
            value.type == "method not allowed" &&
            typeof value.header == "object" &&
            Array.isArray(value.header.allow) &&
            value.header.allow.every((m) => methods.some(m)) &&
            _Error.Error.is(value));
    }
    methodNotAllowed.is = is;
})(methodNotAllowed = exports.methodNotAllowed || (exports.methodNotAllowed = {}));

});

var missingProperty_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.missingProperty = void 0;

function missingProperty(property, type, description) {
    return {
        status: 400,
        type: "missing property",
        content: typeof description == "string" ? { property, type, description } : Object.assign({ property, type }, description),
    };
}
exports.missingProperty = missingProperty;
(function (missingProperty) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "missing property";
    }
    missingProperty.is = is;
})(missingProperty = exports.missingProperty || (exports.missingProperty = {}));

});

var missingQueryArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.missingQueryArgument = void 0;

function missingQueryArgument(name, type, description) {
    return { status: 400, type: "missing query argument", argument: { name, type, description } };
}
exports.missingQueryArgument = missingQueryArgument;
(function (missingQueryArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "missing query argument";
    }
    missingQueryArgument.is = is;
})(missingQueryArgument = exports.missingQueryArgument || (exports.missingQueryArgument = {}));

});

var notFound_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.notFound = void 0;

function notFound() {
    return { status: 404, type: "not found" };
}
exports.notFound = notFound;
(function (notFound) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 404 && value.type == "not found";
    }
    notFound.is = is;
})(notFound = exports.notFound || (exports.notFound = {}));

});

var unauthorized_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unauthorized = void 0;

function unauthorized() {
    return { status: 401, type: "not authorized" };
}
exports.unauthorized = unauthorized;
(function (unauthorized) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 401 && value.type == "not authorized";
    }
    unauthorized.is = is;
})(unauthorized = exports.unauthorized || (exports.unauthorized = {}));

});

var client = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });

Object.defineProperty(exports, "flawedContent", { enumerable: true, get: function () { return flawedContent_1.flawedContent; } });

Object.defineProperty(exports, "invalidContent", { enumerable: true, get: function () { return invalidContent_1.invalidContent; } });

Object.defineProperty(exports, "invalidPathArgument", { enumerable: true, get: function () { return invalidPathArgument_1.invalidPathArgument; } });

Object.defineProperty(exports, "invalidQueryArgument", { enumerable: true, get: function () { return invalidQueryArgument_1.invalidQueryArgument; } });

Object.defineProperty(exports, "malformedContent", { enumerable: true, get: function () { return malformedContent_1.malformedContent; } });

Object.defineProperty(exports, "methodNotAllowed", { enumerable: true, get: function () { return methodNotAllowed_1.methodNotAllowed; } });

Object.defineProperty(exports, "missingProperty", { enumerable: true, get: function () { return missingProperty_1.missingProperty; } });

Object.defineProperty(exports, "missingQueryArgument", { enumerable: true, get: function () { return missingQueryArgument_1.missingQueryArgument; } });

Object.defineProperty(exports, "notFound", { enumerable: true, get: function () { return notFound_1.notFound; } });

Object.defineProperty(exports, "unauthorized", { enumerable: true, get: function () { return unauthorized_1.unauthorized; } });

});

var backendFailure_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.backendFailure = void 0;

function backendFailure(backend, details, reference) {
    if (backend != "string" && details == undefined && reference == undefined) {
        details = backend;
        backend = "unknown";
    }
    return { status: 502, type: "backend failure", backend, details, reference };
}
exports.backendFailure = backendFailure;
(function (backendFailure) {
    function is(value) {
        return (_Error.Error.is(value) &&
            value.status == 502 &&
            value.type == "backend failure" &&
            typeof value.backend == "string");
    }
    backendFailure.is = is;
})(backendFailure = exports.backendFailure || (exports.backendFailure = {}));

});

var backendTimeout_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.backendTimeout = void 0;

function backendTimeout() {
    return { status: 504, type: "backend timeout" };
}
exports.backendTimeout = backendTimeout;
(function (backendTimeout) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 504 && value.type == "backend timeout";
    }
    backendTimeout.is = is;
})(backendTimeout = exports.backendTimeout || (exports.backendTimeout = {}));

});

var databaseFailure_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.databaseFailure = void 0;

function databaseFailure(details) {
    return { status: 502, type: "database failure", details };
}
exports.databaseFailure = databaseFailure;
(function (databaseFailure) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 502 && value.type == "database failure";
    }
    databaseFailure.is = is;
})(databaseFailure = exports.databaseFailure || (exports.databaseFailure = {}));

});

var databaseTimeout_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.databaseTimeout = void 0;

function databaseTimeout() {
    return { status: 504, type: "database timeout" };
}
exports.databaseTimeout = databaseTimeout;
(function (databaseTimeout) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 504 && value.type == "database timeout";
    }
    databaseTimeout.is = is;
})(databaseTimeout = exports.databaseTimeout || (exports.databaseTimeout = {}));

});

var missconfigured_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.missconfigured = void 0;

function missconfigured(key, description) {
    return { status: 503, type: "missing configuration", key, description };
}
exports.missconfigured = missconfigured;
(function (missconfigured) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 503 && value.type == "missing configuration";
    }
    missconfigured.is = is;
})(missconfigured = exports.missconfigured || (exports.missconfigured = {}));

});

var unavailable_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unavailable = void 0;

function unavailable() {
    return { status: 503, type: "service unavailable" };
}
exports.unavailable = unavailable;
(function (unavailable) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 503 && value.type == "service unavailable";
    }
    unavailable.is = is;
})(unavailable = exports.unavailable || (exports.unavailable = {}));

});

var unknown_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unknown = void 0;

function unknown(error) {
    return { status: 500, type: "unknown error", error };
}
exports.unknown = unknown;
(function (unknown) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 500 && value.type == "unknown error";
    }
    unknown.is = is;
})(unknown = exports.unknown || (exports.unknown = {}));

});

var server = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.unknown = exports.unavailable = exports.missconfigured = exports.databaseTimeout = exports.databaseFailure = exports.backendTimeout = exports.backendFailure = void 0;

Object.defineProperty(exports, "backendFailure", { enumerable: true, get: function () { return backendFailure_1.backendFailure; } });

Object.defineProperty(exports, "backendTimeout", { enumerable: true, get: function () { return backendTimeout_1.backendTimeout; } });

Object.defineProperty(exports, "databaseFailure", { enumerable: true, get: function () { return databaseFailure_1.databaseFailure; } });

Object.defineProperty(exports, "databaseTimeout", { enumerable: true, get: function () { return databaseTimeout_1.databaseTimeout; } });

Object.defineProperty(exports, "missconfigured", { enumerable: true, get: function () { return missconfigured_1.missconfigured; } });

Object.defineProperty(exports, "unavailable", { enumerable: true, get: function () { return unavailable_1.unavailable; } });

Object.defineProperty(exports, "unknown", { enumerable: true, get: function () { return unknown_1.unknown; } });

});

var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
exports.server = exports.client = exports.redirect = exports.success = exports.Result = exports.Flaw = exports.Error = void 0;

Object.defineProperty(exports, "Error", { enumerable: true, get: function () { return _Error.Error; } });

Object.defineProperty(exports, "Flaw", { enumerable: true, get: function () { return Flaw_1.Flaw; } });

Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return Result_1.Result; } });

exports.success = success;

exports.redirect = redirect;

exports.client = client;

exports.server = server;

});

exports.dist = dist;
