;
    tabPanes.forEach(tabPane => {
      const match = tabPane.id.match(/^tabset-(\d+)/);
      if (match) {
        const number = parseInt(match[1], 10);
        if (number > maxTabsetNumber) {
          maxTabsetNumber = number;
        }
      }
    });
    return maxTabsetNumber;
  }
  

  // Function to update TOC when tab changes
  function updateActiveTabTOC() {
    const maxTabsetNumber = getMaxTabsetNumber();
    const activeTab = document.querySelector(`.tab-pane[id^="tabset-${maxTabsetNumber}"]