"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
class Respond extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['url', 'body', 'status', 'headers'],
            fo: [],
            o: ['done'],
        }, {
            input: {
                body: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_RESPOND);
    }
    async f({ url, status, headers, body }, done, fail) {
        const { cache: { responses }, } = this.__system;
        const waiter = responses[url];
        if (!waiter) {
            fail('could not find request');
            return;
        }
        const raw = await body.raw();
        const ok = status >= 200 && status < 300;
        const type = 'basic';
        waiter.set({
            status,
            statusText: 'OK',
            headers,
            body: raw,
            redirected: false,
            bodyUsed: false,
            ok,
            url,
            type,
        });
        done();
    }
    b() {
        this._output.done.push(true);
    }
}
exports.default = Respond;
//# sourceMappingURL=index.js.map