class PersistTabs {
    init() {

        let tabs = jQuery('.main-nav-tabs .nav-link');
        let tabPanes = jQuery('.tab-content .tab-pane');
        
        function clearActiveClasses() {
            tabs.removeClass('active');
            tabPanes.removeClass('show active');
        }
        let activeTabId = localStorage.getItem('activeTabFuse');
        if (activeTabId) {
            clearActiveClasses();
            let activeTab = jQuery(`.nav-tabs .nav-link[data-bs-target="#${activeTabId}"]`);
            let activeTabContent = jQuery(`#${activeTabId}`);
            if (activeTab.length && activeTabContent.length) {
                activeTab.addClass('active');
                activeTabContent.addClass('show active');
            }
        }
        tabs.on('click', function () {
            clearActiveClasses();
            let targetContentId = jQuery(this).attr('data-bs-target').substring(1);
            jQuery(this).addClass('active');
            jQuery(`#${targetContentId}`).addClass('show active');
            localStorage.setItem('activeTabFuse', targetContentId);
        });
    }
}
export default PersistTabs;