/* OK ITHAKI V249508 - FAST FEED / REAL EXTERNAL CENTER / SCHEDULE TO PUBLISH */
(function(){'use strict';
if(window.__ITHAKI_V249508_RUNTIME__)return;
window.__ITHAKI_V249508_RUNTIME__={fastFeed:true,externalCenter:true,scheduleToPublish:true};
const $=id=>document.getElementById(id),I=()=>window.ITH||(window.ITH={});
function css(){if($('ithV249508Css'))return;const s=document.createElement('style');s.id='ithV249508Css';s.textContent=`
#feedPage .ithFeedStageV249429,#feedPage .ithFeedCardV249429,#feedPage article[data-post]{content-visibility:auto;contain:layout style paint;contain-intrinsic-size:100dvh 720px}
#feedPage .ithFeedListV249429,#feedPage .feedList{overscroll-behavior-y:contain;scroll-behavior:auto}
#feedPage video{background:#000}
`;document.head.appendChild(s)}
function openExternal(){const f=I().openExternalMessageCenterV249477;if(typeof f==='function')return f(false,'all');const p=I().openProfessionalCenterV249477;if(typeof p==='function')return p();return false}
function captureExternal(e){const b=e.target&&e.target.closest&&e.target.closest('[data-v249461-action="external"],#ithExternalCenterHomeV249483,#ithExternalCenterHomeV249486');if(!b)return;e.preventDefault();e.stopImmediatePropagation();openExternal()}
let observer=null;
function tuneVideos(){const feed=$('feedPage');if(!feed)return;const videos=[...feed.querySelectorAll('video')];for(const v of videos){v.setAttribute('playsinline','');v.setAttribute('webkit-playsinline','');if(!v.dataset.v249508Video){v.dataset.v249508Video='1';v.preload='none'}}if(!('IntersectionObserver' in window))return;if(!observer)observer=new IntersectionObserver(entries=>{for(const ent of entries){const v=ent.target;if(ent.isIntersecting){v.preload='metadata';try{v.load()}catch(e){}}else{try{v.pause()}catch(e){}v.preload='none'}}},{root:feed.querySelector('.ithFeedListV249429,.feedList')||null,rootMargin:'140% 0px',threshold:.01});for(const v of videos){try{observer.observe(v)}catch(e){}}}
function scheduleTune(){clearTimeout(window.__ith508Tune);window.__ith508Tune=setTimeout(tuneVideos,80)}
function visibleRefresh(){if(document.visibilityState!=='visible')return;const f=I().openProfessionalFeedV249429;if(typeof f==='function'&&(document.body&&document.body.dataset.page==='feed')){setTimeout(()=>f('visible-background'),50)}scheduleTune()}
function install(){css();document.removeEventListener('click',captureExternal,true);document.addEventListener('click',captureExternal,true);I().openExternalMessagesCenterV249508=openExternal;document.documentElement.setAttribute('data-ithaki-v249508','fast-feed-external-center-schedule-publish');scheduleTune()}
if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install,{once:true});else install();
new MutationObserver(scheduleTune).observe(document.documentElement,{subtree:true,childList:true});
document.addEventListener('visibilitychange',visibleRefresh);
window.addEventListener('ithaki:page-changed',e=>{if(String(e&&e.detail&&e.detail.page||'')==='feed')scheduleTune()});
})();
