const rbxTabControls=[];
const stacks=document.querySelectorAll(".rbx-stack");
stacks.forEach((stack, index)=> {
const tabTitles=stack.querySelectorAll(".rbx-stack-tab-title");
const tabs=stack.querySelectorAll(".rbx-stack-cards .rbx-stack-tab");
const glows=stack.querySelectorAll(".rbx-stack-glow-container .rbx-stack-tab",
);
const autoChangeInterval = !!stack.dataset.autochange
? parseInt(stack.dataset.autochange)
: -1;
const isAutoChange=autoChangeInterval > 0;
stack.dataset.activeIndex=0;
if(isAutoChange){
let autoChangeIndex=0;
const autoChange=()=> {
if(!!stack.dataset.manuallyChanged){
return;
}
if(autoChangeIndex > tabTitles.length){
autoChangeIndex=0;
}
tabs.forEach((tab)=> {
tab.classList.remove("persist-active");
});
tabs[autoChangeIndex].classList.add("persist-active");
glows.forEach((glow)=> {
glow.classList.remove("persist-active");
});
glows[autoChangeIndex].classList.add("persist-active");
tabTitles.forEach((tabTitle)=> {
tabTitle.classList.remove("persist-active");
});
if(autoChangeIndex > 0){
tabTitles[autoChangeIndex - 1].classList.add("persist-active");
}
autoChangeIndex +=1;
};
const autoChangeIntervalId=setInterval(autoChange, autoChangeInterval);
}
tabTitles.forEach((tabTitle, index)=> {
tabTitle.addEventListener("mouseenter", ()=> {
tabs.forEach((tab)=> {
tab.classList.remove("active");
});
tabs[index + 1].classList.add("active");
glows.forEach((glow)=> {
glow.classList.remove("active");
});
glows[index + 1].classList.add("active");
});
tabTitle.addEventListener("mouseleave", ()=> {
tabs.forEach((tab)=> {
tab.classList.remove("active");
});
tabs[0].classList.add("active");
glows.forEach((glow)=> {
glow.classList.remove("active");
});
glows[0].classList.add("active");
});
tabTitle.addEventListener("click", (e)=> {
if(!tabTitle.dataset.isdirect){
e.preventDefault();
}
let deactivate=false;
if(tabTitle.classList.contains("persist-active")){
deactivate=true;
}
tabTitles.forEach((tabTitle)=> {
tabTitle.classList.remove("active");
tabTitle.classList.remove("persist-active");
});
tabs.forEach((tab)=> {
tab.classList.remove("active");
tab.classList.remove("persist-active");
});
glows.forEach((glow)=> {
glow.classList.remove("active");
glow.classList.remove("persist-active");
});
if(deactivate){
return;
}
tabTitle.classList.add("persist-active");
tabs[index + 1].classList.add("persist-active");
glows[index + 1].classList.add("persist-active");
stack.dataset.activeIndex=index + 1;
});
});
document.addEventListener("click", (event)=> {
if(!stack.contains(event.target)){
tabTitles.forEach((tabTitle)=> {
tabTitle.classList.remove("active");
tabTitle.classList.remove("persist-active");
});
tabs.forEach((tab)=> {
tab.classList.remove("active");
tab.classList.remove("persist-active");
});
glows.forEach((glow)=> {
glow.classList.remove("active");
glow.classList.remove("persist-active");
});
}
stack.dataset.manuallyChanged=1;
});
stack.classList.add("active");
});