"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseHeaders = void 0;
const tslib_1 = require("tslib");
const ui_kit_1 = require("@stoplight/ui-kit");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const Array_1 = require("fp-ts/lib/Array");
const lodash_1 = require("lodash");
const mobx_react_lite_1 = require("mobx-react-lite");
const React = tslib_1.__importStar(require("react"));
const useRequestMaker_1 = require("../../../hooks/useRequestMaker");
const ViolationsDisplay_1 = require("./ViolationsDisplay");
exports.ResponseHeaders = mobx_react_lite_1.observer(({ className }) => {
    const responseStore = useRequestMaker_1.useRequestMakerStore('response');
    const headers = Object.entries(responseStore.headers);
    if (!headers.length) {
        return React.createElement("div", { className: "text-center p-10 text-gray-6" }, "No response headers");
    }
    const headerViolations = responseStore.violations.filter(v => v.path && v.path[0] === 'header');
    return (React.createElement(React.Fragment, null,
        Array_1.isNonEmpty(headerViolations) && React.createElement(ViolationsDisplay_1.ViolationsDisplay, { violations: headerViolations }),
        React.createElement(ui_kit_1.HTMLTable, { className: classnames_1.default('RequestMaker__ResponseHeaders container', className), striped: true, condensed: true, interactive: true },
            React.createElement("thead", null,
                React.createElement("tr", null,
                    React.createElement("th", null, "Name"),
                    React.createElement("th", null, "Value"))),
            React.createElement("tbody", null, lodash_1.map(headers, ([key, value]) => (React.createElement("tr", { key: key, className: "RequestMaker__ResponseHeader" },
                React.createElement("td", { className: "font-bold" }, key),
                React.createElement("td", null,
                    React.createElement("span", null, value)))))))));
});
exports.ResponseHeaders.displayName = 'RequestMaker.ResponseHeaders';
//# sourceMappingURL=Headers.js.map