"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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const React = __importStar(require("react"));
const Panel_1 = __importDefault(require("react-bootstrap/lib/Panel"));
const Table_1 = __importDefault(require("react-bootstrap/lib/Table"));
const ProgressBar_1 = __importDefault(require("react-bootstrap/lib/ProgressBar"));
const Button_1 = __importDefault(require("react-bootstrap/lib/Button"));
const ButtonGroup_1 = __importDefault(require("react-bootstrap/lib/ButtonGroup"));
const ButtonToolbar_1 = __importDefault(require("react-bootstrap/lib/ButtonToolbar"));
const Overlay_1 = __importDefault(require("react-bootstrap/lib/Overlay"));
const OverlayTrigger_1 = __importDefault(require("react-bootstrap/lib/OverlayTrigger"));
const Popover_1 = __importDefault(require("react-bootstrap/lib/Popover"));
const Tooltip_1 = __importDefault(require("react-bootstrap/lib/Tooltip"));
const Glyphicon_1 = __importDefault(require("react-bootstrap/lib/Glyphicon"));
const Modal_1 = __importDefault(require("react-bootstrap/lib/Modal"));
const Row_1 = __importDefault(require("react-bootstrap/lib/Row"));
const Col_1 = __importDefault(require("react-bootstrap/lib/Col"));
const FormGroup_1 = __importDefault(require("react-bootstrap/lib/FormGroup"));
const InputGroup_1 = __importDefault(require("react-bootstrap/lib/InputGroup"));
const FormControl_1 = __importDefault(require("react-bootstrap/lib/FormControl"));
const ListGroup_1 = __importDefault(require("react-bootstrap/lib/ListGroup"));
const ListGroupItem_1 = __importDefault(require("react-bootstrap/lib/ListGroupItem"));
const Breadcrumb_1 = __importDefault(require("react-bootstrap/lib/Breadcrumb"));
const HelpBlock_1 = __importDefault(require("react-bootstrap/lib/HelpBlock"));
const MenuItem_1 = __importDefault(require("react-bootstrap/lib/MenuItem"));
const Alert_1 = __importDefault(require("react-bootstrap/lib/Alert"));
const Pager_1 = __importDefault(require("react-bootstrap/lib/Pager"));
const Accordion_1 = __importDefault(require("react-bootstrap/lib/Accordion"));
const Collapse_1 = __importDefault(require("react-bootstrap/lib/Collapse"));
const Dropdown_1 = __importDefault(require("react-bootstrap/lib/Dropdown"));
const Form_1 = __importDefault(require("react-bootstrap/lib/Form"));
const ControlLabel_1 = __importDefault(require("react-bootstrap/lib/ControlLabel"));
const Checkbox_1 = __importDefault(require("react-bootstrap/lib/Checkbox"));
const ToggleButton_1 = __importDefault(require("react-bootstrap/lib/ToggleButton"));
const ToggleButtonGroup_1 = __importDefault(require("react-bootstrap/lib/ToggleButtonGroup"));
const mapBtnVariant = (variant) => {
    return variant === null || variant === void 0 ? void 0 : variant.replace("outline-", "");
};
const Panel = React.forwardRef((_a, ref) => {
    var { variant } = _a, props = __rest(_a, ["variant"]);
    return React.createElement(Panel_1.default, Object.assign({}, props, { bsStyle: variant, ref: ref }));
});
const __Panel = Panel;
__Panel.Body = Panel_1.default.Body;
__Panel.Heading = Panel_1.default.Heading;
__Panel.Collapse = Panel_1.default.Collapse;
__Panel.Footer = Panel_1.default.Footer;
// Wrapper needed or webpack will hang.
const _Dropdown = (props) => React.createElement(Dropdown_1.default, Object.assign({}, props));
const __Dropdown = _Dropdown;
__Dropdown.Menu = React.forwardRef((props, ref) => React.createElement(Dropdown_1.default.Menu, Object.assign({}, props, { ref: ref })));
__Dropdown.Menu.defaultProps = { bsRole: "menu" };
__Dropdown.Toggle = React.forwardRef((_a, ref) => {
    var { variant } = _a, props = __rest(_a, ["variant"]);
    return React.createElement(Dropdown_1.default.Toggle, Object.assign({ bsStyle: variant }, props, { ref: ref }));
});
__Dropdown.Toggle.defaultProps = { bsRole: "toggle" };
const _Breadcrumb = Breadcrumb_1.default;
_Breadcrumb.Item = Breadcrumb_1.default.Item;
function usePreviousValue(value) {
    const ref = React.useRef();
    React.useEffect(() => {
        ref.current = value;
    });
    return ref.current;
}
const OverlayTrigger = (props) => {
    const { show } = props, _props = __rest(props, ["show"]);
    const prevShow = usePreviousValue(show);
    const ref = React.useRef();
    React.useEffect(() => {
        if (show && !prevShow) {
            ref.current.show();
        }
        else if (!show && prevShow) {
            ref.current.hide();
        }
    }, [show, prevShow]);
    return (React.createElement(OverlayTrigger_1.default, Object.assign({}, _props, { ref: ref })));
};
const theme = {
    Panel: __Panel,
    Table: Table_1.default,
    ProgressBar: ProgressBar_1.default,
    Button: React.forwardRef((_a, ref) => {
        var { variant, small } = _a, props = __rest(_a, ["variant", "small"]);
        return React.createElement(Button_1.default, Object.assign({}, props, { bsStyle: mapBtnVariant(variant), bsSize: small ? "small" : undefined, ref: ref }));
    }),
    ButtonGroup: ButtonGroup_1.default,
    ButtonToolbar: ButtonToolbar_1.default,
    Overlay: Overlay_1.default,
    OverlayTrigger,
    // OverlayTrigger: React.forwardRef<OverlayTrigger, OverlayTriggerProps>(({show, ...props}, ref) => <OverlayTrigger {...props} ref={ref} />),
    Popover: Popover_1.default,
    Tooltip: Tooltip_1.default,
    Glyphicon: Glyphicon_1.default,
    Modal: Modal_1.default,
    Row: Row_1.default,
    Col: Col_1.default,
    FormGroup: FormGroup_1.default,
    InputGroup: InputGroup_1.default,
    FormControl: FormControl_1.default,
    ListGroup: ListGroup_1.default,
    ListGroupItem: ListGroupItem_1.default,
    Breadcrumb: _Breadcrumb,
    HelpBlock: HelpBlock_1.default,
    MenuItem: MenuItem_1.default,
    Alert: (_a) => {
        var { variant } = _a, props = __rest(_a, ["variant"]);
        return React.createElement(Alert_1.default, Object.assign({}, props, { bsStyle: variant }));
    },
    Pager: Pager_1.default,
    Accordion: Accordion_1.default,
    Collapse: Collapse_1.default,
    Dropdown: __Dropdown,
    Form: Form_1.default,
    ControlLabel: ControlLabel_1.default,
    Checkbox: Checkbox_1.default,
    ToggleButton: ToggleButton_1.default,
    ToggleButtonGroup: ToggleButtonGroup_1.default,
    // Radio
};
exports.default = theme;
