"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RequestedData = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var LinearLoadIndicator_1 = require("../LinearLoadIndicator");
var EmptySearchResult_1 = require("../EmptySearchResult");
var ErrorBoundary_1 = require("../ErrorBoundary");
var EmptyState_1 = require("../EmptyState");
var types_1 = require("../types");
var RequestedData_module_css_1 = __importDefault(require("./RequestedData.module.css"));
var RequestedData = function (_a) {
    var requestState = _a.requestState, isResponseEmpty = _a.isResponseEmpty, children = _a.children, DataLoadedComponent = _a.DataLoadedComponent, _b = _a.DataLoadingComponent, DataLoadingComponent = _b === void 0 ? RequestedDataLoading : _b, _c = _a.DataErrorComponent, DataErrorComponent = _c === void 0 ? RequestedDataError : _c;
    switch (requestState) {
        case types_1.RequestStates.LOADED:
            return DataLoadedComponent ? (react_1.default.createElement(DataLoadedComponent, null)) : (react_1.default.createElement(RequestedDataLoaded, { isResponseEmpty: isResponseEmpty }, children));
        case types_1.RequestStates.ERROR:
            return react_1.default.createElement(DataErrorComponent, null);
        case types_1.RequestStates.LOADING:
        default:
            return react_1.default.createElement(DataLoadingComponent, null);
    }
};
exports.RequestedData = RequestedData;
var RequestedDataError = function () { return (react_1.default.createElement(EmptyState_1.EmptyState, { LogoRenderer: EmptyState_1.EMPTY_STATE_ICONS.ERROR, text: ui_i18n_1.default.text('Something went wrong'), variant: EmptyState_1.EMPTY_STATE_VARIANTS.full })); };
var RequestedDataLoaded = function (_a) {
    var isResponseEmpty = _a.isResponseEmpty, children = _a.children;
    return isResponseEmpty ? (react_1.default.createElement(EmptySearchResult_1.EmptySearchResult, { variant: "noData", className: RequestedData_module_css_1.default.noData })) : (react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { error: react_1.default.createElement(RequestedDataError, null) }, children));
};
var RequestedDataLoading = function () { return react_1.default.createElement(LinearLoadIndicator_1.LinearLoadIndicator, null); };
