import { __assign, __rest } from "tslib";
import React from 'react';
import { Icon, Button } from '@alicloud/console-components';
function Page(props) {
    var returnIcon = function (type) {
        var icon = undefined;
        switch (type) {
            case 'success':
                icon = (React.createElement(Icon, { type: "success", style: { color: '#1DC11D', marginRight: '8px' } }));
                break;
            case 'error':
                icon = (React.createElement(Icon, { type: "error", style: { color: '#FF3333', marginRight: '8px' } }));
                break;
            case 'warning':
                icon = (React.createElement(Icon, { type: "warning", style: { color: '#FFA003', marginRight: '8px' } }));
                break;
            case 'noPower':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1mnLer1H2gK0jSZJnXXaT1FXa-72-72.svg" }));
                break;
            case 'noRule':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1oxV2sEz1gK0jSZLeXXb9kVXa-72-72.svg" }));
                break;
            case 'noEquipment':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1WMpSsEz1gK0jSZLeXXb9kVXa-72-72.svg" }));
                break;
            case 'noContent':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1wUubeW61gK0jSZFlXXXDKFXa-72-72.svg" }));
                break;
            case 'imgFail':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1U9Ydr.Y1gK0jSZFCXXcwqXXa-72-72.svg" }));
                break;
            case 'arrears':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB1bTFQspT7gK0jSZFpXXaTkpXa-72-72.svg" }));
                break;
            case '404':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB16fm.rVY7gK0jSZKzXXaikpXa-72-72.svg" }));
                break;
            case '500':
                icon = (React.createElement("img", { src: "https://img.alicdn.com/tfs/TB13M2Xr7L0gK0jSZFtXXXQCXXa-72-72.svg" }));
                break;
            default:
                icon = undefined;
        }
        return icon;
    };
    var returnButtons = function (buttons) {
        var bts = buttons.map(function (bt, i) {
            var name = bt.name, func = bt.func, btProps = __rest(bt, ["name", "func"]);
            return (React.createElement(Button, __assign({ key: 'ResultPage_' + name + i, type: i === 0 ? 'primary' : 'normal', onClick: func || bt.onClick }, btProps), name));
        });
        return bts;
    };
    var title = props.title, _a = props.content, content = _a === void 0 ? "" : _a, icon = props.icon, _b = props.type, type = _b === void 0 ? 'success' : _b, _c = props.buttons, buttons = _c === void 0 ? [] : _c;
    var onlyTitleAndImg = buttons.length === 0 && content === '';
    return (React.createElement("div", { className: "lp-result-page" },
        React.createElement("ul", { className: "lp-result-page-content", style: { textAlign: onlyTitleAndImg ? 'center' : 'inherit' } },
            React.createElement("li", { className: onlyTitleAndImg ? 'icon-area_' : 'icon-area' }, icon ? icon : returnIcon(type)),
            React.createElement("li", { className: onlyTitleAndImg ? 'show-area_' : 'show-area' },
                React.createElement("h2", null, title),
                React.createElement("p", null, content),
                (buttons && buttons.length > 0) ? React.createElement("div", { className: "button-area" }, returnButtons(buttons)) : null))));
}
function EmptyPage(props) {
    return (React.createElement(Page, __assign({}, props)));
}
Page.empty = EmptyPage;
function ResultPage(props) {
    var firstButtons = props.firstButtons, secondButtons = props.secondButtons, rest = __rest(props, ["firstButtons", "secondButtons"]);
    var buttons = [];
    if (firstButtons) {
        buttons.push(firstButtons);
    }
    if (secondButtons) {
        buttons.push(secondButtons);
    }
    return (React.createElement(Page, __assign({}, rest, { buttons: buttons })));
}
Page.result = ResultPage;
;
function UnususlPage(props) {
    return (React.createElement(Page, __assign({}, props)));
}
Page.unusual = UnususlPage;
export default Page;
