1(function(){'use strict';var LISTEN_KEY='rzap_listen_state';var PREFS_KEY='rzap_user_prefs';var NEW_WINDOW_MS=7*24*3600*1000;var MAX_LISTEN_ENTRIES=200;var MAX_LISTEN_AGE_MS=90*24*3600*1000;var STATE_RANK={unset:0,inprogress:1,done:2};var trackedPostIds={};var consentGranted=consentOk();var stateChangeListeners=[];function consentOk(){if(typeof RZAP_CONSENT!=='undefined'&&!RZAP_CONSENT.require){return true;} 2if(typeof cmplz_has_consent==='function'){return!!cmplz_has_consent('preferences');} 3return false;} 4document.addEventListener('cmplz_status_change',function(){handleConsentRecheck();});document.addEventListener('cmplz_revoke',function(){consentGranted=false;clearAllStoredData();notifyStateChange();});function handleConsentRecheck(){var was=consentGranted;consentGranted=consentOk();if(was&&!consentGranted){clearAllStoredData();} 5notifyStateChange();} 6function clearAllStoredData(){try{localStorage.removeItem(LISTEN_KEY);localStorage.removeItem(PREFS_KEY);}catch(e){} 7try{var toRemove=[];for(var i=0;i<localStorage.length;i++){var k=localStorage.key(i);if(k&&k.indexOf('rzap_progress_')===0){toRemove.push(k);}} 8toRemove.forEach(function(k){localStorage.removeItem(k);});}catch(e){}} 9function notifyStateChange(){stateChangeListeners.forEach(function(fn){fn();});} 10function readListenState(){try{return JSON.parse(localStorage.getItem(LISTEN_KEY))||{};}catch(e){return{};}} 11function writeListenState(all){if(!consentGranted){return;} 12try{var entries=Object.keys(all).map(function(id){return[id,all[id]];});var cutoff=Date.now()-MAX_LISTEN_AGE_MS;entries=entries.filter(function(e){return(e[1].ts||0)>=cutoff;});entries.sort(function(a,b){return(b[1].ts||0)-(a[1].ts||0);});entries=entries.slice(0,MAX_LISTEN_ENTRIES);var trimmed={};entries.forEach(function(e){trimmed[e[0]]=e[1];});localStorage.setItem(LISTEN_KEY,JSON.stringify(trimmed));}catch(e){}} 13function getListenState(postId){if(!postId){return'unset';} 14var all=readListenState();return all[postId]?all[postId].state:'unset';} 15function markListened(postId,minLevel){if(!postId||!consentGranted){return;} 16var current=getListenState(postId);if(STATE_RANK[minLevel]<=STATE_RANK[current]){return;} 17var all=readListenState();all[postId]={state:minLevel,ts:Date.now()};writeListenState(all);notifyStateChange();} 18function readUserPrefs(){try{return JSON.parse(localStorage.getItem(PREFS_KEY));}catch(e){return null;}} 19function saveUserPrefs(prefs){if(!consentGranted){return;} 20try{localStorage.setItem(PREFS_KEY,JSON.stringify(prefs));}catch(e){}} 21function iconSvg(state,isNew){if('done'===state){return('<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><circle cx="12" cy="12" r="11" fill="none" stroke="var(--rzap-muted)" stroke-width="1.5"></circle><path d="M7 12.5l3 3 7-7" fill="none" stroke="var(--rzap-muted)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>');} 22var color='inprogress'===state?'var(--rzap-accent)':'var(--rzap-accent-light)';var badge=isNew?'<circle cx="18" cy="6" r="4" fill="var(--rzap-accent)"></circle>':'';return('<svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><path d="M4 14v-2a8 8 0 0 1 16 0v2" fill="none" stroke="'+ 23color+'" stroke-width="1.8" stroke-linecap="round"></path><rect x="2.5" y="13" width="4" height="6" rx="1.5" fill="'+ 24color+'"></rect><rect x="17.5" y="13" width="4" height="6" rx="1.5" fill="'+ 25color+'"></rect>'+ 26badge+'</svg>');} 27function renderItemIcon(itemEl){var iconEl=itemEl.querySelector('.rzap-widget-item-icon');var titleEl=itemEl.querySelector('.rzap-widget-item-title');if(!iconEl){return;} 28var postId=itemEl.getAttribute('data-post-id');var dateSec=parseInt(itemEl.getAttribute('data-date'),10)||0;var state=consentGranted?getListenState(postId):'unset';var isNew='unset'===state&&Date.now()-dateSec*1000<NEW_WINDOW_MS;iconEl.innerHTML=iconSvg(state,isNew);itemEl.classList.toggle('rzap-widget-item-done','done'===state);if(titleEl){titleEl.style.color='done'===state?'var(--rzap-muted)':'';}} 29function refreshAllIcons(){document.querySelectorAll('.rzap-widget-item').forEach(renderItemIcon);} 30stateChangeListeners.push(refreshAllIcons);function maybeTrackPlay(postId){if(!postId||trackedPostIds[postId]||typeof RZAP_AJAX==='undefined'){return;} 31trackedPostIds[postId]=true;var data=new URLSearchParams();data.append('action','rzap_track_play');data.append('post_id',postId);if(navigator.sendBeacon){navigator.sendBeacon(RZAP_AJAX.url,data);}else{fetch(RZAP_AJAX.url,{method:'POST',body:data,keepalive:true});}} 32document.addEventListener('DOMContentLoaded',function(){document.querySelectorAll('.rzap-player').forEach(initArticlePlayer);document.querySelectorAll('.rzap-widget').forEach(initWidget);refreshAllIcons();
32[300,1000,2500].forEach(function(delay){setTimeout(handleConsentRecheck,delay);});});function initArticlePlayer(playerEl){var audio=playerEl.querySelector('.rzap-audio-el');if(!audio){return;} 33var postId=playerEl.getAttribute('data-post-id');var playBtn=playerEl.querySelector('.rzap-play-btn');var iconPlay=playerEl.querySelector('.rzap-icon-play');var iconPause=playerEl.querySelector('.rzap-icon-pause');var progressBar=playerEl.querySelector('.rzap-progress-bar');var progressFill=playerEl.querySelector('.rzap-progress-fill');var timeLabel=playerEl.querySelector('.rzap-time');var speedSelect=playerEl.querySelector('.rzap-speed');var resumeBanner=playerEl.querySelector('.rzap-resume-banner');var resumeYes=playerEl.querySelector('.rzap-resume-yes');var resumeNo=playerEl.querySelector('.rzap-resume-no');var storageKey='rzap_progress_'+postId;audio.playbackRate=parseFloat(speedSelect.value)||1;var saved=readSaved(storageKey);if(saved&&saved.time>3&&resumeBanner){resumeBanner.style.display='flex';} 34playBtn.addEventListener('click',function(){if(audio.paused){audio.play();}else{audio.pause();}});audio.addEventListener('play',function(){setPlayIcon(true);});audio.addEventListener('pause',function(){setPlayIcon(false);});audio.addEventListener('timeupdate',function(){updateProgress();saveProgress(storageKey,audio.currentTime);if(audio.currentTime>=5){maybeTrackPlay(postId);markListened(postId,'inprogress');} 35if(audio.duration&&audio.currentTime/audio.duration>=0.9){markListened(postId,'done');}});audio.addEventListener('loadedmetadata',function(){updateProgress();});audio.addEventListener('ended',function(){markListened(postId,'done');try{localStorage.removeItem(storageKey);}catch(e){}});if(progressBar){progressBar.addEventListener('click',function(e){if(!audio.duration){return;} 36var rect=progressBar.getBoundingClientRect();var ratio=(e.clientX-rect.left)/rect.width;audio.currentTime=ratio*audio.duration;});} 37if(speedSelect){speedSelect.addEventListener('change',function(){audio.playbackRate=parseFloat(speedSelect.value)||1;});} 38if(resumeYes){resumeYes.addEventListener('click',function(){resumeBanner.style.display='none';audio.currentTime=saved.time;audio.play();});} 39if(resumeNo){resumeNo.addEventListener('click',function(){resumeBanner.style.display='none';try{localStorage.removeItem(storageKey);}catch(e){}});} 40function setPlayIcon(playing){iconPlay.style.display=playing?'none':'inline';iconPause.style.display=playing?'inline':'none';} 41function updateProgress(){if(!audio.duration){return;} 42var pct=(audio.currentTime/audio.duration)*100;progressFill.style.width=pct+'%';timeLabel.textContent=formatTime(audio.currentTime)+' / '+formatTime(audio.duration);}} 43function initWidget(widgetEl){var audio=widgetEl.querySelector('.rzap-widget-audio-el');var nowPlaying=widgetEl.querySelector('.rzap-widget-now-playing');var playPauseBtn=widgetEl.querySelector('.rzap-widget-playpause');var prevBtn=widgetEl.querySelector('.rzap-widget-prev');var nextBtn=widgetEl.querySelector('.rzap-widget-next');var titleEl=widgetEl.querySelector('.rzap-widget-current-title');var progressBar=widgetEl.querySelector('.rzap-widget-progress-bar');var progressFill=widgetEl.querySelector('.rzap-widget-progress-fill');var timeLabel=widgetEl.querySelector('.rzap-widget-time');var itemEls=Array.prototype.slice.call(widgetEl.querySelectorAll('.rzap-widget-item'));if(!audio){return;} 44var autoplayEnabled=widgetEl.getAttribute('data-default-autoplay')==='1';var skipListened=widgetEl.getAttribute('data-default-skip')==='1';var autoplayCheckbox=widgetEl.querySelector('.rzap-pref-autoplay');var skipCheckbox=widgetEl.querySelector('.rzap-pref-skip');function applyPrefsUI(){var stored=consentGranted?readUserPrefs():null;autoplayEnabled=stored&&typeof stored.autoplay==='boolean'?stored.autoplay:widgetEl.getAttribute('data-default-autoplay')==='1';skipListened=stored&&typeof stored.skipListened==='boolean'?stored.skipListened:widgetEl.getAttribute('data-default-skip')==='1';if(autoplayCheckbox){autoplayCheckbox.checked=autoplayEnabled;autoplayCheckbox.disabled=!consentGranted;} 45if(skipCheckbox){skipCheckbox.checked=skipListened;skipCheckbox.disabled=!consentGranted;} 46widgetEl.classList.toggle('rzap-widget-no-consent',!consentGranted);} 47applyPrefsUI();stateChangeListeners.push(applyPrefsUI);
47if(autoplayCheckbox){autoplayCheckbox.addEventListener('change',function(){autoplayEnabled=autoplayCheckbox.checked;saveUserPrefs({autoplay:autoplayEnabled,skipListened:skipListened});});} 48if(skipCheckbox){skipCheckbox.addEventListener('change',function(){skipListened=skipCheckbox.checked;saveUserPrefs({autoplay:autoplayEnabled,skipListened:skipListened});updateNavButtons();});} 49var queue=[];try{queue=JSON.parse(widgetEl.getAttribute('data-queue'))||[];}catch(e){queue=[];} 50if(!queue.length){queue=itemEls.map(function(el){return{id:el.getAttribute('data-post-id'),url:el.getAttribute('data-audio-url'),title:el.getAttribute('data-title')};});} 51var currentIndex=-1;itemEls.forEach(function(item,index){item.addEventListener('click',function(){playIndex(index);});});if(playPauseBtn){playPauseBtn.addEventListener('click',function(){if(audio.paused){audio.play();}else{audio.pause();}});} 52if(prevBtn){prevBtn.addEventListener('click',function(){var idx=findAdjacentIndex(currentIndex,-1);if(idx!==-1){playIndex(idx);}});} 53if(nextBtn){nextBtn.addEventListener('click',function(){var idx=findAdjacentIndex(currentIndex,1);if(idx!==-1){playIndex(idx);}});} 54if(progressBar){progressBar.addEventListener('click',function(e){if(!audio.duration){return;} 55var rect=progressBar.getBoundingClientRect();var ratio=(e.clientX-rect.left)/rect.width;audio.currentTime=ratio*audio.duration;});} 56audio.addEventListener('play',function(){if(playPauseBtn){playPauseBtn.textContent='â¸';}});audio.addEventListener('pause',function(){if(playPauseBtn){playPauseBtn.textContent='â¶';}});audio.addEventListener('timeupdate',updateProgress);audio.addEventListener('loadedmetadata',updateProgress);audio.addEventListener('ended',function(){if(currentIndex>=0&&queue[currentIndex]){markListened(queue[currentIndex].id,'done');} 57if(!autoplayEnabled){return;} 58var idx=findAdjacentIndex(currentIndex,1);if(idx!==-1){playIndex(idx);}});function findAdjacentIndex(fromIndex,direction){var idx=fromIndex+direction;while(idx>=0&&idx<queue.length){if(!skipListened||!consentGranted||'done'!==getListenState(queue[idx].id)){return idx;} 59idx+=direction;} 60return-1;} 61function playIndex(index){if(index<0||index>=queue.length){return;} 62currentIndex=index;var track=queue[index];itemEls.forEach(function(el,i){el.classList.toggle('rzap-widget-item-active',i===index);});if(audio.getAttribute('data-current-url')!==track.url){audio.src=track.url;audio.setAttribute('data-current-url',track.url);} 63titleEl.textContent=track.title;nowPlaying.style.display='flex';updateNavButtons();audio.play();} 64function updateNavButtons(){if(prevBtn){prevBtn.disabled=findAdjacentIndex(currentIndex,-1)===-1;} 65if(nextBtn){nextBtn.disabled=findAdjacentIndex(currentIndex,1)===-1;}} 66function updateProgress(){if(!audio.duration){return;} 67var pct=(audio.currentTime/audio.duration)*100;progressFill.style.width=pct+'%';timeLabel.textContent=formatTime(audio.currentTime)+' / '+formatTime(audio.duration);if(currentIndex>=0&&queue[currentIndex]){var trackId=queue[currentIndex].id;if(audio.currentTime>=5){maybeTrackPlay(trackId);markListened(trackId,'inprogress');} 68if(audio.currentTime/audio.duration>=0.9){markListened(trackId,'done');}}}} 69function readSaved(key){try{return JSON.parse(localStorage.getItem(key));}catch(e){return null;}} 70function saveProgress(key,time){if(!consentGranted){return;} 71try{localStorage.setItem(key,JSON.stringify({time:time,ts:Date.now()}));}catch(e){}} 72function formatTime(sec){if(!isFinite(sec)){return'--:--';} 73var m=Math.floor(sec/60);var s=Math.floor(sec%60);return m+':'+(s<10?'0':'')+s;}})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.