Filters ${ac ? `(${ac})` : ''}
${ac ? `` : ''}
${typeof rFilters === 'function' ? rFilters() : ''}
`;
document.getElementById('pfov').addEventListener('click', closePsFilterSheet);
requestAnimationFrame(() => requestAnimationFrame(() => document.getElementById('pfsh')?.classList.add('open')));
}
function closePsFilterSheet() {
_psSheetOpen = false;
const sh = document.getElementById('pfsh');
if(sh) sh.classList.remove('open');
setTimeout(() => { const w = document.getElementById('_pfs'); if(w) w.innerHTML = ''; }, 340);
}
function updatePsSheet() {
const b = document.getElementById('pfsbody');
if(b && typeof rFilters === 'function') b.innerHTML = rFilters();
const sh = document.getElementById('pfsh');
if(sh) {
const btn = sh.querySelector('[onclick*="closePsFilterSheet"]');
if(btn) btn.textContent = `Done Β· ${S.hits.length} results`;
}
}
// Swipe navigation in detail
let _pstx = 0, _psty = 0;
document.addEventListener('touchstart', ev => {
if(S.view !== 'detail') return;
_pstx = ev.touches[0].clientX; _psty = ev.touches[0].clientY;
}, {passive: true});
document.addEventListener('touchend', ev => {
if(S.view !== 'detail') return;
if(ev.target.closest('textarea,input,.flt-sheet')) return;
const dx = _pstx - ev.changedTouches[0].clientX;
const dy = Math.abs(_psty - ev.changedTouches[0].clientY);
if(dy > 60 || Math.abs(dx) < 80) return;
const id = S.pid || S.cid;
const idx = S.hits.findIndex(x => x.id === id);
if(dx > 0 && idx < S.hits.length - 1) {
const nid = S.hits[idx+1].id;
if(S.pid !== undefined) S.pid = nid; else S.cid = nid;
S.activeTab = 'profile';
render(); document.querySelector('.page-wrapper')?.scrollTo(0,0);
} else if(dx < 0 && idx > 0) {
const pid = S.hits[idx-1].id;
if(S.pid !== undefined) S.pid = pid; else S.cid = pid;
S.activeTab = 'profile';
render(); document.querySelector('.page-wrapper')?.scrollTo(0,0);
}
}, {passive: true});
// Bottom nav
function updatePsBotNav() {
const bn = document.getElementById('_bn');
if(!bn) return;
const IC_ICONS = {
dash: `