"use strict";(()=>{var s=t=>document.getElementById(t),R=s("site-name"),G=s("site-domain"),d=s("action-btn"),w=s("action-text"),S=s("site-toggle"),_=s("content"),g=s("assist-slider"),O=s("slider-fill"),P=s("slider-thumb"),y=s("assist-hint"),C=s("seg-control"),q=s("seg-pill"),F=s("mode-desc"),k=s("preview"),X=s("link-options"),A=s("vocab-levels"),j=s("vocab-hint"),L={1:"\u53EA\u63B0\u6700\u96BE\u7684\u53E5\u5B50",2:"\u590D\u6742\u53E5\u624D\u63B0",3:"\u590D\u6742\u53E5\u81EA\u52A8\u63B0\uFF0C\u7B80\u5355\u53E5\u4E0D\u6253\u6270",4:"\u5927\u90E8\u5206\u957F\u53E5\u90FD\u4F1A\u63B0",5:"\u5C3D\u91CF\u90FD\u63B0\u5F00"},z={1:{chunkGranularity:"coarse",scanThreshold:"long",sensitivity:5},2:{chunkGranularity:"coarse",scanThreshold:"long",sensitivity:4},3:{chunkGranularity:"medium",scanThreshold:"medium",sensitivity:3},4:{chunkGranularity:"fine",scanThreshold:"short",sensitivity:2},5:{chunkGranularity:"fine",scanThreshold:"short",sensitivity:1}},B={structure:{desc:"\u63B0\u6210\u6BB5\uFF0C\u7F29\u8FDB\u663E\u793A\u4E3B\u4ECE\u5173\u7CFB",intensity:5,html:`
      <span class="line line-main">She finished the project</span>
      <span class="line line-sub1">that no one thought was possible,</span>
      <span class="line line-sub2">before the deadline.</span>
    `},lines:{desc:"\u53EA\u5206\u884C\uFF0C\u4E0D\u52A0\u989D\u5916\u6807\u8BB0",intensity:3,html:`
      <span class="line">She finished the project</span>
      <span class="line">that no one thought was possible,</span>
      <span class="line">before the deadline.</span>
    `},light:{desc:"\u4E0D\u5206\u884C\uFF0C\u6B21\u8981\u90E8\u5206\u53D8\u6DE1",intensity:1,html:'<span class="line line-main">She finished the project</span><span class="dot"> \xB7 </span><span class="line line-sub">that no one thought was possible,</span><span class="dot"> \xB7 </span><span class="line line-sub">before the deadline.</span>'}},b=1,D=5,a=3;function T(t){let e=(t-b)/(D-b)*100;O.style.width=e+"%",P.style.left=e+"%"}function I(t){let e=g.getBoundingClientRect(),m=Math.max(0,Math.min(1,(t-e.left)/e.width));return Math.round(m*(D-b)+b)}var V={zk:"\u521D\u4E2D\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",gz:"\u9AD8\u4E2D\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",gk:"\u9AD8\u8003\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",cet4:"\u56DB\u7EA7\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",cet6:"\u516D\u7EA7\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",ky:"\u8003\u7814\u4EE5\u4E0A\u8BCD\u6C47\u90FD\u6807\u6CE8",adv:"\u53EA\u6807\u6CE8\u8FDB\u9636\u8BCD\u6C47"};function H(t){A.querySelectorAll(".vocab-btn").forEach(e=>{e.classList.toggle("active",e.dataset.level===t)}),j.textContent=V[t]||""}var o=null,c="",l=!1,u=!0;function r(t){return chrome.runtime.sendMessage(t)}function $(t){let e=t.sensitivity;return e>=5?1:e>=4?2:e>=3?3:e>=2?4:5}function U(t){return t>=4?"structure":t>=2?"lines":"light"}function E(){l?(d.className="action-btn is-on",w.textContent="\u663E\u793A\u539F\u6587"):(d.className="action-btn is-off",w.textContent="\u63B0it"),u?(d.style.opacity="1",d.style.pointerEvents="auto"):(d.style.opacity="0.4",d.style.pointerEvents="none")}function M(){_.classList.toggle("disabled",!u||!l)}function x(t){let e=B[t];if(!e)return;let m=C.querySelectorAll(".seg-btn"),f=0;m.forEach((v,h)=>{let n=v.dataset.mode===t;v.classList.toggle("active",n),n&&(f=h)}),q.style.transform=`translateX(${f*100}%)`,F.textContent=e.desc,k.className="display-preview mode-"+t,k.innerHTML=e.html}async function W(){let[t]=await chrome.tabs.query({active:!0,currentWindow:!0});if(o=t??null,o?.url)try{c=new URL(o.url).hostname}catch{c=""}if(R.textContent=c||"\u2014",G.textContent=c||"\u2014",o?.id&&c){let n=await r({type:"getTabState",tabId:o.id,hostname:c});u=n.state!=="disabled",l=n.state==="active"}let e=await r({type:"getConfig"});S.checked=u;let m=$(e);a=m,T(a),y.textContent=L[m];let f=await chrome.storage.sync.get({vocabLevel:"gz"});H(f.vocabLevel);let v=U(e.chunkIntensity);x(v),E(),M(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{g.classList.remove("no-transition"),C.classList.remove("no-transition")})}),d.addEventListener("click",async()=>{!u||!o?.id||(l=!l,l?await r({type:"resumeTab",tabId:o.id}):await r({type:"pauseTab",tabId:o.id}),E(),M())}),S.addEventListener("change",async()=>{if(!c)return;u=(await r({type:"toggleSite",hostname:c})).enabled,u?l=!0:l=!1,E(),M()});let h=!1;g.addEventListener("pointerdown",n=>{h=!0,g.setPointerCapture(n.pointerId);let i=I(n.clientX);i!==a&&(a=i,T(a),y.textContent=L[a])}),g.addEventListener("pointermove",n=>{if(!h)return;let i=I(n.clientX);i!==a&&(a=i,T(a),y.textContent=L[a])}),g.addEventListener("pointerup",async()=>{if(!h)return;h=!1;let n=z[a];await r({type:"updateConfig",config:n})}),A.addEventListener("click",async n=>{let i=n.target.closest(".vocab-btn");if(!i||i.classList.contains("active"))return;let p=i.dataset.level;H(p),await chrome.storage.sync.set({vocabLevel:p})}),C.addEventListener("click",async n=>{let i=n.target.closest(".seg-btn");if(!i||i.classList.contains("active"))return;let p=i.dataset.mode;x(p);let N=B[p];await r({type:"updateConfig",config:{chunkIntensity:N.intensity}})}),X.addEventListener("click",n=>{n.preventDefault(),chrome.runtime.openOptionsPage()})}W();})();
