import Tooltip from "bootstrap/js/src/tooltip";
import Dropdown from "bootstrap/js/src/dropdown";
import Collapse from "bootstrap/js/src/collapse";
import Modal from "bootstrap/js/src/modal";
import Tab from "bootstrap/js/src/tab";

export default function () {
    applyBootstrapPlugin('[data-bs-toggle="tooltip"]', Tooltip, 'Tooltip');
    applyBootstrapPlugin('[data-bs-toggle="dropdown"]', Dropdown, 'Dropdown');
    applyBootstrapPlugin('[data-bs-toggle="collapse"]', Collapse, 'Collapse');
    applyBootstrapPlugin('div.modal', Modal, 'Modal');
    applyBootstrapPlugin('[data-bs-toggle="tab"]', Tab, 'Tab');
}

function applyBootstrapPlugin(selector, plugin, name) {
    let els = document.querySelectorAll(selector);
    els.forEach((el) => {
        let key = 'aaBootstrap' + name;
        el[key] = new plugin(el);
    });
}
