"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
const React = __importStar(require("react"));
const react_bootstrap_5_1 = require("react-bootstrap-5");
const react_fontawesome_1 = require("@fortawesome/react-fontawesome");
const glyphicon_fa_mapping_1 = require("./glyphicon-fa-mapping");
const utils_1 = require("../utils");
const mapAnyVariant = (variant, defaultVariant = "outline-secondary") => {
    if (!variant || variant === "default") {
        return defaultVariant;
    }
    return variant;
};
const mapVariant = (variant, defaultVariant) => {
    return mapAnyVariant(variant, defaultVariant);
};
const mapBtnVariant = (variant, defaultVariant) => {
    return mapAnyVariant(variant, defaultVariant);
};
const mapValidationStateToClass = (validationState) => {
    if (!validationState) {
        return "";
    }
    return "text-" + (validationState === "error" ? "danger" : validationState);
};
const _Card = React.forwardRef((_a, ref) => {
    var { eventKey } = _a, props = __rest(_a, ["eventKey"]);
    return (React.createElement(react_bootstrap_5_1.Card, Object.assign({}, props, { ref: ref })));
});
let Panel = _Card;
Panel.Body = react_bootstrap_5_1.Card.Body;
Panel.Heading = React.forwardRef((props, ref) => (React.createElement(react_bootstrap_5_1.Card.Header, Object.assign({ className: "panel-heading" }, props, { ref: ref }))));
Panel.Collapse = React.forwardRef((_a, ref) => {
    var { children } = _a, props = __rest(_a, ["children"]);
    return (React.createElement(react_bootstrap_5_1.Collapse, Object.assign({}, props, { ref: ref }),
        React.createElement("div", null, children)) // animations don't work if children are not wrapped to div
    );
});
Panel.Footer = react_bootstrap_5_1.Card.Footer;
const Glyphicon = React.forwardRef((_a, ref) => {
    var { glyph } = _a, props = __rest(_a, ["glyph"]);
    return (React.createElement(react_fontawesome_1.FontAwesomeIcon, Object.assign({ className: "glyphicon", icon: glyphicon_fa_mapping_1.mapping[glyph] }, props, { ref: ref })));
});
const _Modal = react_bootstrap_5_1.Modal;
const _InputGroup = react_bootstrap_5_1.InputGroup;
_InputGroup.Addon = react_bootstrap_5_1.InputGroup.Text;
_InputGroup.Button = React.forwardRef((props, ref) => (React.createElement("span", Object.assign({}, props, { ref: ref }))));
const _Dropdown = react_bootstrap_5_1.Dropdown;
_Dropdown.Menu = react_bootstrap_5_1.Dropdown.Menu;
_Dropdown.Toggle = React.forwardRef((_a, ref) => {
    var { variant } = _a, props = __rest(_a, ["variant"]);
    return (React.createElement(react_bootstrap_5_1.Dropdown.Toggle, Object.assign({ variant: mapVariant(variant) }, props, { ref: ref })));
});
const _Popover = React.forwardRef((_a, ref) => {
    var { children } = _a, props = __rest(_a, ["children"]);
    return (React.createElement(react_bootstrap_5_1.Popover, Object.assign({}, props, { ref: ref }),
        props.title ? React.createElement(react_bootstrap_5_1.Popover.Header, null, props.title) : null,
        React.createElement(react_bootstrap_5_1.Popover.Body, null, children)));
});
const _Pager = react_bootstrap_5_1.Pagination;
_Pager.Item = React.forwardRef((_a, ref) => {
    var { previous, next } = _a, props = __rest(_a, ["previous", "next"]);
    return (React.createElement(react_bootstrap_5_1.PageItem, Object.assign({}, props, { ref: ref })));
});
const theme = {
    Panel,
    Table: react_bootstrap_5_1.Table,
    ProgressBar: react_bootstrap_5_1.ProgressBar,
    Button: React.forwardRef((_a, ref) => {
        var { variant, small } = _a, props = __rest(_a, ["variant", "small"]);
        return React.createElement(react_bootstrap_5_1.Button, Object.assign({}, props, { variant: mapBtnVariant(variant), size: small ? "sm" : undefined, ref: ref }));
    }),
    ButtonGroup: react_bootstrap_5_1.ButtonGroup,
    ButtonToolbar: react_bootstrap_5_1.ButtonToolbar,
    Overlay: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Overlay, Object.assign({}, props, { ref: ref }))),
    OverlayTrigger: (props) => React.createElement(react_bootstrap_5_1.OverlayTrigger, Object.assign({}, props)),
    Popover: _Popover,
    Tooltip: react_bootstrap_5_1.Tooltip,
    Glyphicon,
    Modal: _Modal,
    Row: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Row, Object.assign({}, props, { ref: ref }))),
    Col: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Col, Object.assign({}, props, { ref: ref }))),
    FormGroup: React.forwardRef((_a, ref) => {
        var { validationState, className } = _a, props = __rest(_a, ["validationState", "className"]);
        return React.createElement(react_bootstrap_5_1.FormGroup, Object.assign({}, props, { className: (0, utils_1.classNames)(className, mapValidationStateToClass(validationState)), ref: ref }));
    }),
    InputGroup: _InputGroup,
    FormControl: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.FormControl, Object.assign({}, props, { ref: ref }))),
    ListGroup: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.ListGroup, Object.assign({ variant: "flush" }, props, { ref: ref }))),
    ListGroupItem: React.forwardRef((_a, ref) => {
        var { onClick } = _a, props = __rest(_a, ["onClick"]);
        return React.createElement(react_bootstrap_5_1.ListGroupItem, Object.assign({ action: !!onClick, onClick: onClick }, props, { ref: ref }));
    }),
    Breadcrumb: react_bootstrap_5_1.Breadcrumb,
    HelpBlock: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Form.Text, Object.assign({}, props, { ref: ref }))),
    MenuItem: react_bootstrap_5_1.Dropdown.Item,
    Alert: React.forwardRef((_a, ref) => {
        var { variant } = _a, props = __rest(_a, ["variant"]);
        return React.createElement(react_bootstrap_5_1.Alert, Object.assign({ variant: mapVariant(variant) }, props, { ref: ref }));
    }),
    Pager: _Pager,
    Accordion: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.Accordion, Object.assign({}, props, { ref: ref }))),
    Collapse: react_bootstrap_5_1.Collapse,
    Dropdown: _Dropdown,
    Form: react_bootstrap_5_1.Form,
    ControlLabel: react_bootstrap_5_1.Form.Label,
    Checkbox: react_bootstrap_5_1.Form.Check,
    ToggleButton: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.ToggleButton, Object.assign({ variant: "outline-secondary" }, props, { ref: ref }))),
    ToggleButtonGroup: React.forwardRef((props, ref) => React.createElement(react_bootstrap_5_1.ToggleButtonGroup, Object.assign({}, props, { ref: ref })))
};
exports.default = theme;
