function simulateClick(element) {
const clickEvent = new MouseEvent('click', { bubbles: true });
element.dispatchEvent(clickEvent);
}
const tabs = document.querySelectorAll('.bde-tabs__tab,.bde-accordion__button,.bde-
faq__question');
tabs.forEach((tab) => {
tab.addEventListener('click', () => {
const newHash = `/#${tab.id}`;
history.replaceState({}, '', newHash);
});
});
window.addEventListener('popstate', () => {
const currentHash = window.location.hash;
if (currentHash && currentHash !== '#') {
const tabId = currentHash.substring(1);
const targetTabButton = document.getElementById(tabId);
if (targetTabButton) {
simulateClick(targetTabButton);
}
}
});
const hashChangeHandler = () => {
const hash = window.location.hash.slice(1);
const targetTabButton = document.getElementById(hash);
simulateClick(targetTabButton);
};
if (window.location.hash) {
setTimeout(() => {
hashChangeHandler();
}, 0);
}
window.addEventListener('hashchange', hashChangeHandler);