"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseStatus = void 0;
const tslib_1 = require("tslib");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const mobx_react_lite_1 = require("mobx-react-lite");
const React = tslib_1.__importStar(require("react"));
const constants_1 = require("../../../constants");
const useRequestMaker_1 = require("../../../hooks/useRequestMaker");
const http_1 = require("../../../utils/http");
exports.ResponseStatus = mobx_react_lite_1.observer(({ className }) => {
    const { statusCode, error } = useRequestMaker_1.useRequestMakerStore('response');
    if (statusCode === 0 && !error) {
        return null;
    }
    const color = statusCode !== undefined ? http_1.getHttpCodeColor(statusCode) : '';
    const errorMessage = error ? 'Network error' : '';
    return (React.createElement("div", { className: classnames_1.default('RequestMaker__ResponseStatus', className) },
        React.createElement("div", { className: "flex items-center my-2 text-xl font-bold" },
            React.createElement("div", { className: classnames_1.default('flex h-8 items-center mr-6 px-3 rounded text-white', `bg-${color} dark:bg-${color}`) }, statusCode !== 0 ? statusCode : 'ERR'),
            React.createElement("div", null, errorMessage || constants_1.HttpCodeDescriptions[statusCode] || '')),
        error && (React.createElement("div", { className: "px-3 py-2 mt-3 rounded bg-darken-2 text-darken-7 dark:text-gray-6" },
            "The API did not return a response. Is it running and accessible? If you are sending this request from a web browser, does the API support",
            ' ',
            React.createElement("a", { target: "_blank", rel: "noopener noreferrer", className: "font-semibold text-darken-7 dark:text-gray-6", href: "https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" }, "CORS"),
            "?"))));
});
//# sourceMappingURL=Status.js.map