(function(){
'use strict';
const TABLE_STATE=new WeakMap();
const px=value=> `${Math.round(value)}px`;
function copyCellStyle(source, target){
const style=getComputedStyle(source);
[
'background-color','color','font-family','font-size','font-weight','font-style',
'line-height','letter-spacing','text-align','vertical-align','padding-top',
'padding-right','padding-bottom','padding-left','border-top-width','border-top-style',
'border-top-color','border-right-width','border-right-style','border-right-color',
'border-bottom-width','border-bottom-style','border-bottom-color','border-left-width',
'border-left-style','border-left-color'
].forEach(property=> target.style.setProperty(property, style.getPropertyValue(property), 'important'));
target.style.setProperty('background-image','none','important');
target.style.setProperty('box-shadow','none','important');
target.style.setProperty('filter','none','important');
target.style.setProperty('opacity','1','important');
}
function syncFrozenColumn(wrapper){
const state=TABLE_STATE.get(wrapper);
if(!state||!state.overlay) return;
state.overlay.style.setProperty('--ppv-frozen-height', `${Math.ceil(state.overlay.scrollHeight)}px`);
}
function buildFrozenColumn(wrapper){
const table=wrapper.querySelector(':scope > table.ppv-table');
if(!table||!table.rows.length||!table.rows[0].cells[0]) return;
let state=TABLE_STATE.get(wrapper);
if(!state){
state={ overlay:null };
TABLE_STATE.set(wrapper, state);
}
if(state.overlay) state.overlay.remove();
const rows=Array.from(table.rows);
const firstCell=rows[0].cells[0];
const width=Math.ceil(firstCell.getBoundingClientRect().width);
const overlay=document.createElement('div');
overlay.className='ppv-frozen-column';
overlay.setAttribute('aria-hidden','true');
overlay.style.width=px(width);
rows.forEach((row, index)=> {
const cell=row.cells[0];
if(!cell) return;
const clone=document.createElement('div');
clone.className=`ppv-frozen-cell${index===0 ? ' is-head':''}`;
clone.style.height=px(row.getBoundingClientRect().height);
clone.style.width=px(width);
copyCellStyle(cell, clone);
if(index===0){
clone.style.setProperty('background','#0F172A','important');
clone.style.setProperty('color','#FFFFFF','important');
}
clone.innerHTML=cell.innerHTML;
overlay.appendChild(clone);
});
wrapper.insertBefore(overlay, table);
state.overlay=overlay;
syncFrozenColumn(wrapper);
}
function initResponsiveToc(page){
const layout=page.querySelector('.ppv-layout');
const main=page.querySelector('.ppv-main');
const aside=page.querySelector('.ppv-aside');
if(!layout||!main||!aside) return;
const marker=document.createComment('ppv-aside-origin');
layout.insertBefore(marker, aside);
let ticking=false;
const isMobile=()=> window.matchMedia('(max-width: 900px)').matches;
const reset=()=> {
aside.classList.remove('ppv-toc-fixed','ppv-toc-bottom');
['left','right','top','bottom','width'].forEach(property=> aside.style.removeProperty(property));
};
function place(){
ticking=false;
reset();
if(isMobile()){
if(layout.firstElementChild!==aside) layout.insertBefore(aside, layout.firstElementChild);
return;
}
if(marker.nextSibling!==aside) layout.insertBefore(aside, marker.nextSibling);
const layoutRect=layout.getBoundingClientRect();
const width=Math.round(aside.getBoundingClientRect().width||290);
const documentTop=window.scrollY + layoutRect.top;
const documentBottom=documentTop + layout.offsetHeight;
const footer=page.querySelector('.ppv-global-footer');
const footerTop=footer ? window.scrollY + footer.getBoundingClientRect().top:documentBottom;
const boundaryBottom=Math.min(documentBottom, footerTop - 24);
const asideHeight=Math.min(aside.offsetHeight, window.innerHeight - 40);
const fixedTop=20;
const currentTop=window.scrollY + fixedTop;
const bottomLimit=boundaryBottom - asideHeight;
if(currentTop <=documentTop) return;
if(currentTop >=bottomLimit){
aside.classList.add('ppv-toc-bottom');
aside.style.setProperty('top', px(Math.max(0, boundaryBottom - documentTop - asideHeight)), 'important');
aside.style.setProperty('right', '0', 'important');
return;
}
aside.classList.add('ppv-toc-fixed');
aside.style.setProperty('left', px(layoutRect.right - width), 'important');
aside.style.setProperty('width', px(width), 'important');
}
function requestPlace(){
if(ticking) return;
ticking=true;
requestAnimationFrame(place);
}
window.addEventListener('scroll', requestPlace, {passive:true});
window.addEventListener('resize', requestPlace, {passive:true});
place();
}
function init(){
const page=document.querySelector('.ppv-knowledge-page');
if(!page||page.dataset.ppvKcInit==='1') return;
page.dataset.ppvKcInit='1';
const tocLinks=Array.from(page.querySelectorAll('.ppv-toc a[href^="#"]'));
const sections=tocLinks.map(link=> page.querySelector(link.getAttribute('href'))).filter(Boolean);
const setActive=id=> tocLinks.forEach(link=> link.classList.toggle('ppv-toc-active', link.getAttribute('href')===`#${id}`));
if('IntersectionObserver' in window){
const observer=new IntersectionObserver(entries=> {
const visible=entries.filter(entry=> entry.isIntersecting).sort((a,b)=> a.boundingClientRect.top - b.boundingClientRect.top);
if(visible[0]) setActive(visible[0].target.id);
}, {rootMargin:'-15% 0px -72% 0px', threshold:[0,0.01]});
sections.forEach(section=> observer.observe(section));
}
const backToTop=page.querySelector('.ppv-back-to-top');
if(backToTop){
if(backToTop.parentElement!==document.body) document.body.appendChild(backToTop);
backToTop.addEventListener('click', event=> {
event.preventDefault();
window.scrollTo({top:0, behavior:'smooth'});
});
}
const wrappers=Array.from(page.querySelectorAll('.ppv-table-wrap'));
let resizeTimer=0;
const rebuild=()=> wrappers.forEach(buildFrozenColumn);
const delayedRebuild=()=> {
rebuild();
window.setTimeout(rebuild, 250);
window.setTimeout(rebuild, 900);
};
delayedRebuild();
window.addEventListener('resize', ()=> {
window.clearTimeout(resizeTimer);
resizeTimer=window.setTimeout(delayedRebuild, 140);
}, {passive:true});
if(document.fonts&&document.fonts.ready) document.fonts.ready.then(delayedRebuild);
if('ResizeObserver' in window){
const resizeObserver=new ResizeObserver(()=> {
window.clearTimeout(resizeTimer);
resizeTimer=window.setTimeout(rebuild, 90);
});
wrappers.forEach(wrapper=> resizeObserver.observe(wrapper));
}
initResponsiveToc(page);
}
document.readyState==='loading'
? document.addEventListener('DOMContentLoaded', init, {once:true})
: init();
})();