"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.__tsfTypeAliases = exports.Redirect = exports.RawResponseResult = exports.EmptyResponseResult = exports.RedirectResponseResult = exports.JsonResponseResult = exports.NodeHttpResponse = exports.MemoryHttpResponse = exports.HttpResponse = void 0;
exports.jsonResponse = jsonResponse;
exports.redirectResponse = redirectResponse;
exports.emptyResponse = emptyResponse;
exports.rawResponse = rawResponse;
exports.isHttpResponseResult = isHttpResponseResult;
const tslib_1 = require("tslib");
const _a = tslib_1.__importStar(require("@zyno-io/ts-server-foundation/type-metadata-runtime"));
const node_stream_1 = require("node:stream");
const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":2},{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":14,\"type\":{\"kind\":6}},{\"kind\":4}]},{\"kind\":7},{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}],\"index\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},\"types\":[],\"typeName\":\"HttpHeaderOutput\"},{\"kind\":14,\"type\":{\"kind\":15,\"types\":[{\"type\":{\"kind\":6}},{\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}}]}}],\"typeName\":\"HttpWriteHeadHeaders\"},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}],\"index\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},\"types\":[],\"typeName\":\"HttpHeaderOutput\"},{\"kind\":14,\"type\":{\"kind\":15,\"types\":[{\"type\":{\"kind\":6}},{\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}}]}}],\"typeName\":\"HttpWriteHeadHeaders\"}]},{\"kind\":3},{\"kind\":2,\"typeName\":\"(error?: Error | null) =\\u003e void\"},{\"kind\":1},{\"kind\":8},{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"statusCode\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"contentType\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"headers\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}],\"index\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},\"types\":[]},{\"kind\":4}]},\"optional\":true}]}]]", []);
let _HttpResponseMetadata_1;
class HttpResponse extends node_stream_1.Writable {
    statusCodeValue = 200;
    chunks = [];
    headerMap = new Map();
    get statusCode() {
        return this.statusCodeValue;
    }
    set statusCode(value) {
        this.statusCodeValue = value;
    }
    setHeader(name, value) {
        this.headerMap.set(name.toLowerCase(), Array.isArray(value) ? value.map(String) : String(value));
        return this;
    }
    getHeader(name) {
        return this.headerMap.get(name.toLowerCase());
    }
    get headers() {
        return Object.fromEntries([...this.headerMap.entries()].map(([name, value]) => [name, Array.isArray(value) ? value.join(', ') : value]));
    }
    get rawHeaders() {
        return Object.fromEntries(this.headerMap.entries());
    }
    get headersSent() {
        return false;
    }
    get socket() {
        return undefined;
    }
    writeHead(statusCode, statusMessageOrHeaders, headers) {
        this.statusCode = statusCode;
        for (const [name, value] of normalizeWriteHeadHeaders(typeof statusMessageOrHeaders === 'string' ? headers : statusMessageOrHeaders)) {
            this.setHeader(name, value);
        }
        return this;
    }
    flushHeaders() { }
    redirect(url, statusCode = 302) {
        this.statusCode = statusCode;
        this.setHeader('location', url);
        this.end();
    }
    get body() {
        return Buffer.concat(this.chunks);
    }
    get status() {
        return this.statusCode;
    }
    get text() {
        return this.body.toString();
    }
    get bodyString() {
        return this.text;
    }
    get json() {
        return JSON.parse(this.text);
    }
    /** @internal Keep in-memory observations consistent with Node's HEAD response semantics. */
    discardBody() {
        this.chunks = [];
    }
    _write(chunk, _encoding, callback) {
        this.chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
        callback();
    }
    static __tsfType = _HttpResponseMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"HttpResponse\",\"typeName\":\"HttpResponse\",\"classType\":{\"$tsf\":0},\"properties\":[{\"name\":\"statusCodeValue\",\"type\":{\"$tsfType\":0},\"optional\":false},{\"name\":\"chunks\",\"type\":{\"kind\":14,\"type\":{\"kind\":16,\"typeName\":\"Buffer\",\"classType\":{\"$tsf\":1}}},\"optional\":false},{\"name\":\"headerMap\",\"type\":{\"$tsfType\":0},\"optional\":false}],\"methods\":[{\"name\":\"setHeader\",\"parameters\":[{\"name\":\"name\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"value\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":2}}},{\"name\":\"getHeader\",\"parameters\":[{\"name\":\"name\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":3}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":2}}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"statusMessage\",\"type\":{\"$tsfType\":1},\"optional\":true,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":2}}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"statusMessageOrHeaders\",\"type\":{\"$tsfType\":6},\"optional\":true,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":2}}},{\"name\":\"flushHeaders\",\"parameters\":[],\"returnType\":{\"$tsfType\":7}},{\"name\":\"redirect\",\"parameters\":[{\"name\":\"url\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"statusCode\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"discardBody\",\"parameters\":[],\"returnType\":{\"$tsfType\":7}},{\"name\":\"_write\",\"parameters\":[{\"name\":\"chunk\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Buffer\",\"classType\":{\"$tsf\":1}},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"_encoding\",\"type\":{\"kind\":16,\"typeName\":\"BufferEncoding\",\"classType\":{\"$tsf\":3}},\"optional\":false,\"default\":false},{\"name\":\"callback\",\"type\":{\"$tsfType\":8},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":false,\"constructorParameters\":[]}]", [() => HttpResponse, () => (typeof Buffer !== "undefined" ? Buffer : (typeof exports !== "undefined" ? exports.Buffer : undefined)), () => (typeof this !== "undefined" ? this : (typeof exports !== "undefined" ? exports.this : undefined)), () => (typeof BufferEncoding !== "undefined" ? BufferEncoding : (typeof exports !== "undefined" ? exports.BufferEncoding : undefined))], __tsf_metadata_type);
}
exports.HttpResponse = HttpResponse;
_HttpResponseMetadata_1.classType = HttpResponse;
HttpResponse.__tsfType = _HttpResponseMetadata_1;
let _MemoryHttpResponseMetadata_1;
class MemoryHttpResponse extends HttpResponse {
    static __tsfType = _MemoryHttpResponseMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"MemoryHttpResponse\",\"typeName\":\"MemoryHttpResponse\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[],\"hasConstructor\":false,\"constructorParameters\":[]}]", [() => MemoryHttpResponse], __tsf_metadata_type);
}
exports.MemoryHttpResponse = MemoryHttpResponse;
_MemoryHttpResponseMetadata_1.classType = MemoryHttpResponse;
MemoryHttpResponse.__tsfType = _MemoryHttpResponseMetadata_1;
let _NodeHttpResponseMetadata_1;
class NodeHttpResponse extends HttpResponse {
    outgoing;
    committed = false;
    streaming = false;
    constructor(outgoing) {
        super();
        this.outgoing = outgoing;
        this.statusCode = outgoing.statusCode || 200;
        outgoing.once('finish', () => this.emit('finish'));
        outgoing.once('close', () => {
            this.emit('close');
        });
    }
    get headersSent() {
        return this.committed || this.outgoing.headersSent;
    }
    get socket() {
        return this.outgoing.socket ?? undefined;
    }
    setHeader(name, value) {
        if (this.headersSent)
            return this;
        return super.setHeader(name, value);
    }
    writeHead(statusCode, statusMessageOrHeaders, headers) {
        if (this.headersSent)
            return this;
        return super.writeHead(statusCode, statusMessageOrHeaders, headers);
    }
    write(chunk, encoding, callback) {
        this.streaming = true;
        if (this.chunks.length) {
            this.commitHeaders();
            for (const buffered of this.chunks.splice(0))
                this.outgoing.write(buffered);
        }
        return super.write(chunk, encoding, callback);
    }
    _write(chunk, encoding, callback) {
        if (!this.streaming) {
            this.chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding));
            callback();
            return;
        }
        this.commitHeaders();
        this.outgoing.write(chunk, encoding, callback);
    }
    _final(callback) {
        if (!this.streaming) {
            callback();
            return;
        }
        if (this.outgoing.writableEnded) {
            callback();
            return;
        }
        this.commitHeaders();
        this.outgoing.end(callback);
    }
    destroy(error) {
        if (error && !this.outgoing.destroyed)
            this.outgoing.destroy(error);
        return super.destroy(error);
    }
    redirect(url, statusCode = 302) {
        this.statusCode = statusCode;
        this.setHeader('location', url);
        this.end();
    }
    flush() {
        if (this.headersSent)
            return;
        this.commitHeaders();
        this.outgoing.end(this.body);
    }
    flushHeaders() {
        if (this.headersSent)
            return;
        this.streaming = true;
        this.commitHeaders();
        this.outgoing.flushHeaders();
    }
    commitHeaders() {
        if (this.headersSent)
            return;
        this.outgoing.statusCode = this.statusCode;
        for (const [name, value] of Object.entries(this.rawHeaders))
            this.outgoing.setHeader(name, value);
        this.committed = true;
    }
    static __tsfType = _NodeHttpResponseMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"NodeHttpResponse\",\"typeName\":\"NodeHttpResponse\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"setHeader\",\"parameters\":[{\"name\":\"name\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"value\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":1}}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":1}}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"statusMessage\",\"type\":{\"$tsfType\":1},\"optional\":true,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":1}}},{\"name\":\"writeHead\",\"parameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false},{\"name\":\"statusMessageOrHeaders\",\"type\":{\"$tsfType\":6},\"optional\":true,\"default\":false},{\"name\":\"headers\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":1}}},{\"name\":\"write\",\"parameters\":[{\"name\":\"chunk\",\"type\":{\"$tsfType\":9},\"optional\":false,\"default\":false},{\"name\":\"encoding\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"BufferEncoding\",\"classType\":{\"$tsf\":2}},{\"kind\":2,\"typeName\":\"(error?: Error | null) =\\u003e void\"}]},\"optional\":true,\"default\":false},{\"name\":\"callback\",\"type\":{\"$tsfType\":8},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":10}},{\"name\":\"_write\",\"parameters\":[{\"name\":\"chunk\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Buffer\",\"classType\":{\"$tsf\":3}},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"encoding\",\"type\":{\"kind\":16,\"typeName\":\"BufferEncoding\",\"classType\":{\"$tsf\":2}},\"optional\":false,\"default\":false},{\"name\":\"callback\",\"type\":{\"$tsfType\":8},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"_final\",\"parameters\":[{\"name\":\"callback\",\"type\":{\"$tsfType\":8},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"destroy\",\"parameters\":[{\"name\":\"error\",\"type\":{\"kind\":16,\"typeName\":\"Error\",\"classType\":{\"$tsf\":4}},\"optional\":true,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"this\",\"classType\":{\"$tsf\":1}}},{\"name\":\"redirect\",\"parameters\":[{\"name\":\"url\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"statusCode\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"flush\",\"parameters\":[],\"returnType\":{\"$tsfType\":7}},{\"name\":\"flushHeaders\",\"parameters\":[],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"outgoing\",\"type\":{\"$tsfAlias\":[5,\"node:http\",\"ServerResponse\",\"ServerResponse\"]},\"optional\":false,\"default\":false}]}]", [() => NodeHttpResponse, () => (typeof this !== "undefined" ? this : (typeof exports !== "undefined" ? exports.this : undefined)), () => (typeof BufferEncoding !== "undefined" ? BufferEncoding : (typeof exports !== "undefined" ? exports.BufferEncoding : undefined)), () => (typeof Buffer !== "undefined" ? Buffer : (typeof exports !== "undefined" ? exports.Buffer : undefined)), () => (typeof Error !== "undefined" ? Error : (typeof exports !== "undefined" ? exports.Error : undefined)), require], __tsf_metadata_type);
}
exports.NodeHttpResponse = NodeHttpResponse;
_NodeHttpResponseMetadata_1.classType = NodeHttpResponse;
NodeHttpResponse.__tsfType = _NodeHttpResponseMetadata_1;
function normalizeWriteHeadHeaders(headers) {
    if (!headers)
        return [];
    return Array.isArray(headers) ? headers : Object.entries(headers);
}
let _JsonResponseResultMetadata_1;
class JsonResponseResult {
    value;
    statusCode;
    constructor(value, statusCode = 200) {
        this.value = value;
        this.statusCode = statusCode;
    }
    writeTo(response) {
        response.statusCode = this.statusCode;
        response.setHeader('content-type', 'application/json');
        response.end(JSON.stringify(this.value));
    }
    static __tsfType = _JsonResponseResultMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"JsonResponseResult\",\"typeName\":\"JsonResponseResult\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"writeTo\",\"parameters\":[{\"name\":\"response\",\"type\":{\"kind\":16,\"typeName\":\"HttpResponse\",\"classType\":{\"$tsf\":1}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"value\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false},{\"name\":\"statusCode\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}]}]", [() => JsonResponseResult, () => (typeof HttpResponse !== "undefined" ? HttpResponse : (typeof exports !== "undefined" ? exports.HttpResponse : undefined))], __tsf_metadata_type);
}
exports.JsonResponseResult = JsonResponseResult;
_JsonResponseResultMetadata_1.classType = JsonResponseResult;
JsonResponseResult.__tsfType = _JsonResponseResultMetadata_1;
let _RedirectResponseResultMetadata_1;
class RedirectResponseResult {
    url;
    statusCode;
    constructor(url, statusCode = 302) {
        this.url = url;
        this.statusCode = statusCode;
    }
    writeTo(response) {
        response.redirect(this.url, this.statusCode);
    }
    static __tsfType = _RedirectResponseResultMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"RedirectResponseResult\",\"typeName\":\"RedirectResponseResult\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"writeTo\",\"parameters\":[{\"name\":\"response\",\"type\":{\"kind\":16,\"typeName\":\"HttpResponse\",\"classType\":{\"$tsf\":1}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"url\",\"type\":{\"$tsfType\":1},\"optional\":false,\"default\":false},{\"name\":\"statusCode\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}]}]", [() => RedirectResponseResult, () => (typeof HttpResponse !== "undefined" ? HttpResponse : (typeof exports !== "undefined" ? exports.HttpResponse : undefined))], __tsf_metadata_type);
}
exports.RedirectResponseResult = RedirectResponseResult;
_RedirectResponseResultMetadata_1.classType = RedirectResponseResult;
RedirectResponseResult.__tsfType = _RedirectResponseResultMetadata_1;
let _EmptyResponseResultMetadata_1;
class EmptyResponseResult {
    statusCode;
    constructor(statusCode = 204) {
        this.statusCode = statusCode;
    }
    writeTo(response) {
        response.statusCode = this.statusCode;
        response.end();
    }
    static __tsfType = _EmptyResponseResultMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"EmptyResponseResult\",\"typeName\":\"EmptyResponseResult\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"writeTo\",\"parameters\":[{\"name\":\"response\",\"type\":{\"kind\":16,\"typeName\":\"HttpResponse\",\"classType\":{\"$tsf\":1}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"statusCode\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}]}]", [() => EmptyResponseResult, () => (typeof HttpResponse !== "undefined" ? HttpResponse : (typeof exports !== "undefined" ? exports.HttpResponse : undefined))], __tsf_metadata_type);
}
exports.EmptyResponseResult = EmptyResponseResult;
_EmptyResponseResultMetadata_1.classType = EmptyResponseResult;
EmptyResponseResult.__tsfType = _EmptyResponseResultMetadata_1;
let _RawResponseResultMetadata_1;
class RawResponseResult {
    body;
    options;
    constructor(body, options = {}) {
        this.body = body;
        this.options = options;
    }
    writeTo(response) {
        response.statusCode = this.options.statusCode ?? response.statusCode;
        if (this.options.contentType)
            response.setHeader('content-type', this.options.contentType);
        for (const [name, value] of Object.entries(this.options.headers ?? {}))
            response.setHeader(name, value);
        response.end(this.body);
    }
    static __tsfType = _RawResponseResultMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"RawResponseResult\",\"typeName\":\"RawResponseResult\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[{\"name\":\"writeTo\",\"parameters\":[{\"name\":\"response\",\"type\":{\"kind\":16,\"typeName\":\"HttpResponse\",\"classType\":{\"$tsf\":1}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"body\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":16,\"typeName\":\"Buffer\",\"classType\":{\"$tsf\":2}}]},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":11},\"optional\":true,\"default\":true}]}]", [() => RawResponseResult, () => (typeof HttpResponse !== "undefined" ? HttpResponse : (typeof exports !== "undefined" ? exports.HttpResponse : undefined)), () => (typeof Buffer !== "undefined" ? Buffer : (typeof exports !== "undefined" ? exports.Buffer : undefined))], __tsf_metadata_type);
}
exports.RawResponseResult = RawResponseResult;
_RawResponseResultMetadata_1.classType = RawResponseResult;
RawResponseResult.__tsfType = _RawResponseResultMetadata_1;
function jsonResponse(value, statusCode = 200) {
    return new JsonResponseResult(value, statusCode);
}
function redirectResponse(url, statusCode = 302) {
    return new RedirectResponseResult(url, statusCode);
}
let _RedirectMetadata_1;
class Redirect {
    static toUrl(url, statusCode = 302) {
        return redirectResponse(url, statusCode);
    }
    static __tsfType = _RedirectMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"Redirect\",\"typeName\":\"Redirect\",\"classType\":{\"$tsf\":0},\"properties\":[],\"methods\":[],\"hasConstructor\":false,\"constructorParameters\":[]}]", [() => Redirect], __tsf_metadata_type);
}
exports.Redirect = Redirect;
_RedirectMetadata_1.classType = Redirect;
Redirect.__tsfType = _RedirectMetadata_1;
function emptyResponse(statusCode = 204) {
    return new EmptyResponseResult(statusCode);
}
function rawResponse(body, options = {}) {
    return new RawResponseResult(body, options);
}
function isHttpResponseResult(value) {
    return !!value && typeof value === 'object' && typeof value.writeTo === 'function';
}
exports.__tsfTypeAliases = _a.decodeCompactMetadataV1("[1,{\"HttpHeaderOutput\":{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}],\"index\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},\"types\":[],\"typeName\":\"HttpHeaderOutput\"},\"HttpResponseResult\":{\"kind\":18,\"typeName\":\"HttpResponseResult\",\"types\":[]},\"HttpWriteHeadHeaders\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"Record\",\"utilityType\":\"Record\",\"typeArguments\":[{\"kind\":6},{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}],\"index\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]},\"types\":[],\"typeName\":\"HttpHeaderOutput\"},{\"kind\":14,\"type\":{\"kind\":15,\"types\":[{\"type\":{\"kind\":6}},{\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":6}}]}}]}}],\"typeName\":\"HttpWriteHeadHeaders\"}}]", [], __tsf_metadata_type);
//# sourceMappingURL=response.js.map