import"./chunks/modulepreload-polyfill-B5Qt9EMX.js";import{b as W,g as se,r as ne,d as ie,a as re,m as oe,T as ce}from"./chunks/db-CwROBlWC.js";const H=100,R=10;let I=[],x=new Set,P=[],k=[],C=0,E=R,B=null,z=0;function O(e){if(!e.length)return[];const s=[],t=new Set(e);for(const n of ce)if(t.has(n.id))for(const i of n.keywords)s.push(i.toLowerCase());return s}function ae(e){if(x.size>0&&e.topicIds&&e.topicIds.length>0){for(const s of e.topicIds)if(x.has(s))return!0}if(P.length>0&&(!e.topicIds||e.topicIds.length===0)){const s=e.title.toLowerCase();for(const t of P)if(s.includes(t))return!0}if(k.length>0){const s=e.title.toLowerCase();for(const t of k)if(s.includes(t))return!0}return!1}const $=new Worker(new URL("/assets/ml-worker-C-WpS3Gh.js",import.meta.url),{type:"module"}),y=new Worker(new URL("/assets/scraper-worker-B06hZrZJ.js",import.meta.url),{type:"module"}),o={currentPage:1,articles:[],activeArticleId:null,hideRead:!0,hideLow:!0,loading:!1,modelReady:!1,digestMode:!1,_scrapeRequested:!1,_showLoading:!0,_scoreTimer:null,_preScoring:!1,_retrainPending:!1},g=document.getElementById("article-list"),de=document.getElementById("stats-bar"),v=document.getElementById("rec-indicator"),U=document.getElementById("robot-mascot"),q=document.getElementById("toggle-hide-read"),K=document.getElementById("toggle-hide-low"),b=document.getElementById("btn-refresh"),Z=document.getElementById("refresh-countdown"),F=document.getElementById("refresh-countdown-fill");function u(e){$.postMessage(e)}function L(e,s=15e3){return new Promise((t,n)=>{const i=setTimeout(()=>{$.removeEventListener("message",r),n(new Error(`ML worker timeout waiting for ${e}`))},s),r=c=>{c.data.type===e&&(clearTimeout(i),$.removeEventListener("message",r),t(c.data))};$.addEventListener("message",r)})}async function G(e){if(e.length===0)return e;try{u({type:"score",articles:e});const s=await L("score:done",6e4);if(s.type==="score:done")return s.articles}catch(s){console.warn(`[sidepanel] score failed: ${s instanceof Error?s.message:String(s)}`)}return e}let l=[];async function h(e=1,s=!1,t=!0){if(!s&&l.length>0){o.currentPage=e,o.articles=f(e),p(),M();return}o._showLoading=t,s&&u({type:"retrain"}),o.currentPage=e,fe(),y.postMessage({type:"loadFromDB",page:1,pageSize:9999,hideRead:!1})}function f(e){const s=(e-1)*H;return l.slice(s,s+H)}y.onmessage=async e=>{const s=e.data;if(s.type==="loadFromDB:done"){if(o._preScoring)return;if(C=s.totalCount,o._showLoading){const t=s.articles.length,n=o._retrainPending?t:s.articles.filter(a=>a.recScore===0||!a.topicIds||a.topicIds.length===0).length,i=n===0?`${t.toLocaleString()}개 게시글 준비 완료`:n<t?`${n.toLocaleString()}개 새 게시글 점수 계산 중...`:`${t.toLocaleString()}개 게시글 점수 계산 중...`;g.innerHTML=`
        <div class="empty-state">
          <div class="empty-icon">🤖</div>
          <div class="empty-title">추천 점수를 계산하고 있습니다</div>
          <div class="empty-desc">${i}</div>
          <div class="scrape-progress" id="score-progress">
            <div class="scrape-progress-bar"><div class="scrape-progress-fill" id="score-progress-fill" style="width:0%;transition:width 1s linear"></div></div>
            <div class="scrape-progress-text" id="score-progress-text">모델 준비 중...</div>
          </div>
        </div>`;let r=0;const c=setInterval(()=>{r=Math.min(r+3,90);const a=document.getElementById("score-progress-fill"),d=document.getElementById("score-progress-text");a&&(a.style.width=`${r}%`),d&&(d.textContent=`점수 계산 중... ${r}%`),r>=90&&clearInterval(c)},1e3);o._scoreTimer=c}pe(s.articles),w()}else s.type==="loadFromDB:error"?(g.innerHTML=`
      <div class="empty-state">
        <div class="empty-icon">⚠️</div>
        <div class="empty-title">로드 실패</div>
        <div class="empty-desc">${m(s.error)}</div>
      </div>`,M(),w()):s.type==="scrape:done"&&w()};async function le(){console.log("[sidepanel] Pre-scoring in background..."),o._preScoring=!0,u({type:"retrain"});const e=await new Promise(i=>{const r=c=>{c.data.type==="loadFromDB:done"?(y.removeEventListener("message",r),C=c.data.totalCount,i(c.data.articles)):c.data.type==="loadFromDB:error"&&(y.removeEventListener("message",r),i([]))};y.addEventListener("message",r),y.postMessage({type:"loadFromDB",page:1,pageSize:9999,hideRead:!1})});if(e.length===0)return;const s=e.filter(i=>i.recScore!==0&&i.topicIds&&i.topicIds.length>0),t=e.filter(i=>i.recScore===0||!i.topicIds||i.topicIds.length===0);let n;if(t.length>0){const i=await G(t),r=new Map;for(const c of s)c.id&&r.set(c.id,c);for(const c of i)c.id&&r.set(c.id,c);n=e.map(c=>c.id&&r.has(c.id)?r.get(c.id):c),W(i).catch(()=>{})}else n=e;l=n,o.articles=f(o.currentPage);try{u({type:"getStats"});const i=await L("stats:done",1e4);o.modelReady=i.type==="stats:done"?i.stats.modelReady:!1}catch{}o._preScoring=!1,p(),M(),w(),D(),console.log("[sidepanel] Pre-score complete, list updated")}async function pe(e){const s=o._retrainPending;o._retrainPending=!1;const t=s?[]:e.filter(r=>r.recScore!==0&&r.topicIds&&r.topicIds.length>0),n=s?e:e.filter(r=>r.recScore===0||!r.topicIds||r.topicIds.length===0);let i;if(n.length>0){const r=await G(n),c=new Map;for(const a of t)a.id&&c.set(a.id,a);for(const a of r)a.id&&c.set(a.id,a);i=e.map(a=>a.id&&c.has(a.id)?c.get(a.id):a),W(r).catch(()=>{})}else i=e;l=i,o.articles=f(o.currentPage),o._scoreTimer&&(clearInterval(o._scoreTimer),o._scoreTimer=null);try{u({type:"getStats"});const r=await L("stats:done",1e4);o.modelReady=r.type==="stats:done"?r.stats.modelReady:!1}catch{}p(),M(),w()}$.onmessage=e=>{};async function ge(e=1){if(l.length>0){o.currentPage=e,o.articles=f(e),p(),M();return}h(e)}function J(e){return e.id===o.activeArticleId?!0:!(o.hideRead&&e.isRead||o.hideLow&&o.modelReady&&e.recScore>0&&e.recScore<=.04||I.length>0&&I.includes(e.sourceSite)||ae(e))}function p(){const e=o.articles.filter(J);if(e.length===0){const t=C===0,n=t?`<div class="empty-state">
           <div class="empty-icon">📡</div>
           <div class="empty-title">게시글을 수집하고 있습니다</div>
           <div class="empty-desc">백그라운드에서 커뮤니티 사이트를 수집 중입니다.</div>
           <div class="scrape-progress" id="scrape-progress">
             <div class="scrape-progress-bar"><div class="scrape-progress-fill" id="scrape-progress-fill"></div></div>
             <div class="scrape-progress-text" id="scrape-progress-text">준비 중...</div>
           </div>
         </div>`:`<div class="empty-state">
           <div class="empty-icon">✨</div>
           <div class="empty-title">새 게시글이 없습니다</div>
           <div class="empty-desc">필터 설정을 변경하거나 잠시 후 다시 확인해 주세요.</div>
         </div>`;g.innerHTML=n,t&&!o._scrapeRequested&&(o._scrapeRequested=!0,console.log("[sidepanel] Empty state — requesting immediate scrape"),chrome.runtime.sendMessage({type:"trigger-scrape-now"}).catch(()=>{}));return}const s=e.map(t=>{const n=t.id===o.activeArticleId,i=t.recScore||0,r=o.modelReady&&i>0?i>=.15?"score-high":i<=.04?"score-low":"":"",c=["article-item",n?"active":"",t.isRead?"read":"",r].filter(Boolean).join(" "),a=n?'<span class="active-arrow" title="읽는 중">▶</span>':t.recommended?'<span class="rec-arrow" title="추천">➤</span>':"",d=t.publishedAt?$e(t.publishedAt):"";return`
        <div class="${c}" role="listitem" tabindex="0"
             data-id="${t.id}">
          <div class="article-rec">${a}</div>
          <div class="article-rank">${t.rank||""}</div>
          <div class="article-body">
            <div class="article-title">${m(t.title)}</div>
            <div class="article-meta">
              <span class="source-badge" data-source="${m(t.sourceSite)}">${m(t.sourceSite)}</span>
              ${t.commentCount>0?`<span class="comment-count">[${t.commentCount}]</span>`:""}
              ${t.viewCount>0?`<span class="view-count">${we(t.viewCount)} 조회</span>`:""}
              ${d?`<span>${d}</span>`:""}
              ${t.author?`<span class="author-name">${m(t.author)}<button class="btn-block-author" data-author="${m(t.author)}" title="이 작성자 차단">❌</button></span>`:""}
            </div>
          </div>
          <button class="btn-dismiss" data-dismiss-id="${t.id}" title="안 볼래요">🚫</button>
          <button class="btn-reject" data-reject-id="${t.id}" title="싫어요">👎</button>
        </div>`}).join("");g.innerHTML=s}async function X(e){const s=o.articles.find(n=>n.id===e);if(!s)return;o.activeArticleId=e,p(),oe(e,s.recommended||!1,s.recScore||null).then(()=>{s.isRead=!0,p(),w(),u({type:"recordOutcome",wasRecommended:s.recommended||!1,wasClicked:!0})}).catch(n=>console.warn("[click] mark-read failed",n.message));const t=s.originalUrl||s.issueLinkUrl;try{const[n]=await chrome.tabs.query({active:!0,currentWindow:!0});n?.id&&chrome.tabs.update(n.id,{url:t})}catch{console.warn("[click] tabs.update failed, opening new tab"),chrome.tabs.create({url:t})}}async function w(){let e;try{u({type:"getStats"}),e=await L("stats:done",3e4)}catch(i){console.warn(`[sidepanel] stats load failed: ${i instanceof Error?i.message:String(i)}`);return}if(e.type!=="stats:done")return;const{stats:s}=e;de.textContent=`${s.totalReads}/${s.totalArticles}`;const t=document.getElementById("btn-digest"),n=s.recommendationAccuracy;if(s.modelReady)if(U.style.display="none",n.totalRecs>0){const i=(n.accuracy*100).toFixed(0),r=n.autoModeEligible;v.textContent=`모델: 활성 | 정확도: ${i}%${r?" | 자동":""}`,v.style.color=r?"var(--success)":"var(--text-muted)",t&&(t.style.display=r?"inline-block":"none")}else v.textContent="모델: 활성 | 추천 클릭 대기 중",v.style.color="var(--text-muted)",t&&(t.style.display="none");else{U.style.display="inline-block";const i=30-(s.totalReads||0);i>0?v.textContent=`학습 중… ${i}개 더 읽어주세요`:v.textContent="학습 완료! 새로고침을 눌러주세요",t&&(t.style.display="none")}}function ue(){return Math.max(1,Math.ceil(C/H))}function M(){const e=document.getElementById("pagination"),s=ue();let t="";for(let n=1;n<=s;n++){const i=n===o.currentPage,r=f(n),c=l.length>0&&r.length===0,a=["btn-page-num",i?"active":"",c?"empty":""].filter(Boolean).join(" ");t+=`<button class="${a}" data-page="${n}">${n}</button>`}e.innerHTML=t}function fe(){document.querySelectorAll(".btn-page-num").forEach(e=>{const s=e,t=parseInt(s.dataset.page||"0",10);s.classList.toggle("active",t===o.currentPage);const n=f(t);l.length>0&&n.length===0?s.classList.add("empty"):s.classList.remove("empty")})}document.getElementById("pagination").addEventListener("click",e=>{const s=e.target.closest("[data-page]");if(!s)return;const t=parseInt(s.dataset.page||"0",10);isNaN(t)||t===o.currentPage||(ge(t),g.scrollTop=0)});q.addEventListener("change",()=>{o.hideRead=q.checked,p()});K.addEventListener("change",()=>{o.hideLow=K.checked,p()});const S=document.getElementById("report-modal"),j=document.getElementById("report-body");document.getElementById("btn-settings").addEventListener("click",()=>{chrome.runtime.openOptionsPage()});document.getElementById("btn-report").addEventListener("click",async()=>{S.style.display="flex",j.innerHTML='<div class="loading">리포트 불러오는 중...</div>',u({type:"getReport"});const[e,s]=await Promise.all([L("report:done"),se()]);e.type==="report:done"?j.innerHTML=me(e.report,s):j.innerHTML='<p class="report-error">리포트를 불러오지 못했습니다.</p>'});document.getElementById("btn-close-report").addEventListener("click",()=>{S.style.display="none"});S.addEventListener("click",e=>{e.target===S&&(S.style.display="none")});function me(e,s){let t="";if(s.length>0){const n=s.reduce((r,c)=>r+c.reads,0),i=s.reduce((r,c)=>r+c.rejected,0);t+='<section class="report-section">',t+="<h3>사이트별 활동</h3>",t+='<table class="report-activity-table">',t+="<thead><tr><th>사이트</th><th>읽음</th><th>싫어요</th></tr></thead>",t+="<tbody>";for(const r of s)t+=`<tr>
        <td class="site-name">${r.site}</td>
        <td class="num">${r.reads}</td>
        <td class="num">${r.rejected}</td>
      </tr>`;t+=`<tr class="total-row">
      <td class="site-name"><strong>합계</strong></td>
      <td class="num"><strong>${n}</strong></td>
      <td class="num"><strong>${i}</strong></td>
    </tr>`,t+="</tbody></table></section>"}if(!e.ready){const n=e.totalReads??0,i=e.minRequired??30,r=Math.min(100,Math.round(n/i*100));if(t+='<section class="report-section report-progress">',t+="<h3>AI 학습 진행</h3>",n>=i)t+="<p>게시글을 충분히 읽었습니다! <strong>새로고침</strong> 버튼을 눌러 AI 학습을 시작하세요.</p>",t+='<div class="progress-track"><div class="progress-fill" style="width:100%"></div></div>',t+=`<p class="progress-label">${n} / ${i} 읽음 ✓</p>`;else{const c=i-n;t+=`<p>게시글을 더 읽어주세요. 최소 <strong>${i}개</strong>의 게시글을 읽어야 AI가 선호도를 분석합니다.</p>`,t+=`<div class="progress-track"><div class="progress-fill" style="width:${r}%"></div></div>`,t+=`<p class="progress-label">${n} / ${i} 읽음 (${c}개 남음)</p>`}return t+="</section>",t}if(e.topics&&e.topics.length){const n=e.topics.filter(i=>Math.abs(i.weight)>.01).sort((i,r)=>r.weight-i.weight);if(n.length){t+='<section class="report-section">',t+="<h3>토픽 선호도</h3>",t+='<div class="topic-grid">';const i=Math.max(...n.map(r=>Math.abs(r.weight)),.01);for(const r of n){const c=Math.round(Math.abs(r.weight)/i*100),a=r.weight>=0?"topic-positive":"topic-negative",d=r.weight>0?"+":"";t+=`<div class="topic-row ${a}" title="${r.matchedWords}개 관련 단어 감지">
          <span class="topic-label">${r.label}</span>
          <div class="topic-bar-track">
            <div class="topic-bar-fill ${a}" style="width:${c}%"></div>
          </div>
          <span class="topic-val">${d}${r.weight}</span>
        </div>`}t+="</div></section>"}}if(e.liked_words&&e.liked_words.length&&(t+='<section class="report-section">',t+="<h3>좋아하는 단어</h3>",t+='<div class="tag-cloud tag-positive">',t+=e.liked_words.map(n=>`<span class="tag" title="weight: ${n.weight}">${n.word}</span>`).join(""),t+="</div></section>"),e.disliked_words&&e.disliked_words.length&&(t+='<section class="report-section">',t+="<h3>싫어하는 단어</h3>",t+='<div class="tag-cloud tag-negative">',t+=e.disliked_words.map(n=>`<span class="tag" title="weight: ${n.weight}">${n.word}</span>`).join(""),t+="</div></section>"),e.sources&&e.sources.length){t+='<section class="report-section">',t+="<h3>출처 사이트</h3>",t+='<div class="report-bars">';const n=Math.max(...e.sources.map(i=>Math.abs(i.weight)),.01);t+=e.sources.map(i=>{const r=Math.round(Math.abs(i.weight)/n*100),c=i.weight>=0?"bar-positive":"bar-negative";return`<div class="bar-row">
          <span class="bar-label">${i.source}</span>
          <div class="bar-track"><div class="bar-fill ${c}" style="width:${r}%"></div></div>
          <span class="bar-val">${i.weight>0?"+":""}${i.weight}</span>
        </div>`}).join(""),t+="</div></section>"}if(e.liked_authors&&e.liked_authors.length&&(t+='<section class="report-section">',t+="<h3>좋아하는 작성자</h3>",t+='<div class="tag-cloud tag-positive">',t+=e.liked_authors.map(n=>`<span class="tag" title="weight: ${n.weight}">${n.author}</span>`).join(""),t+="</div></section>"),e.disliked_authors&&e.disliked_authors.length&&(t+='<section class="report-section">',t+="<h3>싫어하는 작성자</h3>",t+='<div class="tag-cloud tag-negative">',t+=e.disliked_authors.map(n=>`<span class="tag" title="weight: ${n.weight}">${n.author}</span>`).join(""),t+="</div></section>"),e.metadata&&e.metadata.length){t+='<section class="report-section">',t+="<h3>기타 선호</h3>",t+="<ul class='report-meta-list'>";for(const n of e.metadata){const i=n.feature==="comment_count"?"댓글 수":"조회 수",r=n.weight>0?"인기글 선호":"비주류 선호";t+=`<li>${i}: ${r} (${n.weight>0?"+":""}${n.weight})</li>`}t+="</ul></section>"}return t||'<p class="report-empty">아직 표시할 선호 데이터가 없습니다.</p>'}b.addEventListener("click",async()=>{if(o.loading)return;o.loading=!0,b.classList.add("refreshing"),b.disabled=!0,N(),o.digestMode=!1;const e=document.getElementById("btn-digest");e&&e.classList.remove("active"),g.innerHTML=`
    <div class="empty-state">
      <div class="empty-icon">📡</div>
      <div class="empty-title">게시글을 수집하고 있습니다</div>
      <div class="empty-desc">커뮤니티 사이트에서 최신 글을 가져오는 중입니다.</div>
      <div class="scrape-progress" id="scrape-progress">
        <div class="scrape-progress-bar"><div class="scrape-progress-fill" id="scrape-progress-fill"></div></div>
        <div class="scrape-progress-text" id="scrape-progress-text">준비 중...</div>
      </div>
    </div>`;try{chrome.runtime.sendMessage({type:"trigger-scrape-now"}).catch(()=>{})}catch{Q()}});function Q(){l=[],o.loading=!1,b.classList.remove("refreshing"),b.disabled=!1,h(1,!0),D()}const _=document.getElementById("btn-digest");_&&_.addEventListener("click",()=>{o.digestMode=!o.digestMode,o.digestMode?(_.classList.add("active"),p()):(_.classList.remove("active"),p())});g.addEventListener("click",e=>{const s=e.target,t=s.closest(".btn-block-author");if(t){e.stopPropagation();const a=t.dataset.author;a&&ye(a);return}const n=s.closest(".btn-dismiss");if(n){e.stopPropagation();const a=parseInt(n.dataset.dismissId||"0",10);!isNaN(a)&&a>0&&ve(a);return}const i=s.closest(".btn-reject");if(i){e.stopPropagation();const a=parseInt(i.dataset.rejectId||"0",10);!isNaN(a)&&a>0&&he(a);return}const r=s.closest(".article-item");if(!r)return;const c=parseInt(r.dataset.id||"0",10);!isNaN(c)&&c>0&&X(c)});async function he(e){const s=o.articles.find(t=>t.id===e);try{await ne(e,s?.recScore||null),l=l.filter(t=>t.id!==e),o.articles=f(o.currentPage),p()}catch{const t=g.querySelector(`[data-id="${e}"]`);t&&t.remove()}}async function ve(e){const s=o.articles.find(t=>t.id===e);try{await ie(e),s&&(s.isRead=!0),p()}catch{const t=g.querySelector(`[data-id="${e}"]`);t&&t.remove()}}async function ye(e){try{await re(e),l=l.filter(s=>s.author!==e),o.articles=f(o.currentPage),p()}catch{}}document.addEventListener("keydown",e=>{const s=e.target.tagName;s==="INPUT"||s==="TEXTAREA"||(e.key==="j"||e.key==="ArrowDown"?(e.preventDefault(),V(1)):(e.key==="k"||e.key==="ArrowUp")&&(e.preventDefault(),V(-1)))});function V(e){const s=o.articles.filter(J);if(s.length===0)return;const t=s.findIndex(i=>i.id===o.activeArticleId);let n;if(t===-1?n=e>0?0:s.length-1:n=t+e,n>=0&&n<s.length){X(s[n].id);const i=g.querySelector(".article-item.active");i&&i.scrollIntoView({block:"nearest",behavior:"smooth"})}}function m(e){return e?e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"):""}function we(e){return e>=1e4?(e/1e4).toFixed(1)+"만":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function $e(e){try{const s=new Date(e),n=new Date().getTime()-s.getTime(),i=Math.floor(n/6e4);if(i<1)return"방금";if(i<60)return`${i}m`;const r=Math.floor(i/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}catch{return""}}function be(e,s,t,n,i,r,c){const a=document.getElementById("scrape-progress-fill"),d=document.getElementById("scrape-progress-text");if(!a||!d)return;const ee=s>0?Math.round(e/s*100):0;a.style.width=`${ee}%`;const A=c?.length||0,T=A>0?` · ⚠ ${A}개 실패`:"";if(e>=s&&s>0)d.innerHTML=A>0?`완료! ${n}개 수집됨 · <span style="color:#e94560;">⚠ ${A}개 사이트 실패</span>`:`완료! ${n}개 수집됨`;else if(r)d.innerHTML=`<span style="color:#e94560;">✗ ${m(r)} 실패</span> (${e}/${s}) · ${n}개 수집됨${T}`;else if(t)d.textContent=`✓ ${t} 완료 (${e}/${s}) · ${n}개 수집됨${T}`;else if(i&&i.length>0){const te=i.join(", ");d.textContent=`수집 중: ${te} (${e}/${s})${T}`}else d.textContent=`수집 중... (${e}/${s})${T}`}function Y(e){const t=Number.isFinite(e)?e:13,n=Math.max(.8,t/13);document.documentElement.style.setProperty("--font-size-base",`${t}px`);const i=document.getElementById("app");i&&(i.style.zoom=String(n),i.style.height=100/n+"vh")}chrome.storage.sync.get({disabledSites:[],hiddenTopics:[],hiddenKeywords:[],fontSize:13,refreshInterval:R},e=>{I=e.disabledSites||[];const s=e.hiddenTopics||[];x=new Set(s),P=O(s),k=e.hiddenKeywords||[];const t=e.fontSize||13;E=e.refreshInterval||R,console.log("[init] sidepanel settings",{fontSize:t,refreshIntervalMinutes:E,disabledSites:I.length,hiddenTopics:s.length,hiddenKeywords:k.length}),Y(t),h(1),D()});chrome.runtime.onMessage.addListener((e,s,t)=>{if(e.type==="ping-sidepanel"){t({pong:!0}),window.close();return}e.type==="data-cleared"?(console.log("[sidepanel] Data cleared from settings, refreshing"),l=[],o.modelReady=!1,o._retrainPending=!0,u({type:"resetModel"}),h(1,!0)):e.type==="scrape-complete"?(console.log("[sidepanel] Background scrape complete"),o.loading?Q():le()):e.type==="scrape-progress"&&(console.log("[sidepanel] scrape-progress:",e.completed,"/",e.total,e.currentSite||e.scrapingSites?.join(",")),be(e.completed||0,e.total||1,e.currentSite||"",e.articlesCount||0,e.scrapingSites,e.failedSite||"",e.errors||[]))});function D(){N(),z=Date.now()+E*60*1e3,Z.style.display="",F.style.width="100%",B=setInterval(()=>{const e=z-Date.now(),s=E*60*1e3;if(e<=0){F.style.width="0%",N();return}const t=Math.max(0,e/s*100);F.style.width=`${t}%`},1e3)}function N(){B&&(clearInterval(B),B=null),Z.style.display="none"}chrome.storage.onChanged.addListener((e,s)=>{if(s==="sync"){if(e.fontSize&&Y(e.fontSize.newValue||13),e.refreshInterval&&(E=e.refreshInterval.newValue||R,D()),e.disabledSites&&(I=e.disabledSites.newValue||[],h(1,!0,!1)),e.hiddenTopics){const t=e.hiddenTopics.newValue||[];x=new Set(t),P=O(t),h(1,!0,!1)}e.hiddenKeywords&&(k=e.hiddenKeywords.newValue||[],h(1,!0,!1))}});
